@contentful/experiences-visual-editor-react 1.39.0-alpha-20250528T1342-e28bc3d.0 → 1.39.0-alpha-20250528T1549-bd210e1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/renderApp.js CHANGED
@@ -44712,17 +44712,16 @@ const PrimitiveValueSchema$1 = z.union([
44712
44712
  z.record(z.any(), z.any()),
44713
44713
  z.undefined(),
44714
44714
  ]);
44715
+ const UsedComponentsSchema$1 = z.array(z.object({
44716
+ sys: z.object({
44717
+ type: z.literal('Link'),
44718
+ id: z.string(),
44719
+ linkType: z.literal('Entry'),
44720
+ }),
44721
+ }));
44715
44722
  const uuidKeySchema$1 = z
44716
44723
  .string()
44717
44724
  .regex(/^[a-zA-Z0-9-_]{1,21}$/, { message: 'Does not match /^[a-zA-Z0-9-_]{1,21}$/' });
44718
- /**
44719
- * Property keys for imported components have a limit of 32 characters (to be implemented) while
44720
- * property keys for patterns have a limit of 54 characters (<32-char-variabl-name>_<21-char-nanoid-id>).
44721
- * Because we cannot distinguish between the two in the componentTree, we will use the larger limit for both.
44722
- */
44723
- const propertyKeySchema$1 = z
44724
- .string()
44725
- .regex(/^[a-zA-Z0-9-_]{1,54}$/, { message: 'Does not match /^[a-zA-Z0-9-_]{1,54}$/' });
44726
44725
  const DataSourceSchema$1 = z.record(uuidKeySchema$1, z.object({
44727
44726
  sys: z.object({
44728
44727
  type: z.literal('Link'),
@@ -44730,7 +44729,62 @@ const DataSourceSchema$1 = z.record(uuidKeySchema$1, z.object({
44730
44729
  linkType: z.enum(['Entry', 'Asset']),
44731
44730
  }),
44732
44731
  }));
44732
+ const UnboundValuesSchema$1 = z.record(uuidKeySchema$1, z.object({
44733
+ value: PrimitiveValueSchema$1,
44734
+ }));
44735
+ /**
44736
+ * Property keys for imported components have a limit of 32 characters (to be implemented) while
44737
+ * property keys for patterns have a limit of 54 characters (<32-char-variable-name>_<21-char-nanoid-id>).
44738
+ * Because we cannot distinguish between the two in the componentTree, we will use the larger limit for both.
44739
+ */
44740
+ const propertyKeySchema$1 = z
44741
+ .string()
44742
+ .regex(/^[a-zA-Z0-9-_]{1,54}$/, { message: 'Does not match /^[a-zA-Z0-9-_]{1,54}$/' });
44743
+ const ComponentTreeNodeIdSchema$1 = z
44744
+ .string()
44745
+ .regex(/^[a-zA-Z0-9]{1,8}$/, { message: 'Does not match /^[a-zA-Z0-9]{1,8}$/' });
44746
+ const breakpointsRefinement$1 = (value, ctx) => {
44747
+ if (!value.length || value[0].query !== '*') {
44748
+ ctx.addIssue({
44749
+ code: z.ZodIssueCode.custom,
44750
+ message: `The first breakpoint should include the following attributes: { "query": "*" }`,
44751
+ });
44752
+ }
44753
+ const hasDuplicateIds = value.some((currentBreakpoint, currentBreakpointIndex) => {
44754
+ // check if the current breakpoint id is found in the rest of the array
44755
+ const breakpointIndex = value.findIndex((breakpoint) => breakpoint.id === currentBreakpoint.id);
44756
+ return breakpointIndex !== currentBreakpointIndex;
44757
+ });
44758
+ if (hasDuplicateIds) {
44759
+ ctx.addIssue({
44760
+ code: z.ZodIssueCode.custom,
44761
+ message: `Breakpoint IDs must be unique`,
44762
+ });
44763
+ }
44764
+ // Extract the queries boundary by removing the special characters around it
44765
+ const queries = value.map((bp) => bp.query === '*' ? bp.query : parseInt(bp.query.replace(/px|<|>/, '')));
44766
+ // sort updates queries array in place so we need to create a copy
44767
+ const originalQueries = [...queries];
44768
+ queries.sort((q1, q2) => {
44769
+ if (q1 === '*') {
44770
+ return -1;
44771
+ }
44772
+ if (q2 === '*') {
44773
+ return 1;
44774
+ }
44775
+ return q1 > q2 ? -1 : 1;
44776
+ });
44777
+ if (originalQueries.join('') !== queries.join('')) {
44778
+ ctx.addIssue({
44779
+ code: z.ZodIssueCode.custom,
44780
+ message: `Breakpoints should be ordered from largest to smallest pixel value`,
44781
+ });
44782
+ }
44783
+ };
44733
44784
  const ValuesByBreakpointSchema$1 = z.record(z.lazy(() => PrimitiveValueSchema$1));
44785
+ const BindingSourceTypeEnumSchema$1 = z
44786
+ .array(z.enum(['entry', 'asset', 'manual', 'experience']))
44787
+ .nonempty();
44734
44788
  const DesignValueSchema$1 = z
44735
44789
  .object({
44736
44790
  type: z.literal('DesignValue'),
@@ -44763,8 +44817,6 @@ const ComponentValueSchema$1 = z
44763
44817
  key: z.string(),
44764
44818
  })
44765
44819
  .strict();
44766
- // TODO: finalize schema structure before release
44767
- // https://contentful.atlassian.net/browse/LUMOS-523
44768
44820
  const NoValueSchema$1 = z.object({ type: z.literal('NoValue') }).strict();
44769
44821
  const ComponentPropertyValueSchema$1 = z.discriminatedUnion('type', [
44770
44822
  DesignValueSchema$1,
@@ -44776,41 +44828,12 @@ const ComponentPropertyValueSchema$1 = z.discriminatedUnion('type', [
44776
44828
  ]);
44777
44829
  // TODO: finalize schema structure before release
44778
44830
  // https://contentful.atlassian.net/browse/LUMOS-523
44779
- const VariableMappingSchema$1 = z.object({
44780
- patternPropertyDefinitionId: propertyKeySchema$1,
44781
- type: z.literal('ContentTypeMapping'),
44782
- pathsByContentType: z.record(z.string(), z.object({ path: z.string() })),
44783
- });
44784
- const VariableMappingsSchema$1 = z.record(propertyKeySchema$1, VariableMappingSchema$1);
44785
- // TODO: finalize schema structure before release
44786
- // https://contentful.atlassian.net/browse/LUMOS-523
44787
- const PatternPropertyDefinitionSchema$1 = z.object({
44788
- defaultValue: z
44789
- .record(z.string(), z.object({
44790
- sys: z.object({
44791
- type: z.literal('Link'),
44792
- id: z.string(),
44793
- linkType: z.enum(['Entry']),
44794
- }),
44795
- }))
44796
- .optional(),
44797
- contentTypes: z.record(z.string(), z.object({
44798
- sys: z.object({
44799
- type: z.literal('Link'),
44800
- id: z.string(),
44801
- linkType: z.enum(['ContentType']),
44802
- }),
44803
- })),
44804
- });
44805
- const PatternPropertyDefinitionsSchema$1 = z.record(propertyKeySchema$1, PatternPropertyDefinitionSchema$1);
44806
- // TODO: finalize schema structure before release
44807
- // https://contentful.atlassian.net/browse/LUMOS-523
44808
44831
  const PatternPropertySchema$1 = z.object({
44809
44832
  type: z.literal('BoundValue'),
44810
44833
  path: z.string(),
44811
44834
  contentType: z.string(),
44812
44835
  });
44813
- const PatternPropertysSchema$1 = z.record(propertyKeySchema$1, PatternPropertySchema$1);
44836
+ const PatternPropertiesSchema$1 = z.record(propertyKeySchema$1, PatternPropertySchema$1);
44814
44837
  const BreakpointSchema$1 = z
44815
44838
  .object({
44816
44839
  id: propertyKeySchema$1,
@@ -44820,12 +44843,6 @@ const BreakpointSchema$1 = z
44820
44843
  displayIcon: z.enum(['desktop', 'tablet', 'mobile']).optional(),
44821
44844
  })
44822
44845
  .strict();
44823
- const UnboundValuesSchema$1 = z.record(uuidKeySchema$1, z.object({
44824
- value: PrimitiveValueSchema$1,
44825
- }));
44826
- const ComponentTreeNodeIdSchema$1 = z
44827
- .string()
44828
- .regex(/^[a-zA-Z0-9]{1,8}$/, { message: 'Does not match /^[a-zA-Z0-9]{1,8}$/' });
44829
44846
  // Use helper schema to define a recursive schema with its type correctly below
44830
44847
  const BaseComponentTreeNodeSchema$1 = z.object({
44831
44848
  id: ComponentTreeNodeIdSchema$1.optional(),
@@ -44833,14 +44850,8 @@ const BaseComponentTreeNodeSchema$1 = z.object({
44833
44850
  displayName: z.string().optional(),
44834
44851
  slotId: z.string().optional(),
44835
44852
  variables: z.record(propertyKeySchema$1, ComponentPropertyValueSchema$1),
44836
- patternProperties: PatternPropertysSchema$1.optional(),
44837
- });
44838
- const ComponentTreeNodeSchema$1 = BaseComponentTreeNodeSchema$1.extend({
44839
- children: z.lazy(() => ComponentTreeNodeSchema$1.array()),
44853
+ patternProperties: PatternPropertiesSchema$1.optional(),
44840
44854
  });
44841
- const BindingSourceTypeEnumSchema$1 = z
44842
- .array(z.enum(['entry', 'asset', 'manual', 'experience']))
44843
- .nonempty();
44844
44855
  const ComponentVariableSchema$1 = z.object({
44845
44856
  displayName: z.string().optional(),
44846
44857
  type: DefinitionPropertyTypeSchema$1,
@@ -44861,8 +44872,25 @@ const ComponentVariableSchema$1 = z.object({
44861
44872
  })
44862
44873
  .optional(),
44863
44874
  });
44864
- const ComponentVariablesSchema$1 = z.record(z.string().regex(/^[a-zA-Z0-9-_]{1,54}$/), // Here the key is <variableName>_<nanoidId> so we need to allow for a longer length
44865
- ComponentVariableSchema$1);
44875
+ const ComponentTreeNodeSchema$1 = BaseComponentTreeNodeSchema$1.extend({
44876
+ children: z.lazy(() => ComponentTreeNodeSchema$1.array()),
44877
+ });
44878
+ const ComponentTreeSchema$1 = z
44879
+ .object({
44880
+ breakpoints: z.array(BreakpointSchema$1).superRefine(breakpointsRefinement$1),
44881
+ children: z.array(ComponentTreeNodeSchema$1),
44882
+ schemaVersion: SchemaVersions$1,
44883
+ })
44884
+ .strict();
44885
+ const localeWrapper$1 = (fieldSchema) => z.record(z.string(), fieldSchema);
44886
+
44887
+ z.object({
44888
+ componentTree: localeWrapper$1(ComponentTreeSchema$1),
44889
+ dataSource: localeWrapper$1(DataSourceSchema$1),
44890
+ unboundValues: localeWrapper$1(UnboundValuesSchema$1),
44891
+ usedComponents: localeWrapper$1(UsedComponentsSchema$1).optional(),
44892
+ });
44893
+
44866
44894
  const THUMBNAIL_IDS$1 = [
44867
44895
  'columns',
44868
44896
  'columnsPlusRight',
@@ -44888,6 +44916,37 @@ const THUMBNAIL_IDS$1 = [
44888
44916
  'textColumns',
44889
44917
  'duplex',
44890
44918
  ];
44919
+ // TODO: finalize schema structure before release
44920
+ // https://contentful.atlassian.net/browse/LUMOS-523
44921
+ const VariableMappingSchema$1 = z.object({
44922
+ patternPropertyDefinitionId: propertyKeySchema$1,
44923
+ type: z.literal('ContentTypeMapping'),
44924
+ pathsByContentType: z.record(z.string(), z.object({ path: z.string() })),
44925
+ });
44926
+ // TODO: finalize schema structure before release
44927
+ // https://contentful.atlassian.net/browse/LUMOS-523
44928
+ const PatternPropertyDefinitionSchema$1 = z.object({
44929
+ defaultValue: z
44930
+ .record(z.string(), z.object({
44931
+ sys: z.object({
44932
+ type: z.literal('Link'),
44933
+ id: z.string(),
44934
+ linkType: z.enum(['Entry']),
44935
+ }),
44936
+ }))
44937
+ .optional(),
44938
+ contentTypes: z.record(z.string(), z.object({
44939
+ sys: z.object({
44940
+ type: z.literal('Link'),
44941
+ id: z.string(),
44942
+ linkType: z.enum(['ContentType']),
44943
+ }),
44944
+ })),
44945
+ });
44946
+ const PatternPropertyDefinitionsSchema$1 = z.record(propertyKeySchema$1, PatternPropertyDefinitionSchema$1);
44947
+ const VariableMappingsSchema$1 = z.record(propertyKeySchema$1, VariableMappingSchema$1);
44948
+ const ComponentVariablesSchema$1 = z.record(z.string().regex(/^[a-zA-Z0-9-_]{1,54}$/), // Here the key is <variableName>_<nanoidId> so we need to allow for a longer length
44949
+ ComponentVariableSchema$1);
44891
44950
  const ComponentSettingsSchema$1 = z.object({
44892
44951
  variableDefinitions: ComponentVariablesSchema$1,
44893
44952
  thumbnailId: z.enum(THUMBNAIL_IDS$1).optional(),
@@ -44895,65 +44954,12 @@ const ComponentSettingsSchema$1 = z.object({
44895
44954
  variableMappings: VariableMappingsSchema$1.optional(),
44896
44955
  patternPropertyDefinitions: PatternPropertyDefinitionsSchema$1.optional(),
44897
44956
  });
44898
- const UsedComponentsSchema$1 = z.array(z.object({
44899
- sys: z.object({
44900
- type: z.literal('Link'),
44901
- id: z.string(),
44902
- linkType: z.literal('Entry'),
44903
- }),
44904
- }));
44905
- const breakpointsRefinement$1 = (value, ctx) => {
44906
- if (!value.length || value[0].query !== '*') {
44907
- ctx.addIssue({
44908
- code: z.ZodIssueCode.custom,
44909
- message: `The first breakpoint should include the following attributes: { "query": "*" }`,
44910
- });
44911
- }
44912
- const hasDuplicateIds = value.some((currentBreakpoint, currentBreakpointIndex) => {
44913
- // check if the current breakpoint id is found in the rest of the array
44914
- const breakpointIndex = value.findIndex((breakpoint) => breakpoint.id === currentBreakpoint.id);
44915
- return breakpointIndex !== currentBreakpointIndex;
44916
- });
44917
- if (hasDuplicateIds) {
44918
- ctx.addIssue({
44919
- code: z.ZodIssueCode.custom,
44920
- message: `Breakpoint IDs must be unique`,
44921
- });
44922
- }
44923
- // Extract the queries boundary by removing the special characters around it
44924
- const queries = value.map((bp) => bp.query === '*' ? bp.query : parseInt(bp.query.replace(/px|<|>/, '')));
44925
- // sort updates queries array in place so we need to create a copy
44926
- const originalQueries = [...queries];
44927
- queries.sort((q1, q2) => {
44928
- if (q1 === '*') {
44929
- return -1;
44930
- }
44931
- if (q2 === '*') {
44932
- return 1;
44933
- }
44934
- return q1 > q2 ? -1 : 1;
44935
- });
44936
- if (originalQueries.join('') !== queries.join('')) {
44937
- ctx.addIssue({
44938
- code: z.ZodIssueCode.custom,
44939
- message: `Breakpoints should be ordered from largest to smallest pixel value`,
44940
- });
44941
- }
44942
- };
44943
- const ComponentTreeSchema$1 = z
44944
- .object({
44945
- breakpoints: z.array(BreakpointSchema$1).superRefine(breakpointsRefinement$1),
44946
- children: z.array(ComponentTreeNodeSchema$1),
44947
- schemaVersion: SchemaVersions$1,
44948
- })
44949
- .strict();
44950
- const localeWrapper$1 = (fieldSchema) => z.record(z.string(), fieldSchema);
44951
44957
  z.object({
44952
44958
  componentTree: localeWrapper$1(ComponentTreeSchema$1),
44953
44959
  dataSource: localeWrapper$1(DataSourceSchema$1),
44954
44960
  unboundValues: localeWrapper$1(UnboundValuesSchema$1),
44955
44961
  usedComponents: localeWrapper$1(UsedComponentsSchema$1).optional(),
44956
- componentSettings: localeWrapper$1(ComponentSettingsSchema$1).optional(),
44962
+ componentSettings: localeWrapper$1(ComponentSettingsSchema$1),
44957
44963
  });
44958
44964
 
44959
44965
  z.object({
@@ -48097,17 +48103,16 @@ const PrimitiveValueSchema = z.union([
48097
48103
  z.record(z.any(), z.any()),
48098
48104
  z.undefined(),
48099
48105
  ]);
48106
+ const UsedComponentsSchema = z.array(z.object({
48107
+ sys: z.object({
48108
+ type: z.literal('Link'),
48109
+ id: z.string(),
48110
+ linkType: z.literal('Entry'),
48111
+ }),
48112
+ }));
48100
48113
  const uuidKeySchema = z
48101
48114
  .string()
48102
48115
  .regex(/^[a-zA-Z0-9-_]{1,21}$/, { message: 'Does not match /^[a-zA-Z0-9-_]{1,21}$/' });
48103
- /**
48104
- * Property keys for imported components have a limit of 32 characters (to be implemented) while
48105
- * property keys for patterns have a limit of 54 characters (<32-char-variabl-name>_<21-char-nanoid-id>).
48106
- * Because we cannot distinguish between the two in the componentTree, we will use the larger limit for both.
48107
- */
48108
- const propertyKeySchema = z
48109
- .string()
48110
- .regex(/^[a-zA-Z0-9-_]{1,54}$/, { message: 'Does not match /^[a-zA-Z0-9-_]{1,54}$/' });
48111
48116
  const DataSourceSchema = z.record(uuidKeySchema, z.object({
48112
48117
  sys: z.object({
48113
48118
  type: z.literal('Link'),
@@ -48115,7 +48120,62 @@ const DataSourceSchema = z.record(uuidKeySchema, z.object({
48115
48120
  linkType: z.enum(['Entry', 'Asset']),
48116
48121
  }),
48117
48122
  }));
48123
+ const UnboundValuesSchema = z.record(uuidKeySchema, z.object({
48124
+ value: PrimitiveValueSchema,
48125
+ }));
48126
+ /**
48127
+ * Property keys for imported components have a limit of 32 characters (to be implemented) while
48128
+ * property keys for patterns have a limit of 54 characters (<32-char-variable-name>_<21-char-nanoid-id>).
48129
+ * Because we cannot distinguish between the two in the componentTree, we will use the larger limit for both.
48130
+ */
48131
+ const propertyKeySchema = z
48132
+ .string()
48133
+ .regex(/^[a-zA-Z0-9-_]{1,54}$/, { message: 'Does not match /^[a-zA-Z0-9-_]{1,54}$/' });
48134
+ const ComponentTreeNodeIdSchema = z
48135
+ .string()
48136
+ .regex(/^[a-zA-Z0-9]{1,8}$/, { message: 'Does not match /^[a-zA-Z0-9]{1,8}$/' });
48137
+ const breakpointsRefinement = (value, ctx) => {
48138
+ if (!value.length || value[0].query !== '*') {
48139
+ ctx.addIssue({
48140
+ code: z.ZodIssueCode.custom,
48141
+ message: `The first breakpoint should include the following attributes: { "query": "*" }`,
48142
+ });
48143
+ }
48144
+ const hasDuplicateIds = value.some((currentBreakpoint, currentBreakpointIndex) => {
48145
+ // check if the current breakpoint id is found in the rest of the array
48146
+ const breakpointIndex = value.findIndex((breakpoint) => breakpoint.id === currentBreakpoint.id);
48147
+ return breakpointIndex !== currentBreakpointIndex;
48148
+ });
48149
+ if (hasDuplicateIds) {
48150
+ ctx.addIssue({
48151
+ code: z.ZodIssueCode.custom,
48152
+ message: `Breakpoint IDs must be unique`,
48153
+ });
48154
+ }
48155
+ // Extract the queries boundary by removing the special characters around it
48156
+ const queries = value.map((bp) => bp.query === '*' ? bp.query : parseInt(bp.query.replace(/px|<|>/, '')));
48157
+ // sort updates queries array in place so we need to create a copy
48158
+ const originalQueries = [...queries];
48159
+ queries.sort((q1, q2) => {
48160
+ if (q1 === '*') {
48161
+ return -1;
48162
+ }
48163
+ if (q2 === '*') {
48164
+ return 1;
48165
+ }
48166
+ return q1 > q2 ? -1 : 1;
48167
+ });
48168
+ if (originalQueries.join('') !== queries.join('')) {
48169
+ ctx.addIssue({
48170
+ code: z.ZodIssueCode.custom,
48171
+ message: `Breakpoints should be ordered from largest to smallest pixel value`,
48172
+ });
48173
+ }
48174
+ };
48118
48175
  const ValuesByBreakpointSchema = z.record(z.lazy(() => PrimitiveValueSchema));
48176
+ const BindingSourceTypeEnumSchema = z
48177
+ .array(z.enum(['entry', 'asset', 'manual', 'experience']))
48178
+ .nonempty();
48119
48179
  const DesignValueSchema = z
48120
48180
  .object({
48121
48181
  type: z.literal('DesignValue'),
@@ -48148,8 +48208,6 @@ const ComponentValueSchema = z
48148
48208
  key: z.string(),
48149
48209
  })
48150
48210
  .strict();
48151
- // TODO: finalize schema structure before release
48152
- // https://contentful.atlassian.net/browse/LUMOS-523
48153
48211
  const NoValueSchema = z.object({ type: z.literal('NoValue') }).strict();
48154
48212
  const ComponentPropertyValueSchema = z.discriminatedUnion('type', [
48155
48213
  DesignValueSchema,
@@ -48161,41 +48219,12 @@ const ComponentPropertyValueSchema = z.discriminatedUnion('type', [
48161
48219
  ]);
48162
48220
  // TODO: finalize schema structure before release
48163
48221
  // https://contentful.atlassian.net/browse/LUMOS-523
48164
- const VariableMappingSchema = z.object({
48165
- patternPropertyDefinitionId: propertyKeySchema,
48166
- type: z.literal('ContentTypeMapping'),
48167
- pathsByContentType: z.record(z.string(), z.object({ path: z.string() })),
48168
- });
48169
- const VariableMappingsSchema = z.record(propertyKeySchema, VariableMappingSchema);
48170
- // TODO: finalize schema structure before release
48171
- // https://contentful.atlassian.net/browse/LUMOS-523
48172
- const PatternPropertyDefinitionSchema = z.object({
48173
- defaultValue: z
48174
- .record(z.string(), z.object({
48175
- sys: z.object({
48176
- type: z.literal('Link'),
48177
- id: z.string(),
48178
- linkType: z.enum(['Entry']),
48179
- }),
48180
- }))
48181
- .optional(),
48182
- contentTypes: z.record(z.string(), z.object({
48183
- sys: z.object({
48184
- type: z.literal('Link'),
48185
- id: z.string(),
48186
- linkType: z.enum(['ContentType']),
48187
- }),
48188
- })),
48189
- });
48190
- const PatternPropertyDefinitionsSchema = z.record(propertyKeySchema, PatternPropertyDefinitionSchema);
48191
- // TODO: finalize schema structure before release
48192
- // https://contentful.atlassian.net/browse/LUMOS-523
48193
48222
  const PatternPropertySchema = z.object({
48194
48223
  type: z.literal('BoundValue'),
48195
48224
  path: z.string(),
48196
48225
  contentType: z.string(),
48197
48226
  });
48198
- const PatternPropertysSchema = z.record(propertyKeySchema, PatternPropertySchema);
48227
+ const PatternPropertiesSchema = z.record(propertyKeySchema, PatternPropertySchema);
48199
48228
  const BreakpointSchema = z
48200
48229
  .object({
48201
48230
  id: propertyKeySchema,
@@ -48205,12 +48234,6 @@ const BreakpointSchema = z
48205
48234
  displayIcon: z.enum(['desktop', 'tablet', 'mobile']).optional(),
48206
48235
  })
48207
48236
  .strict();
48208
- const UnboundValuesSchema = z.record(uuidKeySchema, z.object({
48209
- value: PrimitiveValueSchema,
48210
- }));
48211
- const ComponentTreeNodeIdSchema = z
48212
- .string()
48213
- .regex(/^[a-zA-Z0-9]{1,8}$/, { message: 'Does not match /^[a-zA-Z0-9]{1,8}$/' });
48214
48237
  // Use helper schema to define a recursive schema with its type correctly below
48215
48238
  const BaseComponentTreeNodeSchema = z.object({
48216
48239
  id: ComponentTreeNodeIdSchema.optional(),
@@ -48218,14 +48241,8 @@ const BaseComponentTreeNodeSchema = z.object({
48218
48241
  displayName: z.string().optional(),
48219
48242
  slotId: z.string().optional(),
48220
48243
  variables: z.record(propertyKeySchema, ComponentPropertyValueSchema),
48221
- patternProperties: PatternPropertysSchema.optional(),
48222
- });
48223
- const ComponentTreeNodeSchema = BaseComponentTreeNodeSchema.extend({
48224
- children: z.lazy(() => ComponentTreeNodeSchema.array()),
48244
+ patternProperties: PatternPropertiesSchema.optional(),
48225
48245
  });
48226
- const BindingSourceTypeEnumSchema = z
48227
- .array(z.enum(['entry', 'asset', 'manual', 'experience']))
48228
- .nonempty();
48229
48246
  const ComponentVariableSchema = z.object({
48230
48247
  displayName: z.string().optional(),
48231
48248
  type: DefinitionPropertyTypeSchema,
@@ -48246,8 +48263,25 @@ const ComponentVariableSchema = z.object({
48246
48263
  })
48247
48264
  .optional(),
48248
48265
  });
48249
- const ComponentVariablesSchema = z.record(z.string().regex(/^[a-zA-Z0-9-_]{1,54}$/), // Here the key is <variableName>_<nanoidId> so we need to allow for a longer length
48250
- ComponentVariableSchema);
48266
+ const ComponentTreeNodeSchema = BaseComponentTreeNodeSchema.extend({
48267
+ children: z.lazy(() => ComponentTreeNodeSchema.array()),
48268
+ });
48269
+ const ComponentTreeSchema = z
48270
+ .object({
48271
+ breakpoints: z.array(BreakpointSchema).superRefine(breakpointsRefinement),
48272
+ children: z.array(ComponentTreeNodeSchema),
48273
+ schemaVersion: SchemaVersions,
48274
+ })
48275
+ .strict();
48276
+ const localeWrapper = (fieldSchema) => z.record(z.string(), fieldSchema);
48277
+
48278
+ z.object({
48279
+ componentTree: localeWrapper(ComponentTreeSchema),
48280
+ dataSource: localeWrapper(DataSourceSchema),
48281
+ unboundValues: localeWrapper(UnboundValuesSchema),
48282
+ usedComponents: localeWrapper(UsedComponentsSchema).optional(),
48283
+ });
48284
+
48251
48285
  const THUMBNAIL_IDS = [
48252
48286
  'columns',
48253
48287
  'columnsPlusRight',
@@ -48273,6 +48307,37 @@ const THUMBNAIL_IDS = [
48273
48307
  'textColumns',
48274
48308
  'duplex',
48275
48309
  ];
48310
+ // TODO: finalize schema structure before release
48311
+ // https://contentful.atlassian.net/browse/LUMOS-523
48312
+ const VariableMappingSchema = z.object({
48313
+ patternPropertyDefinitionId: propertyKeySchema,
48314
+ type: z.literal('ContentTypeMapping'),
48315
+ pathsByContentType: z.record(z.string(), z.object({ path: z.string() })),
48316
+ });
48317
+ // TODO: finalize schema structure before release
48318
+ // https://contentful.atlassian.net/browse/LUMOS-523
48319
+ const PatternPropertyDefinitionSchema = z.object({
48320
+ defaultValue: z
48321
+ .record(z.string(), z.object({
48322
+ sys: z.object({
48323
+ type: z.literal('Link'),
48324
+ id: z.string(),
48325
+ linkType: z.enum(['Entry']),
48326
+ }),
48327
+ }))
48328
+ .optional(),
48329
+ contentTypes: z.record(z.string(), z.object({
48330
+ sys: z.object({
48331
+ type: z.literal('Link'),
48332
+ id: z.string(),
48333
+ linkType: z.enum(['ContentType']),
48334
+ }),
48335
+ })),
48336
+ });
48337
+ const PatternPropertyDefinitionsSchema = z.record(propertyKeySchema, PatternPropertyDefinitionSchema);
48338
+ const VariableMappingsSchema = z.record(propertyKeySchema, VariableMappingSchema);
48339
+ const ComponentVariablesSchema = z.record(z.string().regex(/^[a-zA-Z0-9-_]{1,54}$/), // Here the key is <variableName>_<nanoidId> so we need to allow for a longer length
48340
+ ComponentVariableSchema);
48276
48341
  const ComponentSettingsSchema = z.object({
48277
48342
  variableDefinitions: ComponentVariablesSchema,
48278
48343
  thumbnailId: z.enum(THUMBNAIL_IDS).optional(),
@@ -48280,65 +48345,12 @@ const ComponentSettingsSchema = z.object({
48280
48345
  variableMappings: VariableMappingsSchema.optional(),
48281
48346
  patternPropertyDefinitions: PatternPropertyDefinitionsSchema.optional(),
48282
48347
  });
48283
- const UsedComponentsSchema = z.array(z.object({
48284
- sys: z.object({
48285
- type: z.literal('Link'),
48286
- id: z.string(),
48287
- linkType: z.literal('Entry'),
48288
- }),
48289
- }));
48290
- const breakpointsRefinement = (value, ctx) => {
48291
- if (!value.length || value[0].query !== '*') {
48292
- ctx.addIssue({
48293
- code: z.ZodIssueCode.custom,
48294
- message: `The first breakpoint should include the following attributes: { "query": "*" }`,
48295
- });
48296
- }
48297
- const hasDuplicateIds = value.some((currentBreakpoint, currentBreakpointIndex) => {
48298
- // check if the current breakpoint id is found in the rest of the array
48299
- const breakpointIndex = value.findIndex((breakpoint) => breakpoint.id === currentBreakpoint.id);
48300
- return breakpointIndex !== currentBreakpointIndex;
48301
- });
48302
- if (hasDuplicateIds) {
48303
- ctx.addIssue({
48304
- code: z.ZodIssueCode.custom,
48305
- message: `Breakpoint IDs must be unique`,
48306
- });
48307
- }
48308
- // Extract the queries boundary by removing the special characters around it
48309
- const queries = value.map((bp) => bp.query === '*' ? bp.query : parseInt(bp.query.replace(/px|<|>/, '')));
48310
- // sort updates queries array in place so we need to create a copy
48311
- const originalQueries = [...queries];
48312
- queries.sort((q1, q2) => {
48313
- if (q1 === '*') {
48314
- return -1;
48315
- }
48316
- if (q2 === '*') {
48317
- return 1;
48318
- }
48319
- return q1 > q2 ? -1 : 1;
48320
- });
48321
- if (originalQueries.join('') !== queries.join('')) {
48322
- ctx.addIssue({
48323
- code: z.ZodIssueCode.custom,
48324
- message: `Breakpoints should be ordered from largest to smallest pixel value`,
48325
- });
48326
- }
48327
- };
48328
- const ComponentTreeSchema = z
48329
- .object({
48330
- breakpoints: z.array(BreakpointSchema).superRefine(breakpointsRefinement),
48331
- children: z.array(ComponentTreeNodeSchema),
48332
- schemaVersion: SchemaVersions,
48333
- })
48334
- .strict();
48335
- const localeWrapper = (fieldSchema) => z.record(z.string(), fieldSchema);
48336
48348
  z.object({
48337
48349
  componentTree: localeWrapper(ComponentTreeSchema),
48338
48350
  dataSource: localeWrapper(DataSourceSchema),
48339
48351
  unboundValues: localeWrapper(UnboundValuesSchema),
48340
48352
  usedComponents: localeWrapper(UsedComponentsSchema).optional(),
48341
- componentSettings: localeWrapper(ComponentSettingsSchema).optional(),
48353
+ componentSettings: localeWrapper(ComponentSettingsSchema),
48342
48354
  });
48343
48355
 
48344
48356
  z.object({