ngx-t-forms-types 0.0.33 → 0.0.34

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.
@@ -0,0 +1,32 @@
1
+ /**
2
+ * How an import session decides that two rows are the same record.
3
+ *
4
+ * Passed to the import controller's `runImport` / `runMultipleInputImport`
5
+ * as per-import data — which fields identify a record in *this* form — not
6
+ * as application configuration. Only rows of the one session are compared;
7
+ * records already persisted are the server's to check.
8
+ *
9
+ * @public
10
+ */
11
+ export interface ImportIdentity {
12
+ /**
13
+ * `formControlName`s that together identify a record (for a multiple-input
14
+ * import: the child inputs' `formControlName`s). A row whose values for all
15
+ * of them repeat an earlier row's is a duplicate of that row. Empty or
16
+ * absent disables duplicate detection. A name the form does not have
17
+ * rejects the run rather than matching nothing.
18
+ */
19
+ readonly distinctKeys: readonly string[];
20
+ /**
21
+ * What to do with a duplicate.
22
+ *
23
+ * - `skip` — the row is never processed: no tower, no fetches. It is
24
+ * reported with status `duplicate` and `duplicateOf` naming the row it
25
+ * repeats. The default.
26
+ * - `flag` — the row is processed and validated like any other and keeps
27
+ * its real status; only `duplicateOf` marks it. For hosts that want to
28
+ * show what the duplicate contained. Such a row still must not be
29
+ * imported.
30
+ */
31
+ readonly onDuplicate?: 'skip' | 'flag';
32
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -14,7 +14,11 @@ export interface ImportProgress {
14
14
  pending: number;
15
15
  /** Rows currently processing. */
16
16
  processing: number;
17
- /** `valid` + `overridable` + `invalid` — i.e. rows that fully settled (regardless of validity). */
17
+ /**
18
+ * `valid` + `overridable` + `invalid` + rows held with status `duplicate` —
19
+ * i.e. rows that reached an outcome. `complete + error === total` once a
20
+ * run has finished, duplicates included.
21
+ */
18
22
  complete: number;
19
23
  /** Rows that settled with no errors. */
20
24
  valid: number;
@@ -24,6 +28,13 @@ export interface ImportProgress {
24
28
  invalid: number;
25
29
  /** Rows that threw before settling. */
26
30
  error: number;
31
+ /**
32
+ * Rows recognised as repeating an earlier row (`duplicateOf` set). Under
33
+ * the default `skip` policy these carry status `duplicate` and are counted
34
+ * in `complete`; under `flag` they keep their real status and are counted
35
+ * there as well.
36
+ */
37
+ duplicate: number;
27
38
  /** Underlying array — useful for rendering per-row UI. */
28
39
  rows: ImportRowState[];
29
40
  }
@@ -13,12 +13,19 @@
13
13
  * pre-process error (a row carrying both blocking and overridable errors is
14
14
  * `invalid`, not `overridable`).
15
15
  * - `error` — `_processRow` threw before settle (tower init failure, etc.).
16
+ * - `duplicate` — the row repeats an earlier row of the session on the
17
+ * fields the import was given as its identity (`ImportIdentity`), and is
18
+ * held out of the import; {@link ImportRowState.duplicateOf} names the row
19
+ * it repeats. A row skipped before its tower was built has no other
20
+ * verdict; one recognised only after it settled keeps its settled value
21
+ * and errors under this status. Under `onDuplicate: 'flag'` a duplicate
22
+ * keeps its real status instead and only `duplicateOf` marks it.
16
23
  *
17
24
  * Upstreamed from `ngx-t-forms` per DECISIONS.md D-016.
18
25
  *
19
26
  * @public
20
27
  */
21
- export type ImportRowStatus = 'pending' | 'processing' | 'valid' | 'overridable' | 'invalid' | 'error';
28
+ export type ImportRowStatus = 'pending' | 'processing' | 'valid' | 'overridable' | 'invalid' | 'error' | 'duplicate';
22
29
  /**
23
30
  * Per-row state recorded throughout an import session.
24
31
  *
@@ -63,4 +70,48 @@ export interface ImportRowState {
63
70
  colErrors?: Record<string, string>;
64
71
  /** Free-form message attached when `status === 'error'`. */
65
72
  errorMessage?: string;
73
+ /**
74
+ * formControlName → the cells of a choice field (select, autocomplete,
75
+ * paginated selection table) whose text matched MORE THAN ONE of the
76
+ * field's options, with the options it could be. The import accepts an
77
+ * option's visible label (or, for a table, any of its column values) in
78
+ * place of its stored value; a unique match is substituted silently, a
79
+ * tie is reported here so the user can pick, and the row stays `invalid`
80
+ * (`colErrors` carries `ambiguousOption:<text>`) until each is settled.
81
+ * A multi-select cell lists one entry per unsettled value.
82
+ */
83
+ optionChoices?: Record<string, ImportOptionChoice[]>;
84
+ /**
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.
92
+ */
93
+ duplicateOf?: number;
94
+ }
95
+ /**
96
+ * One option an imported cell could stand for.
97
+ *
98
+ * @public
99
+ */
100
+ export interface ImportOptionCandidate {
101
+ /** The value the form stores when this option is chosen. */
102
+ value: unknown;
103
+ /** What the form shows for the option — its label, or a table row's column values. */
104
+ label: string;
105
+ }
106
+ /**
107
+ * An imported cell (or one value of a multi-select cell) whose text matched
108
+ * several options of a choice field. See {@link ImportRowState.optionChoices}.
109
+ *
110
+ * @public
111
+ */
112
+ export interface ImportOptionChoice {
113
+ /** The text as it was imported. */
114
+ text: string;
115
+ /** The options it matched, in the field's option order. */
116
+ candidates: ImportOptionCandidate[];
66
117
  }
@@ -1,2 +1,3 @@
1
- export { ImportRowState, ImportRowStatus } from './ImportRowState.js';
1
+ export { ImportOptionCandidate, ImportOptionChoice, ImportRowState, ImportRowStatus } from './ImportRowState.js';
2
2
  export { ImportProgress } from './ImportProgress.js';
3
+ export { ImportIdentity } from './ImportIdentity.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ngx-t-forms-types",
3
- "version": "0.0.33",
3
+ "version": "0.0.34",
4
4
  "description": "Typings and interfaces for the ngx-t-forms library for dynamic forms.",
5
5
  "keywords": [
6
6
  "typings",