@form-engine-ts/core 2.2.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -0
- package/dist/index.cjs +500 -25
- package/dist/index.d.cts +124 -1
- package/dist/index.d.ts +124 -1
- package/dist/index.js +490 -25
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -163,6 +163,22 @@ interface FormStorageAdapter extends StorageAdapter {
|
|
|
163
163
|
deleteSchema(formId: string, formVersion: number): Promise<void>;
|
|
164
164
|
deleteSubmission(submissionId: string): Promise<void>;
|
|
165
165
|
}
|
|
166
|
+
interface SubmissionPageQueryOptions {
|
|
167
|
+
readonly version?: number;
|
|
168
|
+
readonly cursor?: string;
|
|
169
|
+
readonly pageSize?: number;
|
|
170
|
+
readonly since?: string;
|
|
171
|
+
readonly until?: string;
|
|
172
|
+
readonly locale?: string;
|
|
173
|
+
}
|
|
174
|
+
interface SubmissionPage {
|
|
175
|
+
readonly items: readonly FormSubmission[];
|
|
176
|
+
readonly nextCursor?: string;
|
|
177
|
+
readonly hasMore: boolean;
|
|
178
|
+
}
|
|
179
|
+
interface PagedSubmissionStorageAdapter extends FormStorageAdapter {
|
|
180
|
+
listSubmissionPage(formId: string, options?: SubmissionPageQueryOptions): Promise<SubmissionPage>;
|
|
181
|
+
}
|
|
166
182
|
interface BaseQuestionAggregate {
|
|
167
183
|
readonly fieldId: string;
|
|
168
184
|
readonly answeredCount: number;
|
|
@@ -234,11 +250,34 @@ declare function calculateChoiceDistribution(responses: readonly FormSubmission[
|
|
|
234
250
|
declare function calculateNumericSummary(responses: readonly FormSubmission[], questionId: string): NumericSummary;
|
|
235
251
|
declare function calculateCrossTabulation(responses: readonly FormSubmission[], rowQuestionId: string, colQuestionId: string): CrossTabulationResult;
|
|
236
252
|
declare function aggregateResponses(schema: FormSchema, submissions: readonly FormSubmission[]): FormAnalytics;
|
|
253
|
+
type AccumulatorResponse = FormSubmission | FormResponse;
|
|
254
|
+
interface ResponseAccumulator {
|
|
255
|
+
add(submission: AccumulatorResponse): {
|
|
256
|
+
readonly success: boolean;
|
|
257
|
+
readonly error?: string;
|
|
258
|
+
};
|
|
259
|
+
addMany(submissions: Iterable<AccumulatorResponse>): void;
|
|
260
|
+
merge(other: ResponseAccumulator): ResponseAccumulator;
|
|
261
|
+
finalize(): FormAnalytics;
|
|
262
|
+
}
|
|
263
|
+
interface ResponseAccumulatorOptions {
|
|
264
|
+
readonly mode?: "strict" | "lenient";
|
|
265
|
+
}
|
|
266
|
+
declare function createResponseAccumulator(schema: FormSchema, options?: ResponseAccumulatorOptions): ResponseAccumulator;
|
|
237
267
|
declare function escapeCsvCell(value: string | number | boolean | null | undefined, neutralizeFormulas?: boolean): string;
|
|
238
268
|
interface CsvExportOptions {
|
|
239
269
|
readonly withBom?: boolean;
|
|
240
270
|
readonly neutralizeFormulas?: boolean;
|
|
241
271
|
}
|
|
272
|
+
interface CsvColumnDef {
|
|
273
|
+
readonly header: string;
|
|
274
|
+
readonly getValue: (submission: FormResponse) => string | number | boolean | null | undefined;
|
|
275
|
+
}
|
|
276
|
+
interface StreamCsvOptions extends CsvExportOptions {
|
|
277
|
+
readonly columns?: readonly CsvColumnDef[];
|
|
278
|
+
readonly includeDefaultColumns?: boolean;
|
|
279
|
+
}
|
|
280
|
+
declare function exportResponsesToCsvStream(schema: FormSchema, submissions: AsyncIterable<AccumulatorResponse>, options?: StreamCsvOptions): AsyncIterable<string>;
|
|
242
281
|
declare function exportResponsesToCsv(schema: FormSchema, responses: readonly FormSubmission[], options?: CsvExportOptions): string;
|
|
243
282
|
|
|
244
283
|
type FormEventType = "response.submitted" | "schema.updated";
|
|
@@ -268,6 +307,25 @@ declare function dispatchWebhook<T>(event: FormEvent<T>, config: WebhookConfig,
|
|
|
268
307
|
*/
|
|
269
308
|
declare function transformFieldType(field: FormField, nextType: QuestionType): FormField;
|
|
270
309
|
|
|
310
|
+
interface SubmissionCursorValue {
|
|
311
|
+
readonly submittedAt: string;
|
|
312
|
+
readonly responseId: string;
|
|
313
|
+
}
|
|
314
|
+
declare function encodeSubmissionCursor(value: SubmissionCursorValue): string;
|
|
315
|
+
declare function decodeSubmissionCursor(cursor: string): SubmissionCursorValue;
|
|
316
|
+
declare function normalizeSubmissionPageSize(pageSize: number | undefined, fallback?: number): number;
|
|
317
|
+
|
|
318
|
+
interface CollectedLocales {
|
|
319
|
+
readonly defaultLocale?: string;
|
|
320
|
+
readonly supportedLocales: readonly string[];
|
|
321
|
+
readonly translationLocales: ReadonlySet<string>;
|
|
322
|
+
readonly allUniqueLocales: ReadonlySet<string>;
|
|
323
|
+
/** Every translation or translation-metadata locale and the schema paths where it occurs. */
|
|
324
|
+
readonly translationLocalePaths: ReadonlyMap<string, readonly string[]>;
|
|
325
|
+
}
|
|
326
|
+
/** Collects locale registrations and every locale key used by translations or translation metadata. */
|
|
327
|
+
declare function collectSchemaLocales(schema: FormSchema): CollectedLocales;
|
|
328
|
+
|
|
271
329
|
type SchemaStructureIssueType = "dangling_condition_reference" | "duplicate_question_id" | "duplicate_choice_id" | "self_condition_reference" | "cyclic_condition_reference";
|
|
272
330
|
interface SchemaStructureIssue {
|
|
273
331
|
readonly type: SchemaStructureIssueType;
|
|
@@ -307,6 +365,8 @@ interface PopulateTranslationOptions {
|
|
|
307
365
|
readonly overwrite?: "missing-only" | "all";
|
|
308
366
|
readonly shouldOverwrite?: (slot: TranslationSlot) => boolean;
|
|
309
367
|
readonly createMetadata?: (slot: TranslationSlot, translatedText: string) => Readonly<Record<string, JsonValue>>;
|
|
368
|
+
/** Applies locale admission and count limits before the adapter is called. */
|
|
369
|
+
readonly policy?: Pick<FormPolicy, "allowedLocales" | "maxLocales">;
|
|
310
370
|
}
|
|
311
371
|
interface TranslationReport {
|
|
312
372
|
readonly updatedSlots: readonly TranslationSlot[];
|
|
@@ -322,10 +382,73 @@ declare function resolveFormTranslation(schema: FormSchema, adapter: AsyncTransl
|
|
|
322
382
|
declare function validateAnswers(schema: FormSchema, values: FormValues): AnswerValidationResult;
|
|
323
383
|
declare function validatePageAnswers(schema: FormSchema, pageIndex: number, values: FormValues): AnswerValidationResult;
|
|
324
384
|
|
|
385
|
+
type Result<T, E> = {
|
|
386
|
+
readonly success: true;
|
|
387
|
+
readonly value: T;
|
|
388
|
+
} | {
|
|
389
|
+
readonly success: false;
|
|
390
|
+
readonly error: E;
|
|
391
|
+
};
|
|
392
|
+
type FormVersionStatus = "draft" | "published" | "archived";
|
|
393
|
+
interface FormVersionRecord {
|
|
394
|
+
readonly formId: string;
|
|
395
|
+
readonly version: number;
|
|
396
|
+
readonly status: FormVersionStatus;
|
|
397
|
+
readonly schema: FormSchema;
|
|
398
|
+
readonly createdAt: string;
|
|
399
|
+
readonly publishedAt?: string;
|
|
400
|
+
readonly archivedAt?: string;
|
|
401
|
+
}
|
|
402
|
+
interface FormVersionState {
|
|
403
|
+
readonly formId: string;
|
|
404
|
+
readonly draftVersion?: number;
|
|
405
|
+
readonly publishedVersion?: number;
|
|
406
|
+
readonly nextVersion: number;
|
|
407
|
+
readonly revision: number;
|
|
408
|
+
}
|
|
409
|
+
type VersionTransitionError = {
|
|
410
|
+
readonly type: "draft_already_exists";
|
|
411
|
+
readonly currentDraftVersion: number;
|
|
412
|
+
} | {
|
|
413
|
+
readonly type: "draft_not_found";
|
|
414
|
+
} | {
|
|
415
|
+
readonly type: "revision_conflict";
|
|
416
|
+
readonly expectedRevision: number;
|
|
417
|
+
readonly actualRevision: number;
|
|
418
|
+
} | {
|
|
419
|
+
readonly type: "version_immutable";
|
|
420
|
+
readonly status: FormVersionStatus;
|
|
421
|
+
} | {
|
|
422
|
+
readonly type: "max_version_exceeded";
|
|
423
|
+
readonly max: number;
|
|
424
|
+
};
|
|
425
|
+
interface CloneVersionOptions {
|
|
426
|
+
readonly maxVersions?: number;
|
|
427
|
+
}
|
|
428
|
+
interface PublishDraftOptions {
|
|
429
|
+
readonly expectedRevision?: number;
|
|
430
|
+
readonly validate?: (schema: FormSchema) => boolean;
|
|
431
|
+
/** Supplies deterministic record timestamps while keeping the transition pure. */
|
|
432
|
+
readonly timestamp?: string;
|
|
433
|
+
}
|
|
434
|
+
declare function cloneVersionToDraft(state: FormVersionState, sourceSchema: FormSchema, options?: CloneVersionOptions): Result<{
|
|
435
|
+
readonly nextState: FormVersionState;
|
|
436
|
+
readonly draftSchema: FormSchema;
|
|
437
|
+
}, VersionTransitionError>;
|
|
438
|
+
declare function publishDraft(state: FormVersionState, draftSchema: FormSchema, options?: PublishDraftOptions): Result<{
|
|
439
|
+
readonly nextState: FormVersionState;
|
|
440
|
+
readonly publishedRecord: FormVersionRecord;
|
|
441
|
+
readonly archivedVersion?: number;
|
|
442
|
+
}, VersionTransitionError>;
|
|
443
|
+
declare function deleteDraft(state: FormVersionState): Result<{
|
|
444
|
+
readonly nextState: FormVersionState;
|
|
445
|
+
}, VersionTransitionError>;
|
|
446
|
+
declare function assertVersionMutable(status: FormVersionStatus): void;
|
|
447
|
+
|
|
325
448
|
declare function isQuestionVisible(question: FormField, currentAnswers: Readonly<Record<string, unknown>>): boolean;
|
|
326
449
|
declare function isDisplayConditionSatisfied(condition: DisplayCondition | undefined, currentAnswers: Readonly<Record<string, unknown>>): boolean;
|
|
327
450
|
declare function calculatePageVisibility(schema: FormSchema, currentAnswers: Readonly<Record<string, unknown>>): Readonly<Record<string, boolean>>;
|
|
328
451
|
declare function calculateFieldVisibility(schema: FormSchema, currentAnswers: Readonly<Record<string, unknown>>): Readonly<Record<string, boolean>>;
|
|
329
452
|
declare function selectVisibleAnswers(schema: FormSchema, currentAnswers: FormValues): FormValues;
|
|
330
453
|
|
|
331
|
-
export { type AnswerValidationResult, type AsyncTranslationAdapter, type BaseField, type CheckboxField, type CheckboxQuestionAggregate, type ChoiceDistributionEntry, type ChoiceOption, type ChoiceQuestionAggregate, type ConditionOperator, type ConditionValue, type CreateSubmissionOptions, type CrossTabulationResult, type CsvExportOptions, type DisplayCondition, type ExtensibleNode, type FieldOption, type FieldType, type FormAnalytics, type FormEvent, type FormEventType, type FormField, type FormPage, type FormPolicy, type FormResponse, type FormSchema, type FormStorageAdapter, type FormSubmission, type FormValue, type FormValues, type JsonValue, type LocalizedText, type MultiSelectField, type NumberField, type NumberQuestionAggregate, type NumericSummary, type OptionAggregate, type PopulateTranslationOptions, type Question, type QuestionAggregate, type QuestionType, type RatingField, type SchemaIssue, type SchemaStructureIssue, type SchemaStructureIssueType, type SchemaTranslations, type SchemaValidationResult, type SelectField, type StorageAdapter, type SubmissionQueryOptions, type TextField, type TextQuestionAggregate, type TranslationAdapter, type TranslationReport, type TranslationSlot, type ValidateFormSchemaOptions, type ValidationCode, type ValidationError, type ValidationIssue, type WebhookConfig, type WebhookDispatchResult, aggregateResponses, assertValidFormSchema, calculateChoiceDistribution, calculateCrossTabulation, calculateFieldVisibility, calculateNumericSummary, calculatePageVisibility, createSubmission, dispatchWebhook, escapeCsvCell, exportResponsesToCsv, isDisplayConditionSatisfied, isQuestionVisible, populateSchemaTranslations, resolveFormTranslation, resolveLocalizedSchema, sanitizeSchema, selectVisibleAnswers, transformFieldType, validateAnswers, validateFormSchema, validatePageAnswers, validateSchemaStructure };
|
|
454
|
+
export { type AccumulatorResponse, type AnswerValidationResult, type AsyncTranslationAdapter, type BaseField, type CheckboxField, type CheckboxQuestionAggregate, type ChoiceDistributionEntry, type ChoiceOption, type ChoiceQuestionAggregate, type CloneVersionOptions, type CollectedLocales, type ConditionOperator, type ConditionValue, type CreateSubmissionOptions, type CrossTabulationResult, type CsvColumnDef, type CsvExportOptions, type DisplayCondition, type ExtensibleNode, type FieldOption, type FieldType, type FormAnalytics, type FormEvent, type FormEventType, type FormField, type FormPage, type FormPolicy, type FormResponse, type FormSchema, type FormStorageAdapter, type FormSubmission, type FormValue, type FormValues, type FormVersionRecord, type FormVersionState, type FormVersionStatus, type JsonValue, type LocalizedText, type MultiSelectField, type NumberField, type NumberQuestionAggregate, type NumericSummary, type OptionAggregate, type PagedSubmissionStorageAdapter, type PopulateTranslationOptions, type PublishDraftOptions, type Question, type QuestionAggregate, type QuestionType, type RatingField, type ResponseAccumulator, type ResponseAccumulatorOptions, type Result, type SchemaIssue, type SchemaStructureIssue, type SchemaStructureIssueType, type SchemaTranslations, type SchemaValidationResult, type SelectField, type StorageAdapter, type StreamCsvOptions, type SubmissionCursorValue, type SubmissionPage, type SubmissionPageQueryOptions, type SubmissionQueryOptions, type TextField, type TextQuestionAggregate, type TranslationAdapter, type TranslationReport, type TranslationSlot, type ValidateFormSchemaOptions, type ValidationCode, type ValidationError, type ValidationIssue, type VersionTransitionError, type WebhookConfig, type WebhookDispatchResult, aggregateResponses, assertValidFormSchema, assertVersionMutable, calculateChoiceDistribution, calculateCrossTabulation, calculateFieldVisibility, calculateNumericSummary, calculatePageVisibility, cloneVersionToDraft, collectSchemaLocales, createResponseAccumulator, createSubmission, decodeSubmissionCursor, deleteDraft, dispatchWebhook, encodeSubmissionCursor, escapeCsvCell, exportResponsesToCsv, exportResponsesToCsvStream, isDisplayConditionSatisfied, isQuestionVisible, normalizeSubmissionPageSize, populateSchemaTranslations, publishDraft, resolveFormTranslation, resolveLocalizedSchema, sanitizeSchema, selectVisibleAnswers, transformFieldType, validateAnswers, validateFormSchema, validatePageAnswers, validateSchemaStructure };
|
package/dist/index.d.ts
CHANGED
|
@@ -163,6 +163,22 @@ interface FormStorageAdapter extends StorageAdapter {
|
|
|
163
163
|
deleteSchema(formId: string, formVersion: number): Promise<void>;
|
|
164
164
|
deleteSubmission(submissionId: string): Promise<void>;
|
|
165
165
|
}
|
|
166
|
+
interface SubmissionPageQueryOptions {
|
|
167
|
+
readonly version?: number;
|
|
168
|
+
readonly cursor?: string;
|
|
169
|
+
readonly pageSize?: number;
|
|
170
|
+
readonly since?: string;
|
|
171
|
+
readonly until?: string;
|
|
172
|
+
readonly locale?: string;
|
|
173
|
+
}
|
|
174
|
+
interface SubmissionPage {
|
|
175
|
+
readonly items: readonly FormSubmission[];
|
|
176
|
+
readonly nextCursor?: string;
|
|
177
|
+
readonly hasMore: boolean;
|
|
178
|
+
}
|
|
179
|
+
interface PagedSubmissionStorageAdapter extends FormStorageAdapter {
|
|
180
|
+
listSubmissionPage(formId: string, options?: SubmissionPageQueryOptions): Promise<SubmissionPage>;
|
|
181
|
+
}
|
|
166
182
|
interface BaseQuestionAggregate {
|
|
167
183
|
readonly fieldId: string;
|
|
168
184
|
readonly answeredCount: number;
|
|
@@ -234,11 +250,34 @@ declare function calculateChoiceDistribution(responses: readonly FormSubmission[
|
|
|
234
250
|
declare function calculateNumericSummary(responses: readonly FormSubmission[], questionId: string): NumericSummary;
|
|
235
251
|
declare function calculateCrossTabulation(responses: readonly FormSubmission[], rowQuestionId: string, colQuestionId: string): CrossTabulationResult;
|
|
236
252
|
declare function aggregateResponses(schema: FormSchema, submissions: readonly FormSubmission[]): FormAnalytics;
|
|
253
|
+
type AccumulatorResponse = FormSubmission | FormResponse;
|
|
254
|
+
interface ResponseAccumulator {
|
|
255
|
+
add(submission: AccumulatorResponse): {
|
|
256
|
+
readonly success: boolean;
|
|
257
|
+
readonly error?: string;
|
|
258
|
+
};
|
|
259
|
+
addMany(submissions: Iterable<AccumulatorResponse>): void;
|
|
260
|
+
merge(other: ResponseAccumulator): ResponseAccumulator;
|
|
261
|
+
finalize(): FormAnalytics;
|
|
262
|
+
}
|
|
263
|
+
interface ResponseAccumulatorOptions {
|
|
264
|
+
readonly mode?: "strict" | "lenient";
|
|
265
|
+
}
|
|
266
|
+
declare function createResponseAccumulator(schema: FormSchema, options?: ResponseAccumulatorOptions): ResponseAccumulator;
|
|
237
267
|
declare function escapeCsvCell(value: string | number | boolean | null | undefined, neutralizeFormulas?: boolean): string;
|
|
238
268
|
interface CsvExportOptions {
|
|
239
269
|
readonly withBom?: boolean;
|
|
240
270
|
readonly neutralizeFormulas?: boolean;
|
|
241
271
|
}
|
|
272
|
+
interface CsvColumnDef {
|
|
273
|
+
readonly header: string;
|
|
274
|
+
readonly getValue: (submission: FormResponse) => string | number | boolean | null | undefined;
|
|
275
|
+
}
|
|
276
|
+
interface StreamCsvOptions extends CsvExportOptions {
|
|
277
|
+
readonly columns?: readonly CsvColumnDef[];
|
|
278
|
+
readonly includeDefaultColumns?: boolean;
|
|
279
|
+
}
|
|
280
|
+
declare function exportResponsesToCsvStream(schema: FormSchema, submissions: AsyncIterable<AccumulatorResponse>, options?: StreamCsvOptions): AsyncIterable<string>;
|
|
242
281
|
declare function exportResponsesToCsv(schema: FormSchema, responses: readonly FormSubmission[], options?: CsvExportOptions): string;
|
|
243
282
|
|
|
244
283
|
type FormEventType = "response.submitted" | "schema.updated";
|
|
@@ -268,6 +307,25 @@ declare function dispatchWebhook<T>(event: FormEvent<T>, config: WebhookConfig,
|
|
|
268
307
|
*/
|
|
269
308
|
declare function transformFieldType(field: FormField, nextType: QuestionType): FormField;
|
|
270
309
|
|
|
310
|
+
interface SubmissionCursorValue {
|
|
311
|
+
readonly submittedAt: string;
|
|
312
|
+
readonly responseId: string;
|
|
313
|
+
}
|
|
314
|
+
declare function encodeSubmissionCursor(value: SubmissionCursorValue): string;
|
|
315
|
+
declare function decodeSubmissionCursor(cursor: string): SubmissionCursorValue;
|
|
316
|
+
declare function normalizeSubmissionPageSize(pageSize: number | undefined, fallback?: number): number;
|
|
317
|
+
|
|
318
|
+
interface CollectedLocales {
|
|
319
|
+
readonly defaultLocale?: string;
|
|
320
|
+
readonly supportedLocales: readonly string[];
|
|
321
|
+
readonly translationLocales: ReadonlySet<string>;
|
|
322
|
+
readonly allUniqueLocales: ReadonlySet<string>;
|
|
323
|
+
/** Every translation or translation-metadata locale and the schema paths where it occurs. */
|
|
324
|
+
readonly translationLocalePaths: ReadonlyMap<string, readonly string[]>;
|
|
325
|
+
}
|
|
326
|
+
/** Collects locale registrations and every locale key used by translations or translation metadata. */
|
|
327
|
+
declare function collectSchemaLocales(schema: FormSchema): CollectedLocales;
|
|
328
|
+
|
|
271
329
|
type SchemaStructureIssueType = "dangling_condition_reference" | "duplicate_question_id" | "duplicate_choice_id" | "self_condition_reference" | "cyclic_condition_reference";
|
|
272
330
|
interface SchemaStructureIssue {
|
|
273
331
|
readonly type: SchemaStructureIssueType;
|
|
@@ -307,6 +365,8 @@ interface PopulateTranslationOptions {
|
|
|
307
365
|
readonly overwrite?: "missing-only" | "all";
|
|
308
366
|
readonly shouldOverwrite?: (slot: TranslationSlot) => boolean;
|
|
309
367
|
readonly createMetadata?: (slot: TranslationSlot, translatedText: string) => Readonly<Record<string, JsonValue>>;
|
|
368
|
+
/** Applies locale admission and count limits before the adapter is called. */
|
|
369
|
+
readonly policy?: Pick<FormPolicy, "allowedLocales" | "maxLocales">;
|
|
310
370
|
}
|
|
311
371
|
interface TranslationReport {
|
|
312
372
|
readonly updatedSlots: readonly TranslationSlot[];
|
|
@@ -322,10 +382,73 @@ declare function resolveFormTranslation(schema: FormSchema, adapter: AsyncTransl
|
|
|
322
382
|
declare function validateAnswers(schema: FormSchema, values: FormValues): AnswerValidationResult;
|
|
323
383
|
declare function validatePageAnswers(schema: FormSchema, pageIndex: number, values: FormValues): AnswerValidationResult;
|
|
324
384
|
|
|
385
|
+
type Result<T, E> = {
|
|
386
|
+
readonly success: true;
|
|
387
|
+
readonly value: T;
|
|
388
|
+
} | {
|
|
389
|
+
readonly success: false;
|
|
390
|
+
readonly error: E;
|
|
391
|
+
};
|
|
392
|
+
type FormVersionStatus = "draft" | "published" | "archived";
|
|
393
|
+
interface FormVersionRecord {
|
|
394
|
+
readonly formId: string;
|
|
395
|
+
readonly version: number;
|
|
396
|
+
readonly status: FormVersionStatus;
|
|
397
|
+
readonly schema: FormSchema;
|
|
398
|
+
readonly createdAt: string;
|
|
399
|
+
readonly publishedAt?: string;
|
|
400
|
+
readonly archivedAt?: string;
|
|
401
|
+
}
|
|
402
|
+
interface FormVersionState {
|
|
403
|
+
readonly formId: string;
|
|
404
|
+
readonly draftVersion?: number;
|
|
405
|
+
readonly publishedVersion?: number;
|
|
406
|
+
readonly nextVersion: number;
|
|
407
|
+
readonly revision: number;
|
|
408
|
+
}
|
|
409
|
+
type VersionTransitionError = {
|
|
410
|
+
readonly type: "draft_already_exists";
|
|
411
|
+
readonly currentDraftVersion: number;
|
|
412
|
+
} | {
|
|
413
|
+
readonly type: "draft_not_found";
|
|
414
|
+
} | {
|
|
415
|
+
readonly type: "revision_conflict";
|
|
416
|
+
readonly expectedRevision: number;
|
|
417
|
+
readonly actualRevision: number;
|
|
418
|
+
} | {
|
|
419
|
+
readonly type: "version_immutable";
|
|
420
|
+
readonly status: FormVersionStatus;
|
|
421
|
+
} | {
|
|
422
|
+
readonly type: "max_version_exceeded";
|
|
423
|
+
readonly max: number;
|
|
424
|
+
};
|
|
425
|
+
interface CloneVersionOptions {
|
|
426
|
+
readonly maxVersions?: number;
|
|
427
|
+
}
|
|
428
|
+
interface PublishDraftOptions {
|
|
429
|
+
readonly expectedRevision?: number;
|
|
430
|
+
readonly validate?: (schema: FormSchema) => boolean;
|
|
431
|
+
/** Supplies deterministic record timestamps while keeping the transition pure. */
|
|
432
|
+
readonly timestamp?: string;
|
|
433
|
+
}
|
|
434
|
+
declare function cloneVersionToDraft(state: FormVersionState, sourceSchema: FormSchema, options?: CloneVersionOptions): Result<{
|
|
435
|
+
readonly nextState: FormVersionState;
|
|
436
|
+
readonly draftSchema: FormSchema;
|
|
437
|
+
}, VersionTransitionError>;
|
|
438
|
+
declare function publishDraft(state: FormVersionState, draftSchema: FormSchema, options?: PublishDraftOptions): Result<{
|
|
439
|
+
readonly nextState: FormVersionState;
|
|
440
|
+
readonly publishedRecord: FormVersionRecord;
|
|
441
|
+
readonly archivedVersion?: number;
|
|
442
|
+
}, VersionTransitionError>;
|
|
443
|
+
declare function deleteDraft(state: FormVersionState): Result<{
|
|
444
|
+
readonly nextState: FormVersionState;
|
|
445
|
+
}, VersionTransitionError>;
|
|
446
|
+
declare function assertVersionMutable(status: FormVersionStatus): void;
|
|
447
|
+
|
|
325
448
|
declare function isQuestionVisible(question: FormField, currentAnswers: Readonly<Record<string, unknown>>): boolean;
|
|
326
449
|
declare function isDisplayConditionSatisfied(condition: DisplayCondition | undefined, currentAnswers: Readonly<Record<string, unknown>>): boolean;
|
|
327
450
|
declare function calculatePageVisibility(schema: FormSchema, currentAnswers: Readonly<Record<string, unknown>>): Readonly<Record<string, boolean>>;
|
|
328
451
|
declare function calculateFieldVisibility(schema: FormSchema, currentAnswers: Readonly<Record<string, unknown>>): Readonly<Record<string, boolean>>;
|
|
329
452
|
declare function selectVisibleAnswers(schema: FormSchema, currentAnswers: FormValues): FormValues;
|
|
330
453
|
|
|
331
|
-
export { type AnswerValidationResult, type AsyncTranslationAdapter, type BaseField, type CheckboxField, type CheckboxQuestionAggregate, type ChoiceDistributionEntry, type ChoiceOption, type ChoiceQuestionAggregate, type ConditionOperator, type ConditionValue, type CreateSubmissionOptions, type CrossTabulationResult, type CsvExportOptions, type DisplayCondition, type ExtensibleNode, type FieldOption, type FieldType, type FormAnalytics, type FormEvent, type FormEventType, type FormField, type FormPage, type FormPolicy, type FormResponse, type FormSchema, type FormStorageAdapter, type FormSubmission, type FormValue, type FormValues, type JsonValue, type LocalizedText, type MultiSelectField, type NumberField, type NumberQuestionAggregate, type NumericSummary, type OptionAggregate, type PopulateTranslationOptions, type Question, type QuestionAggregate, type QuestionType, type RatingField, type SchemaIssue, type SchemaStructureIssue, type SchemaStructureIssueType, type SchemaTranslations, type SchemaValidationResult, type SelectField, type StorageAdapter, type SubmissionQueryOptions, type TextField, type TextQuestionAggregate, type TranslationAdapter, type TranslationReport, type TranslationSlot, type ValidateFormSchemaOptions, type ValidationCode, type ValidationError, type ValidationIssue, type WebhookConfig, type WebhookDispatchResult, aggregateResponses, assertValidFormSchema, calculateChoiceDistribution, calculateCrossTabulation, calculateFieldVisibility, calculateNumericSummary, calculatePageVisibility, createSubmission, dispatchWebhook, escapeCsvCell, exportResponsesToCsv, isDisplayConditionSatisfied, isQuestionVisible, populateSchemaTranslations, resolveFormTranslation, resolveLocalizedSchema, sanitizeSchema, selectVisibleAnswers, transformFieldType, validateAnswers, validateFormSchema, validatePageAnswers, validateSchemaStructure };
|
|
454
|
+
export { type AccumulatorResponse, type AnswerValidationResult, type AsyncTranslationAdapter, type BaseField, type CheckboxField, type CheckboxQuestionAggregate, type ChoiceDistributionEntry, type ChoiceOption, type ChoiceQuestionAggregate, type CloneVersionOptions, type CollectedLocales, type ConditionOperator, type ConditionValue, type CreateSubmissionOptions, type CrossTabulationResult, type CsvColumnDef, type CsvExportOptions, type DisplayCondition, type ExtensibleNode, type FieldOption, type FieldType, type FormAnalytics, type FormEvent, type FormEventType, type FormField, type FormPage, type FormPolicy, type FormResponse, type FormSchema, type FormStorageAdapter, type FormSubmission, type FormValue, type FormValues, type FormVersionRecord, type FormVersionState, type FormVersionStatus, type JsonValue, type LocalizedText, type MultiSelectField, type NumberField, type NumberQuestionAggregate, type NumericSummary, type OptionAggregate, type PagedSubmissionStorageAdapter, type PopulateTranslationOptions, type PublishDraftOptions, type Question, type QuestionAggregate, type QuestionType, type RatingField, type ResponseAccumulator, type ResponseAccumulatorOptions, type Result, type SchemaIssue, type SchemaStructureIssue, type SchemaStructureIssueType, type SchemaTranslations, type SchemaValidationResult, type SelectField, type StorageAdapter, type StreamCsvOptions, type SubmissionCursorValue, type SubmissionPage, type SubmissionPageQueryOptions, type SubmissionQueryOptions, type TextField, type TextQuestionAggregate, type TranslationAdapter, type TranslationReport, type TranslationSlot, type ValidateFormSchemaOptions, type ValidationCode, type ValidationError, type ValidationIssue, type VersionTransitionError, type WebhookConfig, type WebhookDispatchResult, aggregateResponses, assertValidFormSchema, assertVersionMutable, calculateChoiceDistribution, calculateCrossTabulation, calculateFieldVisibility, calculateNumericSummary, calculatePageVisibility, cloneVersionToDraft, collectSchemaLocales, createResponseAccumulator, createSubmission, decodeSubmissionCursor, deleteDraft, dispatchWebhook, encodeSubmissionCursor, escapeCsvCell, exportResponsesToCsv, exportResponsesToCsvStream, isDisplayConditionSatisfied, isQuestionVisible, normalizeSubmissionPageSize, populateSchemaTranslations, publishDraft, resolveFormTranslation, resolveLocalizedSchema, sanitizeSchema, selectVisibleAnswers, transformFieldType, validateAnswers, validateFormSchema, validatePageAnswers, validateSchemaStructure };
|