@orkestrel/form 0.0.5 → 0.0.7

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.
@@ -1,8 +1,8 @@
1
- import { EmitterErrorHandler } from '@orkestrel/emitter';
2
- import { EmitterHooks } from '@orkestrel/emitter';
3
- import { EmitterInterface } from '@orkestrel/emitter';
4
- import { JSONRecord } from '@orkestrel/contract';
5
- import { Result } from '@orkestrel/contract';
1
+ import type { EmitterErrorHandler } from '@orkestrel/emitter';
2
+ import type { EmitterHooks } from '@orkestrel/emitter';
3
+ import type { EmitterInterface } from '@orkestrel/emitter';
4
+ import type { JSONRecord } from '@orkestrel/contract';
5
+ import type { Result } from '@orkestrel/contract';
6
6
 
7
7
  /** Matches one or more ASCII letters or digits. */
8
8
  export declare const ALPHANUMERIC_PATTERN: Readonly<RegExp>;
@@ -41,7 +41,7 @@ export declare interface CheckboxField extends FieldBase {
41
41
  readonly default?: readonly string[];
42
42
  }
43
43
 
44
- /** Caps the number of choices one `select` or `checkbox` field may offer. */
44
+ /** Caps the number of choices one `select` or `checkbox` field may offer, at 1024. */
45
45
  export declare const CHOICE_LIMIT = 1024;
46
46
 
47
47
  /**
@@ -82,7 +82,7 @@ export declare function cloneValue(value: FieldValue): FieldValue;
82
82
  /** Matches a six-digit hexadecimal color string. */
83
83
  export declare const COLOR_PATTERN: Readonly<RegExp>;
84
84
 
85
- /** Represents a color, held as the control's own string. */
85
+ /** Represents a color, held as the control's own six-digit `#rrggbb` string. */
86
86
  export declare interface ColorField extends FieldBase {
87
87
  readonly control: 'color';
88
88
  readonly default?: string;
@@ -91,6 +91,10 @@ export declare interface ColorField extends FieldBase {
91
91
  /**
92
92
  * Computes the values explicitly seeded by a schema.
93
93
  *
94
+ * @remarks
95
+ * `password` and `file` declare no default, so a field of either control never appears in the
96
+ * result.
97
+ *
94
98
  * @param schema - The schema whose defaults to collect.
95
99
  * @returns A value record containing only fields with defaults.
96
100
  */
@@ -136,8 +140,10 @@ export declare function createFieldError(field: FormField, rule: FieldRuleName,
136
140
  * @throws A {@link FormError} coded `SCHEMA` when the schema is malformed, `FIELD` when
137
141
  * `options.values` names a field the schema does not declare, and `CONTROL` when a seeded value
138
142
  * is one its field's control cannot hold.
139
- * @example
143
+ * @example Open a form, answer it, and settle it
140
144
  * ```ts
145
+ * import { createForm } from '@orkestrel/form'
146
+ *
141
147
  * const form = createForm({
142
148
  * label: 'Sign up',
143
149
  * fields: [
@@ -147,7 +153,8 @@ export declare function createFieldError(field: FormField, rule: FieldRuleName,
147
153
  * })
148
154
  *
149
155
  * form.fill({ email: 'ada@example.com', terms: true })
150
- * form.submit() // { success: true, value: { email: 'ada@example.com', terms: true } }
156
+ * const result = form.submit() // { success: true, value: { email: 'ada@example.com', terms: true } }
157
+ * const answers = await form.answer // { email: 'ada@example.com', terms: true }
151
158
  * ```
152
159
  */
153
160
  export declare function createForm(schema: FormSchema, options?: FormOptions): FormInterface;
@@ -155,7 +162,7 @@ export declare function createForm(schema: FormSchema, options?: FormOptions): F
155
162
  /** Matches an ISO calendar date string in `YYYY-MM-DD` form. */
156
163
  export declare const DATE_PATTERN: Readonly<RegExp>;
157
164
 
158
- /** Represents a calendar date, held as the control's own string. */
165
+ /** Represents a calendar date, held as the control's own `YYYY-MM-DD` string. */
159
166
  export declare interface DateField extends FieldBase {
160
167
  readonly control: 'date';
161
168
  readonly default?: string;
@@ -284,7 +291,7 @@ export declare const FIELD_CONTROLS: readonly FieldControl[];
284
291
  */
285
292
  export declare const FIELD_KEYS: Readonly<Record<FieldControl, readonly string[]>>;
286
293
 
287
- /** Caps the number of fields one schema may declare. */
294
+ /** Caps the number of fields one schema may declare, at 512. */
288
295
  export declare const FIELD_LIMIT = 512;
289
296
 
290
297
  /**
@@ -439,11 +446,11 @@ export declare type FieldValidator = (value: FieldValue | undefined, values: For
439
446
  export declare type FieldValue = string | number | boolean | readonly string[];
440
447
 
441
448
  /**
442
- * Represents one or more files.
449
+ * Represents one or more files, by name.
443
450
  *
444
451
  * @remarks
445
- * `accept` lists the media types and extensions the control offers, in the form the host
446
- * expects.
452
+ * A value is the names alone: bytes never enter the document. `accept` lists the media types
453
+ * and extensions the control offers, in the form the host expects.
447
454
  */
448
455
  export declare interface FileField extends FieldBase {
449
456
  readonly control: 'file';
@@ -452,7 +459,8 @@ export declare interface FileField extends FieldBase {
452
459
  }
453
460
 
454
461
  /**
455
- * Represents a form: a schema, the answers given against it, and the errors they carry.
462
+ * Implements `FormInterface` exactly, over an owned schema, the answers given against it, and the
463
+ * errors they carry.
456
464
  *
457
465
  * @remarks
458
466
  * The form owns its schema, so a later edit to the schema the caller passed changes nothing here.
@@ -626,6 +634,10 @@ export declare const FORM_STATUSES: readonly FormStatus[];
626
634
  /**
627
635
  * Resolves and interpolates one rule message.
628
636
  *
637
+ * @remarks
638
+ * A replacement in `messages` is read first and {@link RULE_MESSAGES} supplies the copy otherwise,
639
+ * and `{limit}` in whichever text wins is replaced with the rule's operand.
640
+ *
629
641
  * @param rule - The rule whose message to resolve.
630
642
  * @param limit - The optional operand substituted for `{limit}`.
631
643
  * @param messages - Optional rule-specific message replacements.
@@ -721,7 +733,7 @@ export declare interface FormGroup {
721
733
  }
722
734
 
723
735
  /**
724
- * Represents a form: a schema, the answers given against it, and the errors they carry.
736
+ * Declares the contract a form exposes: the state it holds and the calls that move it.
725
737
  *
726
738
  * @remarks
727
739
  * `valid` is true when the last completed evaluation found no error, and `dirty` is true once
@@ -787,7 +799,7 @@ export declare interface FormInterface {
787
799
  */
788
800
  field(name: string): FormField | undefined;
789
801
  /**
790
- * Answers several fields at once.
802
+ * Answers one field, or several at once.
791
803
  *
792
804
  * @param values - The answers to write, each keyed by its field name.
793
805
  */
@@ -808,12 +820,16 @@ export declare interface FormInterface {
808
820
  /**
809
821
  * Fails a field from outside, for what the rules cannot see.
810
822
  *
823
+ * @remarks
824
+ * One field holds one external failure, so a second call replaces the first, and the failure
825
+ * lasts until that field is filled again or the form is cleared.
826
+ *
811
827
  * @param name - The field's name.
812
828
  * @param message - What to tell the person.
813
829
  */
814
830
  invalidate(name: string, message: string): void;
815
831
  /**
816
- * Takes every field out of the form.
832
+ * Takes one field, several fields, or every field out of the form.
817
833
  *
818
834
  * @remarks
819
835
  * A disabled field is neither evaluated nor submitted. Its answer is kept, and so is any
@@ -839,7 +855,7 @@ export declare interface FormInterface {
839
855
  */
840
856
  disable(names: readonly string[]): void;
841
857
  /**
842
- * Puts every field back into the form.
858
+ * Puts one field, several fields, or every field back into the form.
843
859
  *
844
860
  * @remarks
845
861
  * An enabled field is evaluated and submitted again, and any invalidation held while it was
@@ -869,19 +885,20 @@ export declare interface FormInterface {
869
885
  */
870
886
  submit(): FormResult;
871
887
  /**
872
- * Returns every answer to {@link FormInterface.baseline}, the answers the form opened with.
888
+ * Returns every answer to the ones the form opened with.
873
889
  *
874
890
  * @remarks
875
- * The runtime disabled overlay resets with them, so {@link FormInterface.disabled} reads the
876
- * schema's declarations again.
891
+ * Those answers are {@link FormInterface.baseline}. The runtime disabled overlay resets with
892
+ * them, so {@link FormInterface.disabled} reads the schema's declarations again.
877
893
  */
878
894
  clear(): void;
879
895
  /**
880
896
  * Tears the form down, abandoning it when it has not settled.
881
897
  *
882
898
  * @remarks
883
- * A request from inside a listener defers teardown until the outermost mutation batch closes,
884
- * so an in-flight settlement can win and leave the form `settled` rather than `abandoned`.
899
+ * Tearing down twice does nothing the second time. A request from inside a listener defers
900
+ * teardown until the outermost mutation batch closes, so an in-flight settlement can win and
901
+ * leave the form `settled` rather than `abandoned`.
885
902
  */
886
903
  destroy(): void;
887
904
  }
@@ -984,7 +1001,7 @@ export declare type FormValues = Readonly<Record<string, FieldValue>>;
984
1001
  *
985
1002
  * @remarks
986
1003
  * The prototype-safe write of {@link defineEntry}, frozen: the entry is neither writable nor
987
- * configurable, so the record a parser hands back cannot be edited through the key it just filled.
1004
+ * configurable, so the record a parser hands back cannot be edited through the key it filled.
988
1005
  *
989
1006
  * @example
990
1007
  * ```ts
@@ -995,7 +1012,7 @@ export declare type FormValues = Readonly<Record<string, FieldValue>>;
995
1012
  */
996
1013
  export declare function freezeEntry<T>(target: Record<string, T>, name: string, value: T): void;
997
1014
 
998
- /** Caps the number of groups one schema may declare. */
1015
+ /** Caps the number of groups one schema may declare, at 64. */
999
1016
  export declare const GROUP_LIMIT = 64;
1000
1017
 
1001
1018
  /** Matches a signed or unsigned base-ten integer string. */
@@ -1036,6 +1053,10 @@ export declare function isFieldRule(input: unknown): input is FieldRule;
1036
1053
  /**
1037
1054
  * Determines whether an unknown value has a form field value shape.
1038
1055
  *
1056
+ * @remarks
1057
+ * A string, a finite number, a boolean, and a list of strings each qualify. A number that is not
1058
+ * finite does not, so `NaN` and `Infinity` are refused.
1059
+ *
1039
1060
  * @param input - The value to inspect.
1040
1061
  * @returns True if the value is a field value; false otherwise.
1041
1062
  */
@@ -1073,6 +1094,10 @@ export declare function isFormGroup(input: unknown): input is FormGroup;
1073
1094
  /**
1074
1095
  * Determines whether an unknown value is one exact structural form schema.
1075
1096
  *
1097
+ * @remarks
1098
+ * Structure alone is read. Domain soundness — a duplicate name, a bound no answer satisfies, a
1099
+ * breached budget — is {@link auditSchema}'s question.
1100
+ *
1076
1101
  * @param input - The value to inspect.
1077
1102
  * @returns True if the value is a structurally valid form schema; false otherwise.
1078
1103
  */
@@ -1094,7 +1119,7 @@ export declare function isFormStatus(input: unknown): input is FormStatus;
1094
1119
  */
1095
1120
  export declare function isFormValues(input: unknown): input is FormValues;
1096
1121
 
1097
- /** Caps the number of entries one list-valued answer may hold. */
1122
+ /** Caps the number of entries one list-valued answer may hold, at 1024. */
1098
1123
  export declare const LIST_LIMIT = 1024;
1099
1124
 
1100
1125
  /**
@@ -1114,6 +1139,10 @@ export declare function matchesAnswer(value: FieldValue | undefined): boolean;
1114
1139
  /**
1115
1140
  * Checks whether a value has the shape required by one field control.
1116
1141
  *
1142
+ * @remarks
1143
+ * Every write and every seeded value passes through this gate, and it reads `STRING_LIMIT` and
1144
+ * `LIST_LIMIT` before it consults the control, so no regular expression sees an over-long value.
1145
+ *
1117
1146
  * @param field - The field that owns the value.
1118
1147
  * @param value - The unknown value to inspect.
1119
1148
  * @returns True if the control can hold the value; false otherwise.
@@ -1138,10 +1167,10 @@ export declare function matchesValue(a: FieldValue, b: FieldValue): boolean;
1138
1167
  */
1139
1168
  export declare function matchesValues(a: FormValues, b: FormValues): boolean;
1140
1169
 
1141
- /** Caps the length, in UTF-16 code units, of a schema, group, or field name. */
1170
+ /** Caps the length, in UTF-16 code units, of a schema, group, or field name, at 128. */
1142
1171
  export declare const NAME_LIMIT = 128;
1143
1172
 
1144
- /** Caps the total number of records, arrays, and leaves one schema retains. */
1173
+ /** Caps the total number of records, arrays, and leaves one schema retains, at 16384. */
1145
1174
  export declare const NODE_LIMIT = 16384;
1146
1175
 
1147
1176
  /** Represents a number. */
@@ -1162,6 +1191,10 @@ export declare function parseForm(input: unknown): FormSchema | undefined;
1162
1191
  /**
1163
1192
  * Parses one answer against its field control.
1164
1193
  *
1194
+ * @remarks
1195
+ * A numeric string coerces to a number for a `number` field, and `'true'` and `'false'` coerce to
1196
+ * a boolean for a `confirm` field. Every other value must already have its control's shape.
1197
+ *
1165
1198
  * @param field - The field that defines the accepted value.
1166
1199
  * @param input - The unknown value to parse.
1167
1200
  * @returns The typed or lexically coerced field value, or `undefined` on refusal.
@@ -1189,7 +1222,7 @@ export declare interface PasswordField extends FieldBase {
1189
1222
  readonly mask?: string;
1190
1223
  }
1191
1224
 
1192
- /** Caps the accepted source length for an authored regular expression. */
1225
+ /** Caps the accepted source length for an authored regular expression, at 256. */
1193
1226
  export declare const PATTERN_LIMIT = 256;
1194
1227
 
1195
1228
  /** Holds the default failure copy for every named field rule. */
@@ -1219,10 +1252,10 @@ export declare interface SelectField extends FieldBase {
1219
1252
  */
1220
1253
  export declare function serializeForm(schema: FormSchema): JSONRecord;
1221
1254
 
1222
- /** Caps the length, in UTF-16 code units, of any single retained string. */
1255
+ /** Caps the length, in UTF-16 code units, of any single retained string, at 65536. */
1223
1256
  export declare const STRING_LIMIT = 65536;
1224
1257
 
1225
- /** Caps the total length, in UTF-16 code units, of every string one schema retains. */
1258
+ /** Caps the total length, in UTF-16 code units, of every string one schema retains, at 1048576. */
1226
1259
  export declare const TEXT_LIMIT = 1048576;
1227
1260
 
1228
1261
  /** Represents a single line of text. */
@@ -1235,7 +1268,7 @@ export declare interface TextField extends FieldBase {
1235
1268
  /** Matches a 24-hour time string with optional seconds. */
1236
1269
  export declare const TIME_PATTERN: Readonly<RegExp>;
1237
1270
 
1238
- /** Represents a time of day, held as the control's own string. */
1271
+ /** Represents a time of day, held as the control's own `HH:MM` string, with seconds optional. */
1239
1272
  export declare interface TimeField extends FieldBase {
1240
1273
  readonly control: 'time';
1241
1274
  readonly default?: string;
@@ -1,8 +1,8 @@
1
- import { EmitterErrorHandler } from '@orkestrel/emitter';
2
- import { EmitterHooks } from '@orkestrel/emitter';
3
- import { EmitterInterface } from '@orkestrel/emitter';
4
- import { JSONRecord } from '@orkestrel/contract';
5
- import { Result } from '@orkestrel/contract';
1
+ import type { EmitterErrorHandler } from '@orkestrel/emitter';
2
+ import type { EmitterHooks } from '@orkestrel/emitter';
3
+ import type { EmitterInterface } from '@orkestrel/emitter';
4
+ import type { JSONRecord } from '@orkestrel/contract';
5
+ import type { Result } from '@orkestrel/contract';
6
6
 
7
7
  /** Matches one or more ASCII letters or digits. */
8
8
  export declare const ALPHANUMERIC_PATTERN: Readonly<RegExp>;
@@ -41,7 +41,7 @@ export declare interface CheckboxField extends FieldBase {
41
41
  readonly default?: readonly string[];
42
42
  }
43
43
 
44
- /** Caps the number of choices one `select` or `checkbox` field may offer. */
44
+ /** Caps the number of choices one `select` or `checkbox` field may offer, at 1024. */
45
45
  export declare const CHOICE_LIMIT = 1024;
46
46
 
47
47
  /**
@@ -82,7 +82,7 @@ export declare function cloneValue(value: FieldValue): FieldValue;
82
82
  /** Matches a six-digit hexadecimal color string. */
83
83
  export declare const COLOR_PATTERN: Readonly<RegExp>;
84
84
 
85
- /** Represents a color, held as the control's own string. */
85
+ /** Represents a color, held as the control's own six-digit `#rrggbb` string. */
86
86
  export declare interface ColorField extends FieldBase {
87
87
  readonly control: 'color';
88
88
  readonly default?: string;
@@ -91,6 +91,10 @@ export declare interface ColorField extends FieldBase {
91
91
  /**
92
92
  * Computes the values explicitly seeded by a schema.
93
93
  *
94
+ * @remarks
95
+ * `password` and `file` declare no default, so a field of either control never appears in the
96
+ * result.
97
+ *
94
98
  * @param schema - The schema whose defaults to collect.
95
99
  * @returns A value record containing only fields with defaults.
96
100
  */
@@ -136,8 +140,10 @@ export declare function createFieldError(field: FormField, rule: FieldRuleName,
136
140
  * @throws A {@link FormError} coded `SCHEMA` when the schema is malformed, `FIELD` when
137
141
  * `options.values` names a field the schema does not declare, and `CONTROL` when a seeded value
138
142
  * is one its field's control cannot hold.
139
- * @example
143
+ * @example Open a form, answer it, and settle it
140
144
  * ```ts
145
+ * import { createForm } from '@orkestrel/form'
146
+ *
141
147
  * const form = createForm({
142
148
  * label: 'Sign up',
143
149
  * fields: [
@@ -147,7 +153,8 @@ export declare function createFieldError(field: FormField, rule: FieldRuleName,
147
153
  * })
148
154
  *
149
155
  * form.fill({ email: 'ada@example.com', terms: true })
150
- * form.submit() // { success: true, value: { email: 'ada@example.com', terms: true } }
156
+ * const result = form.submit() // { success: true, value: { email: 'ada@example.com', terms: true } }
157
+ * const answers = await form.answer // { email: 'ada@example.com', terms: true }
151
158
  * ```
152
159
  */
153
160
  export declare function createForm(schema: FormSchema, options?: FormOptions): FormInterface;
@@ -155,7 +162,7 @@ export declare function createForm(schema: FormSchema, options?: FormOptions): F
155
162
  /** Matches an ISO calendar date string in `YYYY-MM-DD` form. */
156
163
  export declare const DATE_PATTERN: Readonly<RegExp>;
157
164
 
158
- /** Represents a calendar date, held as the control's own string. */
165
+ /** Represents a calendar date, held as the control's own `YYYY-MM-DD` string. */
159
166
  export declare interface DateField extends FieldBase {
160
167
  readonly control: 'date';
161
168
  readonly default?: string;
@@ -284,7 +291,7 @@ export declare const FIELD_CONTROLS: readonly FieldControl[];
284
291
  */
285
292
  export declare const FIELD_KEYS: Readonly<Record<FieldControl, readonly string[]>>;
286
293
 
287
- /** Caps the number of fields one schema may declare. */
294
+ /** Caps the number of fields one schema may declare, at 512. */
288
295
  export declare const FIELD_LIMIT = 512;
289
296
 
290
297
  /**
@@ -439,11 +446,11 @@ export declare type FieldValidator = (value: FieldValue | undefined, values: For
439
446
  export declare type FieldValue = string | number | boolean | readonly string[];
440
447
 
441
448
  /**
442
- * Represents one or more files.
449
+ * Represents one or more files, by name.
443
450
  *
444
451
  * @remarks
445
- * `accept` lists the media types and extensions the control offers, in the form the host
446
- * expects.
452
+ * A value is the names alone: bytes never enter the document. `accept` lists the media types
453
+ * and extensions the control offers, in the form the host expects.
447
454
  */
448
455
  export declare interface FileField extends FieldBase {
449
456
  readonly control: 'file';
@@ -452,7 +459,8 @@ export declare interface FileField extends FieldBase {
452
459
  }
453
460
 
454
461
  /**
455
- * Represents a form: a schema, the answers given against it, and the errors they carry.
462
+ * Implements `FormInterface` exactly, over an owned schema, the answers given against it, and the
463
+ * errors they carry.
456
464
  *
457
465
  * @remarks
458
466
  * The form owns its schema, so a later edit to the schema the caller passed changes nothing here.
@@ -626,6 +634,10 @@ export declare const FORM_STATUSES: readonly FormStatus[];
626
634
  /**
627
635
  * Resolves and interpolates one rule message.
628
636
  *
637
+ * @remarks
638
+ * A replacement in `messages` is read first and {@link RULE_MESSAGES} supplies the copy otherwise,
639
+ * and `{limit}` in whichever text wins is replaced with the rule's operand.
640
+ *
629
641
  * @param rule - The rule whose message to resolve.
630
642
  * @param limit - The optional operand substituted for `{limit}`.
631
643
  * @param messages - Optional rule-specific message replacements.
@@ -721,7 +733,7 @@ export declare interface FormGroup {
721
733
  }
722
734
 
723
735
  /**
724
- * Represents a form: a schema, the answers given against it, and the errors they carry.
736
+ * Declares the contract a form exposes: the state it holds and the calls that move it.
725
737
  *
726
738
  * @remarks
727
739
  * `valid` is true when the last completed evaluation found no error, and `dirty` is true once
@@ -787,7 +799,7 @@ export declare interface FormInterface {
787
799
  */
788
800
  field(name: string): FormField | undefined;
789
801
  /**
790
- * Answers several fields at once.
802
+ * Answers one field, or several at once.
791
803
  *
792
804
  * @param values - The answers to write, each keyed by its field name.
793
805
  */
@@ -808,12 +820,16 @@ export declare interface FormInterface {
808
820
  /**
809
821
  * Fails a field from outside, for what the rules cannot see.
810
822
  *
823
+ * @remarks
824
+ * One field holds one external failure, so a second call replaces the first, and the failure
825
+ * lasts until that field is filled again or the form is cleared.
826
+ *
811
827
  * @param name - The field's name.
812
828
  * @param message - What to tell the person.
813
829
  */
814
830
  invalidate(name: string, message: string): void;
815
831
  /**
816
- * Takes every field out of the form.
832
+ * Takes one field, several fields, or every field out of the form.
817
833
  *
818
834
  * @remarks
819
835
  * A disabled field is neither evaluated nor submitted. Its answer is kept, and so is any
@@ -839,7 +855,7 @@ export declare interface FormInterface {
839
855
  */
840
856
  disable(names: readonly string[]): void;
841
857
  /**
842
- * Puts every field back into the form.
858
+ * Puts one field, several fields, or every field back into the form.
843
859
  *
844
860
  * @remarks
845
861
  * An enabled field is evaluated and submitted again, and any invalidation held while it was
@@ -869,19 +885,20 @@ export declare interface FormInterface {
869
885
  */
870
886
  submit(): FormResult;
871
887
  /**
872
- * Returns every answer to {@link FormInterface.baseline}, the answers the form opened with.
888
+ * Returns every answer to the ones the form opened with.
873
889
  *
874
890
  * @remarks
875
- * The runtime disabled overlay resets with them, so {@link FormInterface.disabled} reads the
876
- * schema's declarations again.
891
+ * Those answers are {@link FormInterface.baseline}. The runtime disabled overlay resets with
892
+ * them, so {@link FormInterface.disabled} reads the schema's declarations again.
877
893
  */
878
894
  clear(): void;
879
895
  /**
880
896
  * Tears the form down, abandoning it when it has not settled.
881
897
  *
882
898
  * @remarks
883
- * A request from inside a listener defers teardown until the outermost mutation batch closes,
884
- * so an in-flight settlement can win and leave the form `settled` rather than `abandoned`.
899
+ * Tearing down twice does nothing the second time. A request from inside a listener defers
900
+ * teardown until the outermost mutation batch closes, so an in-flight settlement can win and
901
+ * leave the form `settled` rather than `abandoned`.
885
902
  */
886
903
  destroy(): void;
887
904
  }
@@ -984,7 +1001,7 @@ export declare type FormValues = Readonly<Record<string, FieldValue>>;
984
1001
  *
985
1002
  * @remarks
986
1003
  * The prototype-safe write of {@link defineEntry}, frozen: the entry is neither writable nor
987
- * configurable, so the record a parser hands back cannot be edited through the key it just filled.
1004
+ * configurable, so the record a parser hands back cannot be edited through the key it filled.
988
1005
  *
989
1006
  * @example
990
1007
  * ```ts
@@ -995,7 +1012,7 @@ export declare type FormValues = Readonly<Record<string, FieldValue>>;
995
1012
  */
996
1013
  export declare function freezeEntry<T>(target: Record<string, T>, name: string, value: T): void;
997
1014
 
998
- /** Caps the number of groups one schema may declare. */
1015
+ /** Caps the number of groups one schema may declare, at 64. */
999
1016
  export declare const GROUP_LIMIT = 64;
1000
1017
 
1001
1018
  /** Matches a signed or unsigned base-ten integer string. */
@@ -1036,6 +1053,10 @@ export declare function isFieldRule(input: unknown): input is FieldRule;
1036
1053
  /**
1037
1054
  * Determines whether an unknown value has a form field value shape.
1038
1055
  *
1056
+ * @remarks
1057
+ * A string, a finite number, a boolean, and a list of strings each qualify. A number that is not
1058
+ * finite does not, so `NaN` and `Infinity` are refused.
1059
+ *
1039
1060
  * @param input - The value to inspect.
1040
1061
  * @returns True if the value is a field value; false otherwise.
1041
1062
  */
@@ -1073,6 +1094,10 @@ export declare function isFormGroup(input: unknown): input is FormGroup;
1073
1094
  /**
1074
1095
  * Determines whether an unknown value is one exact structural form schema.
1075
1096
  *
1097
+ * @remarks
1098
+ * Structure alone is read. Domain soundness — a duplicate name, a bound no answer satisfies, a
1099
+ * breached budget — is {@link auditSchema}'s question.
1100
+ *
1076
1101
  * @param input - The value to inspect.
1077
1102
  * @returns True if the value is a structurally valid form schema; false otherwise.
1078
1103
  */
@@ -1094,7 +1119,7 @@ export declare function isFormStatus(input: unknown): input is FormStatus;
1094
1119
  */
1095
1120
  export declare function isFormValues(input: unknown): input is FormValues;
1096
1121
 
1097
- /** Caps the number of entries one list-valued answer may hold. */
1122
+ /** Caps the number of entries one list-valued answer may hold, at 1024. */
1098
1123
  export declare const LIST_LIMIT = 1024;
1099
1124
 
1100
1125
  /**
@@ -1114,6 +1139,10 @@ export declare function matchesAnswer(value: FieldValue | undefined): boolean;
1114
1139
  /**
1115
1140
  * Checks whether a value has the shape required by one field control.
1116
1141
  *
1142
+ * @remarks
1143
+ * Every write and every seeded value passes through this gate, and it reads `STRING_LIMIT` and
1144
+ * `LIST_LIMIT` before it consults the control, so no regular expression sees an over-long value.
1145
+ *
1117
1146
  * @param field - The field that owns the value.
1118
1147
  * @param value - The unknown value to inspect.
1119
1148
  * @returns True if the control can hold the value; false otherwise.
@@ -1138,10 +1167,10 @@ export declare function matchesValue(a: FieldValue, b: FieldValue): boolean;
1138
1167
  */
1139
1168
  export declare function matchesValues(a: FormValues, b: FormValues): boolean;
1140
1169
 
1141
- /** Caps the length, in UTF-16 code units, of a schema, group, or field name. */
1170
+ /** Caps the length, in UTF-16 code units, of a schema, group, or field name, at 128. */
1142
1171
  export declare const NAME_LIMIT = 128;
1143
1172
 
1144
- /** Caps the total number of records, arrays, and leaves one schema retains. */
1173
+ /** Caps the total number of records, arrays, and leaves one schema retains, at 16384. */
1145
1174
  export declare const NODE_LIMIT = 16384;
1146
1175
 
1147
1176
  /** Represents a number. */
@@ -1162,6 +1191,10 @@ export declare function parseForm(input: unknown): FormSchema | undefined;
1162
1191
  /**
1163
1192
  * Parses one answer against its field control.
1164
1193
  *
1194
+ * @remarks
1195
+ * A numeric string coerces to a number for a `number` field, and `'true'` and `'false'` coerce to
1196
+ * a boolean for a `confirm` field. Every other value must already have its control's shape.
1197
+ *
1165
1198
  * @param field - The field that defines the accepted value.
1166
1199
  * @param input - The unknown value to parse.
1167
1200
  * @returns The typed or lexically coerced field value, or `undefined` on refusal.
@@ -1189,7 +1222,7 @@ export declare interface PasswordField extends FieldBase {
1189
1222
  readonly mask?: string;
1190
1223
  }
1191
1224
 
1192
- /** Caps the accepted source length for an authored regular expression. */
1225
+ /** Caps the accepted source length for an authored regular expression, at 256. */
1193
1226
  export declare const PATTERN_LIMIT = 256;
1194
1227
 
1195
1228
  /** Holds the default failure copy for every named field rule. */
@@ -1219,10 +1252,10 @@ export declare interface SelectField extends FieldBase {
1219
1252
  */
1220
1253
  export declare function serializeForm(schema: FormSchema): JSONRecord;
1221
1254
 
1222
- /** Caps the length, in UTF-16 code units, of any single retained string. */
1255
+ /** Caps the length, in UTF-16 code units, of any single retained string, at 65536. */
1223
1256
  export declare const STRING_LIMIT = 65536;
1224
1257
 
1225
- /** Caps the total length, in UTF-16 code units, of every string one schema retains. */
1258
+ /** Caps the total length, in UTF-16 code units, of every string one schema retains, at 1048576. */
1226
1259
  export declare const TEXT_LIMIT = 1048576;
1227
1260
 
1228
1261
  /** Represents a single line of text. */
@@ -1235,7 +1268,7 @@ export declare interface TextField extends FieldBase {
1235
1268
  /** Matches a 24-hour time string with optional seconds. */
1236
1269
  export declare const TIME_PATTERN: Readonly<RegExp>;
1237
1270
 
1238
- /** Represents a time of day, held as the control's own string. */
1271
+ /** Represents a time of day, held as the control's own `HH:MM` string, with seconds optional. */
1239
1272
  export declare interface TimeField extends FieldBase {
1240
1273
  readonly control: 'time';
1241
1274
  readonly default?: string;