diff --git a/docsite/patches/cf-json-schema-viz+0.3.0.patch b/docsite/patches/cf-json-schema-viz+0.3.0.patch index d37d9504..318d0944 100644 --- a/docsite/patches/cf-json-schema-viz+0.3.0.patch +++ b/docsite/patches/cf-json-schema-viz+0.3.0.patch @@ -11,7 +11,7 @@ index 0536c69..be6274b 100644 type JsonSchemaProps = Partial & { diff --git a/node_modules/cf-json-schema-viz/dist/index.js b/node_modules/cf-json-schema-viz/dist/index.js -index b23316c..ef8be1e 100644 +index b23316c..d89b3ea 100644 --- a/node_modules/cf-json-schema-viz/dist/index.js +++ b/node_modules/cf-json-schema-viz/dist/index.js @@ -41,19 +41,19 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge @@ -3462,7 +3462,19 @@ index b23316c..ef8be1e 100644 } return [makeChoice(schemaNode)]; }, [schemaNode]); -@@ -8468,22 +8501,6 @@ var TopLevelSchemaRow = ({ +@@ -8313,7 +8346,10 @@ var SchemaRow = React2.memo( + ); + const { selectedChoice, setSelectedChoice, choices } = useChoices(schemaNode); + const typeToShow = selectedChoice.type; +- const description = isRegularNode(typeToShow) ? typeToShow.annotations.description : null; ++ let description = isRegularNode(typeToShow) ? typeToShow.annotations.description : null; ++ if ((description === null || description === void 0) && "annotations" in schemaNode && (schemaNode.annotations?.description !== null && schemaNode.annotations?.description !== void 0)) { ++ description = schemaNode.annotations?.description; ++ } + const rootLevel = renderRootTreeLines ? 1 : 2; + const childNodes = React2.useMemo(() => visibleChildren(typeToShow), [typeToShow]); + const combiner = isRegularNode(schemaNode) && schemaNode.combiners?.length ? schemaNode.combiners[0] : null; +@@ -8468,22 +8504,6 @@ var TopLevelSchemaRow = ({ [schemaNode.fragment] ); const hasVendorProperties = totalVendorExtensions > 0; @@ -3485,7 +3497,7 @@ index b23316c..ef8be1e 100644 if (isRegularNode(schemaNode) && choices.length > 1) { const combiner = isRegularNode(schemaNode) && schemaNode.combiners?.length ? schemaNode.combiners[0] : null; return /* @__PURE__ */ jsxs(Fragment, { children: [ -@@ -8517,6 +8534,22 @@ var TopLevelSchemaRow = ({ +@@ -8517,6 +8537,22 @@ var TopLevelSchemaRow = ({ ) : combiner ? /* @__PURE__ */ jsx(SchemaRow, { schemaNode: selectedChoice.type, nestingLevel }) : null ] }); } @@ -3508,7 +3520,7 @@ index b23316c..ef8be1e 100644 if (isComplexArray(schemaNode) && isPureObjectNode(schemaNode.children[0])) { const validations = isRegularNode(schemaNode) ? getValidationsFromSchema(schemaNode) : {}; return /* @__PURE__ */ jsxs(Fragment, { children: [ -@@ -8550,6 +8583,7 @@ var JsonSchemaViewer = ({ +@@ -8550,6 +8586,7 @@ var JsonSchemaViewer = ({ disableCrumbs, nodeHasChanged, skipTopLevelDescription, @@ -3516,7 +3528,7 @@ index b23316c..ef8be1e 100644 ...rest }) => { const options = React2.useMemo( -@@ -8562,7 +8596,8 @@ var JsonSchemaViewer = ({ +@@ -8562,7 +8599,8 @@ var JsonSchemaViewer = ({ hideExamples, renderRootTreeLines, disableCrumbs, @@ -3526,7 +3538,7 @@ index b23316c..ef8be1e 100644 }), [ defaultExpandedDepth, -@@ -8573,7 +8608,8 @@ var JsonSchemaViewer = ({ +@@ -8573,7 +8611,8 @@ var JsonSchemaViewer = ({ hideExamples, renderRootTreeLines, disableCrumbs, diff --git a/src/backend/common/infrastructure/Atomic.ts b/src/backend/common/infrastructure/Atomic.ts index 938d3adf..163b3366 100644 --- a/src/backend/common/infrastructure/Atomic.ts +++ b/src/backend/common/infrastructure/Atomic.ts @@ -417,12 +417,29 @@ export interface ScrobbleRangeResult { export const REFRESH_STALE_DEFAULT = 60; -export const durationValueSchema = z.union([z.number(), z.string()]).meta({ - description: stripIndents`A duration of time as either +/** A number of seconds */ +export const secondsSchema = z.number().meta({ + description: 'number of seconds', + example: [60, 3600], + title: 'Seconds' +}); + + +/** A string representing a number and unit of time comptabile with dayjs */ +export const durationStringSchema = z.string().meta({ + description: 'a string containing a number and a unit of time compatible with dayjs', + example:["1 hour", "4 days"], + title: 'Duration Value' +}) + +export const durationValueSchema = z.xor([secondsSchema, durationStringSchema]); + +// .meta({ +// description: stripIndents`A duration of time as either - * a number of seconds - * or a string containing a number and a unit of time compatible with dayjs`, - example: [60, 3600, "1 hour", "4 days"]}); +// * a number of seconds +// * or a string containing a number and a unit of time compatible with dayjs`, +// example: [60, 3600, "1 hour", "4 days"]}); /** * A duration of time * diff --git a/src/backend/common/infrastructure/config/database.ts b/src/backend/common/infrastructure/config/database.ts index 6ceb7d48..5367d480 100644 --- a/src/backend/common/infrastructure/config/database.ts +++ b/src/backend/common/infrastructure/config/database.ts @@ -36,7 +36,9 @@ export type RetentionValue = z.infer; export const rententionGranularDurationValueSchema = z.object({ failed: durationValueSchema.optional(), completed: durationValueSchema.optional(), - duped: durationValueSchema.optional(), + duped: durationValueSchema.optional() +}).meta({ + description: 'Individual duration policies based on the state of the Play' }); export type RententionGranularDurationValue = z.infer; @@ -77,7 +79,9 @@ export const retentionConfigValueSchema = z.union([ ]); export type RetentionConfigValue = z.infer; -export const compactablePropertySchema = z.enum(['transform', 'input']); +export const compactablePropertySchema = z.enum(['transform', 'input']).meta({ + description: 'The type of data to compact on the Play' +}); export type CompactableProperty = z.infer; @@ -108,22 +112,22 @@ export const retentionOptionSchema = z.union([retentionOptionDurationSchema, ret export type RetentionOption = z.infer; export const retentionConfigDurationValueSchema = z.object({ - deleteAfter: retentionConfigValueDurationValueSchema.optional(), - compactAfter: retentionConfigValueDurationValueSchema.optional(), - compact: z.array(compactablePropertySchema).optional(), + deleteAfter: retentionConfigValueDurationValueSchema.optional().meta({description: 'Delete Plays using these retention policies'}), + compactAfter: retentionConfigValueDurationValueSchema.optional().meta({description: 'Compact Plays using these retention policies'}), + compact: z.array(compactablePropertySchema).optional().meta({ description: 'The type of data to compact on the Play'}) }); export type RetentionConfigDurationValue = z.infer; export const retentionConfigDurationSchema = z.object({ - deleteAfter: retentionConfigValueDurationSchema.optional(), - compactAfter: retentionConfigValueDurationSchema.optional(), + deleteAfter: retentionConfigValueDurationSchema.optional().meta({description: 'test'}), + compactAfter: retentionConfigValueDurationSchema.optional().meta({description: 'test'}), compact: z.array(compactablePropertySchema).optional(), }); export type RetentionConfigDuration = z.infer; export const retentionConfigRetentionValueSchema = z.object({ - deleteAfter: retentionConfigValueRetentionValueSchema.optional(), - compactAfter: retentionConfigValueRetentionValueSchema.optional(), + deleteAfter: retentionConfigValueRetentionValueSchema.optional().meta({description: 'test'}), + compactAfter: retentionConfigValueRetentionValueSchema.optional().meta({description: 'test'}), compact: z.array(compactablePropertySchema).optional(), }); export type RetentionConfigRetentionValue = z.infer; @@ -136,8 +140,8 @@ export const retentionConfigSchema = z.union([ export type RetentionConfig = z.infer; export const retentionOptionsSchema = z.object({ - deleteAfter: retentionOptionDurationSchema, - compactAfter: retentionOptionRetentionValueSchema, + deleteAfter: retentionOptionDurationSchema.meta({description: 'test'}), + compactAfter: retentionOptionRetentionValueSchema.meta({description: 'test'}), compact: z.array(compactablePropertySchema), }); diff --git a/src/backend/utils/SchemaDocsStaticUtils.ts b/src/backend/utils/SchemaDocsStaticUtils.ts index 8edbce98..d2a81731 100644 --- a/src/backend/utils/SchemaDocsStaticUtils.ts +++ b/src/backend/utils/SchemaDocsStaticUtils.ts @@ -11,7 +11,7 @@ mkdirSync(resolve(projectRootDir, 'docsite/static/schemas'), {recursive: true}); const jsonSchema = z.toJSONSchema(koitoClientConfigSchema, { io: "output", - //reused: "ref", + reused: "inline", unrepresentable: "any", override: (ctx) => { //const def = ctx.zodSchema._zod.def;