Skip to content

Commit

Permalink
chore: update validators for pre-binding functionality [LUMOS-543] (#975
Browse files Browse the repository at this point in the history
)

* chore: update validators for pre-binding functionality

* fix: adjust variable schema to be less of an intrusive change

* chore: update comments
  • Loading branch information
chasepoirier authored Feb 4, 2025
1 parent 73638f0 commit 5bea055
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions packages/validators/src/schemas/v2023_09_28/experience.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,22 @@ const ComponentValueSchema = z
})
.strict();

// TODO: finalize schema structure before release
// https://contentful.atlassian.net/browse/LUMOS-523
const EmptyObjectSchema = z.object({ type: z.undefined() });

const ComponentPropertyValueSchema = z.discriminatedUnion('type', [
DesignValueSchema,
BoundValueSchema,
UnboundValueSchema,
HyperlinkValueSchema,
ComponentValueSchema,
EmptyObjectSchema,
]);

export type ComponentPropertyValue = z.infer<typeof ComponentPropertyValueSchema>;

// TODO: finalized schema structure before release
// TODO: finalize schema structure before release
// https://contentful.atlassian.net/browse/LUMOS-523
const VariableMappingSchema = z.object({
patternPropertyDefinitionId: propertyKeySchema,
Expand All @@ -106,13 +111,16 @@ const VariableMappingSchema = z.object({

const VariableMappingsSchema = z.record(propertyKeySchema, VariableMappingSchema);

// TODO: finalized schema structure before release
// TODO: finalize schema structure before release
// https://contentful.atlassian.net/browse/LUMOS-523
const PatternPropertyDefinitionSchema = z.object({
defaultValue: z.object({
path: z.string(),
type: z.literal('BoundValue'),
}),
defaultValue: z.union([
z.object({
path: z.string(),
type: z.literal('BoundValue'),
}),
z.null(),
]),
contentTypes: z.record(z.string(), z.any()),
});

Expand All @@ -121,7 +129,7 @@ const PatternPropertyDefinitionsSchema = z.record(
PatternPropertyDefinitionSchema,
);

// TODO: finalized schema structure before release
// TODO: finalize schema structure before release
// https://contentful.atlassian.net/browse/LUMOS-523
const PatternPropertySchema = z.object({
type: z.literal('BoundValue'),
Expand Down

0 comments on commit 5bea055

Please sign in to comment.