@form-engine-ts/core 4.4.0 → 4.6.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 +16 -0
- package/dist/index.cjs +442 -69
- package/dist/index.d.cts +80 -4
- package/dist/index.d.ts +80 -4
- package/dist/index.js +435 -69
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -148,7 +148,9 @@ interface FormPolicy {
|
|
|
148
148
|
/** Per-question-type defaults and immutable or bounded field constraints. */
|
|
149
149
|
readonly fieldConstraints?: Partial<Record<QuestionType, FieldConstraintRule>>;
|
|
150
150
|
}
|
|
151
|
-
type ConditionOperator = "equals" | "not_equals" | "contains" | "
|
|
151
|
+
type ConditionOperator = "equals" | "not_equals" | "contains" | "not_contains" | "is_empty" | "is_not_empty" | "greater_than" | "less_than"
|
|
152
|
+
/** @deprecated Use is_not_empty instead. */
|
|
153
|
+
| "not_empty";
|
|
152
154
|
type ConditionValue = string | number | boolean;
|
|
153
155
|
type JsonValue = string | number | boolean | null | readonly JsonValue[] | {
|
|
154
156
|
readonly [key: string]: JsonValue;
|
|
@@ -164,6 +166,19 @@ interface DisplayCondition {
|
|
|
164
166
|
readonly operator: ConditionOperator;
|
|
165
167
|
readonly value?: ConditionValue;
|
|
166
168
|
}
|
|
169
|
+
interface FieldDisplayCondition {
|
|
170
|
+
readonly fieldId: string;
|
|
171
|
+
readonly operator: ConditionOperator;
|
|
172
|
+
readonly value?: unknown;
|
|
173
|
+
}
|
|
174
|
+
interface DisplayConditionGroup {
|
|
175
|
+
readonly logic: "all" | "any";
|
|
176
|
+
readonly conditions: readonly (FieldDisplayCondition | DisplayConditionGroup)[];
|
|
177
|
+
}
|
|
178
|
+
interface DisplayRule {
|
|
179
|
+
readonly action: "show" | "hide";
|
|
180
|
+
readonly condition: DisplayConditionGroup;
|
|
181
|
+
}
|
|
167
182
|
interface LocalizedText {
|
|
168
183
|
readonly title?: string;
|
|
169
184
|
readonly description?: string;
|
|
@@ -185,6 +200,7 @@ interface BaseField extends ExtensibleNode {
|
|
|
185
200
|
readonly required: boolean;
|
|
186
201
|
readonly messages?: Partial<Record<ValidationCode, string>>;
|
|
187
202
|
readonly displayCondition?: DisplayCondition;
|
|
203
|
+
readonly displayRule?: DisplayRule;
|
|
188
204
|
readonly translations?: SchemaTranslations;
|
|
189
205
|
}
|
|
190
206
|
interface TextField extends BaseField {
|
|
@@ -240,6 +256,13 @@ interface FormSchema extends ExtensibleNode {
|
|
|
240
256
|
readonly translations?: SchemaTranslations;
|
|
241
257
|
readonly fields: readonly FormField[];
|
|
242
258
|
readonly pages?: readonly FormPage[];
|
|
259
|
+
readonly submissionSettings?: FormSubmissionSettings;
|
|
260
|
+
}
|
|
261
|
+
interface FormSubmissionSettings extends ExtensibleNode {
|
|
262
|
+
readonly showConfirmationBeforeSubmit?: boolean;
|
|
263
|
+
readonly confirmationRenderMode?: "dialog" | "inline" | "replace";
|
|
264
|
+
readonly confirmButtonLabel?: string;
|
|
265
|
+
readonly cancelButtonLabel?: string;
|
|
243
266
|
}
|
|
244
267
|
type FormValue = string | number | boolean | readonly string[] | undefined;
|
|
245
268
|
type FormValues = Readonly<Record<string, FormValue>>;
|
|
@@ -253,6 +276,7 @@ interface SchemaIssue {
|
|
|
253
276
|
readonly fieldId?: string;
|
|
254
277
|
readonly property?: string;
|
|
255
278
|
readonly expected?: boolean | number | readonly [number, number];
|
|
279
|
+
readonly cycle?: readonly string[];
|
|
256
280
|
}
|
|
257
281
|
type SchemaValidationResult = {
|
|
258
282
|
readonly valid: true;
|
|
@@ -615,6 +639,7 @@ interface SchemaStructureIssue {
|
|
|
615
639
|
readonly questionId: string;
|
|
616
640
|
readonly choiceId?: string;
|
|
617
641
|
readonly message: string;
|
|
642
|
+
readonly cycle?: readonly string[];
|
|
618
643
|
}
|
|
619
644
|
declare function validateSchemaStructure(schema: FormSchema): SchemaStructureIssue[];
|
|
620
645
|
declare function sanitizeSchema(schema: FormSchema, options?: SanitizeSchemaOptions): FormSchema;
|
|
@@ -641,34 +666,85 @@ interface TranslationSlot {
|
|
|
641
666
|
readonly existingText?: string;
|
|
642
667
|
readonly nodeMetadata?: Readonly<Record<string, JsonValue>>;
|
|
643
668
|
readonly existingTranslationMetadata?: Readonly<Record<string, JsonValue>>;
|
|
669
|
+
/** Canonical target information for workspace clients. */
|
|
670
|
+
readonly target?: {
|
|
671
|
+
readonly kind: "form" | "page" | "field" | "option";
|
|
672
|
+
readonly id?: string;
|
|
673
|
+
readonly property: "title" | "description" | "label" | "completionMessage";
|
|
674
|
+
};
|
|
675
|
+
readonly path?: string;
|
|
676
|
+
readonly sourceTextHash?: string;
|
|
677
|
+
readonly status?: TranslationStatus;
|
|
644
678
|
/** @deprecated Use nodeMetadata instead. */
|
|
645
679
|
readonly metadata?: Readonly<Record<string, JsonValue>>;
|
|
646
680
|
}
|
|
681
|
+
type TranslationStatus = "missing" | "translated" | "stale" | "manual" | "manual-stale";
|
|
682
|
+
interface CanonicalTranslationMetadata {
|
|
683
|
+
readonly sourceLocale: string;
|
|
684
|
+
readonly sourceTextHash: string;
|
|
685
|
+
readonly translationSource: "automatic" | "manual";
|
|
686
|
+
readonly translatedAt?: string;
|
|
687
|
+
readonly editedAt?: string;
|
|
688
|
+
}
|
|
689
|
+
interface LegacyTranslationMetadata {
|
|
690
|
+
readonly isManuallyEdited?: boolean;
|
|
691
|
+
readonly translationSource?: "MANUAL" | "AUTOMATIC" | "manual" | "automatic" | string;
|
|
692
|
+
readonly sourceTextHash?: string;
|
|
693
|
+
readonly sourceText?: string;
|
|
694
|
+
readonly sourceLocale?: string;
|
|
695
|
+
readonly translatedAt?: string;
|
|
696
|
+
readonly editedAt?: string;
|
|
697
|
+
readonly isManual?: boolean;
|
|
698
|
+
readonly [key: string]: unknown;
|
|
699
|
+
}
|
|
700
|
+
declare const isManualTranslationMetadata: (metadata?: LegacyTranslationMetadata | CanonicalTranslationMetadata) => boolean;
|
|
647
701
|
interface PopulateTranslationOptions {
|
|
648
|
-
readonly overwrite?: "missing-only" | "
|
|
702
|
+
readonly overwrite?: "all" | "missing-only" | "stale-and-missing";
|
|
703
|
+
readonly preserveManualTranslations?: boolean;
|
|
704
|
+
readonly markStaleTranslations?: boolean;
|
|
649
705
|
readonly shouldOverwrite?: (slot: TranslationSlot) => boolean;
|
|
650
706
|
readonly createMetadata?: (slot: TranslationSlot, translatedText: string) => Readonly<Record<string, JsonValue>>;
|
|
707
|
+
readonly isManualTranslation?: (metadata: unknown, context: {
|
|
708
|
+
readonly path: string;
|
|
709
|
+
readonly locale: string;
|
|
710
|
+
}) => boolean;
|
|
711
|
+
readonly normalizeMetadata?: (metadata: unknown, sourceText: string) => CanonicalTranslationMetadata;
|
|
651
712
|
/** Applies locale admission and count limits before the adapter is called. */
|
|
652
713
|
readonly policy?: Pick<FormPolicy, "allowedLocales" | "maxLocales">;
|
|
653
714
|
}
|
|
715
|
+
/** Compatibility alias for clients that used the pluralized options name. */
|
|
716
|
+
type PopulateTranslationsOptions = PopulateTranslationOptions;
|
|
654
717
|
interface TranslationReport {
|
|
655
718
|
readonly updatedSlots: readonly TranslationSlot[];
|
|
656
719
|
readonly skippedSlots: readonly TranslationSlot[];
|
|
657
|
-
|
|
720
|
+
readonly staleSlots?: readonly TranslationSlot[];
|
|
721
|
+
readonly skippedReasons?: Readonly<Record<string, "manual" | "unchanged" | "unsupported">>;
|
|
722
|
+
}
|
|
723
|
+
declare const computeSourceTextHash: (text: string) => string;
|
|
724
|
+
declare function getTranslationStatus(sourceText: string, translatedText: string | undefined, metadata: CanonicalTranslationMetadata | Readonly<Record<string, JsonValue>> | undefined): TranslationStatus;
|
|
725
|
+
declare const migrateSchemaTranslationMetadata: (schema: FormSchema, customMigrator?: (oldMeta: unknown, sourceText: string) => CanonicalTranslationMetadata) => FormSchema;
|
|
726
|
+
/** Removes a locale registration and every localized value and metadata entry for it. */
|
|
727
|
+
declare const removeLocaleFromSchema: (schema: FormSchema, localeToRemove: string) => FormSchema;
|
|
728
|
+
declare function collectTranslationSlots(schema: FormSchema, locale: string): readonly TranslationSlot[];
|
|
658
729
|
declare function resolveLocalizedSchema(schema: FormSchema, targetLocale?: string): FormSchema;
|
|
659
730
|
declare function populateSchemaTranslations(schema: FormSchema, targetLocales: readonly string[], adapter: AsyncTranslationAdapter, options?: PopulateTranslationOptions): Promise<{
|
|
660
731
|
readonly schema: FormSchema;
|
|
661
732
|
readonly report: TranslationReport;
|
|
662
733
|
}>;
|
|
734
|
+
declare function populateSchemaTranslations(schema: FormSchema, targetLocales: readonly string[], adapter: TranslationAdapter, options?: PopulateTranslationOptions): Promise<{
|
|
735
|
+
readonly schema: FormSchema;
|
|
736
|
+
readonly report: TranslationReport;
|
|
737
|
+
}>;
|
|
663
738
|
declare function resolveFormTranslation(schema: FormSchema, adapter: AsyncTranslationAdapter, targetLocale: string, sourceLocale?: string): Promise<FormSchema>;
|
|
664
739
|
|
|
665
740
|
declare function validateAnswers(schema: FormSchema, values: FormValues): AnswerValidationResult;
|
|
666
741
|
declare function validatePageAnswers(schema: FormSchema, pageIndex: number, values: FormValues): AnswerValidationResult;
|
|
667
742
|
|
|
743
|
+
declare function isDisplayConditionGroupSatisfied(group: DisplayConditionGroup, currentAnswers: Readonly<Record<string, unknown>>): boolean;
|
|
668
744
|
declare function isQuestionVisible(question: FormField, currentAnswers: Readonly<Record<string, unknown>>): boolean;
|
|
669
745
|
declare function isDisplayConditionSatisfied(condition: DisplayCondition | undefined, currentAnswers: Readonly<Record<string, unknown>>): boolean;
|
|
670
746
|
declare function calculatePageVisibility(schema: FormSchema, currentAnswers: Readonly<Record<string, unknown>>): Readonly<Record<string, boolean>>;
|
|
671
747
|
declare function calculateFieldVisibility(schema: FormSchema, currentAnswers: Readonly<Record<string, unknown>>): Readonly<Record<string, boolean>>;
|
|
672
748
|
declare function selectVisibleAnswers(schema: FormSchema, currentAnswers: FormValues): FormValues;
|
|
673
749
|
|
|
674
|
-
export { type AccumulatorReport, type AccumulatorResponse, type AccumulatorSkipReason, type AnswerValidationResult, type AsyncTranslationAdapter, type BaseField, type BaseFieldConstraintRule, type BuilderTranslationKey, type CheckboxField, type CheckboxQuestionAggregate, type ChoiceDistributionEntry, type ChoiceFieldConstraintRule, type ChoiceOption, type ChoiceQuestionAggregate, type CloneVersionOptions, type CollectedLocales, type ConditionOperator, type ConditionValue, type CreateSubmissionOptions, type CrossTabulationResult, type CsvColumnContext, type CsvColumnDef, type CsvExportOptions, DEFAULT_FIELD_TYPE_DEFINITIONS, type DeleteDraftOptions, type DisplayCondition, type ExtensibleNode, type FieldConstraintRule, type FieldOption, type FieldType, type FieldTypeDefinition, 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 NodeWritableStream, type NumberField, type NumberQuestionAggregate, type NumericSummary, type OptionAggregate, type PagedSubmissionStorageAdapter, type PaginationIteratorOptions, type PopulateTranslationOptions, type PublishDraftOptions, type PublishDraftResult, type Question, type QuestionAggregate, type QuestionType, type RatingField, type RatingFieldConstraintRule, type ResponseAccumulator, type ResponseAccumulatorOptions, type Result, type SanitizeSchemaOptions, type SchemaIssue, type SchemaStructureIssue, type SchemaStructureIssueType, type SchemaTranslations, type SchemaValidationResult, type SelectField, type StorageAdapter, type StorageCommitError, type StreamCsvOptions, type SubmissionCursorValue, type SubmissionFilter, type SubmissionPage, type SubmissionPageQueryOptions, type SubmissionQueryOptions, type TextAnswerCursorValue, type TextAnswerItem, type TextAnswerPage, type TextAnswerPageQueryOptions, type TextField, type TextFieldConstraintRule, type TextQuestionAggregate, type TranslationAdapter, type TranslationReport, type TranslationSlot, type ValidateFormSchemaOptions, type ValidationCode, type ValidationError, type ValidationIssue, type VersionTransitionError, type VersionTransitionEvent, type VersionTransitionPlan, type VersionedFormStorageAdapter, type WebhookConfig, type WebhookDispatchResult, aggregateResponses, assertValidFormSchema, assertVersionMutable, calculateChoiceDistribution, calculateCrossTabulation, calculateFieldVisibility, calculateNumericSummary, calculatePageVisibility, cloneVersionToDraft, collectSchemaLocales, createCloneTransitionPlan, createDeleteDraftTransitionPlan, createPublishTransitionPlan, createResponseAccumulator, createSubmission, decodeSubmissionCursor, decodeTextAnswerCursor, deleteDraft, dispatchWebhook, encodeSubmissionCursor, encodeTextAnswerCursor, escapeCsvCell, exportResponsesToCsv, exportResponsesToCsvStream, isDisplayConditionSatisfied, isQuestionVisible, iterateSubmissionPages, jsonValuesEqual, matchesSubmissionFilter, matchesSubmissionPageFilters, normalizeSubmissionPageSize, pipeResponsesToCsvStream, populateSchemaTranslations, publishDraft, resolveFormTranslation, resolveLocalizedSchema, sanitizeSchema, selectVisibleAnswers, transformFieldType, validateAnswers, validateFormSchema, validatePageAnswers, validateSchemaStructure };
|
|
750
|
+
export { type AccumulatorReport, type AccumulatorResponse, type AccumulatorSkipReason, type AnswerValidationResult, type AsyncTranslationAdapter, type BaseField, type BaseFieldConstraintRule, type BuilderTranslationKey, type CanonicalTranslationMetadata, type CheckboxField, type CheckboxQuestionAggregate, type ChoiceDistributionEntry, type ChoiceFieldConstraintRule, type ChoiceOption, type ChoiceQuestionAggregate, type CloneVersionOptions, type CollectedLocales, type ConditionOperator, type ConditionValue, type CreateSubmissionOptions, type CrossTabulationResult, type CsvColumnContext, type CsvColumnDef, type CsvExportOptions, DEFAULT_FIELD_TYPE_DEFINITIONS, type DeleteDraftOptions, type DisplayCondition, type DisplayConditionGroup, type DisplayRule, type ExtensibleNode, type FieldConstraintRule, type FieldDisplayCondition, type FieldOption, type FieldType, type FieldTypeDefinition, type FormAnalytics, type FormEvent, type FormEventType, type FormField, type FormPage, type FormPolicy, type FormResponse, type FormSchema, type FormStorageAdapter, type FormSubmission, type FormSubmissionSettings, type FormValue, type FormValues, type FormVersionRecord, type FormVersionState, type FormVersionStatus, type JsonValue, type LegacyTranslationMetadata, type LocalizedText, type MultiSelectField, type NodeWritableStream, type NumberField, type NumberQuestionAggregate, type NumericSummary, type OptionAggregate, type PagedSubmissionStorageAdapter, type PaginationIteratorOptions, type PopulateTranslationOptions, type PopulateTranslationsOptions, type PublishDraftOptions, type PublishDraftResult, type Question, type QuestionAggregate, type QuestionType, type RatingField, type RatingFieldConstraintRule, type ResponseAccumulator, type ResponseAccumulatorOptions, type Result, type SanitizeSchemaOptions, type SchemaIssue, type SchemaStructureIssue, type SchemaStructureIssueType, type SchemaTranslations, type SchemaValidationResult, type SelectField, type StorageAdapter, type StorageCommitError, type StreamCsvOptions, type SubmissionCursorValue, type SubmissionFilter, type SubmissionPage, type SubmissionPageQueryOptions, type SubmissionQueryOptions, type TextAnswerCursorValue, type TextAnswerItem, type TextAnswerPage, type TextAnswerPageQueryOptions, type TextField, type TextFieldConstraintRule, type TextQuestionAggregate, type TranslationAdapter, type TranslationReport, type TranslationSlot, type TranslationStatus, type ValidateFormSchemaOptions, type ValidationCode, type ValidationError, type ValidationIssue, type VersionTransitionError, type VersionTransitionEvent, type VersionTransitionPlan, type VersionedFormStorageAdapter, type WebhookConfig, type WebhookDispatchResult, aggregateResponses, assertValidFormSchema, assertVersionMutable, calculateChoiceDistribution, calculateCrossTabulation, calculateFieldVisibility, calculateNumericSummary, calculatePageVisibility, cloneVersionToDraft, collectSchemaLocales, collectTranslationSlots, computeSourceTextHash, createCloneTransitionPlan, createDeleteDraftTransitionPlan, createPublishTransitionPlan, createResponseAccumulator, createSubmission, decodeSubmissionCursor, decodeTextAnswerCursor, deleteDraft, dispatchWebhook, encodeSubmissionCursor, encodeTextAnswerCursor, escapeCsvCell, exportResponsesToCsv, exportResponsesToCsvStream, getTranslationStatus, isDisplayConditionGroupSatisfied, isDisplayConditionSatisfied, isManualTranslationMetadata, isQuestionVisible, iterateSubmissionPages, jsonValuesEqual, matchesSubmissionFilter, matchesSubmissionPageFilters, migrateSchemaTranslationMetadata, normalizeSubmissionPageSize, pipeResponsesToCsvStream, populateSchemaTranslations, publishDraft, removeLocaleFromSchema, resolveFormTranslation, resolveLocalizedSchema, sanitizeSchema, selectVisibleAnswers, transformFieldType, validateAnswers, validateFormSchema, validatePageAnswers, validateSchemaStructure };
|
package/dist/index.d.ts
CHANGED
|
@@ -148,7 +148,9 @@ interface FormPolicy {
|
|
|
148
148
|
/** Per-question-type defaults and immutable or bounded field constraints. */
|
|
149
149
|
readonly fieldConstraints?: Partial<Record<QuestionType, FieldConstraintRule>>;
|
|
150
150
|
}
|
|
151
|
-
type ConditionOperator = "equals" | "not_equals" | "contains" | "
|
|
151
|
+
type ConditionOperator = "equals" | "not_equals" | "contains" | "not_contains" | "is_empty" | "is_not_empty" | "greater_than" | "less_than"
|
|
152
|
+
/** @deprecated Use is_not_empty instead. */
|
|
153
|
+
| "not_empty";
|
|
152
154
|
type ConditionValue = string | number | boolean;
|
|
153
155
|
type JsonValue = string | number | boolean | null | readonly JsonValue[] | {
|
|
154
156
|
readonly [key: string]: JsonValue;
|
|
@@ -164,6 +166,19 @@ interface DisplayCondition {
|
|
|
164
166
|
readonly operator: ConditionOperator;
|
|
165
167
|
readonly value?: ConditionValue;
|
|
166
168
|
}
|
|
169
|
+
interface FieldDisplayCondition {
|
|
170
|
+
readonly fieldId: string;
|
|
171
|
+
readonly operator: ConditionOperator;
|
|
172
|
+
readonly value?: unknown;
|
|
173
|
+
}
|
|
174
|
+
interface DisplayConditionGroup {
|
|
175
|
+
readonly logic: "all" | "any";
|
|
176
|
+
readonly conditions: readonly (FieldDisplayCondition | DisplayConditionGroup)[];
|
|
177
|
+
}
|
|
178
|
+
interface DisplayRule {
|
|
179
|
+
readonly action: "show" | "hide";
|
|
180
|
+
readonly condition: DisplayConditionGroup;
|
|
181
|
+
}
|
|
167
182
|
interface LocalizedText {
|
|
168
183
|
readonly title?: string;
|
|
169
184
|
readonly description?: string;
|
|
@@ -185,6 +200,7 @@ interface BaseField extends ExtensibleNode {
|
|
|
185
200
|
readonly required: boolean;
|
|
186
201
|
readonly messages?: Partial<Record<ValidationCode, string>>;
|
|
187
202
|
readonly displayCondition?: DisplayCondition;
|
|
203
|
+
readonly displayRule?: DisplayRule;
|
|
188
204
|
readonly translations?: SchemaTranslations;
|
|
189
205
|
}
|
|
190
206
|
interface TextField extends BaseField {
|
|
@@ -240,6 +256,13 @@ interface FormSchema extends ExtensibleNode {
|
|
|
240
256
|
readonly translations?: SchemaTranslations;
|
|
241
257
|
readonly fields: readonly FormField[];
|
|
242
258
|
readonly pages?: readonly FormPage[];
|
|
259
|
+
readonly submissionSettings?: FormSubmissionSettings;
|
|
260
|
+
}
|
|
261
|
+
interface FormSubmissionSettings extends ExtensibleNode {
|
|
262
|
+
readonly showConfirmationBeforeSubmit?: boolean;
|
|
263
|
+
readonly confirmationRenderMode?: "dialog" | "inline" | "replace";
|
|
264
|
+
readonly confirmButtonLabel?: string;
|
|
265
|
+
readonly cancelButtonLabel?: string;
|
|
243
266
|
}
|
|
244
267
|
type FormValue = string | number | boolean | readonly string[] | undefined;
|
|
245
268
|
type FormValues = Readonly<Record<string, FormValue>>;
|
|
@@ -253,6 +276,7 @@ interface SchemaIssue {
|
|
|
253
276
|
readonly fieldId?: string;
|
|
254
277
|
readonly property?: string;
|
|
255
278
|
readonly expected?: boolean | number | readonly [number, number];
|
|
279
|
+
readonly cycle?: readonly string[];
|
|
256
280
|
}
|
|
257
281
|
type SchemaValidationResult = {
|
|
258
282
|
readonly valid: true;
|
|
@@ -615,6 +639,7 @@ interface SchemaStructureIssue {
|
|
|
615
639
|
readonly questionId: string;
|
|
616
640
|
readonly choiceId?: string;
|
|
617
641
|
readonly message: string;
|
|
642
|
+
readonly cycle?: readonly string[];
|
|
618
643
|
}
|
|
619
644
|
declare function validateSchemaStructure(schema: FormSchema): SchemaStructureIssue[];
|
|
620
645
|
declare function sanitizeSchema(schema: FormSchema, options?: SanitizeSchemaOptions): FormSchema;
|
|
@@ -641,34 +666,85 @@ interface TranslationSlot {
|
|
|
641
666
|
readonly existingText?: string;
|
|
642
667
|
readonly nodeMetadata?: Readonly<Record<string, JsonValue>>;
|
|
643
668
|
readonly existingTranslationMetadata?: Readonly<Record<string, JsonValue>>;
|
|
669
|
+
/** Canonical target information for workspace clients. */
|
|
670
|
+
readonly target?: {
|
|
671
|
+
readonly kind: "form" | "page" | "field" | "option";
|
|
672
|
+
readonly id?: string;
|
|
673
|
+
readonly property: "title" | "description" | "label" | "completionMessage";
|
|
674
|
+
};
|
|
675
|
+
readonly path?: string;
|
|
676
|
+
readonly sourceTextHash?: string;
|
|
677
|
+
readonly status?: TranslationStatus;
|
|
644
678
|
/** @deprecated Use nodeMetadata instead. */
|
|
645
679
|
readonly metadata?: Readonly<Record<string, JsonValue>>;
|
|
646
680
|
}
|
|
681
|
+
type TranslationStatus = "missing" | "translated" | "stale" | "manual" | "manual-stale";
|
|
682
|
+
interface CanonicalTranslationMetadata {
|
|
683
|
+
readonly sourceLocale: string;
|
|
684
|
+
readonly sourceTextHash: string;
|
|
685
|
+
readonly translationSource: "automatic" | "manual";
|
|
686
|
+
readonly translatedAt?: string;
|
|
687
|
+
readonly editedAt?: string;
|
|
688
|
+
}
|
|
689
|
+
interface LegacyTranslationMetadata {
|
|
690
|
+
readonly isManuallyEdited?: boolean;
|
|
691
|
+
readonly translationSource?: "MANUAL" | "AUTOMATIC" | "manual" | "automatic" | string;
|
|
692
|
+
readonly sourceTextHash?: string;
|
|
693
|
+
readonly sourceText?: string;
|
|
694
|
+
readonly sourceLocale?: string;
|
|
695
|
+
readonly translatedAt?: string;
|
|
696
|
+
readonly editedAt?: string;
|
|
697
|
+
readonly isManual?: boolean;
|
|
698
|
+
readonly [key: string]: unknown;
|
|
699
|
+
}
|
|
700
|
+
declare const isManualTranslationMetadata: (metadata?: LegacyTranslationMetadata | CanonicalTranslationMetadata) => boolean;
|
|
647
701
|
interface PopulateTranslationOptions {
|
|
648
|
-
readonly overwrite?: "missing-only" | "
|
|
702
|
+
readonly overwrite?: "all" | "missing-only" | "stale-and-missing";
|
|
703
|
+
readonly preserveManualTranslations?: boolean;
|
|
704
|
+
readonly markStaleTranslations?: boolean;
|
|
649
705
|
readonly shouldOverwrite?: (slot: TranslationSlot) => boolean;
|
|
650
706
|
readonly createMetadata?: (slot: TranslationSlot, translatedText: string) => Readonly<Record<string, JsonValue>>;
|
|
707
|
+
readonly isManualTranslation?: (metadata: unknown, context: {
|
|
708
|
+
readonly path: string;
|
|
709
|
+
readonly locale: string;
|
|
710
|
+
}) => boolean;
|
|
711
|
+
readonly normalizeMetadata?: (metadata: unknown, sourceText: string) => CanonicalTranslationMetadata;
|
|
651
712
|
/** Applies locale admission and count limits before the adapter is called. */
|
|
652
713
|
readonly policy?: Pick<FormPolicy, "allowedLocales" | "maxLocales">;
|
|
653
714
|
}
|
|
715
|
+
/** Compatibility alias for clients that used the pluralized options name. */
|
|
716
|
+
type PopulateTranslationsOptions = PopulateTranslationOptions;
|
|
654
717
|
interface TranslationReport {
|
|
655
718
|
readonly updatedSlots: readonly TranslationSlot[];
|
|
656
719
|
readonly skippedSlots: readonly TranslationSlot[];
|
|
657
|
-
|
|
720
|
+
readonly staleSlots?: readonly TranslationSlot[];
|
|
721
|
+
readonly skippedReasons?: Readonly<Record<string, "manual" | "unchanged" | "unsupported">>;
|
|
722
|
+
}
|
|
723
|
+
declare const computeSourceTextHash: (text: string) => string;
|
|
724
|
+
declare function getTranslationStatus(sourceText: string, translatedText: string | undefined, metadata: CanonicalTranslationMetadata | Readonly<Record<string, JsonValue>> | undefined): TranslationStatus;
|
|
725
|
+
declare const migrateSchemaTranslationMetadata: (schema: FormSchema, customMigrator?: (oldMeta: unknown, sourceText: string) => CanonicalTranslationMetadata) => FormSchema;
|
|
726
|
+
/** Removes a locale registration and every localized value and metadata entry for it. */
|
|
727
|
+
declare const removeLocaleFromSchema: (schema: FormSchema, localeToRemove: string) => FormSchema;
|
|
728
|
+
declare function collectTranslationSlots(schema: FormSchema, locale: string): readonly TranslationSlot[];
|
|
658
729
|
declare function resolveLocalizedSchema(schema: FormSchema, targetLocale?: string): FormSchema;
|
|
659
730
|
declare function populateSchemaTranslations(schema: FormSchema, targetLocales: readonly string[], adapter: AsyncTranslationAdapter, options?: PopulateTranslationOptions): Promise<{
|
|
660
731
|
readonly schema: FormSchema;
|
|
661
732
|
readonly report: TranslationReport;
|
|
662
733
|
}>;
|
|
734
|
+
declare function populateSchemaTranslations(schema: FormSchema, targetLocales: readonly string[], adapter: TranslationAdapter, options?: PopulateTranslationOptions): Promise<{
|
|
735
|
+
readonly schema: FormSchema;
|
|
736
|
+
readonly report: TranslationReport;
|
|
737
|
+
}>;
|
|
663
738
|
declare function resolveFormTranslation(schema: FormSchema, adapter: AsyncTranslationAdapter, targetLocale: string, sourceLocale?: string): Promise<FormSchema>;
|
|
664
739
|
|
|
665
740
|
declare function validateAnswers(schema: FormSchema, values: FormValues): AnswerValidationResult;
|
|
666
741
|
declare function validatePageAnswers(schema: FormSchema, pageIndex: number, values: FormValues): AnswerValidationResult;
|
|
667
742
|
|
|
743
|
+
declare function isDisplayConditionGroupSatisfied(group: DisplayConditionGroup, currentAnswers: Readonly<Record<string, unknown>>): boolean;
|
|
668
744
|
declare function isQuestionVisible(question: FormField, currentAnswers: Readonly<Record<string, unknown>>): boolean;
|
|
669
745
|
declare function isDisplayConditionSatisfied(condition: DisplayCondition | undefined, currentAnswers: Readonly<Record<string, unknown>>): boolean;
|
|
670
746
|
declare function calculatePageVisibility(schema: FormSchema, currentAnswers: Readonly<Record<string, unknown>>): Readonly<Record<string, boolean>>;
|
|
671
747
|
declare function calculateFieldVisibility(schema: FormSchema, currentAnswers: Readonly<Record<string, unknown>>): Readonly<Record<string, boolean>>;
|
|
672
748
|
declare function selectVisibleAnswers(schema: FormSchema, currentAnswers: FormValues): FormValues;
|
|
673
749
|
|
|
674
|
-
export { type AccumulatorReport, type AccumulatorResponse, type AccumulatorSkipReason, type AnswerValidationResult, type AsyncTranslationAdapter, type BaseField, type BaseFieldConstraintRule, type BuilderTranslationKey, type CheckboxField, type CheckboxQuestionAggregate, type ChoiceDistributionEntry, type ChoiceFieldConstraintRule, type ChoiceOption, type ChoiceQuestionAggregate, type CloneVersionOptions, type CollectedLocales, type ConditionOperator, type ConditionValue, type CreateSubmissionOptions, type CrossTabulationResult, type CsvColumnContext, type CsvColumnDef, type CsvExportOptions, DEFAULT_FIELD_TYPE_DEFINITIONS, type DeleteDraftOptions, type DisplayCondition, type ExtensibleNode, type FieldConstraintRule, type FieldOption, type FieldType, type FieldTypeDefinition, 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 NodeWritableStream, type NumberField, type NumberQuestionAggregate, type NumericSummary, type OptionAggregate, type PagedSubmissionStorageAdapter, type PaginationIteratorOptions, type PopulateTranslationOptions, type PublishDraftOptions, type PublishDraftResult, type Question, type QuestionAggregate, type QuestionType, type RatingField, type RatingFieldConstraintRule, type ResponseAccumulator, type ResponseAccumulatorOptions, type Result, type SanitizeSchemaOptions, type SchemaIssue, type SchemaStructureIssue, type SchemaStructureIssueType, type SchemaTranslations, type SchemaValidationResult, type SelectField, type StorageAdapter, type StorageCommitError, type StreamCsvOptions, type SubmissionCursorValue, type SubmissionFilter, type SubmissionPage, type SubmissionPageQueryOptions, type SubmissionQueryOptions, type TextAnswerCursorValue, type TextAnswerItem, type TextAnswerPage, type TextAnswerPageQueryOptions, type TextField, type TextFieldConstraintRule, type TextQuestionAggregate, type TranslationAdapter, type TranslationReport, type TranslationSlot, type ValidateFormSchemaOptions, type ValidationCode, type ValidationError, type ValidationIssue, type VersionTransitionError, type VersionTransitionEvent, type VersionTransitionPlan, type VersionedFormStorageAdapter, type WebhookConfig, type WebhookDispatchResult, aggregateResponses, assertValidFormSchema, assertVersionMutable, calculateChoiceDistribution, calculateCrossTabulation, calculateFieldVisibility, calculateNumericSummary, calculatePageVisibility, cloneVersionToDraft, collectSchemaLocales, createCloneTransitionPlan, createDeleteDraftTransitionPlan, createPublishTransitionPlan, createResponseAccumulator, createSubmission, decodeSubmissionCursor, decodeTextAnswerCursor, deleteDraft, dispatchWebhook, encodeSubmissionCursor, encodeTextAnswerCursor, escapeCsvCell, exportResponsesToCsv, exportResponsesToCsvStream, isDisplayConditionSatisfied, isQuestionVisible, iterateSubmissionPages, jsonValuesEqual, matchesSubmissionFilter, matchesSubmissionPageFilters, normalizeSubmissionPageSize, pipeResponsesToCsvStream, populateSchemaTranslations, publishDraft, resolveFormTranslation, resolveLocalizedSchema, sanitizeSchema, selectVisibleAnswers, transformFieldType, validateAnswers, validateFormSchema, validatePageAnswers, validateSchemaStructure };
|
|
750
|
+
export { type AccumulatorReport, type AccumulatorResponse, type AccumulatorSkipReason, type AnswerValidationResult, type AsyncTranslationAdapter, type BaseField, type BaseFieldConstraintRule, type BuilderTranslationKey, type CanonicalTranslationMetadata, type CheckboxField, type CheckboxQuestionAggregate, type ChoiceDistributionEntry, type ChoiceFieldConstraintRule, type ChoiceOption, type ChoiceQuestionAggregate, type CloneVersionOptions, type CollectedLocales, type ConditionOperator, type ConditionValue, type CreateSubmissionOptions, type CrossTabulationResult, type CsvColumnContext, type CsvColumnDef, type CsvExportOptions, DEFAULT_FIELD_TYPE_DEFINITIONS, type DeleteDraftOptions, type DisplayCondition, type DisplayConditionGroup, type DisplayRule, type ExtensibleNode, type FieldConstraintRule, type FieldDisplayCondition, type FieldOption, type FieldType, type FieldTypeDefinition, type FormAnalytics, type FormEvent, type FormEventType, type FormField, type FormPage, type FormPolicy, type FormResponse, type FormSchema, type FormStorageAdapter, type FormSubmission, type FormSubmissionSettings, type FormValue, type FormValues, type FormVersionRecord, type FormVersionState, type FormVersionStatus, type JsonValue, type LegacyTranslationMetadata, type LocalizedText, type MultiSelectField, type NodeWritableStream, type NumberField, type NumberQuestionAggregate, type NumericSummary, type OptionAggregate, type PagedSubmissionStorageAdapter, type PaginationIteratorOptions, type PopulateTranslationOptions, type PopulateTranslationsOptions, type PublishDraftOptions, type PublishDraftResult, type Question, type QuestionAggregate, type QuestionType, type RatingField, type RatingFieldConstraintRule, type ResponseAccumulator, type ResponseAccumulatorOptions, type Result, type SanitizeSchemaOptions, type SchemaIssue, type SchemaStructureIssue, type SchemaStructureIssueType, type SchemaTranslations, type SchemaValidationResult, type SelectField, type StorageAdapter, type StorageCommitError, type StreamCsvOptions, type SubmissionCursorValue, type SubmissionFilter, type SubmissionPage, type SubmissionPageQueryOptions, type SubmissionQueryOptions, type TextAnswerCursorValue, type TextAnswerItem, type TextAnswerPage, type TextAnswerPageQueryOptions, type TextField, type TextFieldConstraintRule, type TextQuestionAggregate, type TranslationAdapter, type TranslationReport, type TranslationSlot, type TranslationStatus, type ValidateFormSchemaOptions, type ValidationCode, type ValidationError, type ValidationIssue, type VersionTransitionError, type VersionTransitionEvent, type VersionTransitionPlan, type VersionedFormStorageAdapter, type WebhookConfig, type WebhookDispatchResult, aggregateResponses, assertValidFormSchema, assertVersionMutable, calculateChoiceDistribution, calculateCrossTabulation, calculateFieldVisibility, calculateNumericSummary, calculatePageVisibility, cloneVersionToDraft, collectSchemaLocales, collectTranslationSlots, computeSourceTextHash, createCloneTransitionPlan, createDeleteDraftTransitionPlan, createPublishTransitionPlan, createResponseAccumulator, createSubmission, decodeSubmissionCursor, decodeTextAnswerCursor, deleteDraft, dispatchWebhook, encodeSubmissionCursor, encodeTextAnswerCursor, escapeCsvCell, exportResponsesToCsv, exportResponsesToCsvStream, getTranslationStatus, isDisplayConditionGroupSatisfied, isDisplayConditionSatisfied, isManualTranslationMetadata, isQuestionVisible, iterateSubmissionPages, jsonValuesEqual, matchesSubmissionFilter, matchesSubmissionPageFilters, migrateSchemaTranslationMetadata, normalizeSubmissionPageSize, pipeResponsesToCsvStream, populateSchemaTranslations, publishDraft, removeLocaleFromSchema, resolveFormTranslation, resolveLocalizedSchema, sanitizeSchema, selectVisibleAnswers, transformFieldType, validateAnswers, validateFormSchema, validatePageAnswers, validateSchemaStructure };
|