@case-framework/survey-core 0.3.0 → 0.4.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/build/editor.d.mts +52 -12
- package/build/editor.d.mts.map +1 -1
- package/build/editor.mjs +222 -43
- package/build/editor.mjs.map +1 -1
- package/build/index.d.mts +67 -45
- package/build/index.d.mts.map +1 -1
- package/build/index.mjs +171 -69
- package/build/index.mjs.map +1 -1
- package/build/package.json +5 -5
- package/build/{survey-wnGyIY66.d.mts → survey-DShEOjyz.d.mts} +378 -86
- package/build/survey-DShEOjyz.d.mts.map +1 -0
- package/build/{survey-DJbgFVPz.mjs → survey-yXdl8xkf.mjs} +428 -31
- package/build/survey-yXdl8xkf.mjs.map +1 -0
- package/package.json +5 -5
- package/build/survey-DJbgFVPz.mjs.map +0 -1
- package/build/survey-wnGyIY66.d.mts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"survey-yXdl8xkf.mjs","names":[],"sources":["../src/utils.ts","../src/survey/utils/value-reference.ts","../src/expressions/expression.ts","../src/expressions/template-value.ts","../src/survey/responses/value-types.ts","../src/survey/items/utils.ts","../src/survey/items/prefill.ts","../src/survey/items/survey-item.ts","../src/survey/items/types.ts","../src/survey/item-key.ts","../src/survey/utils/group-utils.ts","../src/survey/registry/built-in-items.ts","../src/survey/registry/item-registry.ts","../src/survey/survey-file-schema.ts","../src/survey/utils/translations.ts","../src/survey/utils/content.ts","../src/survey/survey.ts"],"sourcesContent":["\nfunction hashString(seed: string): number {\n let hash = 2166136261;\n\n for (let i = 0; i < seed.length; i++) {\n hash ^= seed.charCodeAt(i);\n hash = Math.imul(hash, 16777619);\n }\n\n return hash >>> 0;\n}\n\nexport function createSeededRandom(seed: string): () => number {\n let state = hashString(seed);\n\n return () => {\n state = (state + 0x6D2B79F5) >>> 0;\n let next = state;\n next = Math.imul(next ^ (next >>> 15), next | 1);\n next ^= next + Math.imul(next ^ (next >>> 7), next | 61);\n return ((next ^ (next >>> 14)) >>> 0) / 4294967296;\n };\n}\n\nexport function shuffleArray<T>(values: readonly T[], random: () => number = Math.random): T[] {\n const shuffledValues = [...values];\n\n for (let i = shuffledValues.length - 1; i > 0; i--) {\n const j = Math.floor(random() * (i + 1));\n [shuffledValues[i], shuffledValues[j]] = [shuffledValues[j], shuffledValues[i]];\n }\n\n return shuffledValues;\n}\n\n/**\n * Shuffles an array of indices using the Fisher-Yates shuffle algorithm\n * @param length - The length of the array to create indices for\n * @returns A shuffled array of indices from 0 to length-1\n */\nexport function shuffleIndices(length: number, random: () => number = Math.random): number[] {\n return shuffleArray(Array.from({ length }, (_, i) => i), random);\n}\n\nexport function structuredCloneMethod<T>(obj: T): T {\n if (typeof structuredClone !== 'undefined') {\n return structuredClone(obj);\n }\n // Fallback to JSON method\n return JSON.parse(JSON.stringify(obj));\n}\n\nconst ALPHABET = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';\n\nexport function generateId(): string {\n const length = 10;\n const timestamp = Date.now();\n let encodedTimestamp = '';\n let t = timestamp;\n const base = ALPHABET.length;\n\n while (t > 0) {\n encodedTimestamp = ALPHABET.charAt(t % base) + encodedTimestamp;\n t = Math.floor(t / base);\n }\n\n let randomPart = '';\n for (let i = 0; i < length; i++) {\n randomPart += ALPHABET.charAt(Math.floor(Math.random() * base));\n }\n return randomPart + encodedTimestamp;\n}\n\n\n/** Alphanumeric chars without ambiguous ones (0/O, 1/I) for human-readable coding keys. */\nconst CODING_KEY_ALPHABET = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ';\n\n/**\n * Generates a short random coding key suitable for item keys in exports/codebooks.\n * @param length - Key length (default 4)\n * @returns A random string of the specified length.\n */\nexport function generateCodingKey(length: number = 4): string {\n const base = CODING_KEY_ALPHABET.length;\n let key = '';\n for (let i = 0; i < length; i++) {\n key += CODING_KEY_ALPHABET.charAt(Math.floor(Math.random() * base));\n }\n return key;\n}\n","const SEPARATOR = '...';\n\nexport enum ValueReferenceMethod {\n get = 'get',\n isDefined = 'isDefined',\n}\n\n\n\nexport class ValueReference {\n _itemId: string;\n _name: ValueReferenceMethod;\n _slotId: string;\n\n constructor(str: string) {\n const parts = str.split(SEPARATOR);\n if (parts.length !== 3) {\n throw new Error('Invalid value reference: ' + str);\n }\n this._itemId = parts[0];\n this._name = parts[1] as ValueReferenceMethod;\n this._slotId = parts[2];\n }\n\n get itemId(): string {\n return this._itemId;\n }\n\n get name(): ValueReferenceMethod {\n return this._name;\n }\n\n get slotId(): string {\n return this._slotId;\n }\n\n set itemId(itemId: string) {\n this._itemId = itemId;\n }\n\n toString(): string {\n return `${this._itemId}${SEPARATOR}${this._name}${this._slotId ? SEPARATOR + this._slotId : ''}`;\n }\n\n static fromParts(itemId: string, name: ValueReferenceMethod, slotId: string): ValueReference {\n return new ValueReference(`${itemId}${SEPARATOR}${name}${SEPARATOR}${slotId}`);\n }\n}\n\n\nexport enum ReferenceUsageType {\n displayConditions = 'displayConditions',\n templateValues = 'templateValues',\n validations = 'validations',\n disabledConditions = 'disabledConditions',\n prefills = 'prefills',\n}\n\nexport interface ReferenceUsage {\n itemId: string;\n fullComponentKey?: string;\n usageType?: ReferenceUsageType;\n valueReference: ValueReference;\n}\n","import { ResponseValue, ValueType, } from \"../survey/responses\";\nimport { ValueReference } from \"../survey/utils/value-reference\";\n\n\nexport const ExpressionType = {\n Const: 'const',\n ResponseVariable: 'responseVariable',\n ContextVariable: 'contextVariable',\n Function: 'function',\n} as const;\n\nexport type ExpressionType = (typeof ExpressionType)[keyof typeof ExpressionType];\n\nexport const ContextVariableType = {\n Locale: 'locale',\n ParticipantFlag: 'participantFlag',\n CustomValue: 'customValue',\n CustomExpression: 'customExpression'\n} as const;\n\nexport type ContextVariableType = (typeof ContextVariableType)[keyof typeof ContextVariableType];\n\nexport interface ExpressionEditorConfig {\n usedTemplate?: string;\n label?: string;\n description?: string;\n}\n\nexport interface JsonConstExpression {\n type: typeof ExpressionType.Const;\n value?: ResponseValue;\n\n editorConfig?: ExpressionEditorConfig;\n}\n\nexport interface JsonResponseVariableExpression {\n type: typeof ExpressionType.ResponseVariable;\n variableRef: string;\n\n editorConfig?: ExpressionEditorConfig;\n}\n\nexport interface JsonContextVariableExpression {\n type: typeof ExpressionType.ContextVariable;\n\n contextType: ContextVariableType;\n key?: JsonExpression;\n arguments?: Array<JsonExpression | undefined>;\n asType?: ValueType;\n\n editorConfig?: ExpressionEditorConfig;\n}\n\nexport interface JsonFunctionExpression {\n type: typeof ExpressionType.Function;\n functionName: string;\n arguments: Array<JsonExpression | undefined>;\n\n editorConfig?: ExpressionEditorConfig;\n}\n\nexport type JsonExpression = JsonConstExpression | JsonResponseVariableExpression | JsonContextVariableExpression | JsonFunctionExpression;\n\n\n\n/**\n * Base class for all expressions.\n */\nexport abstract class Expression {\n type: ExpressionType;\n editorConfig?: ExpressionEditorConfig;\n\n constructor(type: ExpressionType, editorConfig?: ExpressionEditorConfig) {\n this.type = type;\n this.editorConfig = editorConfig;\n }\n\n static deserialize(json: JsonExpression | undefined): Expression | undefined {\n if (!json) {\n return undefined;\n }\n\n switch (json.type) {\n case ExpressionType.Const:\n return ConstExpression.deserialize(json);\n case ExpressionType.ResponseVariable:\n return ResponseVariableExpression.deserialize(json);\n case ExpressionType.ContextVariable:\n return ContextVariableExpression.deserialize(json);\n case ExpressionType.Function:\n return FunctionExpression.deserialize(json);\n }\n }\n\n /**\n * Returns all unique response variable references in the expression.\n * @returns A list of ValueReference objects.\n */\n abstract get responseVariableRefs(): ValueReference[]\n abstract serialize(): JsonExpression | undefined;\n\n clone(): Expression {\n return Expression.deserialize(this.serialize()) ?? (() => {\n throw new Error('Failed to clone expression');\n })();\n }\n}\n\nexport class ConstExpression extends Expression {\n declare type: typeof ExpressionType.Const;\n value?: ResponseValue;\n\n constructor(value?: ResponseValue, editorConfig?: ExpressionEditorConfig) {\n super(ExpressionType.Const, editorConfig);\n this.value = value;\n this.type = ExpressionType.Const;\n }\n\n static deserialize(json: JsonExpression): ConstExpression {\n if (json.type !== ExpressionType.Const) {\n throw new Error('Invalid expression type: ' + json.type);\n }\n\n return new ConstExpression(json.value, json.editorConfig);\n }\n\n get responseVariableRefs(): ValueReference[] {\n return [];\n }\n\n serialize(): JsonExpression {\n return {\n type: this.type,\n value: this.value,\n editorConfig: this.editorConfig\n }\n }\n\n updateItemKeyReferences(_oldItemKey: string, _newItemKey: string): boolean {\n // Const expressions don't have item references\n return false;\n }\n}\n\nexport class ResponseVariableExpression extends Expression {\n declare type: typeof ExpressionType.ResponseVariable;\n variableRef: string;\n\n constructor(variableRef: string, editorConfig?: ExpressionEditorConfig) {\n super(ExpressionType.ResponseVariable, editorConfig);\n this.variableRef = variableRef;\n this.type = ExpressionType.ResponseVariable;\n }\n\n static deserialize(json: JsonExpression): ResponseVariableExpression {\n if (json.type !== ExpressionType.ResponseVariable) {\n throw new Error('Invalid expression type: ' + json.type);\n }\n\n return new ResponseVariableExpression(json.variableRef, json.editorConfig);\n }\n\n get responseVariableRefs(): ValueReference[] {\n return [new ValueReference(this.variableRef)];\n }\n\n get responseVariableRef(): ValueReference {\n return new ValueReference(this.variableRef);\n }\n\n serialize(): JsonExpression {\n return {\n type: this.type,\n variableRef: this.variableRef,\n editorConfig: this.editorConfig\n }\n }\n}\n\nexport class ContextVariableExpression extends Expression {\n declare type: typeof ExpressionType.ContextVariable;\n\n contextType: ContextVariableType;\n key?: Expression;\n arguments?: Array<Expression | undefined>;\n asType?: ValueType;\n\n constructor(contextType: ContextVariableType, key?: Expression, args?: Array<Expression | undefined>, asType?: ValueType, editorConfig?: ExpressionEditorConfig) {\n super(ExpressionType.ContextVariable, editorConfig);\n this.type = ExpressionType.ContextVariable;\n this.contextType = contextType;\n this.key = key;\n this.arguments = args;\n this.asType = asType;\n }\n\n static deserialize(json: JsonExpression): ContextVariableExpression {\n if (json.type !== ExpressionType.ContextVariable) {\n throw new Error('Invalid expression type: ' + json.type);\n }\n\n return new ContextVariableExpression(json.contextType, Expression.deserialize(json.key), json.arguments?.map(arg => Expression.deserialize(arg)), json.asType, json.editorConfig);\n }\n\n get responseVariableRefs(): ValueReference[] {\n return this.arguments?.flatMap(arg => arg?.responseVariableRefs).filter(ref => ref !== undefined) ?? [];\n }\n\n serialize(): JsonExpression {\n return {\n type: this.type,\n contextType: this.contextType,\n key: this.key?.serialize(),\n arguments: this.arguments?.map(arg => arg?.serialize()),\n asType: this.asType,\n editorConfig: this.editorConfig\n }\n }\n}\n\n\nexport enum FunctionExpressionNames {\n and = 'and',\n or = 'or',\n not = 'not',\n\n list_contains = 'list_contains',\n\n // numeric functions\n eq = 'eq',\n gt = 'gt',\n gte = 'gte',\n lt = 'lt',\n lte = 'lte',\n in_range = 'in_range',\n\n sum = 'sum',\n min = 'min',\n max = 'max',\n\n\n\n\n // string functions\n str_eq = 'str_eq',\n\n // date functions\n date_eq = 'date_eq',\n}\n\nexport class FunctionExpression extends Expression {\n declare type: typeof ExpressionType.Function;\n functionName: FunctionExpressionNames;\n arguments: Array<Expression | undefined>;\n\n constructor(functionName: FunctionExpressionNames, args: Array<Expression | undefined>, editorConfig?: ExpressionEditorConfig) {\n super(ExpressionType.Function);\n this.type = ExpressionType.Function;\n this.functionName = functionName;\n this.arguments = args;\n this.editorConfig = editorConfig;\n }\n\n static deserialize(json: JsonExpression): FunctionExpression {\n if (json.type !== ExpressionType.Function) {\n throw new Error('Invalid expression type: ' + json.type);\n }\n\n const functionName = json.functionName as FunctionExpressionNames;\n if (!Object.values(FunctionExpressionNames).includes(functionName)) {\n throw new Error('Invalid function name: ' + functionName);\n }\n\n const expr = new FunctionExpression(functionName, json.arguments.map(arg => Expression.deserialize(arg)));\n expr.editorConfig = json.editorConfig;\n return expr;\n }\n\n get responseVariableRefs(): ValueReference[] {\n const refs = this.arguments.flatMap(arg => arg?.responseVariableRefs).filter(ref => ref !== undefined);\n const refStrings = refs.map(ref => ref.toString());\n return [...new Set(refStrings)].map(ref => new ValueReference(ref));\n }\n\n serialize(): JsonExpression | undefined {\n return {\n type: this.type,\n functionName: this.functionName,\n arguments: this.arguments.map(arg => arg?.serialize()),\n editorConfig: this.editorConfig\n }\n }\n}\n","import { ValueType } from \"../survey/responses\";\nimport { Expression, JsonExpression } from \"./expression\";\n\n\nexport enum TemplateDefTypes {\n Default = 'default',\n Date2String = 'date2string'\n}\n\nexport type TemplateValueBase = {\n type: TemplateDefTypes;\n returnType: ValueType;\n expression?: Expression;\n}\n\n\nexport type TemplateValueFormatDate = TemplateValueBase & {\n type: TemplateDefTypes.Date2String;\n returnType: typeof ValueType.string;\n dateFormat: string;\n}\n\nexport type TemplateValueDefinition = TemplateValueBase | TemplateValueFormatDate;\n\n\n\nexport const serializeTemplateValue = (templateValue: TemplateValueDefinition): JsonTemplateValue => {\n const json: JsonTemplateValue = {\n type: templateValue.type,\n returnType: templateValue.returnType,\n expression: templateValue.expression?.serialize(),\n }\n if (templateValue.type === TemplateDefTypes.Date2String) {\n json.dateFormat = (templateValue as TemplateValueFormatDate).dateFormat;\n }\n return json;\n}\n\nexport const serializeTemplateValues = (templateValues: Map<string, TemplateValueDefinition>): { [templateValueKey: string]: JsonTemplateValue } => {\n const json: { [templateValueKey: string]: JsonTemplateValue } = {};\n for (const [key, value] of templateValues.entries()) {\n json[key] = serializeTemplateValue(value);\n }\n return json;\n}\n\nexport const deserializeTemplateValue = (json: JsonTemplateValue): TemplateValueDefinition => {\n return {\n type: json.type,\n expression: json.expression ? Expression.deserialize(json.expression) : undefined,\n returnType: json.returnType,\n dateFormat: json.dateFormat\n }\n}\n\nexport const deserializeTemplateValues = (json: { [templateValueKey: string]: JsonTemplateValue }): Map<string, TemplateValueDefinition> => {\n return new Map(Object.entries(json).map(([key, value]) => [key, deserializeTemplateValue(value)]));\n}\n\nexport interface JsonTemplateValue {\n type: TemplateDefTypes;\n expression?: JsonExpression;\n returnType: ValueType;\n dateFormat?: string;\n}\n\n","export 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\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\n\nexport const NumberPrecision = {\n int: 'int',\n float: 'float',\n} as const;\n\nexport type NumberPrecision = (typeof NumberPrecision)[keyof typeof NumberPrecision];\n\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: number;\n}\n\nexport interface StringArrayResponse extends SlotResponseBase<typeof ValueType.stringArray> {\n value: string[];\n}\n\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\n\nexport interface DateArrayResponse extends SlotResponseBase<typeof ValueType.dateArray> {\n value: number[];\n}\n\n\nexport interface ReferenceArrayResponse extends SlotResponseBase<typeof ValueType.referenceArray> {\n value: string[];\n}\n\nexport type ResponseValue = StringResponse | DurationResponse | ReferenceResponse | NumberResponse | BooleanResponse | DateResponse | StringArrayResponse | DurationArrayResponse | NumberArrayResponse | DateArrayResponse | ReferenceArrayResponse;\n\n\nexport type ValueRefTypeLookup = {\n [valueRefString: string]: ValueType;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction isFiniteNumber(value: unknown): value is number {\n return typeof value === \"number\" && Number.isFinite(value);\n}\n\nfunction isStringArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every((item) => typeof item === \"string\");\n}\n\nfunction isNumberArray(value: unknown): value is number[] {\n return Array.isArray(value) && value.every((item) => isFiniteNumber(item));\n}\n\nfunction isOptionalNumberPrecision(value: unknown): value is NumberPrecision | undefined {\n return value === undefined || value === NumberPrecision.int || value === NumberPrecision.float;\n}\n\nfunction isDurationUnit(value: unknown): value is DurationUnit {\n return typeof value === \"string\" && Object.values(DurationUnits).includes(value as DurationUnit);\n}\n\nexport function isResponseValue(value: unknown): value is ResponseValue {\n if (!isPlainObject(value) || typeof value.type !== \"string\") {\n return false;\n }\n\n switch (value.type) {\n case ValueType.string:\n case ValueType.reference:\n return typeof value.value === \"string\";\n case ValueType.number:\n return isFiniteNumber(value.value) && isOptionalNumberPrecision(value.precision);\n case ValueType.boolean:\n return typeof value.value === \"boolean\";\n case ValueType.date:\n return isFiniteNumber(value.value);\n case ValueType.duration:\n return isFiniteNumber(value.value)\n && isDurationUnit(value.unit)\n && isOptionalNumberPrecision(value.precision);\n case ValueType.stringArray:\n case ValueType.referenceArray:\n return isStringArray(value.value);\n case ValueType.numberArray:\n case ValueType.dateArray:\n return isNumberArray(value.value)\n && (value.type !== ValueType.numberArray || isOptionalNumberPrecision(value.precision));\n case ValueType.durationArray:\n return isNumberArray(value.value)\n && isDurationUnit(value.unit)\n && isOptionalNumberPrecision(value.precision);\n default:\n return false;\n }\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\n","import { Expression, JsonExpression } from \"../../expressions\";\n\nexport interface DisplayConditions {\n root?: Expression;\n components?: {\n [componentKey: string]: Expression | undefined;\n }\n}\n\nexport interface JsonDisplayConditions {\n root?: JsonExpression;\n components?: {\n [componentKey: string]: JsonExpression | undefined;\n }\n}\n\nexport interface JsonDisabledConditions {\n components?: {\n [componentKey: string]: JsonExpression | undefined;\n }\n}\n\nexport interface DisabledConditions {\n components?: {\n [componentKey: string]: Expression | undefined;\n }\n}\n\nexport const displayConditionsFromJson = (json: JsonDisplayConditions): DisplayConditions => {\n return {\n root: json.root ? Expression.deserialize(json.root) : undefined,\n components: json.components ? Object.fromEntries(Object.entries(json.components).map(([key, value]) => [key, Expression.deserialize(value)])) : undefined\n }\n}\n\nexport const displayConditionsToJson = (displayConditions: DisplayConditions): JsonDisplayConditions => {\n return {\n root: displayConditions.root ? displayConditions.root.serialize() : undefined,\n components: displayConditions.components ? Object.fromEntries(Object.entries(displayConditions.components).map(([key, value]) => [key, value?.serialize()])) : undefined\n }\n}\n\nexport const disabledConditionsFromJson = (json: JsonDisabledConditions): DisabledConditions => {\n return {\n components: json.components ? Object.fromEntries(Object.entries(json.components).map(([key, value]) => [key, Expression.deserialize(value)])) : undefined\n }\n}\n\nexport const disabledConditionsToJson = (disabledConditions: DisabledConditions): JsonDisabledConditions => {\n return {\n components: disabledConditions.components ? Object.fromEntries(Object.entries(disabledConditions.components).map(([key, value]) => [key, value?.serialize()])) : undefined\n }\n}\n","import { Expression, type JsonExpression } from \"../../expressions\";\nimport type { ResponseValue } from \"../responses\";\n\nexport const SurveyItemPrefillApplyMode = {\n ifEmpty: \"ifEmpty\",\n} as const;\n\nexport type SurveyItemPrefillApplyMode = (typeof SurveyItemPrefillApplyMode)[keyof typeof SurveyItemPrefillApplyMode];\n\nexport const SurveyItemPrefillTargetType = {\n itemResponse: \"itemResponse\",\n field: \"field\",\n embeddedField: \"embeddedField\",\n} as const;\n\nexport type SurveyItemPrefillTargetType = (typeof SurveyItemPrefillTargetType)[keyof typeof SurveyItemPrefillTargetType];\n\nexport type JsonSurveyItemPrefillTarget =\n | {\n type: typeof SurveyItemPrefillTargetType.itemResponse;\n }\n | {\n type: typeof SurveyItemPrefillTargetType.field;\n fieldId: string;\n }\n | {\n type: typeof SurveyItemPrefillTargetType.embeddedField;\n optionId: string;\n fieldId: string;\n };\n\nexport type SurveyItemPrefillTarget = JsonSurveyItemPrefillTarget;\n\nexport interface SurveyItemPreviousResponseRef {\n surveyKey?: string;\n itemId: string;\n target?: SurveyItemPrefillTarget;\n}\n\nexport type JsonSurveyItemPrefillSource =\n | {\n type: \"static\";\n value: ResponseValue;\n }\n | {\n type: \"expression\";\n expression: JsonExpression;\n }\n | {\n type: \"templateValue\";\n key: string;\n }\n | {\n type: \"previousResponse\";\n ref: SurveyItemPreviousResponseRef;\n ifUnsupported?: \"skip\";\n };\n\nexport type SurveyItemPrefillSource =\n | {\n type: \"static\";\n value: ResponseValue;\n }\n | {\n type: \"expression\";\n expression: Expression;\n }\n | {\n type: \"templateValue\";\n key: string;\n }\n | {\n type: \"previousResponse\";\n ref: SurveyItemPreviousResponseRef;\n ifUnsupported?: \"skip\";\n };\n\nexport interface JsonSurveyItemPrefill {\n id: string;\n target: JsonSurveyItemPrefillTarget;\n when?: JsonExpression;\n apply?: SurveyItemPrefillApplyMode;\n source: JsonSurveyItemPrefillSource;\n}\n\nexport interface SurveyItemPrefill {\n id: string;\n target: SurveyItemPrefillTarget;\n when?: Expression;\n apply?: SurveyItemPrefillApplyMode;\n source: SurveyItemPrefillSource;\n}\n\nexport function deserializeSurveyItemPrefill(json: JsonSurveyItemPrefill): SurveyItemPrefill {\n switch (json.source.type) {\n case \"static\":\n return {\n id: json.id,\n target: json.target,\n when: Expression.deserialize(json.when),\n apply: json.apply,\n source: {\n type: \"static\",\n value: json.source.value,\n },\n };\n case \"expression\":\n return {\n id: json.id,\n target: json.target,\n when: Expression.deserialize(json.when),\n apply: json.apply,\n source: {\n type: \"expression\",\n expression: Expression.deserialize(json.source.expression) ?? (() => {\n throw new Error(`Prefill '${json.id}' is missing a valid expression source`);\n })(),\n },\n };\n case \"templateValue\":\n return {\n id: json.id,\n target: json.target,\n when: Expression.deserialize(json.when),\n apply: json.apply,\n source: {\n type: \"templateValue\",\n key: json.source.key,\n },\n };\n case \"previousResponse\":\n return {\n id: json.id,\n target: json.target,\n when: Expression.deserialize(json.when),\n apply: json.apply,\n source: {\n type: \"previousResponse\",\n ref: json.source.ref,\n ifUnsupported: json.source.ifUnsupported,\n },\n };\n default:\n throw new Error(`Unsupported prefill source type: ${(json.source as { type?: string }).type}`);\n }\n}\n\nexport function serializeSurveyItemPrefill(prefill: SurveyItemPrefill): JsonSurveyItemPrefill {\n switch (prefill.source.type) {\n case \"static\":\n return {\n id: prefill.id,\n target: prefill.target,\n when: prefill.when?.serialize(),\n apply: prefill.apply,\n source: {\n type: \"static\",\n value: prefill.source.value,\n },\n };\n case \"expression\":\n return {\n id: prefill.id,\n target: prefill.target,\n when: prefill.when?.serialize(),\n apply: prefill.apply,\n source: {\n type: \"expression\",\n expression: prefill.source.expression.serialize() ?? (() => {\n throw new Error(`Prefill '${prefill.id}' cannot serialize an empty expression source`);\n })(),\n },\n };\n case \"templateValue\":\n return {\n id: prefill.id,\n target: prefill.target,\n when: prefill.when?.serialize(),\n apply: prefill.apply,\n source: {\n type: \"templateValue\",\n key: prefill.source.key,\n },\n };\n case \"previousResponse\":\n return {\n id: prefill.id,\n target: prefill.target,\n when: prefill.when?.serialize(),\n apply: prefill.apply,\n source: {\n type: \"previousResponse\",\n ref: prefill.source.ref,\n ifUnsupported: prefill.source.ifUnsupported,\n },\n };\n default:\n throw new Error(`Unsupported prefill source type: ${(prefill.source as { type?: string }).type}`);\n }\n}\n\nexport function prefillTargetsEqual(left: SurveyItemPrefillTarget, right: SurveyItemPrefillTarget): boolean {\n if (left.type !== right.type) {\n return false;\n }\n\n switch (left.type) {\n case SurveyItemPrefillTargetType.itemResponse:\n return true;\n case SurveyItemPrefillTargetType.field:\n return left.fieldId === (right as Extract<SurveyItemPrefillTarget, { type: \"field\" }>).fieldId;\n case SurveyItemPrefillTargetType.embeddedField:\n return left.optionId === (right as Extract<SurveyItemPrefillTarget, { type: \"embeddedField\" }>).optionId\n && left.fieldId === (right as Extract<SurveyItemPrefillTarget, { type: \"embeddedField\" }>).fieldId;\n default:\n return false;\n }\n}\n","import { Expression } from \"../../expressions\";\nimport { RawSurveyItem } from \"../items\";\nimport { ResponseSlotDefinition } from \"../responses/slot-definition\";\nimport { ResponseValue, ValueRefTypeLookup, ValueType } from \"../responses/value-types\";\nimport { ReferenceUsage, ReferenceUsageType, ValueReferenceMethod } from \"../utils/value-reference\";\nimport { DisabledConditions, disabledConditionsFromJson, DisplayConditions, displayConditionsFromJson } from \"./utils\";\nimport { deserializeSurveyItemPrefill, prefillTargetsEqual, SurveyItemPrefill, SurveyItemPrefillTarget, SurveyItemPrefillTargetType } from \"./prefill\";\n\n/**\n * Core contract for survey item handlers.\n * Every item type (built-in and plugin) is represented by a handler class implementing this interface.\n * The core uses these methods without any casting.\n */\nexport interface SurveyItemCoreType<TConfig = unknown> {\n readonly type: string;\n readonly id: string;\n readonly key: string;\n readonly config: TConfig;\n\n isInteractive(): boolean;\n getResponseSlotDefinitions(): ResponseSlotDefinition[];\n getAvailableResponseValueSlots(byType?: ValueType): ValueRefTypeLookup;\n}\n\n/**\n * Base class for survey item handlers.\n * Each handler holds type, id, key, and config (properly typed) and implements core methods.\n * Subclass for each item type; the core works with SurveyItemHandler only—no casting needed.\n */\nexport abstract class SurveyItemCore<\n TType extends string = string,\n TConfig = unknown\n> implements SurveyItemCoreType<TConfig> {\n abstract readonly type: TType;\n readonly id: string;\n key: string;\n config: TConfig;\n\n private _rawItem: RawSurveyItem;\n\n displayConditions?: DisplayConditions;\n disabledConditions?: DisabledConditions;\n validations?: {\n [validationKey: string]: Expression | undefined;\n }\n prefills?: SurveyItemPrefill[];\n\n\n constructor(rawItem: RawSurveyItem) {\n this._rawItem = rawItem;\n this.updateExpressions();\n this.id = this._rawItem.id;\n this.key = this._rawItem.key;\n this.config = this.parseConfig(this._rawItem.config);\n }\n\n /** Parse raw config from JSON into typed config. Override in subclasses. */\n abstract parseConfig(rawConfig: unknown): TConfig;\n abstract isInteractive(): boolean;\n abstract getResponseSlotDefinitions(): ResponseSlotDefinition[];\n\n protected getAdditionalResponseValueSlots(): ValueRefTypeLookup {\n return {};\n }\n\n getAvailableResponseValueSlots(byType?: ValueType): ValueRefTypeLookup {\n const valueRefs: ValueRefTypeLookup = {};\n\n for (const slot of this.getResponseSlotDefinitions()) {\n valueRefs[`${this.id}...${ValueReferenceMethod.get}...${slot.slotId}`] = slot.valueType;\n valueRefs[`${this.id}...${ValueReferenceMethod.isDefined}...${slot.slotId}`] = ValueType.boolean;\n }\n\n Object.assign(valueRefs, this.getAdditionalResponseValueSlots());\n\n if (!byType) {\n return valueRefs;\n }\n\n return Object.fromEntries(\n Object.entries(valueRefs).filter(([, valueType]) => valueType === byType)\n );\n }\n\n get rawItem(): RawSurveyItem {\n return this._rawItem;\n }\n\n get metadata(): { [key: string]: string } {\n return this._rawItem.metadata ?? {};\n }\n\n set metadata(metadata: { [key: string]: string }) {\n this.updateRawItem({\n ...this._rawItem,\n metadata: metadata,\n });\n }\n\n updateRawItem(rawItem: RawSurveyItem) {\n if (rawItem.id !== this.id) {\n throw new Error('Cannot update raw item with a different id');\n }\n this._rawItem = rawItem;\n this.updateExpressions();\n this.key = rawItem.key;\n this.config = this.parseConfig(rawItem.config);\n }\n\n private updateExpressions() {\n this.displayConditions = this._rawItem.displayConditions ? displayConditionsFromJson(this._rawItem.displayConditions) : undefined;\n this.disabledConditions = this._rawItem.disabledConditions ? disabledConditionsFromJson(this._rawItem.disabledConditions) : undefined;\n this.validations = this._rawItem.validations ? Object.fromEntries(Object.entries(this._rawItem.validations).map(([key, value]) => [key, Expression.deserialize(value)])) : undefined;\n this.prefills = this._rawItem.prefills?.map(prefill => deserializeSurveyItemPrefill(prefill));\n }\n\n getReferenceUsages(): ReferenceUsage[] {\n const usages: ReferenceUsage[] = [];\n\n if (this.displayConditions) {\n // root\n for (const ref of this.displayConditions.root?.responseVariableRefs || []) {\n usages.push({\n itemId: this.id,\n usageType: ReferenceUsageType.displayConditions,\n valueReference: ref,\n });\n }\n\n // components\n for (const [componentKey, expression] of Object.entries(this.displayConditions.components || {})) {\n for (const ref of expression?.responseVariableRefs || []) {\n usages.push({\n itemId: this.id,\n fullComponentKey: componentKey,\n usageType: ReferenceUsageType.displayConditions,\n valueReference: ref,\n });\n }\n }\n }\n\n if (this.disabledConditions) {\n for (const [componentKey, expression] of Object.entries(this.disabledConditions.components || {})) {\n for (const ref of expression?.responseVariableRefs || []) {\n usages.push({\n itemId: this.id,\n fullComponentKey: componentKey,\n usageType: ReferenceUsageType.disabledConditions,\n valueReference: ref,\n });\n }\n }\n }\n\n if (this.validations) {\n for (const [validationKey, expression] of Object.entries(this.validations)) {\n for (const ref of expression?.responseVariableRefs || []) {\n usages.push({\n itemId: this.id,\n fullComponentKey: validationKey,\n usageType: ReferenceUsageType.validations,\n valueReference: ref,\n });\n }\n }\n }\n\n if (this.prefills) {\n for (const prefill of this.prefills) {\n for (const ref of prefill.when?.responseVariableRefs || []) {\n usages.push({\n itemId: this.id,\n fullComponentKey: prefill.id,\n usageType: ReferenceUsageType.prefills,\n valueReference: ref,\n });\n }\n\n if (prefill.source.type === \"expression\") {\n for (const ref of prefill.source.expression.responseVariableRefs || []) {\n usages.push({\n itemId: this.id,\n fullComponentKey: prefill.id,\n usageType: ReferenceUsageType.prefills,\n valueReference: ref,\n });\n }\n }\n }\n }\n\n return usages;\n }\n\n resolvePrefillTarget(target: SurveyItemPrefillTarget): ResponseSlotDefinition | undefined {\n const slotDefinitions = this.getResponseSlotDefinitions();\n const explicitMatch = slotDefinitions.find((slot) =>\n slot.prefillTarget !== undefined && prefillTargetsEqual(slot.prefillTarget, target)\n );\n if (explicitMatch) {\n return explicitMatch;\n }\n\n if (target.type === SurveyItemPrefillTargetType.itemResponse && slotDefinitions.length === 1) {\n return slotDefinitions[0];\n }\n\n return undefined;\n }\n\n normalizePrefillValue(\n _prefill: SurveyItemPrefill,\n targetSlot: ResponseSlotDefinition,\n value: ResponseValue,\n ): ResponseValue | undefined {\n return value.type === targetSlot.valueType ? value : undefined;\n }\n}\n\n\n/**\n * Constructor type for handler classes. Used by the registry to instantiate handlers.\n */\nexport type ItemCoreConstructor<TType extends string = string, TConfig = unknown> = new (\n rawItem: RawSurveyItem\n) => SurveyItemCore<TType, TConfig>;\n","export enum ReservedSurveyItemTypes {\n Group = 'group',\n PageBreak = 'page-break',\n}\n\n","\n/**\n * SurveyItemKey stores the key of the item and the path to the item.\n */\n\nexport class SurveyItemKey {\n private _itemKey: string;\n private _path: Array<string>;\n private _keySeparator: string;\n\n constructor(itemKey: string, path: string[] | undefined, keySeparator: string = '.') {\n this._itemKey = itemKey;\n this._path = path ?? [];\n this._keySeparator = keySeparator;\n }\n\n get itemKey(): string {\n return this._itemKey;\n }\n\n get path(): Array<string> {\n return this._path;\n }\n\n get parentFullKey(): string {\n return this._path.join(this._keySeparator);\n }\n\n get fullKey(): string {\n return [...this._path, this._itemKey].join(this._keySeparator);\n }\n\n get isRoot(): boolean {\n return this._path.length === 0;\n }\n\n get keySeparator(): string {\n return this._keySeparator;\n }\n\n set keySeparator(keySeparator: string) {\n this._keySeparator = keySeparator;\n }\n}\n\n","/**\n * Shared utilities for array operations.\n */\n\n/**\n * Swap two elements in an array by index.\n * @returns A new array with the elements swapped\n */\nexport function swapArrayElements<T>(arr: T[], fromIndex: number, toIndex: number): T[] {\n const result = [...arr];\n [result[fromIndex], result[toIndex]] = [result[toIndex], result[fromIndex]];\n return result;\n}\n\n/**\n * Move an element from one index to another.\n * @returns A new array with the element moved\n */\nexport function moveArrayElement<T>(arr: T[], fromIndex: number, toIndex: number): T[] {\n const result = [...arr];\n const [moved] = result.splice(fromIndex, 1);\n result.splice(toIndex, 0, moved);\n return result;\n}\n","import { ReservedSurveyItemTypes } from \"../items/types\";\nimport { ItemCoreConstructor, SurveyItemCore } from \"../items/survey-item\";\nimport { moveArrayElement, swapArrayElements } from \"../utils/group-utils\";\n\n\n/**\n * Group item core.\n */\nexport type GroupConfig = {\n items?: string[];\n shuffleItems?: boolean;\n isRoot?: boolean;\n};\n\nexport class GroupItemCore extends SurveyItemCore<\n typeof ReservedSurveyItemTypes.Group,\n GroupConfig\n> {\n readonly type = ReservedSurveyItemTypes.Group;\n\n parseConfig(rawConfig: unknown): GroupConfig {\n const cfg = (rawConfig ?? {}) as Partial<GroupConfig>;\n return {\n items: cfg.items,\n shuffleItems: cfg.shuffleItems,\n isRoot: cfg.isRoot,\n };\n }\n\n serializeConfig(): unknown {\n return this.config;\n }\n\n isInteractive(): boolean {\n return false;\n }\n\n getResponseSlotDefinitions() {\n return [];\n }\n\n isRoot(): boolean {\n return this.config.isRoot ?? false;\n }\n\n get items(): string[] {\n return this.config.items ?? [];\n }\n\n /**\n * Add a child item id to this group at the given index.\n * @param itemId The id of the item to add to this group.\n * @param index The index at which to add the item. If not provided, the item is added to the end of the group.\n */\n addChild(itemId: string, index?: number): void {\n const items = this.config.items ??= [];\n const insertIndex = index !== undefined ? Math.min(index, items.length) : items.length;\n items.splice(insertIndex, 0, itemId);\n this.updateRawItem({\n ...this.rawItem,\n config: { ...this.config },\n });\n }\n\n /**\n * Remove a child item id from this group.\n * @param itemId The id of the item to remove from this group.\n */\n removeChild(itemId: string): void {\n const items = this.config.items ??= [];\n const index = items.indexOf(itemId);\n if (index !== -1) {\n items.splice(index, 1);\n this.updateRawItem({\n ...this.rawItem,\n config: { ...this.config },\n });\n }\n }\n\n /**\n * Check if an item is a direct child of this group.\n */\n hasChild(itemId: string): boolean {\n return this.items.includes(itemId);\n }\n\n /** Whether items in this group should be shuffled. */\n get shuffleItems(): boolean {\n return this.config.shuffleItems ?? false;\n }\n\n set shuffleItems(value: boolean) {\n this.config.shuffleItems = value;\n this.updateRawItem({\n ...this.rawItem,\n config: { ...this.config },\n });\n }\n\n /**\n * Get the ordered list of child item ids.\n */\n getChildrenIds(): string[] {\n return [...this.items];\n }\n\n /**\n * Swap two items by their positions in the group.\n * @throws Error if indices are out of bounds\n */\n swapItemsByIndex(from: number, to: number): void {\n const items = this.items;\n if (from < 0 || from >= items.length || to < 0 || to >= items.length) {\n throw new Error(`Index out of bounds. Valid range is 0-${items.length - 1}`);\n }\n if (from === to) return;\n this.config.items = swapArrayElements(items, from, to);\n this.updateRawItem({\n ...this.rawItem,\n config: { ...this.config },\n });\n }\n\n /**\n * Swap two items by their ids.\n * @throws Error if either id is not found in this group\n */\n swapItemsById(id: string, withId: string): void {\n const items = this.items;\n const index1 = items.indexOf(id);\n const index2 = items.indexOf(withId);\n if (index1 === -1) {\n throw new Error(`Item '${id}' not found in group '${this.key}'`);\n }\n if (index2 === -1) {\n throw new Error(`Item '${withId}' not found in group '${this.key}'`);\n }\n this.swapItemsByIndex(index1, index2);\n }\n\n /**\n * Move an item by id to a specific index.\n * @throws Error if the item is not found or index is out of bounds\n */\n moveItemToIndex(id: string, index: number): void {\n const items = this.items;\n const fromIndex = items.indexOf(id);\n if (fromIndex === -1) {\n throw new Error(`Item '${id}' not found in group '${this.key}'`);\n }\n if (index < 0 || index >= items.length) {\n throw new Error(`Index out of bounds. Valid range is 0-${items.length - 1}`);\n }\n if (fromIndex === index) return;\n this.config.items = moveArrayElement(items, fromIndex, index);\n this.updateRawItem({\n ...this.rawItem,\n config: { ...this.config },\n });\n }\n}\n\n/**\n * Page break item core.\n */\nexport type PageBreakConfig = Record<string, never>;\n\nexport class PageBreakItemCore extends SurveyItemCore<\n typeof ReservedSurveyItemTypes.PageBreak,\n PageBreakConfig\n> {\n readonly type = ReservedSurveyItemTypes.PageBreak;\n\n parseConfig(_rawConfig: unknown): PageBreakConfig {\n return {};\n }\n\n serializeConfig(): unknown {\n return undefined;\n }\n\n isInteractive(): boolean {\n return false;\n }\n\n getResponseSlotDefinitions() {\n return [];\n }\n}\n\n/**\n * Built-in item type.\n */\nexport type BuiltInItemType = typeof ReservedSurveyItemTypes.Group | typeof ReservedSurveyItemTypes.PageBreak;\n\nexport const builtInItemCoreRegistry: Record<BuiltInItemType, ItemCoreConstructor> = {\n [ReservedSurveyItemTypes.Group]: GroupItemCore,\n [ReservedSurveyItemTypes.PageBreak]: PageBreakItemCore,\n};\n\nexport const isBuiltInItemType = (itemType: string): itemType is BuiltInItemType =>\n itemType in builtInItemCoreRegistry;\n","import { ItemCoreConstructor, SurveyItemCore } from \"../items/survey-item\";\nimport { RawSurveyItem } from \"../items/survey-item-json\";\nimport { builtInItemCoreRegistry, isBuiltInItemType } from \"./built-in-items\";\nimport type { AnyItemExpressionDefinition } from \"../../expressions/item-expression-registry\";\n\n/**\n * Registry maps item type name → handler constructor.\n * Plugins extend this with their own handler classes.\n */\nexport type ItemTypeRegistry = Record<string, new (rawItem: RawSurveyItem) => SurveyItemCore>;\n\n/** Item type identifier (e.g. \"singleChoiceQuestion\", \"display\"). */\nexport type ItemTypeName = string;\n\n/** Capabilities of an item type (interactive, supports children). */\nexport interface ItemTypeCapabilities {\n interactive?: boolean;\n supportsChildren?: boolean;\n}\n\n/**\n * Definition of an item type: its name, constructor, and optional capabilities.\n * Used by editor/UI layers to compose registries.\n */\nexport interface ItemTypeDefinition {\n itemType: ItemTypeName;\n constructor: ItemCoreConstructor;\n capabilities?: ItemTypeCapabilities;\n expressions?: AnyItemExpressionDefinition[];\n}\n\n/** Registry mapping item type name → definition. */\nexport type ItemTypeDefinitionRegistry = Record<ItemTypeName, ItemTypeDefinition>;\n\n/** Convert constructor registry to explicit definitions for higher-layer composition. */\nexport function toItemTypeDefinitionRegistry(registry: ItemTypeRegistry): ItemTypeDefinitionRegistry {\n return Object.fromEntries(\n Object.entries(registry).map(([itemType, constructor]) => [\n itemType,\n { itemType, constructor },\n ])\n );\n}\n\n\n/**\n * Creates a handler instance for a raw survey item.\n * Uses built-in registry for group/page-break, otherwise the provided plugin registry.\n */\nexport function createItemCore(\n rawItem: RawSurveyItem,\n pluginRegistry?: ItemTypeRegistry\n): SurveyItemCore {\n if (isBuiltInItemType(rawItem.itemType)) {\n const HandlerClass = builtInItemCoreRegistry[rawItem.itemType];\n return new HandlerClass(rawItem);\n }\n\n if (pluginRegistry && rawItem.itemType in pluginRegistry) {\n const HandlerClass = pluginRegistry[rawItem.itemType];\n return new HandlerClass(rawItem);\n }\n\n throw new Error(`Unknown item type: ${rawItem.itemType}`);\n}\n\n/**\n * Merge built-in handlers with plugin registry for a complete registry.\n */\nexport function createFullRegistry(pluginRegistry?: ItemTypeRegistry): ItemTypeRegistry {\n return {\n ...builtInItemCoreRegistry,\n ...pluginRegistry,\n };\n}\n\n/** Build full registry as explicit definitions for editor/ui composition. */\nexport function createItemTypeDefinitionRegistry(pluginRegistry?: ItemTypeRegistry): ItemTypeDefinitionRegistry {\n return toItemTypeDefinitionRegistry(createFullRegistry(pluginRegistry));\n}\n","import { JsonTemplateValue } from \"../expressions/template-value\";\nimport { RawSurveyItem } from \"./items\";\nimport { JsonSurveyTranslations } from \"./utils/translations\";\n\nexport const CURRENT_SURVEY_SCHEMA = 'https://github.com/case-framework/case-survey-toolkit/packages/survey-core/schemas/survey-schema.json';\n// TODO: generate schema from survey-core.ts\n\n\nexport interface SurveyVersion {\n id?: string;\n surveyKey: string;\n published?: number;\n unpublished?: number;\n versionId?: string;\n survey: RawSurvey;\n}\n\nexport type RawSurveyAsset =\n | {\n kind: 'image';\n source: {\n type: 'embedded';\n mediaType: string;\n encoding: 'base64';\n data: string;\n };\n metadata?: {\n name?: string;\n filename?: string;\n alt?: string;\n width?: number;\n height?: number;\n };\n };\n\nexport type RawSurvey = {\n $schema: string;\n maxItemsPerPage?: { large: number, small: number };\n\n surveyItems: Array<RawSurveyItem>;\n assets?: Record<string, RawSurveyAsset>;\n\n metadata?: {\n [key: string]: string\n }\n templateValues?: {\n [templateValueKey: string]: JsonTemplateValue;\n };\n translations?: JsonSurveyTranslations;\n}\n","import { structuredCloneMethod } from \"../../utils\";\nimport { Content } from \"./content\";\n\n\nexport const validateLocale = (locale: string): void => {\n if (locale.trim() === '') {\n throw new Error('Locale cannot be empty');\n }\n}\n\nexport class SurveyItemTranslations {\n private _translations?: {\n [locale: string]: JsonComponentContent;\n };\n\n constructor() {\n this._translations = {};\n }\n\n setContent(locale: string, contentKey: string, content?: Content): void {\n validateLocale(locale);\n if (!this._translations?.[locale]) {\n if (!content) {\n // No need to do anything if content is undefined\n return\n }\n this._translations![locale] = {};\n }\n if (!content) {\n delete this._translations![locale][contentKey];\n } else {\n this._translations![locale][contentKey] = content;\n }\n }\n\n setAllForLocale(locale: string, content?: JsonComponentContent): void {\n validateLocale(locale);\n if (!this._translations?.[locale]) {\n if (!content) {\n // No need to do anything if content is undefined\n return\n }\n this._translations![locale] = {};\n }\n this._translations![locale] = content || {};\n }\n\n get locales(): string[] {\n return Object.keys(this._translations || {});\n }\n\n getAllForLocale(locale: string): JsonComponentContent | undefined {\n return this._translations?.[locale];\n }\n\n getContent(locale: string, contentKey: string, fallbackLocale?: string): Content | undefined {\n const content = this._translations?.[locale]?.[contentKey];\n if (content) {\n return content;\n }\n if (fallbackLocale) {\n return this._translations?.[fallbackLocale]?.[contentKey];\n }\n return undefined;\n }\n\n /**\n * Create a deep clone that can be safely mutated before persisting with\n * `setItemTranslations` or `updateItemTranslations`.\n */\n clone(): SurveyItemTranslations {\n const cloned = new SurveyItemTranslations();\n\n for (const locale of this.locales) {\n const localeContent = this.getAllForLocale(locale);\n if (!localeContent) {\n continue;\n }\n\n cloned.setAllForLocale(locale, structuredCloneMethod(localeContent));\n }\n\n return cloned;\n }\n\n /**\n * Remove a single content key from every locale in this translation set.\n */\n removeContentKey(contentKey: string): void {\n for (const locale of this.locales) {\n delete this._translations?.[locale]?.[contentKey];\n }\n }\n\n /**\n * Remove every content key that is exactly the prefix or nested beneath it.\n */\n removeContentKeysWithPrefix(prefix: string): void {\n for (const locale of this.locales) {\n const localeContent = this._translations?.[locale];\n if (!localeContent) {\n continue;\n }\n\n for (const contentKey of Object.keys(localeContent)) {\n if (contentKey === prefix || contentKey.startsWith(prefix + '.')) {\n delete localeContent[contentKey];\n }\n }\n }\n }\n\n /**\n * Remove empty locales in place.\n * Returns `undefined` when no translations remain so callers can pass the\n * result directly into `setItemTranslations` / `updateItemTranslations`.\n */\n compact(): SurveyItemTranslations | undefined {\n for (const locale of this.locales) {\n const localeContent = this._translations?.[locale];\n if (!localeContent) {\n continue;\n }\n\n if (Object.keys(localeContent).length === 0) {\n delete this._translations?.[locale];\n }\n }\n\n return this.locales.length > 0 ? this : undefined;\n }\n}\n\nexport interface SurveyCardTranslations {\n [locale: string]: SurveyCardContent;\n}\n\n\nexport class SurveyTranslations {\n private _translations: JsonSurveyTranslations;\n\n constructor(translations?: JsonSurveyTranslations) {\n this._translations = translations || {};\n }\n\n\n serialize(): JsonSurveyTranslations | undefined {\n if (this.locales.length === 0) {\n return undefined;\n }\n return this._translations;\n }\n\n get locales(): string[] {\n return Object.keys(this._translations);\n }\n\n removeLocale(locale: string): void {\n validateLocale(locale);\n delete this._translations[locale];\n }\n\n renameLocale(oldLocale: string, newLocale: string): void {\n validateLocale(oldLocale);\n validateLocale(newLocale);\n if (this._translations[oldLocale]) {\n this._translations[newLocale] = this._translations[oldLocale];\n delete this._translations[oldLocale];\n }\n }\n\n cloneLocaleAs(locale: string, newLocale: string): void {\n validateLocale(locale);\n validateLocale(newLocale);\n if (this._translations[locale]) {\n this._translations[newLocale] = structuredCloneMethod(this._translations[locale]);\n }\n }\n\n get surveyCardContent(): SurveyCardTranslations | undefined {\n const translations: SurveyCardTranslations = {};\n for (const locale of this.locales) {\n const contentForLocale = this._translations?.[locale]?.surveyCardContent;\n if (contentForLocale) {\n translations[locale] = contentForLocale as SurveyCardContent;\n }\n }\n return translations;\n }\n\n get navigationContent(): { [locale: string]: NavigationContent } | undefined {\n const translations: { [locale: string]: NavigationContent } = {};\n for (const locale of this.locales) {\n const contentForLocale = this._translations?.[locale]?.navigationContent;\n if (contentForLocale) {\n translations[locale] = contentForLocale as NavigationContent;\n }\n }\n return translations;\n }\n\n get validationMessages(): { [locale: string]: { invalidResponse?: Content } } | undefined {\n const translations: { [locale: string]: { invalidResponse?: Content } } = {};\n for (const locale of this.locales) {\n const contentForLocale = this._translations?.[locale]?.validationMessages;\n if (contentForLocale) {\n translations[locale] = contentForLocale as { invalidResponse?: Content };\n }\n }\n return translations;\n }\n\n setSurveyCardContent(locale: string, content?: SurveyCardContent): void {\n validateLocale(locale);\n if (!this._translations[locale]) {\n if (!content) {\n // No need to do anything if content is undefined\n return\n }\n this._translations[locale] = {};\n }\n this._translations[locale].surveyCardContent = content;\n }\n\n setNavigationContent(locale: string, content?: NavigationContent): void {\n validateLocale(locale);\n if (!this._translations[locale]) {\n if (!content) {\n // No need to do anything if content is undefined\n return\n }\n this._translations[locale] = {};\n }\n this._translations[locale].navigationContent = content;\n }\n\n setValidationMessages(locale: string, content?: { invalidResponse?: Content }): void {\n validateLocale(locale);\n if (!this._translations[locale]) {\n if (!content) {\n // No need to do anything if content is undefined\n return\n }\n this._translations[locale] = {};\n }\n this._translations[locale].validationMessages = content;\n }\n\n getItemTranslations(itemId: string): SurveyItemTranslations | undefined {\n const itemTranslations: SurveyItemTranslations = new SurveyItemTranslations();\n for (const locale of this.locales) {\n const contentForLocale = this._translations?.[locale].itemTranslations?.[itemId];\n itemTranslations.setAllForLocale(locale, contentForLocale as JsonComponentContent);\n }\n return itemTranslations.locales.length > 0 ? itemTranslations : undefined;\n }\n\n /**\n * Persist item translations after normalizing them:\n * empty keys/locales are removed automatically, and an empty translation set\n * clears the item's stored translations entirely.\n */\n setItemTranslations(itemId: string, itemContent?: SurveyItemTranslations): void {\n const normalizedItemContent = itemContent?.clone().compact();\n\n normalizedItemContent?.locales.forEach(locale => validateLocale(locale));\n if (!normalizedItemContent) {\n for (const locale of this.locales) {\n if (this._translations[locale].itemTranslations?.[itemId]) {\n delete this._translations[locale].itemTranslations?.[itemId];\n }\n }\n } else {\n const localesInUpdate = normalizedItemContent.locales;\n // Add new locales to the translations\n for (const locale of localesInUpdate) {\n if (!this.locales.includes(locale)) {\n this._translations[locale] = {};\n }\n }\n for (const locale of this.locales) {\n if (localesInUpdate.includes(locale)) {\n if (!this._translations[locale]) {\n this._translations[locale] = {};\n }\n if (!this._translations[locale].itemTranslations) {\n this._translations[locale].itemTranslations = {};\n }\n this._translations[locale].itemTranslations![itemId] = normalizedItemContent.getAllForLocale(locale)!;\n } else {\n delete this._translations[locale].itemTranslations?.[itemId];\n }\n }\n }\n }\n\n /**\n * Rename a component key (within an item) - update key in all translations and remove old key\n * @param itemKey - The key of the item\n * @param oldKey - The old key of the component\n * @param newKey - The new key of the component\n */\n onComponentKeyChanged(itemKey: string, oldKey: string, newKey: string): void {\n for (const locale of this.locales) {\n const itemTranslations = this._translations?.[locale].itemTranslations?.[itemKey] as JsonComponentContent;\n if (itemTranslations) {\n for (const key of Object.keys(itemTranslations)) {\n if (key.startsWith(oldKey + '.') || key === oldKey) {\n itemTranslations[key.replace(oldKey, newKey)] = { ...itemTranslations[key] };\n delete itemTranslations[key];\n }\n }\n }\n }\n }\n\n /**\n * Remove all translations for a component\n * @param itemId - The id of the item\n * @param componentKey - The key of the component\n */\n onComponentDeleted(itemId: string, componentKey: string): void {\n for (const locale of this.locales) {\n const itemTranslations = this._translations?.[locale].itemTranslations?.[itemId];\n if (itemTranslations) {\n for (const key of Object.keys(itemTranslations)) {\n if (key.startsWith(componentKey + '.') || key === componentKey) {\n delete itemTranslations[key as keyof typeof itemTranslations];\n }\n }\n }\n }\n }\n\n /**\n * Remove all translations for an item\n * @param id - The id of the item\n */\n onItemDeleted(id: string): void {\n for (const locale of this.locales) {\n delete this._translations![locale].itemTranslations?.[id];\n }\n }\n}\n\n\n/**\n * Json Schemas for translations\n */\nexport type JsonComponentContent = {\n [contentKey: string]: Content;\n}\n\n\nexport interface SurveyCardContent {\n name?: Content;\n description?: Content;\n typicalDuration?: Content;\n}\n\nexport interface NavigationContent {\n previousButtonText?: Content;\n nextButtonText?: Content;\n submitButtonText?: Content;\n pageIndicatorText?: Content;\n submitBoxMessage?: Content;\n}\n\nexport interface JsonSurveyTranslations {\n [locale: string]: {\n surveyCardContent?: SurveyCardContent;\n navigationContent?: NavigationContent;\n validationMessages?: {\n invalidResponse?: Content;\n }\n itemTranslations?: {\n [itemId: string]: JsonComponentContent;\n }\n }\n}\n","export enum ContentType {\n richText = 'richText',\n plain = 'plain',\n md = 'md'\n}\n\nexport type ContentAttributes = Record<string, unknown>;\n\nexport type TextAlignment = 'left' | 'center' | 'right' | 'justify';\n\nexport type RichTextStyle = {\n weight?: 'strong' | 'normal';\n italic?: 'italic' | 'normal';\n underline?: 'underline' | 'none';\n color?: 'primary' | 'accent' | 'default';\n}\n\nexport type RichTextTextInline = {\n type: 'text';\n text: string;\n style?: RichTextStyle;\n attrs?: ContentAttributes;\n}\n\nexport type RichTextTemplateInline = {\n type: 'template';\n key: string;\n style?: RichTextStyle;\n attrs?: ContentAttributes;\n}\n\nexport type RichTextLineBreakInline = {\n type: 'lineBreak';\n attrs?: ContentAttributes;\n}\n\n/** Inline nodes allowed inside a {@link RichTextLinkInline} (no nested links). */\nexport type RichTextLinkChildInline =\n | RichTextTextInline\n | RichTextTemplateInline\n | RichTextLineBreakInline;\n\nexport type RichTextLinkInline = {\n type: 'link';\n href: string;\n target?: string | null;\n rel?: string | null;\n title?: string | null;\n attrs?: ContentAttributes;\n children: RichTextLinkChildInline[];\n}\n\nexport type RichTextInlineExtension = {\n type: 'inlineExtension';\n name: string;\n attrs?: ContentAttributes;\n}\n\nexport type RichTextInlineNode =\n | RichTextTextInline\n | RichTextTemplateInline\n | RichTextLinkInline\n | RichTextLineBreakInline\n | RichTextInlineExtension;\n\nexport type RichTextParagraphBlock = {\n type: 'paragraph';\n children: RichTextInlineNode[];\n alignment?: TextAlignment;\n attrs?: ContentAttributes;\n}\n\nexport type RichTextHeadingBlock = {\n type: 'heading';\n level: 1 | 2 | 3 | 4 | 5 | 6;\n children: RichTextInlineNode[];\n alignment?: TextAlignment;\n attrs?: ContentAttributes;\n}\n\nexport type RichTextListItemBlock = {\n type: 'listItem';\n children: RichTextParagraphBlock[];\n attrs?: ContentAttributes;\n}\n\nexport type RichTextBulletListBlock = {\n type: 'bulletList';\n items: RichTextListItemBlock[];\n attrs?: ContentAttributes;\n}\n\nexport type SurveyContentImageSource =\n | {\n type: 'external';\n url: string;\n }\n | {\n type: 'asset';\n assetId: string;\n };\n\nexport type RichTextImageDimension =\n | { unit: 'px'; value: number }\n | { unit: '%'; value: number };\n\nexport type RichTextImageSize = {\n width?: RichTextImageDimension;\n maxWidth?: RichTextImageDimension;\n};\n\nexport type RichTextImageBlock = {\n type: 'image';\n source: SurveyContentImageSource;\n alt?: string;\n caption?: RichTextParagraphBlock[];\n size?: RichTextImageSize;\n alignment?: TextAlignment;\n attrs?: ContentAttributes;\n}\n\nexport type RichTextInfoBoxBlock = {\n type: 'infoBox';\n tone?: 'info' | 'warning';\n title?: RichTextInlineNode[];\n collapsible?: boolean;\n defaultOpen?: boolean;\n children: RichTextParagraphBlock[];\n attrs?: ContentAttributes;\n}\n\nexport type RichTextSeparatorBlock = {\n type: 'separator';\n attrs?: ContentAttributes;\n}\n\nexport type RichTextBlockExtension = {\n type: 'blockExtension';\n name: string;\n attrs?: ContentAttributes;\n}\n\nexport type RichTextBlockNode =\n | RichTextParagraphBlock\n | RichTextHeadingBlock\n | RichTextBulletListBlock\n | RichTextImageBlock\n | RichTextInfoBoxBlock\n | RichTextSeparatorBlock\n | RichTextBlockExtension;\n\nexport type RichTextDocument = {\n type: 'doc';\n blocks: RichTextBlockNode[];\n}\n\nexport type RichTextContent = {\n type: ContentType.richText;\n version: 1;\n doc: RichTextDocument;\n}\n\nexport type MDContent = {\n type: ContentType.md;\n content: string;\n}\n\nexport type PlainTextContent = {\n type: ContentType.plain;\n content: string;\n}\n\nexport type Content = RichTextContent | MDContent | PlainTextContent;\nexport type RichTextInline = RichTextInlineNode;\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: 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\n .map((paragraph) => getPlainTextFromInlineNodes(paragraph.children))\n .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\n .map((item) => getPlainTextFromParagraphs(item.children))\n .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 { CURRENT_SURVEY_SCHEMA, RawSurvey, RawSurveyAsset } from \"./survey-file-schema\";\nimport { SurveyItemTranslations, SurveyTranslations } from \"./utils/translations\";\nimport { SurveyItemCore, RawSurveyItem, ReservedSurveyItemTypes } from \"./items\";\nimport { ReferenceUsage, ReferenceUsageType } from \"./utils/value-reference\";\nimport { Content, getAssetUsagesFromContent } from \"./utils/content\";\nimport { SurveyItemKey } from \"./item-key\";\nimport { deserializeTemplateValues, serializeTemplateValues, TemplateValueDefinition } from \"../expressions/template-value\";\nimport { ValueRefTypeLookup, ValueType } from \"./responses/value-types\";\nimport { ResponseSlotDefinition } from \"./responses/slot-definition\";\nimport { createItemCore, ItemTypeRegistry } from \"./registry/item-registry\";\nimport { GroupItemCore } from \"./registry/built-in-items\";\nimport { generateCodingKey, generateId, structuredCloneMethod } from \"../utils\";\n\nexport interface SurveyAssetUsage {\n assetId: string;\n itemId?: string;\n locale?: string;\n contentKey: string;\n usageScope: 'itemTranslation' | 'surveyCard' | 'navigation' | 'validationMessages';\n blockIndex: number;\n}\n\nexport class Survey {\n maxItemsPerPage?: { large: number, small: number };\n metadata?: {\n [key: string]: string\n }\n surveyItems: Map<string, SurveyItemCore> = new Map();\n private _templateValues?: Map<string, TemplateValueDefinition> = new Map();\n private _assets?: Map<string, RawSurveyAsset> = new Map();\n\n private _translations?: SurveyTranslations;\n\n constructor(\n private readonly pluginRegistry?: ItemTypeRegistry\n ) {\n this._translations = new SurveyTranslations();\n }\n\n /** Plugin registry used when parsing items. Exposed for editors that re-parse without their own registry. */\n getPluginRegistry(): ItemTypeRegistry | undefined {\n return this.pluginRegistry;\n }\n\n /**\n * Create a survey item from raw JSON data.\n * Uses the survey's plugin registry when available.\n */\n createItemFromRaw(rawItem: RawSurveyItem): SurveyItemCore {\n return createItemCore(rawItem, this.pluginRegistry);\n }\n\n /**\n * Create a minimal blank survey with a root group and one empty page.\n */\n static createBlankSurvey(\n pluginRegistry?: ItemTypeRegistry,\n surveyKey?: string,\n ): Survey {\n const newKey = surveyKey ?? generateCodingKey();\n const rawSurvey: RawSurvey = {\n $schema: CURRENT_SURVEY_SCHEMA,\n surveyItems: [\n {\n id: generateId(),\n key: newKey,\n itemType: ReservedSurveyItemTypes.Group,\n config: { isRoot: true, items: [], shuffleItems: false },\n },\n ],\n };\n\n return Survey.fromJson(rawSurvey, pluginRegistry);\n }\n\n static fromJson(json: RawSurvey, pluginRegistry?: ItemTypeRegistry): Survey {\n const survey = new Survey(pluginRegistry);\n const rawSurvey = json as RawSurvey;\n if (rawSurvey.$schema !== CURRENT_SURVEY_SCHEMA) {\n throw new Error(`Unsupported survey schema: ${rawSurvey.$schema}`);\n }\n\n survey.surveyItems = new Map();\n if (!rawSurvey.surveyItems || rawSurvey.surveyItems.length === 0) {\n throw new Error('surveyItems is required');\n }\n rawSurvey.surveyItems.forEach(item => {\n const surveyItem = createItemCore(item, pluginRegistry);\n survey.surveyItems.set(surveyItem.id, surveyItem);\n });\n\n // Parse other fields\n if (rawSurvey.templateValues) {\n survey._templateValues = deserializeTemplateValues(rawSurvey.templateValues);\n }\n\n if (rawSurvey.assets) {\n survey._assets = new Map(Object.entries(rawSurvey.assets));\n }\n\n survey._translations = new SurveyTranslations(rawSurvey.translations);\n\n if (rawSurvey.maxItemsPerPage) {\n survey.maxItemsPerPage = rawSurvey.maxItemsPerPage;\n }\n\n if (rawSurvey.metadata) {\n survey.metadata = rawSurvey.metadata;\n }\n\n return survey;\n }\n\n serialize(): RawSurvey {\n const json: RawSurvey = {\n $schema: CURRENT_SURVEY_SCHEMA,\n surveyItems: Array.from(this.surveyItems.values()).map(item => item.rawItem),\n };\n\n // Export other fields\n json.translations = this._translations?.serialize();\n\n if (this._templateValues) {\n json.templateValues = serializeTemplateValues(this._templateValues);\n }\n\n if (this._assets && this._assets.size > 0) {\n json.assets = Object.fromEntries(this._assets.entries());\n }\n\n if (this.maxItemsPerPage) {\n json.maxItemsPerPage = this.maxItemsPerPage;\n }\n if (this.metadata) {\n json.metadata = this.metadata;\n }\n\n return json;\n }\n\n get surveyKey(): string | undefined {\n const rootItem = this.rootItem;\n if (!rootItem) {\n return undefined;\n }\n return this.rootItem.key;\n }\n\n get locales(): string[] {\n return this._translations?.locales || [];\n }\n\n get rootItem(): GroupItemCore | undefined {\n const rootItem = Array.from(this.surveyItems.values()).find(item => item instanceof GroupItemCore && item.isRoot) as GroupItemCore | undefined;\n return rootItem;\n }\n\n\n get keyIndex(): Array<{ itemId: string, key: string, keyPath: string[], path: string[] }> {\n const index: Array<{ itemId: string, key: string, keyPath: string[], path: string[] }> = [];\n for (const item of this.surveyItems.values()) {\n const path = this.getItemPath(item.id);\n index.push({\n itemId: item.id, key: item.key,\n keyPath: path.map(id => this.surveyItems.get(id)?.key ?? ''),\n path: path\n });\n }\n return index;\n }\n\n getItemPath(itemId: string): string[] {\n const item = this.surveyItems.get(itemId);\n if (!item) {\n throw new Error(`Item ${itemId} not found`);\n }\n\n if (item instanceof GroupItemCore && item.isRoot()) {\n return [];\n }\n\n // find parent item for the given item id\n const parentItem = this.getParentItem(itemId);\n if (!parentItem) {\n throw new Error(`Parent item for ${itemId} not found`);\n }\n return [...this.getItemPath(parentItem.id), parentItem.id];\n }\n\n getItemKey(itemId: string): SurveyItemKey | undefined {\n const item = this.surveyItems.get(itemId);\n if (!item) {\n return undefined;\n }\n const idPath = this.getItemPath(itemId);\n const keyPath = idPath.map(id => this.surveyItems.get(id)?.key ?? '');\n return new SurveyItemKey(item.key, keyPath);\n }\n\n getParentItem(itemId: string): GroupItemCore | undefined {\n const item = this.surveyItems.get(itemId);\n if (!item) {\n throw new Error(`Item ${itemId} not found`);\n }\n if (item instanceof GroupItemCore && item.isRoot()) {\n return undefined;\n }\n const parentItem = Array.from(this.surveyItems.values()).find(item => item instanceof GroupItemCore && item.config.items?.includes(itemId)) as GroupItemCore | undefined;\n if (!parentItem) {\n return undefined;\n }\n return parentItem;\n }\n\n getChildrenItems(parentId: string): SurveyItemCore[] {\n const parentItem = this.surveyItems.get(parentId);\n if (!parentItem || !(parentItem instanceof GroupItemCore)) {\n return [];\n }\n return (parentItem as GroupItemCore).config.items?.map(id => this.surveyItems.get(id))?.filter(item => item !== undefined) as SurveyItemCore[] || [];\n }\n\n getSiblings(itemId: string): SurveyItemCore[] {\n const item = this.surveyItems.get(itemId);\n if (!item) {\n return [];\n }\n const parentItem = this.getParentItem(itemId);\n return parentItem?.items?.map(id => this.surveyItems.get(id))?.filter(item => item !== undefined) as SurveyItemCore[] || [];\n }\n\n get translations(): SurveyTranslations {\n if (!this._translations) {\n this._translations = new SurveyTranslations();\n }\n return this._translations;\n }\n\n getItemTranslations(id: string): SurveyItemTranslations | undefined {\n const item = this.surveyItems.get(id);\n if (!item) {\n throw new Error(`Item ${id} not found`);\n }\n\n return this._translations?.getItemTranslations(id);\n }\n\n getTemplateValue(templateValueKey: string): TemplateValueDefinition | undefined {\n return this._templateValues?.get(templateValueKey);\n }\n\n setTemplateValue(templateValueKey: string, templateValue: TemplateValueDefinition) {\n if (!this._templateValues) {\n this._templateValues = new Map();\n }\n this._templateValues?.set(templateValueKey, templateValue);\n }\n\n deleteTemplateValue(templateValueKey: string) {\n this._templateValues?.delete(templateValueKey);\n }\n\n getTemplateValueKeys(): string[] {\n return Array.from(this._templateValues?.keys() || []);\n }\n\n getAsset(assetId: string): RawSurveyAsset | undefined {\n const asset = this._assets?.get(assetId);\n return asset ? structuredCloneMethod(asset) : undefined;\n }\n\n setAsset(assetId: string, asset: RawSurveyAsset): void {\n if (!this._assets) {\n this._assets = new Map();\n }\n\n this._assets.set(assetId, structuredCloneMethod(asset));\n }\n\n deleteAsset(assetId: string): void {\n this._assets?.delete(assetId);\n }\n\n hasAsset(assetId: string): boolean {\n return this._assets?.has(assetId) ?? false;\n }\n\n getAssetIds(): string[] {\n return Array.from(this._assets?.keys() || []);\n }\n\n getAssets(): Map<string, RawSurveyAsset> {\n return new Map(\n Array.from(this._assets?.entries() || []).map(([assetId, asset]) => [\n assetId,\n structuredCloneMethod(asset),\n ]),\n );\n }\n\n getAssetUsages(filterAssetId?: string): SurveyAssetUsage[] {\n const usages: SurveyAssetUsage[] = [];\n const pushContentUsages = (\n content: Content | undefined,\n usageScope: SurveyAssetUsage['usageScope'],\n contentKey: string,\n locale?: string,\n itemId?: string,\n ) => {\n for (const usage of getAssetUsagesFromContent(content)) {\n if (filterAssetId && usage.assetId !== filterAssetId) {\n continue;\n }\n\n usages.push({\n assetId: usage.assetId,\n itemId,\n locale,\n contentKey,\n usageScope,\n blockIndex: usage.blockIndex,\n });\n }\n };\n\n const serializedTranslations = this._translations?.serialize();\n const rootItemId = this.rootItem?.id;\n\n if (!serializedTranslations) {\n return usages;\n }\n\n for (const [locale, localeTranslations] of Object.entries(serializedTranslations)) {\n for (const [contentKey, content] of Object.entries(localeTranslations.surveyCardContent || {})) {\n pushContentUsages(content, 'surveyCard', contentKey, locale, rootItemId);\n }\n\n for (const [contentKey, content] of Object.entries(localeTranslations.navigationContent || {})) {\n pushContentUsages(content, 'navigation', contentKey, locale, rootItemId);\n }\n\n for (const [contentKey, content] of Object.entries(localeTranslations.validationMessages || {})) {\n pushContentUsages(content, 'validationMessages', contentKey, locale, rootItemId);\n }\n\n for (const [itemId, itemTranslations] of Object.entries(localeTranslations.itemTranslations || {})) {\n for (const [contentKey, content] of Object.entries(itemTranslations || {})) {\n pushContentUsages(content, 'itemTranslation', contentKey, locale, itemId);\n }\n }\n }\n\n return usages;\n }\n\n getAvailableResponseValueSlots(byType?: ValueType): ValueRefTypeLookup {\n let valueRefs: ValueRefTypeLookup = {};\n for (const item of this.surveyItems.values()) {\n valueRefs = { ...valueRefs, ...item.getAvailableResponseValueSlots(byType) };\n }\n return valueRefs;\n }\n\n getResponseSlotDefinitions(): Array<{ itemId: string; slots: ResponseSlotDefinition[] }> {\n return Array.from(this.surveyItems.values()).map((item) => ({\n itemId: item.id,\n slots: item.getResponseSlotDefinitions(),\n }));\n }\n\n /**\n * Get all reference usages for the survey\n * @param forItemId - optional item id to filter usages for a specific item and its children (if not provided, all usages are returned)\n * @returns all reference usages for the survey (or for a specific item and its children)\n */\n getReferenceUsages(forItemId?: string): ReferenceUsage[] {\n const usages: ReferenceUsage[] = [];\n for (const item of this.surveyItems.values()) {\n if (forItemId && item.id !== forItemId && !this.isDescendantOf(item.id, forItemId)) {\n continue;\n }\n usages.push(...item.getReferenceUsages());\n }\n\n if (this._templateValues) {\n for (const [templateValueKey, templateValue] of this._templateValues.entries()) {\n for (const ref of templateValue.expression?.responseVariableRefs || []) {\n usages.push({\n itemId: templateValueKey,\n usageType: ReferenceUsageType.templateValues,\n valueReference: ref,\n });\n }\n }\n }\n\n return usages;\n }\n\n // Helper method to check if targetId is a descendant of ancestorId\n isDescendantOf(targetId: string, ancestorId: string): boolean {\n if (targetId === ancestorId) {\n return true;\n }\n const targetPath = this.getItemPath(targetId);\n return targetPath.includes(ancestorId);\n }\n}\n"],"mappings":";AACA,SAAS,WAAW,MAAsB;CACxC,IAAI,OAAO;AAEX,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAQ,KAAK,WAAW,EAAE;AAC1B,SAAO,KAAK,KAAK,MAAM,SAAS;;AAGlC,QAAO,SAAS;;AAGlB,SAAgB,mBAAmB,MAA4B;CAC7D,IAAI,QAAQ,WAAW,KAAK;AAE5B,cAAa;AACX,UAAS,QAAQ,eAAgB;EACjC,IAAI,OAAO;AACX,SAAO,KAAK,KAAK,OAAQ,SAAS,IAAK,OAAO,EAAE;AAChD,UAAQ,OAAO,KAAK,KAAK,OAAQ,SAAS,GAAI,OAAO,GAAG;AACxD,WAAS,OAAQ,SAAS,QAAS,KAAK;;;AAI5C,SAAgB,aAAgB,QAAsB,SAAuB,KAAK,QAAa;CAC7F,MAAM,iBAAiB,CAAC,GAAG,OAAO;AAElC,MAAK,IAAI,IAAI,eAAe,SAAS,GAAG,IAAI,GAAG,KAAK;EAClD,MAAM,IAAI,KAAK,MAAM,QAAQ,IAAI,IAAI,GAAG;AACxC,GAAC,eAAe,IAAI,eAAe,MAAM,CAAC,eAAe,IAAI,eAAe,GAAG;;AAGjF,QAAO;;;;;;;AAQT,SAAgB,eAAe,QAAgB,SAAuB,KAAK,QAAkB;AAC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,QAAO;AAGT,SADmB,KAAK,YAAY,SACnB,CAAC,SAAS,WAAW"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@case-framework/survey-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Implementation of the survey core to use in typescript/javascript projects.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"@types/jest": "^30.0.0",
|
|
17
17
|
"eslint": "^9.39.4",
|
|
18
18
|
"jest": "^30.3.0",
|
|
19
|
-
"ts-jest": "^29.4.
|
|
20
|
-
"tsdown": "^0.21.
|
|
21
|
-
"typescript": "^
|
|
22
|
-
"typescript-eslint": "^8.
|
|
19
|
+
"ts-jest": "^29.4.9",
|
|
20
|
+
"tsdown": "^0.21.10",
|
|
21
|
+
"typescript": "^6.0.3",
|
|
22
|
+
"typescript-eslint": "^8.59.1"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"date-fns": "^4.1.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"survey-DJbgFVPz.mjs","names":[],"sources":["../src/utils.ts","../src/survey/utils/value-reference.ts","../src/expressions/expression.ts","../src/expressions/template-value.ts","../src/survey/responses/value-types.ts","../src/survey/items/utils.ts","../src/survey/items/survey-item.ts","../src/survey/items/types.ts","../src/survey/item-key.ts","../src/survey/utils/group-utils.ts","../src/survey/registry/built-in-items.ts","../src/survey/registry/item-registry.ts","../src/survey/survey-file-schema.ts","../src/survey/utils/translations.ts","../src/survey/survey.ts"],"sourcesContent":["\n/**\n * Shuffles an array of indices using the Fisher-Yates shuffle algorithm\n * @param length - The length of the array to create indices for\n * @returns A shuffled array of indices from 0 to length-1\n */\nexport function shuffleIndices(length: number): number[] {\n const shuffledIndices = Array.from({ length }, (_, i) => i);\n\n for (let i = shuffledIndices.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [shuffledIndices[i], shuffledIndices[j]] = [shuffledIndices[j], shuffledIndices[i]];\n }\n\n return shuffledIndices;\n}\n\nexport function structuredCloneMethod<T>(obj: T): T {\n if (typeof structuredClone !== 'undefined') {\n return structuredClone(obj);\n }\n // Fallback to JSON method\n return JSON.parse(JSON.stringify(obj));\n}\n\nconst ALPHABET = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';\n\nexport function generateId(): string {\n const length = 10;\n const timestamp = Date.now();\n let encodedTimestamp = '';\n let t = timestamp;\n const base = ALPHABET.length;\n\n while (t > 0) {\n encodedTimestamp = ALPHABET.charAt(t % base) + encodedTimestamp;\n t = Math.floor(t / base);\n }\n\n let randomPart = '';\n for (let i = 0; i < length; i++) {\n randomPart += ALPHABET.charAt(Math.floor(Math.random() * base));\n }\n return randomPart + encodedTimestamp;\n}\n\n\n/** Alphanumeric chars without ambiguous ones (0/O, 1/I) for human-readable coding keys. */\nconst CODING_KEY_ALPHABET = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ';\n\n/**\n * Generates a short random coding key suitable for item keys in exports/codebooks.\n * @param length - Key length (default 4)\n * @returns A random string of the specified length.\n */\nexport function generateCodingKey(length: number = 4): string {\n const base = CODING_KEY_ALPHABET.length;\n let key = '';\n for (let i = 0; i < length; i++) {\n key += CODING_KEY_ALPHABET.charAt(Math.floor(Math.random() * base));\n }\n return key;\n}\n","const SEPARATOR = '...';\n\nexport enum ValueReferenceMethod {\n get = 'get',\n isDefined = 'isDefined',\n}\n\n\n\nexport class ValueReference {\n _itemId: string;\n _name: ValueReferenceMethod;\n _slotId: string;\n\n constructor(str: string) {\n const parts = str.split(SEPARATOR);\n if (parts.length !== 3) {\n throw new Error('Invalid value reference: ' + str);\n }\n this._itemId = parts[0];\n this._name = parts[1] as ValueReferenceMethod;\n this._slotId = parts[2];\n }\n\n get itemId(): string {\n return this._itemId;\n }\n\n get name(): ValueReferenceMethod {\n return this._name;\n }\n\n get slotId(): string {\n return this._slotId;\n }\n\n set itemId(itemId: string) {\n this._itemId = itemId;\n }\n\n toString(): string {\n return `${this._itemId}${SEPARATOR}${this._name}${this._slotId ? SEPARATOR + this._slotId : ''}`;\n }\n\n static fromParts(itemId: string, name: ValueReferenceMethod, slotId: string): ValueReference {\n return new ValueReference(`${itemId}${SEPARATOR}${name}${SEPARATOR}${slotId}`);\n }\n}\n\n\nexport enum ReferenceUsageType {\n displayConditions = 'displayConditions',\n templateValues = 'templateValues',\n validations = 'validations',\n disabledConditions = 'disabledConditions',\n}\n\nexport interface ReferenceUsage {\n itemId: string;\n fullComponentKey?: string;\n usageType?: ReferenceUsageType;\n valueReference: ValueReference;\n}\n","import { ResponseValue, ValueType, } from \"../survey/responses\";\nimport { ValueReference } from \"../survey/utils/value-reference\";\n\n\nexport const ExpressionType = {\n Const: 'const',\n ResponseVariable: 'responseVariable',\n ContextVariable: 'contextVariable',\n Function: 'function',\n} as const;\n\nexport type ExpressionType = (typeof ExpressionType)[keyof typeof ExpressionType];\n\nexport const ContextVariableType = {\n Locale: 'locale',\n ParticipantFlag: 'participantFlag',\n CustomValue: 'customValue',\n CustomExpression: 'customExpression'\n} as const;\n\nexport type ContextVariableType = (typeof ContextVariableType)[keyof typeof ContextVariableType];\n\nexport interface ExpressionEditorConfig {\n usedTemplate?: string;\n}\n\nexport interface JsonConstExpression {\n type: typeof ExpressionType.Const;\n value?: ResponseValue;\n\n editorConfig?: ExpressionEditorConfig;\n}\n\nexport interface JsonResponseVariableExpression {\n type: typeof ExpressionType.ResponseVariable;\n variableRef: string;\n\n editorConfig?: ExpressionEditorConfig;\n}\n\nexport interface JsonContextVariableExpression {\n type: typeof ExpressionType.ContextVariable;\n\n contextType: ContextVariableType;\n key?: JsonExpression;\n arguments?: Array<JsonExpression | undefined>;\n asType?: ValueType;\n\n editorConfig?: ExpressionEditorConfig;\n}\n\nexport interface JsonFunctionExpression {\n type: typeof ExpressionType.Function;\n functionName: string;\n arguments: Array<JsonExpression | undefined>;\n\n editorConfig?: ExpressionEditorConfig;\n}\n\nexport type JsonExpression = JsonConstExpression | JsonResponseVariableExpression | JsonContextVariableExpression | JsonFunctionExpression;\n\n\n\n/**\n * Base class for all expressions.\n */\nexport abstract class Expression {\n type: ExpressionType;\n editorConfig?: ExpressionEditorConfig;\n\n constructor(type: ExpressionType, editorConfig?: ExpressionEditorConfig) {\n this.type = type;\n this.editorConfig = editorConfig;\n }\n\n static deserialize(json: JsonExpression | undefined): Expression | undefined {\n if (!json) {\n return undefined;\n }\n\n switch (json.type) {\n case ExpressionType.Const:\n return ConstExpression.deserialize(json);\n case ExpressionType.ResponseVariable:\n return ResponseVariableExpression.deserialize(json);\n case ExpressionType.ContextVariable:\n return ContextVariableExpression.deserialize(json);\n case ExpressionType.Function:\n return FunctionExpression.deserialize(json);\n }\n }\n\n /**\n * Returns all unique response variable references in the expression.\n * @returns A list of ValueReference objects.\n */\n abstract get responseVariableRefs(): ValueReference[]\n abstract serialize(): JsonExpression | undefined;\n\n clone(): Expression {\n return Expression.deserialize(this.serialize()) ?? (() => {\n throw new Error('Failed to clone expression');\n })();\n }\n}\n\nexport class ConstExpression extends Expression {\n declare type: typeof ExpressionType.Const;\n value?: ResponseValue;\n\n constructor(value?: ResponseValue, editorConfig?: ExpressionEditorConfig) {\n super(ExpressionType.Const, editorConfig);\n this.value = value;\n this.type = ExpressionType.Const;\n }\n\n static deserialize(json: JsonExpression): ConstExpression {\n if (json.type !== ExpressionType.Const) {\n throw new Error('Invalid expression type: ' + json.type);\n }\n\n return new ConstExpression(json.value, json.editorConfig);\n }\n\n get responseVariableRefs(): ValueReference[] {\n return [];\n }\n\n serialize(): JsonExpression {\n return {\n type: this.type,\n value: this.value,\n editorConfig: this.editorConfig\n }\n }\n\n updateItemKeyReferences(_oldItemKey: string, _newItemKey: string): boolean {\n // Const expressions don't have item references\n return false;\n }\n}\n\nexport class ResponseVariableExpression extends Expression {\n declare type: typeof ExpressionType.ResponseVariable;\n variableRef: string;\n\n constructor(variableRef: string, editorConfig?: ExpressionEditorConfig) {\n super(ExpressionType.ResponseVariable, editorConfig);\n this.variableRef = variableRef;\n this.type = ExpressionType.ResponseVariable;\n }\n\n static deserialize(json: JsonExpression): ResponseVariableExpression {\n if (json.type !== ExpressionType.ResponseVariable) {\n throw new Error('Invalid expression type: ' + json.type);\n }\n\n return new ResponseVariableExpression(json.variableRef, json.editorConfig);\n }\n\n get responseVariableRefs(): ValueReference[] {\n return [new ValueReference(this.variableRef)];\n }\n\n get responseVariableRef(): ValueReference {\n return new ValueReference(this.variableRef);\n }\n\n serialize(): JsonExpression {\n return {\n type: this.type,\n variableRef: this.variableRef,\n editorConfig: this.editorConfig\n }\n }\n}\n\nexport class ContextVariableExpression extends Expression {\n declare type: typeof ExpressionType.ContextVariable;\n\n contextType: ContextVariableType;\n key?: Expression;\n arguments?: Array<Expression | undefined>;\n asType?: ValueType;\n\n constructor(contextType: ContextVariableType, key?: Expression, args?: Array<Expression | undefined>, asType?: ValueType, editorConfig?: ExpressionEditorConfig) {\n super(ExpressionType.ContextVariable, editorConfig);\n this.type = ExpressionType.ContextVariable;\n this.contextType = contextType;\n this.key = key;\n this.arguments = args;\n this.asType = asType;\n }\n\n static deserialize(json: JsonExpression): ContextVariableExpression {\n if (json.type !== ExpressionType.ContextVariable) {\n throw new Error('Invalid expression type: ' + json.type);\n }\n\n return new ContextVariableExpression(json.contextType, Expression.deserialize(json.key), json.arguments?.map(arg => Expression.deserialize(arg)), json.asType, json.editorConfig);\n }\n\n get responseVariableRefs(): ValueReference[] {\n return this.arguments?.flatMap(arg => arg?.responseVariableRefs).filter(ref => ref !== undefined) ?? [];\n }\n\n serialize(): JsonExpression {\n return {\n type: this.type,\n contextType: this.contextType,\n key: this.key?.serialize(),\n arguments: this.arguments?.map(arg => arg?.serialize()),\n asType: this.asType,\n editorConfig: this.editorConfig\n }\n }\n}\n\n\nexport enum FunctionExpressionNames {\n and = 'and',\n or = 'or',\n not = 'not',\n\n list_contains = 'list_contains',\n\n // numeric functions\n eq = 'eq',\n gt = 'gt',\n gte = 'gte',\n lt = 'lt',\n lte = 'lte',\n in_range = 'in_range',\n\n sum = 'sum',\n min = 'min',\n max = 'max',\n\n\n\n\n // string functions\n str_eq = 'str_eq',\n\n // date functions\n date_eq = 'date_eq',\n}\n\nexport class FunctionExpression extends Expression {\n declare type: typeof ExpressionType.Function;\n functionName: FunctionExpressionNames;\n arguments: Array<Expression | undefined>;\n\n constructor(functionName: FunctionExpressionNames, args: Array<Expression | undefined>, editorConfig?: ExpressionEditorConfig) {\n super(ExpressionType.Function);\n this.type = ExpressionType.Function;\n this.functionName = functionName;\n this.arguments = args;\n this.editorConfig = editorConfig;\n }\n\n static deserialize(json: JsonExpression): FunctionExpression {\n if (json.type !== ExpressionType.Function) {\n throw new Error('Invalid expression type: ' + json.type);\n }\n\n const functionName = json.functionName as FunctionExpressionNames;\n if (!Object.values(FunctionExpressionNames).includes(functionName)) {\n throw new Error('Invalid function name: ' + functionName);\n }\n\n const expr = new FunctionExpression(functionName, json.arguments.map(arg => Expression.deserialize(arg)));\n expr.editorConfig = json.editorConfig;\n return expr;\n }\n\n get responseVariableRefs(): ValueReference[] {\n const refs = this.arguments.flatMap(arg => arg?.responseVariableRefs).filter(ref => ref !== undefined);\n const refStrings = refs.map(ref => ref.toString());\n return [...new Set(refStrings)].map(ref => new ValueReference(ref));\n }\n\n serialize(): JsonExpression | undefined {\n return {\n type: this.type,\n functionName: this.functionName,\n arguments: this.arguments.map(arg => arg?.serialize()),\n editorConfig: this.editorConfig\n }\n }\n}\n","import { ValueType } from \"../survey/responses\";\nimport { Expression, JsonExpression } from \"./expression\";\n\n\nexport enum TemplateDefTypes {\n Default = 'default',\n Date2String = 'date2string'\n}\n\nexport type TemplateValueBase = {\n type: TemplateDefTypes;\n returnType: ValueType;\n expression?: Expression;\n}\n\n\nexport type TemplateValueFormatDate = TemplateValueBase & {\n type: TemplateDefTypes.Date2String;\n returnType: typeof ValueType.string;\n dateFormat: string;\n}\n\nexport type TemplateValueDefinition = TemplateValueBase | TemplateValueFormatDate;\n\n\n\nexport const serializeTemplateValue = (templateValue: TemplateValueDefinition): JsonTemplateValue => {\n const json: JsonTemplateValue = {\n type: templateValue.type,\n returnType: templateValue.returnType,\n expression: templateValue.expression?.serialize(),\n }\n if (templateValue.type === TemplateDefTypes.Date2String) {\n json.dateFormat = (templateValue as TemplateValueFormatDate).dateFormat;\n }\n return json;\n}\n\nexport const serializeTemplateValues = (templateValues: Map<string, TemplateValueDefinition>): { [templateValueKey: string]: JsonTemplateValue } => {\n const json: { [templateValueKey: string]: JsonTemplateValue } = {};\n for (const [key, value] of templateValues.entries()) {\n json[key] = serializeTemplateValue(value);\n }\n return json;\n}\n\nexport const deserializeTemplateValue = (json: JsonTemplateValue): TemplateValueDefinition => {\n return {\n type: json.type,\n expression: json.expression ? Expression.deserialize(json.expression) : undefined,\n returnType: json.returnType,\n dateFormat: json.dateFormat\n }\n}\n\nexport const deserializeTemplateValues = (json: { [templateValueKey: string]: JsonTemplateValue }): Map<string, TemplateValueDefinition> => {\n return new Map(Object.entries(json).map(([key, value]) => [key, deserializeTemplateValue(value)]));\n}\n\nexport interface JsonTemplateValue {\n type: TemplateDefTypes;\n expression?: JsonExpression;\n returnType: ValueType;\n dateFormat?: string;\n}\n\n","export 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\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\n\nexport const NumberPrecision = {\n int: 'int',\n float: 'float',\n} as const;\n\nexport type NumberPrecision = (typeof NumberPrecision)[keyof typeof NumberPrecision];\n\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: number;\n}\n\nexport interface StringArrayResponse extends SlotResponseBase<typeof ValueType.stringArray> {\n value: string[];\n}\n\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\n\nexport interface DateArrayResponse extends SlotResponseBase<typeof ValueType.dateArray> {\n value: number[];\n}\n\n\nexport interface ReferenceArrayResponse extends SlotResponseBase<typeof ValueType.referenceArray> {\n value: string[];\n}\n\nexport type ResponseValue = StringResponse | DurationResponse | ReferenceResponse | NumberResponse | BooleanResponse | DateResponse | StringArrayResponse | DurationArrayResponse | NumberArrayResponse | DateArrayResponse | ReferenceArrayResponse;\n\n\nexport type ValueRefTypeLookup = {\n [valueRefString: string]: ValueType;\n}\n\n\n","import { Expression, JsonExpression } from \"../../expressions\";\n\nexport interface DisplayConditions {\n root?: Expression;\n components?: {\n [componentKey: string]: Expression | undefined;\n }\n}\n\nexport interface JsonDisplayConditions {\n root?: JsonExpression;\n components?: {\n [componentKey: string]: JsonExpression | undefined;\n }\n}\n\nexport interface JsonDisabledConditions {\n components?: {\n [componentKey: string]: JsonExpression | undefined;\n }\n}\n\nexport interface DisabledConditions {\n components?: {\n [componentKey: string]: Expression | undefined;\n }\n}\n\nexport const displayConditionsFromJson = (json: JsonDisplayConditions): DisplayConditions => {\n return {\n root: json.root ? Expression.deserialize(json.root) : undefined,\n components: json.components ? Object.fromEntries(Object.entries(json.components).map(([key, value]) => [key, Expression.deserialize(value)])) : undefined\n }\n}\n\nexport const displayConditionsToJson = (displayConditions: DisplayConditions): JsonDisplayConditions => {\n return {\n root: displayConditions.root ? displayConditions.root.serialize() : undefined,\n components: displayConditions.components ? Object.fromEntries(Object.entries(displayConditions.components).map(([key, value]) => [key, value?.serialize()])) : undefined\n }\n}\n\nexport const disabledConditionsFromJson = (json: JsonDisabledConditions): DisabledConditions => {\n return {\n components: json.components ? Object.fromEntries(Object.entries(json.components).map(([key, value]) => [key, Expression.deserialize(value)])) : undefined\n }\n}\n\nexport const disabledConditionsToJson = (disabledConditions: DisabledConditions): JsonDisabledConditions => {\n return {\n components: disabledConditions.components ? Object.fromEntries(Object.entries(disabledConditions.components).map(([key, value]) => [key, value?.serialize()])) : undefined\n }\n}\n","import { Expression } from \"../../expressions\";\nimport { RawSurveyItem } from \"../items\";\nimport { ResponseSlotDefinition } from \"../responses/slot-definition\";\nimport { ValueRefTypeLookup, ValueType } from \"../responses/value-types\";\nimport { ReferenceUsage, ReferenceUsageType, ValueReferenceMethod } from \"../utils/value-reference\";\nimport { DisabledConditions, disabledConditionsFromJson, DisplayConditions, displayConditionsFromJson } from \"./utils\";\n\n/**\n * Core contract for survey item handlers.\n * Every item type (built-in and plugin) is represented by a handler class implementing this interface.\n * The core uses these methods without any casting.\n */\nexport interface SurveyItemCoreType<TConfig = unknown> {\n readonly type: string;\n readonly id: string;\n readonly key: string;\n readonly config: TConfig;\n\n isInteractive(): boolean;\n getResponseSlotDefinitions(): ResponseSlotDefinition[];\n getAvailableResponseValueSlots(byType?: ValueType): ValueRefTypeLookup;\n}\n\n/**\n * Base class for survey item handlers.\n * Each handler holds type, id, key, and config (properly typed) and implements core methods.\n * Subclass for each item type; the core works with SurveyItemHandler only—no casting needed.\n */\nexport abstract class SurveyItemCore<\n TType extends string = string,\n TConfig = unknown\n> implements SurveyItemCoreType<TConfig> {\n abstract readonly type: TType;\n readonly id: string;\n key: string;\n config: TConfig;\n\n private _rawItem: RawSurveyItem;\n\n displayConditions?: DisplayConditions;\n disabledConditions?: DisabledConditions;\n validations?: {\n [validationKey: string]: Expression | undefined;\n }\n prefillRules?: Array<Expression | undefined>;\n\n\n constructor(rawItem: RawSurveyItem) {\n this._rawItem = rawItem;\n this.updateExpressions();\n this.id = this._rawItem.id;\n this.key = this._rawItem.key;\n this.config = this.parseConfig(this._rawItem.config);\n }\n\n /** Parse raw config from JSON into typed config. Override in subclasses. */\n abstract parseConfig(rawConfig: unknown): TConfig;\n abstract isInteractive(): boolean;\n abstract getResponseSlotDefinitions(): ResponseSlotDefinition[];\n\n protected getAdditionalResponseValueSlots(): ValueRefTypeLookup {\n return {};\n }\n\n getAvailableResponseValueSlots(byType?: ValueType): ValueRefTypeLookup {\n const valueRefs: ValueRefTypeLookup = {};\n\n for (const slot of this.getResponseSlotDefinitions()) {\n valueRefs[`${this.id}...${ValueReferenceMethod.get}...${slot.slotId}`] = slot.valueType;\n valueRefs[`${this.id}...${ValueReferenceMethod.isDefined}...${slot.slotId}`] = ValueType.boolean;\n }\n\n Object.assign(valueRefs, this.getAdditionalResponseValueSlots());\n\n if (!byType) {\n return valueRefs;\n }\n\n return Object.fromEntries(\n Object.entries(valueRefs).filter(([, valueType]) => valueType === byType)\n );\n }\n\n get rawItem(): RawSurveyItem {\n return this._rawItem;\n }\n\n get metadata(): { [key: string]: string } {\n return this._rawItem.metadata ?? {};\n }\n\n set metadata(metadata: { [key: string]: string }) {\n this.updateRawItem({\n ...this._rawItem,\n metadata: metadata,\n });\n }\n\n updateRawItem(rawItem: RawSurveyItem) {\n if (rawItem.id !== this.id) {\n throw new Error('Cannot update raw item with a different id');\n }\n this._rawItem = rawItem;\n this.updateExpressions();\n this.key = rawItem.key;\n this.config = this.parseConfig(rawItem.config);\n }\n\n private updateExpressions() {\n this.displayConditions = this._rawItem.displayConditions ? displayConditionsFromJson(this._rawItem.displayConditions) : undefined;\n this.disabledConditions = this._rawItem.disabledConditions ? disabledConditionsFromJson(this._rawItem.disabledConditions) : undefined;\n this.validations = this._rawItem.validations ? Object.fromEntries(Object.entries(this._rawItem.validations).map(([key, value]) => [key, Expression.deserialize(value)])) : undefined;\n this.prefillRules = this._rawItem.prefillRules ? this._rawItem.prefillRules.map(rule => rule ? Expression.deserialize(rule) : undefined) : undefined;\n }\n\n getReferenceUsages(): ReferenceUsage[] {\n const usages: ReferenceUsage[] = [];\n\n if (this.displayConditions) {\n // root\n for (const ref of this.displayConditions.root?.responseVariableRefs || []) {\n usages.push({\n itemId: this.id,\n usageType: ReferenceUsageType.displayConditions,\n valueReference: ref,\n });\n }\n\n // components\n for (const [componentKey, expression] of Object.entries(this.displayConditions.components || {})) {\n for (const ref of expression?.responseVariableRefs || []) {\n usages.push({\n itemId: this.id,\n fullComponentKey: componentKey,\n usageType: ReferenceUsageType.displayConditions,\n valueReference: ref,\n });\n }\n }\n }\n\n if (this.disabledConditions) {\n for (const [componentKey, expression] of Object.entries(this.disabledConditions.components || {})) {\n for (const ref of expression?.responseVariableRefs || []) {\n usages.push({\n itemId: this.id,\n fullComponentKey: componentKey,\n usageType: ReferenceUsageType.disabledConditions,\n valueReference: ref,\n });\n }\n }\n }\n\n if (this.validations) {\n for (const [validationKey, expression] of Object.entries(this.validations)) {\n for (const ref of expression?.responseVariableRefs || []) {\n usages.push({\n itemId: this.id,\n fullComponentKey: validationKey,\n usageType: ReferenceUsageType.validations,\n valueReference: ref,\n });\n }\n }\n }\n\n return usages;\n }\n}\n\n\n/**\n * Constructor type for handler classes. Used by the registry to instantiate handlers.\n */\nexport type ItemCoreConstructor<TType extends string = string, TConfig = unknown> = new (\n rawItem: RawSurveyItem\n) => SurveyItemCore<TType, TConfig>;\n","export enum ReservedSurveyItemTypes {\n Group = 'group',\n PageBreak = 'page-break',\n}\n\n","\n/**\n * SurveyItemKey stores the key of the item and the path to the item.\n */\n\nexport class SurveyItemKey {\n private _itemKey: string;\n private _path: Array<string>;\n private _keySeparator: string;\n\n constructor(itemKey: string, path: string[] | undefined, keySeparator: string = '.') {\n this._itemKey = itemKey;\n this._path = path ?? [];\n this._keySeparator = keySeparator;\n }\n\n get itemKey(): string {\n return this._itemKey;\n }\n\n get path(): Array<string> {\n return this._path;\n }\n\n get parentFullKey(): string {\n return this._path.join(this._keySeparator);\n }\n\n get fullKey(): string {\n return [...this._path, this._itemKey].join(this._keySeparator);\n }\n\n get isRoot(): boolean {\n return this._path.length === 0;\n }\n\n get keySeparator(): string {\n return this._keySeparator;\n }\n\n set keySeparator(keySeparator: string) {\n this._keySeparator = keySeparator;\n }\n}\n\n","/**\n * Shared utilities for array operations.\n */\n\n/**\n * Swap two elements in an array by index.\n * @returns A new array with the elements swapped\n */\nexport function swapArrayElements<T>(arr: T[], fromIndex: number, toIndex: number): T[] {\n const result = [...arr];\n [result[fromIndex], result[toIndex]] = [result[toIndex], result[fromIndex]];\n return result;\n}\n\n/**\n * Move an element from one index to another.\n * @returns A new array with the element moved\n */\nexport function moveArrayElement<T>(arr: T[], fromIndex: number, toIndex: number): T[] {\n const result = [...arr];\n const [moved] = result.splice(fromIndex, 1);\n result.splice(toIndex, 0, moved);\n return result;\n}\n","import { ReservedSurveyItemTypes } from \"../items/types\";\nimport { ItemCoreConstructor, SurveyItemCore } from \"../items/survey-item\";\nimport { moveArrayElement, swapArrayElements } from \"../utils/group-utils\";\n\n\n/**\n * Group item core.\n */\nexport type GroupConfig = {\n items?: string[];\n shuffleItems?: boolean;\n isRoot?: boolean;\n};\n\nexport class GroupItemCore extends SurveyItemCore<\n typeof ReservedSurveyItemTypes.Group,\n GroupConfig\n> {\n readonly type = ReservedSurveyItemTypes.Group;\n\n parseConfig(rawConfig: unknown): GroupConfig {\n const cfg = (rawConfig ?? {}) as Partial<GroupConfig>;\n return {\n items: cfg.items,\n shuffleItems: cfg.shuffleItems,\n isRoot: cfg.isRoot,\n };\n }\n\n serializeConfig(): unknown {\n return this.config;\n }\n\n isInteractive(): boolean {\n return false;\n }\n\n getResponseSlotDefinitions() {\n return [];\n }\n\n isRoot(): boolean {\n return this.config.isRoot ?? false;\n }\n\n get items(): string[] {\n return this.config.items ?? [];\n }\n\n /**\n * Add a child item id to this group at the given index.\n * @param itemId The id of the item to add to this group.\n * @param index The index at which to add the item. If not provided, the item is added to the end of the group.\n */\n addChild(itemId: string, index?: number): void {\n const items = this.config.items ??= [];\n const insertIndex = index !== undefined ? Math.min(index, items.length) : items.length;\n items.splice(insertIndex, 0, itemId);\n this.updateRawItem({\n ...this.rawItem,\n config: { ...this.config },\n });\n }\n\n /**\n * Remove a child item id from this group.\n * @param itemId The id of the item to remove from this group.\n */\n removeChild(itemId: string): void {\n const items = this.config.items ??= [];\n const index = items.indexOf(itemId);\n if (index !== -1) {\n items.splice(index, 1);\n this.updateRawItem({\n ...this.rawItem,\n config: { ...this.config },\n });\n }\n }\n\n /**\n * Check if an item is a direct child of this group.\n */\n hasChild(itemId: string): boolean {\n return this.items.includes(itemId);\n }\n\n /** Whether items in this group should be shuffled. */\n get shuffleItems(): boolean {\n return this.config.shuffleItems ?? false;\n }\n\n set shuffleItems(value: boolean) {\n this.config.shuffleItems = value;\n this.updateRawItem({\n ...this.rawItem,\n config: { ...this.config },\n });\n }\n\n /**\n * Get the ordered list of child item ids.\n */\n getChildrenIds(): string[] {\n return [...this.items];\n }\n\n /**\n * Swap two items by their positions in the group.\n * @throws Error if indices are out of bounds\n */\n swapItemsByIndex(from: number, to: number): void {\n const items = this.items;\n if (from < 0 || from >= items.length || to < 0 || to >= items.length) {\n throw new Error(`Index out of bounds. Valid range is 0-${items.length - 1}`);\n }\n if (from === to) return;\n this.config.items = swapArrayElements(items, from, to);\n this.updateRawItem({\n ...this.rawItem,\n config: { ...this.config },\n });\n }\n\n /**\n * Swap two items by their ids.\n * @throws Error if either id is not found in this group\n */\n swapItemsById(id: string, withId: string): void {\n const items = this.items;\n const index1 = items.indexOf(id);\n const index2 = items.indexOf(withId);\n if (index1 === -1) {\n throw new Error(`Item '${id}' not found in group '${this.key}'`);\n }\n if (index2 === -1) {\n throw new Error(`Item '${withId}' not found in group '${this.key}'`);\n }\n this.swapItemsByIndex(index1, index2);\n }\n\n /**\n * Move an item by id to a specific index.\n * @throws Error if the item is not found or index is out of bounds\n */\n moveItemToIndex(id: string, index: number): void {\n const items = this.items;\n const fromIndex = items.indexOf(id);\n if (fromIndex === -1) {\n throw new Error(`Item '${id}' not found in group '${this.key}'`);\n }\n if (index < 0 || index >= items.length) {\n throw new Error(`Index out of bounds. Valid range is 0-${items.length - 1}`);\n }\n if (fromIndex === index) return;\n this.config.items = moveArrayElement(items, fromIndex, index);\n this.updateRawItem({\n ...this.rawItem,\n config: { ...this.config },\n });\n }\n}\n\n/**\n * Page break item core.\n */\nexport type PageBreakConfig = Record<string, never>;\n\nexport class PageBreakItemCore extends SurveyItemCore<\n typeof ReservedSurveyItemTypes.PageBreak,\n PageBreakConfig\n> {\n readonly type = ReservedSurveyItemTypes.PageBreak;\n\n parseConfig(_rawConfig: unknown): PageBreakConfig {\n return {};\n }\n\n serializeConfig(): unknown {\n return undefined;\n }\n\n isInteractive(): boolean {\n return false;\n }\n\n getResponseSlotDefinitions() {\n return [];\n }\n}\n\n/**\n * Built-in item type.\n */\nexport type BuiltInItemType = typeof ReservedSurveyItemTypes.Group | typeof ReservedSurveyItemTypes.PageBreak;\n\nexport const builtInItemCoreRegistry: Record<BuiltInItemType, ItemCoreConstructor> = {\n [ReservedSurveyItemTypes.Group]: GroupItemCore,\n [ReservedSurveyItemTypes.PageBreak]: PageBreakItemCore,\n};\n\nexport const isBuiltInItemType = (itemType: string): itemType is BuiltInItemType =>\n itemType in builtInItemCoreRegistry;\n","import { ItemCoreConstructor, SurveyItemCore } from \"../items/survey-item\";\nimport { RawSurveyItem } from \"../items/survey-item-json\";\nimport { builtInItemCoreRegistry, isBuiltInItemType } from \"./built-in-items\";\n\n/**\n * Registry maps item type name → handler constructor.\n * Plugins extend this with their own handler classes.\n */\nexport type ItemTypeRegistry = Record<string, new (rawItem: RawSurveyItem) => SurveyItemCore>;\n\n/** Item type identifier (e.g. \"singleChoiceQuestion\", \"display\"). */\nexport type ItemTypeName = string;\n\n/** Capabilities of an item type (interactive, supports children). */\nexport interface ItemTypeCapabilities {\n interactive?: boolean;\n supportsChildren?: boolean;\n}\n\n/**\n * Definition of an item type: its name, constructor, and optional capabilities.\n * Used by editor/UI layers to compose registries.\n */\nexport interface ItemTypeDefinition {\n itemType: ItemTypeName;\n constructor: ItemCoreConstructor;\n capabilities?: ItemTypeCapabilities;\n}\n\n/** Registry mapping item type name → definition. */\nexport type ItemTypeDefinitionRegistry = Record<ItemTypeName, ItemTypeDefinition>;\n\n/** Convert constructor registry to explicit definitions for higher-layer composition. */\nexport function toItemTypeDefinitionRegistry(registry: ItemTypeRegistry): ItemTypeDefinitionRegistry {\n return Object.fromEntries(\n Object.entries(registry).map(([itemType, constructor]) => [\n itemType,\n { itemType, constructor },\n ])\n );\n}\n\n\n/**\n * Creates a handler instance for a raw survey item.\n * Uses built-in registry for group/page-break, otherwise the provided plugin registry.\n */\nexport function createItemCore(\n rawItem: RawSurveyItem,\n pluginRegistry?: ItemTypeRegistry\n): SurveyItemCore {\n if (isBuiltInItemType(rawItem.itemType)) {\n const HandlerClass = builtInItemCoreRegistry[rawItem.itemType];\n return new HandlerClass(rawItem);\n }\n\n if (pluginRegistry && rawItem.itemType in pluginRegistry) {\n const HandlerClass = pluginRegistry[rawItem.itemType];\n return new HandlerClass(rawItem);\n }\n\n throw new Error(`Unknown item type: ${rawItem.itemType}`);\n}\n\n/**\n * Merge built-in handlers with plugin registry for a complete registry.\n */\nexport function createFullRegistry(pluginRegistry?: ItemTypeRegistry): ItemTypeRegistry {\n return {\n ...builtInItemCoreRegistry,\n ...pluginRegistry,\n };\n}\n\n/** Build full registry as explicit definitions for editor/ui composition. */\nexport function createItemTypeDefinitionRegistry(pluginRegistry?: ItemTypeRegistry): ItemTypeDefinitionRegistry {\n return toItemTypeDefinitionRegistry(createFullRegistry(pluginRegistry));\n}\n","import { JsonTemplateValue } from \"../expressions/template-value\";\nimport { RawSurveyItem } from \"./items\";\nimport { JsonSurveyTranslations } from \"./utils/translations\";\n\nexport const CURRENT_SURVEY_SCHEMA = 'https://github.com/case-framework/case-survey-toolkit/packages/survey-core/schemas/survey-schema.json';\n// TODO: generate schema from survey-core.ts\n\n\nexport interface SurveyVersion {\n id?: string;\n surveyKey: string;\n published?: number;\n unpublished?: number;\n versionId?: string;\n survey: RawSurvey;\n}\n\nexport type RawSurvey = {\n $schema: string;\n maxItemsPerPage?: { large: number, small: number };\n\n surveyItems: Array<RawSurveyItem>;\n\n metadata?: {\n [key: string]: string\n }\n templateValues?: {\n [templateValueKey: string]: JsonTemplateValue;\n };\n translations?: JsonSurveyTranslations;\n}\n","import { structuredCloneMethod } from \"../../utils\";\nimport { Content } from \"./content\";\n\n\nexport const validateLocale = (locale: string): void => {\n if (locale.trim() === '') {\n throw new Error('Locale cannot be empty');\n }\n}\n\nexport class SurveyItemTranslations {\n private _translations?: {\n [locale: string]: JsonComponentContent;\n };\n\n constructor() {\n this._translations = {};\n }\n\n setContent(locale: string, contentKey: string, content?: Content): void {\n validateLocale(locale);\n if (!this._translations?.[locale]) {\n if (!content) {\n // No need to do anything if content is undefined\n return\n }\n this._translations![locale] = {};\n }\n if (!content) {\n delete this._translations![locale][contentKey];\n } else {\n this._translations![locale][contentKey] = content;\n }\n }\n\n setAllForLocale(locale: string, content?: JsonComponentContent): void {\n validateLocale(locale);\n if (!this._translations?.[locale]) {\n if (!content) {\n // No need to do anything if content is undefined\n return\n }\n this._translations![locale] = {};\n }\n this._translations![locale] = content || {};\n }\n\n get locales(): string[] {\n return Object.keys(this._translations || {});\n }\n\n getAllForLocale(locale: string): JsonComponentContent | undefined {\n return this._translations?.[locale];\n }\n\n getContent(locale: string, contentKey: string, fallbackLocale?: string): Content | undefined {\n const content = this._translations?.[locale]?.[contentKey];\n if (content) {\n return content;\n }\n if (fallbackLocale) {\n return this._translations?.[fallbackLocale]?.[contentKey];\n }\n return undefined;\n }\n}\n\nexport interface SurveyCardTranslations {\n [locale: string]: SurveyCardContent;\n}\n\n\nexport class SurveyTranslations {\n private _translations: JsonSurveyTranslations;\n\n constructor(translations?: JsonSurveyTranslations) {\n this._translations = translations || {};\n }\n\n\n serialize(): JsonSurveyTranslations | undefined {\n if (this.locales.length === 0) {\n return undefined;\n }\n return this._translations;\n }\n\n get locales(): string[] {\n return Object.keys(this._translations);\n }\n\n removeLocale(locale: string): void {\n validateLocale(locale);\n delete this._translations[locale];\n }\n\n renameLocale(oldLocale: string, newLocale: string): void {\n validateLocale(oldLocale);\n validateLocale(newLocale);\n if (this._translations[oldLocale]) {\n this._translations[newLocale] = this._translations[oldLocale];\n delete this._translations[oldLocale];\n }\n }\n\n cloneLocaleAs(locale: string, newLocale: string): void {\n validateLocale(locale);\n validateLocale(newLocale);\n if (this._translations[locale]) {\n this._translations[newLocale] = structuredCloneMethod(this._translations[locale]);\n }\n }\n\n get surveyCardContent(): SurveyCardTranslations | undefined {\n const translations: SurveyCardTranslations = {};\n for (const locale of this.locales) {\n const contentForLocale = this._translations?.[locale]?.surveyCardContent;\n if (contentForLocale) {\n translations[locale] = contentForLocale as SurveyCardContent;\n }\n }\n return translations;\n }\n\n get navigationContent(): { [locale: string]: NavigationContent } | undefined {\n const translations: { [locale: string]: NavigationContent } = {};\n for (const locale of this.locales) {\n const contentForLocale = this._translations?.[locale]?.navigationContent;\n if (contentForLocale) {\n translations[locale] = contentForLocale as NavigationContent;\n }\n }\n return translations;\n }\n\n get validationMessages(): { [locale: string]: { invalidResponse?: Content } } | undefined {\n const translations: { [locale: string]: { invalidResponse?: Content } } = {};\n for (const locale of this.locales) {\n const contentForLocale = this._translations?.[locale]?.validationMessages;\n if (contentForLocale) {\n translations[locale] = contentForLocale as { invalidResponse?: Content };\n }\n }\n return translations;\n }\n\n setSurveyCardContent(locale: string, content?: SurveyCardContent): void {\n validateLocale(locale);\n if (!this._translations[locale]) {\n if (!content) {\n // No need to do anything if content is undefined\n return\n }\n this._translations[locale] = {};\n }\n this._translations[locale].surveyCardContent = content;\n }\n\n setNavigationContent(locale: string, content?: NavigationContent): void {\n validateLocale(locale);\n if (!this._translations[locale]) {\n if (!content) {\n // No need to do anything if content is undefined\n return\n }\n this._translations[locale] = {};\n }\n this._translations[locale].navigationContent = content;\n }\n\n setValidationMessages(locale: string, content?: { invalidResponse?: Content }): void {\n validateLocale(locale);\n if (!this._translations[locale]) {\n if (!content) {\n // No need to do anything if content is undefined\n return\n }\n this._translations[locale] = {};\n }\n this._translations[locale].validationMessages = content;\n }\n\n getItemTranslations(itemId: string): SurveyItemTranslations | undefined {\n const itemTranslations: SurveyItemTranslations = new SurveyItemTranslations();\n for (const locale of this.locales) {\n const contentForLocale = this._translations?.[locale].itemTranslations?.[itemId];\n itemTranslations.setAllForLocale(locale, contentForLocale as JsonComponentContent);\n }\n return itemTranslations;\n }\n\n setItemTranslations(itemId: string, itemContent?: SurveyItemTranslations): void {\n itemContent?.locales.forEach(locale => validateLocale(locale));\n if (!itemContent) {\n for (const locale of this.locales) {\n if (this._translations[locale].itemTranslations?.[itemId]) {\n delete this._translations[locale].itemTranslations?.[itemId];\n }\n }\n } else {\n const localesInUpdate = itemContent.locales;\n // Add new locales to the translations\n for (const locale of localesInUpdate) {\n if (!this.locales.includes(locale)) {\n this._translations[locale] = {};\n }\n }\n for (const locale of this.locales) {\n if (localesInUpdate.includes(locale)) {\n if (!this._translations[locale]) {\n this._translations[locale] = {};\n }\n if (!this._translations[locale].itemTranslations) {\n this._translations[locale].itemTranslations = {};\n }\n this._translations[locale].itemTranslations![itemId] = itemContent.getAllForLocale(locale) ?? {};\n } else {\n delete this._translations[locale].itemTranslations![itemId];\n }\n }\n }\n }\n\n /**\n * Rename a component key (within an item) - update key in all translations and remove old key\n * @param itemKey - The key of the item\n * @param oldKey - The old key of the component\n * @param newKey - The new key of the component\n */\n onComponentKeyChanged(itemKey: string, oldKey: string, newKey: string): void {\n for (const locale of this.locales) {\n const itemTranslations = this._translations?.[locale].itemTranslations?.[itemKey] as JsonComponentContent;\n if (itemTranslations) {\n for (const key of Object.keys(itemTranslations)) {\n if (key.startsWith(oldKey + '.') || key === oldKey) {\n itemTranslations[key.replace(oldKey, newKey)] = { ...itemTranslations[key] };\n delete itemTranslations[key];\n }\n }\n }\n }\n }\n\n /**\n * Remove all translations for a component\n * @param itemId - The id of the item\n * @param componentKey - The key of the component\n */\n onComponentDeleted(itemId: string, componentKey: string): void {\n for (const locale of this.locales) {\n const itemTranslations = this._translations?.[locale].itemTranslations?.[itemId];\n if (itemTranslations) {\n for (const key of Object.keys(itemTranslations)) {\n if (key.startsWith(componentKey + '.') || key === componentKey) {\n delete itemTranslations[key as keyof typeof itemTranslations];\n }\n }\n }\n }\n }\n\n /**\n * Remove all translations for an item\n * @param id - The id of the item\n */\n onItemDeleted(id: string): void {\n for (const locale of this.locales) {\n delete this._translations![locale].itemTranslations?.[id];\n }\n }\n}\n\n\n/**\n * Json Schemas for translations\n */\nexport type JsonComponentContent = {\n [contentKey: string]: Content;\n}\n\n\nexport interface SurveyCardContent {\n name?: Content;\n description?: Content;\n typicalDuration?: Content;\n}\n\nexport interface NavigationContent {\n previousButtonText?: Content;\n nextButtonText?: Content;\n submitButtonText?: Content;\n submitBoxMessage?: Content;\n}\n\nexport interface JsonSurveyTranslations {\n [locale: string]: {\n surveyCardContent?: SurveyCardContent;\n navigationContent?: NavigationContent;\n validationMessages?: {\n invalidResponse?: Content;\n }\n itemTranslations?: {\n [itemId: string]: JsonComponentContent;\n }\n }\n}\n","import { CURRENT_SURVEY_SCHEMA, RawSurvey, } from \"./survey-file-schema\";\nimport { SurveyItemTranslations, SurveyTranslations } from \"./utils/translations\";\nimport { SurveyItemCore, RawSurveyItem, ReservedSurveyItemTypes } from \"./items\";\nimport { ReferenceUsage, ReferenceUsageType } from \"./utils/value-reference\";\nimport { SurveyItemKey } from \"./item-key\";\nimport { deserializeTemplateValues, serializeTemplateValues, TemplateValueDefinition } from \"../expressions/template-value\";\nimport { ValueRefTypeLookup, ValueType } from \"./responses/value-types\";\nimport { ResponseSlotDefinition } from \"./responses/slot-definition\";\nimport { createItemCore, ItemTypeRegistry } from \"./registry/item-registry\";\nimport { GroupItemCore } from \"./registry/built-in-items\";\nimport { generateCodingKey, generateId } from \"../utils\";\n\n\nexport class Survey {\n maxItemsPerPage?: { large: number, small: number };\n metadata?: {\n [key: string]: string\n }\n surveyItems: Map<string, SurveyItemCore> = new Map();\n private _templateValues?: Map<string, TemplateValueDefinition> = new Map();\n\n private _translations?: SurveyTranslations;\n\n constructor(\n private readonly pluginRegistry?: ItemTypeRegistry\n ) {\n this._translations = new SurveyTranslations();\n }\n\n /** Plugin registry used when parsing items. Exposed for editors that re-parse without their own registry. */\n getPluginRegistry(): ItemTypeRegistry | undefined {\n return this.pluginRegistry;\n }\n\n /**\n * Create a survey item from raw JSON data.\n * Uses the survey's plugin registry when available.\n */\n createItemFromRaw(rawItem: RawSurveyItem): SurveyItemCore {\n return createItemCore(rawItem, this.pluginRegistry);\n }\n\n /**\n * Create a minimal blank survey with a root group and one empty page.\n */\n static createBlankSurvey(\n pluginRegistry?: ItemTypeRegistry,\n surveyKey?: string,\n ): Survey {\n const newKey = surveyKey ?? generateCodingKey();\n const rawSurvey: RawSurvey = {\n $schema: CURRENT_SURVEY_SCHEMA,\n surveyItems: [\n {\n id: generateId(),\n key: newKey,\n itemType: ReservedSurveyItemTypes.Group,\n config: { isRoot: true, items: [], shuffleItems: false },\n },\n ],\n };\n\n return Survey.fromJson(rawSurvey, pluginRegistry);\n }\n\n static fromJson(json: RawSurvey, pluginRegistry?: ItemTypeRegistry): Survey {\n const survey = new Survey(pluginRegistry);\n const rawSurvey = json as RawSurvey;\n if (rawSurvey.$schema !== CURRENT_SURVEY_SCHEMA) {\n throw new Error(`Unsupported survey schema: ${rawSurvey.$schema}`);\n }\n\n survey.surveyItems = new Map();\n if (!rawSurvey.surveyItems || rawSurvey.surveyItems.length === 0) {\n throw new Error('surveyItems is required');\n }\n rawSurvey.surveyItems.forEach(item => {\n const surveyItem = createItemCore(item, pluginRegistry);\n survey.surveyItems.set(surveyItem.id, surveyItem);\n });\n\n // Parse other fields\n if (rawSurvey.templateValues) {\n survey._templateValues = deserializeTemplateValues(rawSurvey.templateValues);\n }\n\n survey._translations = new SurveyTranslations(rawSurvey.translations);\n\n if (rawSurvey.maxItemsPerPage) {\n survey.maxItemsPerPage = rawSurvey.maxItemsPerPage;\n }\n\n if (rawSurvey.metadata) {\n survey.metadata = rawSurvey.metadata;\n }\n\n return survey;\n }\n\n serialize(): RawSurvey {\n const json: RawSurvey = {\n $schema: CURRENT_SURVEY_SCHEMA,\n surveyItems: Array.from(this.surveyItems.values()).map(item => item.rawItem),\n };\n\n // Export other fields\n json.translations = this._translations?.serialize();\n\n if (this._templateValues) {\n json.templateValues = serializeTemplateValues(this._templateValues);\n }\n\n if (this.maxItemsPerPage) {\n json.maxItemsPerPage = this.maxItemsPerPage;\n }\n if (this.metadata) {\n json.metadata = this.metadata;\n }\n\n return json;\n }\n\n get surveyKey(): string | undefined {\n const rootItem = this.rootItem;\n if (!rootItem) {\n return undefined;\n }\n return this.rootItem.key;\n }\n\n get locales(): string[] {\n return this._translations?.locales || [];\n }\n\n get rootItem(): GroupItemCore | undefined {\n const rootItem = Array.from(this.surveyItems.values()).find(item => item instanceof GroupItemCore && item.isRoot) as GroupItemCore | undefined;\n return rootItem;\n }\n\n\n get keyIndex(): Array<{ itemId: string, key: string, keyPath: string[], path: string[] }> {\n const index: Array<{ itemId: string, key: string, keyPath: string[], path: string[] }> = [];\n for (const item of this.surveyItems.values()) {\n const path = this.getItemPath(item.id);\n index.push({\n itemId: item.id, key: item.key,\n keyPath: path.map(id => this.surveyItems.get(id)?.key ?? ''),\n path: path\n });\n }\n return index;\n }\n\n getItemPath(itemId: string): string[] {\n const item = this.surveyItems.get(itemId);\n if (!item) {\n throw new Error(`Item ${itemId} not found`);\n }\n\n if (item instanceof GroupItemCore && item.isRoot()) {\n return [];\n }\n\n // find parent item for the given item id\n const parentItem = this.getParentItem(itemId);\n if (!parentItem) {\n throw new Error(`Parent item for ${itemId} not found`);\n }\n return [...this.getItemPath(parentItem.id), parentItem.id];\n }\n\n getItemKey(itemId: string): SurveyItemKey | undefined {\n const item = this.surveyItems.get(itemId);\n if (!item) {\n return undefined;\n }\n const idPath = this.getItemPath(itemId);\n const keyPath = idPath.map(id => this.surveyItems.get(id)?.key ?? '');\n return new SurveyItemKey(item.key, keyPath);\n }\n\n getParentItem(itemId: string): GroupItemCore | undefined {\n const item = this.surveyItems.get(itemId);\n if (!item) {\n throw new Error(`Item ${itemId} not found`);\n }\n if (item instanceof GroupItemCore && item.isRoot()) {\n return undefined;\n }\n const parentItem = Array.from(this.surveyItems.values()).find(item => item instanceof GroupItemCore && item.config.items?.includes(itemId)) as GroupItemCore | undefined;\n if (!parentItem) {\n return undefined;\n }\n return parentItem;\n }\n\n getChildrenItems(parentId: string): SurveyItemCore[] {\n const parentItem = this.surveyItems.get(parentId);\n if (!parentItem || !(parentItem instanceof GroupItemCore)) {\n return [];\n }\n return (parentItem as GroupItemCore).config.items?.map(id => this.surveyItems.get(id))?.filter(item => item !== undefined) as SurveyItemCore[] || [];\n }\n\n getSiblings(itemId: string): SurveyItemCore[] {\n const item = this.surveyItems.get(itemId);\n if (!item) {\n return [];\n }\n const parentItem = this.getParentItem(itemId);\n return parentItem?.items?.map(id => this.surveyItems.get(id))?.filter(item => item !== undefined) as SurveyItemCore[] || [];\n }\n\n get translations(): SurveyTranslations {\n if (!this._translations) {\n this._translations = new SurveyTranslations();\n }\n return this._translations;\n }\n\n getItemTranslations(id: string): SurveyItemTranslations | undefined {\n const item = this.surveyItems.get(id);\n if (!item) {\n throw new Error(`Item ${id} not found`);\n }\n\n return this._translations?.getItemTranslations(id);\n }\n\n getTemplateValue(templateValueKey: string): TemplateValueDefinition | undefined {\n return this._templateValues?.get(templateValueKey);\n }\n\n setTemplateValue(templateValueKey: string, templateValue: TemplateValueDefinition) {\n if (!this._templateValues) {\n this._templateValues = new Map();\n }\n this._templateValues?.set(templateValueKey, templateValue);\n }\n\n deleteTemplateValue(templateValueKey: string) {\n this._templateValues?.delete(templateValueKey);\n }\n\n getTemplateValueKeys(): string[] {\n return Array.from(this._templateValues?.keys() || []);\n }\n\n getAvailableResponseValueSlots(byType?: ValueType): ValueRefTypeLookup {\n let valueRefs: ValueRefTypeLookup = {};\n for (const item of this.surveyItems.values()) {\n valueRefs = { ...valueRefs, ...item.getAvailableResponseValueSlots(byType) };\n }\n return valueRefs;\n }\n\n getResponseSlotDefinitions(): Array<{ itemId: string; slots: ResponseSlotDefinition[] }> {\n return Array.from(this.surveyItems.values()).map((item) => ({\n itemId: item.id,\n slots: item.getResponseSlotDefinitions(),\n }));\n }\n\n /**\n * Get all reference usages for the survey\n * @param forItemId - optional item id to filter usages for a specific item and its children (if not provided, all usages are returned)\n * @returns all reference usages for the survey (or for a specific item and its children)\n */\n getReferenceUsages(forItemId?: string): ReferenceUsage[] {\n const usages: ReferenceUsage[] = [];\n for (const item of this.surveyItems.values()) {\n if (forItemId && item.id !== forItemId && !this.isDescendantOf(item.id, forItemId)) {\n continue;\n }\n usages.push(...item.getReferenceUsages());\n }\n\n if (this._templateValues) {\n for (const [templateValueKey, templateValue] of this._templateValues.entries()) {\n for (const ref of templateValue.expression?.responseVariableRefs || []) {\n usages.push({\n itemId: templateValueKey,\n usageType: ReferenceUsageType.templateValues,\n valueReference: ref,\n });\n }\n }\n }\n\n return usages;\n }\n\n // Helper method to check if targetId is a descendant of ancestorId\n isDescendantOf(targetId: string, ancestorId: string): boolean {\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,4BAA4B;GACzC,EAAE;;;;;;;CAQL,mBAAmB,WAAsC;EACvD,MAAM,SAA2B,EAAE;AACnC,OAAK,MAAM,QAAQ,KAAK,YAAY,QAAQ,EAAE;AAC5C,OAAI,aAAa,KAAK,OAAO,aAAa,CAAC,KAAK,eAAe,KAAK,IAAI,UAAU,CAChF;AAEF,UAAO,KAAK,GAAG,KAAK,oBAAoB,CAAC;;AAG3C,MAAI,KAAK,gBACP,MAAK,MAAM,CAAC,kBAAkB,kBAAkB,KAAK,gBAAgB,SAAS,CAC5E,MAAK,MAAM,OAAO,cAAc,YAAY,wBAAwB,EAAE,CACpE,QAAO,KAAK;GACV,QAAQ;GACR,WAAW,mBAAmB;GAC9B,gBAAgB;GACjB,CAAC;AAKR,SAAO;;CAIT,eAAe,UAAkB,YAA6B;AAC5D,MAAI,aAAa,WACf,QAAO;AAGT,SADmB,KAAK,YAAY,SAAS,CAC3B,SAAS,WAAW"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"survey-wnGyIY66.d.mts","names":[],"sources":["../src/survey/responses/value-types.ts","../src/survey/responses/slot-definition.ts","../src/survey/utils/value-reference.ts","../src/expressions/expression.ts","../src/expressions/template-value.ts","../src/survey/items/utils.ts","../src/survey/items/survey-item.ts","../src/survey/items/survey-item-json.ts","../src/survey/items/types.ts","../src/survey/utils/content.ts","../src/survey/utils/translations.ts","../src/survey/survey-file-schema.ts","../src/survey/item-key.ts","../src/survey/registry/item-registry.ts","../src/survey/registry/built-in-items.ts","../src/survey/survey.ts"],"mappings":";cAAa,SAAA;EAAA;;;;;;;;;;;;KAcD,SAAA,WAAoB,SAAA,eAAwB,SAAA;AAAA,cAG3C,aAAA;EAAA;;;;;;;;KAUD,YAAA,WAAuB,aAAA,eAA4B,aAAA;AAAA,cAGlD,eAAA;EAAA,SAGH,GAAA;EAAA,SAAA,KAAA;AAAA;AAAA,KAEE,eAAA,WAA0B,eAAA,eAA8B,eAAA;AAAA,UAGnD,gBAAA,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