@case-framework/survey-core 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2208 +0,0 @@
1
- import { Locale } from "date-fns";
2
- //#region src/to_mirgrate/data_types/expression.d.ts
3
- type SelectionMethodNames = "sequential" | "uniform" | "highestPriority" | "exponential";
4
- type SurveyContextRuleNames = "LAST_RESPONSES_BY_KEY" | "ALL_RESPONSES_SINCE" | "RESPONSES_SINCE_BY_KEY";
5
- type SurveyPrefillRuleNames = "GET_LAST_SURVEY_ITEM";
6
- type ClientSideSurveyExpName = "or" | "and" | "not" | "eq" | "lt" | "lte" | "gt" | "gte" | "isDefined" | "getContext" | "getResponses" | "getRenderedItems" | "getAttribute" | "getArrayItemAtIndex" | "getArrayItemByKey" | "getObjByHierarchicalKey" | "getNestedObjectByKey" | "findPreviousSurveyResponsesByKey" | "getLastFromSurveyResponses" | "getPreviousResponses" | "filterResponsesByIncludesKeys" | "filterResponsesByValue" | "getLastFromSurveyItemResponses" | "getSecondsSince" | "parseValueAsNum" | "hasResponse" | "getResponseItem" | "getResponseValueAsNum" | "getResponseValueAsStr" | "checkResponseValueWithRegex" | "responseHasKeysAny" | "responseHasKeysAll" | "responseHasOnlyKeysOtherThan" | "getSurveyItemValidation" | "timestampWithOffset" | "dateResponseDiffFromNow" | "countResponseItems" | "hasParticipantFlagKey" | "hasParticipantFlagKeyAndValue" | "getParticipantFlagValue" | "validateSelectedOptionHasValueDefined";
7
- type StudyEngineExpNames = string;
8
- type ExpressionName = ClientSideSurveyExpName | SelectionMethodNames | SurveyContextRuleNames | SurveyPrefillRuleNames | StudyEngineExpNames;
9
- interface Expression$1 {
10
- name: ExpressionName;
11
- returnType?: string;
12
- data?: ExpressionArg[];
13
- }
14
- type ExpressionArgDType = "exp" | "num" | "str";
15
- interface ExpressionArg {
16
- dtype?: ExpressionArgDType;
17
- exp?: Expression$1;
18
- str?: string;
19
- num?: number;
20
- }
21
- //#endregion
22
- //#region src/to_mirgrate/data_types/legacy-types.d.ts
23
- type LegacyItemComponent = LegacyItemComponentBase | LegacyItemGroupComponent | LegacyResponseComponent;
24
- interface LegacyItemComponentBase {
25
- role: string;
26
- key?: string;
27
- content?: Array<LegacyLocalizedObject>;
28
- displayCondition?: Expression$1 | boolean;
29
- disabled?: Expression$1 | boolean;
30
- style?: Array<{
31
- key: string;
32
- value: string;
33
- }>;
34
- description?: Array<LegacyLocalizedObject>;
35
- properties?: LegacyComponentProperties;
36
- }
37
- interface LegacyResponseComponent extends LegacyItemComponentBase {
38
- key: string;
39
- dtype?: string;
40
- }
41
- interface LegacyItemGroupComponent extends LegacyItemComponentBase {
42
- items: Array<LegacyItemComponent>;
43
- order?: Expression$1;
44
- }
45
- declare const isLegacyItemGroupComponent: (item: LegacyItemComponent) => item is LegacyItemGroupComponent;
46
- interface LegacyComponentProperties {
47
- min?: ExpressionArg | number;
48
- max?: ExpressionArg | number;
49
- stepSize?: ExpressionArg | number;
50
- dateInputMode?: ExpressionArg | string;
51
- pattern?: string;
52
- }
53
- type LegacyLocalizedObject = LegacyLocalizedString;
54
- interface LegacyLocalizedObjectBase {
55
- code: string;
56
- }
57
- interface LegacyLocalizedString extends LegacyLocalizedObjectBase {
58
- parts: Array<ExpressionArg>;
59
- resolvedText?: string;
60
- }
61
- interface LegacySurvey {
62
- id?: string;
63
- props?: LegacySurveyProps;
64
- prefillRules?: Expression$1[];
65
- maxItemsPerPage?: {
66
- large: number;
67
- small: number;
68
- };
69
- availableFor?: string;
70
- requireLoginBeforeSubmission?: boolean;
71
- surveyDefinition: LegacySurveyGroupItem;
72
- published?: number;
73
- unpublished?: number;
74
- versionId: string;
75
- metadata?: {
76
- [key: string]: string;
77
- };
78
- }
79
- interface LegacySurveyProps {
80
- name?: LegacyLocalizedObject[];
81
- description?: LegacyLocalizedObject[];
82
- typicalDuration?: LegacyLocalizedObject[];
83
- }
84
- interface LegacySurveyItemBase {
85
- key: string;
86
- metadata?: {
87
- [key: string]: string;
88
- };
89
- follows?: Array<string>;
90
- condition?: Expression$1;
91
- priority?: number;
92
- }
93
- type LegacySurveyItem = LegacySurveyGroupItem | LegacySurveySingleItem;
94
- interface LegacySurveyGroupItem extends LegacySurveyItemBase {
95
- items: Array<LegacySurveyItem>;
96
- selectionMethod?: Expression$1;
97
- }
98
- declare const isLegacySurveyGroupItem: (item: LegacySurveyItem) => item is LegacySurveyGroupItem;
99
- type LegacySurveyItemTypes = "pageBreak" | "test" | "surveyEnd";
100
- interface LegacySurveySingleItem extends LegacySurveyItemBase {
101
- type?: LegacySurveyItemTypes;
102
- components?: LegacyItemGroupComponent;
103
- validations?: Array<LegacyValidation>;
104
- confidentialMode?: LegacyConfidentialMode;
105
- mapToKey?: string;
106
- }
107
- interface LegacyValidation {
108
- key: string;
109
- type: "soft" | "hard";
110
- rule: Expression$1 | boolean;
111
- }
112
- type LegacyConfidentialMode = "add" | "replace";
113
- //#endregion
114
- //#region src/survey/responses/response-meta.d.ts
115
- interface ItemResponseMeta {
116
- position: number;
117
- }
118
- declare const SurveyEventTypes: {
119
- readonly openSurvey: "openSurvey";
120
- readonly pageChanged: "pageChanged";
121
- readonly responseChanged: "responseChanged";
122
- readonly languageChanged: "languageChanged";
123
- };
124
- type SurveyEventTypes = (typeof SurveyEventTypes)[keyof typeof SurveyEventTypes];
125
- interface SurveyEventBase<TEventType extends SurveyEventTypes = SurveyEventTypes> {
126
- type: TEventType;
127
- timestamp: number;
128
- }
129
- interface OpenSurveyEvent extends SurveyEventBase<typeof SurveyEventTypes.openSurvey> {
130
- value: string;
131
- }
132
- interface PageChangedEvent extends SurveyEventBase<typeof SurveyEventTypes.pageChanged> {
133
- value: number;
134
- }
135
- interface ResponseChangedEvent extends SurveyEventBase<typeof SurveyEventTypes.responseChanged> {
136
- slotId: string;
137
- operation: "set" | "clear";
138
- }
139
- interface LanguageChangedEvent extends SurveyEventBase<typeof SurveyEventTypes.languageChanged> {
140
- value: string;
141
- }
142
- type SurveyEvent = OpenSurveyEvent | PageChangedEvent | ResponseChangedEvent | LanguageChangedEvent;
143
- //#endregion
144
- //#region src/calendar-date.d.ts
145
- /** Gregorian calendar values, without a time or timezone. Precision is part of the value. */
146
- type CalendarDate = string;
147
- type CalendarDatePrecision = "year" | "year-month" | "year-month-day";
148
- type CalendarDateUnit = "years" | "months" | "days";
149
- declare function isCalendarDate(value: unknown): value is CalendarDate;
150
- declare function calendarDatePrecision(value: CalendarDate): CalendarDatePrecision;
151
- declare function calendarDateFromLocalDate(date: Date, precision?: CalendarDatePrecision): CalendarDate;
152
- /** Adapter for calendar widgets only. Never serialize this Date as an instant. */
153
- declare function calendarDateToLocalDate(value: CalendarDate): Date;
154
- declare function calendarDateBounds(value: CalendarDate): [CalendarDate, CalendarDate];
155
- /** Ordering requires equal precision; callers must explicitly choose interval semantics otherwise. */
156
- declare function compareCalendarDates(a: CalendarDate, b: CalendarDate): number | undefined;
157
- declare function addCalendarDate(value: CalendarDate, amount: number, unit: CalendarDateUnit): CalendarDate | undefined;
158
- /** Signed difference a - b in the value's precision unit (days, months, or years). */
159
- declare function differenceCalendarDates(a: CalendarDate, b: CalendarDate): number | undefined;
160
- /** Partial dates retain their precision even if a display pattern requests absent components. */
161
- declare function formatCalendarDate(value: CalendarDate, pattern: string): string;
162
- //#endregion
163
- //#region src/survey/responses/value-types.d.ts
164
- declare const ValueType: {
165
- readonly string: "string";
166
- readonly duration: "duration";
167
- readonly reference: "reference";
168
- readonly number: "number";
169
- readonly boolean: "boolean";
170
- readonly date: "date";
171
- readonly stringArray: "string[]";
172
- readonly durationArray: "duration[]";
173
- readonly referenceArray: "reference[]";
174
- readonly numberArray: "number[]";
175
- readonly dateArray: "date[]";
176
- };
177
- type ValueType = (typeof ValueType)[keyof typeof ValueType];
178
- declare const DurationUnits: {
179
- readonly seconds: "seconds";
180
- readonly minutes: "minutes";
181
- readonly hours: "hours";
182
- readonly days: "days";
183
- readonly weeks: "weeks";
184
- readonly months: "months";
185
- readonly years: "years";
186
- };
187
- type DurationUnit = (typeof DurationUnits)[keyof typeof DurationUnits];
188
- declare const NumberPrecision: {
189
- readonly int: "int";
190
- readonly float: "float";
191
- };
192
- type NumberPrecision = (typeof NumberPrecision)[keyof typeof NumberPrecision];
193
- interface SlotResponseBase<TValueType extends ValueType> {
194
- type: TValueType;
195
- }
196
- interface StringResponse extends SlotResponseBase<typeof ValueType.string> {
197
- value: string;
198
- }
199
- interface DurationResponse extends SlotResponseBase<typeof ValueType.duration> {
200
- value: number;
201
- unit: DurationUnit;
202
- precision?: NumberPrecision;
203
- }
204
- interface NumberResponse extends SlotResponseBase<typeof ValueType.number> {
205
- value: number;
206
- precision?: NumberPrecision;
207
- }
208
- interface BooleanResponse extends SlotResponseBase<typeof ValueType.boolean> {
209
- value: boolean;
210
- }
211
- interface ReferenceResponse extends SlotResponseBase<typeof ValueType.reference> {
212
- value: string;
213
- }
214
- interface DateResponse extends SlotResponseBase<typeof ValueType.date> {
215
- value: CalendarDate;
216
- }
217
- interface StringArrayResponse extends SlotResponseBase<typeof ValueType.stringArray> {
218
- value: string[];
219
- }
220
- interface DurationArrayResponse extends SlotResponseBase<typeof ValueType.durationArray> {
221
- value: number[];
222
- unit: DurationUnit;
223
- precision?: NumberPrecision;
224
- }
225
- interface NumberArrayResponse extends SlotResponseBase<typeof ValueType.numberArray> {
226
- value: number[];
227
- precision?: NumberPrecision;
228
- }
229
- interface DateArrayResponse extends SlotResponseBase<typeof ValueType.dateArray> {
230
- value: CalendarDate[];
231
- }
232
- interface ReferenceArrayResponse extends SlotResponseBase<typeof ValueType.referenceArray> {
233
- value: string[];
234
- }
235
- type ResponseValue = StringResponse | DurationResponse | ReferenceResponse | NumberResponse | BooleanResponse | DateResponse | StringArrayResponse | DurationArrayResponse | NumberArrayResponse | DateArrayResponse | ReferenceArrayResponse;
236
- type ValueRefTypeLookup = {
237
- [valueRefString: string]: ValueType;
238
- };
239
- declare function isResponseValue(value: unknown): value is ResponseValue;
240
- declare function assertResponseValue(value: unknown, path: string): asserts value is ResponseValue;
241
- //#endregion
242
- //#region src/survey/responses/item-response.d.ts
243
- interface JsonSurveyItemResponse {
244
- itemId: string;
245
- itemType: string;
246
- meta?: ItemResponseMeta;
247
- response?: JsonResponseItem;
248
- }
249
- interface JsonResponseItem {
250
- slots: Record<string, ResponseValue>;
251
- }
252
- /**
253
- * SurveyItemResponse to store the response of a survey item.
254
- */
255
- declare class SurveyItemResponse {
256
- itemId: string;
257
- meta?: ItemResponseMeta;
258
- response?: ResponseItem;
259
- itemType: string;
260
- constructor(itemDef: {
261
- itemId: string;
262
- itemType: string;
263
- }, response?: ResponseItem);
264
- serialize(): JsonSurveyItemResponse;
265
- static deserialize(json: JsonSurveyItemResponse): SurveyItemResponse;
266
- }
267
- declare class ResponseItem {
268
- private _slots;
269
- constructor(initialValues?: Array<[slotId: string, slotResponse: ResponseValue]>);
270
- get(slotId: string): ResponseValue | undefined;
271
- setSlotValue(slotId: string, slotResponse?: ResponseValue): void;
272
- serialize(): JsonResponseItem | undefined;
273
- isEmpty(): boolean;
274
- clone(): ResponseItem;
275
- static deserialize(json: JsonResponseItem): ResponseItem;
276
- }
277
- //#endregion
278
- //#region src/survey/responses/variable-naming.d.ts
279
- declare const RESPONSE_VARIABLE_NAME_MAX_LENGTH = 32;
280
- declare const isValidResponseVariableName: (name: string) => boolean;
281
- /** Generate an initial suggestion; explicit rename operations validate instead of coercing. */
282
- declare function suggestResponseVariableName(text: string, fallback?: string): string;
283
- declare function allocateResponseVariableName(base: string, used: ReadonlySet<string>, maxLength?: number): string;
284
- /** Paths are derived from the current declaration, never used as persistent answer identities. */
285
- type ResponseNamingSource = {
286
- kind: "variable";
287
- path: (string | number)[];
288
- } | {
289
- kind: "matrix";
290
- prefixPath: (string | number)[];
291
- rowPath?: (string | number)[];
292
- columnPath?: (string | number)[];
293
- suffix?: string;
294
- };
295
- //#endregion
296
- //#region src/survey/responses/survey-response.d.ts
297
- declare const SURVEY_RESPONSE_SCHEMA_VERSION = 2;
298
- interface ResponseEvaluationContext {
299
- locale: string;
300
- participantFlags?: Record<string, string>;
301
- }
302
- type SurveyResponseContext = Record<string, ResponseValue>;
303
- /** Publication and schema association belong to the host, never to an answer address. */
304
- declare class SurveyResponse {
305
- key: string;
306
- participantId?: string;
307
- submittedAt?: number;
308
- answers: Record<string, ResponseValue>;
309
- itemMetadata: Record<string, ItemResponseMeta>;
310
- events: SurveyEvent[];
311
- context?: SurveyResponseContext;
312
- evaluationContext?: ResponseEvaluationContext;
313
- constructor(key: string);
314
- /** Collect an engine item view into a flat submission, rejecting ambiguous ownership. */
315
- addItemResponse(item: SurveyItemResponse): void;
316
- serialize(): JsonSurveyResponse;
317
- static deserialize(json: JsonSurveyResponse): SurveyResponse;
318
- }
319
- interface JsonSurveyResponse {
320
- schemaVersion: typeof SURVEY_RESPONSE_SCHEMA_VERSION;
321
- key: string;
322
- participantId?: string;
323
- submittedAt?: number;
324
- answers: Record<string, ResponseValue>;
325
- itemMetadata?: Record<string, ItemResponseMeta>;
326
- events: SurveyEvent[];
327
- context?: SurveyResponseContext;
328
- evaluationContext?: ResponseEvaluationContext;
329
- }
330
- //#endregion
331
- //#region src/expressions/template-value.d.ts
332
- declare enum TemplateDefTypes {
333
- Default = "default",
334
- Date2String = "date2string"
335
- }
336
- type TemplateValueBase = {
337
- type: TemplateDefTypes;
338
- returnType: ValueType;
339
- expression?: Expression;
340
- };
341
- type TemplateValueFormatDate = TemplateValueBase & {
342
- type: TemplateDefTypes.Date2String;
343
- returnType: typeof ValueType.string;
344
- dateFormat: string;
345
- };
346
- type TemplateValueDefinition = TemplateValueBase | TemplateValueFormatDate;
347
- declare const serializeTemplateValue: (templateValue: TemplateValueDefinition) => JsonTemplateValue;
348
- declare const serializeTemplateValues: (templateValues: Map<string, TemplateValueDefinition>) => {
349
- [templateValueKey: string]: JsonTemplateValue;
350
- };
351
- declare const deserializeTemplateValue: (json: JsonTemplateValue) => TemplateValueDefinition;
352
- declare const deserializeTemplateValues: (json: {
353
- [templateValueKey: string]: JsonTemplateValue;
354
- }) => Map<string, TemplateValueDefinition>;
355
- interface JsonTemplateValue {
356
- type: TemplateDefTypes;
357
- expression?: JsonExpression;
358
- returnType: ValueType;
359
- dateFormat?: string;
360
- }
361
- //#endregion
362
- //#region src/survey/utils/context.d.ts
363
- interface SurveyContext {
364
- participantFlags?: {
365
- [key: string]: string;
366
- };
367
- locale: string;
368
- customValues?: {
369
- [key: string]: ResponseValue;
370
- };
371
- customExpressions?: {
372
- [key: string]: (args?: Array<Expression | undefined>) => ResponseValue;
373
- };
374
- }
375
- //#endregion
376
- //#region src/expressions/expression-evaluator.d.ts
377
- interface ExpressionContext {
378
- surveyContext: SurveyContext;
379
- resolveComputedValue?: (slotId: string) => ResponseValue | undefined;
380
- resolveResponseValue?: (slotId: string) => ResponseValue | undefined;
381
- responses: {
382
- [key: string]: SurveyItemResponse;
383
- };
384
- }
385
- declare class ExpressionEvaluator {
386
- private context?;
387
- constructor(context?: ExpressionContext);
388
- eval(expression: Expression | undefined): ResponseValue | undefined;
389
- setContext(context: ExpressionContext): void;
390
- private evaluateConst;
391
- private resolveStoredValue;
392
- private evaluateResponseVariable;
393
- private evaluateFunction;
394
- private evaluateContextVariable;
395
- private evaluateDateFunction;
396
- private evaluateAnd;
397
- private evaluateOr;
398
- private evaluateNot;
399
- private evaluateListContains;
400
- private evaluateStrEq;
401
- private evaluateEq;
402
- private evaluateGt;
403
- private evaluateGte;
404
- private evaluateLt;
405
- private evaluateLte;
406
- private evaluateInRange;
407
- private evaluateSum;
408
- private evaluateMin;
409
- private evaluateMax;
410
- }
411
- //#endregion
412
- //#region src/expressions/item-expression-registry.d.ts
413
- type ItemExpressionParameterInput = "string" | "number" | "boolean" | "singleSelect" | "multiSelect";
414
- interface ItemExpressionParameterOption {
415
- value: string;
416
- label: string;
417
- description?: string;
418
- }
419
- interface ItemExpressionParameterDefinition<TItem extends SurveyItemCore = SurveyItemCore> {
420
- key: string;
421
- label: string;
422
- description?: string;
423
- input: ItemExpressionParameterInput;
424
- required?: boolean;
425
- defaultValue?: unknown;
426
- getOptions?: (item: TItem) => ItemExpressionParameterOption[];
427
- }
428
- interface ItemExpressionDefinition<TItem extends SurveyItemCore = SurveyItemCore> {
429
- id: string;
430
- label: string;
431
- description?: string;
432
- returnType: ValueType;
433
- parameters?: Array<ItemExpressionParameterDefinition<TItem>>;
434
- buildExpression: (item: TItem, params?: Record<string, unknown>) => Expression;
435
- }
436
- type AnyItemExpressionDefinition = ItemExpressionDefinition<any>;
437
- declare function getItemExpressionDefinition<TItem extends SurveyItemCore>(definitions: ReadonlyArray<ItemExpressionDefinition<TItem>> | undefined, expressionId: string): ItemExpressionDefinition<TItem> | undefined;
438
- declare function buildItemExpression<TItem extends SurveyItemCore>(item: TItem, definitions: ReadonlyArray<ItemExpressionDefinition<TItem>> | undefined, expressionId: string, params?: Record<string, unknown>): Expression;
439
- //#endregion
440
- //#region src/survey/utils/value-reference.d.ts
441
- declare enum ValueReferenceMethod {
442
- get = "get",
443
- isDefined = "isDefined"
444
- }
445
- interface JsonValueReference {
446
- slotId: string;
447
- method: "get" | "isDefined";
448
- }
449
- /** Slot identity is opaque. String keys are an internal JSON-tuple lookup codec. */
450
- declare class ValueReference {
451
- readonly slotId: string;
452
- readonly name: ValueReferenceMethod;
453
- constructor(reference: JsonValueReference | string);
454
- serialize(): JsonValueReference;
455
- toString(): string;
456
- static fromParts(slotId: string, method: ValueReferenceMethod): ValueReference;
457
- }
458
- declare enum ReferenceUsageType {
459
- displayConditions = "displayConditions",
460
- templateValues = "templateValues",
461
- validations = "validations",
462
- disabledConditions = "disabledConditions",
463
- prefills = "prefills"
464
- }
465
- interface ReferenceUsage {
466
- itemId: string;
467
- fullComponentKey?: string;
468
- usageType?: ReferenceUsageType;
469
- valueReference: ValueReference;
470
- }
471
- //#endregion
472
- //#region src/expressions/reference-integrity.d.ts
473
- interface SurveyExpressionLocation {
474
- expression: JsonExpression;
475
- location: string;
476
- ownerItemId?: string;
477
- ownerItemKey?: string;
478
- ownerScope: "component" | "item" | "survey";
479
- surface: "display-condition" | "disabled-condition" | "validation" | "prefill-condition" | "prefill-source" | "template-value";
480
- }
481
- interface SurveyExpressionResponseSlot {
482
- ref: string;
483
- itemId?: string;
484
- valueType: ValueType;
485
- allowedReferenceValues?: string[];
486
- allowedValues?: ResponseValue[];
487
- }
488
- type SurveyExpressionReferenceDiagnosticCode = "invalid-expression" | "unknown-response-ref" | "expression-reference-type-mismatch" | "unknown-reference-value" | "display-condition-cycle";
489
- type SurveyExpressionReferenceDiagnosticDisposition = "advisory" | "blocking";
490
- type SurveyExpressionReferenceDiagnosticCategory = "display-dependency" | "reference-integrity";
491
- interface SurveyExpressionReferenceDiagnosticPolicy {
492
- category: SurveyExpressionReferenceDiagnosticCategory;
493
- disposition: SurveyExpressionReferenceDiagnosticDisposition;
494
- }
495
- /**
496
- * Display-condition cycles prevent active-response evaluation, even with prefills.
497
- * This item-level analysis is complemented by ActiveResponsePlan's full runtime graph,
498
- * which also includes inherited visibility, component activation and computed dependencies.
499
- */
500
- declare const SURVEY_EXPRESSION_REFERENCE_DIAGNOSTIC_POLICY: {
501
- readonly "invalid-expression": {
502
- readonly category: "reference-integrity";
503
- readonly disposition: "blocking";
504
- };
505
- readonly "unknown-response-ref": {
506
- readonly category: "reference-integrity";
507
- readonly disposition: "blocking";
508
- };
509
- readonly "expression-reference-type-mismatch": {
510
- readonly category: "reference-integrity";
511
- readonly disposition: "blocking";
512
- };
513
- readonly "unknown-reference-value": {
514
- readonly category: "reference-integrity";
515
- readonly disposition: "blocking";
516
- };
517
- readonly "display-condition-cycle": {
518
- readonly category: "display-dependency";
519
- readonly disposition: "blocking";
520
- };
521
- };
522
- interface SurveyExpressionReferenceDiagnostic {
523
- category: SurveyExpressionReferenceDiagnosticCategory;
524
- code: SurveyExpressionReferenceDiagnosticCode;
525
- disposition: SurveyExpressionReferenceDiagnosticDisposition;
526
- message: string;
527
- location: string;
528
- ownerItemId?: string;
529
- ownerItemKey?: string;
530
- reference?: string;
531
- referenceValue?: string;
532
- candidates?: string[];
533
- }
534
- /** Discover references even when a sibling expression is malformed and cannot deserialize. */
535
- declare function collectExpressionResponseReferences(expression: unknown): ValueReference[];
536
- /** Shared by integrity diagnostics and deletion guards for config-owned bounds. */
537
- declare const collectConfigValueExpressions: (config: unknown) => {
538
- expression: JsonExpression;
539
- location: string;
540
- }[];
541
- declare const collectSurveyExpressionLocations: (survey: RawSurvey) => SurveyExpressionLocation[];
542
- declare const analyzeSurveyExpressionReferences: ({ responseSlots, survey }: {
543
- responseSlots: SurveyExpressionResponseSlot[];
544
- survey: RawSurvey;
545
- }) => SurveyExpressionReferenceDiagnostic[];
546
- declare const expressionReferenceDiagnosticKey: (diagnostic: SurveyExpressionReferenceDiagnostic) => string;
547
- declare const findIntroducedExpressionReferenceDiagnosticsIncludingAdvisories: ({ after, before }: {
548
- after: SurveyExpressionReferenceDiagnostic[];
549
- before: SurveyExpressionReferenceDiagnostic[];
550
- }) => SurveyExpressionReferenceDiagnostic[];
551
- declare const isBlockingSurveyExpressionReferenceDiagnostic: (diagnostic: Pick<SurveyExpressionReferenceDiagnostic, "disposition">) => boolean;
552
- declare const findIntroducedBlockingExpressionReferenceDiagnostics: ({ after, before }: {
553
- after: SurveyExpressionReferenceDiagnostic[];
554
- before: SurveyExpressionReferenceDiagnostic[];
555
- }) => SurveyExpressionReferenceDiagnostic[];
556
- declare const replaceResponseVariableReferences: <T>(value: T, replacements: Readonly<Record<string, string>>, optionReplacements?: Readonly<Record<string, string>>) => {
557
- changed: boolean;
558
- value: T;
559
- };
560
- declare const responseValueReferenceIds: (values: ResponseValue[] | undefined) => string[] | undefined;
561
- //#endregion
562
- //#region src/expressions/editors/expression-editor.d.ts
563
- declare abstract class ExpressionEditor {
564
- returnType: ValueType;
565
- protected _editorConfig?: ExpressionEditorConfig;
566
- abstract getExpression(): Expression | undefined;
567
- get editorConfig(): ExpressionEditorConfig | undefined;
568
- withEditorConfig(editorConfig: ExpressionEditorConfig): ExpressionEditor;
569
- }
570
- declare class ConstStringArrayEditor extends ExpressionEditor {
571
- readonly returnType: "string[]";
572
- private _values;
573
- constructor(values: string[], editorConfig?: ExpressionEditorConfig);
574
- get values(): string[];
575
- set values(values: string[]);
576
- getExpression(): Expression | undefined;
577
- }
578
- declare class ConstStringEditor extends ExpressionEditor {
579
- readonly returnType: "string";
580
- private _value;
581
- constructor(value: string, editorConfig?: ExpressionEditorConfig);
582
- get value(): string;
583
- set value(value: string);
584
- getExpression(): Expression | undefined;
585
- }
586
- declare class ConstNumberEditor extends ExpressionEditor {
587
- readonly returnType: "number";
588
- private _value;
589
- constructor(value: number, editorConfig?: ExpressionEditorConfig);
590
- get value(): number;
591
- set value(value: number);
592
- getExpression(): Expression | undefined;
593
- }
594
- declare class ConstBooleanEditor extends ExpressionEditor {
595
- readonly returnType: "boolean";
596
- private _value;
597
- constructor(value: boolean, editorConfig?: ExpressionEditorConfig);
598
- get value(): boolean;
599
- set value(value: boolean);
600
- getExpression(): Expression | undefined;
601
- }
602
- declare class ConstDateEditor extends ExpressionEditor {
603
- readonly returnType: "date";
604
- private _value;
605
- constructor(value: CalendarDate, editorConfig?: ExpressionEditorConfig);
606
- get value(): CalendarDate;
607
- set value(value: CalendarDate);
608
- getExpression(): Expression | undefined;
609
- }
610
- declare class ConstNumberArrayEditor extends ExpressionEditor {
611
- readonly returnType: "number[]";
612
- private _values;
613
- constructor(values: number[], editorConfig?: ExpressionEditorConfig);
614
- get values(): number[];
615
- set values(values: number[]);
616
- getExpression(): Expression | undefined;
617
- }
618
- declare class ConstDateArrayEditor extends ExpressionEditor {
619
- readonly returnType: "date[]";
620
- private _values;
621
- constructor(values: CalendarDate[], editorConfig?: ExpressionEditorConfig);
622
- get values(): CalendarDate[];
623
- set values(values: CalendarDate[]);
624
- getExpression(): Expression | undefined;
625
- }
626
- declare class ResponseVariableEditor extends ExpressionEditor {
627
- private _variableName;
628
- private _variableRef;
629
- constructor(variableName: string | JsonValueReference, variableType: ValueType, editorConfig?: ExpressionEditorConfig);
630
- get variableName(): string;
631
- get variableRef(): ValueReference;
632
- getExpression(): Expression | undefined;
633
- }
634
- declare abstract class ContextVariableEditor extends ExpressionEditor {
635
- private _contextType;
636
- private _key?;
637
- private _args?;
638
- private _asType?;
639
- constructor(contextType: ContextVariableType, key?: ExpressionEditor, args?: ExpressionEditor[], asType?: ValueType, editorConfig?: ExpressionEditorConfig);
640
- getExpression(): Expression | undefined;
641
- }
642
- declare class CtxLocaleEditor extends ContextVariableEditor {
643
- readonly returnType: "string";
644
- constructor(editorConfig?: ExpressionEditorConfig);
645
- }
646
- declare class CtxPFlagIsDefinedEditor extends ContextVariableEditor {
647
- readonly returnType: "boolean";
648
- constructor(key: ExpressionEditor, editorConfig?: ExpressionEditorConfig);
649
- }
650
- declare class CtxPFlagStringEditor extends ContextVariableEditor {
651
- readonly returnType: "string";
652
- constructor(key: ExpressionEditor, editorConfig?: ExpressionEditorConfig);
653
- }
654
- declare class CtxPFlagNumEditor extends ContextVariableEditor {
655
- readonly returnType: "number";
656
- constructor(key: ExpressionEditor, editorConfig?: ExpressionEditorConfig);
657
- }
658
- declare class CtxPFlagDateEditor extends ContextVariableEditor {
659
- readonly returnType: "date";
660
- constructor(key: ExpressionEditor, editorConfig?: ExpressionEditorConfig);
661
- }
662
- declare class CtxCustomValueEditor extends ContextVariableEditor {
663
- constructor(key: ExpressionEditor, asType: ValueType, editorConfig?: ExpressionEditorConfig);
664
- }
665
- declare class CtxCustomExpressionEditor extends ContextVariableEditor {
666
- constructor(key: ExpressionEditor, args: ExpressionEditor[], asType: ValueType, editorConfig?: ExpressionEditorConfig);
667
- }
668
- declare abstract class GroupExpressionEditor extends ExpressionEditor {
669
- private _args;
670
- constructor(args: ExpressionEditor[], editorConfig?: ExpressionEditorConfig);
671
- get args(): ExpressionEditor[];
672
- addArg(arg: ExpressionEditor, position?: number): void;
673
- removeArg(position: number): void;
674
- replaceArg(position: number, arg: ExpressionEditor): void;
675
- swapArgs(activeIndex: number, overIndex: number): void;
676
- }
677
- declare class AndExpressionEditor extends GroupExpressionEditor {
678
- readonly returnType: "boolean";
679
- constructor(args: ExpressionEditor[], editorConfig?: ExpressionEditorConfig);
680
- getExpression(): Expression | undefined;
681
- }
682
- declare class OrExpressionEditor extends GroupExpressionEditor {
683
- readonly returnType: "boolean";
684
- constructor(args: ExpressionEditor[], editorConfig?: ExpressionEditorConfig);
685
- getExpression(): Expression;
686
- }
687
- declare class StrListContainsExpressionEditor extends ExpressionEditor {
688
- readonly returnType: "boolean";
689
- private _list;
690
- private _item;
691
- constructor(list: ExpressionEditor, item: ExpressionEditor, editorConfig?: ExpressionEditorConfig);
692
- get list(): ExpressionEditor | undefined;
693
- get item(): ExpressionEditor | undefined;
694
- set list(list: ExpressionEditor | undefined);
695
- set item(item: ExpressionEditor | undefined);
696
- getExpression(): Expression;
697
- }
698
- declare class StrEqExpressionEditor extends ExpressionEditor {
699
- readonly returnType: "boolean";
700
- private _a;
701
- private _b;
702
- constructor(a: ExpressionEditor, b: ExpressionEditor, editorConfig?: ExpressionEditorConfig);
703
- get a(): ExpressionEditor | undefined;
704
- get b(): ExpressionEditor | undefined;
705
- set a(a: ExpressionEditor | undefined);
706
- set b(b: ExpressionEditor | undefined);
707
- getExpression(): Expression;
708
- }
709
- declare class EqExpressionEditor extends ExpressionEditor {
710
- readonly returnType: "boolean";
711
- private _a;
712
- private _b;
713
- constructor(a: ExpressionEditor, b: ExpressionEditor, editorConfig?: ExpressionEditorConfig);
714
- get a(): ExpressionEditor | undefined;
715
- get b(): ExpressionEditor | undefined;
716
- set a(a: ExpressionEditor | undefined);
717
- set b(b: ExpressionEditor | undefined);
718
- getExpression(): Expression;
719
- }
720
- declare class GtExpressionEditor extends ExpressionEditor {
721
- readonly returnType: "boolean";
722
- private _a;
723
- private _b;
724
- constructor(a: ExpressionEditor, b: ExpressionEditor, editorConfig?: ExpressionEditorConfig);
725
- get a(): ExpressionEditor | undefined;
726
- get b(): ExpressionEditor | undefined;
727
- set a(a: ExpressionEditor | undefined);
728
- set b(b: ExpressionEditor | undefined);
729
- getExpression(): Expression;
730
- }
731
- declare class GteExpressionEditor extends ExpressionEditor {
732
- readonly returnType: "boolean";
733
- private _a;
734
- private _b;
735
- constructor(a: ExpressionEditor, b: ExpressionEditor, editorConfig?: ExpressionEditorConfig);
736
- get a(): ExpressionEditor | undefined;
737
- get b(): ExpressionEditor | undefined;
738
- set a(a: ExpressionEditor | undefined);
739
- set b(b: ExpressionEditor | undefined);
740
- getExpression(): Expression;
741
- }
742
- declare class LtExpressionEditor extends ExpressionEditor {
743
- readonly returnType: "boolean";
744
- private _a;
745
- private _b;
746
- constructor(a: ExpressionEditor, b: ExpressionEditor, editorConfig?: ExpressionEditorConfig);
747
- get a(): ExpressionEditor | undefined;
748
- get b(): ExpressionEditor | undefined;
749
- set a(a: ExpressionEditor | undefined);
750
- set b(b: ExpressionEditor | undefined);
751
- getExpression(): Expression;
752
- }
753
- declare class LteExpressionEditor extends ExpressionEditor {
754
- readonly returnType: "boolean";
755
- private _a;
756
- private _b;
757
- constructor(a: ExpressionEditor, b: ExpressionEditor, editorConfig?: ExpressionEditorConfig);
758
- get a(): ExpressionEditor | undefined;
759
- get b(): ExpressionEditor | undefined;
760
- set b(b: ExpressionEditor | undefined);
761
- set a(a: ExpressionEditor | undefined);
762
- getExpression(): Expression;
763
- }
764
- declare class InRangeExpressionEditor extends ExpressionEditor {
765
- readonly returnType: "boolean";
766
- value: ExpressionEditor | undefined;
767
- min: ExpressionEditor | undefined;
768
- max: ExpressionEditor | undefined;
769
- inclusive: ExpressionEditor | undefined;
770
- constructor(value: ExpressionEditor, min: ExpressionEditor, max: ExpressionEditor, inclusive: ExpressionEditor, editorConfig?: ExpressionEditorConfig);
771
- getExpression(): Expression;
772
- }
773
- declare class SumExpressionEditor extends GroupExpressionEditor {
774
- readonly returnType: "number";
775
- constructor(args: ExpressionEditor[], editorConfig?: ExpressionEditorConfig);
776
- getExpression(): Expression;
777
- }
778
- declare class MinExpressionEditor extends GroupExpressionEditor {
779
- readonly returnType: "number";
780
- constructor(args: ExpressionEditor[], editorConfig?: ExpressionEditorConfig);
781
- getExpression(): Expression;
782
- }
783
- declare class MaxExpressionEditor extends GroupExpressionEditor {
784
- readonly returnType: "number";
785
- constructor(args: ExpressionEditor[], editorConfig?: ExpressionEditorConfig);
786
- getExpression(): Expression;
787
- }
788
- //#endregion
789
- //#region src/expressions/editors/expression-editor-generators.d.ts
790
- declare const const_string_array: (...values: string[]) => ExpressionEditor;
791
- declare const const_string: (value: string) => ExpressionEditor;
792
- declare const const_number_array: (...values: number[]) => ExpressionEditor;
793
- declare const const_number: (value: number) => ExpressionEditor;
794
- declare const const_boolean: (value: boolean) => ExpressionEditor;
795
- declare const const_date: (value: string) => ExpressionEditor;
796
- declare const const_date_array: (...values: string[]) => ExpressionEditor;
797
- declare const response_string: (valueRef: string | JsonValueReference) => ExpressionEditor;
798
- declare const response_string_array: (valueRef: string | JsonValueReference) => ExpressionEditor;
799
- declare const response_number: (valueRef: string | JsonValueReference) => ExpressionEditor;
800
- declare const response_boolean: (valueRef: string | JsonValueReference) => ExpressionEditor;
801
- declare const response_date: (valueRef: string | JsonValueReference) => ExpressionEditor;
802
- declare const response_number_array: (valueRef: string | JsonValueReference) => ExpressionEditor;
803
- declare const response_date_array: (valueRef: string | JsonValueReference) => ExpressionEditor;
804
- declare const ctx_locale: () => ExpressionEditor;
805
- declare const ctx_pflag_is_defined: (key: ExpressionEditor) => ExpressionEditor;
806
- declare const ctx_pflag_string: (key: ExpressionEditor) => ExpressionEditor;
807
- declare const ctx_pflag_num: (key: ExpressionEditor) => ExpressionEditor;
808
- declare const ctx_pflag_date: (key: ExpressionEditor) => ExpressionEditor;
809
- declare const ctx_custom_value: (key: ExpressionEditor, dType: ValueType) => ExpressionEditor;
810
- declare const ctx_custom_expression: (key: ExpressionEditor, args: ExpressionEditor[], returnType: ValueType) => ExpressionEditor;
811
- declare const and: (...args: ExpressionEditor[]) => ExpressionEditor;
812
- declare const or: (...args: ExpressionEditor[]) => ExpressionEditor;
813
- declare const str_list_contains: (list: ExpressionEditor, item: ExpressionEditor) => ExpressionEditor;
814
- declare const str_eq: (a: ExpressionEditor, b: ExpressionEditor) => ExpressionEditor;
815
- declare const eq: (a: ExpressionEditor, b: ExpressionEditor) => ExpressionEditor;
816
- declare const gt: (a: ExpressionEditor, b: ExpressionEditor) => ExpressionEditor;
817
- declare const gte: (a: ExpressionEditor, b: ExpressionEditor) => ExpressionEditor;
818
- declare const lt: (a: ExpressionEditor, b: ExpressionEditor) => ExpressionEditor;
819
- declare const lte: (a: ExpressionEditor, b: ExpressionEditor) => ExpressionEditor;
820
- declare const in_range: (value: ExpressionEditor, min: ExpressionEditor, max: ExpressionEditor, inclusive: ExpressionEditor) => ExpressionEditor;
821
- declare const sum: (...args: ExpressionEditor[]) => ExpressionEditor;
822
- declare const min: (...args: ExpressionEditor[]) => ExpressionEditor;
823
- declare const max: (...args: ExpressionEditor[]) => ExpressionEditor;
824
- declare const date_eq: (a: ExpressionEditor, b: ExpressionEditor) => ExpressionEditor;
825
- declare const date_gt: (a: ExpressionEditor, b: ExpressionEditor) => ExpressionEditor;
826
- declare const date_gte: (a: ExpressionEditor, b: ExpressionEditor) => ExpressionEditor;
827
- declare const date_lt: (a: ExpressionEditor, b: ExpressionEditor) => ExpressionEditor;
828
- declare const date_lte: (a: ExpressionEditor, b: ExpressionEditor) => ExpressionEditor;
829
- declare const date_add_days: (a: ExpressionEditor, b: ExpressionEditor) => ExpressionEditor;
830
- declare const date_add_months: (a: ExpressionEditor, b: ExpressionEditor) => ExpressionEditor;
831
- declare const date_add_years: (a: ExpressionEditor, b: ExpressionEditor) => ExpressionEditor;
832
- declare const date_diff: (a: ExpressionEditor, b: ExpressionEditor) => ExpressionEditor;
833
- declare const date_min: (...args: ExpressionEditor[]) => ExpressionEditor;
834
- declare const date_max: (...args: ExpressionEditor[]) => ExpressionEditor;
835
- //#endregion
836
- //#region src/expressions/date-functions.d.ts
837
- /** Shared signatures used by authoring, reference diagnostics and assistant validation. */
838
- declare const DATE_FUNCTION_SIGNATURES: Record<string, {
839
- args: ValueType[];
840
- variadic?: boolean;
841
- returns: ValueType;
842
- }>;
843
- //#endregion
844
- //#region src/survey/items/utils.d.ts
845
- interface DisplayConditions {
846
- root?: Expression;
847
- components?: {
848
- [componentKey: string]: Expression | undefined;
849
- };
850
- }
851
- interface DisabledConditions {
852
- components?: {
853
- [componentKey: string]: Expression | undefined;
854
- };
855
- }
856
- //#endregion
857
- //#region src/survey/items/prefill.d.ts
858
- declare const SurveyItemPrefillApplyMode: {
859
- readonly ifEmpty: "ifEmpty";
860
- };
861
- type SurveyItemPrefillApplyMode = (typeof SurveyItemPrefillApplyMode)[keyof typeof SurveyItemPrefillApplyMode];
862
- declare const SurveyItemPrefillTargetType: {
863
- readonly itemResponse: "itemResponse";
864
- readonly field: "field";
865
- readonly embeddedField: "embeddedField";
866
- };
867
- type SurveyItemPrefillTargetType = (typeof SurveyItemPrefillTargetType)[keyof typeof SurveyItemPrefillTargetType];
868
- type JsonSurveyItemPrefillTarget = {
869
- type: typeof SurveyItemPrefillTargetType.itemResponse;
870
- } | {
871
- type: typeof SurveyItemPrefillTargetType.field;
872
- fieldId: string;
873
- } | {
874
- type: typeof SurveyItemPrefillTargetType.embeddedField;
875
- optionId: string;
876
- fieldId: string;
877
- };
878
- type SurveyItemPrefillTarget = JsonSurveyItemPrefillTarget;
879
- interface SurveyItemPreviousResponseRef {
880
- surveyKey?: string;
881
- slotId: string;
882
- }
883
- type JsonSurveyItemPrefillSource = {
884
- type: "static";
885
- value: ResponseValue;
886
- } | {
887
- type: "expression";
888
- expression: JsonExpression;
889
- } | {
890
- type: "templateValue";
891
- key: string;
892
- } | {
893
- type: "previousResponse";
894
- ref: SurveyItemPreviousResponseRef;
895
- ifUnsupported?: "skip";
896
- };
897
- type SurveyItemPrefillSource = {
898
- type: "static";
899
- value: ResponseValue;
900
- } | {
901
- type: "expression";
902
- expression: Expression;
903
- } | {
904
- type: "templateValue";
905
- key: string;
906
- } | {
907
- type: "previousResponse";
908
- ref: SurveyItemPreviousResponseRef;
909
- ifUnsupported?: "skip";
910
- };
911
- interface JsonSurveyItemPrefill {
912
- id: string;
913
- target: JsonSurveyItemPrefillTarget;
914
- when?: JsonExpression;
915
- apply?: SurveyItemPrefillApplyMode;
916
- source: JsonSurveyItemPrefillSource;
917
- }
918
- interface SurveyItemPrefill {
919
- id: string;
920
- target: SurveyItemPrefillTarget;
921
- when?: Expression;
922
- apply?: SurveyItemPrefillApplyMode;
923
- source: SurveyItemPrefillSource;
924
- }
925
- declare function deserializeSurveyItemPrefill(json: JsonSurveyItemPrefill): SurveyItemPrefill;
926
- declare function serializeSurveyItemPrefill(prefill: SurveyItemPrefill): JsonSurveyItemPrefill;
927
- declare function prefillTargetsEqual(left: SurveyItemPrefillTarget, right: SurveyItemPrefillTarget): boolean;
928
- //#endregion
929
- //#region src/survey/items/survey-item.d.ts
930
- /**
931
- * Core contract for survey item handlers.
932
- * Every item type (built-in and plugin) is represented by a handler class implementing this interface.
933
- * The core uses these methods without any casting.
934
- */
935
- interface SurveyItemCoreType<TConfig = unknown> {
936
- readonly type: string;
937
- readonly id: string;
938
- readonly config: TConfig;
939
- isInteractive(): boolean;
940
- getResponseSlotDefinitions(): ResponseSlotDefinition[];
941
- getAvailableResponseValueSlots(byType?: ValueType): ValueRefTypeLookup;
942
- }
943
- interface ResponseNormalizationDiagnostic {
944
- code: string;
945
- message: string;
946
- slotId?: string;
947
- }
948
- interface NormalizedItemResponse {
949
- response?: ResponseItem;
950
- diagnostics?: ResponseNormalizationDiagnostic[];
951
- }
952
- /**
953
- * Base class for survey item handlers.
954
- * Each handler holds type, id, key, and config (properly typed) and implements core methods.
955
- * Subclass for each item type; the core works with SurveyItemHandler only—no casting needed.
956
- */
957
- declare abstract class SurveyItemCore<TType extends string = string, TConfig = unknown> implements SurveyItemCoreType<TConfig> {
958
- abstract readonly type: TType;
959
- readonly id: string;
960
- config: TConfig;
961
- private _rawItem;
962
- displayConditions?: DisplayConditions;
963
- disabledConditions?: DisabledConditions;
964
- validations?: {
965
- [validationKey: string]: Expression | undefined;
966
- };
967
- prefills?: SurveyItemPrefill[];
968
- constructor(rawItem: RawSurveyItem);
969
- /** Primitive authors can identify meaningful headings without exposing option/decorative text. */
970
- getOutlineContentKeys(): readonly string[];
971
- getCompositionTypes(): readonly string[];
972
- /** Parse raw config from JSON into typed config. Override in subclasses. */
973
- abstract parseConfig(rawConfig: unknown): TConfig;
974
- abstract isInteractive(): boolean;
975
- abstract getResponseSlotDefinitions(): ResponseSlotDefinition[];
976
- /**
977
- * Validate/canonicalize updates, initial responses, and configured prefills before evaluation.
978
- * Prefills are applied one slot at a time, so multi-slot items must allow partial responses.
979
- */
980
- normalizeResponse(response: ResponseItem | undefined): NormalizedItemResponse;
981
- /** Opt-in component ownership for copy/paste. Existing item formats remain unchanged. */
982
- getOwnedComponentIds(): string[];
983
- /** Slots omitted from submissions when their component condition is false; session answers are retained. */
984
- getConditionalResponseSlots(): Array<{
985
- slotId: string;
986
- componentId: string;
987
- }>;
988
- /** Dependencies used when projecting a stored answer (for example visible choice options). */
989
- getActiveResponseDependencies(_slotId: string): {
990
- slotIds: string[];
991
- componentIds: string[];
992
- };
993
- /** Project retained data without mutating it. Dependencies must be declared above. */
994
- getActiveResponseValue(_slotId: string, value: ResponseValue | undefined, _isVisible: (componentId: string) => boolean, _getAnswer: (slotId: string) => ResponseValue | undefined): ResponseValue | undefined;
995
- /** Source slots used by a computed reference, for component visibility cycle diagnostics. */
996
- getComputedResponseDependencies(slotId: string): string[];
997
- /** Computed references are read-only, evaluated on demand, never persisted/exported as answers. */
998
- getComputedResponseValue(_slotId: string, _response: ResponseItem | undefined, _isVisible: (componentId: string) => boolean): ResponseValue | undefined;
999
- getResponseValidationValues(_response: ResponseItem | undefined, _isVisible: (componentId: string) => boolean, _evaluate?: (expression: JsonExpression) => ResponseValue | undefined): Record<string, boolean>;
1000
- /** Runtime-only checks; authoring may retain incomplete drafts. */
1001
- getExecutionConfigurationIssues(): string[];
1002
- getAvailableResponseValueSlots(byType?: ValueType): ValueRefTypeLookup;
1003
- get rawItem(): RawSurveyItem;
1004
- get metadata(): {
1005
- [key: string]: string;
1006
- };
1007
- set metadata(metadata: {
1008
- [key: string]: string;
1009
- });
1010
- get editorMetadata(): NonNullable<RawSurveyItem["editorMetadata"]>;
1011
- setCreatedAt(timestamp: string): void;
1012
- setModifiedAt(timestamp: string): void;
1013
- updateRawItem(rawItem: RawSurveyItem): void;
1014
- private updateExpressions;
1015
- getReferenceUsages(): ReferenceUsage[];
1016
- resolvePrefillTarget(target: SurveyItemPrefillTarget): ResponseSlotDefinition | undefined;
1017
- normalizePrefillValue(_prefill: SurveyItemPrefill, targetSlot: ResponseSlotDefinition, value: ResponseValue): ResponseValue | undefined;
1018
- }
1019
- /**
1020
- * Constructor type for handler classes. Used by the registry to instantiate handlers.
1021
- */
1022
- type ItemCoreConstructor<TType extends string = string, TConfig = unknown> = new (rawItem: RawSurveyItem) => SurveyItemCore<TType, TConfig>;
1023
- //#endregion
1024
- //#region src/survey/items/survey-item-json.d.ts
1025
- interface RawSurveyItem {
1026
- id: string;
1027
- itemType: string;
1028
- editorMetadata?: {
1029
- createdAt?: string;
1030
- updatedAt?: string;
1031
- };
1032
- metadata?: {
1033
- [key: string]: string;
1034
- };
1035
- config?: unknown;
1036
- responseSettings?: Record<string, SlotTransformConfig>;
1037
- validations?: {
1038
- [validationKey: string]: JsonExpression | undefined;
1039
- };
1040
- displayConditions?: {
1041
- root?: JsonExpression;
1042
- components?: {
1043
- [componentId: string]: JsonExpression | undefined;
1044
- };
1045
- };
1046
- disabledConditions?: {
1047
- components?: {
1048
- [componentId: string]: JsonExpression | undefined;
1049
- };
1050
- };
1051
- prefills?: JsonSurveyItemPrefill[];
1052
- }
1053
- //#endregion
1054
- //#region src/survey/items/types.d.ts
1055
- declare enum ReservedSurveyItemTypes {
1056
- Group = "group",
1057
- PageBreak = "page-break"
1058
- }
1059
- //#endregion
1060
- //#region src/survey/utils/content.d.ts
1061
- declare enum ContentType {
1062
- richText = "richText",
1063
- plain = "plain",
1064
- md = "md"
1065
- }
1066
- type ContentAttributes = Record<string, unknown>;
1067
- type TextAlignment = "left" | "center" | "right" | "justify";
1068
- type RichTextStyle = {
1069
- weight?: "strong" | "normal";
1070
- italic?: "italic" | "normal";
1071
- underline?: "underline" | "none";
1072
- color?: "primary" | "accent" | "default";
1073
- };
1074
- type RichTextTextInline = {
1075
- type: "text";
1076
- text: string;
1077
- style?: RichTextStyle;
1078
- attrs?: ContentAttributes;
1079
- };
1080
- type RichTextTemplateInline = {
1081
- type: "template";
1082
- key: string;
1083
- style?: RichTextStyle;
1084
- attrs?: ContentAttributes;
1085
- };
1086
- type RichTextLineBreakInline = {
1087
- type: "lineBreak";
1088
- attrs?: ContentAttributes;
1089
- };
1090
- /** Inline nodes allowed inside a {@link RichTextLinkInline} (no nested links). */
1091
- type RichTextLinkChildInline = RichTextTextInline | RichTextTemplateInline | RichTextLineBreakInline;
1092
- type RichTextLinkInline = {
1093
- type: "link";
1094
- href: string;
1095
- target?: string | null;
1096
- rel?: string | null;
1097
- title?: string | null;
1098
- attrs?: ContentAttributes;
1099
- children: RichTextLinkChildInline[];
1100
- };
1101
- type RichTextInlineExtension = {
1102
- type: "inlineExtension";
1103
- name: string;
1104
- attrs?: ContentAttributes;
1105
- };
1106
- type RichTextInlineNode = RichTextTextInline | RichTextTemplateInline | RichTextLinkInline | RichTextLineBreakInline | RichTextInlineExtension;
1107
- type RichTextParagraphBlock = {
1108
- type: "paragraph";
1109
- children: RichTextInlineNode[];
1110
- alignment?: TextAlignment;
1111
- attrs?: ContentAttributes;
1112
- };
1113
- type RichTextHeadingBlock = {
1114
- type: "heading";
1115
- level: 1 | 2 | 3 | 4 | 5 | 6;
1116
- children: RichTextInlineNode[];
1117
- alignment?: TextAlignment;
1118
- attrs?: ContentAttributes;
1119
- };
1120
- type RichTextListItemBlock = {
1121
- type: "listItem";
1122
- children: RichTextParagraphBlock[];
1123
- attrs?: ContentAttributes;
1124
- };
1125
- type RichTextBulletListBlock = {
1126
- type: "bulletList";
1127
- items: RichTextListItemBlock[];
1128
- attrs?: ContentAttributes;
1129
- };
1130
- type SurveyContentImageSource = {
1131
- type: "external";
1132
- url: string;
1133
- } | {
1134
- type: "asset";
1135
- assetId: string;
1136
- };
1137
- type RichTextImageDimension = {
1138
- unit: "px";
1139
- value: number;
1140
- } | {
1141
- unit: "%";
1142
- value: number;
1143
- };
1144
- type RichTextImageSize = {
1145
- width?: RichTextImageDimension;
1146
- height?: RichTextImageDimension;
1147
- maxWidth?: RichTextImageDimension;
1148
- maxHeight?: RichTextImageDimension;
1149
- };
1150
- type RichTextImageBlock = {
1151
- type: "image";
1152
- source: SurveyContentImageSource;
1153
- alt?: string;
1154
- caption?: RichTextParagraphBlock[];
1155
- size?: RichTextImageSize;
1156
- alignment?: TextAlignment;
1157
- attrs?: ContentAttributes;
1158
- };
1159
- type RichTextInfoBoxBlock = {
1160
- type: "infoBox";
1161
- tone?: "info" | "warning";
1162
- title?: RichTextInlineNode[];
1163
- collapsible?: boolean;
1164
- defaultOpen?: boolean;
1165
- children: RichTextParagraphBlock[];
1166
- attrs?: ContentAttributes;
1167
- };
1168
- type RichTextSeparatorBlock = {
1169
- type: "separator";
1170
- attrs?: ContentAttributes;
1171
- };
1172
- type RichTextBlockExtension = {
1173
- type: "blockExtension";
1174
- name: string;
1175
- attrs?: ContentAttributes;
1176
- };
1177
- type RichTextBlockNode = RichTextParagraphBlock | RichTextHeadingBlock | RichTextBulletListBlock | RichTextImageBlock | RichTextInfoBoxBlock | RichTextSeparatorBlock | RichTextBlockExtension;
1178
- type RichTextDocument = {
1179
- type: "doc";
1180
- blocks: RichTextBlockNode[];
1181
- };
1182
- type RichTextContent = {
1183
- type: ContentType.richText;
1184
- version: 1;
1185
- doc: RichTextDocument;
1186
- };
1187
- type MDContent = {
1188
- type: ContentType.md;
1189
- content: string;
1190
- };
1191
- type PlainTextContent = {
1192
- type: ContentType.plain;
1193
- content: string;
1194
- };
1195
- type Content = RichTextContent | MDContent | PlainTextContent;
1196
- type RichTextInline = RichTextInlineNode;
1197
- interface ContentAssetUsage {
1198
- assetId: string;
1199
- blockIndex: number;
1200
- }
1201
- declare function hasRenderableRichTextBlock(block: RichTextBlockNode): boolean;
1202
- declare function hasRenderableRichTextContent(content: RichTextContent): boolean;
1203
- declare function createRichTextContent(text?: string): RichTextContent;
1204
- declare function getPlainTextFromRichTextContent(content: RichTextContent): string;
1205
- declare function getContentPlainText(content?: Content): string;
1206
- declare function isContentEmpty(content?: Content): boolean;
1207
- declare function getAssetUsagesFromContent(content?: Content): ContentAssetUsage[];
1208
- //#endregion
1209
- //#region src/survey/utils/translations.d.ts
1210
- declare const validateLocale: (locale: string) => void;
1211
- declare class SurveyItemTranslations {
1212
- private _translations?;
1213
- constructor();
1214
- setContent(locale: string, contentKey: string, content?: Content): void;
1215
- setAllForLocale(locale: string, content?: JsonComponentContent): void;
1216
- get locales(): string[];
1217
- getAllForLocale(locale: string): JsonComponentContent | undefined;
1218
- getContent(locale: string, contentKey: string, fallbackLocale?: string): Content | undefined;
1219
- /**
1220
- * Create a deep clone that can be safely mutated before persisting with
1221
- * `setItemTranslations` or `updateItemTranslations`.
1222
- */
1223
- clone(): SurveyItemTranslations;
1224
- /**
1225
- * Remove a single content key from every locale in this translation set.
1226
- */
1227
- removeContentKey(contentKey: string): void;
1228
- /**
1229
- * Remove every content key that is exactly the prefix or nested beneath it.
1230
- */
1231
- removeContentKeysWithPrefix(prefix: string): void;
1232
- /**
1233
- * Remove empty locales in place.
1234
- * Returns `undefined` when no translations remain so callers can pass the
1235
- * result directly into `setItemTranslations` / `updateItemTranslations`.
1236
- */
1237
- compact(): SurveyItemTranslations | undefined;
1238
- }
1239
- interface SurveyCardTranslations {
1240
- [locale: string]: SurveyCardContent;
1241
- }
1242
- declare class SurveyTranslations {
1243
- private _translations;
1244
- constructor(translations?: JsonSurveyTranslations);
1245
- /** Cheap revision fork. Every writer replaces its path before changing it. */
1246
- fork(): SurveyTranslations;
1247
- serialize(): JsonSurveyTranslations | undefined;
1248
- get locales(): string[];
1249
- private replaceLocale;
1250
- private replaceItem;
1251
- addLocale(locale: string): boolean;
1252
- removeLocale(locale: string): void;
1253
- renameLocale(oldLocale: string, newLocale: string): void;
1254
- cloneLocaleAs(locale: string, newLocale: string): void;
1255
- get surveyCardContent(): SurveyCardTranslations | undefined;
1256
- get navigationContent(): {
1257
- [locale: string]: NavigationContent;
1258
- } | undefined;
1259
- get validationMessages(): {
1260
- [locale: string]: {
1261
- invalidResponse?: Content;
1262
- };
1263
- } | undefined;
1264
- setSurveyCardContent(locale: string, content?: SurveyCardContent): void;
1265
- setNavigationContent(locale: string, content?: NavigationContent): void;
1266
- setValidationMessages(locale: string, content?: {
1267
- invalidResponse?: Content;
1268
- }): void;
1269
- getItemTranslationContent(itemId: string, locale: string, contentKey: string, fallbackLocale?: string): Content | undefined;
1270
- setItemTranslationContent(itemId: string, locale: string, contentKey: string, content?: Content): boolean;
1271
- getItemTranslations(itemId: string): SurveyItemTranslations | undefined;
1272
- setItemTranslations(itemId: string, content?: SurveyItemTranslations): void;
1273
- onComponentKeyChanged(itemId: string, oldKey: string, newKey: string): void;
1274
- onComponentDeleted(itemId: string, componentKey: string): void;
1275
- onItemDeleted(itemId: string): void;
1276
- }
1277
- /**
1278
- * Json Schemas for translations
1279
- */
1280
- type JsonComponentContent = {
1281
- [contentKey: string]: Content;
1282
- };
1283
- interface SurveyCardContent {
1284
- name?: Content;
1285
- description?: Content;
1286
- typicalDuration?: Content;
1287
- }
1288
- interface NavigationContent {
1289
- previousButtonText?: Content;
1290
- nextButtonText?: Content;
1291
- submitButtonText?: Content;
1292
- pageIndicatorText?: Content;
1293
- submitBoxMessage?: Content;
1294
- }
1295
- interface JsonSurveyTranslations {
1296
- [locale: string]: {
1297
- surveyCardContent?: SurveyCardContent;
1298
- navigationContent?: NavigationContent;
1299
- validationMessages?: {
1300
- invalidResponse?: Content;
1301
- };
1302
- itemTranslations?: {
1303
- [itemId: string]: JsonComponentContent;
1304
- };
1305
- };
1306
- }
1307
- //#endregion
1308
- //#region src/survey/survey-file-schema.d.ts
1309
- declare const CURRENT_SURVEY_SCHEMA_VERSION = 2;
1310
- declare const CURRENT_SURVEY_SCHEMA = "https://github.com/case-framework/case-survey-toolkit/packages/survey-core/schemas/survey-schema.json";
1311
- interface SurveyVersion {
1312
- id?: string;
1313
- surveyKey: string;
1314
- published?: number;
1315
- unpublished?: number;
1316
- versionId?: string;
1317
- survey: RawSurvey;
1318
- }
1319
- type RawSurveyAsset = {
1320
- kind: "image";
1321
- source: {
1322
- type: "embedded";
1323
- mediaType: string;
1324
- encoding: "base64";
1325
- data: string;
1326
- };
1327
- metadata?: {
1328
- name?: string;
1329
- filename?: string;
1330
- alt?: string;
1331
- width?: number;
1332
- height?: number;
1333
- };
1334
- };
1335
- type RawSurvey = {
1336
- $schema: string;
1337
- schemaVersion: number;
1338
- maxItemsPerPage?: {
1339
- large: number;
1340
- small: number;
1341
- };
1342
- surveyItems: Array<RawSurveyItem>;
1343
- assets?: Record<string, RawSurveyAsset>;
1344
- metadata?: {
1345
- [key: string]: string;
1346
- };
1347
- templateValues?: {
1348
- [templateValueKey: string]: JsonTemplateValue;
1349
- };
1350
- translations?: JsonSurveyTranslations;
1351
- };
1352
- //#endregion
1353
- //#region src/survey/item-display-name.d.ts
1354
- interface ItemDisplayPath {
1355
- itemId: string;
1356
- name: string;
1357
- path: string[];
1358
- namePath: string[];
1359
- breadcrumb: string;
1360
- parentBreadcrumb: string;
1361
- }
1362
- declare function getCompositionLabel(types: readonly string[], locale: string): string;
1363
- //#endregion
1364
- //#region src/survey/responses/slot-registry.d.ts
1365
- interface OwnedResponseSlotDefinition extends ResponseSlotDefinition {
1366
- itemId: string;
1367
- primitiveId: string;
1368
- }
1369
- interface ResponseSlotDiagnostic {
1370
- code: "duplicate-slot-id" | "invalid-slot" | "invalid-domain" | "invalid-variable-name" | "duplicate-variable-name" | "unknown-dependency" | "computed-cycle" | "unknown-slot" | "invalid-answer";
1371
- slotId: string;
1372
- itemId?: string;
1373
- message: string;
1374
- }
1375
- /** A detached, derived index. Ambiguous identities never resolve to an arbitrary owner. */
1376
- declare class ResponseSlotRegistry {
1377
- private readonly slots;
1378
- readonly diagnostics: ResponseSlotDiagnostic[];
1379
- constructor(declarations: readonly {
1380
- itemId: string;
1381
- slots: readonly ResponseSlotDefinition[];
1382
- }[]);
1383
- get(slotId: string): OwnedResponseSlotDefinition | undefined;
1384
- get definitions(): OwnedResponseSlotDefinition[];
1385
- assertValid(): void;
1386
- validateAnswers(answers: Readonly<Record<string, unknown>>): ResponseSlotDiagnostic[];
1387
- }
1388
- //#endregion
1389
- //#region src/survey/registry/item-registry.d.ts
1390
- /**
1391
- * Registry maps item type name → handler constructor.
1392
- * Plugins extend this with their own handler classes.
1393
- */
1394
- type ItemTypeRegistry = Record<string, new (rawItem: RawSurveyItem) => SurveyItemCore>;
1395
- /** Item type identifier (e.g. "singleChoiceQuestion", "display"). */
1396
- type ItemTypeName = string;
1397
- /** Capabilities of an item type (interactive, supports children). */
1398
- interface ItemTypeCapabilities {
1399
- interactive?: boolean;
1400
- supportsChildren?: boolean;
1401
- }
1402
- /**
1403
- * Definition of an item type: its name, constructor, and optional capabilities.
1404
- * Used by editor/UI layers to compose registries.
1405
- */
1406
- interface ItemTypeDefinition {
1407
- itemType: ItemTypeName;
1408
- constructor: ItemCoreConstructor;
1409
- capabilities?: ItemTypeCapabilities;
1410
- expressions?: AnyItemExpressionDefinition[];
1411
- }
1412
- /** Registry mapping item type name → definition. */
1413
- type ItemTypeDefinitionRegistry = Record<ItemTypeName, ItemTypeDefinition>;
1414
- /** Convert constructor registry to explicit definitions for higher-layer composition. */
1415
- declare function toItemTypeDefinitionRegistry(registry: ItemTypeRegistry): ItemTypeDefinitionRegistry;
1416
- /**
1417
- * Creates a handler instance for a raw survey item.
1418
- * Uses built-in registry for group/page-break, otherwise the provided plugin registry.
1419
- */
1420
- declare function createItemCore(rawItem: RawSurveyItem, pluginRegistry?: ItemTypeRegistry): SurveyItemCore;
1421
- /**
1422
- * Merge built-in handlers with plugin registry for a complete registry.
1423
- */
1424
- declare function createFullRegistry(pluginRegistry?: ItemTypeRegistry): ItemTypeRegistry;
1425
- /** Build full registry as explicit definitions for editor/ui composition. */
1426
- declare function createItemTypeDefinitionRegistry(pluginRegistry?: ItemTypeRegistry): ItemTypeDefinitionRegistry;
1427
- //#endregion
1428
- //#region src/survey/registry/built-in-items.d.ts
1429
- /**
1430
- * Group item core.
1431
- */
1432
- type GroupConfig = {
1433
- items?: string[];
1434
- shuffleItems?: boolean;
1435
- isRoot?: boolean;
1436
- };
1437
- declare class GroupItemCore extends SurveyItemCore<typeof ReservedSurveyItemTypes.Group, GroupConfig> {
1438
- readonly type = ReservedSurveyItemTypes.Group;
1439
- parseConfig(rawConfig: unknown): GroupConfig;
1440
- serializeConfig(): unknown;
1441
- isInteractive(): boolean;
1442
- getResponseSlotDefinitions(): never[];
1443
- isRoot(): boolean;
1444
- get items(): string[];
1445
- /**
1446
- * Add a child item id to this group at the given index.
1447
- * @param itemId The id of the item to add to this group.
1448
- * @param index The index at which to add the item. If not provided, the item is added to the end of the group.
1449
- */
1450
- addChild(itemId: string, index?: number): void;
1451
- /**
1452
- * Remove a child item id from this group.
1453
- * @param itemId The id of the item to remove from this group.
1454
- */
1455
- removeChild(itemId: string): void;
1456
- /**
1457
- * Check if an item is a direct child of this group.
1458
- */
1459
- hasChild(itemId: string): boolean;
1460
- /** Whether items in this group should be shuffled. */
1461
- get shuffleItems(): boolean;
1462
- set shuffleItems(value: boolean);
1463
- /**
1464
- * Get the ordered list of child item ids.
1465
- */
1466
- getChildrenIds(): string[];
1467
- /**
1468
- * Swap two items by their positions in the group.
1469
- * @throws Error if indices are out of bounds
1470
- */
1471
- swapItemsByIndex(from: number, to: number): void;
1472
- /**
1473
- * Swap two items by their ids.
1474
- * @throws Error if either id is not found in this group
1475
- */
1476
- swapItemsById(id: string, withId: string): void;
1477
- /**
1478
- * Move an item by id to a specific index.
1479
- * @throws Error if the item is not found or index is out of bounds
1480
- */
1481
- moveItemToIndex(id: string, index: number): void;
1482
- }
1483
- /**
1484
- * Page break item core.
1485
- */
1486
- type PageBreakConfig = Record<string, never>;
1487
- declare class PageBreakItemCore extends SurveyItemCore<typeof ReservedSurveyItemTypes.PageBreak, PageBreakConfig> {
1488
- readonly type = ReservedSurveyItemTypes.PageBreak;
1489
- parseConfig(_rawConfig: unknown): PageBreakConfig;
1490
- serializeConfig(): unknown;
1491
- isInteractive(): boolean;
1492
- getResponseSlotDefinitions(): never[];
1493
- }
1494
- /**
1495
- * Built-in item type.
1496
- */
1497
- type BuiltInItemType = typeof ReservedSurveyItemTypes.Group | typeof ReservedSurveyItemTypes.PageBreak;
1498
- declare const builtInItemCoreRegistry: Record<BuiltInItemType, ItemCoreConstructor>;
1499
- declare const isBuiltInItemType: (itemType: string) => itemType is BuiltInItemType;
1500
- //#endregion
1501
- //#region src/survey/survey.d.ts
1502
- interface SurveyAssetUsage {
1503
- assetId: string;
1504
- itemId?: string;
1505
- locale?: string;
1506
- contentKey: string;
1507
- usageScope: "itemTranslation" | "surveyCard" | "navigation" | "validationMessages";
1508
- blockIndex: number;
1509
- }
1510
- declare class Survey {
1511
- private readonly pluginRegistry?;
1512
- maxItemsPerPage?: {
1513
- large: number;
1514
- small: number;
1515
- };
1516
- metadata?: {
1517
- [key: string]: string;
1518
- };
1519
- surveyItems: Map<string, SurveyItemCore>;
1520
- private _templateValues?;
1521
- private _assets?;
1522
- private _translations?;
1523
- constructor(pluginRegistry?: ItemTypeRegistry | undefined);
1524
- /**
1525
- * Derive a read revision from an already detached view. Editable core instances
1526
- * are never reused: the changed item is reconstructed from owned raw data.
1527
- * Other detached items are unchanged by translation publication.
1528
- */
1529
- withItemTranslationContent(rawItem: RawSurveyItem, locale: string, contentKey: string, content?: Content): Survey;
1530
- /** Plugin registry used when parsing items. Exposed for editors that re-parse without their own registry. */
1531
- getPluginRegistry(): ItemTypeRegistry | undefined;
1532
- /**
1533
- * Create a survey item from raw JSON data.
1534
- * Uses the survey's plugin registry when available.
1535
- */
1536
- createItemFromRaw(rawItem: RawSurveyItem): SurveyItemCore;
1537
- /**
1538
- * Create a minimal blank survey with a root group and one empty page.
1539
- */
1540
- static createBlankSurvey(pluginRegistry?: ItemTypeRegistry, surveyKey?: string): Survey;
1541
- static fromJson(json: RawSurvey, pluginRegistry?: ItemTypeRegistry): Survey;
1542
- serialize(): RawSurvey;
1543
- get surveyKey(): string | undefined;
1544
- resolveItemEditorName(itemId: string, locale?: string): string;
1545
- get locales(): string[];
1546
- get rootItem(): GroupItemCore | undefined;
1547
- get itemOutline(): ItemDisplayPath[];
1548
- getItemPath(itemId: string): string[];
1549
- getItemDisplayPath(itemId: string, locale?: string): ItemDisplayPath | undefined;
1550
- getParentItem(itemId: string): GroupItemCore | undefined;
1551
- getChildrenItems(parentId: string): SurveyItemCore[];
1552
- getSiblings(itemId: string): SurveyItemCore[];
1553
- get translations(): SurveyTranslations;
1554
- getItemTranslations(id: string): SurveyItemTranslations | undefined;
1555
- getTemplateValue(templateValueKey: string): TemplateValueDefinition | undefined;
1556
- setTemplateValue(templateValueKey: string, templateValue: TemplateValueDefinition): void;
1557
- deleteTemplateValue(templateValueKey: string): void;
1558
- getTemplateValueKeys(): string[];
1559
- getAsset(assetId: string): RawSurveyAsset | undefined;
1560
- setAsset(assetId: string, asset: RawSurveyAsset): void;
1561
- deleteAsset(assetId: string): void;
1562
- hasAsset(assetId: string): boolean;
1563
- getAssetIds(): string[];
1564
- getAssets(): Map<string, RawSurveyAsset>;
1565
- getAssetUsages(filterAssetId?: string): SurveyAssetUsage[];
1566
- getAvailableResponseValueSlots(byType?: ValueType): ValueRefTypeLookup;
1567
- getResponseSlotDefinitions(): Array<{
1568
- itemId: string;
1569
- slots: ResponseSlotDefinition[];
1570
- }>;
1571
- /** Compile a detached index from item declarations; diagnostics retain incomplete drafts. */
1572
- getResponseSlotRegistry(): ResponseSlotRegistry;
1573
- /** One typed declaration path for editor, runtime and export integrity checks. */
1574
- getExpressionResponseSlots(): SurveyExpressionResponseSlot[];
1575
- getExpressionReferenceDiagnostics(): SurveyExpressionReferenceDiagnostic[];
1576
- getBlockingExpressionIssues(): string[];
1577
- /**
1578
- * Get all reference usages for the survey
1579
- * @param forItemId - optional item id to filter usages for a specific item and its children (if not provided, all usages are returned)
1580
- * @returns all reference usages for the survey (or for a specific item and its children)
1581
- */
1582
- getReferenceUsages(forItemId?: string): ReferenceUsage[];
1583
- isDescendantOf(targetId: string, ancestorId: string): boolean;
1584
- }
1585
- //#endregion
1586
- //#region src/response-exporter/types.d.ts
1587
- /** Meta column keys in fixed order (common attributes first). */
1588
- declare const META_COLUMN_ORDER: readonly ["submittedAt", "participantId", "responseId", "sourceId"];
1589
- type MetaColumnKey = (typeof META_COLUMN_ORDER)[number];
1590
- /** Built-in transform modes for slot export. */
1591
- declare const SlotTransformMode: {
1592
- readonly default: "default";
1593
- readonly mask: "mask";
1594
- readonly dateFormat: "dateFormat";
1595
- };
1596
- type SlotTransformMode = (typeof SlotTransformMode)[keyof typeof SlotTransformMode];
1597
- /** Slot identifier for profile overrides. */
1598
- interface SlotRef {
1599
- slotId: string;
1600
- }
1601
- /** Configuration for dateFormat transform. Uses date-fns format pattern. */
1602
- interface DateFormatConfig {
1603
- pattern: string;
1604
- }
1605
- /** Slot-level override in exporter profile. */
1606
- interface SlotTransformConfig {
1607
- include?: boolean;
1608
- categorical?: "codes" | "labels" | "ids";
1609
- multiple?: "json" | "delimited" | "indicators";
1610
- delimiter?: string;
1611
- locale?: string;
1612
- optionCodes?: Record<string, string>;
1613
- optionLabels?: Record<string, string>;
1614
- booleanValues?: {
1615
- true: string;
1616
- false: string;
1617
- };
1618
- precision?: number;
1619
- durationUnit?: DurationUnit;
1620
- /** Built-in mode or custom formatter key. */
1621
- mode: SlotTransformMode | string;
1622
- /** For dateFormat: date-fns format pattern (e.g. 'yyyy-MM-dd'). */
1623
- dateFormat?: DateFormatConfig;
1624
- /** For mask: replacement string (default '***'). */
1625
- maskChar?: string;
1626
- }
1627
- declare const EXPORTER_PROFILE_SCHEMA_VERSION = 1;
1628
- /** Versioned export settings, associated explicitly with a supplied schema. */
1629
- interface ExporterProfile {
1630
- schemaVersion: typeof EXPORTER_PROFILE_SCHEMA_VERSION;
1631
- /** Slot-level overrides. Key: exact opaque slot ID. Profile overrides always win over defaults. */
1632
- slotOverrides?: Record<string, SlotTransformConfig>;
1633
- /** Header overrides keyed by stable column id. */
1634
- columnHeaders?: Record<string, string>;
1635
- /** Overrides for context keys. Key = context key name. */
1636
- contextOverrides?: Record<string, SlotTransformConfig>;
1637
- /** Ordered list of response column ids. Columns in this list appear in this order; others follow alphabetically. */
1638
- responseColumnOrder?: string[];
1639
- /** Ordered list of context column keys. If omitted, context columns are alphabetical. */
1640
- contextColumnOrder?: string[];
1641
- }
1642
- /** The host supplies the exact definition used to collect these submissions. */
1643
- interface ExportBatch {
1644
- schema: Survey;
1645
- responses: SurveyResponse[];
1646
- profile?: ExporterProfile;
1647
- sourceId?: string;
1648
- }
1649
- interface CombinedExportOptions {
1650
- profile?: ExporterProfile;
1651
- codingPolicy?: "original" | "harmonized";
1652
- }
1653
- /** Source of an export column. */
1654
- declare const ExportColumnSource: {
1655
- readonly meta: "meta";
1656
- readonly context: "context";
1657
- readonly response: "response";
1658
- };
1659
- type ExportColumnSource = (typeof ExportColumnSource)[keyof typeof ExportColumnSource];
1660
- /** Single export column. */
1661
- interface ExportColumn {
1662
- /** Stable internal identifier used for ordering/deduplication. */
1663
- id: string;
1664
- /** Exported column header written to CSV. */
1665
- header: string;
1666
- source: ExportColumnSource;
1667
- /** For meta: the meta field name. */
1668
- metaField?: MetaColumnKey;
1669
- /** For context: the context key. */
1670
- contextKey?: string;
1671
- /** For response: item/slot ids and value type. */
1672
- itemId?: string;
1673
- slotId?: string;
1674
- valueType?: ValueType;
1675
- optionId?: string;
1676
- }
1677
- /** Single export row: key -> string value. */
1678
- type ExportRow = Record<string, string>;
1679
- /** CSV export options. */
1680
- interface CsvExportOptions {
1681
- /** Cell separator (default ','). */
1682
- separator?: string;
1683
- /** Line ending (default '\n'). */
1684
- lineEnding?: string;
1685
- /** Include header row (default true). */
1686
- includeHeader?: boolean;
1687
- }
1688
- /** Parameters for single-slot export (unit-testable). */
1689
- interface ExportSingleSlotParams {
1690
- /** Optional categorical codes for reference values. Missing or blank mappings are errors. */
1691
- referenceValueKeys?: Record<string, string>;
1692
- value: ResponseValue | undefined;
1693
- valueType: ValueType;
1694
- /** Resolved formatter config (default or profile override). */
1695
- transformConfig: SlotTransformConfig;
1696
- }
1697
- //#endregion
1698
- //#region src/survey/responses/slot-definition.d.ts
1699
- interface ResponseSlotDefinition {
1700
- slotId: string;
1701
- /** Persistent primitive identity; current single-primitive items may use their item ID. */
1702
- primitiveId?: string;
1703
- rowId?: string;
1704
- columnId?: string;
1705
- /** Computed slots are declared alongside stored slots, never inferred from ID suffixes. */
1706
- computed?: {
1707
- operation: string;
1708
- sourceSlotIds: string[];
1709
- };
1710
- variableName: string;
1711
- naming?: ResponseNamingSource;
1712
- valueType: ValueType;
1713
- exportSettings?: SlotTransformConfig;
1714
- optionCodePaths?: Record<string, (string | number)[]>;
1715
- /** Optional finite value domain used to validate expression constants. */
1716
- allowedValues?: ResponseValue[];
1717
- /** Categorical export keys indexed by stable reference ID; unmapped IDs export unchanged. */
1718
- referenceValueLabelKeys?: Record<string, string>;
1719
- referenceValueLabels?: Record<string, Record<string, string>>;
1720
- referenceValueKeys?: Record<string, string>;
1721
- /** Finite numeric scores indexed by stable option ID, independent of export codes.
1722
- * Missing entries are non-scoring; an explicit zero is a defined score.
1723
- */
1724
- referenceValueScores?: Record<string, number>;
1725
- prefillTarget?: SurveyItemPrefillTarget;
1726
- }
1727
- //#endregion
1728
- //#region src/survey/responses/utils.d.ts
1729
- declare const initValueForType: (returnType: ValueType) => ResponseValue;
1730
- //#endregion
1731
- //#region src/survey/responses/value-domain.d.ts
1732
- /** Finite domains describe individual selectable values, including for array slots. */
1733
- declare function responseValueElements(value: ResponseValue): ResponseValue[];
1734
- declare function responseValuesEqual(left: ResponseValue, right: ResponseValue): boolean;
1735
- /** No coercion: an export code or label is never a categorical option identity. */
1736
- declare function invalidResponseDomainValues(value: ResponseValue, allowedValues: readonly ResponseValue[]): ResponseValue[];
1737
- declare function validateResponseSlotValue(slot: {
1738
- slotId: string;
1739
- valueType: ValueType;
1740
- allowedValues?: readonly ResponseValue[];
1741
- }, value: unknown): string[];
1742
- //#endregion
1743
- //#region src/expressions/expression.d.ts
1744
- declare const ExpressionType: {
1745
- readonly Const: "const";
1746
- readonly ResponseVariable: "responseVariable";
1747
- readonly ContextVariable: "contextVariable";
1748
- readonly Function: "function";
1749
- };
1750
- type ExpressionType = (typeof ExpressionType)[keyof typeof ExpressionType];
1751
- declare const ContextVariableType: {
1752
- readonly Locale: "locale";
1753
- readonly ParticipantFlag: "participantFlag";
1754
- readonly CustomValue: "customValue";
1755
- readonly CustomExpression: "customExpression";
1756
- };
1757
- type ContextVariableType = (typeof ContextVariableType)[keyof typeof ContextVariableType];
1758
- interface ExpressionEditorConfig {
1759
- usedTemplate?: string;
1760
- label?: string;
1761
- description?: string;
1762
- }
1763
- interface JsonConstExpression {
1764
- type: typeof ExpressionType.Const;
1765
- value?: ResponseValue;
1766
- editorConfig?: ExpressionEditorConfig;
1767
- }
1768
- interface JsonResponseVariableExpression {
1769
- type: typeof ExpressionType.ResponseVariable;
1770
- variableRef: JsonValueReference;
1771
- editorConfig?: ExpressionEditorConfig;
1772
- }
1773
- interface JsonContextVariableExpression {
1774
- type: typeof ExpressionType.ContextVariable;
1775
- contextType: ContextVariableType;
1776
- key?: JsonExpression;
1777
- arguments?: Array<JsonExpression | undefined>;
1778
- asType?: ValueType;
1779
- editorConfig?: ExpressionEditorConfig;
1780
- }
1781
- interface JsonFunctionExpression {
1782
- type: typeof ExpressionType.Function;
1783
- functionName: string;
1784
- arguments: Array<JsonExpression | undefined>;
1785
- editorConfig?: ExpressionEditorConfig;
1786
- }
1787
- type JsonExpression = JsonConstExpression | JsonResponseVariableExpression | JsonContextVariableExpression | JsonFunctionExpression;
1788
- /**
1789
- * Base class for all expressions.
1790
- */
1791
- declare abstract class Expression {
1792
- type: ExpressionType;
1793
- editorConfig?: ExpressionEditorConfig;
1794
- constructor(type: ExpressionType, editorConfig?: ExpressionEditorConfig);
1795
- static deserialize(json: JsonExpression | undefined): Expression | undefined;
1796
- /**
1797
- * Returns all unique response variable references in the expression.
1798
- * @returns A list of ValueReference objects.
1799
- */
1800
- abstract get responseVariableRefs(): ValueReference[];
1801
- abstract serialize(): JsonExpression | undefined;
1802
- clone(): Expression;
1803
- }
1804
- declare class ConstExpression extends Expression {
1805
- type: typeof ExpressionType.Const;
1806
- value?: ResponseValue;
1807
- constructor(value?: ResponseValue, editorConfig?: ExpressionEditorConfig);
1808
- static deserialize(json: JsonExpression): ConstExpression;
1809
- get responseVariableRefs(): ValueReference[];
1810
- serialize(): JsonExpression;
1811
- updateItemKeyReferences(_oldItemKey: string, _newItemKey: string): boolean;
1812
- }
1813
- declare class ResponseVariableExpression extends Expression {
1814
- type: typeof ExpressionType.ResponseVariable;
1815
- variableRef: string;
1816
- constructor(variableRef: JsonValueReference | string, editorConfig?: ExpressionEditorConfig);
1817
- static deserialize(json: JsonExpression): ResponseVariableExpression;
1818
- get responseVariableRefs(): ValueReference[];
1819
- get responseVariableRef(): ValueReference;
1820
- serialize(): JsonExpression;
1821
- }
1822
- declare class ContextVariableExpression extends Expression {
1823
- type: typeof ExpressionType.ContextVariable;
1824
- contextType: ContextVariableType;
1825
- key?: Expression;
1826
- arguments?: Array<Expression | undefined>;
1827
- asType?: ValueType;
1828
- constructor(contextType: ContextVariableType, key?: Expression, args?: Array<Expression | undefined>, asType?: ValueType, editorConfig?: ExpressionEditorConfig);
1829
- static deserialize(json: JsonExpression): ContextVariableExpression;
1830
- get responseVariableRefs(): ValueReference[];
1831
- serialize(): JsonExpression;
1832
- }
1833
- declare enum FunctionExpressionNames {
1834
- and = "and",
1835
- or = "or",
1836
- not = "not",
1837
- list_contains = "list_contains",
1838
- eq = "eq",
1839
- gt = "gt",
1840
- gte = "gte",
1841
- lt = "lt",
1842
- lte = "lte",
1843
- in_range = "in_range",
1844
- sum = "sum",
1845
- min = "min",
1846
- max = "max",
1847
- str_eq = "str_eq",
1848
- date_eq = "date_eq",
1849
- date_gt = "date_gt",
1850
- date_gte = "date_gte",
1851
- date_lt = "date_lt",
1852
- date_lte = "date_lte",
1853
- date_add_days = "date_add_days",
1854
- date_add_months = "date_add_months",
1855
- date_add_years = "date_add_years",
1856
- date_diff = "date_diff",
1857
- date_min = "date_min",
1858
- date_max = "date_max"
1859
- }
1860
- declare class FunctionExpression extends Expression {
1861
- type: typeof ExpressionType.Function;
1862
- functionName: FunctionExpressionNames;
1863
- arguments: Array<Expression | undefined>;
1864
- constructor(functionName: FunctionExpressionNames, args: Array<Expression | undefined>, editorConfig?: ExpressionEditorConfig);
1865
- static deserialize(json: JsonExpression): FunctionExpression;
1866
- get responseVariableRefs(): ValueReference[];
1867
- serialize(): JsonExpression | undefined;
1868
- }
1869
- //#endregion
1870
- //#region src/engine/engine.d.ts
1871
- type ScreenSize = "small" | "large";
1872
- interface RenderedSurveyItem {
1873
- id: string;
1874
- type: string;
1875
- items?: Array<RenderedSurveyItem>;
1876
- }
1877
- interface SurveyEnginePrefillEnvironment {
1878
- getPreviousResponse?: (ref: {
1879
- surveyKey?: string;
1880
- slotId: string;
1881
- }) => ResponseValue | undefined;
1882
- }
1883
- interface SurveyEngineOptions {
1884
- /** Disable defaults when reconstructing a finalized submission. */
1885
- applyConfiguredPrefills?: boolean;
1886
- prefillEnvironment?: SurveyEnginePrefillEnvironment;
1887
- }
1888
- declare class SurveyEngineCore {
1889
- private activeResponsePlan;
1890
- private activeState?;
1891
- private responseDiagnostics;
1892
- private surveyDef;
1893
- private renderedSurveyTree;
1894
- private renderedItemsCache?;
1895
- private context;
1896
- private locale;
1897
- private readonly sessionSeedValue;
1898
- private responses;
1899
- private prefills?;
1900
- private _events;
1901
- private _openedAt;
1902
- private dateLocales;
1903
- private prefillEnvironment?;
1904
- private cache;
1905
- constructor(survey: Survey, context?: SurveyContext, prefills?: Record<string, ResponseValue>, dateLocales?: Array<{
1906
- code: string;
1907
- locale: Locale;
1908
- }>, options?: SurveyEngineOptions);
1909
- setContext(context: SurveyContext): void;
1910
- getDateLocales(): Array<{
1911
- code: string;
1912
- locale: Locale;
1913
- }>;
1914
- getCurrentDateLocale(): Locale | undefined;
1915
- updateContext(context: SurveyContext): void;
1916
- /** Change the presentation language without losing participant/custom context. */
1917
- updateLocale(locale: string): boolean;
1918
- setResponse(targetKey: string, response?: ResponseItem): void;
1919
- get openedAt(): number;
1920
- /** Invalid visibility results in the current evaluation; unanswered conditions are omitted. */
1921
- getEvaluationDiagnostics(): {
1922
- code: "non-boolean-visibility-result";
1923
- itemId: string;
1924
- componentId?: string;
1925
- actualType: ResponseValue["type"];
1926
- }[];
1927
- /** Diagnostics from the latest initialization or response update for an item. */
1928
- getResponseDiagnostics(itemId: string): {
1929
- code: string;
1930
- message: string;
1931
- slotId?: string;
1932
- }[];
1933
- get sessionSeed(): string;
1934
- get survey(): Readonly<Survey>;
1935
- getSurveyPages(size?: ScreenSize): RenderedSurveyItem[][];
1936
- /** Read-only projection, with stable identity until the engine renders a new tree. */
1937
- getRenderedSurveyItems(): ReadonlyArray<Readonly<RenderedSurveyItem>>;
1938
- getRenderedSurveyItem(itemId: string): RenderedSurveyItem | undefined;
1939
- onPageChanged(pageIndex: number): void;
1940
- getEvents(): Readonly<Array<SurveyEvent>>;
1941
- /** Current session answers, including retained answers to hidden items. */
1942
- getResponses(): SurveyItemResponse[];
1943
- /** Answers to currently visible items and response slots on every page; does not erase hidden session answers. */
1944
- getSubmissionResponses(): SurveyItemResponse[];
1945
- /** Flat submission with events and item metadata kept separate from answer identity. */
1946
- getSurveyResponse(key: string, includeHidden?: boolean): SurveyResponse;
1947
- getAnswer(slotId: string): ResponseValue | undefined;
1948
- setAnswer(slotId: string, value: ResponseValue | undefined): void;
1949
- private collectResponses;
1950
- /** Author and intrinsic validation failures, restricted to currently rendered items. */
1951
- getInvalidResponseItems(itemIds?: readonly string[]): string[];
1952
- getIntrinsicValidationValues(itemKey: string): Record<string, boolean>;
1953
- getAuthorValidationValues(itemKey: string): Record<string, boolean>;
1954
- getDisplayConditionValue(itemKey: string, componentKey?: string): boolean | undefined;
1955
- getDisabledConditionValue(itemKey: string, componentKey: string): boolean | undefined;
1956
- getTemplateValue(templateValueKey: string): ResponseValue | undefined;
1957
- getValidationValues(itemKey: string): {
1958
- [validationKey: string]: boolean;
1959
- } | undefined;
1960
- private initCache;
1961
- private initResponseObject;
1962
- private applyConfiguredPrefills;
1963
- private applyConfiguredPrefillsForItem;
1964
- private shouldApplyConfiguredPrefill;
1965
- private resolveConfiguredPrefillValue;
1966
- private shouldRender;
1967
- private sequentialRender;
1968
- private randomizedItemRender;
1969
- private renderGroup;
1970
- private reRenderSurveyTree;
1971
- private _registerSurveyEvent;
1972
- private _getTimestamp;
1973
- getResponseItem(itemId: string): SurveyItemResponse | undefined;
1974
- /** Resolve computed references against current answers and conditions, with cycle detection. */
1975
- getComputedResponseValue(slotId: string): ResponseValue | undefined;
1976
- /** Evaluate against the same current responses/context used by conditions and prefills. */
1977
- evaluateExpression(expression: JsonExpression): ResponseValue | undefined;
1978
- private activeEvaluation;
1979
- private createEvaluator;
1980
- /** Active answer used by conditions and scoring; hidden session values remain in getAnswer(). */
1981
- getActiveAnswer(slotId: string): ResponseValue | undefined;
1982
- /** Validate static runtime contracts without constructing a response session. */
1983
- static getConfigurationIssues(survey: Survey): string[];
1984
- private static inspectConfiguration;
1985
- private evalExpressions;
1986
- private evalTemplateValues;
1987
- private evalDisplayConditions;
1988
- private evalDisableConditions;
1989
- private evalValidations;
1990
- }
1991
- declare const flattenTree: (itemTree: RenderedSurveyItem) => RenderedSurveyItem[];
1992
- //#endregion
1993
- //#region src/engine/active-responses.d.ts
1994
- interface VisibilityEvaluationDiagnostic {
1995
- code: "non-boolean-visibility-result";
1996
- itemId: string;
1997
- componentId?: string;
1998
- actualType: ResponseValue["type"];
1999
- }
2000
- /** Compile the dependencies once; each evaluation reads an immutable logical session snapshot. */
2001
- declare class ActiveResponsePlan {
2002
- private readonly survey;
2003
- private readonly parents;
2004
- private readonly components;
2005
- private readonly slots;
2006
- constructor(survey: Survey);
2007
- evaluate(responses: Record<string, SurveyItemResponse>, context: SurveyContext): {
2008
- evaluator: ExpressionEvaluator;
2009
- getAnswer: (slotId: string) => ResponseValue | undefined;
2010
- getItemResponse: (id: string) => ResponseItem | undefined;
2011
- isItemVisible: (id: string) => boolean;
2012
- isComponentVisible: (id: string, component: string) => boolean;
2013
- getDiagnostics: () => {
2014
- code: "non-boolean-visibility-result";
2015
- itemId: string;
2016
- componentId?: string;
2017
- actualType: ResponseValue["type"];
2018
- }[];
2019
- };
2020
- }
2021
- //#endregion
2022
- //#region src/json-patch.d.ts
2023
- type JsonPrimitive = string | number | boolean | null;
2024
- type JsonObject = {
2025
- [key: string]: JsonValue;
2026
- };
2027
- type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
2028
- type JsonPatchOperation = {
2029
- op: "add" | "replace" | "test";
2030
- path: string;
2031
- value: JsonValue;
2032
- } | {
2033
- op: "remove";
2034
- path: string;
2035
- } | {
2036
- op: "move" | "copy";
2037
- from: string;
2038
- path: string;
2039
- };
2040
- declare class JsonPatchError extends Error {
2041
- readonly code: string;
2042
- readonly path?: string | undefined;
2043
- readonly operationIndex?: number | undefined;
2044
- constructor(message: string, code: string, path?: string | undefined, operationIndex?: number | undefined);
2045
- }
2046
- declare const decodeJsonPointerSegment: (segment: string) => string;
2047
- declare const encodeJsonPointerSegment: (segment: string) => string;
2048
- declare const parseJsonPointer: (pointer: string) => string[];
2049
- declare const getValueAtJsonPointer: <T = unknown>(document: unknown, pointer: string) => T;
2050
- declare const applyJsonPatch: <T>(document: T, operations: readonly JsonPatchOperation[]) => T;
2051
- //#endregion
2052
- //#region src/utils.d.ts
2053
- declare function createSeededRandom(seed: string): () => number;
2054
- declare function shuffleArray<T>(values: readonly T[], random?: () => number): T[];
2055
- /**
2056
- * Shuffles an array of indices using the Fisher-Yates shuffle algorithm
2057
- * @param length - The length of the array to create indices for
2058
- * @returns A shuffled array of indices from 0 to length-1
2059
- */
2060
- declare function shuffleIndices(length: number, random?: () => number): number[];
2061
- declare function structuredCloneMethod<T>(obj: T): T;
2062
- declare function generateId(): string;
2063
- /**
2064
- * Generates a short random coding key suitable for item keys in exports/codebooks.
2065
- * @param length - Key length (default 4)
2066
- * @returns A random string of the specified length.
2067
- */
2068
- declare function generateCodingKey(length?: number): string;
2069
- /** Resolve a sibling key using the editor's stable numeric suffix convention. */
2070
- declare function resolveUniqueItemKey(key: string, siblingKeys: ReadonlySet<string>): string;
2071
- //#endregion
2072
- //#region src/response-exporter/exporter.d.ts
2073
- /** Export only against schemas selected by the host, never against response version tags. */
2074
- declare class SurveyResponseExporter {
2075
- private readonly batches;
2076
- private readonly options;
2077
- constructor(batches: ExportBatch[], options?: CombinedExportOptions);
2078
- private batch;
2079
- private profile;
2080
- private compileContexts;
2081
- private validateProfile;
2082
- computeResponseColumns(batchIndex?: number, extraResponses?: SurveyResponse[]): ExportColumn[];
2083
- computeColumns(extraResponses?: SurveyResponse[]): ExportColumn[];
2084
- private columns;
2085
- private row;
2086
- /** Explicitly associate one response with a supplied batch schema. */
2087
- exportResponse(response: SurveyResponse, batchIndex?: number): ExportRow;
2088
- exportRows(): ExportRow[];
2089
- private rows;
2090
- exportResponsesToCsv(options?: CsvExportOptions): string;
2091
- }
2092
- //#endregion
2093
- //#region src/response-exporter/slot-formatter.d.ts
2094
- /** Default transform config when no profile override. */
2095
- declare const DEFAULT_TRANSFORM: SlotTransformConfig;
2096
- /**
2097
- * Export a single response slot to a string. Pure function for unit testing.
2098
- * Uses default formatting by ValueType unless overridden by transformConfig.
2099
- */
2100
- declare function exportSingleResponseSlot(params: ExportSingleSlotParams): string;
2101
- //#endregion
2102
- //#region src/response-exporter/csv-serializer.d.ts
2103
- /**
2104
- * Escape a cell value for CSV. Quotes the cell when it contains separator, quote, CR, or LF.
2105
- * Doubles embedded quotes. Preserves multiline content inside quoted cells.
2106
- */
2107
- declare function escapeCsvCell(value: string, separator?: string): string;
2108
- /**
2109
- * Serialize export rows to CSV string.
2110
- */
2111
- declare function serializeToCsv(columns: ExportColumn[], rows: ExportRow[], options?: CsvExportOptions): string;
2112
- //#endregion
2113
- //#region src/response-exporter/codebook.d.ts
2114
- /** Single slot entry in codebook. */
2115
- interface CodebookSlot {
2116
- slotId: string;
2117
- primitiveId: string;
2118
- rowId?: string;
2119
- columnId?: string;
2120
- computed?: ResponseSlotDefinition["computed"];
2121
- variableName: string;
2122
- encoding?: SlotTransformConfig;
2123
- optionLabels?: Record<string, Record<string, string>>;
2124
- allowedValues?: ResponseValue[];
2125
- valueType: ValueType;
2126
- /** Categorical export codes for stable reference IDs; missing mappings block code exports. */
2127
- referenceValueKeys?: Record<string, string>;
2128
- referenceValueScores?: Record<string, number>;
2129
- }
2130
- /** Single item entry in codebook. */
2131
- interface CodebookItem {
2132
- id: string;
2133
- editorName: string;
2134
- breadcrumb: string;
2135
- type: string;
2136
- interactive: boolean;
2137
- slots: CodebookSlot[];
2138
- /** Content by locale, keyed by content key (e.g. 'title', 'description'). */
2139
- contentByLocale?: Record<string, Record<string, string>>;
2140
- }
2141
- /** Full codebook for a survey. */
2142
- interface Codebook {
2143
- surveyKey?: string;
2144
- items: CodebookItem[];
2145
- projection: ExportColumn[];
2146
- profile?: ExporterProfile;
2147
- missingValue: "";
2148
- }
2149
- /**
2150
- * Generate a structured codebook from a survey definition.
2151
- */
2152
- declare function generateCodebook(survey: Survey, options?: {
2153
- locales?: string[];
2154
- profile?: ExporterProfile;
2155
- }): Codebook;
2156
- /** Describe precisely the combined projection and each host-selected source definition. */
2157
- declare function generateExportCodebook(batches: ExportBatch[], options?: CombinedExportOptions): {
2158
- schemaVersion: number;
2159
- codingPolicy: "original" | "harmonized";
2160
- columns: ExportColumn[];
2161
- missingValue: string;
2162
- profile: ExporterProfile | undefined;
2163
- sources: {
2164
- sourceId: string | undefined;
2165
- surveySchemaVersion: number;
2166
- profile: ExporterProfile | undefined;
2167
- variables: {
2168
- encoding: SlotTransformConfig;
2169
- itemId: string;
2170
- primitiveId: string;
2171
- slotId: string;
2172
- rowId?: string;
2173
- columnId?: string;
2174
- computed?: {
2175
- operation: string;
2176
- sourceSlotIds: string[];
2177
- };
2178
- variableName: string;
2179
- naming?: ResponseNamingSource;
2180
- valueType: ValueType;
2181
- exportSettings?: SlotTransformConfig;
2182
- optionCodePaths?: Record<string, (string | number)[]>;
2183
- allowedValues?: ResponseValue[];
2184
- referenceValueLabelKeys?: Record<string, string>;
2185
- referenceValueLabels?: Record<string, Record<string, string>>;
2186
- referenceValueKeys?: Record<string, string>;
2187
- referenceValueScores?: Record<string, number>;
2188
- prefillTarget?: SurveyItemPrefillTarget;
2189
- }[];
2190
- }[];
2191
- };
2192
- //#endregion
2193
- //#region src/response-exporter/column-id.d.ts
2194
- /** One opaque codec shared by export projections, profiles and codebooks. */
2195
- type ExportColumnIdentity = readonly ["response", string, "value"] | readonly ["response", string, "option", string] | readonly ["meta", string] | readonly ["context", string];
2196
- declare function encodeExportColumnId(identity: ExportColumnIdentity): string;
2197
- declare function decodeExportColumnId(value: string): ExportColumnIdentity;
2198
- //#endregion
2199
- //#region src/response-exporter/projection.d.ts
2200
- declare function optionMapping(slot: OwnedResponseSlotDefinition, config: SlotTransformConfig): Record<string, string>;
2201
- /** Compile every declared role before applying inclusion settings. */
2202
- declare function projectSlot(slot: OwnedResponseSlotDefinition, config: SlotTransformConfig, allRoles?: boolean): ExportColumn[];
2203
- declare function formatProjectedValue(slot: OwnedResponseSlotDefinition, column: ExportColumn, value: ResponseValue | undefined, config: SlotTransformConfig): string;
2204
- /** Collect draft diagnostics without stopping at the first unfinished variable. */
2205
- declare function getDefaultProjectionIssues(survey: Survey): string[];
2206
- //#endregion
2207
- export { JsonExpression as $, addCalendarDate as $a, ItemExpressionDefinition as $i, SurveyItemPrefill as $n, sum as $r, JsonSurveyTranslations as $t, applyJsonPatch as A, BooleanResponse as Aa, SurveyExpressionLocation as Ai, RichTextSeparatorBlock as An, LegacyValidation as Ao, date_gte as Ar, PageBreakItemCore as At, SurveyEngineOptions as B, ReferenceArrayResponse as Ba, collectSurveyExpressionLocations as Bi, hasRenderableRichTextBlock as Bn, lte as Br, createItemTypeDefinitionRegistry as Bt, shuffleIndices as C, allocateResponseVariableName as Ca, MinExpressionEditor as Ci, RichTextInlineExtension as Cn, LegacyResponseComponent as Co, ctx_pflag_string as Cr, SlotTransformMode as Ct, JsonPatchOperation as D, JsonSurveyItemResponse as Da, StrListContainsExpressionEditor as Di, RichTextLinkInline as Dn, LegacySurveyItemTypes as Do, date_diff as Dr, GroupConfig as Dt, JsonPatchError as E, JsonResponseItem as Ea, StrEqExpressionEditor as Ei, RichTextLinkChildInline as En, LegacySurveyItem as Eo, date_add_years as Er, BuiltInItemType as Et, ActiveResponsePlan as F, DurationUnit as Fa, SurveyExpressionReferenceDiagnosticPolicy as Fi, TextAlignment as Fn, eq as Fr, ItemTypeDefinitionRegistry as Ft, ContextVariableType as G, StringResponse as Ga, replaceResponseVariableReferences as Gi, ItemCoreConstructor as Gn, response_date as Gr, ItemDisplayPath as Gt, flattenTree as H, ResponseValue as Ha, findIntroducedBlockingExpressionReferenceDiagnostics as Hi, isContentEmpty as Hn, min as Hr, OwnedResponseSlotDefinition as Ht, VisibilityEvaluationDiagnostic as I, DurationUnits as Ia, SurveyExpressionResponseSlot as Ii, createRichTextContent as In, gt as Ir, ItemTypeName as It, ExpressionType as J, assertResponseValue as Ja, ReferenceUsage as Ji, SurveyItemCore as Jn, response_number_array as Jr, CURRENT_SURVEY_SCHEMA_VERSION as Jt, Expression as K, ValueRefTypeLookup as Ka, responseValueReferenceIds as Ki, NormalizedItemResponse as Kn, response_date_array as Kr, getCompositionLabel as Kt, RenderedSurveyItem as L, NumberArrayResponse as La, analyzeSurveyExpressionReferences as Li, getAssetUsagesFromContent as Ln, gte as Lr, ItemTypeRegistry as Lt, encodeJsonPointerSegment as M, DateResponse as Ma, SurveyExpressionReferenceDiagnosticCategory as Mi, RichTextTemplateInline as Mn, isLegacySurveyGroupItem as Mo, date_lte as Mr, isBuiltInItemType as Mt, getValueAtJsonPointer as N, DurationArrayResponse as Na, SurveyExpressionReferenceDiagnosticCode as Ni, RichTextTextInline as Nn, date_max as Nr, ItemTypeCapabilities as Nt, JsonPrimitive as O, ResponseItem as Oa, SumExpressionEditor as Oi, RichTextListItemBlock as On, LegacySurveyProps as Oo, date_eq as Or, GroupItemCore as Ot, parseJsonPointer as P, DurationResponse as Pa, SurveyExpressionReferenceDiagnosticDisposition as Pi, SurveyContentImageSource as Pn, date_min as Pr, ItemTypeDefinition as Pt, JsonContextVariableExpression as Q, CalendarDateUnit as Qa, AnyItemExpressionDefinition as Qi, JsonSurveyItemPrefillTarget as Qn, str_list_contains as Qr, JsonComponentContent as Qt, ScreenSize as R, NumberPrecision as Ra, collectConfigValueExpressions as Ri, getContentPlainText as Rn, in_range as Rr, createFullRegistry as Rt, shuffleArray as S, ResponseNamingSource as Sa, MaxExpressionEditor as Si, RichTextInline as Sn, LegacyLocalizedString as So, ctx_pflag_num as Sr, SlotTransformConfig as St, JsonObject as T, suggestResponseVariableName as Ta, ResponseVariableEditor as Ti, RichTextLineBreakInline as Tn, LegacySurveyGroupItem as To, date_add_months as Tr, SurveyAssetUsage as Tt, ConstExpression as U, SlotResponseBase as Ua, findIntroducedExpressionReferenceDiagnosticsIncludingAdvisories as Ui, ReservedSurveyItemTypes as Un, or as Ur, ResponseSlotDiagnostic as Ut, SurveyEnginePrefillEnvironment as V, ReferenceResponse as Va, expressionReferenceDiagnosticKey as Vi, hasRenderableRichTextContent as Vn, max as Vr, toItemTypeDefinitionRegistry as Vt, ContextVariableExpression as W, StringArrayResponse as Wa, isBlockingSurveyExpressionReferenceDiagnostic as Wi, RawSurveyItem as Wn, response_boolean as Wr, ResponseSlotRegistry as Wt, FunctionExpressionNames as X, CalendarDate as Xa, ValueReference as Xi, JsonSurveyItemPrefill as Xn, response_string_array as Xr, RawSurveyAsset as Xt, FunctionExpression as Y, isResponseValue as Ya, ReferenceUsageType as Yi, SurveyItemCoreType as Yn, response_string as Yr, RawSurvey as Yt, JsonConstExpression as Z, CalendarDatePrecision as Za, ValueReferenceMethod as Zi, JsonSurveyItemPrefillSource as Zn, str_eq as Zr, SurveyVersion as Zt, SurveyResponseExporter as _, ResponseEvaluationContext as _a, GtExpressionEditor as _i, RichTextHeadingBlock as _n, LegacyConfidentialMode as _o, ctx_custom_expression as _r, ExportSingleSlotParams as _t, ExportColumnIdentity as a, ExpressionContext as aa, ConstNumberEditor as ai, validateLocale as an, differenceCalendarDates as ao, deserializeSurveyItemPrefill as ar, responseValuesEqual as at, generateId as b, SurveyResponseContext as ba, LtExpressionEditor as bi, RichTextImageSize as bn, LegacyLocalizedObject as bo, ctx_pflag_date as br, MetaColumnKey as bt, Codebook as c, TemplateDefTypes as ca, CtxCustomExpressionEditor as ci, ContentAttributes as cn, ItemResponseMeta as co, DATE_FUNCTION_SIGNATURES as cr, ResponseSlotDefinition as ct, generateCodebook as d, TemplateValueFormatDate as da, CtxPFlagDateEditor as di, PlainTextContent as dn, PageChangedEvent as do, const_date as dr, DateFormatConfig as dt, ItemExpressionParameterDefinition as ea, AndExpressionEditor as ei, NavigationContent as en, calendarDateBounds as eo, SurveyItemPrefillApplyMode as er, JsonFunctionExpression as et, generateExportCodebook as f, deserializeTemplateValue as fa, CtxPFlagIsDefinedEditor as fi, RichTextBlockExtension as fn, ResponseChangedEvent as fo, const_date_array as fr, EXPORTER_PROFILE_SCHEMA_VERSION as ft, exportSingleResponseSlot as g, JsonSurveyResponse as ga, ExpressionEditor as gi, RichTextDocument as gn, LegacyComponentProperties as go, const_string_array as gr, ExportRow as gt, DEFAULT_TRANSFORM as h, serializeTemplateValues as ha, EqExpressionEditor as hi, RichTextContent as hn, SurveyEventTypes as ho, const_string as hr, ExportColumnSource as ht, projectSlot as i, getItemExpressionDefinition as ia, ConstNumberArrayEditor as ii, SurveyTranslations as in, compareCalendarDates as io, SurveyItemPreviousResponseRef as ir, responseValueElements as it, decodeJsonPointerSegment as j, DateArrayResponse as ja, SurveyExpressionReferenceDiagnostic as ji, RichTextStyle as jn, isLegacyItemGroupComponent as jo, date_lt as jr, builtInItemCoreRegistry as jt, JsonValue as k, SurveyItemResponse as ka, SURVEY_EXPRESSION_REFERENCE_DIAGNOSTIC_POLICY as ki, RichTextParagraphBlock as kn, LegacySurveySingleItem as ko, date_gt as kr, PageBreakConfig as kt, CodebookItem as l, TemplateValueBase as la, CtxCustomValueEditor as li, ContentType as ln, LanguageChangedEvent as lo, and as lr, CombinedExportOptions as lt, serializeToCsv as m, serializeTemplateValue as ma, CtxPFlagStringEditor as mi, RichTextBulletListBlock as mn, SurveyEventBase as mo, const_number_array as mr, ExportColumn as mt, getDefaultProjectionIssues as n, ItemExpressionParameterOption as na, ConstDateArrayEditor as ni, SurveyCardTranslations as nn, calendarDatePrecision as no, SurveyItemPrefillTarget as nr, ResponseVariableExpression as nt, decodeExportColumnId as o, ExpressionEvaluator as oa, ConstStringArrayEditor as oi, Content as on, formatCalendarDate as oo, prefillTargetsEqual as or, validateResponseSlotValue as ot, escapeCsvCell as p, deserializeTemplateValues as pa, CtxPFlagNumEditor as pi, RichTextBlockNode as pn, SurveyEvent as po, const_number as pr, ExportBatch as pt, ExpressionEditorConfig as q, ValueType as qa, JsonValueReference as qi, ResponseNormalizationDiagnostic as qn, response_number as qr, CURRENT_SURVEY_SCHEMA as qt, optionMapping as r, buildItemExpression as ra, ConstDateEditor as ri, SurveyItemTranslations as rn, calendarDateToLocalDate as ro, SurveyItemPrefillTargetType as rr, invalidResponseDomainValues as rt, encodeExportColumnId as s, JsonTemplateValue as sa, ConstStringEditor as si, ContentAssetUsage as sn, isCalendarDate as so, serializeSurveyItemPrefill as sr, initValueForType as st, formatProjectedValue as t, ItemExpressionParameterInput as ta, ConstBooleanEditor as ti, SurveyCardContent as tn, calendarDateFromLocalDate as to, SurveyItemPrefillSource as tr, JsonResponseVariableExpression as tt, CodebookSlot as u, TemplateValueDefinition as ua, CtxLocaleEditor as ui, MDContent as un, OpenSurveyEvent as uo, const_boolean as ur, CsvExportOptions as ut, createSeededRandom as v, SURVEY_RESPONSE_SCHEMA_VERSION as va, GteExpressionEditor as vi, RichTextImageBlock as vn, LegacyItemComponent as vo, ctx_custom_value as vr, ExporterProfile as vt, structuredCloneMethod as w, isValidResponseVariableName as wa, OrExpressionEditor as wi, RichTextInlineNode as wn, LegacySurvey as wo, date_add_days as wr, Survey as wt, resolveUniqueItemKey as x, RESPONSE_VARIABLE_NAME_MAX_LENGTH as xa, LteExpressionEditor as xi, RichTextInfoBoxBlock as xn, LegacyLocalizedObjectBase as xo, ctx_pflag_is_defined as xr, SlotRef as xt, generateCodingKey as y, SurveyResponse as ya, InRangeExpressionEditor as yi, RichTextImageDimension as yn, LegacyItemGroupComponent as yo, ctx_locale as yr, META_COLUMN_ORDER as yt, SurveyEngineCore as z, NumberResponse as za, collectExpressionResponseReferences as zi, getPlainTextFromRichTextContent as zn, lt as zr, createItemCore as zt };
2208
- //# sourceMappingURL=index-SDbZ5WQM.d.mts.map