@form-engine-ts/core 2.3.0 → 2.5.1

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/dist/index.d.cts CHANGED
@@ -1,3 +1,82 @@
1
+ type Result<T, E> = {
2
+ readonly success: true;
3
+ readonly value: T;
4
+ } | {
5
+ readonly success: false;
6
+ readonly error: E;
7
+ };
8
+ type FormVersionStatus = "draft" | "published" | "archived";
9
+ interface FormVersionRecord {
10
+ readonly formId: string;
11
+ readonly version: number;
12
+ readonly status: FormVersionStatus;
13
+ readonly schema: FormSchema;
14
+ readonly createdAt: string;
15
+ readonly publishedAt?: string;
16
+ readonly archivedAt?: string;
17
+ }
18
+ interface FormVersionState {
19
+ readonly formId: string;
20
+ readonly draftVersion?: number;
21
+ readonly publishedVersion?: number;
22
+ readonly nextVersion: number;
23
+ readonly revision: number;
24
+ }
25
+ type VersionTransitionError = {
26
+ readonly type: "draft_already_exists";
27
+ readonly currentDraftVersion: number;
28
+ } | {
29
+ readonly type: "draft_not_found";
30
+ } | {
31
+ readonly type: "revision_conflict";
32
+ readonly expectedRevision: number;
33
+ readonly actualRevision: number;
34
+ } | {
35
+ readonly type: "invalid_source_version";
36
+ readonly requestedVersion: number;
37
+ readonly publishedVersion?: number;
38
+ } | {
39
+ readonly type: "version_immutable";
40
+ readonly status: FormVersionStatus;
41
+ } | {
42
+ readonly type: "max_version_exceeded";
43
+ readonly max: number;
44
+ } | {
45
+ readonly type: "validation_failed";
46
+ readonly issues: readonly SchemaIssue[];
47
+ };
48
+ interface CloneVersionOptions {
49
+ readonly maxVersions?: number;
50
+ readonly expectedRevision?: number;
51
+ /** Additional known published versions that may be used as a clone source. */
52
+ readonly allowedSourceVersions?: readonly number[];
53
+ }
54
+ interface PublishDraftOptions {
55
+ readonly expectedRevision?: number;
56
+ readonly validate?: (schema: FormSchema) => boolean | readonly SchemaIssue[];
57
+ /** Supplies deterministic record timestamps while keeping the transition pure. */
58
+ readonly timestamp?: string;
59
+ }
60
+ interface DeleteDraftOptions {
61
+ readonly expectedRevision?: number;
62
+ }
63
+ interface PublishDraftResult {
64
+ readonly nextState: FormVersionState;
65
+ readonly publishedRecord: FormVersionRecord;
66
+ readonly archivedRecords: readonly FormVersionRecord[];
67
+ /** @deprecated Read archivedRecords instead. */
68
+ readonly archivedVersion?: number;
69
+ }
70
+ declare function cloneVersionToDraft(state: FormVersionState, sourceSchema: FormSchema, options?: CloneVersionOptions): Result<{
71
+ readonly nextState: FormVersionState;
72
+ readonly draftSchema: FormSchema;
73
+ }, VersionTransitionError>;
74
+ declare function publishDraft(state: FormVersionState, draftSchema: FormSchema, options?: PublishDraftOptions): Result<PublishDraftResult, VersionTransitionError>;
75
+ declare function deleteDraft(state: FormVersionState, options?: DeleteDraftOptions): Result<{
76
+ readonly nextState: FormVersionState;
77
+ }, VersionTransitionError>;
78
+ declare function assertVersionMutable(status: FormVersionStatus): void;
79
+
1
80
  type FieldType = "text" | "textarea" | "number" | "rating" | "select" | "multi-select" | "checkbox" | "radio";
2
81
  interface FormPolicy {
3
82
  readonly allowedFieldTypes?: readonly FieldType[];
@@ -163,6 +242,37 @@ interface FormStorageAdapter extends StorageAdapter {
163
242
  deleteSchema(formId: string, formVersion: number): Promise<void>;
164
243
  deleteSubmission(submissionId: string): Promise<void>;
165
244
  }
245
+ interface SubmissionPageQueryOptions {
246
+ readonly version?: number;
247
+ readonly cursor?: string;
248
+ readonly pageSize?: number;
249
+ readonly since?: string;
250
+ readonly until?: string;
251
+ readonly locale?: string;
252
+ readonly filter?: (submission: FormSubmission) => boolean;
253
+ readonly metadataFilters?: Readonly<Record<string, JsonValue>>;
254
+ }
255
+ interface SubmissionPage {
256
+ readonly items: readonly FormSubmission[];
257
+ readonly nextCursor?: string;
258
+ readonly hasMore: boolean;
259
+ }
260
+ interface PagedSubmissionStorageAdapter extends FormStorageAdapter {
261
+ listSubmissionPage(formId: string, options?: SubmissionPageQueryOptions): Promise<SubmissionPage>;
262
+ }
263
+ interface VersionTransitionPlan {
264
+ readonly state: FormVersionState;
265
+ readonly expectedRevision: number;
266
+ readonly draftToPublish?: FormSchema;
267
+ readonly versionsToArchive: readonly number[];
268
+ readonly versionsToDelete: readonly number[];
269
+ }
270
+ interface VersionedFormStorageAdapter extends FormStorageAdapter {
271
+ commitVersionTransition(plan: VersionTransitionPlan): Promise<{
272
+ readonly success: boolean;
273
+ readonly error?: string;
274
+ }>;
275
+ }
166
276
  interface BaseQuestionAggregate {
167
277
  readonly fieldId: string;
168
278
  readonly answeredCount: number;
@@ -207,6 +317,7 @@ type ChoiceOption = FieldOption;
207
317
  interface FormResponse extends ExtensibleNode {
208
318
  readonly responseId: string;
209
319
  readonly formId: string;
320
+ readonly formVersion?: number;
210
321
  readonly sourceLocale?: string;
211
322
  readonly answers: Readonly<Record<string, unknown>>;
212
323
  readonly submittedAt: string;
@@ -234,11 +345,59 @@ declare function calculateChoiceDistribution(responses: readonly FormSubmission[
234
345
  declare function calculateNumericSummary(responses: readonly FormSubmission[], questionId: string): NumericSummary;
235
346
  declare function calculateCrossTabulation(responses: readonly FormSubmission[], rowQuestionId: string, colQuestionId: string): CrossTabulationResult;
236
347
  declare function aggregateResponses(schema: FormSchema, submissions: readonly FormSubmission[]): FormAnalytics;
348
+ type AccumulatorResponse = FormSubmission | FormResponse;
349
+ type AccumulatorSkipReason = "form_id_mismatch" | "version_mismatch" | "invalid_structure";
350
+ interface AccumulatorReport {
351
+ readonly processedCount: number;
352
+ readonly skippedCount: number;
353
+ readonly skipReasons: readonly {
354
+ readonly responseId: string;
355
+ readonly reason: AccumulatorSkipReason;
356
+ }[];
357
+ }
358
+ interface ResponseAccumulator {
359
+ add(submission: AccumulatorResponse): {
360
+ readonly success: boolean;
361
+ readonly skipped?: boolean;
362
+ readonly error?: string;
363
+ };
364
+ addMany(submissions: Iterable<AccumulatorResponse>): AccumulatorReport;
365
+ merge(other: ResponseAccumulator): ResponseAccumulator;
366
+ finalize(): FormAnalytics;
367
+ getReport(): AccumulatorReport;
368
+ }
369
+ interface ResponseAccumulatorOptions {
370
+ readonly mode?: "strict" | "lenient";
371
+ }
372
+ declare function createResponseAccumulator(schema: FormSchema, options?: ResponseAccumulatorOptions): ResponseAccumulator;
237
373
  declare function escapeCsvCell(value: string | number | boolean | null | undefined, neutralizeFormulas?: boolean): string;
238
374
  interface CsvExportOptions {
239
375
  readonly withBom?: boolean;
240
376
  readonly neutralizeFormulas?: boolean;
241
377
  }
378
+ interface CsvColumnDef {
379
+ readonly header: string;
380
+ readonly getValue: (context: CsvColumnContext) => string | number | boolean | null | undefined;
381
+ }
382
+ interface CsvColumnContext extends FormResponse {
383
+ readonly submission: FormResponse;
384
+ readonly formVersion: number;
385
+ readonly schema: FormSchema;
386
+ }
387
+ interface StreamCsvOptions extends CsvExportOptions {
388
+ readonly columns?: readonly CsvColumnDef[];
389
+ readonly includeDefaultColumns?: boolean;
390
+ }
391
+ declare function exportResponsesToCsvStream(schema: FormSchema, submissions: AsyncIterable<AccumulatorResponse>, options?: StreamCsvOptions): AsyncIterable<string>;
392
+ interface NodeWritableStream {
393
+ write(chunk: Uint8Array): boolean;
394
+ once(event: "drain", listener: () => void): unknown;
395
+ once(event: "error", listener: (error: Error) => void): unknown;
396
+ removeListener(event: "drain", listener: () => void): unknown;
397
+ removeListener(event: "error", listener: (error: Error) => void): unknown;
398
+ end(callback: () => void): unknown;
399
+ }
400
+ declare function pipeResponsesToCsvStream(schema: FormSchema, submissions: AsyncIterable<AccumulatorResponse>, writable: WritableStream<Uint8Array> | NodeWritableStream, options?: StreamCsvOptions): Promise<void>;
242
401
  declare function exportResponsesToCsv(schema: FormSchema, responses: readonly FormSubmission[], options?: CsvExportOptions): string;
243
402
 
244
403
  type FormEventType = "response.submitted" | "schema.updated";
@@ -268,6 +427,15 @@ declare function dispatchWebhook<T>(event: FormEvent<T>, config: WebhookConfig,
268
427
  */
269
428
  declare function transformFieldType(field: FormField, nextType: QuestionType): FormField;
270
429
 
430
+ interface SubmissionCursorValue {
431
+ readonly submittedAt: string;
432
+ readonly responseId: string;
433
+ }
434
+ declare function encodeSubmissionCursor(value: SubmissionCursorValue): string;
435
+ declare function decodeSubmissionCursor(cursor: string): SubmissionCursorValue;
436
+ declare function normalizeSubmissionPageSize(pageSize: number | undefined, fallback?: number): number;
437
+ declare function matchesSubmissionPageFilters(submission: FormSubmission, options: Pick<SubmissionPageQueryOptions, "filter" | "metadataFilters">): boolean;
438
+
271
439
  interface CollectedLocales {
272
440
  readonly defaultLocale?: string;
273
441
  readonly supportedLocales: readonly string[];
@@ -341,4 +509,4 @@ declare function calculatePageVisibility(schema: FormSchema, currentAnswers: Rea
341
509
  declare function calculateFieldVisibility(schema: FormSchema, currentAnswers: Readonly<Record<string, unknown>>): Readonly<Record<string, boolean>>;
342
510
  declare function selectVisibleAnswers(schema: FormSchema, currentAnswers: FormValues): FormValues;
343
511
 
344
- export { type AnswerValidationResult, type AsyncTranslationAdapter, type BaseField, type CheckboxField, type CheckboxQuestionAggregate, type ChoiceDistributionEntry, type ChoiceOption, type ChoiceQuestionAggregate, type CollectedLocales, 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, collectSchemaLocales, createSubmission, dispatchWebhook, escapeCsvCell, exportResponsesToCsv, isDisplayConditionSatisfied, isQuestionVisible, populateSchemaTranslations, resolveFormTranslation, resolveLocalizedSchema, sanitizeSchema, selectVisibleAnswers, transformFieldType, validateAnswers, validateFormSchema, validatePageAnswers, validateSchemaStructure };
512
+ export { type AccumulatorReport, type AccumulatorResponse, type AccumulatorSkipReason, 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 CsvColumnContext, type CsvColumnDef, type CsvExportOptions, type DeleteDraftOptions, 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 NodeWritableStream, type NumberField, type NumberQuestionAggregate, type NumericSummary, type OptionAggregate, type PagedSubmissionStorageAdapter, type PopulateTranslationOptions, type PublishDraftOptions, type PublishDraftResult, 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 VersionTransitionPlan, type VersionedFormStorageAdapter, 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, matchesSubmissionPageFilters, normalizeSubmissionPageSize, pipeResponsesToCsvStream, populateSchemaTranslations, publishDraft, resolveFormTranslation, resolveLocalizedSchema, sanitizeSchema, selectVisibleAnswers, transformFieldType, validateAnswers, validateFormSchema, validatePageAnswers, validateSchemaStructure };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,82 @@
1
+ type Result<T, E> = {
2
+ readonly success: true;
3
+ readonly value: T;
4
+ } | {
5
+ readonly success: false;
6
+ readonly error: E;
7
+ };
8
+ type FormVersionStatus = "draft" | "published" | "archived";
9
+ interface FormVersionRecord {
10
+ readonly formId: string;
11
+ readonly version: number;
12
+ readonly status: FormVersionStatus;
13
+ readonly schema: FormSchema;
14
+ readonly createdAt: string;
15
+ readonly publishedAt?: string;
16
+ readonly archivedAt?: string;
17
+ }
18
+ interface FormVersionState {
19
+ readonly formId: string;
20
+ readonly draftVersion?: number;
21
+ readonly publishedVersion?: number;
22
+ readonly nextVersion: number;
23
+ readonly revision: number;
24
+ }
25
+ type VersionTransitionError = {
26
+ readonly type: "draft_already_exists";
27
+ readonly currentDraftVersion: number;
28
+ } | {
29
+ readonly type: "draft_not_found";
30
+ } | {
31
+ readonly type: "revision_conflict";
32
+ readonly expectedRevision: number;
33
+ readonly actualRevision: number;
34
+ } | {
35
+ readonly type: "invalid_source_version";
36
+ readonly requestedVersion: number;
37
+ readonly publishedVersion?: number;
38
+ } | {
39
+ readonly type: "version_immutable";
40
+ readonly status: FormVersionStatus;
41
+ } | {
42
+ readonly type: "max_version_exceeded";
43
+ readonly max: number;
44
+ } | {
45
+ readonly type: "validation_failed";
46
+ readonly issues: readonly SchemaIssue[];
47
+ };
48
+ interface CloneVersionOptions {
49
+ readonly maxVersions?: number;
50
+ readonly expectedRevision?: number;
51
+ /** Additional known published versions that may be used as a clone source. */
52
+ readonly allowedSourceVersions?: readonly number[];
53
+ }
54
+ interface PublishDraftOptions {
55
+ readonly expectedRevision?: number;
56
+ readonly validate?: (schema: FormSchema) => boolean | readonly SchemaIssue[];
57
+ /** Supplies deterministic record timestamps while keeping the transition pure. */
58
+ readonly timestamp?: string;
59
+ }
60
+ interface DeleteDraftOptions {
61
+ readonly expectedRevision?: number;
62
+ }
63
+ interface PublishDraftResult {
64
+ readonly nextState: FormVersionState;
65
+ readonly publishedRecord: FormVersionRecord;
66
+ readonly archivedRecords: readonly FormVersionRecord[];
67
+ /** @deprecated Read archivedRecords instead. */
68
+ readonly archivedVersion?: number;
69
+ }
70
+ declare function cloneVersionToDraft(state: FormVersionState, sourceSchema: FormSchema, options?: CloneVersionOptions): Result<{
71
+ readonly nextState: FormVersionState;
72
+ readonly draftSchema: FormSchema;
73
+ }, VersionTransitionError>;
74
+ declare function publishDraft(state: FormVersionState, draftSchema: FormSchema, options?: PublishDraftOptions): Result<PublishDraftResult, VersionTransitionError>;
75
+ declare function deleteDraft(state: FormVersionState, options?: DeleteDraftOptions): Result<{
76
+ readonly nextState: FormVersionState;
77
+ }, VersionTransitionError>;
78
+ declare function assertVersionMutable(status: FormVersionStatus): void;
79
+
1
80
  type FieldType = "text" | "textarea" | "number" | "rating" | "select" | "multi-select" | "checkbox" | "radio";
2
81
  interface FormPolicy {
3
82
  readonly allowedFieldTypes?: readonly FieldType[];
@@ -163,6 +242,37 @@ interface FormStorageAdapter extends StorageAdapter {
163
242
  deleteSchema(formId: string, formVersion: number): Promise<void>;
164
243
  deleteSubmission(submissionId: string): Promise<void>;
165
244
  }
245
+ interface SubmissionPageQueryOptions {
246
+ readonly version?: number;
247
+ readonly cursor?: string;
248
+ readonly pageSize?: number;
249
+ readonly since?: string;
250
+ readonly until?: string;
251
+ readonly locale?: string;
252
+ readonly filter?: (submission: FormSubmission) => boolean;
253
+ readonly metadataFilters?: Readonly<Record<string, JsonValue>>;
254
+ }
255
+ interface SubmissionPage {
256
+ readonly items: readonly FormSubmission[];
257
+ readonly nextCursor?: string;
258
+ readonly hasMore: boolean;
259
+ }
260
+ interface PagedSubmissionStorageAdapter extends FormStorageAdapter {
261
+ listSubmissionPage(formId: string, options?: SubmissionPageQueryOptions): Promise<SubmissionPage>;
262
+ }
263
+ interface VersionTransitionPlan {
264
+ readonly state: FormVersionState;
265
+ readonly expectedRevision: number;
266
+ readonly draftToPublish?: FormSchema;
267
+ readonly versionsToArchive: readonly number[];
268
+ readonly versionsToDelete: readonly number[];
269
+ }
270
+ interface VersionedFormStorageAdapter extends FormStorageAdapter {
271
+ commitVersionTransition(plan: VersionTransitionPlan): Promise<{
272
+ readonly success: boolean;
273
+ readonly error?: string;
274
+ }>;
275
+ }
166
276
  interface BaseQuestionAggregate {
167
277
  readonly fieldId: string;
168
278
  readonly answeredCount: number;
@@ -207,6 +317,7 @@ type ChoiceOption = FieldOption;
207
317
  interface FormResponse extends ExtensibleNode {
208
318
  readonly responseId: string;
209
319
  readonly formId: string;
320
+ readonly formVersion?: number;
210
321
  readonly sourceLocale?: string;
211
322
  readonly answers: Readonly<Record<string, unknown>>;
212
323
  readonly submittedAt: string;
@@ -234,11 +345,59 @@ declare function calculateChoiceDistribution(responses: readonly FormSubmission[
234
345
  declare function calculateNumericSummary(responses: readonly FormSubmission[], questionId: string): NumericSummary;
235
346
  declare function calculateCrossTabulation(responses: readonly FormSubmission[], rowQuestionId: string, colQuestionId: string): CrossTabulationResult;
236
347
  declare function aggregateResponses(schema: FormSchema, submissions: readonly FormSubmission[]): FormAnalytics;
348
+ type AccumulatorResponse = FormSubmission | FormResponse;
349
+ type AccumulatorSkipReason = "form_id_mismatch" | "version_mismatch" | "invalid_structure";
350
+ interface AccumulatorReport {
351
+ readonly processedCount: number;
352
+ readonly skippedCount: number;
353
+ readonly skipReasons: readonly {
354
+ readonly responseId: string;
355
+ readonly reason: AccumulatorSkipReason;
356
+ }[];
357
+ }
358
+ interface ResponseAccumulator {
359
+ add(submission: AccumulatorResponse): {
360
+ readonly success: boolean;
361
+ readonly skipped?: boolean;
362
+ readonly error?: string;
363
+ };
364
+ addMany(submissions: Iterable<AccumulatorResponse>): AccumulatorReport;
365
+ merge(other: ResponseAccumulator): ResponseAccumulator;
366
+ finalize(): FormAnalytics;
367
+ getReport(): AccumulatorReport;
368
+ }
369
+ interface ResponseAccumulatorOptions {
370
+ readonly mode?: "strict" | "lenient";
371
+ }
372
+ declare function createResponseAccumulator(schema: FormSchema, options?: ResponseAccumulatorOptions): ResponseAccumulator;
237
373
  declare function escapeCsvCell(value: string | number | boolean | null | undefined, neutralizeFormulas?: boolean): string;
238
374
  interface CsvExportOptions {
239
375
  readonly withBom?: boolean;
240
376
  readonly neutralizeFormulas?: boolean;
241
377
  }
378
+ interface CsvColumnDef {
379
+ readonly header: string;
380
+ readonly getValue: (context: CsvColumnContext) => string | number | boolean | null | undefined;
381
+ }
382
+ interface CsvColumnContext extends FormResponse {
383
+ readonly submission: FormResponse;
384
+ readonly formVersion: number;
385
+ readonly schema: FormSchema;
386
+ }
387
+ interface StreamCsvOptions extends CsvExportOptions {
388
+ readonly columns?: readonly CsvColumnDef[];
389
+ readonly includeDefaultColumns?: boolean;
390
+ }
391
+ declare function exportResponsesToCsvStream(schema: FormSchema, submissions: AsyncIterable<AccumulatorResponse>, options?: StreamCsvOptions): AsyncIterable<string>;
392
+ interface NodeWritableStream {
393
+ write(chunk: Uint8Array): boolean;
394
+ once(event: "drain", listener: () => void): unknown;
395
+ once(event: "error", listener: (error: Error) => void): unknown;
396
+ removeListener(event: "drain", listener: () => void): unknown;
397
+ removeListener(event: "error", listener: (error: Error) => void): unknown;
398
+ end(callback: () => void): unknown;
399
+ }
400
+ declare function pipeResponsesToCsvStream(schema: FormSchema, submissions: AsyncIterable<AccumulatorResponse>, writable: WritableStream<Uint8Array> | NodeWritableStream, options?: StreamCsvOptions): Promise<void>;
242
401
  declare function exportResponsesToCsv(schema: FormSchema, responses: readonly FormSubmission[], options?: CsvExportOptions): string;
243
402
 
244
403
  type FormEventType = "response.submitted" | "schema.updated";
@@ -268,6 +427,15 @@ declare function dispatchWebhook<T>(event: FormEvent<T>, config: WebhookConfig,
268
427
  */
269
428
  declare function transformFieldType(field: FormField, nextType: QuestionType): FormField;
270
429
 
430
+ interface SubmissionCursorValue {
431
+ readonly submittedAt: string;
432
+ readonly responseId: string;
433
+ }
434
+ declare function encodeSubmissionCursor(value: SubmissionCursorValue): string;
435
+ declare function decodeSubmissionCursor(cursor: string): SubmissionCursorValue;
436
+ declare function normalizeSubmissionPageSize(pageSize: number | undefined, fallback?: number): number;
437
+ declare function matchesSubmissionPageFilters(submission: FormSubmission, options: Pick<SubmissionPageQueryOptions, "filter" | "metadataFilters">): boolean;
438
+
271
439
  interface CollectedLocales {
272
440
  readonly defaultLocale?: string;
273
441
  readonly supportedLocales: readonly string[];
@@ -341,4 +509,4 @@ declare function calculatePageVisibility(schema: FormSchema, currentAnswers: Rea
341
509
  declare function calculateFieldVisibility(schema: FormSchema, currentAnswers: Readonly<Record<string, unknown>>): Readonly<Record<string, boolean>>;
342
510
  declare function selectVisibleAnswers(schema: FormSchema, currentAnswers: FormValues): FormValues;
343
511
 
344
- export { type AnswerValidationResult, type AsyncTranslationAdapter, type BaseField, type CheckboxField, type CheckboxQuestionAggregate, type ChoiceDistributionEntry, type ChoiceOption, type ChoiceQuestionAggregate, type CollectedLocales, 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, collectSchemaLocales, createSubmission, dispatchWebhook, escapeCsvCell, exportResponsesToCsv, isDisplayConditionSatisfied, isQuestionVisible, populateSchemaTranslations, resolveFormTranslation, resolveLocalizedSchema, sanitizeSchema, selectVisibleAnswers, transformFieldType, validateAnswers, validateFormSchema, validatePageAnswers, validateSchemaStructure };
512
+ export { type AccumulatorReport, type AccumulatorResponse, type AccumulatorSkipReason, 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 CsvColumnContext, type CsvColumnDef, type CsvExportOptions, type DeleteDraftOptions, 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 NodeWritableStream, type NumberField, type NumberQuestionAggregate, type NumericSummary, type OptionAggregate, type PagedSubmissionStorageAdapter, type PopulateTranslationOptions, type PublishDraftOptions, type PublishDraftResult, 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 VersionTransitionPlan, type VersionedFormStorageAdapter, 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, matchesSubmissionPageFilters, normalizeSubmissionPageSize, pipeResponsesToCsvStream, populateSchemaTranslations, publishDraft, resolveFormTranslation, resolveLocalizedSchema, sanitizeSchema, selectVisibleAnswers, transformFieldType, validateAnswers, validateFormSchema, validatePageAnswers, validateSchemaStructure };