@opencrvs/toolkit 2.0.0-rc.ca1536b → 2.0.0-rc.ca3fe84

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 (127) hide show
  1. package/README.md +15 -0
  2. package/build.sh +3 -2
  3. package/create-countryconfig/index.js +50 -20
  4. package/create-countryconfig/package.json +12 -2
  5. package/dist/application-config/index.js +273 -98
  6. package/dist/cli.js +3354 -51
  7. package/dist/commons/api/router.d.ts +3005 -2570
  8. package/dist/commons/application-config/index.d.ts +7 -6
  9. package/dist/commons/conditionals/conditionals.d.ts +293 -234
  10. package/dist/commons/conditionals/validate.d.ts +51 -2
  11. package/dist/commons/events/ActionConfig.d.ts +93 -67
  12. package/dist/commons/events/ActionDocument.d.ts +113 -107
  13. package/dist/commons/events/ActionInput.d.ts +42 -36
  14. package/dist/commons/events/ActionType.d.ts +57 -57
  15. package/dist/commons/events/AdvancedSearchConfig.d.ts +651 -297
  16. package/dist/commons/events/AuditLog.d.ts +41 -41
  17. package/dist/commons/events/CompositeFieldValue.d.ts +4 -4
  18. package/dist/commons/events/Conditional.d.ts +3 -3
  19. package/dist/commons/events/CountryConfigQueryInput.d.ts +603 -561
  20. package/dist/commons/events/Draft.d.ts +33 -34
  21. package/dist/commons/events/DynamicFieldValue.d.ts +9 -9
  22. package/dist/commons/events/EventConfig.d.ts +5 -3
  23. package/dist/commons/events/EventDocument.d.ts +46 -43
  24. package/dist/commons/events/EventIndex.d.ts +76 -51
  25. package/dist/commons/events/EventMetadata.d.ts +60 -34
  26. package/dist/commons/events/FieldConfig.d.ts +710 -372
  27. package/dist/commons/events/FieldType.d.ts +51 -50
  28. package/dist/commons/events/FieldTypeMapping.d.ts +101 -101
  29. package/dist/commons/events/FieldValue.d.ts +18 -12
  30. package/dist/commons/events/Flag.d.ts +15 -15
  31. package/dist/commons/events/TemplateConfig.d.ts +1 -1
  32. package/dist/commons/events/WorkqueueColumnConfig.d.ts +40 -40
  33. package/dist/commons/events/WorkqueueConfig.d.ts +981 -942
  34. package/dist/commons/events/deduplication.d.ts +1 -1
  35. package/dist/commons/events/event.d.ts +2 -2
  36. package/dist/commons/events/field.d.ts +112 -189
  37. package/dist/commons/events/index.d.ts +2 -0
  38. package/dist/commons/events/locations.d.ts +5 -4
  39. package/dist/commons/events/mocks.test.utils.d.ts +2 -2
  40. package/dist/commons/events/scopes.d.ts +4 -4
  41. package/dist/commons/events/state/flags.d.ts +16 -0
  42. package/dist/commons/events/state/index.d.ts +23 -15
  43. package/dist/commons/events/state/utils.d.ts +25 -291
  44. package/dist/commons/events/test.utils.d.ts +33 -33
  45. package/dist/commons/events/utils.d.ts +120 -109
  46. package/dist/commons/notification/UserNotifications.d.ts +10 -10
  47. package/dist/conditionals/index.js +63 -5
  48. package/dist/environment/custom-types.d.ts +33 -0
  49. package/dist/environment/custom-types.d.ts.map +1 -0
  50. package/dist/environment/custom-types.js +12 -0
  51. package/dist/environment/derived-variables.d.ts +134 -0
  52. package/dist/environment/derived-variables.d.ts.map +1 -0
  53. package/dist/environment/derived-variables.js +169 -0
  54. package/dist/environment/editor-questions.d.ts +4 -0
  55. package/dist/environment/editor-questions.d.ts.map +1 -0
  56. package/dist/environment/editor-questions.js +67 -0
  57. package/dist/environment/git.d.ts +5 -0
  58. package/dist/environment/git.d.ts.map +1 -0
  59. package/dist/environment/git.js +38 -0
  60. package/dist/environment/github.d.ts +26 -0
  61. package/dist/environment/github.d.ts.map +1 -0
  62. package/dist/environment/github.js +247 -0
  63. package/dist/environment/index.d.ts +5 -0
  64. package/dist/environment/index.d.ts.map +1 -0
  65. package/dist/environment/index.js +71 -0
  66. package/dist/environment/logger.d.ts +6 -0
  67. package/dist/environment/logger.d.ts.map +1 -0
  68. package/dist/environment/logger.js +25 -0
  69. package/dist/environment/manage-users.d.ts +11 -0
  70. package/dist/environment/manage-users.d.ts.map +1 -0
  71. package/dist/environment/manage-users.js +507 -0
  72. package/dist/environment/questions-helper.d.ts +15 -0
  73. package/dist/environment/questions-helper.d.ts.map +1 -0
  74. package/dist/environment/questions-helper.js +70 -0
  75. package/dist/environment/questions.d.ts +200 -0
  76. package/dist/environment/questions.d.ts.map +1 -0
  77. package/dist/environment/questions.js +412 -0
  78. package/dist/environment/setup-environment.d.ts +2 -0
  79. package/dist/environment/setup-environment.d.ts.map +1 -0
  80. package/dist/environment/setup-environment.js +788 -0
  81. package/dist/environment/ssh-keygen.d.ts +5 -0
  82. package/dist/environment/ssh-keygen.d.ts.map +1 -0
  83. package/dist/environment/ssh-keygen.js +21 -0
  84. package/dist/environment/swarm-to-k8s.d.ts +2 -0
  85. package/dist/environment/swarm-to-k8s.d.ts.map +1 -0
  86. package/dist/environment/swarm-to-k8s.js +183 -0
  87. package/dist/environment/templates.d.ts +27 -0
  88. package/dist/environment/templates.d.ts.map +1 -0
  89. package/dist/environment/templates.js +163 -0
  90. package/dist/environment/update-workflows.d.ts +2 -0
  91. package/dist/environment/update-workflows.d.ts.map +1 -0
  92. package/dist/environment/update-workflows.js +179 -0
  93. package/dist/environment/users.d.ts +2 -0
  94. package/dist/environment/users.d.ts.map +1 -0
  95. package/dist/environment/users.js +122 -0
  96. package/dist/environment/utils.d.ts +18 -0
  97. package/dist/environment/utils.d.ts.map +1 -0
  98. package/dist/environment/utils.js +110 -0
  99. package/dist/events/deduplication.d.ts +1 -1
  100. package/dist/events/index.js +1088 -237
  101. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +1 -1
  102. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  103. package/dist/migrations/v2.0/checkout-upstream-files.js +1 -1
  104. package/dist/migrations/v2.0/convert-config-files-to-ts.js +17 -7
  105. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts +3 -0
  106. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts.map +1 -0
  107. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.js +110 -0
  108. package/dist/migrations/v2.0/index.d.ts.map +1 -1
  109. package/dist/migrations/v2.0/index.js +114 -12
  110. package/dist/migrations/v2.0/migrate-application-config-url.js +4 -3
  111. package/dist/migrations/v2.0/remove-hearth-migrations.js +17 -7
  112. package/dist/notification/index.js +899 -135
  113. package/dist/scopes/index.d.ts +209 -123
  114. package/dist/scopes/index.js +20 -7
  115. package/dist/templates/charts-values/dependencies/values.override.yaml +4 -0
  116. package/dist/templates/charts-values/dependencies/values.yaml +83 -0
  117. package/dist/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
  118. package/dist/templates/charts-values/opencrvs-services/values.yaml +81 -0
  119. package/dist/templates/charts-values/traefik/values.override.yaml +4 -0
  120. package/dist/templates/charts-values/traefik/values.yaml +115 -0
  121. package/dist/templates/inventory/inventory.template.yml +100 -0
  122. package/dist/templates/inventory/production.example.yml +77 -0
  123. package/dist/templates/inventory/qa.example.yml +48 -0
  124. package/opencrvs-toolkit-2.0.0-rc.ca3fe84.tgz +0 -0
  125. package/package.json +21 -4
  126. package/tsconfig.tsbuildinfo +1 -1
  127. package/opencrvs-toolkit-2.0.0-rc.ca1536b.tgz +0 -0
@@ -1,12 +1,13 @@
1
1
  import { EventDocument } from '../events/EventDocument';
2
- import { EventState } from '../events/ActionDocument';
2
+ import { ActionUpdate, EventState } from '../events/ActionDocument';
3
3
  import { ITokenPayload as TokenPayload } from '../authentication';
4
4
  import { PartialSchema as AjvJSONSchemaType } from 'ajv/dist/types/json-schema';
5
5
  import { userSerializer } from '../events/serializers/user/serializer';
6
6
  import { UUID } from '../uuid';
7
7
  import { todayDateTimeValueSerializer } from '../events/serializers/date/serializer';
8
8
  import { EventStatus } from '../events/EventMetadata';
9
- import { FieldReference } from '../events/FieldConfig';
9
+ import { CodeToEvaluate, FieldReference } from '../events/FieldConfig';
10
+ import type { ClientFunctionContext } from './validate';
10
11
  /** @knipignore */
11
12
  export type JSONSchema = {
12
13
  $id: string;
@@ -25,7 +26,7 @@ export type EventConditionalParameters = CommonConditionalParameters & {
25
26
  $event: EventDocument;
26
27
  };
27
28
  export type FormConditionalParameters = CommonConditionalParameters & {
28
- $form: EventState | Record<string, unknown>;
29
+ $form: EventState | ActionUpdate;
29
30
  $leafAdminStructureLocationIds?: Array<{
30
31
  id: UUID;
31
32
  }>;
@@ -67,6 +68,12 @@ export declare function not(condition: AjvJSONSchema): JSONSchema;
67
68
  * @returns {JSONSchema} An schema object that always evaluates to false.
68
69
  */
69
70
  export declare function never(): JSONSchema;
71
+ /**
72
+ * Returns an JSON Schema object, which is treated as always valid.
73
+ *
74
+ * @returns {JSONSchema} An schema object that always evaluates to true.
75
+ */
76
+ export declare function always(): JSONSchema;
70
77
  /**
71
78
  * Generate conditional rules for current date
72
79
  */
@@ -76,32 +83,34 @@ export declare const now: typeof todayDateTimeValueSerializer;
76
83
  * Generate conditional rules for user.
77
84
  */
78
85
  export declare const user: typeof userSerializer & {
79
- hasScope: (scope: string) => JSONSchema;
80
- hasRole: (role: string) => JSONSchema;
81
- isOnline: () => JSONSchema;
82
- locationLevel: (adminLevelId: string) => {
83
- $user: {
84
- $location: string;
85
- };
86
- };
87
86
  scope: (scope: import("../scopes").ScopeType) => {
88
87
  attribute: (option: import("../scopes").ScopeOptionKey) => {
89
- $scope: "record.search" | "record.create" | "record.read" | "record.declare" | "record.notify" | "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register" | "record.print-certified-copies" | "record.request-correction" | "record.correct" | "record.unassign-others" | "record.custom-action" | "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration" | "organisation.read-locations" | "user.read" | "user.create" | "user.edit" | "user.search" | "workqueue" | "dashboard.view";
90
- $option: "role" | "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
88
+ $scope: "attachment.upload" | "bypassratelimit" | "config.update-all" | "dashboard.view" | "integration.create" | "organisation.read-locations" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "profile.electronic-signature" | "record.archive" | "record.confirm-registration" | "record.correct" | "record.create" | "record.custom-action" | "record.declare" | "record.edit" | "record.import" | "record.notify" | "record.print-certified-copies" | "record.read" | "record.register" | "record.reindex" | "record.reject" | "record.reject-registration" | "record.request-correction" | "record.review-duplicates" | "record.search" | "record.unassign-others" | "user.create" | "user.data-seeding" | "user.edit" | "user.read" | "user.read-only-my-audit" | "user.search" | "workqueue";
89
+ $option: "accessLevel" | "declaredBy" | "declaredIn" | "event" | "ids" | "notifiedBy" | "notifiedIn" | "placeOfEvent" | "registeredBy" | "registeredIn" | "role";
91
90
  };
92
91
  };
93
92
  jurisdiction: (jurisdiction: import("../scopes").JurisdictionFilter | {
94
- $scope: "record.search" | "record.create" | "record.read" | "record.declare" | "record.notify" | "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register" | "record.print-certified-copies" | "record.request-correction" | "record.correct" | "record.unassign-others" | "record.custom-action" | "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration" | "organisation.read-locations" | "user.read" | "user.create" | "user.edit" | "user.search" | "workqueue" | "dashboard.view";
95
- $option: "role" | "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
93
+ $scope: "attachment.upload" | "bypassratelimit" | "config.update-all" | "dashboard.view" | "integration.create" | "organisation.read-locations" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "profile.electronic-signature" | "record.archive" | "record.confirm-registration" | "record.correct" | "record.create" | "record.custom-action" | "record.declare" | "record.edit" | "record.import" | "record.notify" | "record.print-certified-copies" | "record.read" | "record.register" | "record.reindex" | "record.reject" | "record.reject-registration" | "record.request-correction" | "record.review-duplicates" | "record.search" | "record.unassign-others" | "user.create" | "user.data-seeding" | "user.edit" | "user.read" | "user.read-only-my-audit" | "user.search" | "workqueue";
94
+ $option: "accessLevel" | "declaredBy" | "declaredIn" | "event" | "ids" | "notifiedBy" | "notifiedIn" | "placeOfEvent" | "registeredBy" | "registeredIn" | "role";
96
95
  }) => {
97
- $jurisdiction: "administrativeArea" | "location" | "all" | {
98
- $scope: "record.search" | "record.create" | "record.read" | "record.declare" | "record.notify" | "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register" | "record.print-certified-copies" | "record.request-correction" | "record.correct" | "record.unassign-others" | "record.custom-action" | "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration" | "organisation.read-locations" | "user.read" | "user.create" | "user.edit" | "user.search" | "workqueue" | "dashboard.view";
99
- $option: "role" | "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
96
+ $jurisdiction: "administrativeArea" | "all" | "location" | {
97
+ $scope: "attachment.upload" | "bypassratelimit" | "config.update-all" | "dashboard.view" | "integration.create" | "organisation.read-locations" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "profile.electronic-signature" | "record.archive" | "record.confirm-registration" | "record.correct" | "record.create" | "record.custom-action" | "record.declare" | "record.edit" | "record.import" | "record.notify" | "record.print-certified-copies" | "record.read" | "record.register" | "record.reindex" | "record.reject" | "record.reject-registration" | "record.request-correction" | "record.review-duplicates" | "record.search" | "record.unassign-others" | "user.create" | "user.data-seeding" | "user.edit" | "user.read" | "user.read-only-my-audit" | "user.search" | "workqueue";
98
+ $option: "accessLevel" | "declaredBy" | "declaredIn" | "event" | "ids" | "notifiedBy" | "notifiedIn" | "placeOfEvent" | "registeredBy" | "registeredIn" | "role";
99
+ };
100
+ };
101
+ hasScope: (scope: string) => JSONSchema;
102
+ hasRole: (role: string) => JSONSchema;
103
+ isOnline: () => JSONSchema;
104
+ locationLevel: (adminLevelId: string) => {
105
+ $user: {
106
+ $location: string;
100
107
  };
101
108
  };
102
109
  };
103
110
  export declare function isFieldReference(value: unknown): value is FieldReference;
104
- export declare function isEventFieldReference(value: unknown): value is FieldReference;
111
+ export declare function isEventFieldReference(value: unknown): value is {
112
+ $$event: string;
113
+ };
105
114
  /** Check if an event flag is present */
106
115
  export declare function flag(flagvalue: string): JSONSchema;
107
116
  /** Check if an event flag is present */
@@ -124,22 +133,22 @@ export declare function createFieldConditionals(fieldId: string): {
124
133
  */
125
134
  $$subfield: string[];
126
135
  get(fieldPath: string): {
127
- $$subfield: string[];
128
136
  /**
129
137
  * @private Internal property used for field reference tracking.
130
138
  */
131
139
  $$field: string;
132
- get(fieldPath: string): any;
140
+ get(fieldPath: string): /*elided*/ any;
141
+ $$subfield: string[];
133
142
  getByPath(fieldPath: string[]): {
134
- $$subfield: string[];
135
143
  /**
136
144
  * @private Internal property used for field reference tracking.
137
145
  */
138
146
  $$field: string;
139
- get(fieldPath: string): any;
140
- getByPath(fieldPath: string[]): any;
141
- asDob(): any;
142
- asAge(): any;
147
+ get(fieldPath: string): /*elided*/ any;
148
+ getByPath(fieldPath: string[]): /*elided*/ any;
149
+ $$subfield: string[];
150
+ asDob(): /*elided*/ any;
151
+ asAge(): /*elided*/ any;
143
152
  isAfter(): {
144
153
  days: (days: number) => {
145
154
  inPast: () => JSONSchema;
@@ -196,9 +205,40 @@ export declare function createFieldConditionals(fieldId: string): {
196
205
  * )
197
206
  */
198
207
  object: (options: Record<string, any>) => JSONSchema;
208
+ /**
209
+ * Custom client-side validator. The provided function is serialised and executed
210
+ * just-in-time on the client only. External references (e.g. lodash) are not
211
+ * available inside the function body — all logic must be self-contained.
212
+ *
213
+ * @example
214
+ * field('nid').customClientValidator((value) => {
215
+ * // LUHN check — all logic must be inline
216
+ * const digits = String(value).split('').map(Number)
217
+ * // ...
218
+ * return isValid
219
+ * })
220
+ */
221
+ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
222
+ /**
223
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
224
+ * that can be used as the `value` property or a DATA component entry.
225
+ * The function receives the referenced field's value as the first argument and
226
+ * the full form context as the second; its return value replaces the field reference.
227
+ * The function is serialised and executed just-in-time on the client only.
228
+ * External references (e.g. lodash) are not available inside the function body.
229
+ *
230
+ * For computing a default value without referencing a specific field, use
231
+ * `evaluate(fn)` in the `defaultValue` property instead.
232
+ *
233
+ * @example
234
+ * field('a').customClientEvaluation((aValue, ctx) =>
235
+ * Number(aValue) + Number(ctx.$form.b)
236
+ * )
237
+ */
238
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
199
239
  };
200
- asDob(): any;
201
- asAge(): any;
240
+ asDob(): /*elided*/ any;
241
+ asAge(): /*elided*/ any;
202
242
  isAfter(): {
203
243
  days: (days: number) => {
204
244
  inPast: () => JSONSchema;
@@ -255,215 +295,48 @@ export declare function createFieldConditionals(fieldId: string): {
255
295
  * )
256
296
  */
257
297
  object: (options: Record<string, any>) => JSONSchema;
298
+ /**
299
+ * Custom client-side validator. The provided function is serialised and executed
300
+ * just-in-time on the client only. External references (e.g. lodash) are not
301
+ * available inside the function body — all logic must be self-contained.
302
+ *
303
+ * @example
304
+ * field('nid').customClientValidator((value) => {
305
+ * // LUHN check — all logic must be inline
306
+ * const digits = String(value).split('').map(Number)
307
+ * // ...
308
+ * return isValid
309
+ * })
310
+ */
311
+ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
312
+ /**
313
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
314
+ * that can be used as the `value` property or a DATA component entry.
315
+ * The function receives the referenced field's value as the first argument and
316
+ * the full form context as the second; its return value replaces the field reference.
317
+ * The function is serialised and executed just-in-time on the client only.
318
+ * External references (e.g. lodash) are not available inside the function body.
319
+ *
320
+ * For computing a default value without referencing a specific field, use
321
+ * `evaluate(fn)` in the `defaultValue` property instead.
322
+ *
323
+ * @example
324
+ * field('a').customClientEvaluation((aValue, ctx) =>
325
+ * Number(aValue) + Number(ctx.$form.b)
326
+ * )
327
+ */
328
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
258
329
  };
259
330
  getByPath(fieldPath: string[]): {
260
- $$subfield: string[];
261
331
  /**
262
332
  * @private Internal property used for field reference tracking.
263
333
  */
264
334
  $$field: string;
265
- get(fieldPath: string): {
266
- $$subfield: string[];
267
- /**
268
- * @private Internal property used for field reference tracking.
269
- */
270
- $$field: string;
271
- get(fieldPath: string): any;
272
- getByPath(fieldPath: string[]): any;
273
- asDob(): any;
274
- asAge(): any;
275
- isAfter(): {
276
- days: (days: number) => {
277
- inPast: () => JSONSchema;
278
- inFuture: () => JSONSchema;
279
- fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
280
- fromNow: () => JSONSchema;
281
- };
282
- date: (date: string | FieldReference) => JSONSchema;
283
- now: () => JSONSchema;
284
- };
285
- isBefore(): {
286
- days: (days: number) => {
287
- inPast: () => JSONSchema;
288
- inFuture: () => JSONSchema;
289
- fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
290
- fromNow: () => JSONSchema;
291
- };
292
- date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
293
- now: () => JSONSchema;
294
- };
295
- isGreaterThan(value: number | FieldReference): JSONSchema;
296
- isLessThan(value: number | FieldReference): JSONSchema;
297
- isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
298
- /**
299
- * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
300
- * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
301
- * @returns whether the field is falsy (undefined, false, null, empty string)
302
- *
303
- * NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
304
- *
305
- */
306
- isFalsy(): JSONSchema;
307
- isUndefined(): JSONSchema;
308
- inArray(values: string[]): JSONSchema;
309
- isValidEnglishName(): JSONSchema;
310
- isValidAdministrativeLeafLevel(): JSONSchema;
311
- /**
312
- * Checks if the field value matches a given regular expression pattern.
313
- * @param pattern - The regular expression pattern to match the field value against.
314
- * @returns A JSONSchema conditional that validates the field value against the pattern.
315
- */
316
- matches(pattern: string): JSONSchema;
317
- isBetween(min: number, max: number): JSONSchema;
318
- getId: () => {
319
- fieldId: string;
320
- };
321
- /**
322
- * @deprecated
323
- * use field(fieldId).get(nestedProperty) instead
324
- * with 'and' combinator e.g.
325
- * and(
326
- * field('child.name').get('firstname').isEqualTo('John'),
327
- * field('child.name').get('surname').isEqualTo('Doe')
328
- * )
329
- */
330
- object: (options: Record<string, any>) => JSONSchema;
331
- };
335
+ get(fieldPath: string): any;
332
336
  getByPath(fieldPath: string[]): any;
333
- asDob(): {
334
- $$subfield: string[];
335
- /**
336
- * @private Internal property used for field reference tracking.
337
- */
338
- $$field: string;
339
- get(fieldPath: string): any;
340
- getByPath(fieldPath: string[]): any;
341
- asDob(): any;
342
- asAge(): any;
343
- isAfter(): {
344
- days: (days: number) => {
345
- inPast: () => JSONSchema;
346
- inFuture: () => JSONSchema;
347
- fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
348
- fromNow: () => JSONSchema;
349
- };
350
- date: (date: string | FieldReference) => JSONSchema;
351
- now: () => JSONSchema;
352
- };
353
- isBefore(): {
354
- days: (days: number) => {
355
- inPast: () => JSONSchema;
356
- inFuture: () => JSONSchema;
357
- fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
358
- fromNow: () => JSONSchema;
359
- };
360
- date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
361
- now: () => JSONSchema;
362
- };
363
- isGreaterThan(value: number | FieldReference): JSONSchema;
364
- isLessThan(value: number | FieldReference): JSONSchema;
365
- isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
366
- /**
367
- * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
368
- * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
369
- * @returns whether the field is falsy (undefined, false, null, empty string)
370
- *
371
- * NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
372
- *
373
- */
374
- isFalsy(): JSONSchema;
375
- isUndefined(): JSONSchema;
376
- inArray(values: string[]): JSONSchema;
377
- isValidEnglishName(): JSONSchema;
378
- isValidAdministrativeLeafLevel(): JSONSchema;
379
- /**
380
- * Checks if the field value matches a given regular expression pattern.
381
- * @param pattern - The regular expression pattern to match the field value against.
382
- * @returns A JSONSchema conditional that validates the field value against the pattern.
383
- */
384
- matches(pattern: string): JSONSchema;
385
- isBetween(min: number, max: number): JSONSchema;
386
- getId: () => {
387
- fieldId: string;
388
- };
389
- /**
390
- * @deprecated
391
- * use field(fieldId).get(nestedProperty) instead
392
- * with 'and' combinator e.g.
393
- * and(
394
- * field('child.name').get('firstname').isEqualTo('John'),
395
- * field('child.name').get('surname').isEqualTo('Doe')
396
- * )
397
- */
398
- object: (options: Record<string, any>) => JSONSchema;
399
- };
400
- asAge(): {
401
- $$subfield: string[];
402
- /**
403
- * @private Internal property used for field reference tracking.
404
- */
405
- $$field: string;
406
- get(fieldPath: string): any;
407
- getByPath(fieldPath: string[]): any;
408
- asDob(): any;
409
- asAge(): any;
410
- isAfter(): {
411
- days: (days: number) => {
412
- inPast: () => JSONSchema;
413
- inFuture: () => JSONSchema;
414
- fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
415
- fromNow: () => JSONSchema;
416
- };
417
- date: (date: string | FieldReference) => JSONSchema;
418
- now: () => JSONSchema;
419
- };
420
- isBefore(): {
421
- days: (days: number) => {
422
- inPast: () => JSONSchema;
423
- inFuture: () => JSONSchema;
424
- fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
425
- fromNow: () => JSONSchema;
426
- };
427
- date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
428
- now: () => JSONSchema;
429
- };
430
- isGreaterThan(value: number | FieldReference): JSONSchema;
431
- isLessThan(value: number | FieldReference): JSONSchema;
432
- isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
433
- /**
434
- * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
435
- * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
436
- * @returns whether the field is falsy (undefined, false, null, empty string)
437
- *
438
- * NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
439
- *
440
- */
441
- isFalsy(): JSONSchema;
442
- isUndefined(): JSONSchema;
443
- inArray(values: string[]): JSONSchema;
444
- isValidEnglishName(): JSONSchema;
445
- isValidAdministrativeLeafLevel(): JSONSchema;
446
- /**
447
- * Checks if the field value matches a given regular expression pattern.
448
- * @param pattern - The regular expression pattern to match the field value against.
449
- * @returns A JSONSchema conditional that validates the field value against the pattern.
450
- */
451
- matches(pattern: string): JSONSchema;
452
- isBetween(min: number, max: number): JSONSchema;
453
- getId: () => {
454
- fieldId: string;
455
- };
456
- /**
457
- * @deprecated
458
- * use field(fieldId).get(nestedProperty) instead
459
- * with 'and' combinator e.g.
460
- * and(
461
- * field('child.name').get('firstname').isEqualTo('John'),
462
- * field('child.name').get('surname').isEqualTo('Doe')
463
- * )
464
- */
465
- object: (options: Record<string, any>) => JSONSchema;
466
- };
337
+ $$subfield: string[];
338
+ asDob(): any;
339
+ asAge(): any;
467
340
  isAfter(): {
468
341
  days: (days: number) => {
469
342
  inPast: () => JSONSchema;
@@ -520,22 +393,53 @@ export declare function createFieldConditionals(fieldId: string): {
520
393
  * )
521
394
  */
522
395
  object: (options: Record<string, any>) => JSONSchema;
396
+ /**
397
+ * Custom client-side validator. The provided function is serialised and executed
398
+ * just-in-time on the client only. External references (e.g. lodash) are not
399
+ * available inside the function body — all logic must be self-contained.
400
+ *
401
+ * @example
402
+ * field('nid').customClientValidator((value) => {
403
+ * // LUHN check — all logic must be inline
404
+ * const digits = String(value).split('').map(Number)
405
+ * // ...
406
+ * return isValid
407
+ * })
408
+ */
409
+ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
410
+ /**
411
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
412
+ * that can be used as the `value` property or a DATA component entry.
413
+ * The function receives the referenced field's value as the first argument and
414
+ * the full form context as the second; its return value replaces the field reference.
415
+ * The function is serialised and executed just-in-time on the client only.
416
+ * External references (e.g. lodash) are not available inside the function body.
417
+ *
418
+ * For computing a default value without referencing a specific field, use
419
+ * `evaluate(fn)` in the `defaultValue` property instead.
420
+ *
421
+ * @example
422
+ * field('a').customClientEvaluation((aValue, ctx) =>
423
+ * Number(aValue) + Number(ctx.$form.b)
424
+ * )
425
+ */
426
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
523
427
  };
524
428
  asDob(): {
525
- $$subfield: string[];
526
429
  /**
527
430
  * @private Internal property used for field reference tracking.
528
431
  */
529
432
  $$field: string;
530
433
  get(fieldPath: string): any;
434
+ $$subfield: string[];
531
435
  getByPath(fieldPath: string[]): {
532
- $$subfield: string[];
533
436
  /**
534
437
  * @private Internal property used for field reference tracking.
535
438
  */
536
439
  $$field: string;
537
440
  get(fieldPath: string): any;
538
441
  getByPath(fieldPath: string[]): any;
442
+ $$subfield: string[];
539
443
  asDob(): any;
540
444
  asAge(): any;
541
445
  isAfter(): {
@@ -594,6 +498,37 @@ export declare function createFieldConditionals(fieldId: string): {
594
498
  * )
595
499
  */
596
500
  object: (options: Record<string, any>) => JSONSchema;
501
+ /**
502
+ * Custom client-side validator. The provided function is serialised and executed
503
+ * just-in-time on the client only. External references (e.g. lodash) are not
504
+ * available inside the function body — all logic must be self-contained.
505
+ *
506
+ * @example
507
+ * field('nid').customClientValidator((value) => {
508
+ * // LUHN check — all logic must be inline
509
+ * const digits = String(value).split('').map(Number)
510
+ * // ...
511
+ * return isValid
512
+ * })
513
+ */
514
+ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
515
+ /**
516
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
517
+ * that can be used as the `value` property or a DATA component entry.
518
+ * The function receives the referenced field's value as the first argument and
519
+ * the full form context as the second; its return value replaces the field reference.
520
+ * The function is serialised and executed just-in-time on the client only.
521
+ * External references (e.g. lodash) are not available inside the function body.
522
+ *
523
+ * For computing a default value without referencing a specific field, use
524
+ * `evaluate(fn)` in the `defaultValue` property instead.
525
+ *
526
+ * @example
527
+ * field('a').customClientEvaluation((aValue, ctx) =>
528
+ * Number(aValue) + Number(ctx.$form.b)
529
+ * )
530
+ */
531
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
597
532
  };
598
533
  asDob(): any;
599
534
  asAge(): any;
@@ -653,22 +588,53 @@ export declare function createFieldConditionals(fieldId: string): {
653
588
  * )
654
589
  */
655
590
  object: (options: Record<string, any>) => JSONSchema;
591
+ /**
592
+ * Custom client-side validator. The provided function is serialised and executed
593
+ * just-in-time on the client only. External references (e.g. lodash) are not
594
+ * available inside the function body — all logic must be self-contained.
595
+ *
596
+ * @example
597
+ * field('nid').customClientValidator((value) => {
598
+ * // LUHN check — all logic must be inline
599
+ * const digits = String(value).split('').map(Number)
600
+ * // ...
601
+ * return isValid
602
+ * })
603
+ */
604
+ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
605
+ /**
606
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
607
+ * that can be used as the `value` property or a DATA component entry.
608
+ * The function receives the referenced field's value as the first argument and
609
+ * the full form context as the second; its return value replaces the field reference.
610
+ * The function is serialised and executed just-in-time on the client only.
611
+ * External references (e.g. lodash) are not available inside the function body.
612
+ *
613
+ * For computing a default value without referencing a specific field, use
614
+ * `evaluate(fn)` in the `defaultValue` property instead.
615
+ *
616
+ * @example
617
+ * field('a').customClientEvaluation((aValue, ctx) =>
618
+ * Number(aValue) + Number(ctx.$form.b)
619
+ * )
620
+ */
621
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
656
622
  };
657
623
  asAge(): {
658
- $$subfield: string[];
659
624
  /**
660
625
  * @private Internal property used for field reference tracking.
661
626
  */
662
627
  $$field: string;
663
628
  get(fieldPath: string): any;
629
+ $$subfield: string[];
664
630
  getByPath(fieldPath: string[]): {
665
- $$subfield: string[];
666
631
  /**
667
632
  * @private Internal property used for field reference tracking.
668
633
  */
669
634
  $$field: string;
670
635
  get(fieldPath: string): any;
671
636
  getByPath(fieldPath: string[]): any;
637
+ $$subfield: string[];
672
638
  asDob(): any;
673
639
  asAge(): any;
674
640
  isAfter(): {
@@ -727,6 +693,37 @@ export declare function createFieldConditionals(fieldId: string): {
727
693
  * )
728
694
  */
729
695
  object: (options: Record<string, any>) => JSONSchema;
696
+ /**
697
+ * Custom client-side validator. The provided function is serialised and executed
698
+ * just-in-time on the client only. External references (e.g. lodash) are not
699
+ * available inside the function body — all logic must be self-contained.
700
+ *
701
+ * @example
702
+ * field('nid').customClientValidator((value) => {
703
+ * // LUHN check — all logic must be inline
704
+ * const digits = String(value).split('').map(Number)
705
+ * // ...
706
+ * return isValid
707
+ * })
708
+ */
709
+ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
710
+ /**
711
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
712
+ * that can be used as the `value` property or a DATA component entry.
713
+ * The function receives the referenced field's value as the first argument and
714
+ * the full form context as the second; its return value replaces the field reference.
715
+ * The function is serialised and executed just-in-time on the client only.
716
+ * External references (e.g. lodash) are not available inside the function body.
717
+ *
718
+ * For computing a default value without referencing a specific field, use
719
+ * `evaluate(fn)` in the `defaultValue` property instead.
720
+ *
721
+ * @example
722
+ * field('a').customClientEvaluation((aValue, ctx) =>
723
+ * Number(aValue) + Number(ctx.$form.b)
724
+ * )
725
+ */
726
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
730
727
  };
731
728
  asDob(): any;
732
729
  asAge(): any;
@@ -786,6 +783,37 @@ export declare function createFieldConditionals(fieldId: string): {
786
783
  * )
787
784
  */
788
785
  object: (options: Record<string, any>) => JSONSchema;
786
+ /**
787
+ * Custom client-side validator. The provided function is serialised and executed
788
+ * just-in-time on the client only. External references (e.g. lodash) are not
789
+ * available inside the function body — all logic must be self-contained.
790
+ *
791
+ * @example
792
+ * field('nid').customClientValidator((value) => {
793
+ * // LUHN check — all logic must be inline
794
+ * const digits = String(value).split('').map(Number)
795
+ * // ...
796
+ * return isValid
797
+ * })
798
+ */
799
+ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
800
+ /**
801
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
802
+ * that can be used as the `value` property or a DATA component entry.
803
+ * The function receives the referenced field's value as the first argument and
804
+ * the full form context as the second; its return value replaces the field reference.
805
+ * The function is serialised and executed just-in-time on the client only.
806
+ * External references (e.g. lodash) are not available inside the function body.
807
+ *
808
+ * For computing a default value without referencing a specific field, use
809
+ * `evaluate(fn)` in the `defaultValue` property instead.
810
+ *
811
+ * @example
812
+ * field('a').customClientEvaluation((aValue, ctx) =>
813
+ * Number(aValue) + Number(ctx.$form.b)
814
+ * )
815
+ */
816
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
789
817
  };
790
818
  isAfter(): {
791
819
  days: (days: number) => {
@@ -843,6 +871,37 @@ export declare function createFieldConditionals(fieldId: string): {
843
871
  * )
844
872
  */
845
873
  object: (options: Record<string, any>) => JSONSchema;
874
+ /**
875
+ * Custom client-side validator. The provided function is serialised and executed
876
+ * just-in-time on the client only. External references (e.g. lodash) are not
877
+ * available inside the function body — all logic must be self-contained.
878
+ *
879
+ * @example
880
+ * field('nid').customClientValidator((value) => {
881
+ * // LUHN check — all logic must be inline
882
+ * const digits = String(value).split('').map(Number)
883
+ * // ...
884
+ * return isValid
885
+ * })
886
+ */
887
+ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
888
+ /**
889
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
890
+ * that can be used as the `value` property or a DATA component entry.
891
+ * The function receives the referenced field's value as the first argument and
892
+ * the full form context as the second; its return value replaces the field reference.
893
+ * The function is serialised and executed just-in-time on the client only.
894
+ * External references (e.g. lodash) are not available inside the function body.
895
+ *
896
+ * For computing a default value without referencing a specific field, use
897
+ * `evaluate(fn)` in the `defaultValue` property instead.
898
+ *
899
+ * @example
900
+ * field('a').customClientEvaluation((aValue, ctx) =>
901
+ * Number(aValue) + Number(ctx.$form.b)
902
+ * )
903
+ */
904
+ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
846
905
  };
847
906
  export {};
848
907
  //# sourceMappingURL=conditionals.d.ts.map