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
@@ -10,6 +10,24 @@ export interface FormInterface {
10
10
  submissionHandle?: FormSubmissionHandleInterface;
11
11
  formId: string | any;
12
12
  formTitle: string;
13
+ /**
14
+ * What the form is for, who fills it in and what happens to a submission —
15
+ * the form-wide counterpart of `formTitle`.
16
+ *
17
+ * The builder will not save a form without one: at least
18
+ * `FORM_DESCRIPTION_MIN_WORDS` words in at most `FORM_DESCRIPTION_MAX_PARAGRAPHS`
19
+ * paragraphs (paragraphs are separated by a blank line), checked by
20
+ * `validateFormDescription`. Optional on the type because forms stored before it
21
+ * existed, empty-form factories and AI drafts arrive without one.
22
+ */
23
+ formDescription?: string;
24
+ /**
25
+ * The `value`s of the classifications this form belongs to, chosen from the list
26
+ * the application supplies through `NgxTFormsConfig.formClassifications` (an
27
+ * industry, a module, a use case — whatever the application classifies by).
28
+ * A value the application no longer lists is kept as-is; it is never dropped.
29
+ */
30
+ formClassifications?: string[];
13
31
  submissionMessage?: string;
14
32
  }
15
33
  export interface MainFormInterface {
@@ -1,4 +1,4 @@
1
- import { NgxTFormsConfig } from "../environment/environment.js";
1
+ import { ImportTemplateConfig, NgxTFormsConfig } from "../environment/environment.js";
2
2
  import { FormColumnInputs } from "../formInput/BasicFormInputInterface.js";
3
3
  import { FormInterfaceMigration, IAllInputs, OLD_FormInterface } from "../upgradeFunctions/interfaces/init-form.js";
4
4
  import { IArrayFunction } from "./ArrayFunctions.js";
@@ -9,5 +9,5 @@ import { IFormActions, InClassFormUtilsInterface, InClassFormUtilsWithSectionsIn
9
9
  import { FormInterface, DatabaseFormInterface, MainFormInterface } from "./formInterface.js";
10
10
  import { FormSubmissionHandleInterface, IReportDataSources } from "./formSubmissionHandleInterface.js";
11
11
  import { FormListSection, FormStateErrors, IFormsInitStateInterface, LocalFormStateSelectorInterface } from "./IFormsInitStateInterface.js";
12
- export { CustomConfigInterface, InClassFormUtilsInterface, InClassFormUtilsWithSectionsInterface, FormInterface, MainFormInterface, DatabaseFormInterface, FormSubmissionHandleInterface, FormColumnInputs, IFormActions, NgxTFormsConfig, FileUploadFn, FileData, FormListSection, LocalFormStateSelectorInterface, IFormsInitStateInterface, FormStateErrors, IArrayFunction, OLD_FormInterface, FormInterfaceMigration, IAllInputs, IFormChangeHistory, IReportDataSources };
12
+ export { CustomConfigInterface, InClassFormUtilsInterface, InClassFormUtilsWithSectionsInterface, FormInterface, MainFormInterface, DatabaseFormInterface, FormSubmissionHandleInterface, FormColumnInputs, IFormActions, NgxTFormsConfig, ImportTemplateConfig, FileUploadFn, FileData, FormListSection, LocalFormStateSelectorInterface, IFormsInitStateInterface, FormStateErrors, IArrayFunction, OLD_FormInterface, FormInterfaceMigration, IAllInputs, IFormChangeHistory, IReportDataSources };
13
13
  export { FunctionTypes } from "./ArrayFunctions.js";
@@ -164,8 +164,8 @@ export const DefaultInputConfig = {
164
164
  colSize: 12,
165
165
  validators: [],
166
166
  dataType: InputDataTypes.Boolean,
167
- falseLabel: 'Yes',
168
- trueLabel: 'No',
167
+ falseLabel: 'No',
168
+ trueLabel: 'Yes',
169
169
  },
170
170
  },
171
171
  [ElementTypes.Select]: {
@@ -94,6 +94,8 @@ export declare enum AllFormInputPrimaryKeys {
94
94
  FormIsOpen = "formIsOpen",
95
95
  LinkedSegmentId = "linkedSegmentId",
96
96
  CanReload = "canReload",
97
+ /** Runtime-only search bridge for an options fetch bound to the field's search box. Never persisted. */
98
+ OptionsSearch = "optionsSearch",
97
99
  WorkflowFormForScoreSheet = "workflowFormForScoreSheet",
98
100
  AdjudicationStep = "adjudicationStep",
99
101
  AdjudicationPointTypes = "adjudicationPointTypes",
@@ -98,6 +98,8 @@ export var AllFormInputPrimaryKeys;
98
98
  AllFormInputPrimaryKeys["FormIsOpen"] = "formIsOpen";
99
99
  AllFormInputPrimaryKeys["LinkedSegmentId"] = "linkedSegmentId";
100
100
  AllFormInputPrimaryKeys["CanReload"] = "canReload";
101
+ /** Runtime-only search bridge for an options fetch bound to the field's search box. Never persisted. */
102
+ AllFormInputPrimaryKeys["OptionsSearch"] = "optionsSearch";
101
103
  AllFormInputPrimaryKeys["WorkflowFormForScoreSheet"] = "workflowFormForScoreSheet";
102
104
  AllFormInputPrimaryKeys["AdjudicationStep"] = "adjudicationStep";
103
105
  AllFormInputPrimaryKeys["AdjudicationPointTypes"] = "adjudicationPointTypes";
@@ -34,6 +34,14 @@ export declare enum ElementEditorTypes {
34
34
  DataSourcePicker = "dataSourcePicker",
35
35
  ListLabelConfigEditor = "listLabelConfigEditor",
36
36
  DecisionGateSettings = "decisionGateSettings",
37
+ /**
38
+ * Multi-paragraph plain-text description with live word / sentence /
39
+ * paragraph counts. Rendered by the ngx-t-workflows element editor host (like
40
+ * {@link ElementEditorTypes.DecisionGateSettings}), which picks the workflow or
41
+ * the step description rules from what it is editing. `lib-t-dynamic-data-edit`
42
+ * has no case for it.
43
+ */
44
+ DescriptionEditor = "descriptionEditor",
37
45
  RecordListManager = "recordListManager",
38
46
  MapMatOptionsKeys = "mapMatOptionsKeys",
39
47
  FormPayloadProjection = "formPayloadProjection",
@@ -28,6 +28,14 @@ export var ElementEditorTypes;
28
28
  ElementEditorTypes["DataSourcePicker"] = "dataSourcePicker";
29
29
  ElementEditorTypes["ListLabelConfigEditor"] = "listLabelConfigEditor";
30
30
  ElementEditorTypes["DecisionGateSettings"] = "decisionGateSettings";
31
+ /**
32
+ * Multi-paragraph plain-text description with live word / sentence /
33
+ * paragraph counts. Rendered by the ngx-t-workflows element editor host (like
34
+ * {@link ElementEditorTypes.DecisionGateSettings}), which picks the workflow or
35
+ * the step description rules from what it is editing. `lib-t-dynamic-data-edit`
36
+ * has no case for it.
37
+ */
38
+ ElementEditorTypes["DescriptionEditor"] = "descriptionEditor";
31
39
  ElementEditorTypes["RecordListManager"] = "recordListManager";
32
40
  ElementEditorTypes["MapMatOptionsKeys"] = "mapMatOptionsKeys";
33
41
  ElementEditorTypes["FormPayloadProjection"] = "formPayloadProjection";
@@ -1,6 +1,7 @@
1
1
  import { CurrenciesList } from "../../../Configs/currencies.js";
2
2
  import { DatePipeOptions } from "../../../Configs/datePipes.js";
3
3
  import { AdjudicationSteps, AutocompleteOptions, ElementTypes, InputDataTypes, InputPipeTypes, InputTypes } from "../../formInput/index.js";
4
+ import { ROUNDING_MODES, ROUNDING_MODE_LABELS } from "../../formInput/calculatedFieldRules.js";
4
5
  import { DataSources } from "../../formInput/APIDataFetchingConfigurationInterface.js";
5
6
  import { OptionSelectTypes } from "../../formInput/BasicFormInputInterface.js";
6
7
  import { InputFileType } from "../../formInput/FileUploadInputInterface.js";
@@ -1130,8 +1131,8 @@ export var ElementConfig = {
1130
1131
  {
1131
1132
  name: SpecialElementKeys.Default,
1132
1133
  editType: ElementEditorTypes.ChipSelect,
1133
- label: 'Format displayed value',
1134
- hint: "Apply formatting to the displayed value (e.g., currency symbols, date formatting, decimal places) without changing the stored value.",
1134
+ label: 'Number format',
1135
+ hint: "How the number is presented. Currency, decimal and integer also set the precision the value is kept at: it is rounded when typed, imported or calculated, and the rounded value is what is saved and shown. The other formats only change the display.",
1135
1136
  deepBind: ['pipe', 'pipeType'],
1136
1137
  additionalTest: [
1137
1138
  {
@@ -1147,6 +1148,7 @@ export var ElementConfig = {
1147
1148
  editType: ElementEditorTypes.OptionSelect,
1148
1149
  deepBind: ['pipe', 'param'],
1149
1150
  label: 'Select currency to apply',
1151
+ hint: "Amounts are kept to the currency's minor unit (2 decimals for ZAR) and rounded half to even — banker's rounding — unless you choose another rounding below.",
1150
1152
  options: CurrenciesList,
1151
1153
  id: "209d2295-cbaa-4f99-98d2-15c4515581b8",
1152
1154
  additionalTest: [
@@ -1177,7 +1179,8 @@ export var ElementConfig = {
1177
1179
  {
1178
1180
  name: SpecialElementKeys.Default,
1179
1181
  editType: ElementEditorTypes.Input,
1180
- label: 'Decimal numbers',
1182
+ label: 'Decimal places',
1183
+ hint: 'How many decimal places to keep, for example 2. The value is rounded to this precision when typed, imported or calculated, and the rounded value is saved.',
1181
1184
  deepBind: ['pipe', 'param'],
1182
1185
  additionalTest: [
1183
1186
  {
@@ -1191,6 +1194,25 @@ export var ElementConfig = {
1191
1194
  ],
1192
1195
  id: "d0771f0e-eaec-457c-a2f4-e454fd9092c7"
1193
1196
  },
1197
+ {
1198
+ name: SpecialElementKeys.Default,
1199
+ editType: ElementEditorTypes.ChipSelect,
1200
+ label: 'Rounding',
1201
+ hint: "Which way a value past the precision rounds. Banker's sends a tie (…5) to the even neighbour and is the default for currency; Nearest sends a tie away from zero and is the default otherwise; Round down and Round up always move toward the lower or the higher value.",
1202
+ deepBind: ['pipe', 'rounding'],
1203
+ options: ROUNDING_MODES.map((mode) => ({ label: ROUNDING_MODE_LABELS[mode], value: mode })),
1204
+ additionalTest: [
1205
+ {
1206
+ expression: `type === ${InputTypes.Number}`,
1207
+ deepBind: ['type'],
1208
+ },
1209
+ {
1210
+ expression: `pipeType === ${InputPipeTypes.Currency} || pipeType === ${InputPipeTypes.Decimal} || pipeType === ${InputPipeTypes.Integer}`,
1211
+ deepBind: ['pipe', 'pipeType'],
1212
+ },
1213
+ ],
1214
+ id: "5f3c9b1e-2a74-4d08-b6e1-9c0d7a4f28e3"
1215
+ },
1194
1216
  {
1195
1217
  name: SpecialElementKeys.Default,
1196
1218
  editType: ElementEditorTypes.Input,
@@ -13,8 +13,15 @@ export interface ImportIdentity {
13
13
  * `formControlName`s that together identify a record (for a multiple-input
14
14
  * import: the child inputs' `formControlName`s). A row whose values for all
15
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
16
+ * absent disables duplicate detection between records — `lists` still
17
+ * folds repeats inside each record's lists. A name the form does not have
17
18
  * rejects the run rather than matching nothing.
19
+ *
20
+ * A key may also be a dot path below a field, as a workflow's
21
+ * `uniqueKeys` names one leaf of an object value — e.g.
22
+ * `glAccount.accrual.FUND.debit.SCOAid` for one mSCOA account. It is
23
+ * compared on that leaf alone, read the way the server reads
24
+ * `form.<key>`; its first segment must be a field of the form.
18
25
  */
19
26
  readonly distinctKeys: readonly string[];
20
27
  /**
@@ -29,4 +36,128 @@ export interface ImportIdentity {
29
36
  * imported.
30
37
  */
31
38
  readonly onDuplicate?: 'skip' | 'flag';
39
+ /**
40
+ * Which row of a group of duplicates is kept as the record.
41
+ *
42
+ * - `first` — the lowest row index. The default.
43
+ * - `last` — the highest row index, for a sheet that lists later
44
+ * corrections below earlier lines.
45
+ * - `{ latest: field }` — the row with the greatest value of `field`, a
46
+ * `formControlName` of the form (for a multiple-input import: a child
47
+ * input's), e.g. the most recently dated line. A row's value is read
48
+ * from its settled value once it has settled, else from the sheet's
49
+ * cell. Only values that compare unambiguously count: a `Date`, a finite
50
+ * number, or ISO text (`yyyy-mm-dd`, optionally with a time; without an
51
+ * offset it is local time). A blank or unparseable value never beats a
52
+ * real one, and a tie — all blank included — keeps the lowest row index.
53
+ * Dates and numbers are not converted into each other, so the field
54
+ * should carry one kind. A name the form does not have rejects the run.
55
+ *
56
+ * A host may still keep a specific row of a group (the import controller's
57
+ * `keepRow`), which wins over this default.
58
+ */
59
+ readonly keep?: 'first' | 'last' | {
60
+ readonly latest: string;
61
+ };
62
+ /**
63
+ * Fields whose value the kept row takes from its WHOLE group rather than
64
+ * from itself: `formControlName` → how the group's values are combined.
65
+ * Every other field is the kept row's own.
66
+ *
67
+ * The combined value is written into the kept row's cells before its form
68
+ * is built, so calculations derive from it and validators judge it — a
69
+ * total over a field's maximum fails like any other value over it. The
70
+ * group's rows are read as the sheet gave them, and a blank cell is left
71
+ * out. A cell the op cannot read makes the kept row `invalid`, with
72
+ * `notCombinable:<row numbers>` in its `colErrors` for the field, rather
73
+ * than being dropped.
74
+ *
75
+ * - A number field (`sum`, `avg`, `min`, `max`) reads a finite number or
76
+ * text holding a plain decimal (`1500`, `-12.5`); any other text cannot
77
+ * be read.
78
+ * - A text or multi-select field (`join`) reads text — a cell holding
79
+ * several values, comma-separated or as a JSON list, contributes each —
80
+ * and writes every distinct value once, comma-separated, in the order
81
+ * first seen, as a multi-select cell is written. A structure cannot be
82
+ * read.
83
+ * - A list field — a MultipleInput (`collect`) — reads the rows of each
84
+ * member's list and writes them all, in sheet order, as the kept row's
85
+ * list; `lists` then folds the repeats inside it. A cell that is not a
86
+ * list cannot be read.
87
+ *
88
+ * A field must be a top-level field of the form (for a multiple-input
89
+ * import: a child input), and neither a unique key nor the field a
90
+ * `latest` keeper ranks by; `collect` needs a list field, and the other
91
+ * ops a field that is not one. A name or op that breaks this rejects the
92
+ * run. Unset, every field is the kept row's own, as before.
93
+ */
94
+ readonly combine?: Readonly<Record<string, ImportCombineOp>>;
95
+ /**
96
+ * Repeats inside the rows of a list field — a MultipleInput — of each
97
+ * record: the list's `formControlName` → how its rows are told apart and
98
+ * folded. A sheet that lists a record's detail rows may repeat a row the
99
+ * way its main rows repeat a record, and a `collect` that gathered the
100
+ * lists of a record's repeats makes such repeats of its own.
101
+ *
102
+ * Applied to every record's list as the sheet gave it — after `collect`
103
+ * gathered it, when it did — before any of its rows is checked: a row that
104
+ * repeats an earlier one on the list's keys is folded into the row the
105
+ * list keeps, the children named in its `combine` take the group's
106
+ * combined value, and the list is checked with the rows that remain. What
107
+ * was folded is reported in `ImportRowState.folded`.
108
+ *
109
+ * Rows are compared on their cells as the sheet gave them, the way a
110
+ * record's raw identity is: text trimmed, whitespace collapsed, case
111
+ * folded; a choice cell by its text, not the option it resolves to. The
112
+ * list field must be a list of the form (for a multiple-input import: a
113
+ * list among the children); its keys and combined fields name the list's
114
+ * children. Absent, a list's rows are checked as they came.
115
+ */
116
+ readonly lists?: Readonly<Record<string, ImportListIdentity>>;
32
117
  }
118
+ /**
119
+ * How the rows of one list field are told apart and folded — see
120
+ * {@link ImportIdentity.lists}. Each member means what it means on
121
+ * {@link ImportIdentity}, read against the list's children instead of the
122
+ * form's fields.
123
+ *
124
+ * @public
125
+ */
126
+ export interface ImportListIdentity {
127
+ /**
128
+ * Children whose values together identify a row of the list; a dot path
129
+ * below a child is read as for a record. Empty folds nothing. A name the
130
+ * list has no child for rejects the run.
131
+ */
132
+ readonly distinctKeys: readonly string[];
133
+ /**
134
+ * Which row of a group of repeats the list keeps: `first` (the default),
135
+ * `last`, or the row with the greatest value of a child, judged on the
136
+ * cell as the sheet gave it.
137
+ */
138
+ readonly keep?: 'first' | 'last' | {
139
+ readonly latest: string;
140
+ };
141
+ /**
142
+ * Children whose value the kept row takes from its whole group, as
143
+ * {@link ImportIdentity.combine} describes; `collect` applies to a child
144
+ * that is itself a list.
145
+ */
146
+ readonly combine?: Readonly<Record<string, ImportCombineOp>>;
147
+ }
148
+ /**
149
+ * How a group's values of a field are combined — see
150
+ * {@link ImportIdentity.combine}.
151
+ *
152
+ * - `sum` — added up, at the precision of the most precise value.
153
+ * - `avg` — the mean of the rows that have a value, rounded to two decimals
154
+ * or to the inputs' own precision, whichever is finer.
155
+ * - `min` / `max` — the lowest / highest value.
156
+ * - `join` — every distinct value, comma-separated, as a multi-select cell
157
+ * is written.
158
+ * - `collect` — every row of the group's lists, in sheet order, for a list
159
+ * field.
160
+ *
161
+ * @public
162
+ */
163
+ export type ImportCombineOp = 'sum' | 'avg' | 'min' | 'max' | 'join' | 'collect';