@case-framework/survey-core 0.8.0 → 0.9.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localization-1lzNpyFX.mjs","names":[],"sources":["../src/calendar-date.ts","../src/expressions/tree.ts","../src/expressions/references.ts","../src/survey/responses/value-schema.ts","../src/expressions/schema.ts","../src/schema/annotations.ts","../src/schema/string-record.ts","../src/survey/responses/value-types.ts","../src/survey/composition/content-schema.ts","../src/survey/composition/schema.ts","../src/survey/utils/content.ts","../src/survey/utils/localization.ts"],"sourcesContent":["import { UTCDate } from \"@date-fns/utc\";\nimport { addDays } from \"date-fns/addDays\";\nimport { addMonths } from \"date-fns/addMonths\";\nimport { addYears } from \"date-fns/addYears\";\nimport { differenceInCalendarDays } from \"date-fns/differenceInCalendarDays\";\nimport { differenceInMonths } from \"date-fns/differenceInMonths\";\nimport { differenceInYears } from \"date-fns/differenceInYears\";\nimport { format } from \"date-fns/format\";\nimport { z } from \"zod\";\n\n/** Gregorian calendar values, without a time or timezone. Precision is part of the value. */\nexport type CalendarDate = string;\nexport type CalendarDatePrecision = \"year\" | \"year-month\" | \"year-month-day\";\nexport const CALENDAR_DATE_UNITS = [\"years\", \"months\", \"days\"] as const;\nexport type CalendarDateUnit = (typeof CALENDAR_DATE_UNITS)[number];\nexport const isCalendarDateUnit = (value: unknown): value is CalendarDateUnit =>\n CALENDAR_DATE_UNITS.includes(value as CalendarDateUnit);\nconst pad = (n: number, width = 2) => String(n).padStart(width, \"0\");\nconst daysInMonth = (year: number, month: number) =>\n month === 2\n ? year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0)\n ? 29\n : 28\n : [4, 6, 9, 11].includes(month)\n ? 30\n : 31;\n\nexport function isCalendarDate(value: unknown): value is CalendarDate {\n if (typeof value !== \"string\" || !/^\\d{4}(?:-\\d{2}(?:-\\d{2})?)?$/.test(value)) return false;\n const [year, month, day] = value.split(\"-\").map(Number);\n return (\n year >= 1 &&\n year <= 9999 &&\n (month === undefined ||\n (month >= 1 &&\n month <= 12 &&\n (day === undefined || (day >= 1 && day <= daysInMonth(year, month)))))\n );\n}\n/** A calendar date with day precision, as used for the session's current date. */\nexport const calendarDaySchema = z\n .string()\n .refine((value) => isCalendarDate(value) && value.length === 10, \"Expected a YYYY-MM-DD date\");\nexport function calendarDatePrecision(value: CalendarDate): CalendarDatePrecision {\n if (!isCalendarDate(value)) throw new Error(`Invalid calendar date: ${value}`);\n return value.length === 4 ? \"year\" : value.length === 7 ? \"year-month\" : \"year-month-day\";\n}\nexport function calendarDateFromLocalDate(\n date: Date,\n precision: CalendarDatePrecision = \"year-month-day\",\n): CalendarDate {\n const value = [pad(date.getFullYear(), 4), pad(date.getMonth() + 1), pad(date.getDate())]\n .slice(0, precision === \"year\" ? 1 : precision === \"year-month\" ? 2 : 3)\n .join(\"-\");\n if (!isCalendarDate(value)) throw new Error(\"Invalid calendar date\");\n return value;\n}\n/** Adapter for calendar widgets only. Never serialize this Date as an instant. */\nexport function calendarDateToLocalDate(value: CalendarDate): Date {\n calendarDatePrecision(value);\n const [year, month = 1, day = 1] = value.split(\"-\").map(Number);\n const date = new Date(0);\n date.setFullYear(year, month - 1, day);\n date.setHours(12, 0, 0, 0);\n return date;\n}\nexport function calendarDateBounds(value: CalendarDate): [CalendarDate, CalendarDate] {\n calendarDatePrecision(value);\n const [year, month] = value.split(\"-\").map(Number);\n if (value.length === 4) return [`${value}-01-01`, `${value}-12-31`];\n if (value.length === 7) return [`${value}-01`, `${value}-${pad(daysInMonth(year, month))}`];\n return [value, value];\n}\n/** Ordering requires equal precision; callers must explicitly choose interval semantics otherwise. */\nexport function compareCalendarDates(a: CalendarDate, b: CalendarDate): number | undefined {\n if (!isCalendarDate(a) || !isCalendarDate(b) || a.length !== b.length) return undefined;\n return a === b ? 0 : a < b ? -1 : 1;\n}\n// UTCDate keeps date-fns calendar arithmetic independent of the host timezone and DST.\nfunction utcDate(value: CalendarDate): UTCDate {\n const [year, month = 1, day = 1] = value.split(\"-\").map(Number);\n // The Date constructor maps years 0-99 to 1900-1999; setFullYear does not.\n const date = new UTCDate(0);\n date.setFullYear(year, month - 1, day);\n return date;\n}\nfunction fromUtcDate(date: UTCDate, precision: CalendarDatePrecision): CalendarDate | undefined {\n const value = `${pad(date.getFullYear(), 4)}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;\n const result = value.slice(0, precision === \"year\" ? 4 : precision === \"year-month\" ? 7 : 10);\n return isCalendarDate(result) ? result : undefined;\n}\n// Minimum value length (YYYY, YYYY-MM, YYYY-MM-DD) at which a unit is available.\nconst unitLength: Record<CalendarDateUnit, number> = { years: 4, months: 7, days: 10 };\nexport function addCalendarDate(\n value: CalendarDate,\n amount: number,\n unit: CalendarDateUnit,\n): CalendarDate | undefined {\n if (!isCalendarDate(value) || !Number.isSafeInteger(amount)) return undefined;\n if (amount === 0) return value;\n if (value.length < unitLength[unit]) return undefined;\n const add = unit === \"days\" ? addDays : unit === \"months\" ? addMonths : addYears;\n return fromUtcDate(add(utcDate(value), amount), calendarDatePrecision(value));\n}\n/**\n * Signed number of completed units in a - b. Mixed precisions are compared at the coarser\n * one; a unit finer than that precision is unavailable.\n */\nexport function differenceCalendarDates(\n a: CalendarDate,\n b: CalendarDate,\n unit: CalendarDateUnit,\n): number | undefined {\n if (!isCalendarDate(a) || !isCalendarDate(b)) return undefined;\n const length = Math.min(a.length, b.length);\n if (length < unitLength[unit]) return undefined;\n const later = utcDate(a.slice(0, length)),\n earlier = utcDate(b.slice(0, length));\n return unit === \"days\"\n ? differenceInCalendarDays(later, earlier)\n : unit === \"months\"\n ? differenceInMonths(later, earlier)\n : differenceInYears(later, earlier);\n}\n\n/** Partial dates retain their precision even if a display pattern requests absent components. */\nexport function formatCalendarDate(value: CalendarDate, pattern: string): string {\n calendarDatePrecision(value);\n if (value.length !== 10) return value;\n return format(utcDate(value), pattern);\n}\n","/** Shared traversal and operand helpers for the canonical expression tree. */\nimport type { ExpressionOf, ExpressionPath, JsonExpression } from \"./schema\";\n\n/** Fail an exhaustive node or function switch if a new variant is not handled. */\nexport function unreachable(value: never): never {\n throw new Error(`Unsupported expression node: ${JSON.stringify(value)}`);\n}\n\n/** Convert unfinished editor operands to serializable null gaps, including sparse array indexes. */\nexport function expressionArguments(\n args: readonly (JsonExpression | null | undefined)[],\n): (JsonExpression | null)[] {\n return Array.from(args, (arg) => arg ?? null);\n}\n\n/** Read an operand, treating a missing or null argument as undefined. */\nexport function operand(\n args: readonly (JsonExpression | null)[] | undefined,\n index: number,\n): JsonExpression | undefined {\n return args?.[index] ?? undefined;\n}\n\n/** Require a handler for every expression node type. */\nexport type ExpressionVisitor<T> = {\n [K in JsonExpression[\"type\"]]: (node: ExpressionOf<K>, path: ExpressionPath) => T;\n};\n\n/** Dispatch one node to its typed handler; use transformExpression to recurse into children. */\nexport function visitExpression<T>(\n node: JsonExpression,\n handlers: ExpressionVisitor<T>,\n path: ExpressionPath = [],\n): T {\n switch (node.type) {\n case \"const\":\n return handlers.const(node, path);\n case \"responseVariable\":\n return handlers.responseVariable(node, path);\n case \"ownerState\":\n return handlers.ownerState(node, path);\n case \"contextVariable\":\n return handlers.contextVariable(node, path);\n case \"function\":\n return handlers.function(node, path);\n default:\n return unreachable(node);\n }\n}\n\n/**\n * Rewrite every node after its children. The path points to the node in the original tree;\n * argument positions and null editor gaps are preserved for diagnostics and remapping.\n */\nexport function transformExpression(\n node: JsonExpression,\n handlers: ExpressionVisitor<JsonExpression>,\n path: ExpressionPath = [],\n): JsonExpression {\n const args = (items: readonly (JsonExpression | null)[]) =>\n Array.from(items, (_, index) => {\n const child = operand(items, index);\n return child ? transformExpression(child, handlers, [...path, \"arguments\", index]) : null;\n });\n switch (node.type) {\n case \"const\":\n case \"responseVariable\":\n case \"ownerState\":\n return visitExpression(node, handlers, path);\n case \"function\":\n return visitExpression({ ...node, arguments: args(node.arguments) }, handlers, path);\n case \"contextVariable\":\n return visitExpression(\n {\n ...node,\n ...(node.key ? { key: transformExpression(node.key, handlers, [...path, \"key\"]) } : {}),\n ...(node.arguments ? { arguments: args(node.arguments) } : {}),\n },\n handlers,\n path,\n );\n default:\n return unreachable(node);\n }\n}\n","/** Find and rewrite IDs embedded in expression trees for graph compilation and survey edits. */\nimport type { ExpressionPath, JsonExpression } from \"./schema\";\nimport { transformExpression } from \"./tree\";\n\n/** A response slot or owner state read, with its location in the expression. */\nexport type ExpressionDependency =\n | { kind: \"answer\"; slotId: string; method: \"get\" | \"isDefined\"; path: ExpressionPath }\n | { kind: \"state\"; state: \"disabled\"; targetRef: { ownerId: string }; path: ExpressionPath };\n\n/** Collect response and owner state reads so the graph can validate and order dependencies. */\nexport function collectExpressionDependencies(node: JsonExpression): ExpressionDependency[] {\n const references: ExpressionDependency[] = [];\n transformExpression(node, {\n const: (value) => value,\n contextVariable: (value) => value,\n function: (value) => value,\n responseVariable: (value, path) => {\n references.push({ kind: \"answer\", ...value.variableRef, path });\n return value;\n },\n ownerState: (value, path) => {\n references.push({ kind: \"state\", state: value.state, targetRef: value.targetRef, path });\n return value;\n },\n });\n return references;\n}\n\n/**\n * Rewrite slot IDs, owner IDs, and constant reference values when survey content is copied.\n * IDs absent from the map are left as they are.\n */\nexport function remapExpression(\n node: JsonExpression,\n ids: ReadonlyMap<string, string>,\n): JsonExpression {\n const id = (value: string) => ids.get(value) ?? value;\n return transformExpression(node, {\n const: (value) => {\n if (value.value?.type === \"reference\")\n return { ...value, value: { ...value.value, value: id(value.value.value) } };\n if (value.value?.type === \"reference[]\")\n return { ...value, value: { ...value.value, value: value.value.value.map(id) } };\n return value;\n },\n contextVariable: (value) => value,\n function: (value) => value,\n responseVariable: (value) => ({\n ...value,\n variableRef: { ...value.variableRef, slotId: id(value.variableRef.slotId) },\n }),\n ownerState: (value) => ({ ...value, targetRef: { ownerId: id(value.targetRef.ownerId) } }),\n });\n}\n","import { z } from \"zod\";\nimport { isCalendarDate } from \"../../calendar-date\";\n\nconst precision = z.enum([\"int\", \"float\"]).optional();\nconst number = z.number().finite();\nconst date = z.string().refine(isCalendarDate, \"Expected a calendar year, month, or date\");\nconst unit = z.enum([\"seconds\", \"minutes\", \"hours\", \"days\", \"weeks\", \"months\", \"years\"]);\n\n/** The same JSON value grammar is used by expressions, retained answers, and submissions. */\nexport const responseValueSchema = z.discriminatedUnion(\"type\", [\n z.strictObject({ type: z.literal(\"string\"), value: z.string() }),\n z.strictObject({ type: z.literal(\"reference\"), value: z.string().min(1) }),\n z.strictObject({ type: z.literal(\"number\"), value: number, precision }),\n z.strictObject({ type: z.literal(\"boolean\"), value: z.boolean() }),\n z.strictObject({ type: z.literal(\"date\"), value: date }),\n z.strictObject({ type: z.literal(\"duration\"), value: number, unit, precision }),\n z.strictObject({ type: z.literal(\"string[]\"), value: z.array(z.string()) }),\n z.strictObject({ type: z.literal(\"reference[]\"), value: z.array(z.string().min(1)) }),\n z.strictObject({ type: z.literal(\"number[]\"), value: z.array(number), precision }),\n z.strictObject({ type: z.literal(\"date[]\"), value: z.array(date) }),\n z.strictObject({ type: z.literal(\"duration[]\"), value: z.array(number), unit, precision }),\n]);\n\nexport const valueTypeSchema = z.enum([\n \"string\",\n \"reference\",\n \"number\",\n \"boolean\",\n \"date\",\n \"duration\",\n \"string[]\",\n \"reference[]\",\n \"number[]\",\n \"date[]\",\n \"duration[]\",\n]);\n","/** Serialized expression nodes and their Zod validation contract. Other expression modules operate on these nodes. */\nimport { z } from \"zod\";\nimport { responseValueSchema, valueTypeSchema } from \"../survey/responses/value-schema\";\n\n/** Optional authoring metadata carried by a node without affecting evaluation. */\nexport const expressionEditorConfigSchema = z.strictObject({\n usedTemplate: z.string().optional(),\n label: z.string().optional(),\n description: z.string().optional(),\n});\n\n/** Function names accepted in serialized expression trees. */\nexport const functionNameSchema = z.enum([\n \"and\",\n \"or\",\n \"not\",\n \"list_contains\",\n \"list_count\",\n \"if\",\n \"eq\",\n \"gt\",\n \"gte\",\n \"lt\",\n \"lte\",\n \"in_range\",\n \"sum\",\n \"min\",\n \"max\",\n \"str_eq\",\n \"date_eq\",\n \"date_gt\",\n \"date_gte\",\n \"date_lt\",\n \"date_lte\",\n \"date_add_days\",\n \"date_add_months\",\n \"date_add_years\",\n \"date_diff\",\n \"date_min\",\n \"date_max\",\n]);\nconst editorConfig = expressionEditorConfigSchema.optional();\n\nconst constantSchema = z.strictObject({\n type: z.literal(\"const\"),\n value: responseValueSchema.optional(),\n editorConfig,\n});\n\nconst answerSchema = z.strictObject({\n type: z.literal(\"responseVariable\"),\n variableRef: z.strictObject({ slotId: z.string().min(1), method: z.enum([\"get\", \"isDefined\"]) }),\n editorConfig,\n});\n\nconst ownerStateSchema = z.strictObject({\n type: z.literal(\"ownerState\"),\n state: z.literal(\"disabled\"),\n targetRef: z.strictObject({ ownerId: z.string().min(1) }),\n editorConfig,\n});\n\nconst contextSchema = z.strictObject({\n type: z.literal(\"contextVariable\"),\n contextType: z.enum([\"locale\", \"currentDate\", \"participantFlag\", \"customValue\"]),\n get key(): z.ZodOptional<typeof expressionSchema> {\n return expressionSchema.optional();\n },\n get arguments(): z.ZodOptional<z.ZodArray<z.ZodNullable<typeof expressionSchema>>> {\n return z.array(expressionSchema.nullable()).optional();\n },\n asType: valueTypeSchema.optional(),\n editorConfig,\n});\n\nconst functionSchema = z.strictObject({\n type: z.literal(\"function\"),\n functionName: functionNameSchema,\n get arguments(): z.ZodArray<z.ZodNullable<typeof expressionSchema>> {\n return z.array(expressionSchema.nullable());\n },\n editorConfig,\n});\n\n/** Parse a complete recursive expression tree, including owner state reads. */\nexport const expressionSchema = z.discriminatedUnion(\"type\", [\n constantSchema,\n answerSchema,\n contextSchema,\n functionSchema,\n ownerStateSchema,\n]);\n\n/** A canonical expression as stored in a survey definition. */\nexport type JsonExpression = z.infer<typeof expressionSchema>;\nexport type ExpressionNode = JsonExpression;\nexport type ExpressionEditorConfig = z.infer<typeof expressionEditorConfigSchema>;\nexport type FunctionName = z.infer<typeof functionNameSchema>;\nexport type ExpressionOf<K extends JsonExpression[\"type\"]> = Extract<JsonExpression, { type: K }>;\nexport type ExpressionPath = readonly (string | number)[];\n","import { z } from \"zod\";\nimport type { ValueType } from \"../survey/responses/value-types\";\nimport { collectExpressionDependencies, remapExpression } from \"../expressions/references\";\nimport { expressionSchema, type JsonExpression } from \"../expressions/schema\";\n\nexport type SchemaPath = readonly (string | number)[];\nexport type IdentityKind =\n | \"item\"\n | \"layout\"\n | \"section\"\n | \"element\"\n | \"component\"\n | \"slot\"\n | \"rule\"\n | \"prefill\"\n | \"asset\";\nexport type ReferenceKind = \"state\" | \"owner\" | \"slot\" | \"option\" | \"item\" | \"asset\";\nexport type ContentRole = { role: string; policy: \"inline\" | \"block\"; recommended?: boolean };\nexport type SchemaAnnotation =\n | { kind: \"identity\"; identity: IdentityKind; slotAlias?: boolean }\n | { kind: \"reference\"; target: ReferenceKind; external?: boolean }\n | { kind: \"owner\"; roles: readonly ContentRole[] }\n | { kind: \"expression\"; expectedReturnType?: ValueType }\n | { kind: \"responseValue\" }\n | { kind: \"body\"; followUp: boolean }\n | { kind: \"bound\" };\n\nconst annotations = z.registry<SchemaAnnotation>();\n\n/** Clone before annotating: shared primitive schemas must not acquire another field's meaning. */\nexport function annotated<S extends z.ZodType>(schema: S, annotation: SchemaAnnotation): S {\n const result = schema.clone();\n const base: z.ZodType = result;\n annotations.add(base, annotation);\n return result;\n}\n\nexport function schemaAnnotation(schema: z.ZodType): SchemaAnnotation | undefined {\n return annotations.get(schema);\n}\n\nexport const ownedId = (identity: IdentityKind, slotAlias = false) =>\n annotated(z.string().min(1), { kind: \"identity\", identity, ...(slotAlias ? { slotAlias } : {}) });\nexport const referenceId = (target: ReferenceKind, external = false) =>\n annotated(z.string().min(1), { kind: \"reference\", target, ...(external ? { external } : {}) });\n// Expressions are opaque to the annotation walker. Keep their schema-inferred\n// input/output type named across package boundaries instead of expanding every\n// recursive Zod getter in every element definition's generated declarations.\nexport interface ExpressionValueSchema extends z.ZodType<JsonExpression, JsonExpression> {}\nexport const expressionField = (expectedReturnType?: ValueType): ExpressionValueSchema =>\n annotated(expressionSchema, {\n kind: \"expression\",\n ...(expectedReturnType ? { expectedReturnType } : {}),\n });\n/**\n * A literal, or `{ expression, fallback? }` whose fallback applies when the expression has no\n * value. The annotation lets tools tell a bound from other config that also holds an expression.\n */\nexport const boundField = <V extends z.ZodType>(value: V, expectedReturnType: ValueType) =>\n annotated(\n z.union([\n value,\n z.strictObject({\n expression: expressionField(expectedReturnType),\n fallback: value.optional(),\n }),\n ]),\n { kind: \"bound\" },\n );\nexport const contentOwner = <S extends z.ZodType>(schema: S, roles: readonly ContentRole[]) =>\n annotated(schema, { kind: \"owner\", roles });\n\n/** Object extension changes schema identity, so carry the toolkit metadata explicitly. */\nexport function extendObject<S extends z.ZodRawShape, E extends z.ZodRawShape>(\n schema: z.ZodObject<S>,\n extension: E,\n) {\n const result = schema.extend(extension);\n const annotation = annotations.get(schema);\n return annotation ? annotated(result, annotation) : result;\n}\n\nexport interface SchemaVisit {\n schema: z.core.$ZodType;\n value: unknown;\n path: SchemaPath;\n key: boolean;\n annotation: SchemaAnnotation;\n}\n\nconst record = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst unionDispatch = new WeakMap<\n z.ZodUnion,\n { key: string; variants: Map<unknown, z.ZodType> } | null\n>();\n/** Disjoint literal discriminants select a branch without reparsing its recursive subtree. */\nfunction discriminatedVariant(schema: z.ZodUnion, value: unknown): z.ZodType | undefined {\n let dispatch = unionDispatch.get(schema);\n if (dispatch === undefined) {\n dispatch = null;\n const objects = schema.options.filter(\n (option): option is z.ZodObject => option instanceof z.ZodObject,\n );\n if (objects.length === schema.options.length && objects.length > 0) {\n for (const key of Object.keys(objects[0].shape)) {\n const variants = new Map<unknown, z.ZodType>();\n const disjoint = objects.every((option) => {\n const discriminator: unknown = option.shape[key];\n if (!(discriminator instanceof z.ZodLiteral)) return false;\n for (const literal of discriminator.values) {\n if (variants.has(literal)) return false;\n variants.set(literal, option);\n }\n return true;\n });\n if (disjoint) {\n dispatch = { key, variants };\n break;\n }\n }\n }\n unionDispatch.set(schema, dispatch);\n }\n if (!dispatch) return undefined;\n const branch = record(value) ? dispatch.variants.get(value[dispatch.key]) : undefined;\n if (!branch) throw new Error(`Unknown '${dispatch.key}' schema variant`);\n return branch;\n}\n\n/**\n * A schema-guided walk of validated data. Values and record keys share one traversal.\n * Expressions are opaque here: their canonical visitor owns the recursive AST grammar.\n */\nfunction walkAnnotated(\n schema: z.ZodType,\n input: unknown,\n transform: (visit: SchemaVisit) => unknown,\n): unknown {\n const walk = (\n current: z.core.$ZodType,\n value: unknown,\n path: SchemaPath,\n key = false,\n ): unknown => {\n const annotation = annotations.get(current);\n if (annotation) {\n value = transform({ schema: current, value, path, key, annotation });\n if (annotation.kind === \"expression\" || annotation.kind === \"responseValue\") return value;\n }\n if (value === undefined || value === null) return value;\n if (\n current instanceof z.ZodOptional ||\n current instanceof z.ZodExactOptional ||\n current instanceof z.ZodNullable ||\n current instanceof z.ZodReadonly ||\n current instanceof z.ZodNonOptional ||\n current instanceof z.ZodDefault ||\n current instanceof z.ZodPrefault ||\n current instanceof z.ZodCatch\n )\n return walk(current.unwrap(), value, path, key);\n if (current instanceof z.ZodLazy) return walk(current.unwrap(), value, path, key);\n if (current instanceof z.ZodObject) {\n if (!record(value)) throw new Error(`Expected object at ${JSON.stringify(path)}`);\n return Object.fromEntries(\n Object.entries(value).map(([name, child]) => {\n const childSchema = Object.hasOwn(current.shape, name)\n ? current.shape[name]\n : current._zod.def.catchall;\n // Keep every accepted key, including loose-object fields. The final parse\n // still rejects or strips new keys according to the owning object schema.\n return [name, childSchema ? walk(childSchema, child, [...path, name]) : child];\n }),\n );\n }\n if (current instanceof z.ZodArray) {\n if (!Array.isArray(value)) throw new Error(`Expected array at ${JSON.stringify(path)}`);\n return value.map((child, index) => walk(current.element, child, [...path, index]));\n }\n if (current instanceof z.ZodTuple) {\n if (!Array.isArray(value)) throw new Error(`Expected tuple at ${JSON.stringify(path)}`);\n return value.map((child, index) => {\n const childSchema = current._zod.def.items[index] ?? current._zod.def.rest;\n if (!childSchema) throw new Error(`Unexpected tuple member at ${JSON.stringify(path)}`);\n return walk(childSchema, child, [...path, index]);\n });\n }\n if (current instanceof z.ZodRecord) {\n if (!record(value)) throw new Error(`Expected record at ${JSON.stringify(path)}`);\n const entries = Object.entries(value).map(([name, child]) => {\n const nextKey = walk(current.keyType, name, [...path, name], true);\n if (typeof nextKey !== \"string\") throw new Error(\"A record key must remain a string\");\n return [nextKey, walk(current.valueType, child, [...path, name])] as const;\n });\n if (new Set(entries.map(([name]) => name)).size !== entries.length)\n throw new Error(\"Remapping collides record keys\");\n return Object.fromEntries(entries);\n }\n if (current instanceof z.ZodUnion) {\n const variant = discriminatedVariant(current, value);\n if (variant) return walk(variant, value, path, key);\n for (const candidate of current.options) {\n if (candidate instanceof z.ZodType && candidate.safeParse(value).success)\n return walk(candidate, value, path, key);\n }\n throw new Error(`No schema variant at ${JSON.stringify(path)}`);\n }\n // Leaf schemas have no declared children. Other containers (e.g. intersections\n // and pipes) must not silently conceal annotated identities or references.\n switch (current._zod.def.type) {\n case \"string\":\n case \"number\":\n case \"boolean\":\n case \"bigint\":\n case \"symbol\":\n case \"undefined\":\n case \"null\":\n case \"any\":\n case \"unknown\":\n case \"never\":\n case \"void\":\n case \"date\":\n case \"nan\":\n case \"enum\":\n case \"literal\":\n case \"template_literal\":\n case \"custom\":\n case \"file\":\n return value;\n default:\n throw new Error(\n `Unsupported schema container '${current._zod.def.type}' at ${JSON.stringify(path)}`,\n );\n }\n };\n return walk(schema, input, []);\n}\n\nexport function transformAnnotated<S extends z.ZodType>(\n schema: S,\n input: z.output<S>,\n transform: (visit: SchemaVisit) => unknown,\n): z.output<S> {\n // A transformation can invalidate a value. Keep one authoritative parse at its boundary.\n return schema.parse(walkAnnotated(schema, input, transform));\n}\n\nexport function inspectAnnotated<S extends z.ZodType>(\n schema: S,\n input: z.output<S>,\n): SchemaVisit[] {\n const visits: SchemaVisit[] = [];\n // Callers supply parsed data; inspection does not change or revalidate it.\n walkAnnotated(schema, input, (visit) => {\n visits.push(visit);\n return visit.value;\n });\n return visits;\n}\n\nexport function remapAnnotated<S extends z.ZodType>(\n schema: S,\n input: z.output<S>,\n ids: ReadonlyMap<string, string>,\n): z.output<S> {\n const remap = (id: string) => ids.get(id) ?? id;\n return transformAnnotated(schema, input, ({ value, annotation }) => {\n if (\n annotation.kind === \"identity\" ||\n (annotation.kind === \"reference\" && !annotation.external)\n ) {\n if (typeof value !== \"string\") throw new Error(\"An identity must be a string\");\n return remap(value);\n }\n if (annotation.kind === \"expression\")\n return remapExpression(expressionSchema.parse(value), ids);\n if (annotation.kind === \"responseValue\" && record(value)) {\n if (value.type === \"reference\" && typeof value.value === \"string\")\n return { ...value, value: remap(value.value) };\n if (value.type === \"reference[]\" && Array.isArray(value.value))\n return {\n ...value,\n value: value.value.map((entry: unknown) =>\n typeof entry === \"string\" ? remap(entry) : entry,\n ),\n };\n }\n return value;\n });\n}\n\nexport function annotatedReferences(visits: readonly SchemaVisit[]) {\n return visits.flatMap((visit) => {\n if (\n visit.annotation.kind === \"reference\" &&\n !visit.annotation.external &&\n typeof visit.value === \"string\"\n )\n return [{ target: visit.annotation.target, id: visit.value, path: visit.path }];\n if (visit.annotation.kind === \"expression\")\n return collectExpressionDependencies(expressionSchema.parse(visit.value)).map((ref) => ({\n target: ref.kind === \"answer\" ? (\"slot\" as const) : (\"state\" as const),\n id: ref.kind === \"answer\" ? ref.slotId : ref.targetRef.ownerId,\n path: [...visit.path, ...ref.path],\n }));\n return [];\n });\n}\n\n/** Declared content owners in a validated subtree, including nested custom bodies. */\nexport function contentOwnerIds<S extends z.ZodType>(schema: S, input: z.output<S>): Set<string> {\n return new Set(\n inspectAnnotated(schema, input).flatMap((visit) =>\n visit.annotation.kind === \"owner\" && record(visit.value) && typeof visit.value.id === \"string\"\n ? [visit.value.id]\n : [],\n ),\n );\n}\n","import { z } from \"zod\";\n\n/**\n * JSON dictionaries use opaque string keys, including `__proto__`. Zod's record\n * parser deliberately drops that key. Extend its record type at one boundary so\n * schema introspection, annotations, cloning and JSON Schema still see a record.\n * Define the exceptional property as data; never invoke Object.prototype's setter.\n * On Zod upgrades, run string-record.test.ts (clone/check/async/JSON Schema canaries).\n */\nexport function stringRecord<K extends z.ZodString, V extends z.ZodType>(keyType: K, valueType: V) {\n const RecordSchema = z.core.$constructor<z.ZodRecord<K, V>>(\"StringRecord\", (schema, def) => {\n if (def.keyType._zod.def.checks?.some((check) => check._zod.def.check === \"overwrite\"))\n throw new Error(\"Dictionary key schemas must not rewrite opaque keys\");\n z.ZodRecord.init(schema, def);\n const parse = schema._zod.parse;\n schema._zod.parse = (payload, context) => {\n const input: unknown = payload.value;\n const parsed = parse(payload, context);\n if (\n !z.core.util.isPlainObject(input) ||\n !Object.prototype.propertyIsEnumerable.call(input, \"__proto__\")\n )\n return parsed;\n\n const finish = (result: z.core.ParsePayload) => {\n const key = def.keyType._zod.run({ value: \"__proto__\", issues: [] }, context);\n if (key instanceof Promise) throw new Error(\"Async dictionary keys are unsupported\");\n if (key.issues.length) {\n result.issues.push({\n code: \"invalid_key\",\n origin: \"record\",\n issues: key.issues.map((issue) =>\n z.core.util.finalizeIssue(issue, context, z.config()),\n ),\n input: \"__proto__\",\n path: [\"__proto__\"],\n inst: schema,\n });\n return result;\n }\n if (typeof key.value !== \"string\") throw new Error(\"Dictionary keys must remain strings\");\n const outputKey = key.value;\n const value = def.valueType._zod.run({ value: input.__proto__, issues: [] }, context);\n const assign = (child: z.core.ParsePayload) => {\n result.issues.push(...z.core.util.prefixIssues(\"__proto__\", child.issues));\n Object.defineProperty(result.value, outputKey, {\n value: child.value,\n enumerable: true,\n writable: true,\n configurable: true,\n });\n return result;\n };\n return value instanceof Promise ? value.then(assign) : assign(value);\n };\n return parsed instanceof Promise ? parsed.then(finish) : finish(parsed);\n };\n });\n return new RecordSchema({ type: \"record\", keyType, valueType });\n}\n\n/** JSON dictionary lookups must not fall through to Object.prototype. */\nexport function ownValue<T>(\n record: Readonly<Record<string, T>> | undefined,\n key: string,\n): T | undefined {\n return record && Object.hasOwn(record, key) ? record[key] : undefined;\n}\n\nexport function setOwnValue<T>(record: Record<string, T>, key: string, value: T): void {\n Object.defineProperty(record, key, {\n value,\n enumerable: true,\n writable: true,\n configurable: true,\n });\n}\n","import type { CalendarDate } from \"../../calendar-date\";\nimport { responseValueSchema } from \"./value-schema\";\nexport const ValueType = {\n string: \"string\",\n duration: \"duration\",\n reference: \"reference\",\n number: \"number\",\n boolean: \"boolean\",\n date: \"date\",\n stringArray: \"string[]\",\n durationArray: \"duration[]\",\n referenceArray: \"reference[]\",\n numberArray: \"number[]\",\n dateArray: \"date[]\",\n} as const;\n\nexport type ValueType = (typeof ValueType)[keyof typeof ValueType];\n\nexport const DurationUnits = {\n seconds: \"seconds\",\n minutes: \"minutes\",\n hours: \"hours\",\n days: \"days\",\n weeks: \"weeks\",\n months: \"months\",\n years: \"years\",\n} as const;\n\nexport type DurationUnit = (typeof DurationUnits)[keyof typeof DurationUnits];\n\nexport const NumberPrecision = {\n int: \"int\",\n float: \"float\",\n} as const;\n\nexport type NumberPrecision = (typeof NumberPrecision)[keyof typeof NumberPrecision];\n\nexport interface SlotResponseBase<TValueType extends ValueType> {\n type: TValueType;\n}\n\nexport interface StringResponse extends SlotResponseBase<typeof ValueType.string> {\n value: string;\n}\n\nexport interface DurationResponse extends SlotResponseBase<typeof ValueType.duration> {\n value: number;\n unit: DurationUnit;\n precision?: NumberPrecision;\n}\n\nexport interface NumberResponse extends SlotResponseBase<typeof ValueType.number> {\n value: number;\n precision?: NumberPrecision;\n}\n\nexport interface BooleanResponse extends SlotResponseBase<typeof ValueType.boolean> {\n value: boolean;\n}\n\nexport interface ReferenceResponse extends SlotResponseBase<typeof ValueType.reference> {\n value: string;\n}\n\nexport interface DateResponse extends SlotResponseBase<typeof ValueType.date> {\n value: CalendarDate;\n}\n\nexport interface StringArrayResponse extends SlotResponseBase<typeof ValueType.stringArray> {\n value: string[];\n}\n\nexport interface DurationArrayResponse extends SlotResponseBase<typeof ValueType.durationArray> {\n value: number[];\n unit: DurationUnit;\n precision?: NumberPrecision;\n}\n\nexport interface NumberArrayResponse extends SlotResponseBase<typeof ValueType.numberArray> {\n value: number[];\n precision?: NumberPrecision;\n}\n\nexport interface DateArrayResponse extends SlotResponseBase<typeof ValueType.dateArray> {\n value: CalendarDate[];\n}\n\nexport interface ReferenceArrayResponse extends SlotResponseBase<typeof ValueType.referenceArray> {\n value: string[];\n}\n\nexport type ResponseValue =\n | StringResponse\n | DurationResponse\n | ReferenceResponse\n | NumberResponse\n | BooleanResponse\n | DateResponse\n | StringArrayResponse\n | DurationArrayResponse\n | NumberArrayResponse\n | DateArrayResponse\n | ReferenceArrayResponse;\n\nexport type ValueRefTypeLookup = {\n [valueRefString: string]: ValueType;\n};\n\n/** Use the canonical codec at every boundary, including custom registry declarations. */\nexport function isResponseValue(value: unknown): value is ResponseValue {\n return responseValueSchema.safeParse(value).success;\n}\n\nexport function assertResponseValue(value: unknown, path: string): asserts value is ResponseValue {\n if (!isResponseValue(value)) {\n throw new Error(`Invalid response value at '${path}'`);\n }\n}\n","import { stringRecord } from \"../../schema/string-record\";\nimport { z } from \"zod\";\nimport { referenceId } from \"../../schema/annotations\";\n\nexport const jsonValueSchema: z.ZodType<z.core.util.JSONType, z.core.util.JSONType> = z.lazy(() =>\n z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(jsonValueSchema),\n stringRecord(z.string(), jsonValueSchema),\n ]),\n);\n\nexport const contentAttributesSchema = stringRecord(z.string(), jsonValueSchema);\n\nexport const richTextStyleSchema = z.strictObject({\n weight: z.enum([\"strong\", \"normal\"]).optional(),\n italic: z.enum([\"italic\", \"normal\"]).optional(),\n underline: z.enum([\"underline\", \"none\"]).optional(),\n color: z.enum([\"primary\", \"accent\", \"default\"]).optional(),\n});\n\nexport const richTextTextInlineSchema = z.strictObject({\n type: z.literal(\"text\"),\n text: z.string(),\n style: richTextStyleSchema.optional(),\n attrs: contentAttributesSchema.optional(),\n});\n\nexport const richTextTemplateInlineSchema = z.strictObject({\n type: z.literal(\"template\"),\n key: z.string().min(1),\n style: richTextStyleSchema.optional(),\n attrs: contentAttributesSchema.optional(),\n});\n\nexport const richTextLineBreakInlineSchema = z.strictObject({\n type: z.literal(\"lineBreak\"),\n attrs: contentAttributesSchema.optional(),\n});\n\nexport const richTextLinkChildInlineSchema = z.discriminatedUnion(\"type\", [\n richTextTextInlineSchema,\n richTextTemplateInlineSchema,\n richTextLineBreakInlineSchema,\n]);\n\nexport const richTextLinkInlineSchema = z.strictObject({\n type: z.literal(\"link\"),\n href: z.string().min(1),\n target: z.string().nullable().optional(),\n rel: z.string().nullable().optional(),\n title: z.string().nullable().optional(),\n attrs: contentAttributesSchema.optional(),\n children: z.array(richTextLinkChildInlineSchema),\n});\n\nexport const richTextInlineExtensionSchema = z.strictObject({\n type: z.literal(\"inlineExtension\"),\n name: z.string().min(1),\n attrs: contentAttributesSchema.optional(),\n});\n\nexport const richTextInlineSchema = z.discriminatedUnion(\"type\", [\n richTextTextInlineSchema,\n richTextTemplateInlineSchema,\n richTextLinkInlineSchema,\n richTextLineBreakInlineSchema,\n richTextInlineExtensionSchema,\n]);\n\nexport const textAlignmentSchema = z.enum([\"left\", \"center\", \"right\", \"justify\"]);\n\nexport const richTextParagraphBlockSchema = z.strictObject({\n type: z.literal(\"paragraph\"),\n children: z.array(richTextInlineSchema),\n alignment: textAlignmentSchema.optional(),\n attrs: contentAttributesSchema.optional(),\n});\n\nexport const richTextHeadingBlockSchema = z.strictObject({\n type: z.literal(\"heading\"),\n level: z.union([\n z.literal(1),\n z.literal(2),\n z.literal(3),\n z.literal(4),\n z.literal(5),\n z.literal(6),\n ]),\n children: z.array(richTextInlineSchema),\n alignment: textAlignmentSchema.optional(),\n attrs: contentAttributesSchema.optional(),\n});\n\nexport const richTextListItemBlockSchema = z.strictObject({\n type: z.literal(\"listItem\"),\n children: z.array(richTextParagraphBlockSchema),\n attrs: contentAttributesSchema.optional(),\n});\n\nexport const richTextBulletListBlockSchema = z.strictObject({\n type: z.literal(\"bulletList\"),\n items: z.array(richTextListItemBlockSchema),\n attrs: contentAttributesSchema.optional(),\n});\n\nexport const richTextImageDimensionSchema = z.union([\n z.strictObject({ unit: z.literal(\"px\"), value: z.number().finite().nonnegative() }),\n z.strictObject({ unit: z.literal(\"%\"), value: z.number().finite().nonnegative() }),\n]);\n\nexport const richTextImageSourceSchema = z.discriminatedUnion(\"type\", [\n z.strictObject({ type: z.literal(\"asset\"), assetId: referenceId(\"asset\") }),\n // Image insertion publishes an unfinished block before the author chooses its source.\n z.strictObject({ type: z.literal(\"external\"), url: z.string() }),\n]);\n\nexport const richTextImageBlockSchema = z.strictObject({\n type: z.literal(\"image\"),\n source: richTextImageSourceSchema,\n alt: z.string().optional(),\n caption: z.array(richTextParagraphBlockSchema).optional(),\n size: z\n .strictObject({\n width: richTextImageDimensionSchema.optional(),\n height: richTextImageDimensionSchema.optional(),\n maxWidth: richTextImageDimensionSchema.optional(),\n maxHeight: richTextImageDimensionSchema.optional(),\n })\n .optional(),\n alignment: textAlignmentSchema.optional(),\n attrs: contentAttributesSchema.optional(),\n});\n\nexport const richTextInfoBoxBlockSchema = z.strictObject({\n type: z.literal(\"infoBox\"),\n tone: z.enum([\"info\", \"warning\"]).optional(),\n title: z.array(richTextInlineSchema).optional(),\n collapsible: z.boolean().optional(),\n defaultOpen: z.boolean().optional(),\n children: z.array(richTextParagraphBlockSchema),\n attrs: contentAttributesSchema.optional(),\n});\n\nexport const richTextSeparatorBlockSchema = z.strictObject({\n type: z.literal(\"separator\"),\n attrs: contentAttributesSchema.optional(),\n});\n\nexport const richTextBlockExtensionSchema = z.strictObject({\n type: z.literal(\"blockExtension\"),\n name: z.string().min(1),\n attrs: contentAttributesSchema.optional(),\n});\n\nexport const richTextBlockSchema = z.discriminatedUnion(\"type\", [\n richTextParagraphBlockSchema,\n richTextHeadingBlockSchema,\n richTextBulletListBlockSchema,\n richTextImageBlockSchema,\n richTextInfoBoxBlockSchema,\n richTextSeparatorBlockSchema,\n richTextBlockExtensionSchema,\n]);\n\nexport const contentSchema = z.discriminatedUnion(\"type\", [\n z.strictObject({ type: z.literal(\"md\"), content: z.string() }),\n z.strictObject({ type: z.literal(\"plain\"), content: z.string() }),\n z.strictObject({\n type: z.literal(\"richText\"),\n version: z.literal(1),\n doc: z.strictObject({\n type: z.literal(\"doc\"),\n blocks: z.array(richTextBlockSchema),\n }),\n }),\n]);\n\n/** Survey roles use two document levels; general rich editors can represent all HTML levels. */\nexport const surveyContentSchema = contentSchema.superRefine((content, context) => {\n if (content.type !== \"richText\") return;\n content.doc.blocks.forEach((block, index) => {\n if (block.type === \"heading\" && block.level > 2)\n context.addIssue({\n code: \"custom\",\n path: [\"doc\", \"blocks\", index, \"level\"],\n message: \"Survey headings use level 1 or 2\",\n });\n });\n});\n\nexport type SurveyContent = z.infer<typeof surveyContentSchema>;\nexport type JsonValue = z.infer<typeof jsonValueSchema>;\n","import { stringRecord } from \"../../schema/string-record\";\nimport { z } from \"zod\";\nimport {\n annotated,\n contentOwner,\n expressionField,\n ownedId,\n referenceId,\n} from \"../../schema/annotations\";\nimport { responseValueSchema, valueTypeSchema } from \"../responses/value-schema\";\nimport { surveyContentSchema } from \"./content-schema\";\nimport type { Content } from \"../utils/content\";\n\n// Named schema-inferred payload boundary keeps declarations compact without a second grammar.\nconst localizedContent: z.ZodType<Content, Content> = surveyContentSchema;\n\nexport const CURRENT_SURVEY_SCHEMA_VERSION = 3;\nexport const CURRENT_SURVEY_SCHEMA =\n \"https://github.com/case-framework/case-survey-toolkit/packages/survey-core/schemas/survey-schema.json\";\n\nexport const conditionsShape = {\n visibility: expressionField().optional(),\n disabled: expressionField().optional(),\n};\n\nexport const layoutPolicySchema = z.discriminatedUnion(\"mode\", [\n z.strictObject({ mode: z.literal(\"automatic\"), maxColumns: z.number().int().min(1).max(12) }),\n z.strictObject({\n mode: z.literal(\"advanced\"),\n columns: z.strictObject({\n base: z.number().int().min(1).max(12),\n xs: z.number().int().min(1).max(12),\n sm: z.number().int().min(1).max(12),\n md: z.number().int().min(1).max(12),\n xl: z.number().int().min(1).max(12),\n }),\n }),\n]);\n\nexport const slotTransformSchema = z.strictObject({\n mode: z.string(),\n include: z.boolean().optional(),\n categorical: z.enum([\"codes\", \"labels\", \"ids\"]).optional(),\n multiple: z.enum([\"json\", \"delimited\", \"indicators\"]).optional(),\n delimiter: z.string().optional(),\n locale: z.string().optional(),\n optionCodes: stringRecord(referenceId(\"option\"), z.string()).optional(),\n optionLabels: stringRecord(referenceId(\"option\"), z.string()).optional(),\n booleanValues: z.strictObject({ true: z.string(), false: z.string() }).optional(),\n precision: z.number().int().nonnegative().optional(),\n durationUnit: z\n .enum([\"seconds\", \"minutes\", \"hours\", \"days\", \"weeks\", \"months\", \"years\"])\n .optional(),\n dateFormat: z.strictObject({ pattern: z.string() }).optional(),\n maskText: z.string().optional(),\n});\n\nexport const slotPrefillSchema = z.strictObject({\n id: ownedId(\"prefill\"),\n when: expressionField().optional(),\n apply: z.literal(\"ifEmpty\").optional(),\n source: z.discriminatedUnion(\"type\", [\n z.strictObject({\n type: z.literal(\"static\"),\n value: annotated(responseValueSchema, { kind: \"responseValue\" }),\n }),\n z.strictObject({ type: z.literal(\"expression\"), expression: expressionField() }),\n z.strictObject({ type: z.literal(\"templateValue\"), key: z.string().min(1) }),\n z.strictObject({\n type: z.literal(\"previousResponse\"),\n ref: z.strictObject({\n surveyKey: z.string().optional(),\n slotId: referenceId(\"slot\", true),\n }),\n ifUnsupported: z.literal(\"skip\").optional(),\n }),\n ]),\n});\n\nexport const elementShape = {\n id: ownedId(\"element\"),\n kind: z.literal(\"element\"),\n ...conditionsShape,\n placement: z\n .strictObject({\n width: z.enum([\"auto\", \"full\"]).optional(),\n minWidthRem: z.number().positive().optional(),\n })\n .optional(),\n exportSettings: stringRecord(referenceId(\"slot\"), slotTransformSchema).optional(),\n prefills: stringRecord(referenceId(\"slot\"), z.array(slotPrefillSchema)).optional(),\n};\n\n/** Config types are inferred by each registered schema, including at the registry's parse boundary. */\nexport type ElementEnvelope<K extends string, C> = z.infer<z.ZodObject<typeof elementShape>> & {\n elementType: K;\n config: C;\n};\nexport type CompositionBody<E> = { blocks: (LayoutGroup<E> | ItemSection<E>)[] };\nexport type LayoutGroup<E> = {\n id: string;\n kind: \"layout\";\n layout: z.infer<typeof layoutPolicySchema>;\n elements: E[];\n};\nexport type ItemSection<E> = z.infer<z.ZodObject<typeof conditionsShape>> & {\n id: string;\n kind: \"section\";\n body: CompositionBody<E>;\n};\n\nexport const validationRuleSchema = contentOwner(\n z.strictObject({\n id: ownedId(\"rule\"),\n targets: z.array(referenceId(\"slot\")).min(1),\n expression: expressionField(),\n when: expressionField().optional(),\n phase: z.enum([\"page\", \"submit\"]).optional(),\n }),\n [{ role: \"message\", policy: \"inline\" }],\n);\n\nexport function createCompositionSchema<E>(element: z.ZodType<E>): z.ZodType<CompositionBody<E>> {\n const body: z.ZodType<CompositionBody<E>> = annotated(\n z.strictObject({\n blocks: z.array(\n z.discriminatedUnion(\"kind\", [\n z.strictObject({\n id: ownedId(\"layout\"),\n kind: z.literal(\"layout\"),\n layout: layoutPolicySchema,\n elements: z.array(element),\n }),\n contentOwner(\n z.strictObject({\n id: ownedId(\"section\"),\n kind: z.literal(\"section\"),\n ...conditionsShape,\n get body(): z.ZodType<CompositionBody<E>> {\n return body;\n },\n }),\n [\n { role: \"title\", policy: \"inline\", recommended: true },\n { role: \"description\", policy: \"block\" },\n ],\n ),\n ]),\n ),\n }),\n { kind: \"body\", followUp: false },\n );\n return body;\n}\n\nexport const followUpBody = <E>(body: z.ZodType<CompositionBody<E>>) =>\n annotated(body, { kind: \"body\", followUp: true });\n\nconst metadata = stringRecord(z.string(), z.string()).optional();\nexport const itemEditorMetadataSchema = z.strictObject({\n createdAt: z.string().optional(),\n updatedAt: z.string().optional(),\n});\n\nconst editorMetadata = itemEditorMetadataSchema.optional();\nconst itemShape = { id: ownedId(\"item\"), metadata, editorMetadata, ...conditionsShape };\nconst groupSchema = contentOwner(\n z.strictObject({\n ...itemShape,\n itemType: z.literal(\"group\"),\n config: z.strictObject({\n isRoot: z.boolean().optional(),\n items: z.array(referenceId(\"item\")),\n shuffleItems: z.boolean().optional(),\n }),\n }),\n [],\n);\n\nconst pageBreakSchema = contentOwner(\n z.strictObject({\n ...itemShape,\n itemType: z.literal(\"page-break\"),\n config: z.strictObject({}),\n }),\n [],\n);\n\nfunction createContentItemSchema<E>(body: z.ZodType<CompositionBody<E>>): z.ZodObject<\n typeof itemShape & {\n itemType: z.ZodLiteral<\"content\">;\n config: z.ZodObject<\n {\n body: z.ZodType<CompositionBody<E>>;\n validationRules: z.ZodOptional<z.ZodArray<typeof validationRuleSchema>>;\n },\n z.core.$strict\n >;\n },\n z.core.$strict\n> {\n return contentOwner(\n z.strictObject({\n ...itemShape,\n itemType: z.literal(\"content\"),\n config: z.strictObject({ body, validationRules: z.array(validationRuleSchema).optional() }),\n }),\n [\n { role: \"title\", policy: \"inline\" },\n { role: \"subtitle\", policy: \"block\" },\n { role: \"footer\", policy: \"block\" },\n ],\n );\n}\n\nexport function createFlowItemSchema<E>(\n body: z.ZodType<CompositionBody<E>>,\n): z.ZodDiscriminatedUnion<\n [ReturnType<typeof createContentItemSchema<E>>, typeof groupSchema, typeof pageBreakSchema],\n \"itemType\"\n> {\n return z.discriminatedUnion(\"itemType\", [\n createContentItemSchema(body),\n groupSchema,\n pageBreakSchema,\n ]);\n}\n\nconst surveyLocaleContentSchema = z.strictObject({\n surveyCardContent: z\n .strictObject({\n name: localizedContent.optional(),\n description: localizedContent.optional(),\n typicalDuration: localizedContent.optional(),\n })\n .optional(),\n navigationContent: z\n .strictObject({\n previousButtonText: localizedContent.optional(),\n nextButtonText: localizedContent.optional(),\n submitButtonText: localizedContent.optional(),\n pageIndicatorText: localizedContent.optional(),\n submitBoxMessage: localizedContent.optional(),\n })\n .optional(),\n validationMessages: z.strictObject({ invalidResponse: localizedContent.optional() }).optional(),\n content: stringRecord(referenceId(\"owner\"), stringRecord(z.string(), localizedContent)),\n});\n\nexport const templateValueSchema = z.discriminatedUnion(\"type\", [\n z.strictObject({\n type: z.literal(\"default\"),\n returnType: valueTypeSchema,\n expression: expressionField().optional(),\n }),\n z.strictObject({\n type: z.literal(\"formatDate\"),\n returnType: z.literal(\"string\"),\n expression: expressionField().optional(),\n dateFormat: z.string(),\n }),\n]);\n\nconst surveyShape = {\n $schema: z.literal(CURRENT_SURVEY_SCHEMA),\n schemaVersion: z.literal(CURRENT_SURVEY_SCHEMA_VERSION),\n metadata,\n /** The source language; exports and hosts fall back to it. Must be a key of `translations`. */\n defaultLocale: z.string().min(1).optional(),\n translations: stringRecord(z.string().min(1), surveyLocaleContentSchema).optional(),\n maxItemsPerPage: z\n .strictObject({ large: z.number().int().positive(), small: z.number().int().positive() })\n .optional(),\n assets: stringRecord(\n ownedId(\"asset\"),\n z.strictObject({\n kind: z.literal(\"image\"),\n source: z.strictObject({\n type: z.literal(\"embedded\"),\n mediaType: z.string(),\n encoding: z.literal(\"base64\"),\n data: z.string(),\n }),\n metadata: z\n .strictObject({\n name: z.string().optional(),\n filename: z.string().optional(),\n alt: z.string().optional(),\n width: z.number().positive().optional(),\n height: z.number().positive().optional(),\n })\n .optional(),\n }),\n ).optional(),\n templateValues: stringRecord(z.string(), templateValueSchema).optional(),\n};\n\nexport function createSurveySchema<E>(\n body: z.ZodType<CompositionBody<E>>,\n): z.ZodObject<\n typeof surveyShape & { surveyItems: z.ZodArray<ReturnType<typeof createFlowItemSchema<E>>> },\n z.core.$strict\n> {\n return z.strictObject({\n ...surveyShape,\n surveyItems: z.array(createFlowItemSchema(body)).min(1),\n });\n}\n","import { z } from \"zod\";\nimport * as schemas from \"../composition/content-schema\";\n\nexport const ContentType = { richText: \"richText\", plain: \"plain\", md: \"md\" } as const;\nexport type ContentType = (typeof ContentType)[keyof typeof ContentType];\nexport type Content = z.infer<typeof schemas.surveyContentSchema>;\nexport type RichTextContent = Extract<Content, { type: \"richText\" }>;\nexport type PlainTextContent = Extract<Content, { type: \"plain\" }>;\nexport type MDContent = Extract<Content, { type: \"md\" }>;\nexport type RichTextDocument = RichTextContent[\"doc\"];\nexport type ContentAttributes = z.infer<typeof schemas.contentAttributesSchema>;\nexport type TextAlignment = z.infer<typeof schemas.textAlignmentSchema>;\nexport type RichTextStyle = z.infer<typeof schemas.richTextStyleSchema>;\nexport type RichTextInline = z.infer<typeof schemas.richTextInlineSchema>;\nexport type RichTextInlineNode = RichTextInline;\nexport type RichTextBlockNode = z.infer<typeof schemas.richTextBlockSchema>;\nexport type RichTextTextInline = z.infer<typeof schemas.richTextTextInlineSchema>;\nexport type RichTextTemplateInline = z.infer<typeof schemas.richTextTemplateInlineSchema>;\nexport type RichTextLineBreakInline = z.infer<typeof schemas.richTextLineBreakInlineSchema>;\nexport type RichTextLinkChildInline = z.infer<typeof schemas.richTextLinkChildInlineSchema>;\nexport type RichTextLinkInline = z.infer<typeof schemas.richTextLinkInlineSchema>;\nexport type RichTextInlineExtension = z.infer<typeof schemas.richTextInlineExtensionSchema>;\nexport type RichTextParagraphBlock = z.infer<typeof schemas.richTextParagraphBlockSchema>;\nexport type RichTextHeadingBlock = z.infer<typeof schemas.richTextHeadingBlockSchema>;\nexport type RichTextListItemBlock = z.infer<typeof schemas.richTextListItemBlockSchema>;\nexport type RichTextBulletListBlock = z.infer<typeof schemas.richTextBulletListBlockSchema>;\nexport type SurveyContentImageSource = z.infer<typeof schemas.richTextImageSourceSchema>;\nexport type RichTextImageDimension = z.infer<typeof schemas.richTextImageDimensionSchema>;\nexport type RichTextImageBlock = z.infer<typeof schemas.richTextImageBlockSchema>;\nexport type RichTextImageSize = NonNullable<RichTextImageBlock[\"size\"]>;\nexport type RichTextInfoBoxBlock = z.infer<typeof schemas.richTextInfoBoxBlockSchema>;\nexport type RichTextSeparatorBlock = z.infer<typeof schemas.richTextSeparatorBlockSchema>;\nexport type RichTextBlockExtension = z.infer<typeof schemas.richTextBlockExtensionSchema>;\n\nexport interface ContentAssetUsage {\n assetId: string;\n blockIndex: number;\n}\n\nexport function hasRenderableRichTextBlock(block: RichTextBlockNode): boolean {\n switch (block.type) {\n case \"paragraph\":\n return block.children.length > 0;\n case \"heading\":\n return block.children.length > 0;\n case \"bulletList\":\n return block.items.some((item) =>\n item.children.some((paragraph) => paragraph.children.length > 0),\n );\n case \"image\":\n return true;\n case \"infoBox\":\n // Empty callouts are still intentional blocks (editor inserts title/body later).\n return true;\n case \"separator\":\n return true;\n case \"blockExtension\":\n return true;\n }\n}\n\nexport function hasRenderableRichTextContent(content: RichTextContent): boolean {\n return content.doc.blocks.some((block) => hasRenderableRichTextBlock(block));\n}\n\nexport function createRichTextContent(text = \"\"): RichTextContent {\n return {\n type: ContentType.richText,\n version: 1,\n doc: {\n type: \"doc\",\n blocks: [\n {\n type: \"paragraph\",\n children:\n text.length > 0\n ? text.split(\"\\n\").flatMap<RichTextInlineNode>((line, index) => {\n const parts: RichTextInlineNode[] = [];\n if (index > 0) {\n parts.push({ type: \"lineBreak\" });\n }\n if (line.length > 0) {\n parts.push({ type: \"text\", text: line });\n }\n return parts;\n })\n : [],\n },\n ],\n },\n };\n}\n\nfunction getPlainTextFromLinkChildren(children: RichTextLinkChildInline[]): string {\n return children\n .map((inline) => {\n switch (inline.type) {\n case \"text\":\n return inline.text;\n case \"template\":\n return `{${inline.key}}`;\n case \"lineBreak\":\n return \"\\n\";\n }\n })\n .join(\"\");\n}\n\nfunction getPlainTextFromInlineNodes(inlines: RichTextInlineNode[]): string {\n return inlines\n .map((inline) => {\n switch (inline.type) {\n case \"text\":\n return inline.text;\n case \"template\":\n return `{${inline.key}}`;\n case \"link\":\n return getPlainTextFromLinkChildren(inline.children);\n case \"lineBreak\":\n return \"\\n\";\n case \"inlineExtension\":\n return \"\";\n }\n })\n .join(\"\");\n}\n\nfunction getPlainTextFromParagraphs(paragraphs: RichTextParagraphBlock[]): string {\n return paragraphs.map((paragraph) => getPlainTextFromInlineNodes(paragraph.children)).join(\"\\n\");\n}\n\nfunction getPlainTextFromBlock(block: RichTextBlockNode): string {\n switch (block.type) {\n case \"paragraph\":\n return getPlainTextFromInlineNodes(block.children);\n case \"heading\":\n return getPlainTextFromInlineNodes(block.children);\n case \"bulletList\":\n return block.items.map((item) => getPlainTextFromParagraphs(item.children)).join(\"\\n\");\n case \"image\": {\n const captionText = block.caption ? getPlainTextFromParagraphs(block.caption) : \"\";\n return [block.alt ?? \"\", captionText].filter(Boolean).join(\"\\n\");\n }\n case \"infoBox\": {\n const titleText = block.title ? getPlainTextFromInlineNodes(block.title) : \"\";\n const bodyText = getPlainTextFromParagraphs(block.children);\n return [titleText, bodyText].filter(Boolean).join(\"\\n\");\n }\n case \"separator\":\n return \"\";\n case \"blockExtension\":\n return \"\";\n }\n}\n\nexport function getPlainTextFromRichTextContent(content: RichTextContent): string {\n return content.doc.blocks\n .map((block) => getPlainTextFromBlock(block))\n .filter((text) => text.length > 0)\n .join(\"\\n\")\n .trim();\n}\n\nexport function getContentPlainText(content?: Content): string {\n if (!content) {\n return \"\";\n }\n\n if (content.type !== ContentType.richText) {\n return content.content ?? \"\";\n }\n\n return getPlainTextFromRichTextContent(content);\n}\n\nexport function isContentEmpty(content?: Content): boolean {\n if (!content) {\n return true;\n }\n\n if (content.type !== ContentType.richText) {\n return content.content.trim().length === 0;\n }\n\n return !hasRenderableRichTextContent(content);\n}\n\nexport function getAssetUsagesFromContent(content?: Content): ContentAssetUsage[] {\n if (!content || content.type !== ContentType.richText) {\n return [];\n }\n\n const usages: ContentAssetUsage[] = [];\n\n content.doc.blocks.forEach((block, blockIndex) => {\n if (block.type === \"image\" && block.source.type === \"asset\") {\n usages.push({\n assetId: block.source.assetId,\n blockIndex,\n });\n }\n });\n\n return usages;\n}\n","import type { Survey } from \"../composition/document\";\nimport type { CompositionSurvey } from \"../composition/registry\";\nimport { getContentPlainText, hasRenderableRichTextBlock, type Content } from \"./content\";\nimport { ownValue } from \"../../schema/string-record\";\n\nexport const SURVEY_LOCALIZATION_SURFACES = [\n \"surveyCardContent\",\n \"navigationContent\",\n \"validationMessages\",\n] as const;\nexport type SurveyLocalizationSurface = (typeof SURVEY_LOCALIZATION_SURFACES)[number];\ntype Translation = NonNullable<CompositionSurvey[\"translations\"]>[string];\nconst SURVEY_LOCALIZATION_FIELDS: {\n [S in SurveyLocalizationSurface]: Record<keyof NonNullable<Translation[S]>, true>;\n} = {\n surveyCardContent: { name: true, description: true, typicalDuration: true },\n navigationContent: {\n previousButtonText: true,\n nextButtonText: true,\n submitButtonText: true,\n pageIndicatorText: true,\n submitBoxMessage: true,\n },\n validationMessages: { invalidResponse: true },\n};\nexport type LocalizationRef =\n | { scope: \"content\"; ownerId: string; role: string }\n | { scope: \"survey\"; surface: SurveyLocalizationSurface; contentKey: string };\nexport type LocalizationEntry = {\n key: string;\n ref: LocalizationRef;\n contents: Record<string, Content | undefined>;\n};\nexport const hasLocalizationText = (content: Content | undefined): boolean =>\n Boolean(content && getContentPlainText(content).trim());\nexport const getLocalizationEntryKey = (ref: LocalizationRef): string =>\n ref.scope === \"content\"\n ? JSON.stringify([ref.scope, ref.ownerId, ref.role])\n : JSON.stringify([ref.scope, ref.surface, ref.contentKey]);\nexport const getLocalizationCellKey = (ref: LocalizationRef, locale: string) =>\n JSON.stringify([locale, getLocalizationEntryKey(ref)]);\n\n/** Accepts parsed draft data too, so disconnected items remain discoverable once. */\nexport function getLocalizationItems(survey: CompositionSurvey, itemIds?: readonly string[]) {\n const byId = new Map(survey.surveyItems.map((item) => [item.id, item]));\n const visited = new Set<string>();\n const ordered: CompositionSurvey[\"surveyItems\"] = [];\n const visit = (id: string) => {\n if (visited.has(id)) return;\n visited.add(id);\n const item = byId.get(id);\n if (!item) return;\n ordered.push(item);\n if (item.itemType === \"group\") item.config.items.forEach(visit);\n };\n if (itemIds)\n itemIds.forEach((id) => {\n if (!byId.has(id)) throw new Error(`Unknown localization item '${id}'`);\n visit(id);\n });\n else {\n survey.surveyItems\n .filter((item) => item.itemType === \"group\" && item.config.isRoot)\n .forEach((item) => visit(item.id));\n survey.surveyItems.forEach((item) => visit(item.id));\n }\n return ordered;\n}\n\nexport function validateLocalizationRef(survey: Survey, ref: LocalizationRef): void {\n if (ref.scope === \"content\") {\n if (!survey.owners.get(ref.ownerId)?.roles.some((entry) => entry.role === ref.role))\n throw new Error(`Unavailable localized content '${ref.ownerId}/${ref.role}'`);\n } else if (!Object.hasOwn(SURVEY_LOCALIZATION_FIELDS[ref.surface], ref.contentKey))\n throw new Error(`Unknown survey content field '${ref.surface}/${ref.contentKey}'`);\n}\nexport function readLocalizationContent(\n survey: Survey,\n ref: LocalizationRef,\n locale: string,\n): Content | undefined {\n validateLocalizationRef(survey, ref);\n const translation = ownValue(survey.data.translations, locale);\n if (ref.scope === \"content\")\n return ownValue(ownValue(translation?.content, ref.ownerId), ref.role);\n const values: Record<string, Content | undefined> | undefined = translation?.[ref.surface];\n return ownValue(values, ref.contentKey);\n}\n\nexport function listLocalizationEntries(\n survey: Survey,\n options: {\n sourceLocale?: string;\n itemIds?: readonly string[];\n includeEmptySurveyFields?: boolean;\n } = {},\n): LocalizationEntry[] {\n const locales = Object.keys(survey.data.translations ?? {}),\n entries: LocalizationEntry[] = [];\n const add = (ref: LocalizationRef) => {\n const contents = Object.fromEntries(\n locales.map((locale) => [locale, readLocalizationContent(survey, ref, locale)]),\n );\n const includeEmpty =\n ref.scope === \"survey\" && options.includeEmptySurveyFields && !options.sourceLocale;\n if (\n options.sourceLocale\n ? !hasLocalizationText(ownValue(contents, options.sourceLocale))\n : !includeEmpty && !Object.values(contents).some(hasLocalizationText)\n )\n return;\n entries.push({ key: getLocalizationEntryKey(ref), ref, contents });\n };\n if (!options.itemIds)\n for (const surface of SURVEY_LOCALIZATION_SURFACES)\n for (const contentKey of Object.keys(SURVEY_LOCALIZATION_FIELDS[surface]))\n add({ scope: \"survey\", surface, contentKey });\n for (const item of getLocalizationItems(survey.data, options.itemIds)) {\n for (const owner of survey.owners.values())\n if (owner.itemId === item.id)\n for (const role of owner.roles)\n add({ scope: \"content\", ownerId: owner.id, role: role.role });\n }\n return entries;\n}\nexport const isEmptySurveyLocalizationEntry = (entry: LocalizationEntry) =>\n entry.ref.scope === \"survey\" && !Object.values(entry.contents).some(hasLocalizationText);\nexport function getLocalizationCoverage(entries: readonly LocalizationEntry[], locale: string) {\n const required = entries.filter((entry) => !isEmptySurveyLocalizationEntry(entry));\n const present = required.filter((entry) =>\n hasLocalizationText(ownValue(entry.contents, locale)),\n ).length;\n return { total: required.length, present, missing: required.length - present };\n}\n\n/** Fallback is a participant concern only; inventory and authoring readiness use exact locales. */\nexport function resolveParticipantContent(\n survey: Survey,\n ownerId: string,\n role: string,\n locales: readonly string[],\n) {\n for (const locale of locales) {\n const content = readLocalizationContent(survey, { scope: \"content\", ownerId, role }, locale);\n if (\n content &&\n (hasLocalizationText(content) ||\n // Nontext blocks remain meaningful without words; blank text still falls back.\n (content.type === \"richText\" &&\n content.doc.blocks.some(\n (block) =>\n block.type !== \"paragraph\" &&\n block.type !== \"heading\" &&\n block.type !== \"bulletList\" &&\n hasRenderableRichTextBlock(block),\n )))\n )\n return { locale, content };\n }\n return undefined;\n}\n"],"mappings":";;;;;;;;;;AAaA,MAAa,sBAAsB;CAAC;CAAS;CAAU;AAAM;AAE7D,MAAa,sBAAsB,UACjC,oBAAoB,SAAS,KAAyB;AACxD,MAAM,OAAO,GAAW,QAAQ,MAAM,OAAO,CAAC,CAAC,CAAC,SAAS,OAAO,GAAG;AACnE,MAAM,eAAe,MAAc,UACjC,UAAU,IACN,OAAO,MAAM,MAAM,OAAO,QAAQ,KAAK,OAAO,QAAQ,KACpD,KACA,KACF;CAAC;CAAG;CAAG;CAAG;AAAE,CAAC,CAAC,SAAS,KAAK,IAC1B,KACA;AAER,SAAgB,eAAe,OAAuC;CACpE,IAAI,OAA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F,OAAO;EAAE,OAAO,SAAS;EAAQ;EAAS,SAAS,SAAS,SAAS;CAAQ;AAC/E;;AAGA,SAAgB,0BACd,QACA,SACA,MACA,SACA;CACA,KAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,UAAU,wBAAwB,QAAQ;GAAE,OAAO;GAAW;GAAS;EAAK,GAAG,MAAM;EAC3F,IACE,YACC,oBAAoB,OAAO,KAEzB,QAAQ,SAAS,cAChB,QAAQ,IAAI,OAAO,MAChB,UACC,MAAM,SAAS,eACf,MAAM,SAAS,aACf,MAAM,SAAS,gBACf,2BAA2B,KAAK,CACpC,IAEJ,OAAO;GAAE;GAAQ;EAAQ;CAC7B;AAEF"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@case-framework/survey-core",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Implementation of the survey core to use in typescript/javascript projects.",
5
5
  "keywords": [
6
6
  "survey engine"
@@ -29,6 +29,10 @@
29
29
  "./editor/colors": {
30
30
  "types": "./build/editor/colors.d.mts",
31
31
  "import": "./build/editor/colors.mjs"
32
+ },
33
+ "./schema": {
34
+ "types": "./build/schema.d.mts",
35
+ "import": "./build/schema.mjs"
32
36
  }
33
37
  },
34
38
  "scripts": {
@@ -39,14 +43,16 @@
39
43
  "typecheck:tests": "tsc --noEmit -p tsconfig.test.json"
40
44
  },
41
45
  "dependencies": {
42
- "date-fns": "^4.1.0"
46
+ "@date-fns/utc": "^2.1.1",
47
+ "date-fns": "^4.1.0",
48
+ "zod": "^4.6.5"
43
49
  },
44
50
  "devDependencies": {
45
51
  "@eslint/js": "^9.39.4",
46
52
  "eslint": "^9.39.4",
47
53
  "tsdown": "^0.23.0",
48
54
  "typescript": "^6.0.3",
49
- "typescript-eslint": "^8.70.0",
55
+ "typescript-eslint": "^8.70.1",
50
56
  "vitest": "^5.0.1"
51
57
  }
52
58
  }