@opencrvs/toolkit 2.0.0-rc.ca280e0 → 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.
- package/README.md +15 -0
- package/build.sh +3 -2
- package/dist/application-config/index.js +70 -40
- package/dist/cli.js +3262 -50
- package/dist/commons/api/router.d.ts +3012 -2927
- package/dist/commons/application-config/index.d.ts +7 -6
- package/dist/commons/conditionals/conditionals.d.ts +287 -234
- package/dist/commons/conditionals/validate.d.ts +51 -2
- package/dist/commons/events/ActionConfig.d.ts +93 -67
- package/dist/commons/events/ActionDocument.d.ts +113 -107
- package/dist/commons/events/ActionInput.d.ts +6 -0
- package/dist/commons/events/ActionType.d.ts +57 -57
- package/dist/commons/events/AdvancedSearchConfig.d.ts +651 -297
- package/dist/commons/events/AuditLog.d.ts +41 -41
- package/dist/commons/events/CompositeFieldValue.d.ts +4 -4
- package/dist/commons/events/Conditional.d.ts +3 -3
- package/dist/commons/events/CountryConfigQueryInput.d.ts +603 -561
- package/dist/commons/events/Draft.d.ts +35 -35
- package/dist/commons/events/DynamicFieldValue.d.ts +9 -9
- package/dist/commons/events/EventConfig.d.ts +5 -3
- package/dist/commons/events/EventDocument.d.ts +46 -43
- package/dist/commons/events/EventIndex.d.ts +76 -51
- package/dist/commons/events/EventMetadata.d.ts +60 -34
- package/dist/commons/events/FieldConfig.d.ts +710 -372
- package/dist/commons/events/FieldType.d.ts +51 -50
- package/dist/commons/events/FieldTypeMapping.d.ts +101 -101
- package/dist/commons/events/FieldValue.d.ts +18 -12
- package/dist/commons/events/Flag.d.ts +15 -15
- package/dist/commons/events/TemplateConfig.d.ts +1 -1
- package/dist/commons/events/WorkqueueColumnConfig.d.ts +40 -40
- package/dist/commons/events/WorkqueueConfig.d.ts +837 -798
- package/dist/commons/events/deduplication.d.ts +1 -1
- package/dist/commons/events/event.d.ts +2 -2
- package/dist/commons/events/field.d.ts +112 -189
- package/dist/commons/events/index.d.ts +1 -0
- package/dist/commons/events/locations.d.ts +5 -4
- package/dist/commons/events/mocks.test.utils.d.ts +2 -2
- package/dist/commons/events/scopes.d.ts +4 -4
- package/dist/commons/events/state/flags.d.ts +16 -0
- package/dist/commons/events/state/index.d.ts +23 -15
- package/dist/commons/events/state/utils.d.ts +25 -291
- package/dist/commons/events/test.utils.d.ts +33 -33
- package/dist/commons/events/utils.d.ts +120 -109
- package/dist/commons/notification/UserNotifications.d.ts +10 -10
- package/dist/conditionals/index.js +58 -6
- package/dist/environment/custom-types.d.ts +33 -0
- package/dist/environment/custom-types.d.ts.map +1 -0
- package/dist/environment/custom-types.js +12 -0
- package/dist/environment/derived-variables.d.ts +134 -0
- package/dist/environment/derived-variables.d.ts.map +1 -0
- package/dist/environment/derived-variables.js +169 -0
- package/dist/environment/editor-questions.d.ts +4 -0
- package/dist/environment/editor-questions.d.ts.map +1 -0
- package/dist/environment/editor-questions.js +67 -0
- package/dist/environment/git.d.ts +5 -0
- package/dist/environment/git.d.ts.map +1 -0
- package/dist/environment/git.js +38 -0
- package/dist/environment/github.d.ts +26 -0
- package/dist/environment/github.d.ts.map +1 -0
- package/dist/environment/github.js +247 -0
- package/dist/environment/index.d.ts +5 -0
- package/dist/environment/index.d.ts.map +1 -0
- package/dist/environment/index.js +71 -0
- package/dist/environment/logger.d.ts +6 -0
- package/dist/environment/logger.d.ts.map +1 -0
- package/dist/environment/logger.js +25 -0
- package/dist/environment/manage-users.d.ts +11 -0
- package/dist/environment/manage-users.d.ts.map +1 -0
- package/dist/environment/manage-users.js +507 -0
- package/dist/environment/questions-helper.d.ts +15 -0
- package/dist/environment/questions-helper.d.ts.map +1 -0
- package/dist/environment/questions-helper.js +70 -0
- package/dist/environment/questions.d.ts +200 -0
- package/dist/environment/questions.d.ts.map +1 -0
- package/dist/environment/questions.js +412 -0
- package/dist/environment/setup-environment.d.ts +2 -0
- package/dist/environment/setup-environment.d.ts.map +1 -0
- package/dist/environment/setup-environment.js +788 -0
- package/dist/environment/ssh-keygen.d.ts +5 -0
- package/dist/environment/ssh-keygen.d.ts.map +1 -0
- package/dist/environment/ssh-keygen.js +21 -0
- package/dist/environment/swarm-to-k8s.d.ts +2 -0
- package/dist/environment/swarm-to-k8s.d.ts.map +1 -0
- package/dist/environment/swarm-to-k8s.js +183 -0
- package/dist/environment/templates.d.ts +27 -0
- package/dist/environment/templates.d.ts.map +1 -0
- package/dist/environment/templates.js +163 -0
- package/dist/environment/update-workflows.d.ts +2 -0
- package/dist/environment/update-workflows.d.ts.map +1 -0
- package/dist/environment/update-workflows.js +179 -0
- package/dist/environment/users.d.ts +2 -0
- package/dist/environment/users.d.ts.map +1 -0
- package/dist/environment/users.js +122 -0
- package/dist/environment/utils.d.ts +18 -0
- package/dist/environment/utils.d.ts.map +1 -0
- package/dist/environment/utils.js +110 -0
- package/dist/events/deduplication.d.ts +1 -1
- package/dist/events/index.js +446 -147
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts +1 -1
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
- package/dist/migrations/v2.0/checkout-upstream-files.js +1 -1
- package/dist/migrations/v2.0/convert-config-files-to-ts.js +17 -7
- package/dist/migrations/v2.0/index.js +20 -9
- package/dist/migrations/v2.0/migrate-application-config-url.js +4 -3
- package/dist/migrations/v2.0/remove-hearth-migrations.js +17 -7
- package/dist/notification/index.js +265 -45
- package/dist/scopes/index.d.ts +209 -123
- package/dist/scopes/index.js +19 -8
- package/dist/templates/charts-values/dependencies/values.override.yaml +4 -0
- package/dist/templates/charts-values/dependencies/values.yaml +83 -0
- package/dist/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
- package/dist/templates/charts-values/opencrvs-services/values.yaml +81 -0
- package/dist/templates/charts-values/traefik/values.override.yaml +4 -0
- package/dist/templates/charts-values/traefik/values.yaml +115 -0
- package/dist/templates/inventory/inventory.template.yml +100 -0
- package/dist/templates/inventory/production.example.yml +77 -0
- package/dist/templates/inventory/qa.example.yml +48 -0
- package/opencrvs-toolkit-2.0.0-rc.ca3fe84.tgz +0 -0
- package/package.json +16 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/opencrvs-toolkit-2.0.0-rc.ca280e0.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 |
|
|
29
|
+
$form: EventState | ActionUpdate;
|
|
29
30
|
$leafAdminStructureLocationIds?: Array<{
|
|
30
31
|
id: UUID;
|
|
31
32
|
}>;
|
|
@@ -82,32 +83,34 @@ export declare const now: typeof todayDateTimeValueSerializer;
|
|
|
82
83
|
* Generate conditional rules for user.
|
|
83
84
|
*/
|
|
84
85
|
export declare const user: typeof userSerializer & {
|
|
85
|
-
hasScope: (scope: string) => JSONSchema;
|
|
86
|
-
hasRole: (role: string) => JSONSchema;
|
|
87
|
-
isOnline: () => JSONSchema;
|
|
88
|
-
locationLevel: (adminLevelId: string) => {
|
|
89
|
-
$user: {
|
|
90
|
-
$location: string;
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
86
|
scope: (scope: import("../scopes").ScopeType) => {
|
|
94
87
|
attribute: (option: import("../scopes").ScopeOptionKey) => {
|
|
95
|
-
$scope: "
|
|
96
|
-
$option: "
|
|
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";
|
|
97
90
|
};
|
|
98
91
|
};
|
|
99
92
|
jurisdiction: (jurisdiction: import("../scopes").JurisdictionFilter | {
|
|
100
|
-
$scope: "
|
|
101
|
-
$option: "
|
|
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";
|
|
102
95
|
}) => {
|
|
103
|
-
$jurisdiction: "administrativeArea" | "
|
|
104
|
-
$scope: "
|
|
105
|
-
$option: "
|
|
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;
|
|
106
107
|
};
|
|
107
108
|
};
|
|
108
109
|
};
|
|
109
110
|
export declare function isFieldReference(value: unknown): value is FieldReference;
|
|
110
|
-
export declare function isEventFieldReference(value: unknown): value is
|
|
111
|
+
export declare function isEventFieldReference(value: unknown): value is {
|
|
112
|
+
$$event: string;
|
|
113
|
+
};
|
|
111
114
|
/** Check if an event flag is present */
|
|
112
115
|
export declare function flag(flagvalue: string): JSONSchema;
|
|
113
116
|
/** Check if an event flag is present */
|
|
@@ -130,22 +133,22 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
130
133
|
*/
|
|
131
134
|
$$subfield: string[];
|
|
132
135
|
get(fieldPath: string): {
|
|
133
|
-
$$subfield: string[];
|
|
134
136
|
/**
|
|
135
137
|
* @private Internal property used for field reference tracking.
|
|
136
138
|
*/
|
|
137
139
|
$$field: string;
|
|
138
|
-
get(fieldPath: string): any;
|
|
140
|
+
get(fieldPath: string): /*elided*/ any;
|
|
141
|
+
$$subfield: string[];
|
|
139
142
|
getByPath(fieldPath: string[]): {
|
|
140
|
-
$$subfield: string[];
|
|
141
143
|
/**
|
|
142
144
|
* @private Internal property used for field reference tracking.
|
|
143
145
|
*/
|
|
144
146
|
$$field: string;
|
|
145
|
-
get(fieldPath: string): any;
|
|
146
|
-
getByPath(fieldPath: string[]): any;
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
get(fieldPath: string): /*elided*/ any;
|
|
148
|
+
getByPath(fieldPath: string[]): /*elided*/ any;
|
|
149
|
+
$$subfield: string[];
|
|
150
|
+
asDob(): /*elided*/ any;
|
|
151
|
+
asAge(): /*elided*/ any;
|
|
149
152
|
isAfter(): {
|
|
150
153
|
days: (days: number) => {
|
|
151
154
|
inPast: () => JSONSchema;
|
|
@@ -202,9 +205,40 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
202
205
|
* )
|
|
203
206
|
*/
|
|
204
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;
|
|
205
239
|
};
|
|
206
|
-
asDob(): any;
|
|
207
|
-
asAge(): any;
|
|
240
|
+
asDob(): /*elided*/ any;
|
|
241
|
+
asAge(): /*elided*/ any;
|
|
208
242
|
isAfter(): {
|
|
209
243
|
days: (days: number) => {
|
|
210
244
|
inPast: () => JSONSchema;
|
|
@@ -261,215 +295,48 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
261
295
|
* )
|
|
262
296
|
*/
|
|
263
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;
|
|
264
329
|
};
|
|
265
330
|
getByPath(fieldPath: string[]): {
|
|
266
|
-
$$subfield: string[];
|
|
267
331
|
/**
|
|
268
332
|
* @private Internal property used for field reference tracking.
|
|
269
333
|
*/
|
|
270
334
|
$$field: string;
|
|
271
|
-
get(fieldPath: string):
|
|
272
|
-
$$subfield: string[];
|
|
273
|
-
/**
|
|
274
|
-
* @private Internal property used for field reference tracking.
|
|
275
|
-
*/
|
|
276
|
-
$$field: string;
|
|
277
|
-
get(fieldPath: string): any;
|
|
278
|
-
getByPath(fieldPath: string[]): any;
|
|
279
|
-
asDob(): any;
|
|
280
|
-
asAge(): any;
|
|
281
|
-
isAfter(): {
|
|
282
|
-
days: (days: number) => {
|
|
283
|
-
inPast: () => JSONSchema;
|
|
284
|
-
inFuture: () => JSONSchema;
|
|
285
|
-
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
286
|
-
fromNow: () => JSONSchema;
|
|
287
|
-
};
|
|
288
|
-
date: (date: string | FieldReference) => JSONSchema;
|
|
289
|
-
now: () => JSONSchema;
|
|
290
|
-
};
|
|
291
|
-
isBefore(): {
|
|
292
|
-
days: (days: number) => {
|
|
293
|
-
inPast: () => JSONSchema;
|
|
294
|
-
inFuture: () => JSONSchema;
|
|
295
|
-
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
296
|
-
fromNow: () => JSONSchema;
|
|
297
|
-
};
|
|
298
|
-
date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
299
|
-
now: () => JSONSchema;
|
|
300
|
-
};
|
|
301
|
-
isGreaterThan(value: number | FieldReference): JSONSchema;
|
|
302
|
-
isLessThan(value: number | FieldReference): JSONSchema;
|
|
303
|
-
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
304
|
-
/**
|
|
305
|
-
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
|
306
|
-
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
|
307
|
-
* @returns whether the field is falsy (undefined, false, null, empty string)
|
|
308
|
-
*
|
|
309
|
-
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
|
310
|
-
*
|
|
311
|
-
*/
|
|
312
|
-
isFalsy(): JSONSchema;
|
|
313
|
-
isUndefined(): JSONSchema;
|
|
314
|
-
inArray(values: string[]): JSONSchema;
|
|
315
|
-
isValidEnglishName(): JSONSchema;
|
|
316
|
-
isValidAdministrativeLeafLevel(): JSONSchema;
|
|
317
|
-
/**
|
|
318
|
-
* Checks if the field value matches a given regular expression pattern.
|
|
319
|
-
* @param pattern - The regular expression pattern to match the field value against.
|
|
320
|
-
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
|
321
|
-
*/
|
|
322
|
-
matches(pattern: string): JSONSchema;
|
|
323
|
-
isBetween(min: number, max: number): JSONSchema;
|
|
324
|
-
getId: () => {
|
|
325
|
-
fieldId: string;
|
|
326
|
-
};
|
|
327
|
-
/**
|
|
328
|
-
* @deprecated
|
|
329
|
-
* use field(fieldId).get(nestedProperty) instead
|
|
330
|
-
* with 'and' combinator e.g.
|
|
331
|
-
* and(
|
|
332
|
-
* field('child.name').get('firstname').isEqualTo('John'),
|
|
333
|
-
* field('child.name').get('surname').isEqualTo('Doe')
|
|
334
|
-
* )
|
|
335
|
-
*/
|
|
336
|
-
object: (options: Record<string, any>) => JSONSchema;
|
|
337
|
-
};
|
|
335
|
+
get(fieldPath: string): any;
|
|
338
336
|
getByPath(fieldPath: string[]): any;
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
* @private Internal property used for field reference tracking.
|
|
343
|
-
*/
|
|
344
|
-
$$field: string;
|
|
345
|
-
get(fieldPath: string): any;
|
|
346
|
-
getByPath(fieldPath: string[]): any;
|
|
347
|
-
asDob(): any;
|
|
348
|
-
asAge(): any;
|
|
349
|
-
isAfter(): {
|
|
350
|
-
days: (days: number) => {
|
|
351
|
-
inPast: () => JSONSchema;
|
|
352
|
-
inFuture: () => JSONSchema;
|
|
353
|
-
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
354
|
-
fromNow: () => JSONSchema;
|
|
355
|
-
};
|
|
356
|
-
date: (date: string | FieldReference) => JSONSchema;
|
|
357
|
-
now: () => JSONSchema;
|
|
358
|
-
};
|
|
359
|
-
isBefore(): {
|
|
360
|
-
days: (days: number) => {
|
|
361
|
-
inPast: () => JSONSchema;
|
|
362
|
-
inFuture: () => JSONSchema;
|
|
363
|
-
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
364
|
-
fromNow: () => JSONSchema;
|
|
365
|
-
};
|
|
366
|
-
date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
367
|
-
now: () => JSONSchema;
|
|
368
|
-
};
|
|
369
|
-
isGreaterThan(value: number | FieldReference): JSONSchema;
|
|
370
|
-
isLessThan(value: number | FieldReference): JSONSchema;
|
|
371
|
-
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
372
|
-
/**
|
|
373
|
-
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
|
374
|
-
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
|
375
|
-
* @returns whether the field is falsy (undefined, false, null, empty string)
|
|
376
|
-
*
|
|
377
|
-
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
|
378
|
-
*
|
|
379
|
-
*/
|
|
380
|
-
isFalsy(): JSONSchema;
|
|
381
|
-
isUndefined(): JSONSchema;
|
|
382
|
-
inArray(values: string[]): JSONSchema;
|
|
383
|
-
isValidEnglishName(): JSONSchema;
|
|
384
|
-
isValidAdministrativeLeafLevel(): JSONSchema;
|
|
385
|
-
/**
|
|
386
|
-
* Checks if the field value matches a given regular expression pattern.
|
|
387
|
-
* @param pattern - The regular expression pattern to match the field value against.
|
|
388
|
-
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
|
389
|
-
*/
|
|
390
|
-
matches(pattern: string): JSONSchema;
|
|
391
|
-
isBetween(min: number, max: number): JSONSchema;
|
|
392
|
-
getId: () => {
|
|
393
|
-
fieldId: string;
|
|
394
|
-
};
|
|
395
|
-
/**
|
|
396
|
-
* @deprecated
|
|
397
|
-
* use field(fieldId).get(nestedProperty) instead
|
|
398
|
-
* with 'and' combinator e.g.
|
|
399
|
-
* and(
|
|
400
|
-
* field('child.name').get('firstname').isEqualTo('John'),
|
|
401
|
-
* field('child.name').get('surname').isEqualTo('Doe')
|
|
402
|
-
* )
|
|
403
|
-
*/
|
|
404
|
-
object: (options: Record<string, any>) => JSONSchema;
|
|
405
|
-
};
|
|
406
|
-
asAge(): {
|
|
407
|
-
$$subfield: string[];
|
|
408
|
-
/**
|
|
409
|
-
* @private Internal property used for field reference tracking.
|
|
410
|
-
*/
|
|
411
|
-
$$field: string;
|
|
412
|
-
get(fieldPath: string): any;
|
|
413
|
-
getByPath(fieldPath: string[]): any;
|
|
414
|
-
asDob(): any;
|
|
415
|
-
asAge(): any;
|
|
416
|
-
isAfter(): {
|
|
417
|
-
days: (days: number) => {
|
|
418
|
-
inPast: () => JSONSchema;
|
|
419
|
-
inFuture: () => JSONSchema;
|
|
420
|
-
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
421
|
-
fromNow: () => JSONSchema;
|
|
422
|
-
};
|
|
423
|
-
date: (date: string | FieldReference) => JSONSchema;
|
|
424
|
-
now: () => JSONSchema;
|
|
425
|
-
};
|
|
426
|
-
isBefore(): {
|
|
427
|
-
days: (days: number) => {
|
|
428
|
-
inPast: () => JSONSchema;
|
|
429
|
-
inFuture: () => JSONSchema;
|
|
430
|
-
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
431
|
-
fromNow: () => JSONSchema;
|
|
432
|
-
};
|
|
433
|
-
date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
434
|
-
now: () => JSONSchema;
|
|
435
|
-
};
|
|
436
|
-
isGreaterThan(value: number | FieldReference): JSONSchema;
|
|
437
|
-
isLessThan(value: number | FieldReference): JSONSchema;
|
|
438
|
-
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
439
|
-
/**
|
|
440
|
-
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
|
441
|
-
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
|
442
|
-
* @returns whether the field is falsy (undefined, false, null, empty string)
|
|
443
|
-
*
|
|
444
|
-
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
|
445
|
-
*
|
|
446
|
-
*/
|
|
447
|
-
isFalsy(): JSONSchema;
|
|
448
|
-
isUndefined(): JSONSchema;
|
|
449
|
-
inArray(values: string[]): JSONSchema;
|
|
450
|
-
isValidEnglishName(): JSONSchema;
|
|
451
|
-
isValidAdministrativeLeafLevel(): JSONSchema;
|
|
452
|
-
/**
|
|
453
|
-
* Checks if the field value matches a given regular expression pattern.
|
|
454
|
-
* @param pattern - The regular expression pattern to match the field value against.
|
|
455
|
-
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
|
456
|
-
*/
|
|
457
|
-
matches(pattern: string): JSONSchema;
|
|
458
|
-
isBetween(min: number, max: number): JSONSchema;
|
|
459
|
-
getId: () => {
|
|
460
|
-
fieldId: string;
|
|
461
|
-
};
|
|
462
|
-
/**
|
|
463
|
-
* @deprecated
|
|
464
|
-
* use field(fieldId).get(nestedProperty) instead
|
|
465
|
-
* with 'and' combinator e.g.
|
|
466
|
-
* and(
|
|
467
|
-
* field('child.name').get('firstname').isEqualTo('John'),
|
|
468
|
-
* field('child.name').get('surname').isEqualTo('Doe')
|
|
469
|
-
* )
|
|
470
|
-
*/
|
|
471
|
-
object: (options: Record<string, any>) => JSONSchema;
|
|
472
|
-
};
|
|
337
|
+
$$subfield: string[];
|
|
338
|
+
asDob(): any;
|
|
339
|
+
asAge(): any;
|
|
473
340
|
isAfter(): {
|
|
474
341
|
days: (days: number) => {
|
|
475
342
|
inPast: () => JSONSchema;
|
|
@@ -526,22 +393,53 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
526
393
|
* )
|
|
527
394
|
*/
|
|
528
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;
|
|
529
427
|
};
|
|
530
428
|
asDob(): {
|
|
531
|
-
$$subfield: string[];
|
|
532
429
|
/**
|
|
533
430
|
* @private Internal property used for field reference tracking.
|
|
534
431
|
*/
|
|
535
432
|
$$field: string;
|
|
536
433
|
get(fieldPath: string): any;
|
|
434
|
+
$$subfield: string[];
|
|
537
435
|
getByPath(fieldPath: string[]): {
|
|
538
|
-
$$subfield: string[];
|
|
539
436
|
/**
|
|
540
437
|
* @private Internal property used for field reference tracking.
|
|
541
438
|
*/
|
|
542
439
|
$$field: string;
|
|
543
440
|
get(fieldPath: string): any;
|
|
544
441
|
getByPath(fieldPath: string[]): any;
|
|
442
|
+
$$subfield: string[];
|
|
545
443
|
asDob(): any;
|
|
546
444
|
asAge(): any;
|
|
547
445
|
isAfter(): {
|
|
@@ -600,6 +498,37 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
600
498
|
* )
|
|
601
499
|
*/
|
|
602
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;
|
|
603
532
|
};
|
|
604
533
|
asDob(): any;
|
|
605
534
|
asAge(): any;
|
|
@@ -659,22 +588,53 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
659
588
|
* )
|
|
660
589
|
*/
|
|
661
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;
|
|
662
622
|
};
|
|
663
623
|
asAge(): {
|
|
664
|
-
$$subfield: string[];
|
|
665
624
|
/**
|
|
666
625
|
* @private Internal property used for field reference tracking.
|
|
667
626
|
*/
|
|
668
627
|
$$field: string;
|
|
669
628
|
get(fieldPath: string): any;
|
|
629
|
+
$$subfield: string[];
|
|
670
630
|
getByPath(fieldPath: string[]): {
|
|
671
|
-
$$subfield: string[];
|
|
672
631
|
/**
|
|
673
632
|
* @private Internal property used for field reference tracking.
|
|
674
633
|
*/
|
|
675
634
|
$$field: string;
|
|
676
635
|
get(fieldPath: string): any;
|
|
677
636
|
getByPath(fieldPath: string[]): any;
|
|
637
|
+
$$subfield: string[];
|
|
678
638
|
asDob(): any;
|
|
679
639
|
asAge(): any;
|
|
680
640
|
isAfter(): {
|
|
@@ -733,6 +693,37 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
733
693
|
* )
|
|
734
694
|
*/
|
|
735
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;
|
|
736
727
|
};
|
|
737
728
|
asDob(): any;
|
|
738
729
|
asAge(): any;
|
|
@@ -792,6 +783,37 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
792
783
|
* )
|
|
793
784
|
*/
|
|
794
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;
|
|
795
817
|
};
|
|
796
818
|
isAfter(): {
|
|
797
819
|
days: (days: number) => {
|
|
@@ -849,6 +871,37 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
849
871
|
* )
|
|
850
872
|
*/
|
|
851
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;
|
|
852
905
|
};
|
|
853
906
|
export {};
|
|
854
907
|
//# sourceMappingURL=conditionals.d.ts.map
|