Skip to content

Commit 1fe012b

Browse files
michaelphamcfclaudetylerpina
authored
feat: scaffold Fragment entity types and GetFragmentParams [DX-926] (#2999)
* feat: scaffold Fragment entity types and GetFragmentParams [DX-926] Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * fix: use ExperienceDimensionKeyMap and narrow slots union in FragmentProps - Replace inline dimensionKeyMap struct with ExperienceDimensionKeyMap (shared named type from experience.ts, mirrors upstream DimensionKeyMap) - Drop TreeNode from slots union — upstream contract (experienceCommonFields) uses ViewNode | FragmentNode | InlineFragmentNode; SDK drops deprecated ViewNode leaving FragmentNode | InlineFragmentNode, matching ExperienceProps.slots exactly - Remove unused TreeNode import from component-type Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: prettier --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com> Co-authored-by: Tyler Pina <tyler.pina@contentful.com>
1 parent d7ab506 commit 1fe012b

2 files changed

Lines changed: 76 additions & 0 deletions

File tree

lib/common-types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2965,6 +2965,8 @@ export type GetExperienceParams = GetSpaceEnvironmentParams & { experienceId: st
29652965
/** @internal */
29662966
export type GetDataAssemblyParams = GetSpaceEnvironmentParams & { dataAssemblyId: string }
29672967
/** @internal */
2968+
export type GetFragmentParams = GetSpaceEnvironmentParams & { fragmentId: string }
2969+
/** @internal */
29682970
export type GetTemplateParams = GetSpaceEnvironmentParams & { templateId: string }
29692971
/** @internal */
29702972
export type GetContentTypeParams = GetSpaceEnvironmentParams & { contentTypeId: string }

lib/entities/fragment.ts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import type { Except } from 'type-fest'
2+
import type {
3+
CursorPaginatedCollectionProp,
4+
CursorPaginationParams,
5+
ExoMetadataProps,
6+
Link,
7+
} from '../common-types'
8+
import type {
9+
ComponentTypeViewport,
10+
DimensionedDesignPropertyValue,
11+
FragmentNode,
12+
} from './component-type'
13+
import type {
14+
ExperienceContentBindings,
15+
ExperienceDimensionKeyMap,
16+
InlineFragmentNode,
17+
} from './experience'
18+
19+
export type FragmentSys = {
20+
id: string
21+
type: 'Fragment'
22+
version: number
23+
space: Link<'Space'>
24+
environment: Link<'Environment'>
25+
componentType: Link<'ComponentType'>
26+
archivedAt?: string
27+
archivedBy?: Link<'User'>
28+
archivedVersion?: number
29+
createdAt: string
30+
updatedAt: string
31+
createdBy: Link<'User'>
32+
updatedBy: Link<'User'>
33+
variant?: string
34+
variantType?: string
35+
variantDimension?: string
36+
publishedAt?: string
37+
publishedVersion?: number
38+
publishedCounter?: number
39+
firstPublishedAt?: string
40+
publishedBy?: Link<'User'> | Link<'AppDefinition'>
41+
localeStatus?: Record<string, 'draft' | 'published' | 'changed'>
42+
}
43+
44+
export type FragmentProps = {
45+
sys: FragmentSys
46+
name: string
47+
description: string
48+
viewports: ComponentTypeViewport[]
49+
designProperties: Record<string, DimensionedDesignPropertyValue>
50+
dimensionKeyMap: ExperienceDimensionKeyMap
51+
contentBindings?: ExperienceContentBindings
52+
metadata?: ExoMetadataProps
53+
slots?: Record<string, Array<FragmentNode | InlineFragmentNode>>
54+
}
55+
56+
export type CreateFragmentProps = Except<FragmentProps, 'sys'> & {
57+
componentTypeId: string
58+
}
59+
60+
export type UpdateFragmentProps = Omit<FragmentProps, 'sys'> & {
61+
sys: {
62+
id: string
63+
type: 'Fragment'
64+
version: number
65+
}
66+
componentTypeId: string
67+
}
68+
69+
export type FragmentQueryOptions = CursorPaginationParams & {
70+
order?: string
71+
[key: string]: unknown
72+
}
73+
74+
export type FragmentCollection = CursorPaginatedCollectionProp<FragmentProps>

0 commit comments

Comments
 (0)