@researchdatabox/sails-ng-common 0.0.1-beta.8936

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 (220) hide show
  1. package/README.md +5 -0
  2. package/dist/src/config/base-field-component.model.d.ts +26 -0
  3. package/dist/src/config/base-field-component.model.js +29 -0
  4. package/dist/src/config/base-field-component.outline.d.ts +100 -0
  5. package/dist/src/config/base-field-component.outline.js +3 -0
  6. package/dist/src/config/component/accordion.model.d.ts +103 -0
  7. package/dist/src/config/component/accordion.model.js +127 -0
  8. package/dist/src/config/component/accordion.outline.d.ts +150 -0
  9. package/dist/src/config/component/accordion.outline.js +13 -0
  10. package/dist/src/config/component/action-row-layout.model.d.ts +28 -0
  11. package/dist/src/config/component/action-row-layout.model.js +35 -0
  12. package/dist/src/config/component/action-row-layout.outline.d.ts +36 -0
  13. package/dist/src/config/component/action-row-layout.outline.js +6 -0
  14. package/dist/src/config/component/cancel-button.model.d.ts +46 -0
  15. package/dist/src/config/component/cancel-button.model.js +56 -0
  16. package/dist/src/config/component/cancel-button.outline.d.ts +69 -0
  17. package/dist/src/config/component/cancel-button.outline.js +6 -0
  18. package/dist/src/config/component/checkbox-input.model.d.ts +65 -0
  19. package/dist/src/config/component/checkbox-input.model.js +78 -0
  20. package/dist/src/config/component/checkbox-input.outline.d.ts +85 -0
  21. package/dist/src/config/component/checkbox-input.outline.js +8 -0
  22. package/dist/src/config/component/checkbox-tree.model.d.ts +66 -0
  23. package/dist/src/config/component/checkbox-tree.model.js +79 -0
  24. package/dist/src/config/component/checkbox-tree.outline.d.ts +96 -0
  25. package/dist/src/config/component/checkbox-tree.outline.js +8 -0
  26. package/dist/src/config/component/content.model.d.ts +45 -0
  27. package/dist/src/config/component/content.model.js +55 -0
  28. package/dist/src/config/component/content.outline.d.ts +64 -0
  29. package/dist/src/config/component/content.outline.js +6 -0
  30. package/dist/src/config/component/data-location.model.d.ts +82 -0
  31. package/dist/src/config/component/data-location.model.js +94 -0
  32. package/dist/src/config/component/data-location.outline.d.ts +117 -0
  33. package/dist/src/config/component/data-location.outline.js +6 -0
  34. package/dist/src/config/component/date-input.model.d.ts +66 -0
  35. package/dist/src/config/component/date-input.model.js +79 -0
  36. package/dist/src/config/component/date-input.outline.d.ts +81 -0
  37. package/dist/src/config/component/date-input.outline.js +8 -0
  38. package/dist/src/config/component/default-layout.model.d.ts +22 -0
  39. package/dist/src/config/component/default-layout.model.js +30 -0
  40. package/dist/src/config/component/default-layout.outline.d.ts +29 -0
  41. package/dist/src/config/component/default-layout.outline.js +5 -0
  42. package/dist/src/config/component/delete-button.model.d.ts +46 -0
  43. package/dist/src/config/component/delete-button.model.js +48 -0
  44. package/dist/src/config/component/delete-button.outline.d.ts +55 -0
  45. package/dist/src/config/component/delete-button.outline.js +5 -0
  46. package/dist/src/config/component/dropdown-input.model.d.ts +64 -0
  47. package/dist/src/config/component/dropdown-input.model.js +77 -0
  48. package/dist/src/config/component/dropdown-input.outline.d.ts +84 -0
  49. package/dist/src/config/component/dropdown-input.outline.js +8 -0
  50. package/dist/src/config/component/file-upload.model.d.ts +67 -0
  51. package/dist/src/config/component/file-upload.model.js +81 -0
  52. package/dist/src/config/component/file-upload.outline.d.ts +93 -0
  53. package/dist/src/config/component/file-upload.outline.js +8 -0
  54. package/dist/src/config/component/group.model.d.ts +61 -0
  55. package/dist/src/config/component/group.model.js +75 -0
  56. package/dist/src/config/component/group.outline.d.ts +77 -0
  57. package/dist/src/config/component/group.outline.js +8 -0
  58. package/dist/src/config/component/inline-layout.model.d.ts +22 -0
  59. package/dist/src/config/component/inline-layout.model.js +29 -0
  60. package/dist/src/config/component/inline-layout.outline.d.ts +29 -0
  61. package/dist/src/config/component/inline-layout.outline.js +5 -0
  62. package/dist/src/config/component/map.model.d.ts +68 -0
  63. package/dist/src/config/component/map.model.js +85 -0
  64. package/dist/src/config/component/map.outline.d.ts +102 -0
  65. package/dist/src/config/component/map.outline.js +8 -0
  66. package/dist/src/config/component/pdf-list.model.d.ts +68 -0
  67. package/dist/src/config/component/pdf-list.model.js +71 -0
  68. package/dist/src/config/component/pdf-list.outline.d.ts +91 -0
  69. package/dist/src/config/component/pdf-list.outline.js +6 -0
  70. package/dist/src/config/component/publish-data-location-refresh.model.d.ts +38 -0
  71. package/dist/src/config/component/publish-data-location-refresh.model.js +51 -0
  72. package/dist/src/config/component/publish-data-location-refresh.outline.d.ts +47 -0
  73. package/dist/src/config/component/publish-data-location-refresh.outline.js +5 -0
  74. package/dist/src/config/component/publish-data-location-selector.model.d.ts +74 -0
  75. package/dist/src/config/component/publish-data-location-selector.model.js +100 -0
  76. package/dist/src/config/component/publish-data-location-selector.outline.d.ts +99 -0
  77. package/dist/src/config/component/publish-data-location-selector.outline.js +6 -0
  78. package/dist/src/config/component/question-tree.helper.d.ts +61 -0
  79. package/dist/src/config/component/question-tree.helper.js +298 -0
  80. package/dist/src/config/component/question-tree.model.d.ts +64 -0
  81. package/dist/src/config/component/question-tree.model.js +80 -0
  82. package/dist/src/config/component/question-tree.outline.d.ts +305 -0
  83. package/dist/src/config/component/question-tree.outline.js +9 -0
  84. package/dist/src/config/component/radio-input.model.d.ts +63 -0
  85. package/dist/src/config/component/radio-input.model.js +76 -0
  86. package/dist/src/config/component/radio-input.outline.d.ts +83 -0
  87. package/dist/src/config/component/radio-input.outline.js +8 -0
  88. package/dist/src/config/component/record-metadata-retriever.model.d.ts +41 -0
  89. package/dist/src/config/component/record-metadata-retriever.model.js +57 -0
  90. package/dist/src/config/component/record-metadata-retriever.outline.d.ts +47 -0
  91. package/dist/src/config/component/record-metadata-retriever.outline.js +5 -0
  92. package/dist/src/config/component/record-selector.model.d.ts +60 -0
  93. package/dist/src/config/component/record-selector.model.js +60 -0
  94. package/dist/src/config/component/record-selector.outline.d.ts +84 -0
  95. package/dist/src/config/component/record-selector.outline.js +6 -0
  96. package/dist/src/config/component/repeatable.model.d.ts +90 -0
  97. package/dist/src/config/component/repeatable.model.js +109 -0
  98. package/dist/src/config/component/repeatable.outline.d.ts +108 -0
  99. package/dist/src/config/component/repeatable.outline.js +10 -0
  100. package/dist/src/config/component/reusable.model.d.ts +42 -0
  101. package/dist/src/config/component/reusable.model.js +57 -0
  102. package/dist/src/config/component/reusable.outline.d.ts +49 -0
  103. package/dist/src/config/component/reusable.outline.js +6 -0
  104. package/dist/src/config/component/rich-text-editor.model.d.ts +65 -0
  105. package/dist/src/config/component/rich-text-editor.model.js +79 -0
  106. package/dist/src/config/component/rich-text-editor.outline.d.ts +86 -0
  107. package/dist/src/config/component/rich-text-editor.outline.js +8 -0
  108. package/dist/src/config/component/save-button.model.d.ts +45 -0
  109. package/dist/src/config/component/save-button.model.js +55 -0
  110. package/dist/src/config/component/save-button.outline.d.ts +65 -0
  111. package/dist/src/config/component/save-button.outline.js +6 -0
  112. package/dist/src/config/component/save-status.model.d.ts +42 -0
  113. package/dist/src/config/component/save-status.model.js +60 -0
  114. package/dist/src/config/component/save-status.outline.d.ts +52 -0
  115. package/dist/src/config/component/save-status.outline.js +6 -0
  116. package/dist/src/config/component/simple-input.model.d.ts +62 -0
  117. package/dist/src/config/component/simple-input.model.js +75 -0
  118. package/dist/src/config/component/simple-input.outline.d.ts +80 -0
  119. package/dist/src/config/component/simple-input.outline.js +9 -0
  120. package/dist/src/config/component/tab-content.model.d.ts +63 -0
  121. package/dist/src/config/component/tab-content.model.js +77 -0
  122. package/dist/src/config/component/tab-content.outline.d.ts +92 -0
  123. package/dist/src/config/component/tab-content.outline.js +8 -0
  124. package/dist/src/config/component/tab-nav-button.model.d.ts +45 -0
  125. package/dist/src/config/component/tab-nav-button.model.js +55 -0
  126. package/dist/src/config/component/tab-nav-button.outline.d.ts +64 -0
  127. package/dist/src/config/component/tab-nav-button.outline.js +6 -0
  128. package/dist/src/config/component/tab.model.d.ts +71 -0
  129. package/dist/src/config/component/tab.model.js +84 -0
  130. package/dist/src/config/component/tab.outline.d.ts +106 -0
  131. package/dist/src/config/component/tab.outline.js +9 -0
  132. package/dist/src/config/component/text-area.model.d.ts +63 -0
  133. package/dist/src/config/component/text-area.model.js +76 -0
  134. package/dist/src/config/component/text-area.outline.d.ts +81 -0
  135. package/dist/src/config/component/text-area.outline.js +8 -0
  136. package/dist/src/config/component/typeahead-input.model.d.ts +78 -0
  137. package/dist/src/config/component/typeahead-input.model.js +91 -0
  138. package/dist/src/config/component/typeahead-input.outline.d.ts +107 -0
  139. package/dist/src/config/component/typeahead-input.outline.js +8 -0
  140. package/dist/src/config/component/validation-summary.model.d.ts +42 -0
  141. package/dist/src/config/component/validation-summary.model.js +60 -0
  142. package/dist/src/config/component/validation-summary.outline.d.ts +57 -0
  143. package/dist/src/config/component/validation-summary.outline.js +6 -0
  144. package/dist/src/config/dictionary.model.d.ts +624 -0
  145. package/dist/src/config/dictionary.model.js +175 -0
  146. package/dist/src/config/dictionary.outline.d.ts +94 -0
  147. package/dist/src/config/dictionary.outline.js +3 -0
  148. package/dist/src/config/field-component.model.d.ts +7 -0
  149. package/dist/src/config/field-component.model.js +11 -0
  150. package/dist/src/config/field-component.outline.d.ts +20 -0
  151. package/dist/src/config/field-component.outline.js +3 -0
  152. package/dist/src/config/field-layout.model.d.ts +19 -0
  153. package/dist/src/config/field-layout.model.js +23 -0
  154. package/dist/src/config/field-layout.outline.d.ts +42 -0
  155. package/dist/src/config/field-layout.outline.js +3 -0
  156. package/dist/src/config/field-model.model.d.ts +22 -0
  157. package/dist/src/config/field-model.model.js +25 -0
  158. package/dist/src/config/field-model.outline.d.ts +63 -0
  159. package/dist/src/config/field-model.outline.js +3 -0
  160. package/dist/src/config/field.model.d.ts +12 -0
  161. package/dist/src/config/field.model.js +12 -0
  162. package/dist/src/config/field.outline.d.ts +19 -0
  163. package/dist/src/config/field.outline.js +3 -0
  164. package/dist/src/config/form-behaviour.outline.d.ts +128 -0
  165. package/dist/src/config/form-behaviour.outline.js +40 -0
  166. package/dist/src/config/form-component.model.d.ts +38 -0
  167. package/dist/src/config/form-component.model.js +36 -0
  168. package/dist/src/config/form-component.outline.d.ts +257 -0
  169. package/dist/src/config/form-component.outline.js +24 -0
  170. package/dist/src/config/form-config.model.d.ts +33 -0
  171. package/dist/src/config/form-config.model.js +36 -0
  172. package/dist/src/config/form-config.outline.d.ts +109 -0
  173. package/dist/src/config/form-config.outline.js +3 -0
  174. package/dist/src/config/form-override.model.d.ts +116 -0
  175. package/dist/src/config/form-override.model.js +1209 -0
  176. package/dist/src/config/form-override.outline.d.ts +15 -0
  177. package/dist/src/config/form-override.outline.js +3 -0
  178. package/dist/src/config/form-types.model.d.ts +6 -0
  179. package/dist/src/config/form-types.model.js +23 -0
  180. package/dist/src/config/form-types.outline.d.ts +48 -0
  181. package/dist/src/config/form-types.outline.js +137 -0
  182. package/dist/src/config/helpers.d.ts +23 -0
  183. package/dist/src/config/helpers.js +105 -0
  184. package/dist/src/config/names/naming-helpers.d.ts +71 -0
  185. package/dist/src/config/names/naming-helpers.js +72 -0
  186. package/dist/src/config/names/query-helpers.d.ts +43 -0
  187. package/dist/src/config/names/query-helpers.js +64 -0
  188. package/dist/src/config/shared.outline.d.ts +54 -0
  189. package/dist/src/config/shared.outline.js +41 -0
  190. package/dist/src/config/visitor/base.model.d.ts +137 -0
  191. package/dist/src/config/visitor/base.model.js +323 -0
  192. package/dist/src/config/visitor/base.outline.d.ts +140 -0
  193. package/dist/src/config/visitor/base.outline.js +3 -0
  194. package/dist/src/config/visitor/common.model.d.ts +119 -0
  195. package/dist/src/config/visitor/common.model.js +421 -0
  196. package/dist/src/handlebars-helpers.d.ts +224 -0
  197. package/dist/src/handlebars-helpers.js +558 -0
  198. package/dist/src/index.d.ts +109 -0
  199. package/dist/src/index.js +136 -0
  200. package/dist/src/logger.interface.d.ts +14 -0
  201. package/dist/src/logger.interface.js +3 -0
  202. package/dist/src/record.model.d.ts +35 -0
  203. package/dist/src/record.model.js +21 -0
  204. package/dist/src/report.model.d.ts +21 -0
  205. package/dist/src/report.model.js +19 -0
  206. package/dist/src/status.model.d.ts +22 -0
  207. package/dist/src/status.model.js +28 -0
  208. package/dist/src/template.outline.d.ts +49 -0
  209. package/dist/src/template.outline.js +13 -0
  210. package/dist/src/translation-helpers.d.ts +10 -0
  211. package/dist/src/translation-helpers.js +30 -0
  212. package/dist/src/validation/form.model.d.ts +247 -0
  213. package/dist/src/validation/form.model.js +31 -0
  214. package/dist/src/validation/helpers.d.ts +14 -0
  215. package/dist/src/validation/helpers.js +68 -0
  216. package/dist/src/validation/validators-support.d.ts +41 -0
  217. package/dist/src/validation/validators-support.js +141 -0
  218. package/dist/src/validation/validators.d.ts +23 -0
  219. package/dist/src/validation/validators.js +427 -0
  220. package/package.json +95 -0
@@ -0,0 +1,247 @@
1
+ import { LineagePath, LineagePaths } from "../config/names/naming-helpers";
2
+ /**
3
+ * The parameters for a validator error.
4
+ *
5
+ * These can be used with the translation message id to create the translated text.
6
+ *
7
+ * For example:
8
+ * {actual: 2, requiredThreshold: 3}
9
+ */
10
+ export type FormValidatorErrorParams = {
11
+ [key: string]: unknown;
12
+ };
13
+ /**
14
+ * The map of validation errors.
15
+ *
16
+ * Typically, has a property that is the validation class, e.g. 'min', and
17
+ * value is a dictionary of message and params that are arbitrary values
18
+ * that can be used to render an error message template.
19
+ *
20
+ * This is similar to FormValidatorComponentErrors, but with the class as the key in a parent object.
21
+ *
22
+ * This is similar to the angular form ValidationErrors type.
23
+ */
24
+ export type FormValidatorErrors = {
25
+ [key: string]: {
26
+ message: string;
27
+ params: FormValidatorErrorParams;
28
+ };
29
+ };
30
+ /**
31
+ * The map of validator config.
32
+ * The config is different for each validator.
33
+ */
34
+ export type FormValidatorCreateConfig = {
35
+ class?: string;
36
+ message?: string;
37
+ [key: string]: unknown;
38
+ };
39
+ /**
40
+ * The interface that a form control must implement to be validated by a validator function.
41
+ * Some form controls are a collection of controls, these must provide a way to access the controls they contain.
42
+ *
43
+ * This is similar to the angular AbstractControl class, with only the properties needed for validation.
44
+ *
45
+ * @see https://angular.dev/api/forms/AbstractControl
46
+ */
47
+ export interface FormValidatorControl {
48
+ /**
49
+ * The value of the control.
50
+ * @see https://angular.dev/api/forms/AbstractControl#value
51
+ */
52
+ value: unknown;
53
+ /**
54
+ * Get the descendant control that matches the path.
55
+ * @see https://angular.dev/api/forms/AbstractControl#get
56
+ * @param path
57
+ */
58
+ get<P extends string | LineagePath>(path: P): FormValidatorControl | null;
59
+ }
60
+ /**
61
+ * A simple form validator control that can be used on the server-side to mimic client-side controls.
62
+ *
63
+ * Do not use this on the client-side.
64
+ */
65
+ export declare class SimpleServerFormValidatorControl implements FormValidatorControl {
66
+ value: unknown;
67
+ constructor(value: unknown);
68
+ get<P extends string | LineagePath>(path: P): FormValidatorControl | null;
69
+ }
70
+ /**
71
+ * The validator function.
72
+ *
73
+ * Accepts an AbstractControl and returns either validation errors or no errors (null).
74
+ *
75
+ * This is similar to the angular form ValidatorFn interface.
76
+ */
77
+ export interface FormValidatorFn {
78
+ (control: FormValidatorControl): FormValidatorErrors | null;
79
+ }
80
+ /**
81
+ * The validation function creator.
82
+ *
83
+ * Takes one config argument, which contains config for the specific validator.
84
+ *
85
+ * Returns a form validator function.
86
+ */
87
+ export type FormValidatorCreateFn = (config: FormValidatorCreateConfig | null | undefined) => FormValidatorFn;
88
+ /**
89
+ * The definition of a validator for a form or a form control.
90
+ */
91
+ export interface FormValidatorDefinition {
92
+ /**
93
+ * The unique name of the form validator.
94
+ */
95
+ class: string;
96
+ /**
97
+ * The message id to display when the validator fails.
98
+ */
99
+ message: string;
100
+ /**
101
+ * The validation function creator.
102
+ */
103
+ create: FormValidatorCreateFn;
104
+ }
105
+ /**
106
+ * The configuration block for a validator for a form or a form control.
107
+ */
108
+ export interface FormValidatorConfig {
109
+ /**
110
+ * The 'class' key used to reference one validator definition.
111
+ * The optional message and config will be applied to the validator definition with this class.
112
+ */
113
+ class: string;
114
+ /**
115
+ * The optional message id to display when the validator fails.
116
+ * This is only needed if the message to show is different to the validator definition.
117
+ */
118
+ message?: string;
119
+ /**
120
+ * The optional validator config.
121
+ * Can be left out if the validator takes no config.
122
+ */
123
+ config?: FormValidatorCreateConfig;
124
+ /**
125
+ * Zero or more validation group names this validator belongs to.
126
+ *
127
+ * Validation groups make it easier to run a subset of validators on a form.
128
+ * The validator will be enabled if any of the groups it is part of are enabled.
129
+ *
130
+ * Note that a validation group with 'initialMembership: "all"' will include all validators (that aren't excluded),
131
+ * even if the validators do not include the group name.
132
+ */
133
+ groups?: FormFieldValidationGroup;
134
+ }
135
+ /**
136
+ * One validator error.
137
+ */
138
+ export interface FormValidatorComponentErrors {
139
+ /**
140
+ * The message id for the validator.
141
+ */
142
+ message: string;
143
+ /**
144
+ * The class of the validator.
145
+ */
146
+ class: string;
147
+ /**
148
+ * The params for rendering the translated message.
149
+ */
150
+ params: FormValidatorErrorParams;
151
+ }
152
+ /**
153
+ * Form or form control errors from a validator.
154
+ *
155
+ * Controls can be nested, so validation errors can be nested.
156
+ * The nesting is how the client-side is able to reveal a form field when
157
+ * a link in the validation summary is clicked.
158
+ *
159
+ * If all errors arrays are empty, then the validation summary is treated as 'form is valid'.
160
+ */
161
+ export interface FormValidatorSummaryErrors {
162
+ /**
163
+ * The id of the form control.
164
+ *
165
+ * This is used on the client-side for linking to the form control to reveal it.
166
+ * If this is not available, the validation error is rendered with the form field label and with no link.
167
+ */
168
+ id: string | null;
169
+ /**
170
+ * The message id for the form control label.
171
+ *
172
+ * This is passed to the translation service to get the label text.
173
+ * If this is not available, the id is used, otherwise a default label is used.
174
+ */
175
+ message: string | null;
176
+ /**
177
+ * The validation errors for the form control.
178
+ *
179
+ * These are rendered using the translation service - the message id can use the params to calculate the text to show.
180
+ * If there are no errors, then the form field is not shown in the error summary.
181
+ */
182
+ errors: FormValidatorComponentErrors[];
183
+ /**
184
+ * The lineage paths to this form control.
185
+ *
186
+ * This enables revealing the parents, to be able to navigate to the form control.
187
+ */
188
+ lineagePaths: LineagePaths;
189
+ }
190
+ /**
191
+ * Form validation groups, where the key is the name, and the value is the definition.
192
+ */
193
+ export interface FormValidationGroups {
194
+ /**
195
+ * The key is the name of the validation group.
196
+ */
197
+ [key: string]: FormValidationGroup;
198
+ }
199
+ /**
200
+ * A form validation group,
201
+ * which describes the purpose or usage of the group and the initial membership of the group.
202
+ */
203
+ export interface FormValidationGroup {
204
+ /**
205
+ * A short description of the purpose or usage of the validation group.
206
+ */
207
+ description: string;
208
+ /**
209
+ * The approach this validation group uses to specify which validators are included.
210
+ *
211
+ * Default is "none".
212
+ */
213
+ initialMembership?: FormValidationGroupMembership;
214
+ }
215
+ /**
216
+ * The available form validation group membership approaches.
217
+ *
218
+ * Options:
219
+ * - 'all': Every known / available validator.
220
+ * - 'none': An empty array / no validators.
221
+ */
222
+ export declare const formValidationGroupMembership: readonly ["all", "none"];
223
+ /**
224
+ * The type for the available form validation group membership approaches.
225
+ */
226
+ export type FormValidationGroupMembership = typeof formValidationGroupMembership[number];
227
+ /**
228
+ * Specify the validation groups to include or exclude.
229
+ * All the validation groups used here must also be present in the form top-level validationGroups property.
230
+ * The groups will be added or removed from some list of validation groups.
231
+ */
232
+ export interface FormFieldValidationGroup {
233
+ /**
234
+ * A list of the validation groups to include / add / enable.
235
+ *
236
+ * Default is empty array.
237
+ * Use when a validator should be included in a group with initial membership of none.
238
+ */
239
+ include?: string[];
240
+ /**
241
+ * A list of the validation groups to exclude / remove / disable.
242
+ *
243
+ * Default is empty array.
244
+ * Use when a validator should be excluded from a group with initial membership of all.
245
+ */
246
+ exclude?: string[];
247
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formValidationGroupMembership = exports.SimpleServerFormValidatorControl = void 0;
4
+ const lodash_1 = require("lodash");
5
+ /**
6
+ * A simple form validator control that can be used on the server-side to mimic client-side controls.
7
+ *
8
+ * Do not use this on the client-side.
9
+ */
10
+ class SimpleServerFormValidatorControl {
11
+ value;
12
+ constructor(value) {
13
+ this.value = value;
14
+ }
15
+ get(path) {
16
+ const result = (0, lodash_1.get)(this.value, path) ?? null;
17
+ // For debugging:
18
+ // console.debug(`SimpleServerFormValidatorControl.get path ${JSON.stringify(path)} with result ${JSON.stringify(result)} from value ${JSON.stringify(this.value)}`);
19
+ return result;
20
+ }
21
+ }
22
+ exports.SimpleServerFormValidatorControl = SimpleServerFormValidatorControl;
23
+ /**
24
+ * The available form validation group membership approaches.
25
+ *
26
+ * Options:
27
+ * - 'all': Every known / available validator.
28
+ * - 'none': An empty array / no validators.
29
+ */
30
+ exports.formValidationGroupMembership = ["all", "none"];
31
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9ybS5tb2RlbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy92YWxpZGF0aW9uL2Zvcm0ubW9kZWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsbUNBQXFDO0FBOERyQzs7OztHQUlHO0FBQ0gsTUFBYSxnQ0FBZ0M7SUFDekMsS0FBSyxDQUFVO0lBRWYsWUFBWSxLQUFjO1FBQ3RCLElBQUksQ0FBQyxLQUFLLEdBQUcsS0FBSyxDQUFDO0lBQ3ZCLENBQUM7SUFFRCxHQUFHLENBQWlDLElBQU87UUFDdkMsTUFBTSxNQUFNLEdBQUcsSUFBQSxZQUFJLEVBQUMsSUFBSSxDQUFDLEtBQUssRUFBRSxJQUFJLENBQUMsSUFBSSxJQUFJLENBQUM7UUFFOUMsaUJBQWlCO1FBQ2pCLHFLQUFxSztRQUVySyxPQUFPLE1BQU0sQ0FBQztJQUNsQixDQUFDO0NBQ0o7QUFmRCw0RUFlQztBQTJKRDs7Ozs7O0dBTUc7QUFDVSxRQUFBLDZCQUE2QixHQUFHLENBQUMsS0FBSyxFQUFFLE1BQU0sQ0FBVSxDQUFDIn0=
@@ -0,0 +1,14 @@
1
+ import { FormValidatorCreateConfig } from "./form.model";
2
+ /**
3
+ * Extract the length property in case it's an array or a string.
4
+ * Extract the size property in case it's a set.
5
+ * Return null else.
6
+ * @param value Either an array, set or undefined.
7
+ */
8
+ export declare function formValidatorLengthOrSize(value: null | string | unknown[] | Set<unknown> | unknown): number | null;
9
+ export declare function formValidatorGetDefinitionItem(config: FormValidatorCreateConfig | null | undefined, key: string, defaultValue?: unknown): unknown;
10
+ export declare function formValidatorGetDefinitionString(config: FormValidatorCreateConfig | null | undefined, key: string, defaultValue?: string | undefined): string;
11
+ export declare function formValidatorGetDefinitionNumber(config: FormValidatorCreateConfig | null | undefined, key: string, defaultValue?: string | undefined): number;
12
+ export declare function formValidatorGetDefinitionBoolean(config: FormValidatorCreateConfig | null | undefined, key: string, defaultValue?: boolean | undefined): boolean;
13
+ export declare function formValidatorGetDefinitionRegexp(config: FormValidatorCreateConfig | null | undefined, key: string, defaultValue?: RegExp | undefined): RegExp;
14
+ export declare function formValidatorGetDefinitionArray(config: FormValidatorCreateConfig | null | undefined, key: string, defaultValue?: unknown[] | undefined): unknown[];
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formValidatorLengthOrSize = formValidatorLengthOrSize;
4
+ exports.formValidatorGetDefinitionItem = formValidatorGetDefinitionItem;
5
+ exports.formValidatorGetDefinitionString = formValidatorGetDefinitionString;
6
+ exports.formValidatorGetDefinitionNumber = formValidatorGetDefinitionNumber;
7
+ exports.formValidatorGetDefinitionBoolean = formValidatorGetDefinitionBoolean;
8
+ exports.formValidatorGetDefinitionRegexp = formValidatorGetDefinitionRegexp;
9
+ exports.formValidatorGetDefinitionArray = formValidatorGetDefinitionArray;
10
+ const lodash_1 = require("lodash");
11
+ const helpers_1 = require("../config/helpers");
12
+ /**
13
+ * Extract the length property in case it's an array or a string.
14
+ * Extract the size property in case it's a set.
15
+ * Return null else.
16
+ * @param value Either an array, set or undefined.
17
+ */
18
+ function formValidatorLengthOrSize(value) {
19
+ if (value === null || value === undefined) {
20
+ return null;
21
+ }
22
+ else if (Array.isArray(value) || typeof value === "string") {
23
+ return value.length;
24
+ }
25
+ else if (value instanceof Set) {
26
+ return value.size;
27
+ }
28
+ return null;
29
+ }
30
+ function formValidatorGetDefinitionItem(config, key, defaultValue = undefined) {
31
+ const value = (0, lodash_1.get)(config ?? {}, key, defaultValue);
32
+ if (value === undefined) {
33
+ throw new Error(`Must define '${key}' in validator config.`);
34
+ }
35
+ return value;
36
+ }
37
+ function formValidatorGetDefinitionString(config, key, defaultValue = undefined) {
38
+ const value = formValidatorGetDefinitionItem(config, key, defaultValue);
39
+ return value?.toString() ?? "";
40
+ }
41
+ function formValidatorGetDefinitionNumber(config, key, defaultValue = undefined) {
42
+ const value = formValidatorGetDefinitionItem(config, key, defaultValue);
43
+ const valueString = value?.toString() ?? "";
44
+ const valueNumber = parseFloat(valueString);
45
+ if (isNaN(valueNumber)) {
46
+ throw new Error(`Invalid numeric value '${value}' for key '${key}' in validator config.`);
47
+ }
48
+ return valueNumber;
49
+ }
50
+ function formValidatorGetDefinitionBoolean(config, key, defaultValue = undefined) {
51
+ const value = formValidatorGetDefinitionItem(config, key, defaultValue);
52
+ return (0, helpers_1.toBoolean)(value);
53
+ }
54
+ function formValidatorGetDefinitionRegexp(config, key, defaultValue = undefined) {
55
+ const value = formValidatorGetDefinitionItem(config, key, defaultValue);
56
+ if (value instanceof RegExp) {
57
+ return value;
58
+ }
59
+ return new RegExp(value?.toString() ?? "");
60
+ }
61
+ function formValidatorGetDefinitionArray(config, key, defaultValue = undefined) {
62
+ const value = formValidatorGetDefinitionItem(config, key, defaultValue);
63
+ if (Array.isArray(value)) {
64
+ return value;
65
+ }
66
+ throw new Error(`Invalid array value '${value}' for key '${key}' in validator config.`);
67
+ }
68
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy92YWxpZGF0aW9uL2hlbHBlcnMudHMiXSwibmFtZ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BQyxNQUFNLEVBQUUsR0FBRyxFQUFFLFlBQVksQ0FBQyxDQUFDO0lBQ3hFLElBQUksS0FBSyxZQUFZLE1BQU0sRUFBRSxDQUFDO1FBQzVCLE9BQU8sS0FBSyxDQUFDO0lBQ2YsQ0FBQztJQUNELE9BQU8sSUFBSSxNQUFNLENBQUMsS0FBSyxFQUFFLFFBQVEsRUFBRSxJQUFJLEVBQUUsQ0FBQyxDQUFDO0FBQzdDLENBQUM7QUFFRCxTQUFnQiwrQkFBK0IsQ0FDN0MsTUFBb0QsRUFDcEQsR0FBVyxFQUNYLGVBQXNDLFNBQVM7SUFFL0MsTUFBTSxLQUFLLEdBQUcsOEJBQThCLENBQUMsTUFBTSxFQUFFLEdBQUcsRUFBRSxZQUFZLENBQUMsQ0FBQztJQUN4RSxJQUFJLEtBQUssQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDLEVBQUUsQ0FBQztRQUN6QixPQUFPLEtBQUssQ0FBQztJQUNmLENBQUM7SUFDRCxNQUFNLElBQUksS0FBSyxDQUFDLHdCQUF3QixLQUFLLGNBQWMsR0FBRyx3QkFBd0IsQ0FBQyxDQUFDO0FBQzFGLENBQUMifQ==
@@ -0,0 +1,41 @@
1
+ import { FormValidationGroups, FormValidatorComponentErrors, FormValidatorConfig, FormValidatorDefinition, FormValidatorErrors, FormValidatorFn } from "./form.model";
2
+ export declare class ValidatorsSupport {
3
+ /**
4
+ * Create validator definition mapping from the validator definitions.
5
+ * @param definition The form validator definitions.
6
+ */
7
+ createValidatorDefinitionMapping(definition: FormValidatorDefinition[] | null | undefined): Map<string, FormValidatorDefinition>;
8
+ /**
9
+ * Create form validator instances from the validator definition mapping.
10
+ * @param defMap The validator definition mapping.
11
+ * @param config The form validator config blocks.
12
+ */
13
+ createFormValidatorInstancesFromMapping(defMap: Map<string, FormValidatorDefinition>, config: FormValidatorConfig[] | null | undefined): FormValidatorFn[];
14
+ /**
15
+ * Create instances of the given form validators.
16
+ *
17
+ * @param definition The form validator definitions.
18
+ * @param config The form validator config blocks.
19
+ */
20
+ createFormValidatorInstances(definition: FormValidatorDefinition[] | null | undefined, config: FormValidatorConfig[] | null | undefined): FormValidatorFn[];
21
+ /**
22
+ * Get the form validator errors for a component's control.
23
+ * @param errors The control's errors.
24
+ */
25
+ getFormValidatorComponentErrors(errors: FormValidatorErrors | null): FormValidatorComponentErrors[];
26
+ checkValidationGroups(availableGroups: FormValidationGroups, enabledGroupNames: string[]): void;
27
+ /**
28
+ * Is the component model validator enabled?
29
+ * @param availableGroups All available validation groups in this form.
30
+ * @param enabledGroupNames The currently enabled validation groups.
31
+ * @param validator The validator config for a component's model.
32
+ */
33
+ isValidatorEnabled(availableGroups: FormValidationGroups, enabledGroupNames: string[], validator: FormValidatorConfig): boolean;
34
+ /**
35
+ * Get the enabled validators.
36
+ * @param availableGroups All available validation groups in this form.
37
+ * @param enabledGroups The currently enabled validation groups.
38
+ * @param validators All available validators in this form.
39
+ */
40
+ enabledValidators(availableGroups: FormValidationGroups, enabledGroups: string[], validators: FormValidatorConfig[]): FormValidatorConfig[];
41
+ }
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValidatorsSupport = void 0;
4
+ const form_types_model_1 = require("../config/form-types.model");
5
+ class ValidatorsSupport {
6
+ /**
7
+ * Create validator definition mapping from the validator definitions.
8
+ * @param definition The form validator definitions.
9
+ */
10
+ createValidatorDefinitionMapping(definition) {
11
+ const defMap = new Map();
12
+ for (const definitionItem of (definition ?? [])) {
13
+ if (!(0, form_types_model_1.isTypeFormValidatorDefinition)(definitionItem)) {
14
+ throw new Error(`Validator definition does not have valid 'class', 'message', and 'create' properties: ${JSON.stringify(definitionItem)}`);
15
+ }
16
+ const validatorClass = definitionItem?.class;
17
+ const message = definitionItem?.message;
18
+ if (defMap.has(validatorClass)) {
19
+ const messages = [message, defMap.get(validatorClass)?.message];
20
+ throw new Error(`Duplicate validator class '${validatorClass}' - the validator classes must be unique. `
21
+ + `To help you find the duplicates, these are the messages of the duplicates: '${messages.join(", ")}'.`);
22
+ }
23
+ defMap.set(validatorClass, definitionItem);
24
+ }
25
+ return defMap;
26
+ }
27
+ /**
28
+ * Create form validator instances from the validator definition mapping.
29
+ * @param defMap The validator definition mapping.
30
+ * @param config The form validator config blocks.
31
+ */
32
+ createFormValidatorInstancesFromMapping(defMap, config) {
33
+ const result = [];
34
+ for (const validatorConfigItem of (config ?? [])) {
35
+ const validatorClass = validatorConfigItem?.class;
36
+ const def = defMap.get(validatorClass);
37
+ if (!def) {
38
+ throw new Error(`No validator definition with class '${validatorClass}', `
39
+ + `the available validators are: '${Array.from(defMap.keys()).sort().join(", ")}'.`);
40
+ }
41
+ const message = validatorConfigItem?.message ?? def.message;
42
+ const item = def.create({ class: validatorClass, message: message, ...(validatorConfigItem?.config ?? {}) });
43
+ // for debugging:
44
+ // const getter = function (path: string | LineagePath) {
45
+ // return path as any
46
+ // };
47
+ // const examples = {
48
+ // 'empty': item({value: null, get: getter}),
49
+ // 'filled': item({value: "some-value", get: getter})
50
+ // };
51
+ // console.log(`createFormValidatorInstancesFromMapping validatorClass ${validatorClass} validatorConfigItem ${JSON.stringify(validatorConfigItem)} examples ${JSON.stringify(examples)}`);
52
+ result.push(item);
53
+ }
54
+ return result;
55
+ }
56
+ /**
57
+ * Create instances of the given form validators.
58
+ *
59
+ * @param definition The form validator definitions.
60
+ * @param config The form validator config blocks.
61
+ */
62
+ createFormValidatorInstances(definition, config) {
63
+ const defMap = this.createValidatorDefinitionMapping(definition);
64
+ return this.createFormValidatorInstancesFromMapping(defMap, config);
65
+ }
66
+ /**
67
+ * Get the form validator errors for a component's control.
68
+ * @param errors The control's errors.
69
+ */
70
+ getFormValidatorComponentErrors(errors) {
71
+ return Object.entries(errors ?? {}).map(([key, item]) => ({
72
+ class: key,
73
+ message: item.message ?? null,
74
+ params: { ...item.params },
75
+ })) ?? [];
76
+ }
77
+ checkValidationGroups(availableGroups, enabledGroupNames) {
78
+ const availableGroupNames = Object.keys(availableGroups);
79
+ const unknownGroups = enabledGroupNames.filter(g => !availableGroupNames.includes(g));
80
+ if (unknownGroups.length > 0) {
81
+ throw new Error(`Unknown enabled validation groups ${JSON.stringify(unknownGroups)}.`);
82
+ }
83
+ }
84
+ /**
85
+ * Is the component model validator enabled?
86
+ * @param availableGroups All available validation groups in this form.
87
+ * @param enabledGroupNames The currently enabled validation groups.
88
+ * @param validator The validator config for a component's model.
89
+ */
90
+ isValidatorEnabled(availableGroups, enabledGroupNames, validator) {
91
+ if (Object.keys(availableGroups).length === 0) {
92
+ // If there are no validation groups, all validators are enabled.
93
+ return true;
94
+ }
95
+ if (enabledGroupNames.length === 0) {
96
+ // If there are no validation groups enabled, all validators are enabled.
97
+ return true;
98
+ }
99
+ this.checkValidationGroups(availableGroups, enabledGroupNames);
100
+ // Check each validation group to see if the validator is enabled.
101
+ // A validator must pass at least one of the group checks to be enabled.
102
+ const includes = validator?.groups?.include ?? [];
103
+ this.checkValidationGroups(availableGroups, includes);
104
+ const excludes = validator?.groups?.exclude ?? [];
105
+ this.checkValidationGroups(availableGroups, excludes);
106
+ for (const [groupKey, groupConfig] of Object.entries(availableGroups)) {
107
+ const membership = groupConfig?.initialMembership ?? "none";
108
+ if (!enabledGroupNames?.includes(groupKey)) {
109
+ // Group is not enabled, so move on.
110
+ continue;
111
+ }
112
+ if (excludes.includes(groupKey)) {
113
+ // Validator excludes this group, so move on.
114
+ continue;
115
+ }
116
+ if (membership === "all" && !excludes.includes(groupKey)) {
117
+ // Validator is enabled.
118
+ // Group is enabled, starts with all validators, and validator does not exclude it.
119
+ return true;
120
+ }
121
+ if (membership === "none" && includes.includes(groupKey)) {
122
+ // Validator is enabled.
123
+ // Group is enabled, starts with no validators, and validator includes it.
124
+ return true;
125
+ }
126
+ }
127
+ // Validator was not included in any group, so it is disabled.
128
+ return false;
129
+ }
130
+ /**
131
+ * Get the enabled validators.
132
+ * @param availableGroups All available validation groups in this form.
133
+ * @param enabledGroups The currently enabled validation groups.
134
+ * @param validators All available validators in this form.
135
+ */
136
+ enabledValidators(availableGroups, enabledGroups, validators) {
137
+ return (validators ?? []).filter(validator => this.isValidatorEnabled(availableGroups, enabledGroups, validator));
138
+ }
139
+ }
140
+ exports.ValidatorsSupport = ValidatorsSupport;
141
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdG9ycy1zdXBwb3J0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3ZhbGlkYXRpb24vdmFsaWRhdG9ycy1zdXBwb3J0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQU1BLGlFQUF5RTtBQUV6RSxNQUFhLGlCQUFpQjtJQUMxQjs7O09BR0c7SUFDSSxnQ0FBZ0MsQ0FDbkMsVUFBd0Q7UUFFeEQsTUFBTSxNQUFNLEdBQUcsSUFBSSxHQUFHLEVBQW1DLENBQUM7UUFDMUQsS0FBSyxNQUFNLGNBQWMsSUFBSSxDQUFDLFVBQVUsSUFBSSxFQUFFLENBQUMsRUFBRSxDQUFDO1lBQzlDLElBQUksQ0FBQyxJQUFBLGdEQUE2QixFQUFDLGNBQWMsQ0FBQyxFQUFFLENBQUM7Z0JBQ2pELE1BQU0sSUFBSSxLQUFLLENBQUMseUZBQXlGLElBQUksQ0FBQyxTQUFTLENBQUMsY0FBYyxDQUFDLEVBQUUsQ0FBQyxDQUFDO1lBQy9JLENBQUM7WUFDRCxNQUFNLGNBQWMsR0FBRyxjQUFjLEVBQUUsS0FBSyxDQUFDO1lBQzdDLE1BQU0sT0FBTyxHQUFHLGNBQWMsRUFBRSxPQUFPLENBQUM7WUFDeEMsSUFBSSxNQUFNLENBQUMsR0FBRyxDQUFDLGNBQWMsQ0FBQyxFQUFFLENBQUM7Z0JBQzdCLE1BQU0sUUFBUSxHQUFHLENBQUMsT0FBTyxFQUFFLE1BQU0sQ0FBQyxHQUFHL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ozs7O09BS0c7SUFDSSxpQkFBaUIsQ0FBQyxlQUFxQyxFQUFFLGFBQXVCLEVBQUUsVUFBaUM7UUFDdEgsT0FBTyxDQUFDLFVBQVUsSUFBSSxFQUFFLENBQUMsQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUMsa0JBQWtCLENBQUMsZUFBZSxFQUFFLGFBQWEsRUFBRSxTQUFTLENBQUMsQ0FBQyxDQUFDO0lBQ3RILENBQUM7Q0FDSjtBQTlKRCw4Q0E4SkMifQ==
@@ -0,0 +1,23 @@
1
+ import { FormValidatorDefinition } from "./form.model";
2
+ /**
3
+ * A regular expression for validating an email address.
4
+ *
5
+ * Based on the angular email validation regex. MIT-style license https://angular.dev/license
6
+ */
7
+ export declare const FORM_VALIDATOR_EMAIL_REGEXP: RegExp;
8
+ /**
9
+ * Definitions of shared form validators.
10
+ *
11
+ * These can be used on both server-side and client-side. The server provides them to the client.
12
+ * These are the shared / common definitions.
13
+ * ReDBox implementations can modify these validation definitions or add more.
14
+ *
15
+ * The validators are based on:
16
+ * angular built-in validators: https://github.com/angular/angular/blob/5105fd6f05f01f04873ab1c87d64079fd8519ad4/packages/forms/src/validators.ts
17
+ * formly schema: https://github.com/ngx-formly/ngx-formly/blob/a2f7901b6c0895aee63b4b5fe748fc5ec0ad5475/src/core/src/lib/models/fieldconfig.ts
18
+ *
19
+ * These validation definitions need to be on the server-side, and provided to the client-side from the server.
20
+ * There are two sets of validator definitions - 1) shared / common definitions in the core; 2) definitions specific to a client.
21
+ * These two set of definitions need to be merged and provided by the server to the client.
22
+ */
23
+ export declare const formValidatorsSharedDefinitions: FormValidatorDefinition[];