@marktiderman/genesis-forms 0.2.0 → 0.3.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.
Files changed (42) hide show
  1. package/README.md +113 -13
  2. package/conformance/{after-class-back-after-a-jump.scenario.json → event-feedback-back-after-a-jump.scenario.json} +21 -21
  3. package/conformance/{after-class-contact-yes-completed.scenario.json → event-feedback-contact-yes-completed.scenario.json} +21 -21
  4. package/conformance/{after-class-contact-yes-requires-name-and-email.scenario.json → event-feedback-contact-yes-requires-name-and-email.scenario.json} +19 -19
  5. package/conformance/{after-class-happy-path.scenario.json → event-feedback-happy-path.scenario.json} +24 -24
  6. package/conformance/{after-class-invalid-email-rejected.scenario.json → event-feedback-invalid-email-rejected.scenario.json} +19 -19
  7. package/conformance/{after-class-low-rating-skips-went-well.scenario.json → event-feedback-low-rating-skips-went-well.scenario.json} +21 -21
  8. package/conformance/{after-class-server-drops-unknown-and-hidden-answers.scenario.json → event-feedback-server-drops-unknown-and-hidden-answers.scenario.json} +22 -22
  9. package/conformance/{after-class-server-ignores-a-client-sent-coach.scenario.json → event-feedback-server-ignores-a-client-sent-owner.scenario.json} +24 -24
  10. package/conformance/{monthly-pulse-default-ending.scenario.json → monthly-check-in-default-ending.scenario.json} +6 -6
  11. package/conformance/{monthly-pulse-promoter-ending-via-jump.scenario.json → monthly-check-in-promoter-ending-via-jump.scenario.json} +6 -6
  12. package/dist/destinations.cjs +1211 -0
  13. package/dist/destinations.cjs.map +1 -0
  14. package/dist/destinations.d.cts +465 -0
  15. package/dist/destinations.d.ts +465 -0
  16. package/dist/destinations.js +1169 -0
  17. package/dist/destinations.js.map +1 -0
  18. package/dist/{engine-Coc-gQIB.d.ts → engine-CPLtKVew.d.cts} +2 -1
  19. package/dist/{engine-Bj8-mMVb.d.cts → engine-DOrPgFDw.d.ts} +2 -1
  20. package/dist/index.cjs +320 -24
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +102 -5
  23. package/dist/index.d.ts +102 -5
  24. package/dist/index.js +309 -25
  25. package/dist/index.js.map +1 -1
  26. package/dist/server.cjs +247 -22
  27. package/dist/server.cjs.map +1 -1
  28. package/dist/server.d.cts +3 -2
  29. package/dist/server.d.ts +3 -2
  30. package/dist/server.js +247 -22
  31. package/dist/server.js.map +1 -1
  32. package/dist/testing.cjs +251 -22
  33. package/dist/testing.cjs.map +1 -1
  34. package/dist/testing.d.cts +4 -3
  35. package/dist/testing.d.ts +4 -3
  36. package/dist/testing.js +251 -22
  37. package/dist/testing.js.map +1 -1
  38. package/dist/{validate-BbackAjB.d.cts → types-BBKBQ8sp.d.cts} +2 -29
  39. package/dist/{validate-BbackAjB.d.ts → types-BBKBQ8sp.d.ts} +2 -29
  40. package/dist/validate-BXXqi0fq.d.cts +30 -0
  41. package/dist/validate-BjNwF1UE.d.ts +30 -0
  42. package/package.json +14 -2
package/dist/index.d.cts CHANGED
@@ -1,7 +1,9 @@
1
- import { F as FieldBlock, C as ContentBlock, P as PageBreakBlock, a as FormDefinition, H as HiddenInput, b as FormLayout, L as LogicRule, E as Ending, c as FormSettings, J as Json, d as Condition, B as Block, O as Operator, e as FieldValidator } from './validate-BbackAjB.cjs';
2
- export { f as FormEvent, g as Operand, R as REQUIRED_MESSAGE, S as StandardSchemaV1, v as validateField } from './validate-BbackAjB.cjs';
3
- import { F as FormEngine } from './engine-Bj8-mMVb.cjs';
4
- export { C as CreateFormOptions, a as FormState, c as createForm, i as isFormEvent, b as isJson, r as replay } from './engine-Bj8-mMVb.cjs';
1
+ import { a as FieldBlock, C as ContentBlock, P as PageBreakBlock, F as FormDefinition, H as HiddenInput, b as FormLayout, L as LogicRule, E as Ending, c as FormSettings, J as Json, d as Condition, B as Block, O as Operator } from './types-BBKBQ8sp.cjs';
2
+ export { e as FormEvent, f as Operand } from './types-BBKBQ8sp.cjs';
3
+ import { F as FormEngine } from './engine-CPLtKVew.cjs';
4
+ export { C as CreateFormOptions, a as FormState, c as createForm, i as isFormEvent, b as isJson, r as replay } from './engine-CPLtKVew.cjs';
5
+ import { F as FieldValidator } from './validate-BXXqi0fq.cjs';
6
+ export { R as REQUIRED_MESSAGE, S as StandardSchemaV1, v as validateField } from './validate-BXXqi0fq.cjs';
5
7
 
6
8
  /** A field block that remembers its key and value type, for answer inference. */
7
9
  type FieldSpec<K extends string = string, V = unknown> = FieldBlock & {
@@ -49,6 +51,50 @@ declare const f: {
49
51
  singleChoice: <K extends string, O extends string>(key: K, o: ChoiceFieldOptions<O>) => FieldSpec<K, O>;
50
52
  multiChoice: <K extends string, O extends string>(key: K, o: ChoiceFieldOptions<O>) => FieldSpec<K, O[]>;
51
53
  yesNo: <K extends string>(key: K, o: FieldOptions) => FieldSpec<K, boolean>;
54
+ /** Several short answers, one per line: goals, action items, three things that went well. */
55
+ list: <K extends string>(key: K, o: FieldOptions & {
56
+ min?: number | undefined;
57
+ max?: number | undefined;
58
+ itemMaxLength?: number | undefined;
59
+ itemPlaceholder?: string | undefined;
60
+ }) => FieldSpec<K, string[]>;
61
+ /**
62
+ * A small table each answer fills row by row, one answer per column: an
63
+ * action plan (What / Who / By when), pros and cons.
64
+ */
65
+ table: <K extends string, C extends string>(key: K, o: FieldOptions & {
66
+ columns: readonly {
67
+ key: C;
68
+ label: string;
69
+ long?: boolean | undefined;
70
+ }[];
71
+ minRows?: number | undefined;
72
+ maxRows?: number | undefined;
73
+ }) => FieldSpec<K, Partial<Record<C, string>>[]>;
74
+ /**
75
+ * Notes pinned to times in a video or audio (lecture notes, a recorded call
76
+ * review): `at` is seconds from its start.
77
+ */
78
+ mediaNotes: <K extends string>(key: K, o: FieldOptions & {
79
+ maxNotes?: number | undefined;
80
+ textMaxLength?: number | undefined;
81
+ }) => FieldSpec<K, {
82
+ at: number;
83
+ text: string;
84
+ }[]>;
85
+ /**
86
+ * Highlight passages of a text and note on each (annotating an article, a
87
+ * policy or a contract): `text` here, or supplied by the host app.
88
+ */
89
+ textHighlights: <K extends string>(key: K, o: FieldOptions & {
90
+ text?: string | undefined;
91
+ maxHighlights?: number | undefined;
92
+ }) => FieldSpec<K, {
93
+ start: number;
94
+ end: number;
95
+ quote: string;
96
+ note: string;
97
+ }[]>;
52
98
  /** Any registered field type, including plugins. */
53
99
  custom: <K extends string, V = Json>(type: string, key: K, o: FieldOptions & {
54
100
  props?: Record<string, Json>;
@@ -296,6 +342,57 @@ interface ChoiceOption {
296
342
  }
297
343
  declare function choiceOptions(field: FieldBlock): ChoiceOption[];
298
344
 
345
+ declare function listLimits(field: FieldBlock): {
346
+ min: number;
347
+ max: number;
348
+ itemMaxLength: number;
349
+ };
350
+ interface TableColumn {
351
+ key: string;
352
+ label: string;
353
+ long?: boolean;
354
+ }
355
+ declare const MAX_TABLE_COLUMNS = 6;
356
+ declare const MAX_TABLE_CELL_LENGTH = 2000;
357
+ declare function tableColumns(field: FieldBlock): TableColumn[];
358
+ declare function tableLimits(field: FieldBlock): {
359
+ minRows: number;
360
+ maxRows: number;
361
+ };
362
+ interface MediaNote {
363
+ at: number;
364
+ text: string;
365
+ }
366
+ declare const MAX_TIMESTAMP_SECONDS = 86400;
367
+ declare function formatTimestamp(seconds: number): string;
368
+ declare function parseTimestamp(text: string): number | null;
369
+ interface Highlight {
370
+ start: number;
371
+ end: number;
372
+ quote: string;
373
+ note: string;
374
+ }
375
+ declare const MAX_HIGHLIGHT_NOTE_LENGTH = 1000;
376
+ /** The longest passage one highlight may quote; also bounds a quote the server can't check against `props.text`. */
377
+ declare const MAX_HIGHLIGHT_QUOTE_LENGTH = 2000;
378
+ declare const HIGHLIGHT_NOTE_MESSAGE = "Add a note to each highlight.";
379
+ /**
380
+ * The structured field types, whose answers are lists or records rather than one
381
+ * value:
382
+ * - `list`: several short answers, e.g. goals, action items, three things that went well.
383
+ * - `table`: a small table each answer fills row by row, e.g. an action plan
384
+ * (What / Who / By when), pros and cons.
385
+ * - `media-notes`: notes pinned to times in a video or audio, e.g. lecture notes,
386
+ * a recorded call review.
387
+ * - `text-highlights`: highlight passages of a text and note on each, e.g.
388
+ * annotating an article, a policy or a contract.
389
+ *
390
+ * They are registered like any other, but the builder offers them only to a
391
+ * host that names them in its palette (`FormBuilder palette`), so forms that
392
+ * never had them don't change.
393
+ */
394
+ declare const STRUCTURED_FIELD_TYPES: readonly ["list", "table", "media-notes", "text-highlights"];
395
+
299
396
  interface RecallScope {
300
397
  /** Fields by key. */
301
398
  fieldsByKey: Map<string, FieldBlock>;
@@ -378,4 +475,4 @@ declare function explain(source: FormEngine | ExplainInput, blockId: string, opt
378
475
  /** A condition as a plain-English clause: `contact_me is not Yes`. */
379
476
  declare function describeCondition(condition: Condition, def: FormDefinition, fields?: Map<string, FieldBlock>): string;
380
477
 
381
- export { type AnswersOf, Block, type ChoiceFieldOptions, type ChoiceOption, type CoerceHiddenOptions, type CoercedHidden, Condition, ContentBlock, Ending, type ExplainInput, type ExplainOptions, type Explanation, FieldBlock, type FieldOptions, type FieldSpec, type FieldTypeManifest, type FieldValidation, FieldValidator, type Form, FormDefinition, FormEngine, type FormInput, type FormIssue, FormLayout, FormSettings, HiddenInput, Json, type JumpTrace, type KeyResolver, LogicRule, MAX_HIDDEN_STRING_LENGTH, Operator, PageBreakBlock, type ParseResult, type PathResult, type RuleSpec, type RuleTrace, canonicalJson, choiceOptions, coerceHidden, coerceHiddenValue, computePath, defineForm, describeCondition, evaluate, explain, f, fingerprint, getFieldType, isEmptyValue, isSensitive, listFieldTypes, normalizeValue, parseForm, recall, registerFieldType, ruleVisible, steps, summarizeValue, when };
478
+ export { type AnswersOf, Block, type ChoiceFieldOptions, type ChoiceOption, type CoerceHiddenOptions, type CoercedHidden, Condition, ContentBlock, Ending, type ExplainInput, type ExplainOptions, type Explanation, FieldBlock, type FieldOptions, type FieldSpec, type FieldTypeManifest, type FieldValidation, FieldValidator, type Form, FormDefinition, FormEngine, type FormInput, type FormIssue, FormLayout, FormSettings, HIGHLIGHT_NOTE_MESSAGE, HiddenInput, type Highlight, Json, type JumpTrace, type KeyResolver, LogicRule, MAX_HIDDEN_STRING_LENGTH, MAX_HIGHLIGHT_NOTE_LENGTH, MAX_HIGHLIGHT_QUOTE_LENGTH, MAX_TABLE_CELL_LENGTH, MAX_TABLE_COLUMNS, MAX_TIMESTAMP_SECONDS, type MediaNote, Operator, PageBreakBlock, type ParseResult, type PathResult, type RuleSpec, type RuleTrace, STRUCTURED_FIELD_TYPES, type TableColumn, canonicalJson, choiceOptions, coerceHidden, coerceHiddenValue, computePath, defineForm, describeCondition, evaluate, explain, f, fingerprint, formatTimestamp, getFieldType, isEmptyValue, isSensitive, listFieldTypes, listLimits, normalizeValue, parseForm, parseTimestamp, recall, registerFieldType, ruleVisible, steps, summarizeValue, tableColumns, tableLimits, when };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- import { F as FieldBlock, C as ContentBlock, P as PageBreakBlock, a as FormDefinition, H as HiddenInput, b as FormLayout, L as LogicRule, E as Ending, c as FormSettings, J as Json, d as Condition, B as Block, O as Operator, e as FieldValidator } from './validate-BbackAjB.js';
2
- export { f as FormEvent, g as Operand, R as REQUIRED_MESSAGE, S as StandardSchemaV1, v as validateField } from './validate-BbackAjB.js';
3
- import { F as FormEngine } from './engine-Coc-gQIB.js';
4
- export { C as CreateFormOptions, a as FormState, c as createForm, i as isFormEvent, b as isJson, r as replay } from './engine-Coc-gQIB.js';
1
+ import { a as FieldBlock, C as ContentBlock, P as PageBreakBlock, F as FormDefinition, H as HiddenInput, b as FormLayout, L as LogicRule, E as Ending, c as FormSettings, J as Json, d as Condition, B as Block, O as Operator } from './types-BBKBQ8sp.js';
2
+ export { e as FormEvent, f as Operand } from './types-BBKBQ8sp.js';
3
+ import { F as FormEngine } from './engine-DOrPgFDw.js';
4
+ export { C as CreateFormOptions, a as FormState, c as createForm, i as isFormEvent, b as isJson, r as replay } from './engine-DOrPgFDw.js';
5
+ import { F as FieldValidator } from './validate-BjNwF1UE.js';
6
+ export { R as REQUIRED_MESSAGE, S as StandardSchemaV1, v as validateField } from './validate-BjNwF1UE.js';
5
7
 
6
8
  /** A field block that remembers its key and value type, for answer inference. */
7
9
  type FieldSpec<K extends string = string, V = unknown> = FieldBlock & {
@@ -49,6 +51,50 @@ declare const f: {
49
51
  singleChoice: <K extends string, O extends string>(key: K, o: ChoiceFieldOptions<O>) => FieldSpec<K, O>;
50
52
  multiChoice: <K extends string, O extends string>(key: K, o: ChoiceFieldOptions<O>) => FieldSpec<K, O[]>;
51
53
  yesNo: <K extends string>(key: K, o: FieldOptions) => FieldSpec<K, boolean>;
54
+ /** Several short answers, one per line: goals, action items, three things that went well. */
55
+ list: <K extends string>(key: K, o: FieldOptions & {
56
+ min?: number | undefined;
57
+ max?: number | undefined;
58
+ itemMaxLength?: number | undefined;
59
+ itemPlaceholder?: string | undefined;
60
+ }) => FieldSpec<K, string[]>;
61
+ /**
62
+ * A small table each answer fills row by row, one answer per column: an
63
+ * action plan (What / Who / By when), pros and cons.
64
+ */
65
+ table: <K extends string, C extends string>(key: K, o: FieldOptions & {
66
+ columns: readonly {
67
+ key: C;
68
+ label: string;
69
+ long?: boolean | undefined;
70
+ }[];
71
+ minRows?: number | undefined;
72
+ maxRows?: number | undefined;
73
+ }) => FieldSpec<K, Partial<Record<C, string>>[]>;
74
+ /**
75
+ * Notes pinned to times in a video or audio (lecture notes, a recorded call
76
+ * review): `at` is seconds from its start.
77
+ */
78
+ mediaNotes: <K extends string>(key: K, o: FieldOptions & {
79
+ maxNotes?: number | undefined;
80
+ textMaxLength?: number | undefined;
81
+ }) => FieldSpec<K, {
82
+ at: number;
83
+ text: string;
84
+ }[]>;
85
+ /**
86
+ * Highlight passages of a text and note on each (annotating an article, a
87
+ * policy or a contract): `text` here, or supplied by the host app.
88
+ */
89
+ textHighlights: <K extends string>(key: K, o: FieldOptions & {
90
+ text?: string | undefined;
91
+ maxHighlights?: number | undefined;
92
+ }) => FieldSpec<K, {
93
+ start: number;
94
+ end: number;
95
+ quote: string;
96
+ note: string;
97
+ }[]>;
52
98
  /** Any registered field type, including plugins. */
53
99
  custom: <K extends string, V = Json>(type: string, key: K, o: FieldOptions & {
54
100
  props?: Record<string, Json>;
@@ -296,6 +342,57 @@ interface ChoiceOption {
296
342
  }
297
343
  declare function choiceOptions(field: FieldBlock): ChoiceOption[];
298
344
 
345
+ declare function listLimits(field: FieldBlock): {
346
+ min: number;
347
+ max: number;
348
+ itemMaxLength: number;
349
+ };
350
+ interface TableColumn {
351
+ key: string;
352
+ label: string;
353
+ long?: boolean;
354
+ }
355
+ declare const MAX_TABLE_COLUMNS = 6;
356
+ declare const MAX_TABLE_CELL_LENGTH = 2000;
357
+ declare function tableColumns(field: FieldBlock): TableColumn[];
358
+ declare function tableLimits(field: FieldBlock): {
359
+ minRows: number;
360
+ maxRows: number;
361
+ };
362
+ interface MediaNote {
363
+ at: number;
364
+ text: string;
365
+ }
366
+ declare const MAX_TIMESTAMP_SECONDS = 86400;
367
+ declare function formatTimestamp(seconds: number): string;
368
+ declare function parseTimestamp(text: string): number | null;
369
+ interface Highlight {
370
+ start: number;
371
+ end: number;
372
+ quote: string;
373
+ note: string;
374
+ }
375
+ declare const MAX_HIGHLIGHT_NOTE_LENGTH = 1000;
376
+ /** The longest passage one highlight may quote; also bounds a quote the server can't check against `props.text`. */
377
+ declare const MAX_HIGHLIGHT_QUOTE_LENGTH = 2000;
378
+ declare const HIGHLIGHT_NOTE_MESSAGE = "Add a note to each highlight.";
379
+ /**
380
+ * The structured field types, whose answers are lists or records rather than one
381
+ * value:
382
+ * - `list`: several short answers, e.g. goals, action items, three things that went well.
383
+ * - `table`: a small table each answer fills row by row, e.g. an action plan
384
+ * (What / Who / By when), pros and cons.
385
+ * - `media-notes`: notes pinned to times in a video or audio, e.g. lecture notes,
386
+ * a recorded call review.
387
+ * - `text-highlights`: highlight passages of a text and note on each, e.g.
388
+ * annotating an article, a policy or a contract.
389
+ *
390
+ * They are registered like any other, but the builder offers them only to a
391
+ * host that names them in its palette (`FormBuilder palette`), so forms that
392
+ * never had them don't change.
393
+ */
394
+ declare const STRUCTURED_FIELD_TYPES: readonly ["list", "table", "media-notes", "text-highlights"];
395
+
299
396
  interface RecallScope {
300
397
  /** Fields by key. */
301
398
  fieldsByKey: Map<string, FieldBlock>;
@@ -378,4 +475,4 @@ declare function explain(source: FormEngine | ExplainInput, blockId: string, opt
378
475
  /** A condition as a plain-English clause: `contact_me is not Yes`. */
379
476
  declare function describeCondition(condition: Condition, def: FormDefinition, fields?: Map<string, FieldBlock>): string;
380
477
 
381
- export { type AnswersOf, Block, type ChoiceFieldOptions, type ChoiceOption, type CoerceHiddenOptions, type CoercedHidden, Condition, ContentBlock, Ending, type ExplainInput, type ExplainOptions, type Explanation, FieldBlock, type FieldOptions, type FieldSpec, type FieldTypeManifest, type FieldValidation, FieldValidator, type Form, FormDefinition, FormEngine, type FormInput, type FormIssue, FormLayout, FormSettings, HiddenInput, Json, type JumpTrace, type KeyResolver, LogicRule, MAX_HIDDEN_STRING_LENGTH, Operator, PageBreakBlock, type ParseResult, type PathResult, type RuleSpec, type RuleTrace, canonicalJson, choiceOptions, coerceHidden, coerceHiddenValue, computePath, defineForm, describeCondition, evaluate, explain, f, fingerprint, getFieldType, isEmptyValue, isSensitive, listFieldTypes, normalizeValue, parseForm, recall, registerFieldType, ruleVisible, steps, summarizeValue, when };
478
+ export { type AnswersOf, Block, type ChoiceFieldOptions, type ChoiceOption, type CoerceHiddenOptions, type CoercedHidden, Condition, ContentBlock, Ending, type ExplainInput, type ExplainOptions, type Explanation, FieldBlock, type FieldOptions, type FieldSpec, type FieldTypeManifest, type FieldValidation, FieldValidator, type Form, FormDefinition, FormEngine, type FormInput, type FormIssue, FormLayout, FormSettings, HIGHLIGHT_NOTE_MESSAGE, HiddenInput, type Highlight, Json, type JumpTrace, type KeyResolver, LogicRule, MAX_HIDDEN_STRING_LENGTH, MAX_HIGHLIGHT_NOTE_LENGTH, MAX_HIGHLIGHT_QUOTE_LENGTH, MAX_TABLE_CELL_LENGTH, MAX_TABLE_COLUMNS, MAX_TIMESTAMP_SECONDS, type MediaNote, Operator, PageBreakBlock, type ParseResult, type PathResult, type RuleSpec, type RuleTrace, STRUCTURED_FIELD_TYPES, type TableColumn, canonicalJson, choiceOptions, coerceHidden, coerceHiddenValue, computePath, defineForm, describeCondition, evaluate, explain, f, fingerprint, formatTimestamp, getFieldType, isEmptyValue, isSensitive, listFieldTypes, listLimits, normalizeValue, parseForm, parseTimestamp, recall, registerFieldType, ruleVisible, steps, summarizeValue, tableColumns, tableLimits, when };