@marktiderman/genesis-forms 0.1.1 → 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.
- package/README.md +121 -17
- package/conformance/{after-class-back-after-a-jump.scenario.json → event-feedback-back-after-a-jump.scenario.json} +21 -21
- package/conformance/{after-class-contact-yes-completed.scenario.json → event-feedback-contact-yes-completed.scenario.json} +21 -21
- package/conformance/{after-class-contact-yes-requires-name-and-email.scenario.json → event-feedback-contact-yes-requires-name-and-email.scenario.json} +19 -19
- package/conformance/{after-class-happy-path.scenario.json → event-feedback-happy-path.scenario.json} +24 -24
- package/conformance/{after-class-invalid-email-rejected.scenario.json → event-feedback-invalid-email-rejected.scenario.json} +19 -19
- package/conformance/{after-class-low-rating-skips-went-well.scenario.json → event-feedback-low-rating-skips-went-well.scenario.json} +21 -21
- package/conformance/{after-class-server-drops-unknown-and-hidden-answers.scenario.json → event-feedback-server-drops-unknown-and-hidden-answers.scenario.json} +22 -22
- package/conformance/{after-class-server-ignores-a-client-sent-coach.scenario.json → event-feedback-server-ignores-a-client-sent-owner.scenario.json} +24 -24
- package/conformance/{monthly-pulse-default-ending.scenario.json → monthly-check-in-default-ending.scenario.json} +6 -6
- package/conformance/{monthly-pulse-promoter-ending-via-jump.scenario.json → monthly-check-in-promoter-ending-via-jump.scenario.json} +6 -6
- package/dist/destinations.cjs +1211 -0
- package/dist/destinations.cjs.map +1 -0
- package/dist/destinations.d.cts +465 -0
- package/dist/destinations.d.ts +465 -0
- package/dist/destinations.js +1169 -0
- package/dist/destinations.js.map +1 -0
- package/dist/{engine-LsPRTzt3.d.cts → engine-CPLtKVew.d.cts} +7 -6
- package/dist/{engine-Cp5t2_Am.d.ts → engine-DOrPgFDw.d.ts} +7 -6
- package/dist/index.cjs +410 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +122 -18
- package/dist/index.d.ts +122 -18
- package/dist/index.js +399 -25
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +350 -29
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +13 -12
- package/dist/server.d.ts +13 -12
- package/dist/server.js +350 -29
- package/dist/server.js.map +1 -1
- package/dist/testing.cjs +354 -29
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +4 -3
- package/dist/testing.d.ts +4 -3
- package/dist/testing.js +354 -29
- package/dist/testing.js.map +1 -1
- package/dist/{validate-j8Z188mF.d.cts → types-BBKBQ8sp.d.cts} +9 -29
- package/dist/{validate-j8Z188mF.d.ts → types-BBKBQ8sp.d.ts} +9 -29
- package/dist/validate-BXXqi0fq.d.cts +30 -0
- package/dist/validate-BjNwF1UE.d.ts +30 -0
- package/package.json +14 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { F as FormEngine } from './engine-
|
|
4
|
-
export { C as CreateFormOptions, a as FormState, c as createForm, i as isFormEvent, b as isJson, r as replay } from './engine-
|
|
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 & {
|
|
@@ -11,15 +13,15 @@ type FieldSpec<K extends string = string, V = unknown> = FieldBlock & {
|
|
|
11
13
|
};
|
|
12
14
|
interface FieldOptions {
|
|
13
15
|
label: string;
|
|
14
|
-
description?: string;
|
|
15
|
-
placeholder?: string;
|
|
16
|
-
required?: boolean;
|
|
16
|
+
description?: string | undefined;
|
|
17
|
+
placeholder?: string | undefined;
|
|
18
|
+
required?: boolean | undefined;
|
|
17
19
|
/** Personal or secret data (see `isSensitive`). */
|
|
18
|
-
sensitive?: boolean;
|
|
20
|
+
sensitive?: boolean | undefined;
|
|
19
21
|
/** Identifies the respondent (name, email, phone). Not asked when `settings.anonymous` is true. */
|
|
20
|
-
identifying?: boolean;
|
|
22
|
+
identifying?: boolean | undefined;
|
|
21
23
|
/** Defaults to the key. Set it before renaming a key on a live form, so answers stay linked. */
|
|
22
|
-
id?: string;
|
|
24
|
+
id?: string | undefined;
|
|
23
25
|
}
|
|
24
26
|
interface ChoiceFieldOptions<O extends string> extends FieldOptions {
|
|
25
27
|
options: readonly {
|
|
@@ -28,25 +30,71 @@ interface ChoiceFieldOptions<O extends string> extends FieldOptions {
|
|
|
28
30
|
}[];
|
|
29
31
|
}
|
|
30
32
|
interface HiddenOptions {
|
|
31
|
-
source?: HiddenInput["source"];
|
|
32
|
-
sensitive?: boolean;
|
|
33
|
+
source?: HiddenInput["source"] | undefined;
|
|
34
|
+
sensitive?: boolean | undefined;
|
|
35
|
+
/** Identifies the respondent. Not stored when `settings.anonymous` is true. */
|
|
36
|
+
identifying?: boolean | undefined;
|
|
33
37
|
}
|
|
34
38
|
declare const f: {
|
|
35
39
|
shortText: <K extends string>(key: K, o: FieldOptions & {
|
|
36
|
-
maxLength?: number;
|
|
40
|
+
maxLength?: number | undefined;
|
|
37
41
|
}) => FieldSpec<K, string>;
|
|
38
42
|
longText: <K extends string>(key: K, o: FieldOptions & {
|
|
39
|
-
maxLength?: number;
|
|
43
|
+
maxLength?: number | undefined;
|
|
40
44
|
}) => FieldSpec<K, string>;
|
|
41
45
|
email: <K extends string>(key: K, o: FieldOptions) => FieldSpec<K, string>;
|
|
42
46
|
phone: <K extends string>(key: K, o: FieldOptions) => FieldSpec<K, string>;
|
|
43
47
|
rating: <K extends string>(key: K, o: FieldOptions & {
|
|
44
|
-
max?: number;
|
|
48
|
+
max?: number | undefined;
|
|
45
49
|
}) => FieldSpec<K, number>;
|
|
46
50
|
nps: <K extends string>(key: K, o: FieldOptions) => FieldSpec<K, number>;
|
|
47
51
|
singleChoice: <K extends string, O extends string>(key: K, o: ChoiceFieldOptions<O>) => FieldSpec<K, O>;
|
|
48
52
|
multiChoice: <K extends string, O extends string>(key: K, o: ChoiceFieldOptions<O>) => FieldSpec<K, O[]>;
|
|
49
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
|
+
}[]>;
|
|
50
98
|
/** Any registered field type, including plugins. */
|
|
51
99
|
custom: <K extends string, V = Json>(type: string, key: K, o: FieldOptions & {
|
|
52
100
|
props?: Record<string, Json>;
|
|
@@ -59,16 +107,19 @@ declare const f: {
|
|
|
59
107
|
type: "string";
|
|
60
108
|
source: HiddenInput["source"];
|
|
61
109
|
sensitive?: true;
|
|
110
|
+
identifying?: true;
|
|
62
111
|
};
|
|
63
112
|
number: (o?: HiddenOptions) => {
|
|
64
113
|
type: "number";
|
|
65
114
|
source: HiddenInput["source"];
|
|
66
115
|
sensitive?: true;
|
|
116
|
+
identifying?: true;
|
|
67
117
|
};
|
|
68
118
|
boolean: (o?: HiddenOptions) => {
|
|
69
119
|
type: "boolean";
|
|
70
120
|
source: HiddenInput["source"];
|
|
71
121
|
sensitive?: true;
|
|
122
|
+
identifying?: true;
|
|
72
123
|
};
|
|
73
124
|
};
|
|
74
125
|
};
|
|
@@ -111,7 +162,8 @@ declare namespace when {
|
|
|
111
162
|
type HiddenSpec = {
|
|
112
163
|
type: HiddenInput["type"];
|
|
113
164
|
source: HiddenInput["source"];
|
|
114
|
-
sensitive?: boolean;
|
|
165
|
+
sensitive?: boolean | undefined;
|
|
166
|
+
identifying?: boolean | undefined;
|
|
115
167
|
};
|
|
116
168
|
type HiddenValue<T extends HiddenSpec["type"]> = T extends "number" ? number : T extends "boolean" ? boolean : string;
|
|
117
169
|
type AnyBlock = FieldSpec<string, unknown> | ContentBlock | PageBreakBlock;
|
|
@@ -187,7 +239,8 @@ interface CoercedHidden {
|
|
|
187
239
|
* Convert one raw value to a hidden input's declared type, or `undefined` when
|
|
188
240
|
* it cannot be. Only string, number and boolean primitives are accepted.
|
|
189
241
|
* - `string`: a string (at most 1000 characters), or a number or boolean as text.
|
|
190
|
-
* - `number`: a finite number, or a
|
|
242
|
+
* - `number`: a finite number, or a plain decimal string such as `"12"`, `"-3"`
|
|
243
|
+
* or `"2.5"`. No spaces, hex, exponents or `""`.
|
|
191
244
|
* - `boolean`: `true`/`false`, or the strings `"true"`/`"false"`.
|
|
192
245
|
*/
|
|
193
246
|
declare function coerceHiddenValue(value: unknown, type: HiddenInput["type"]): Json | undefined;
|
|
@@ -289,6 +342,57 @@ interface ChoiceOption {
|
|
|
289
342
|
}
|
|
290
343
|
declare function choiceOptions(field: FieldBlock): ChoiceOption[];
|
|
291
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
|
+
|
|
292
396
|
interface RecallScope {
|
|
293
397
|
/** Fields by key. */
|
|
294
398
|
fieldsByKey: Map<string, FieldBlock>;
|
|
@@ -371,4 +475,4 @@ declare function explain(source: FormEngine | ExplainInput, blockId: string, opt
|
|
|
371
475
|
/** A condition as a plain-English clause: `contact_me is not Yes`. */
|
|
372
476
|
declare function describeCondition(condition: Condition, def: FormDefinition, fields?: Map<string, FieldBlock>): string;
|
|
373
477
|
|
|
374
|
-
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 {
|
|
2
|
-
export {
|
|
3
|
-
import { F as FormEngine } from './engine-
|
|
4
|
-
export { C as CreateFormOptions, a as FormState, c as createForm, i as isFormEvent, b as isJson, r as replay } from './engine-
|
|
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 & {
|
|
@@ -11,15 +13,15 @@ type FieldSpec<K extends string = string, V = unknown> = FieldBlock & {
|
|
|
11
13
|
};
|
|
12
14
|
interface FieldOptions {
|
|
13
15
|
label: string;
|
|
14
|
-
description?: string;
|
|
15
|
-
placeholder?: string;
|
|
16
|
-
required?: boolean;
|
|
16
|
+
description?: string | undefined;
|
|
17
|
+
placeholder?: string | undefined;
|
|
18
|
+
required?: boolean | undefined;
|
|
17
19
|
/** Personal or secret data (see `isSensitive`). */
|
|
18
|
-
sensitive?: boolean;
|
|
20
|
+
sensitive?: boolean | undefined;
|
|
19
21
|
/** Identifies the respondent (name, email, phone). Not asked when `settings.anonymous` is true. */
|
|
20
|
-
identifying?: boolean;
|
|
22
|
+
identifying?: boolean | undefined;
|
|
21
23
|
/** Defaults to the key. Set it before renaming a key on a live form, so answers stay linked. */
|
|
22
|
-
id?: string;
|
|
24
|
+
id?: string | undefined;
|
|
23
25
|
}
|
|
24
26
|
interface ChoiceFieldOptions<O extends string> extends FieldOptions {
|
|
25
27
|
options: readonly {
|
|
@@ -28,25 +30,71 @@ interface ChoiceFieldOptions<O extends string> extends FieldOptions {
|
|
|
28
30
|
}[];
|
|
29
31
|
}
|
|
30
32
|
interface HiddenOptions {
|
|
31
|
-
source?: HiddenInput["source"];
|
|
32
|
-
sensitive?: boolean;
|
|
33
|
+
source?: HiddenInput["source"] | undefined;
|
|
34
|
+
sensitive?: boolean | undefined;
|
|
35
|
+
/** Identifies the respondent. Not stored when `settings.anonymous` is true. */
|
|
36
|
+
identifying?: boolean | undefined;
|
|
33
37
|
}
|
|
34
38
|
declare const f: {
|
|
35
39
|
shortText: <K extends string>(key: K, o: FieldOptions & {
|
|
36
|
-
maxLength?: number;
|
|
40
|
+
maxLength?: number | undefined;
|
|
37
41
|
}) => FieldSpec<K, string>;
|
|
38
42
|
longText: <K extends string>(key: K, o: FieldOptions & {
|
|
39
|
-
maxLength?: number;
|
|
43
|
+
maxLength?: number | undefined;
|
|
40
44
|
}) => FieldSpec<K, string>;
|
|
41
45
|
email: <K extends string>(key: K, o: FieldOptions) => FieldSpec<K, string>;
|
|
42
46
|
phone: <K extends string>(key: K, o: FieldOptions) => FieldSpec<K, string>;
|
|
43
47
|
rating: <K extends string>(key: K, o: FieldOptions & {
|
|
44
|
-
max?: number;
|
|
48
|
+
max?: number | undefined;
|
|
45
49
|
}) => FieldSpec<K, number>;
|
|
46
50
|
nps: <K extends string>(key: K, o: FieldOptions) => FieldSpec<K, number>;
|
|
47
51
|
singleChoice: <K extends string, O extends string>(key: K, o: ChoiceFieldOptions<O>) => FieldSpec<K, O>;
|
|
48
52
|
multiChoice: <K extends string, O extends string>(key: K, o: ChoiceFieldOptions<O>) => FieldSpec<K, O[]>;
|
|
49
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
|
+
}[]>;
|
|
50
98
|
/** Any registered field type, including plugins. */
|
|
51
99
|
custom: <K extends string, V = Json>(type: string, key: K, o: FieldOptions & {
|
|
52
100
|
props?: Record<string, Json>;
|
|
@@ -59,16 +107,19 @@ declare const f: {
|
|
|
59
107
|
type: "string";
|
|
60
108
|
source: HiddenInput["source"];
|
|
61
109
|
sensitive?: true;
|
|
110
|
+
identifying?: true;
|
|
62
111
|
};
|
|
63
112
|
number: (o?: HiddenOptions) => {
|
|
64
113
|
type: "number";
|
|
65
114
|
source: HiddenInput["source"];
|
|
66
115
|
sensitive?: true;
|
|
116
|
+
identifying?: true;
|
|
67
117
|
};
|
|
68
118
|
boolean: (o?: HiddenOptions) => {
|
|
69
119
|
type: "boolean";
|
|
70
120
|
source: HiddenInput["source"];
|
|
71
121
|
sensitive?: true;
|
|
122
|
+
identifying?: true;
|
|
72
123
|
};
|
|
73
124
|
};
|
|
74
125
|
};
|
|
@@ -111,7 +162,8 @@ declare namespace when {
|
|
|
111
162
|
type HiddenSpec = {
|
|
112
163
|
type: HiddenInput["type"];
|
|
113
164
|
source: HiddenInput["source"];
|
|
114
|
-
sensitive?: boolean;
|
|
165
|
+
sensitive?: boolean | undefined;
|
|
166
|
+
identifying?: boolean | undefined;
|
|
115
167
|
};
|
|
116
168
|
type HiddenValue<T extends HiddenSpec["type"]> = T extends "number" ? number : T extends "boolean" ? boolean : string;
|
|
117
169
|
type AnyBlock = FieldSpec<string, unknown> | ContentBlock | PageBreakBlock;
|
|
@@ -187,7 +239,8 @@ interface CoercedHidden {
|
|
|
187
239
|
* Convert one raw value to a hidden input's declared type, or `undefined` when
|
|
188
240
|
* it cannot be. Only string, number and boolean primitives are accepted.
|
|
189
241
|
* - `string`: a string (at most 1000 characters), or a number or boolean as text.
|
|
190
|
-
* - `number`: a finite number, or a
|
|
242
|
+
* - `number`: a finite number, or a plain decimal string such as `"12"`, `"-3"`
|
|
243
|
+
* or `"2.5"`. No spaces, hex, exponents or `""`.
|
|
191
244
|
* - `boolean`: `true`/`false`, or the strings `"true"`/`"false"`.
|
|
192
245
|
*/
|
|
193
246
|
declare function coerceHiddenValue(value: unknown, type: HiddenInput["type"]): Json | undefined;
|
|
@@ -289,6 +342,57 @@ interface ChoiceOption {
|
|
|
289
342
|
}
|
|
290
343
|
declare function choiceOptions(field: FieldBlock): ChoiceOption[];
|
|
291
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
|
+
|
|
292
396
|
interface RecallScope {
|
|
293
397
|
/** Fields by key. */
|
|
294
398
|
fieldsByKey: Map<string, FieldBlock>;
|
|
@@ -371,4 +475,4 @@ declare function explain(source: FormEngine | ExplainInput, blockId: string, opt
|
|
|
371
475
|
/** A condition as a plain-English clause: `contact_me is not Yes`. */
|
|
372
476
|
declare function describeCondition(condition: Condition, def: FormDefinition, fields?: Map<string, FieldBlock>): string;
|
|
373
477
|
|
|
374
|
-
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 };
|