ngx-t-forms-types 0.0.35 → 0.0.38

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 (47) hide show
  1. package/dist/interfaces/Form/formInterface.d.ts +18 -0
  2. package/dist/interfaces/Form/index.d.ts +2 -2
  3. package/dist/interfaces/FormBuilder/DefaultEelement.js +2 -2
  4. package/dist/interfaces/FormBuilder/FormInputKeys.d.ts +2 -0
  5. package/dist/interfaces/FormBuilder/FormInputKeys.js +2 -0
  6. package/dist/interfaces/FormBuilder/elementEditor.d.ts +8 -0
  7. package/dist/interfaces/FormBuilder/elementEditor.js +8 -0
  8. package/dist/interfaces/FormBuilder/inputConfig/ElementEditConfig.js +25 -3
  9. package/dist/interfaces/Import/ImportIdentity.d.ts +132 -1
  10. package/dist/interfaces/Import/ImportRecipe.d.ts +423 -0
  11. package/dist/interfaces/Import/ImportRecipe.js +19 -0
  12. package/dist/interfaces/Import/ImportRowState.d.ts +84 -7
  13. package/dist/interfaces/Import/index.d.ts +4 -2
  14. package/dist/interfaces/Import/index.js +1 -1
  15. package/dist/interfaces/Tower/ITowerFormSteps.d.ts +19 -0
  16. package/dist/interfaces/Tower/index.d.ts +2 -1
  17. package/dist/interfaces/environment/IStoreFunctions.d.ts +42 -2
  18. package/dist/interfaces/environment/environment.d.ts +203 -0
  19. package/dist/interfaces/environment/environment.js +12 -1
  20. package/dist/interfaces/environment/index.d.ts +2 -2
  21. package/dist/interfaces/environment/index.js +2 -1
  22. package/dist/interfaces/formInput/APIDataFetchingConfigurationInterface.d.ts +10 -2
  23. package/dist/interfaces/formInput/BasicFormInputInterface.d.ts +15 -0
  24. package/dist/interfaces/formInput/MinimumInputRequiredInterface.d.ts +14 -0
  25. package/dist/interfaces/formInput/MinimumInputRequiredInterface.js +14 -0
  26. package/dist/interfaces/formInput/calculatedFieldRules.d.ts +31 -1
  27. package/dist/interfaces/formInput/calculatedFieldRules.js +16 -1
  28. package/dist/interfaces/formInput/index.d.ts +2 -2
  29. package/dist/interfaces/formInput/index.js +2 -1
  30. package/dist/interfaces/workflow/DocumentSectionConfigurationsInterface.d.ts +22 -1
  31. package/dist/interfaces/workflow/DocumentSectionConfigurationsInterface.js +6 -0
  32. package/dist/interfaces/workflow/index.d.ts +2 -2
  33. package/dist/schemas/CalculatedFieldRulesSchema.js +2 -1
  34. package/dist/schemas/FormInputSchema.js +9 -1
  35. package/dist/schemas/FormSchema.d.ts +35 -0
  36. package/dist/schemas/FormSchema.js +57 -0
  37. package/dist/schemas/index.d.ts +3 -2
  38. package/dist/schemas/index.js +2 -2
  39. package/dist/schemas/tests/FormInputValidator.spec.js +27 -0
  40. package/dist/skillet/extra-members.d.ts +1 -1
  41. package/dist/skillet/input-members.d.ts +2 -2
  42. package/dist/skillet/input-members.js +2 -1
  43. package/dist/skillet/members/calculated-field.d.ts +4 -4
  44. package/dist/skillet/members/calculated-field.js +6 -5
  45. package/dist/skillet/members/table.d.ts +1 -1
  46. package/dist/skillet/shared-types.js +1 -1
  47. package/package.json +1 -1
@@ -0,0 +1,423 @@
1
+ import type { ImportIdentity } from './ImportIdentity.js';
2
+ /**
3
+ * Reserved key of a mapped import row: the ids of the source rows it was built
4
+ * from. The import controller strips it before the row reaches a form, keeps
5
+ * it in `ImportRowState.originalData`, and never treats it as a field.
6
+ *
7
+ * @public
8
+ */
9
+ export declare const SOURCE_ROWS_KEY = "$sourceRows";
10
+ /**
11
+ * Reserved key of a mapped import row (and of each sub-row a mapping builds):
12
+ * for every choice cell the mapping could not settle up front, the other
13
+ * columns the option must agree with — an {@link OptionMatchCriteriaByCell}.
14
+ * The import controller strips it before the row reaches a form, keeps it in
15
+ * `ImportRowState.originalData`, and matches the cell against the options the
16
+ * form loads for the row only among those that agree with every criterion.
17
+ *
18
+ * @public
19
+ */
20
+ export declare const OPTION_MATCH_KEY = "$optionMatch";
21
+ /**
22
+ * What one choice cell must agree with besides its own text — a recipe's
23
+ * {@link ChoiceRule.matchOn} and {@link ChoiceRule.narrow} rules with the
24
+ * row's values filled in. An option is a match only when its `matchOn`
25
+ * attribute (any text it has, when absent) names the cell's text AND every
26
+ * `equals` attribute equals the given value, compared normalised.
27
+ *
28
+ * @public
29
+ */
30
+ export interface OptionMatchCriteria {
31
+ /** The option attribute the cell's text names; absent compares every text an option has. */
32
+ readonly matchOn?: string;
33
+ /** Option attribute → the value it must equal on this row (normalised on compare). */
34
+ readonly equals: Readonly<Record<string, string>>;
35
+ }
36
+ /**
37
+ * The value of {@link OPTION_MATCH_KEY}: cell key (`formControlName`) →
38
+ * what that cell's option must agree with.
39
+ *
40
+ * @public
41
+ */
42
+ export type OptionMatchCriteriaByCell = Readonly<Record<string, OptionMatchCriteria>>;
43
+ /**
44
+ * A saved, named way to turn one kind of source spreadsheet — a user's own
45
+ * export, not the import template — into import rows for one workflow.
46
+ *
47
+ * Plain data: column sources, value maps and typed rules. Never an expression
48
+ * or code, because a recipe is shared by every user of the workflow.
49
+ *
50
+ * @public
51
+ */
52
+ export interface ImportRecipe {
53
+ /** UUID; immutable. Saves address a recipe by it, never by name. */
54
+ readonly id: string;
55
+ /** Unique within the workflow, compared trimmed and case-insensitively. */
56
+ readonly name: string;
57
+ /** The workflow the recipe imports into. */
58
+ readonly workflowId: string;
59
+ /** Optimistic-concurrency guard: 1 when created, +1 on every update. */
60
+ readonly revision: number;
61
+ /** Version of this shape; a newer one than the library knows is refused. */
62
+ readonly schemaVersion: 1;
63
+ /** Which sheet and header row of the source file the recipe reads. */
64
+ readonly source: RecipeSource;
65
+ /** Import column key → where its cell comes from. A key left out is not filled. */
66
+ readonly columns: Readonly<Record<string, ColumnSource>>;
67
+ /** Choice column key → how a source text is matched to one of its options. */
68
+ readonly choices: Readonly<Record<string, ChoiceRule>>;
69
+ /**
70
+ * Source rows to import. Rules joined by `and` must all hold; `or` starts
71
+ * another group, and a row is kept when any one group holds — see
72
+ * {@link RowRule.join}. Absent imports every row.
73
+ */
74
+ readonly rowRules?: readonly RowRule[];
75
+ /** Folds several source rows into one record with a detail list. */
76
+ readonly grouping?: GroupingRule;
77
+ /**
78
+ * The import's own choices saved with the mapping — how repeats are told
79
+ * apart and combined, and how the rows are checked — so whoever uses the
80
+ * mapping next imports exactly the way it was set up. Absent leaves the
81
+ * import's defaults.
82
+ */
83
+ readonly settings?: ImportRecipeSettings;
84
+ /** User id of whoever created the recipe. */
85
+ readonly createdBy?: string;
86
+ /** User id of whoever saved the current revision. */
87
+ readonly updatedBy?: string;
88
+ /** When the current revision was saved, as ISO text. */
89
+ readonly updatedAt?: string;
90
+ }
91
+ /**
92
+ * Where a recipe reads its source.
93
+ *
94
+ * @public
95
+ */
96
+ export interface RecipeSource {
97
+ /** Sheet name; absent means the first sheet. */
98
+ readonly sheet?: string;
99
+ /** 1-based row that holds the headers; data starts below it. */
100
+ readonly headerRow: number;
101
+ /** The headers at save time, normalised — what offers the recipe for a matching file. */
102
+ readonly headerSignature: readonly string[];
103
+ }
104
+ /**
105
+ * Where one import column's cell comes from.
106
+ *
107
+ * - `column` — a source column, optionally transformed.
108
+ * - `constant` — the same text on every row.
109
+ * - `join` — several source columns joined by `separator`; blanks are skipped.
110
+ * - `random` — one of `values` (option stored values of a choice field) picked
111
+ * per row. The pick is a hash of `seed` and the source row id, so it is
112
+ * stable while one file is mapped and differs between fields; among options
113
+ * that depend on another input, only those the row's parent allows are drawn.
114
+ * - `skip` — deliberately left empty.
115
+ *
116
+ * @public
117
+ */
118
+ export type ColumnSource = {
119
+ readonly kind: 'column';
120
+ readonly column: string;
121
+ readonly transforms?: readonly TransformStep[];
122
+ } | {
123
+ readonly kind: 'constant';
124
+ readonly value: string;
125
+ } | {
126
+ readonly kind: 'join';
127
+ readonly columns: readonly string[];
128
+ readonly separator: string;
129
+ } | {
130
+ readonly kind: 'random';
131
+ readonly values: readonly string[];
132
+ readonly seed: string;
133
+ } | {
134
+ readonly kind: 'skip';
135
+ };
136
+ /**
137
+ * How a source text is matched to one option of a choice column. A `valueMap`
138
+ * answer wins outright; otherwise an option matches when its `matchOn`
139
+ * attribute names the text AND it satisfies every `narrow` rule — the columns
140
+ * are considered together, so a label shared by several records (two
141
+ * "Finance" departments) is told apart by another column (their codes). A
142
+ * text still tied or unmatched is passed through for the import's own
143
+ * resolver, carrying the row's criteria under {@link OPTION_MATCH_KEY} so
144
+ * options loaded only while the row is checked are matched the same way.
145
+ *
146
+ * @public
147
+ */
148
+ export interface ChoiceRule {
149
+ /** The option attribute the text is compared with; absent compares every text an option has. */
150
+ readonly matchOn?: string;
151
+ /** Further columns the option must agree with; an option must satisfy all of them. */
152
+ readonly narrow?: readonly NarrowRule[];
153
+ /** Answers the user gave for specific source texts. */
154
+ readonly valueMap?: readonly ValueMapEntry[];
155
+ }
156
+ /**
157
+ * Keeps the options whose `attribute` equals a source column's value on the
158
+ * same row, or a fixed value.
159
+ *
160
+ * @public
161
+ */
162
+ export interface NarrowRule {
163
+ /** Option attribute to compare. */
164
+ readonly attribute: string;
165
+ /** What it must equal: the row's value in a source column, or a fixed text. */
166
+ readonly equals: {
167
+ readonly column: string;
168
+ } | {
169
+ readonly value: string;
170
+ };
171
+ }
172
+ /**
173
+ * One answer the user gave: this source text means this option.
174
+ *
175
+ * @public
176
+ */
177
+ export interface ValueMapEntry {
178
+ /** The source text, normalised (trimmed, whitespace collapsed, case folded). */
179
+ readonly sourceText: string;
180
+ /**
181
+ * Source column → normalised value the answer is limited to — for a text
182
+ * that means different options under different values of a narrowing
183
+ * column. Absent applies everywhere.
184
+ */
185
+ readonly context?: Readonly<Record<string, string>>;
186
+ /** The option's stored value, as the template lists it (`ImportTemplateOption.value`). */
187
+ readonly optionValue: string;
188
+ /** The option's label when the answer was saved, for messages when it is gone. */
189
+ readonly optionLabel: string;
190
+ }
191
+ /**
192
+ * One typed step that rewrites a source cell's text. Never code.
193
+ *
194
+ * @public
195
+ */
196
+ export type TransformStep = {
197
+ readonly op: 'trim';
198
+ } | {
199
+ readonly op: 'case';
200
+ readonly to: 'upper' | 'lower' | 'title';
201
+ } | {
202
+ readonly op: 'replace';
203
+ readonly find: string;
204
+ readonly with: string;
205
+ } | {
206
+ readonly op: 'split';
207
+ readonly on: string;
208
+ readonly take: number;
209
+ } | {
210
+ readonly op: 'date';
211
+ readonly format: 'dd/mm/yyyy' | 'mm/dd/yyyy' | 'yyyy-mm-dd' | 'excel-serial';
212
+ } | {
213
+ readonly op: 'number';
214
+ readonly decimal: '.' | ',';
215
+ readonly stripCurrency: boolean;
216
+ } | {
217
+ readonly op: 'scale';
218
+ readonly by: number;
219
+ } | {
220
+ readonly op: 'affix';
221
+ readonly prefix?: string;
222
+ readonly suffix?: string;
223
+ };
224
+ /**
225
+ * A condition on a source row's cell. A recipe's rules read as `&&` / `||`
226
+ * with the usual precedence: `and` binds tighter than `or`, so
227
+ * `A and B or C` keeps a row when A and B both hold, or when C does.
228
+ *
229
+ * @public
230
+ */
231
+ export interface RowRule {
232
+ /** Source column. */
233
+ readonly column: string;
234
+ /** Comparison; `gt` / `lt` compare numbers, the rest normalised text. */
235
+ readonly op: 'is' | 'isNot' | 'contains' | 'blank' | 'notBlank' | 'gt' | 'lt';
236
+ /** Operand; unused by `blank` / `notBlank`. */
237
+ readonly value?: string;
238
+ /**
239
+ * How the rule joins the rule before it: `and` (the default) adds it to
240
+ * that rule's group, `or` starts a new group. Ignored on the first rule.
241
+ */
242
+ readonly join?: 'and' | 'or';
243
+ }
244
+ /**
245
+ * The import's own choices saved with a recipe — see
246
+ * {@link ImportRecipe.settings}. Every member is optional; one left out keeps
247
+ * the import's default.
248
+ *
249
+ * @public
250
+ */
251
+ export interface ImportRecipeSettings {
252
+ /**
253
+ * How repeated rows are told apart, which row a repeat keeps, and which
254
+ * fields it takes from the whole group (`sum`, `join`, `collect`, …) — the
255
+ * run's identity as the user set it. A key, field or list the form no
256
+ * longer has is dropped when the mapping is applied.
257
+ */
258
+ readonly identity?: ImportIdentity;
259
+ /** Whether identical API calls are shared between rows while they are checked. */
260
+ readonly apiCache?: boolean;
261
+ }
262
+ /**
263
+ * Folds source rows into records: one record per distinct tuple of `by`, its
264
+ * rows becoming the detail rows of one MultipleInput.
265
+ *
266
+ * @public
267
+ */
268
+ export interface GroupingRule {
269
+ /** Source columns whose values identify a record. */
270
+ readonly by: readonly string[];
271
+ /** `formControlName` of the MultipleInput the grouped rows fill. */
272
+ readonly detailTarget: string;
273
+ /** Main-sheet column key → how the group's values combine; `first` by default. */
274
+ readonly aggregate?: Readonly<Record<string, 'first' | 'last' | 'sum' | 'min' | 'max' | 'count' | 'join'>>;
275
+ }
276
+ /**
277
+ * One sheet of a source file as a grid of cell texts, before any header row is chosen.
278
+ *
279
+ * @public
280
+ */
281
+ export interface SourceSheet {
282
+ /** The sheet's tab name. */
283
+ readonly name: string;
284
+ /** Rows top to bottom, cells left to right, as trimmed text; blanks are `''`. */
285
+ readonly grid: readonly (readonly string[])[];
286
+ }
287
+ /**
288
+ * One data row of a source sheet.
289
+ *
290
+ * @public
291
+ */
292
+ export interface SourceRow {
293
+ /** UUID minted when the file was read; identifies the row for this import session only. */
294
+ readonly id: string;
295
+ /** Sheet the row is on. */
296
+ readonly sheet: string;
297
+ /** 1-based row number in that sheet. */
298
+ readonly row: number;
299
+ /** Header → cell text. */
300
+ readonly cells: Readonly<Record<string, string>>;
301
+ }
302
+ /**
303
+ * A source sheet read under a chosen header row.
304
+ *
305
+ * @public
306
+ */
307
+ export interface SourceTable {
308
+ /** Sheet the table was read from. */
309
+ readonly sheet: string;
310
+ /** 1-based header row. */
311
+ readonly headerRow: number;
312
+ /** Headers left to right; blank and repeated headers are made unique. */
313
+ readonly headers: readonly string[];
314
+ /** Data rows below the header row; wholly blank rows are left out. */
315
+ readonly rows: readonly SourceRow[];
316
+ }
317
+ /**
318
+ * What an uploaded file is, as far as the import is concerned.
319
+ *
320
+ * - `template` — the import template (or a sheet shaped exactly like it): it
321
+ * goes through today's import unchanged.
322
+ * - `near-template` — the template with headers renamed or added; `suggestion`
323
+ * maps it.
324
+ * - `own` — the user's own export; `suggestion` is a starting mapping.
325
+ *
326
+ * Both of the last two carry `saved`: the workflow's recipes whose headers
327
+ * resemble the file's.
328
+ *
329
+ * @public
330
+ */
331
+ export type SourceVerdict = {
332
+ readonly kind: 'template';
333
+ } | {
334
+ readonly kind: 'near-template';
335
+ readonly score: number;
336
+ readonly suggestion: ImportRecipe;
337
+ readonly saved: readonly SavedRecipeMatch[];
338
+ } | {
339
+ readonly kind: 'own';
340
+ readonly score: number;
341
+ readonly suggestion: ImportRecipe;
342
+ readonly saved: readonly SavedRecipeMatch[];
343
+ };
344
+ /**
345
+ * A saved recipe offered for a file, with how well it fits.
346
+ *
347
+ * @public
348
+ */
349
+ export interface SavedRecipeMatch {
350
+ /** The recipe. */
351
+ readonly recipe: ImportRecipe;
352
+ /** Jaccard similarity of its header signature to the file's headers, 0–1. */
353
+ readonly similarity: number;
354
+ /** What no longer fits; a recipe with blocking issues is still offered. */
355
+ readonly check: RecipeCheck;
356
+ }
357
+ /**
358
+ * One broken reference in a recipe.
359
+ *
360
+ * @public
361
+ */
362
+ export interface RecipeIssue {
363
+ /** What is wrong. */
364
+ readonly kind: 'targetMissing' | 'requiredUnmapped' | 'sourceColumnMissing' | 'optionMissing' | 'optionUnverifiable' | 'attributeMissing' | 'groupingInvalid' | 'schemaNewer';
365
+ /** `true` when the recipe cannot be validated or saved until it is fixed. */
366
+ readonly blocking: boolean;
367
+ /** The import column key concerned, when there is one. */
368
+ readonly target?: string;
369
+ /** The source column concerned, when there is one. */
370
+ readonly source?: string;
371
+ /** The issue in plain words. */
372
+ readonly detail: string;
373
+ }
374
+ /**
375
+ * The result of checking a recipe against a form and, optionally, a file.
376
+ *
377
+ * @public
378
+ */
379
+ export interface RecipeCheck {
380
+ /** `true` when no issue is blocking. */
381
+ readonly ok: boolean;
382
+ /** Every issue found, blocking first. */
383
+ readonly issues: readonly RecipeIssue[];
384
+ }
385
+ /**
386
+ * How one choice cell was settled by a recipe.
387
+ *
388
+ * @public
389
+ */
390
+ export interface ChoiceOutcome {
391
+ /** `value`: `cell` is an option's stored value. `pass-through`: `cell` is the original text. */
392
+ readonly kind: 'value' | 'pass-through';
393
+ /** The cell to put in the mapped row. */
394
+ readonly cell: unknown;
395
+ /** Which step decided, or why none did. */
396
+ readonly reason: 'map' | 'rule' | 'unique' | 'tied' | 'unmatched' | 'partial';
397
+ }
398
+ /**
399
+ * The rows a recipe produced, ready for the import controller.
400
+ *
401
+ * @public
402
+ */
403
+ export interface MappedImport {
404
+ /** Template-shaped rows, each carrying {@link SOURCE_ROWS_KEY}. */
405
+ readonly rows: Record<string, unknown>[];
406
+ /** Counts for the mapper's summary. */
407
+ readonly stats: MappingStats;
408
+ }
409
+ /**
410
+ * Counts describing a mapping run.
411
+ *
412
+ * @public
413
+ */
414
+ export interface MappingStats {
415
+ /** Required columns the recipe fills. */
416
+ readonly requiredMapped: number;
417
+ /** Required columns of the form. */
418
+ readonly requiredTotal: number;
419
+ /** Choice column key → cells passed through unmatched or tied. */
420
+ readonly unmatchedValues: Readonly<Record<string, number>>;
421
+ /** Source rows the row rules left out. */
422
+ readonly filteredOut: number;
423
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Reserved key of a mapped import row: the ids of the source rows it was built
3
+ * from. The import controller strips it before the row reaches a form, keeps
4
+ * it in `ImportRowState.originalData`, and never treats it as a field.
5
+ *
6
+ * @public
7
+ */
8
+ export const SOURCE_ROWS_KEY = '$sourceRows';
9
+ /**
10
+ * Reserved key of a mapped import row (and of each sub-row a mapping builds):
11
+ * for every choice cell the mapping could not settle up front, the other
12
+ * columns the option must agree with — an {@link OptionMatchCriteriaByCell}.
13
+ * The import controller strips it before the row reaches a form, keeps it in
14
+ * `ImportRowState.originalData`, and matches the cell against the options the
15
+ * form loads for the row only among those that agree with every criterion.
16
+ *
17
+ * @public
18
+ */
19
+ export const OPTION_MATCH_KEY = '$optionMatch';
@@ -1,3 +1,4 @@
1
+ import type { ImportCombineOp } from './ImportIdentity.js';
1
2
  /**
2
3
  * Lifecycle states for a single import row driven by the import controller in
3
4
  * `ngx-t-forms`.
@@ -82,15 +83,91 @@ export interface ImportRowState {
82
83
  */
83
84
  optionChoices?: Record<string, ImportOptionChoice[]>;
84
85
  /**
85
- * The `rowIndex` of the earlier row this row repeats, when the session was
86
- * given an `ImportIdentity` and this row's identity matches. Always the
87
- * LOWEST index of the matching group — first wins — so the relation is
88
- * stable and a host can offer "go to row N". Set under both duplicate
89
- * policies; under `skip` the row's `status` is `duplicate` as well. Cleared
90
- * when a re-run changes the identities so that the row no longer repeats
91
- * anything.
86
+ * The `rowIndex` of the row kept for this row's group, when the session was
87
+ * given an `ImportIdentity` and this row's identity matches. The kept row is
88
+ * the LOWEST index of the group — first wins — unless `ImportIdentity.keep`
89
+ * is `last` or the host kept another row with the controller's `keepRow`; it
90
+ * is stable between such choices, so a host can offer "go to row N". Set
91
+ * under both duplicate policies; under `skip` the row's `status` is
92
+ * `duplicate` as well. Cleared when a re-run changes the identities so that
93
+ * the row no longer repeats anything.
92
94
  */
93
95
  duplicateOf?: number;
96
+ /**
97
+ * formControlName → how this row's value was taken from its duplicate
98
+ * group, for each field `ImportIdentity.combine` names. Set on the row a
99
+ * group keeps once it has been checked with the combined values; absent on
100
+ * a row that stands alone. `settledValue` already holds the outcome — this
101
+ * says where it came from.
102
+ */
103
+ combined?: Record<string, ImportCombinedValue>;
104
+ /**
105
+ * formControlName of a list field → how the repeats inside its rows were
106
+ * folded (`ImportIdentity.lists`), for each list some row of which repeated
107
+ * another. Absent when no list of the row had a repeat. `settledValue`
108
+ * holds the list as it was checked — the rows that remained — and this
109
+ * says which rows each of them stands for.
110
+ */
111
+ folded?: Record<string, ImportListFold>;
112
+ }
113
+ /**
114
+ * Where a kept row's value of a combined field came from — see
115
+ * {@link ImportRowState.combined}.
116
+ *
117
+ * @public
118
+ */
119
+ export interface ImportCombinedValue {
120
+ /** How the group's values were combined. */
121
+ op: ImportCombineOp;
122
+ /**
123
+ * The value the row was checked with: a number, or for `join` the joined
124
+ * text. Absent when no row of the group had a value there, and for
125
+ * `collect`, whose outcome is the list itself (see `items`).
126
+ */
127
+ value?: number | string;
128
+ /**
129
+ * `rowIndex` of every row of the group, in sheet order, the kept row
130
+ * included. For a group inside a list ({@link ImportListFoldGroup}), the
131
+ * position of each row in the list as it came, from 0.
132
+ */
133
+ rows: number[];
134
+ /** The rows whose cell held a value the op could read, and so went into the outcome; blank ones are left out. */
135
+ counted: number[];
136
+ /** The rows whose cell held something the op could not read; when any, the kept row is `invalid`. */
137
+ rejected: number[];
138
+ /** For `collect`: how many list rows the counted rows' lists held together — the kept row's list before any fold. */
139
+ items?: number;
140
+ }
141
+ /**
142
+ * How the repeats inside one list of a row were folded — see
143
+ * {@link ImportRowState.folded}.
144
+ *
145
+ * @public
146
+ */
147
+ export interface ImportListFold {
148
+ /** How many rows the list had as the sheet gave it. */
149
+ rows: number;
150
+ /** How many rows remained, and were checked. */
151
+ kept: number;
152
+ /** Each group of rows that repeated one another, in the order of their kept rows. */
153
+ groups: ImportListFoldGroup[];
154
+ }
155
+ /**
156
+ * One group of repeated rows inside a list — see {@link ImportListFold}.
157
+ * Positions count the rows of the list as the sheet gave it, from 0, except
158
+ * `at`, which counts the rows that remained.
159
+ *
160
+ * @public
161
+ */
162
+ export interface ImportListFoldGroup {
163
+ /** The position of the row the group kept, in the list as it came. */
164
+ keeper: number;
165
+ /** The position of the kept row in the list as it was checked — its index in `settledValue`'s list. */
166
+ at: number;
167
+ /** The position of every row of the group, in list order, the kept one included. */
168
+ rows: number[];
169
+ /** Child `formControlName` → how the kept row's value was taken from the group, for each child the list's `combine` names. */
170
+ combined: Record<string, ImportCombinedValue>;
94
171
  }
95
172
  /**
96
173
  * One option an imported cell could stand for.
@@ -1,3 +1,5 @@
1
- export { ImportOptionCandidate, ImportOptionChoice, ImportRowState, ImportRowStatus } from './ImportRowState.js';
1
+ export { ImportCombinedValue, ImportListFold, ImportListFoldGroup, ImportOptionCandidate, ImportOptionChoice, ImportRowState, ImportRowStatus } from './ImportRowState.js';
2
2
  export { ImportProgress } from './ImportProgress.js';
3
- export { ImportIdentity } from './ImportIdentity.js';
3
+ export { ImportCombineOp, ImportIdentity, ImportListIdentity } from './ImportIdentity.js';
4
+ export { OPTION_MATCH_KEY, SOURCE_ROWS_KEY } from './ImportRecipe.js';
5
+ export type { ChoiceOutcome, ChoiceRule, OptionMatchCriteria, OptionMatchCriteriaByCell, ColumnSource, GroupingRule, ImportRecipe, ImportRecipeSettings, MappedImport, MappingStats, NarrowRule, RecipeCheck, RecipeIssue, RecipeSource, RowRule, SavedRecipeMatch, SourceRow, SourceSheet, SourceTable, SourceVerdict, TransformStep, ValueMapEntry, } from './ImportRecipe.js';
@@ -1 +1 @@
1
- export {};
1
+ export { OPTION_MATCH_KEY, SOURCE_ROWS_KEY } from './ImportRecipe.js';
@@ -4,11 +4,30 @@ import { FormListSection, FormStateErrors, IFormsInitStateInterface, LocalFormSt
4
4
  import { DatabaseFormInterface } from '../Form/formInterface.js';
5
5
  export interface ITowerStepColumn extends FormColumnInputs {
6
6
  canReload: IInputCanReload;
7
+ /**
8
+ * Present only when the column's options fetch binds the field's search box
9
+ * (a `searchTerm` mapped input, or a `{{@search}}` template token). The
10
+ * rendered search box then drives the API instead of filtering locally.
11
+ * Absent ⇒ the search box filters the loaded options in the browser.
12
+ */
13
+ optionsSearch?: IInputOptionsSearch;
7
14
  inputConfigErrors: {
8
15
  key: string;
9
16
  message: string;
10
17
  }[];
11
18
  }
19
+ /**
20
+ * The bridge between a field's search box and its search-bound options fetch.
21
+ * Handed to the rendered column by the form engine; never persisted.
22
+ */
23
+ export interface IInputOptionsSearch {
24
+ /** Sends a new search term to the options fetch (re-fires it when the term changed). */
25
+ search: (term: string) => void;
26
+ /** The term the options fetch currently uses — seeds a re-created search box. */
27
+ term: () => string;
28
+ /** Whether the options fetch is in flight (reactive when read in a template). */
29
+ isSearching: () => boolean;
30
+ }
12
31
  export interface IInputCanReload {
13
32
  emit: () => void;
14
33
  canReload: boolean;
@@ -1,2 +1,3 @@
1
- import { FormsStoreSelectorsInterface, ITowerFormSteps, ITowerStepColumn } from "./ITowerFormSteps.js";
1
+ import { FormsStoreSelectorsInterface, IInputOptionsSearch, ITowerFormSteps, ITowerStepColumn } from "./ITowerFormSteps.js";
2
2
  export { ITowerFormSteps, FormsStoreSelectorsInterface, ITowerStepColumn };
3
+ export type { IInputOptionsSearch };
@@ -6,7 +6,7 @@ import { FormListSection } from "../Form/IFormsInitStateInterface.js";
6
6
  import { IUserSignature, PointGroup } from "../formInput/userSignature.js";
7
7
  import { IWorkflowDocListCols, IWorkflowStepOption } from "../FormBuilder/workflowSelectionConfig.js";
8
8
  import { IDocumentPage, IDocumentQueryRequest } from "../formInput/WorkflowDocumentPicker.js";
9
- import { IFinancialCycles } from "./environment.js";
9
+ import { GlobalVariables } from "./environment.js";
10
10
  export interface DialogConfig {
11
11
  title: string;
12
12
  message: string;
@@ -49,7 +49,47 @@ export interface IStoreFunctions {
49
49
  toastError: (message: string) => void;
50
50
  workflows: () => Observable<IWorkflowOption[]>;
51
51
  getWorkflowCols: (workflowId: string) => Observable<IWorkflowDocListCols[]>;
52
- getFinacialCycles: () => Observable<IFinancialCycles>;
52
+ /**
53
+ * Values the application injects into every form as read-only system inputs —
54
+ * the current financial cycle, the open transaction's id, the signed-in user's
55
+ * department, anything a form may need to read or a formula may need to use
56
+ * without asking the user for it. Replaces `getFinacialCycles`, which fixed
57
+ * the set of variables to financial cycles.
58
+ *
59
+ * Each entry becomes one system input whose control name is the key, placed in
60
+ * the form's first section and listed in the builder's pickers under a
61
+ * "System:" label, so an author can reference it in formulas, conditions,
62
+ * required-input rules and submission payloads like any other control.
63
+ *
64
+ * Keys are control names: letters, digits and underscores, not starting with a
65
+ * digit (`^[A-Za-z_][A-Za-z0-9_]*$`). Prefer SCREAMING_SNAKE_CASE — an authored
66
+ * control is lowerCamelCase, so the two can never collide. A key an open form
67
+ * already uses for an authored control is not injected: the authored control
68
+ * wins. A key outside the pattern is not injected either.
69
+ *
70
+ * Values decide the input: a `Date` or a `DateLike` (a Moment, a Day.js
71
+ * instance — anything with `toDate()`) becomes a date picker; a number a
72
+ * number input; a boolean a toggle; a string a text input. `null`,
73
+ * `undefined`, an empty string, a non-finite number and an invalid date mean
74
+ * "no value" and the input is not injected. Nested objects and arrays are not
75
+ * accepted — a system input is a single form control.
76
+ *
77
+ * The engine reads the FIRST emission when a form initialises and keeps it for
78
+ * that form's life; the builder follows every emission. The observable must
79
+ * emit at least once or the form never finishes initialising. A failure is
80
+ * tolerated: the form renders with no system inputs.
81
+ *
82
+ * @example
83
+ * getGlobalVariables: () =>
84
+ * combineLatest([org$, route$]).pipe(map(([org, route]) => ({
85
+ * CURRENT_FINANCIAL_CYCLE: org.cycleLabel, // text
86
+ * CURRENT_FINANCIAL_CYCLE_START_DATE: org.cycleStart, // Moment → date picker
87
+ * CURRENT_TRANSACTION_ID: route.docId, // null off the detail screen → not injected
88
+ * IS_PILOT_ORGANISATION: org.pilot, // toggle
89
+ * VAT_RATE: 0.15, // number
90
+ * })))
91
+ */
92
+ getGlobalVariables: () => Observable<GlobalVariables>;
53
93
  getCurrentFormAvailableInputOptions: () => Observable<Array<FormColumnInputs>>;
54
94
  getSelectedDocument: (documentId: string) => Observable<any>;
55
95
  getScoaTree: () => Observable<IGetTreeResponse>;