@opencrvs/toolkit 2.0.0-rc.b0b93f7 → 2.0.0-rc.b0c39c7
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 +102 -17
- package/dist/commons/application-config/index.d.ts +1 -0
- package/dist/commons/conditionals/conditionals.d.ts +351 -7
- package/dist/commons/conditionals/validate.d.ts +51 -2
- package/dist/commons/events/ActionConfig.d.ts +35 -2
- package/dist/commons/events/ActionDocument.d.ts +6 -0
- package/dist/commons/events/ActionInput.d.ts +6 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +354 -0
- package/dist/commons/events/CountryConfigQueryInput.d.ts +42 -0
- package/dist/commons/events/EventConfig.d.ts +2 -0
- package/dist/commons/events/EventDocument.d.ts +3 -0
- package/dist/commons/events/EventIndex.d.ts +25 -0
- package/dist/commons/events/EventMetadata.d.ts +26 -0
- package/dist/commons/events/FieldConfig.d.ts +388 -50
- package/dist/commons/events/FieldType.d.ts +1 -0
- package/dist/commons/events/FieldTypeMapping.d.ts +1 -1
- package/dist/commons/events/FieldValue.d.ts +6 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +39 -0
- package/dist/commons/events/field.d.ts +53 -1
- package/dist/commons/events/index.d.ts +1 -0
- package/dist/commons/events/locations.d.ts +1 -0
- package/dist/commons/events/state/flags.d.ts +1 -0
- package/dist/commons/events/state/index.d.ts +8 -0
- package/dist/commons/events/state/utils.d.ts +21 -287
- package/dist/commons/events/utils.d.ts +20 -1
- 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 +15 -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 +497 -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 +199 -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 +794 -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 +173 -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 +169 -0
- package/dist/environment/users.d.ts +2 -0
- package/dist/environment/users.d.ts.map +1 -0
- package/dist/environment/users.js +112 -0
- package/dist/environment/utils.d.ts +18 -0
- package/dist/environment/utils.d.ts.map +1 -0
- package/dist/environment/utils.js +100 -0
- package/dist/events/index.js +449 -163
- 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/index.js +20 -9
- package/dist/notification/index.js +278 -54
- package/dist/scopes/index.d.ts +93 -7
- 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.b0c39c7.tgz +0 -0
- package/package.json +15 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/opencrvs-toolkit-2.0.0-rc.b0b93f7.tgz +0 -0
package/dist/events/index.js
CHANGED
|
@@ -75,6 +75,7 @@ __export(events_exports, {
|
|
|
75
75
|
CheckboxFieldValue: () => CheckboxFieldValue,
|
|
76
76
|
Clause: () => Clause,
|
|
77
77
|
ClientSpecificAction: () => ClientSpecificAction,
|
|
78
|
+
ComputedDefaultValue: () => ComputedDefaultValue,
|
|
78
79
|
Conditional: () => Conditional,
|
|
79
80
|
ConditionalType: () => ConditionalType,
|
|
80
81
|
ConfirmableActions: () => ConfirmableActions,
|
|
@@ -150,6 +151,7 @@ __export(events_exports, {
|
|
|
150
151
|
FormPageConfig: () => FormPageConfig,
|
|
151
152
|
Fuzzy: () => Fuzzy,
|
|
152
153
|
GeographicalArea: () => GeographicalArea,
|
|
154
|
+
HiddenFieldTypes: () => HiddenFieldTypes,
|
|
153
155
|
HiddenFieldValue: () => HiddenFieldValue,
|
|
154
156
|
HttpFieldUpdateValue: () => HttpFieldUpdateValue,
|
|
155
157
|
HttpFieldValue: () => HttpFieldValue,
|
|
@@ -200,6 +202,7 @@ __export(events_exports, {
|
|
|
200
202
|
SelectDateRangeValue: () => SelectDateRangeValue,
|
|
201
203
|
SelectOption: () => SelectOption,
|
|
202
204
|
ShowConditional: () => ShowConditional,
|
|
205
|
+
SignatureFieldValue: () => SignatureFieldValue,
|
|
203
206
|
StaticDataEntry: () => StaticDataEntry,
|
|
204
207
|
StreetLevelDetailsUpdateValue: () => StreetLevelDetailsUpdateValue,
|
|
205
208
|
SummaryConfig: () => SummaryConfig,
|
|
@@ -246,10 +249,12 @@ __export(events_exports, {
|
|
|
246
249
|
applyDraftToEventIndex: () => applyDraftToEventIndex,
|
|
247
250
|
areCertificateConditionsMet: () => areCertificateConditionsMet,
|
|
248
251
|
areConditionsMet: () => areConditionsMet,
|
|
252
|
+
buildClientFunctionContext: () => buildClientFunctionContext,
|
|
249
253
|
buildFormState: () => buildFormState,
|
|
250
254
|
canAccessEventWithScope: () => canAccessEventWithScope,
|
|
251
255
|
canAccessOtherUserWithScopes: () => canAccessOtherUserWithScopes,
|
|
252
256
|
canAccessUserWithScope: () => canAccessUserWithScope,
|
|
257
|
+
compileClientFunction: () => compileClientFunction,
|
|
253
258
|
compositeFieldTypes: () => compositeFieldTypes,
|
|
254
259
|
createEmptyDraft: () => createEmptyDraft,
|
|
255
260
|
createFieldConditionals: () => createFieldConditionals,
|
|
@@ -270,6 +275,7 @@ __export(events_exports, {
|
|
|
270
275
|
defineWorkqueuesColumns: () => defineWorkqueuesColumns,
|
|
271
276
|
deserializeQuery: () => deserializeQuery,
|
|
272
277
|
errorMessages: () => errorMessages,
|
|
278
|
+
evaluate: () => evaluate,
|
|
273
279
|
event: () => event,
|
|
274
280
|
eventMetadataLabelMap: () => eventMetadataLabelMap,
|
|
275
281
|
eventPayloadGenerator: () => eventPayloadGenerator,
|
|
@@ -282,6 +288,7 @@ __export(events_exports, {
|
|
|
282
288
|
findActiveDraftForEvent: () => findActiveDraftForEvent,
|
|
283
289
|
findAllFields: () => findAllFields,
|
|
284
290
|
findLastAssignmentAction: () => findLastAssignmentAction,
|
|
291
|
+
findPendingCorrectionAction: () => findPendingCorrectionAction,
|
|
285
292
|
findRecordActionPages: () => findRecordActionPages,
|
|
286
293
|
flag: () => flag,
|
|
287
294
|
flattenFieldReference: () => flattenFieldReference,
|
|
@@ -305,6 +312,7 @@ __export(events_exports, {
|
|
|
305
312
|
getActionAnnotation: () => getActionAnnotation,
|
|
306
313
|
getActionAnnotationFields: () => getActionAnnotationFields,
|
|
307
314
|
getActionConfig: () => getActionConfig,
|
|
315
|
+
getActionFormFields: () => getActionFormFields,
|
|
308
316
|
getActionReview: () => getActionReview,
|
|
309
317
|
getActionReviewFields: () => getActionReviewFields,
|
|
310
318
|
getAdministrativeAreaHierarchy: () => getAdministrativeAreaHierarchy,
|
|
@@ -315,6 +323,7 @@ __export(events_exports, {
|
|
|
315
323
|
getAvailableActionsForEvent: () => getAvailableActionsForEvent,
|
|
316
324
|
getAvailableRolesForUserUpdatePayload: () => getAvailableRolesForUserUpdatePayload,
|
|
317
325
|
getCompleteActionAnnotation: () => getCompleteActionAnnotation,
|
|
326
|
+
getCompleteActionContent: () => getCompleteActionContent,
|
|
318
327
|
getCompleteActionDeclaration: () => getCompleteActionDeclaration,
|
|
319
328
|
getCurrentEventState: () => getCurrentEventState,
|
|
320
329
|
getCustomActionFields: () => getCustomActionFields,
|
|
@@ -323,6 +332,7 @@ __export(events_exports, {
|
|
|
323
332
|
getDeclarationFields: () => getDeclarationFields,
|
|
324
333
|
getDeclarationPages: () => getDeclarationPages,
|
|
325
334
|
getEventConfigById: () => getEventConfigById,
|
|
335
|
+
getEventFlags: () => getEventFlags,
|
|
326
336
|
getFilePathsFromEvent: () => getFilePathsFromEvent,
|
|
327
337
|
getLocationHierarchy: () => getLocationHierarchy,
|
|
328
338
|
getMixedPath: () => getMixedPath,
|
|
@@ -345,6 +355,7 @@ __export(events_exports, {
|
|
|
345
355
|
isBulletListFieldType: () => isBulletListFieldType,
|
|
346
356
|
isButtonFieldType: () => isButtonFieldType,
|
|
347
357
|
isCheckboxFieldType: () => isCheckboxFieldType,
|
|
358
|
+
isCodeToEvaluate: () => isCodeToEvaluate,
|
|
348
359
|
isConditionMet: () => isConditionMet,
|
|
349
360
|
isCountryFieldType: () => isCountryFieldType,
|
|
350
361
|
isCustomFieldType: () => isCustomFieldType,
|
|
@@ -385,6 +396,7 @@ __export(events_exports, {
|
|
|
385
396
|
isPageVisible: () => isPageVisible,
|
|
386
397
|
isParagraphFieldType: () => isParagraphFieldType,
|
|
387
398
|
isPhoneFieldType: () => isPhoneFieldType,
|
|
399
|
+
isPotentialDuplicate: () => isPotentialDuplicate,
|
|
388
400
|
isPrintButtonFieldType: () => isPrintButtonFieldType,
|
|
389
401
|
isQrReaderFieldType: () => isQrReaderFieldType,
|
|
390
402
|
isQueryParamReaderFieldType: () => isQueryParamReaderFieldType,
|
|
@@ -418,12 +430,15 @@ __export(events_exports, {
|
|
|
418
430
|
plainDateToLocalDate: () => plainDateToLocalDate,
|
|
419
431
|
precompileActionSchemas: () => precompileActionSchemas,
|
|
420
432
|
resolveDateOfEvent: () => resolveDateOfEvent,
|
|
433
|
+
resolveEventCustomFlags: () => resolveEventCustomFlags,
|
|
421
434
|
resolvePlaceOfEvent: () => resolvePlaceOfEvent,
|
|
435
|
+
runClientFunction: () => runClientFunction,
|
|
422
436
|
runFieldValidations: () => runFieldValidations,
|
|
423
437
|
runStructuralValidations: () => runStructuralValidations,
|
|
424
438
|
safeUnion: () => safeUnion,
|
|
425
439
|
status: () => status,
|
|
426
440
|
timePeriodToDateRange: () => timePeriodToDateRange,
|
|
441
|
+
todayISO: () => todayISO,
|
|
427
442
|
user: () => user,
|
|
428
443
|
userCanAccessEventWithScopes: () => userCanAccessEventWithScopes,
|
|
429
444
|
validate: () => validate,
|
|
@@ -506,11 +521,13 @@ var scopeOptionsPlaceEvent = z2.object({
|
|
|
506
521
|
event: scopeByEvent,
|
|
507
522
|
placeOfEvent: JurisdictionFilter.optional()
|
|
508
523
|
}).describe("Options applicable to all record scopes.");
|
|
509
|
-
var
|
|
524
|
+
var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
|
|
525
|
+
notifiedIn: JurisdictionFilter.optional(),
|
|
526
|
+
notifiedBy: UserFilter.optional(),
|
|
510
527
|
declaredIn: JurisdictionFilter.optional(),
|
|
511
528
|
declaredBy: UserFilter.optional()
|
|
512
529
|
}).describe("Options applicable to actions that may take place after DECLARE");
|
|
513
|
-
var AllRecordScopeOptions =
|
|
530
|
+
var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
|
|
514
531
|
registeredIn: JurisdictionFilter.optional(),
|
|
515
532
|
registeredBy: UserFilter.optional()
|
|
516
533
|
}).describe(
|
|
@@ -548,6 +565,8 @@ var ResolvedScopeOptionsPlaceEvent = z2.object({
|
|
|
548
565
|
"Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
|
|
549
566
|
);
|
|
550
567
|
var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
|
|
568
|
+
notifiedIn: UUID.nullish(),
|
|
569
|
+
notifiedBy: z2.string().optional(),
|
|
551
570
|
declaredIn: UUID.nullish(),
|
|
552
571
|
declaredBy: z2.string().optional()
|
|
553
572
|
}).describe(
|
|
@@ -593,7 +612,7 @@ var RecordScopeV2 = z2.discriminatedUnion("type", [
|
|
|
593
612
|
}),
|
|
594
613
|
z2.object({
|
|
595
614
|
type: ScopesWithDeclaredOptions,
|
|
596
|
-
options:
|
|
615
|
+
options: scopeOptionsDeclaredOrNotified.optional()
|
|
597
616
|
}),
|
|
598
617
|
z2.object({
|
|
599
618
|
type: ScopesWithFullOptions,
|
|
@@ -698,20 +717,27 @@ var unflattenScope = (input) => {
|
|
|
698
717
|
return { type, options };
|
|
699
718
|
};
|
|
700
719
|
var EncodedScope = z2.string().brand("EncodedScope");
|
|
701
|
-
var
|
|
702
|
-
|
|
720
|
+
var decodedScopeCache = /* @__PURE__ */ new Map();
|
|
721
|
+
var decodeScope = (encodedScope) => {
|
|
722
|
+
if (decodedScopeCache.has(encodedScope)) {
|
|
723
|
+
return decodedScopeCache.get(encodedScope);
|
|
724
|
+
}
|
|
725
|
+
const scope = qs.parse(encodedScope, {
|
|
703
726
|
ignoreQueryPrefix: true,
|
|
704
727
|
comma: true,
|
|
705
728
|
allowDots: true
|
|
706
729
|
});
|
|
707
730
|
const unflattenedScope = unflattenScope(scope);
|
|
708
|
-
|
|
731
|
+
const result = Scope.safeParse(unflattenedScope)?.data;
|
|
732
|
+
decodedScopeCache.set(encodedScope, result);
|
|
733
|
+
return result;
|
|
709
734
|
};
|
|
710
735
|
var DEFAULT_SCOPE_OPTIONS = {
|
|
711
736
|
placeOfEvent: JurisdictionFilter.enum.all,
|
|
712
737
|
accessLevel: JurisdictionFilter.enum.all,
|
|
713
|
-
|
|
714
|
-
declaredIn: JurisdictionFilter.enum.all
|
|
738
|
+
notifiedIn: JurisdictionFilter.enum.all,
|
|
739
|
+
declaredIn: JurisdictionFilter.enum.all,
|
|
740
|
+
registeredIn: JurisdictionFilter.enum.all
|
|
715
741
|
};
|
|
716
742
|
function getAcceptedScopesByType({
|
|
717
743
|
acceptedScopes,
|
|
@@ -1200,6 +1226,11 @@ var FieldTypesToHideInReview = [
|
|
|
1200
1226
|
FieldType.ALPHA_PRINT_BUTTON,
|
|
1201
1227
|
FieldType.ALPHA_HIDDEN
|
|
1202
1228
|
];
|
|
1229
|
+
var HiddenFieldTypes = [
|
|
1230
|
+
FieldType.HTTP,
|
|
1231
|
+
FieldType.QUERY_PARAM_READER,
|
|
1232
|
+
FieldType.ALPHA_HIDDEN
|
|
1233
|
+
];
|
|
1203
1234
|
|
|
1204
1235
|
// ../commons/src/events/FieldValue.ts
|
|
1205
1236
|
var z12 = __toESM(require("zod/v4"));
|
|
@@ -1326,7 +1357,7 @@ function plainDateToLocalDate(date) {
|
|
|
1326
1357
|
// ../commons/src/events/FieldValue.ts
|
|
1327
1358
|
var TextValue = z12.string();
|
|
1328
1359
|
var HiddenFieldValue = z12.string();
|
|
1329
|
-
var NonEmptyTextValue =
|
|
1360
|
+
var NonEmptyTextValue = z12.string().trim().min(1);
|
|
1330
1361
|
var DateValue = z12.iso.date().describe("Date in the format YYYY-MM-DD");
|
|
1331
1362
|
var AgeValue = z12.object({
|
|
1332
1363
|
age: z12.number(),
|
|
@@ -1355,6 +1386,7 @@ var DateRangeFieldValue = z12.object({
|
|
|
1355
1386
|
var EmailValue = z12.email();
|
|
1356
1387
|
var CheckboxFieldValue = z12.boolean();
|
|
1357
1388
|
var NumberFieldValue = z12.number();
|
|
1389
|
+
var SignatureFieldValue = FileFieldValue;
|
|
1358
1390
|
var ButtonFieldValue = z12.number();
|
|
1359
1391
|
var VerificationStatusValue = z12.enum([
|
|
1360
1392
|
"verified",
|
|
@@ -1653,8 +1685,9 @@ var RequestedCorrectionAction = ActionBase.extend(
|
|
|
1653
1685
|
var ApprovedCorrectionAction = ActionBase.extend(
|
|
1654
1686
|
z14.object({
|
|
1655
1687
|
type: z14.literal(ActionType.APPROVE_CORRECTION),
|
|
1656
|
-
requestId: z14.string()
|
|
1688
|
+
requestId: z14.string(),
|
|
1657
1689
|
// TODO move into 'content' property
|
|
1690
|
+
content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
|
|
1658
1691
|
}).shape
|
|
1659
1692
|
);
|
|
1660
1693
|
var RejectedCorrectionAction = ActionBase.extend(
|
|
@@ -1788,6 +1821,7 @@ var RegistrationCreationMetadata = ActionCreationMetadata.extend({
|
|
|
1788
1821
|
)
|
|
1789
1822
|
});
|
|
1790
1823
|
var LegalStatuses = z16.object({
|
|
1824
|
+
[EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
|
|
1791
1825
|
[EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
|
|
1792
1826
|
[EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
|
|
1793
1827
|
});
|
|
@@ -1929,6 +1963,8 @@ var eventMetadataLabelMap = {
|
|
|
1929
1963
|
var EventMetadataDateFieldIdInput = z16.enum([
|
|
1930
1964
|
"createdAt",
|
|
1931
1965
|
"updatedAt",
|
|
1966
|
+
"legalStatuses.NOTIFIED.createdAt",
|
|
1967
|
+
"legalStatuses.NOTIFIED.acceptedAt",
|
|
1932
1968
|
"legalStatuses.DECLARED.createdAt",
|
|
1933
1969
|
"legalStatuses.DECLARED.acceptedAt",
|
|
1934
1970
|
"legalStatuses.REGISTERED.createdAt",
|
|
@@ -1937,6 +1973,8 @@ var EventMetadataDateFieldIdInput = z16.enum([
|
|
|
1937
1973
|
var EventMetadataDateFieldId = z16.enum([
|
|
1938
1974
|
"event.createdAt",
|
|
1939
1975
|
"event.updatedAt",
|
|
1976
|
+
"event.legalStatuses.NOTIFIED.createdAt",
|
|
1977
|
+
"event.legalStatuses.NOTIFIED.acceptedAt",
|
|
1940
1978
|
"event.legalStatuses.DECLARED.createdAt",
|
|
1941
1979
|
"event.legalStatuses.DECLARED.acceptedAt",
|
|
1942
1980
|
"event.legalStatuses.REGISTERED.createdAt",
|
|
@@ -1996,7 +2034,8 @@ var Range = import_v4.z.object({
|
|
|
1996
2034
|
});
|
|
1997
2035
|
var ContainsFlags = import_v4.z.object({
|
|
1998
2036
|
anyOf: import_v4.z.array(Flag).optional(),
|
|
1999
|
-
noneOf: import_v4.z.array(Flag).optional()
|
|
2037
|
+
noneOf: import_v4.z.array(Flag).optional(),
|
|
2038
|
+
allOf: import_v4.z.array(Flag).optional()
|
|
2000
2039
|
}).meta({
|
|
2001
2040
|
id: "ContainsFlags"
|
|
2002
2041
|
});
|
|
@@ -2185,8 +2224,21 @@ var FieldReference = import_v43.default.object({
|
|
|
2185
2224
|
$$field: FieldId.describe("Id of the field to reference"),
|
|
2186
2225
|
$$subfield: import_v43.default.array(import_v43.default.string()).optional().default([]).describe(
|
|
2187
2226
|
'If the FieldValue is an object, subfield can be used to refer to e.g. `["foo", "bar"]` in `{ foo: { bar: 3 } }`'
|
|
2227
|
+
),
|
|
2228
|
+
$$code: import_v43.default.string().optional().describe(
|
|
2229
|
+
"Serialised client-side function body. When present the expression is evaluated rather than dereferenced."
|
|
2230
|
+
)
|
|
2231
|
+
}).describe(
|
|
2232
|
+
"Reference to a field value, with an optional client-side computation applied."
|
|
2233
|
+
);
|
|
2234
|
+
function isCodeToEvaluate(v) {
|
|
2235
|
+
return !!v && typeof v === "object" && "$$code" in v;
|
|
2236
|
+
}
|
|
2237
|
+
var ComputedDefaultValue = import_v43.default.object({
|
|
2238
|
+
$$code: import_v43.default.string().describe(
|
|
2239
|
+
"Serialised client-side function body. Receives (undefined, context) where context includes $now, $online, and system variables."
|
|
2188
2240
|
)
|
|
2189
|
-
}).describe("
|
|
2241
|
+
}).describe("A context-only computation used as a field default value.");
|
|
2190
2242
|
var ValidationConfig = import_v43.default.object({
|
|
2191
2243
|
validator: Conditional.describe(
|
|
2192
2244
|
"Conditional expression that must hold for the field value to be considered valid."
|
|
@@ -2227,7 +2279,7 @@ var BaseField = import_v43.default.object({
|
|
|
2227
2279
|
"Indicates whether the field can be modified during record correction."
|
|
2228
2280
|
),
|
|
2229
2281
|
value: FieldReference.or(import_v43.default.array(FieldReference)).optional().describe(
|
|
2230
|
-
"Reference to the source field or fields. When a value is defined, it is copied from the parent field when changed. If multiple references are provided, the first truthy value is used."
|
|
2282
|
+
"Reference to the source field or fields. When a value is defined, it is copied from the parent field when changed. If multiple references are provided, the first truthy value is used. A FieldReference with $$code computes the value via a custom client-side function."
|
|
2231
2283
|
),
|
|
2232
2284
|
analytics: import_v43.default.boolean().default(false).optional().describe(
|
|
2233
2285
|
"Indicates whether the field is included in analytics. When enabled, its value becomes available in the analytics dashboard."
|
|
@@ -2241,7 +2293,7 @@ var Divider = BaseField.extend({
|
|
|
2241
2293
|
});
|
|
2242
2294
|
var TextField = BaseField.extend({
|
|
2243
2295
|
type: import_v43.default.literal(FieldType.TEXT),
|
|
2244
|
-
defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
|
|
2296
|
+
defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
|
|
2245
2297
|
configuration: import_v43.default.object({
|
|
2246
2298
|
maxLength: import_v43.default.number().optional().describe("Maximum length of the text"),
|
|
2247
2299
|
type: import_v43.default.enum(["text", "password"]).optional(),
|
|
@@ -2254,10 +2306,11 @@ var TextField = BaseField.extend({
|
|
|
2254
2306
|
});
|
|
2255
2307
|
var NumberField = BaseField.extend({
|
|
2256
2308
|
type: import_v43.default.literal(FieldType.NUMBER),
|
|
2257
|
-
defaultValue: NumberFieldValue.optional(),
|
|
2309
|
+
defaultValue: NumberFieldValue.or(ComputedDefaultValue).optional(),
|
|
2258
2310
|
configuration: import_v43.default.object({
|
|
2259
2311
|
min: import_v43.default.number().optional().describe("Minimum value"),
|
|
2260
2312
|
max: import_v43.default.number().optional().describe("Maximum value"),
|
|
2313
|
+
integer: import_v43.default.boolean().optional().describe("When true, only whole numbers are allowed"),
|
|
2261
2314
|
prefix: TranslationConfig.optional(),
|
|
2262
2315
|
postfix: TranslationConfig.optional()
|
|
2263
2316
|
}).optional()
|
|
@@ -2267,7 +2320,7 @@ var NumberField = BaseField.extend({
|
|
|
2267
2320
|
});
|
|
2268
2321
|
var TextAreaField = BaseField.extend({
|
|
2269
2322
|
type: import_v43.default.literal(FieldType.TEXTAREA),
|
|
2270
|
-
defaultValue: NonEmptyTextValue.optional(),
|
|
2323
|
+
defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
|
|
2271
2324
|
configuration: import_v43.default.object({
|
|
2272
2325
|
maxLength: import_v43.default.number().optional().describe("Maximum length of the text"),
|
|
2273
2326
|
rows: import_v43.default.number().optional().describe("Number of visible text lines"),
|
|
@@ -2301,7 +2354,7 @@ var SignatureField = BaseField.extend({
|
|
|
2301
2354
|
signaturePromptLabel: TranslationConfig.describe(
|
|
2302
2355
|
"Title of the signature modal"
|
|
2303
2356
|
),
|
|
2304
|
-
defaultValue:
|
|
2357
|
+
defaultValue: SignatureFieldValue.or(ComputedDefaultValue).optional(),
|
|
2305
2358
|
configuration: import_v43.default.object({
|
|
2306
2359
|
maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
|
|
2307
2360
|
acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
|
|
@@ -2317,14 +2370,14 @@ var EmailField = BaseField.extend({
|
|
|
2317
2370
|
configuration: import_v43.default.object({
|
|
2318
2371
|
maxLength: import_v43.default.number().optional().describe("Maximum length of the text")
|
|
2319
2372
|
}).default({ maxLength: 255 }).optional(),
|
|
2320
|
-
defaultValue: NonEmptyTextValue.optional()
|
|
2373
|
+
defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional()
|
|
2321
2374
|
}).meta({
|
|
2322
2375
|
description: "An email input field",
|
|
2323
2376
|
id: "EmailField"
|
|
2324
2377
|
});
|
|
2325
2378
|
var DateField = BaseField.extend({
|
|
2326
2379
|
type: import_v43.default.literal(FieldType.DATE),
|
|
2327
|
-
defaultValue: SerializedNowDateTime.or(PlainDate).optional().describe("Default date value(yyyy-MM-dd)"),
|
|
2380
|
+
defaultValue: SerializedNowDateTime.or(PlainDate).or(ComputedDefaultValue).optional().describe("Default date value(yyyy-MM-dd)"),
|
|
2328
2381
|
configuration: import_v43.default.object({
|
|
2329
2382
|
notice: TranslationConfig.describe(
|
|
2330
2383
|
"Text to display above the date input"
|
|
@@ -2336,7 +2389,7 @@ var DateField = BaseField.extend({
|
|
|
2336
2389
|
});
|
|
2337
2390
|
var AgeField = BaseField.extend({
|
|
2338
2391
|
type: import_v43.default.literal(FieldType.AGE),
|
|
2339
|
-
defaultValue: NumberFieldValue.optional(),
|
|
2392
|
+
defaultValue: NumberFieldValue.or(ComputedDefaultValue).optional(),
|
|
2340
2393
|
configuration: import_v43.default.object({
|
|
2341
2394
|
asOfDate: FieldReference,
|
|
2342
2395
|
prefix: TranslationConfig.optional(),
|
|
@@ -2348,7 +2401,7 @@ var AgeField = BaseField.extend({
|
|
|
2348
2401
|
});
|
|
2349
2402
|
var TimeField = BaseField.extend({
|
|
2350
2403
|
type: import_v43.default.literal(FieldType.TIME),
|
|
2351
|
-
defaultValue: SerializedNowDateTime.or(TimeValue).optional().describe("Default time value (HH-mm)"),
|
|
2404
|
+
defaultValue: SerializedNowDateTime.or(TimeValue).or(ComputedDefaultValue).optional().describe("Default time value (HH-mm)"),
|
|
2352
2405
|
configuration: import_v43.default.object({
|
|
2353
2406
|
use12HourFormat: import_v43.default.boolean().optional().describe("Whether to use 12-hour format"),
|
|
2354
2407
|
notice: TranslationConfig.describe(
|
|
@@ -2361,7 +2414,7 @@ var TimeField = BaseField.extend({
|
|
|
2361
2414
|
});
|
|
2362
2415
|
var DateRangeField = BaseField.extend({
|
|
2363
2416
|
type: import_v43.default.literal(FieldType.DATE_RANGE),
|
|
2364
|
-
defaultValue: DateRangeFieldValue.optional(),
|
|
2417
|
+
defaultValue: DateRangeFieldValue.or(ComputedDefaultValue).optional(),
|
|
2365
2418
|
configuration: import_v43.default.object({
|
|
2366
2419
|
notice: TranslationConfig.describe(
|
|
2367
2420
|
"Text to display above the date input"
|
|
@@ -2440,7 +2493,7 @@ var PageHeader = BaseField.extend({
|
|
|
2440
2493
|
});
|
|
2441
2494
|
var File = BaseField.extend({
|
|
2442
2495
|
type: import_v43.default.literal(FieldType.FILE),
|
|
2443
|
-
defaultValue: FileFieldValue.optional(),
|
|
2496
|
+
defaultValue: FileFieldValue.or(ComputedDefaultValue).optional(),
|
|
2444
2497
|
configuration: import_v43.default.object({
|
|
2445
2498
|
maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
|
|
2446
2499
|
acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
|
|
@@ -2467,7 +2520,7 @@ var SelectOption = import_v43.default.object({
|
|
|
2467
2520
|
});
|
|
2468
2521
|
var NumberWithUnitField = BaseField.extend({
|
|
2469
2522
|
type: import_v43.default.literal(FieldType.NUMBER_WITH_UNIT),
|
|
2470
|
-
defaultValue: NumberWithUnitFieldValue.optional(),
|
|
2523
|
+
defaultValue: NumberWithUnitFieldValue.or(ComputedDefaultValue).optional(),
|
|
2471
2524
|
options: import_v43.default.array(SelectOption).describe("A list of options for the unit select"),
|
|
2472
2525
|
configuration: import_v43.default.object({
|
|
2473
2526
|
min: import_v43.default.number().optional().describe("Minimum value of the number field"),
|
|
@@ -2482,7 +2535,7 @@ var NumberWithUnitField = BaseField.extend({
|
|
|
2482
2535
|
});
|
|
2483
2536
|
var RadioGroup = BaseField.extend({
|
|
2484
2537
|
type: import_v43.default.literal(FieldType.RADIO_GROUP),
|
|
2485
|
-
defaultValue: TextValue.optional(),
|
|
2538
|
+
defaultValue: TextValue.or(ComputedDefaultValue).optional(),
|
|
2486
2539
|
options: import_v43.default.array(SelectOption).describe("A list of options"),
|
|
2487
2540
|
configuration: import_v43.default.object({
|
|
2488
2541
|
styles: import_v43.default.object({
|
|
@@ -2507,7 +2560,7 @@ var BulletList = BaseField.extend({
|
|
|
2507
2560
|
});
|
|
2508
2561
|
var Select = BaseField.extend({
|
|
2509
2562
|
type: import_v43.default.literal(FieldType.SELECT),
|
|
2510
|
-
defaultValue: TextValue.optional(),
|
|
2563
|
+
defaultValue: TextValue.or(ComputedDefaultValue).optional(),
|
|
2511
2564
|
options: import_v43.default.array(SelectOption).describe("A list of options"),
|
|
2512
2565
|
noOptionsMessage: TranslationConfig.optional().describe(
|
|
2513
2566
|
`
|
|
@@ -2529,7 +2582,7 @@ var SelectDateRangeOption = import_v43.default.object({
|
|
|
2529
2582
|
});
|
|
2530
2583
|
var SelectDateRangeField = BaseField.extend({
|
|
2531
2584
|
type: import_v43.default.literal(FieldType.SELECT_DATE_RANGE),
|
|
2532
|
-
defaultValue: SelectDateRangeValue.optional(),
|
|
2585
|
+
defaultValue: SelectDateRangeValue.or(ComputedDefaultValue).optional(),
|
|
2533
2586
|
options: import_v43.default.array(SelectDateRangeOption).describe("A list of options")
|
|
2534
2587
|
}).meta({
|
|
2535
2588
|
description: "A date range selection field",
|
|
@@ -2546,7 +2599,7 @@ var NameField = BaseField.extend({
|
|
|
2546
2599
|
firstname: SerializedUserField.or(NonEmptyTextValue).optional(),
|
|
2547
2600
|
middlename: SerializedUserField.or(NonEmptyTextValue).optional(),
|
|
2548
2601
|
surname: SerializedUserField.or(NonEmptyTextValue).optional()
|
|
2549
|
-
}).optional(),
|
|
2602
|
+
}).or(ComputedDefaultValue).optional(),
|
|
2550
2603
|
configuration: import_v43.default.object({
|
|
2551
2604
|
name: NameConfig.default({
|
|
2552
2605
|
firstname: { required: true },
|
|
@@ -2570,14 +2623,14 @@ var NameField = BaseField.extend({
|
|
|
2570
2623
|
id: "NameField"
|
|
2571
2624
|
});
|
|
2572
2625
|
var PhoneField = BaseField.extend({
|
|
2573
|
-
defaultValue: NonEmptyTextValue.optional(),
|
|
2626
|
+
defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
|
|
2574
2627
|
type: import_v43.default.literal(FieldType.PHONE)
|
|
2575
2628
|
}).meta({
|
|
2576
2629
|
description: "A field for entering a phone number",
|
|
2577
2630
|
id: "PhoneField"
|
|
2578
2631
|
});
|
|
2579
2632
|
var IdField = BaseField.extend({
|
|
2580
|
-
defaultValue: NonEmptyTextValue.optional(),
|
|
2633
|
+
defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
|
|
2581
2634
|
type: import_v43.default.literal(FieldType.ID)
|
|
2582
2635
|
}).meta({
|
|
2583
2636
|
description: "A field for entering an ID",
|
|
@@ -2585,14 +2638,14 @@ var IdField = BaseField.extend({
|
|
|
2585
2638
|
});
|
|
2586
2639
|
var Checkbox = BaseField.extend({
|
|
2587
2640
|
type: import_v43.default.literal(FieldType.CHECKBOX),
|
|
2588
|
-
defaultValue: CheckboxFieldValue.default(false)
|
|
2641
|
+
defaultValue: CheckboxFieldValue.or(ComputedDefaultValue).default(false)
|
|
2589
2642
|
}).meta({
|
|
2590
2643
|
description: "A boolean checkbox field",
|
|
2591
2644
|
id: "Checkbox"
|
|
2592
2645
|
});
|
|
2593
2646
|
var Country = BaseField.extend({
|
|
2594
2647
|
type: import_v43.default.literal(FieldType.COUNTRY),
|
|
2595
|
-
defaultValue: NonEmptyTextValue.optional(),
|
|
2648
|
+
defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
|
|
2596
2649
|
optionOverrides: import_v43.default.array(SelectOption.omit({ label: true })).optional().describe(
|
|
2597
2650
|
"Conditionals for specific countries. Countries not listed are always shown and enabled."
|
|
2598
2651
|
)
|
|
@@ -2610,7 +2663,7 @@ var AdministrativeAreas = import_v43.default.enum([
|
|
|
2610
2663
|
]);
|
|
2611
2664
|
var AdministrativeAreaField = BaseField.extend({
|
|
2612
2665
|
type: import_v43.default.literal(FieldType.ADMINISTRATIVE_AREA),
|
|
2613
|
-
defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
|
|
2666
|
+
defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
|
|
2614
2667
|
configuration: import_v43.default.object({
|
|
2615
2668
|
partOf: FieldReference.optional().describe("Parent location"),
|
|
2616
2669
|
type: AdministrativeAreas,
|
|
@@ -2622,7 +2675,7 @@ var AdministrativeAreaField = BaseField.extend({
|
|
|
2622
2675
|
});
|
|
2623
2676
|
var LocationInput = BaseField.extend({
|
|
2624
2677
|
type: import_v43.default.literal(FieldType.LOCATION),
|
|
2625
|
-
defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
|
|
2678
|
+
defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
|
|
2626
2679
|
configuration: import_v43.default.object({
|
|
2627
2680
|
locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
|
|
2628
2681
|
allowedLocations: AllowedLocations
|
|
@@ -2634,7 +2687,7 @@ var LocationInput = BaseField.extend({
|
|
|
2634
2687
|
var FileUploadWithOptions = BaseField.extend({
|
|
2635
2688
|
type: import_v43.default.literal(FieldType.FILE_WITH_OPTIONS),
|
|
2636
2689
|
options: import_v43.default.array(SelectOption).describe("A list of options"),
|
|
2637
|
-
defaultValue: FileFieldWithOptionValue.optional(),
|
|
2690
|
+
defaultValue: FileFieldWithOptionValue.or(ComputedDefaultValue).optional(),
|
|
2638
2691
|
configuration: import_v43.default.object({
|
|
2639
2692
|
maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
|
|
2640
2693
|
maxImageSize: import_v43.default.object({
|
|
@@ -2650,12 +2703,12 @@ var FileUploadWithOptions = BaseField.extend({
|
|
|
2650
2703
|
});
|
|
2651
2704
|
var Facility = BaseField.extend({
|
|
2652
2705
|
type: import_v43.default.literal(FieldType.FACILITY),
|
|
2653
|
-
defaultValue: NonEmptyTextValue.optional(),
|
|
2706
|
+
defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
|
|
2654
2707
|
configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
|
|
2655
2708
|
}).describe("Input field for a facility");
|
|
2656
2709
|
var Office = BaseField.extend({
|
|
2657
2710
|
type: import_v43.default.literal(FieldType.OFFICE),
|
|
2658
|
-
defaultValue: NonEmptyTextValue.optional(),
|
|
2711
|
+
defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
|
|
2659
2712
|
configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
|
|
2660
2713
|
}).describe("Input field for an office");
|
|
2661
2714
|
var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
|
|
@@ -2691,7 +2744,7 @@ var Address = BaseField.extend({
|
|
|
2691
2744
|
).optional(),
|
|
2692
2745
|
allowedLocations: AllowedLocations
|
|
2693
2746
|
}).optional(),
|
|
2694
|
-
defaultValue: DefaultAddressFieldValue.optional()
|
|
2747
|
+
defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
|
|
2695
2748
|
}).meta({
|
|
2696
2749
|
description: "Address input field \u2013 a combination of location and text fields",
|
|
2697
2750
|
id: "Address"
|
|
@@ -2738,7 +2791,7 @@ var ButtonConfiguration = import_v43.default.object({
|
|
|
2738
2791
|
});
|
|
2739
2792
|
var ButtonField = BaseField.extend({
|
|
2740
2793
|
type: import_v43.default.literal(FieldType.BUTTON),
|
|
2741
|
-
defaultValue: ButtonFieldValue.optional(),
|
|
2794
|
+
defaultValue: ButtonFieldValue.or(ComputedDefaultValue).optional(),
|
|
2742
2795
|
configuration: ButtonConfiguration
|
|
2743
2796
|
}).meta({
|
|
2744
2797
|
description: "A generic button that can be used to trigger an action",
|
|
@@ -2766,7 +2819,7 @@ var AlphaPrintButton = BaseField.extend({
|
|
|
2766
2819
|
});
|
|
2767
2820
|
var HttpField = BaseField.extend({
|
|
2768
2821
|
type: import_v43.default.literal(FieldType.HTTP),
|
|
2769
|
-
defaultValue: HttpFieldValue.optional(),
|
|
2822
|
+
defaultValue: HttpFieldValue.or(ComputedDefaultValue).optional(),
|
|
2770
2823
|
configuration: import_v43.default.object({
|
|
2771
2824
|
trigger: FieldReference.optional().describe(
|
|
2772
2825
|
"Reference to the field that triggers the HTTP request when its value changes. If not provided, the HTTP request is triggered once on component mount."
|
|
@@ -2852,7 +2905,7 @@ var LinkButtonField = BaseField.extend({
|
|
|
2852
2905
|
});
|
|
2853
2906
|
var VerificationStatus = BaseField.extend({
|
|
2854
2907
|
type: import_v43.default.literal(FieldType.VERIFICATION_STATUS),
|
|
2855
|
-
defaultValue: VerificationStatusValue.optional(),
|
|
2908
|
+
defaultValue: VerificationStatusValue.or(ComputedDefaultValue).optional(),
|
|
2856
2909
|
configuration: import_v43.default.object({
|
|
2857
2910
|
status: TranslationConfig.describe("Text to display on the status pill."),
|
|
2858
2911
|
description: TranslationConfig.describe(
|
|
@@ -2874,7 +2927,7 @@ var QueryParamReaderField = BaseField.extend({
|
|
|
2874
2927
|
});
|
|
2875
2928
|
var QrReaderField = BaseField.extend({
|
|
2876
2929
|
type: import_v43.default.literal(FieldType.QR_READER),
|
|
2877
|
-
defaultValue: QrReaderFieldValue.optional(),
|
|
2930
|
+
defaultValue: QrReaderFieldValue.or(ComputedDefaultValue).optional(),
|
|
2878
2931
|
configuration: import_v43.default.object({
|
|
2879
2932
|
validator: import_v43.default.any().meta({
|
|
2880
2933
|
description: "JSON Schema to validate the scanned QR code data against before populating the form fields.",
|
|
@@ -2887,7 +2940,7 @@ var QrReaderField = BaseField.extend({
|
|
|
2887
2940
|
});
|
|
2888
2941
|
var IdReaderField = BaseField.extend({
|
|
2889
2942
|
type: import_v43.default.literal(FieldType.ID_READER),
|
|
2890
|
-
defaultValue: IdReaderFieldValue.optional(),
|
|
2943
|
+
defaultValue: IdReaderFieldValue.or(ComputedDefaultValue).optional(),
|
|
2891
2944
|
methods: import_v43.default.array(
|
|
2892
2945
|
import_v43.default.union([QrReaderField, LinkButtonField]).describe("Methods for reading an ID")
|
|
2893
2946
|
)
|
|
@@ -3172,6 +3225,9 @@ var ActionConfigBase = z24.object({
|
|
|
3172
3225
|
var DeclarationActionBase = ActionConfigBase.extend({
|
|
3173
3226
|
deduplication: DeduplicationConfig.optional()
|
|
3174
3227
|
});
|
|
3228
|
+
var actionConfirmationForm = z24.array(FieldConfig).optional().describe(
|
|
3229
|
+
"Fields rendered on the action confirmation dialog. Submitted values are stored in the action annotation and shown in the audit history."
|
|
3230
|
+
);
|
|
3175
3231
|
var ReadActionConfig = ActionConfigBase.extend(
|
|
3176
3232
|
z24.object({
|
|
3177
3233
|
type: z24.literal(ActionType.READ),
|
|
@@ -3181,12 +3237,19 @@ var ReadActionConfig = ActionConfigBase.extend(
|
|
|
3181
3237
|
conditionals: z24.never().optional().describe("Read-action can not be disabled or hidden with conditionals.")
|
|
3182
3238
|
}).shape
|
|
3183
3239
|
);
|
|
3240
|
+
var NotifyConfig = ActionConfigBase.extend(
|
|
3241
|
+
z24.object({
|
|
3242
|
+
type: z24.literal(ActionType.NOTIFY),
|
|
3243
|
+
form: actionConfirmationForm
|
|
3244
|
+
}).shape
|
|
3245
|
+
);
|
|
3184
3246
|
var DeclareConfig = DeclarationActionBase.extend(
|
|
3185
3247
|
z24.object({
|
|
3186
3248
|
type: z24.literal(ActionType.DECLARE),
|
|
3187
3249
|
review: DeclarationReviewConfig.describe(
|
|
3188
3250
|
"Configuration of the review page fields."
|
|
3189
3251
|
),
|
|
3252
|
+
form: actionConfirmationForm,
|
|
3190
3253
|
dialogCopy: z24.object({
|
|
3191
3254
|
notify: TranslationConfig.describe(
|
|
3192
3255
|
"Confirmation text for the notify action"
|
|
@@ -3202,7 +3265,8 @@ var DeclareConfig = DeclarationActionBase.extend(
|
|
|
3202
3265
|
);
|
|
3203
3266
|
var ArchiveConfig = ActionConfigBase.extend(
|
|
3204
3267
|
z24.object({
|
|
3205
|
-
type: z24.literal(ActionType.ARCHIVE)
|
|
3268
|
+
type: z24.literal(ActionType.ARCHIVE),
|
|
3269
|
+
form: actionConfirmationForm
|
|
3206
3270
|
}).shape
|
|
3207
3271
|
);
|
|
3208
3272
|
var EditActionConfig = ActionConfigBase.extend(
|
|
@@ -3223,12 +3287,14 @@ var EditActionConfig = ActionConfigBase.extend(
|
|
|
3223
3287
|
);
|
|
3224
3288
|
var RejectConfig = ActionConfigBase.extend(
|
|
3225
3289
|
z24.object({
|
|
3226
|
-
type: z24.literal(ActionType.REJECT)
|
|
3290
|
+
type: z24.literal(ActionType.REJECT),
|
|
3291
|
+
form: actionConfirmationForm
|
|
3227
3292
|
}).shape
|
|
3228
3293
|
);
|
|
3229
3294
|
var RegisterConfig = DeclarationActionBase.extend(
|
|
3230
3295
|
z24.object({
|
|
3231
|
-
type: z24.literal(ActionType.REGISTER)
|
|
3296
|
+
type: z24.literal(ActionType.REGISTER),
|
|
3297
|
+
form: actionConfirmationForm
|
|
3232
3298
|
}).shape
|
|
3233
3299
|
);
|
|
3234
3300
|
var PrintCertificateActionConfig = ActionConfigBase.extend(
|
|
@@ -3265,9 +3331,13 @@ var ActionConfig = z24.discriminatedUnion("type", [
|
|
|
3265
3331
|
id: "ReadActionConfig",
|
|
3266
3332
|
description: "Configuration for the read action \u2014 defines the record-tab content displayed on the event overview page."
|
|
3267
3333
|
}),
|
|
3334
|
+
NotifyConfig.meta({
|
|
3335
|
+
id: "NotifyActionConfig",
|
|
3336
|
+
description: "Configuration for the notify action. When present, NOTIFY uses this config independently from DECLARE. When absent, NOTIFY falls back to the DeclareActionConfig."
|
|
3337
|
+
}),
|
|
3268
3338
|
DeclareConfig.meta({
|
|
3269
3339
|
id: "DeclareActionConfig",
|
|
3270
|
-
description: "Configuration for the declare action. Includes review-page fields.
|
|
3340
|
+
description: "Configuration for the declare action. Includes review-page fields. NOTIFY falls back to this config when no dedicated NotifyActionConfig is provided."
|
|
3271
3341
|
}),
|
|
3272
3342
|
RejectConfig.meta({
|
|
3273
3343
|
id: "RejectActionConfig",
|
|
@@ -3446,6 +3516,9 @@ var BaseField3 = z28.object({
|
|
|
3446
3516
|
),
|
|
3447
3517
|
validations: z28.array(ValidationConfig).optional().describe(
|
|
3448
3518
|
`Option for overriding the field validations specifically for advanced search form.`
|
|
3519
|
+
),
|
|
3520
|
+
allowedLocations: JurisdictionReference.optional().describe(
|
|
3521
|
+
`Override the allowedLocations for a location field in advanced search. Use this when the declaration form's allowedLocations references a scope (e.g. record.create) that search-only users don't have \u2014 specify record.search scope instead.`
|
|
3449
3522
|
)
|
|
3450
3523
|
});
|
|
3451
3524
|
var SearchQueryParams = z28.object({
|
|
@@ -3520,9 +3593,11 @@ var z30 = __toESM(require("zod/v4"));
|
|
|
3520
3593
|
var z29 = __toESM(require("zod/v4"));
|
|
3521
3594
|
function getDynamicNameValue(field3) {
|
|
3522
3595
|
const nameConfiguration = field3.configuration?.name;
|
|
3596
|
+
const firstnameRequired = nameConfiguration?.firstname?.required ?? field3.required;
|
|
3597
|
+
const surnameRequired = nameConfiguration?.surname?.required ?? field3.required;
|
|
3523
3598
|
return z29.object({
|
|
3524
|
-
firstname:
|
|
3525
|
-
surname:
|
|
3599
|
+
firstname: firstnameRequired ? NonEmptyTextValue : TextValue,
|
|
3600
|
+
surname: surnameRequired ? NonEmptyTextValue : TextValue,
|
|
3526
3601
|
middlename: nameConfiguration?.middlename?.required ? NonEmptyTextValue : TextValue.optional()
|
|
3527
3602
|
});
|
|
3528
3603
|
}
|
|
@@ -3869,7 +3944,7 @@ var isHiddenFieldType = (field3) => {
|
|
|
3869
3944
|
return field3.config.type === FieldType.ALPHA_HIDDEN;
|
|
3870
3945
|
};
|
|
3871
3946
|
var isNonInteractiveFieldType = (field3) => {
|
|
3872
|
-
return field3.type === FieldType.DIVIDER || field3.type === FieldType.PAGE_HEADER || field3.type === FieldType.PARAGRAPH || field3.type === FieldType.HEADING || field3.type === FieldType.BULLET_LIST || field3.type === FieldType.DATA || field3.type === FieldType.ALPHA_PRINT_BUTTON || field3.type === FieldType.
|
|
3947
|
+
return field3.type === FieldType.DIVIDER || field3.type === FieldType.PAGE_HEADER || field3.type === FieldType.PARAGRAPH || field3.type === FieldType.HEADING || field3.type === FieldType.BULLET_LIST || field3.type === FieldType.DATA || field3.type === FieldType.ALPHA_PRINT_BUTTON || field3.type === FieldType.LINK_BUTTON || field3.type === FieldType.LOADER;
|
|
3873
3948
|
};
|
|
3874
3949
|
|
|
3875
3950
|
// ../commons/src/conditionals/validate.ts
|
|
@@ -3905,7 +3980,37 @@ function resolveDataPath(rootData, dataPath, instancePath) {
|
|
|
3905
3980
|
}
|
|
3906
3981
|
return current;
|
|
3907
3982
|
}
|
|
3983
|
+
function todayISO() {
|
|
3984
|
+
return (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
|
|
3985
|
+
}
|
|
3986
|
+
var compiledFunctionCache = /* @__PURE__ */ new Map();
|
|
3987
|
+
function compileClientFunction(code) {
|
|
3988
|
+
let fn = compiledFunctionCache.get(code);
|
|
3989
|
+
if (!fn) {
|
|
3990
|
+
fn = new Function(`return (${code})`)();
|
|
3991
|
+
compiledFunctionCache.set(code, fn);
|
|
3992
|
+
}
|
|
3993
|
+
return fn;
|
|
3994
|
+
}
|
|
3908
3995
|
(0, import_ajv_formats.default)(ajv);
|
|
3996
|
+
function buildClientFunctionContext(input) {
|
|
3997
|
+
return {
|
|
3998
|
+
$form: input.form,
|
|
3999
|
+
$now: todayISO(),
|
|
4000
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
4001
|
+
$online: isOnline(),
|
|
4002
|
+
$user: input.validatorContext?.user,
|
|
4003
|
+
$event: input.validatorContext?.event,
|
|
4004
|
+
$leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
|
|
4005
|
+
user: input.systemVariables?.user,
|
|
4006
|
+
$window: input.systemVariables?.$window,
|
|
4007
|
+
locations: input.locations,
|
|
4008
|
+
adminLevelIds: input.adminLevelIds
|
|
4009
|
+
};
|
|
4010
|
+
}
|
|
4011
|
+
function runClientFunction(code, data, context) {
|
|
4012
|
+
return compileClientFunction(code)(data, context);
|
|
4013
|
+
}
|
|
3909
4014
|
ajv.addKeyword({
|
|
3910
4015
|
keyword: "daysFromDate",
|
|
3911
4016
|
type: "string",
|
|
@@ -3950,7 +4055,7 @@ ajv.addKeyword({
|
|
|
3950
4055
|
$data: true,
|
|
3951
4056
|
errors: true,
|
|
3952
4057
|
// @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
|
|
3953
|
-
validate(
|
|
4058
|
+
validate(_schema, data, _2, dataContext) {
|
|
3954
4059
|
const locationIdInput = data;
|
|
3955
4060
|
const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
|
|
3956
4061
|
return locations.some((location) => location.id === locationIdInput);
|
|
@@ -3981,6 +4086,23 @@ function isAgeValue(value) {
|
|
|
3981
4086
|
function mergeWithBaseFormState(values, context) {
|
|
3982
4087
|
return { ...context.baseFormState, ...values };
|
|
3983
4088
|
}
|
|
4089
|
+
ajv.addKeyword({
|
|
4090
|
+
keyword: "customClientValidator",
|
|
4091
|
+
schemaType: "object",
|
|
4092
|
+
errors: true,
|
|
4093
|
+
// @ts-expect-error -- AJV's public types don't expose `rootData`. All
|
|
4094
|
+
// `validate()` callers build root data via `buildClientFunctionContext`,
|
|
4095
|
+
// so the cast holds.
|
|
4096
|
+
validate(schema, data, _2, dataContext) {
|
|
4097
|
+
return Boolean(
|
|
4098
|
+
runClientFunction(
|
|
4099
|
+
schema.code,
|
|
4100
|
+
data,
|
|
4101
|
+
dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
|
|
4102
|
+
)
|
|
4103
|
+
);
|
|
4104
|
+
}
|
|
4105
|
+
});
|
|
3984
4106
|
function validate(schema, data) {
|
|
3985
4107
|
const validator = ajv.getSchema(schema.$id) || ajv.compile(schema);
|
|
3986
4108
|
if ("$form" in data) {
|
|
@@ -4017,17 +4139,14 @@ function isOnline() {
|
|
|
4017
4139
|
}
|
|
4018
4140
|
return true;
|
|
4019
4141
|
}
|
|
4020
|
-
function isConditionMet(conditional, values, context
|
|
4021
|
-
return validate(
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
$status: eventIndex?.status,
|
|
4029
|
-
$event: context.event
|
|
4030
|
-
});
|
|
4142
|
+
function isConditionMet(conditional, values, context) {
|
|
4143
|
+
return validate(
|
|
4144
|
+
conditional,
|
|
4145
|
+
buildClientFunctionContext({
|
|
4146
|
+
form: mergeWithBaseFormState(values, context),
|
|
4147
|
+
validatorContext: context
|
|
4148
|
+
})
|
|
4149
|
+
);
|
|
4031
4150
|
}
|
|
4032
4151
|
function getConditionalActionsForField(field3, values) {
|
|
4033
4152
|
if (!field3.conditionals) {
|
|
@@ -4035,9 +4154,9 @@ function getConditionalActionsForField(field3, values) {
|
|
|
4035
4154
|
}
|
|
4036
4155
|
return field3.conditionals.filter((conditional) => validate(conditional.conditional, values)).map((conditional) => conditional.type);
|
|
4037
4156
|
}
|
|
4038
|
-
function areConditionsMet(conditions, values, context,
|
|
4157
|
+
function areConditionsMet(conditions, values, context, _event) {
|
|
4039
4158
|
return conditions.every(
|
|
4040
|
-
(condition) => isConditionMet(condition.conditional, values, context
|
|
4159
|
+
(condition) => isConditionMet(condition.conditional, values, context)
|
|
4041
4160
|
);
|
|
4042
4161
|
}
|
|
4043
4162
|
function isFieldConditionMet(field3, form, conditionalType, context) {
|
|
@@ -4047,14 +4166,13 @@ function isFieldConditionMet(field3, form, conditionalType, context) {
|
|
|
4047
4166
|
if (!hasRule) {
|
|
4048
4167
|
return true;
|
|
4049
4168
|
}
|
|
4050
|
-
const validConditionals = getConditionalActionsForField(
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
});
|
|
4169
|
+
const validConditionals = getConditionalActionsForField(
|
|
4170
|
+
field3,
|
|
4171
|
+
buildClientFunctionContext({
|
|
4172
|
+
form: mergeWithBaseFormState(form, context),
|
|
4173
|
+
validatorContext: context
|
|
4174
|
+
})
|
|
4175
|
+
);
|
|
4058
4176
|
return validConditionals.includes(conditionalType);
|
|
4059
4177
|
}
|
|
4060
4178
|
function isFieldVisible(field3, form, context) {
|
|
@@ -4080,7 +4198,14 @@ function isActionConditionMet(actionConfig, event2, context, conditionalType) {
|
|
|
4080
4198
|
if (!rule) {
|
|
4081
4199
|
return true;
|
|
4082
4200
|
}
|
|
4083
|
-
return
|
|
4201
|
+
return validate(rule.conditional, {
|
|
4202
|
+
...buildClientFunctionContext({
|
|
4203
|
+
form: mergeWithBaseFormState(event2.declaration, context),
|
|
4204
|
+
validatorContext: context
|
|
4205
|
+
}),
|
|
4206
|
+
$flags: event2.flags,
|
|
4207
|
+
$status: event2.status
|
|
4208
|
+
});
|
|
4084
4209
|
}
|
|
4085
4210
|
function isActionEnabled(actionConfig, event2, context) {
|
|
4086
4211
|
return isActionConditionMet(
|
|
@@ -4239,19 +4364,10 @@ function runFieldValidations({
|
|
|
4239
4364
|
if (!isFieldVisible(field3.config, form, context)) {
|
|
4240
4365
|
return [];
|
|
4241
4366
|
}
|
|
4242
|
-
const conditionalParameters = {
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
* In real use cases, there can be hundreds of thousands of locations.
|
|
4247
|
-
* Make sure that the context contains only the locations that are needed for validation.
|
|
4248
|
-
* E.g. if the user is a leaf admin, only the leaf locations under their admin structure are needed.
|
|
4249
|
-
* Loading few megabytes of locations to memory just for validation is not efficient and will choke the application.
|
|
4250
|
-
*/
|
|
4251
|
-
$leafAdminStructureLocationIds: context.leafAdminStructureLocationIds ?? [],
|
|
4252
|
-
$online: isOnline(),
|
|
4253
|
-
$user: context.user
|
|
4254
|
-
};
|
|
4367
|
+
const conditionalParameters = buildClientFunctionContext({
|
|
4368
|
+
form: mergeWithBaseFormState(form, context),
|
|
4369
|
+
validatorContext: context
|
|
4370
|
+
});
|
|
4255
4371
|
if (isFieldGroupFieldType(field3)) {
|
|
4256
4372
|
const subfieldErrors = buildFormState(
|
|
4257
4373
|
field3.config.fields,
|
|
@@ -4390,13 +4506,13 @@ function getActionConfig({
|
|
|
4390
4506
|
actionType,
|
|
4391
4507
|
customActionType
|
|
4392
4508
|
}) {
|
|
4509
|
+
if (actionType === ActionType.NOTIFY) {
|
|
4510
|
+
return eventConfiguration.actions.find((a) => a.type === ActionType.NOTIFY) ?? eventConfiguration.actions.find((a) => a.type === ActionType.DECLARE);
|
|
4511
|
+
}
|
|
4393
4512
|
return eventConfiguration.actions.find((a) => {
|
|
4394
4513
|
if (a.type === ActionType.CUSTOM && customActionType) {
|
|
4395
4514
|
return a.customActionType === customActionType;
|
|
4396
4515
|
}
|
|
4397
|
-
if (actionType === ActionType.NOTIFY) {
|
|
4398
|
-
return a.type === ActionType.DECLARE;
|
|
4399
|
-
}
|
|
4400
4516
|
if (actionType === ActionType.APPROVE_CORRECTION || actionType === ActionType.REJECT_CORRECTION) {
|
|
4401
4517
|
return a.type === ActionType.REQUEST_CORRECTION;
|
|
4402
4518
|
}
|
|
@@ -4409,7 +4525,19 @@ function getCustomActionFields(eventConfiguration, customActionType) {
|
|
|
4409
4525
|
customActionType,
|
|
4410
4526
|
actionType: ActionType.CUSTOM
|
|
4411
4527
|
});
|
|
4412
|
-
if (!actionConfig ||
|
|
4528
|
+
if (!actionConfig || actionConfig.type !== ActionType.CUSTOM) {
|
|
4529
|
+
return [];
|
|
4530
|
+
}
|
|
4531
|
+
return actionConfig.form;
|
|
4532
|
+
}
|
|
4533
|
+
function getActionFormFields(eventConfiguration, actionType, customActionType) {
|
|
4534
|
+
const actionConfig = eventConfiguration.actions.find((a) => {
|
|
4535
|
+
if (a.type === ActionType.CUSTOM && customActionType) {
|
|
4536
|
+
return a.customActionType === customActionType;
|
|
4537
|
+
}
|
|
4538
|
+
return a.type === actionType;
|
|
4539
|
+
});
|
|
4540
|
+
if (!actionConfig || !("form" in actionConfig) || actionConfig.form == null) {
|
|
4413
4541
|
return [];
|
|
4414
4542
|
}
|
|
4415
4543
|
return actionConfig.form;
|
|
@@ -4430,13 +4558,9 @@ var getActionAnnotationFields = (actionConfig) => {
|
|
|
4430
4558
|
if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
|
|
4431
4559
|
return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
|
|
4432
4560
|
}
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
if ("review" in actionConfig) {
|
|
4437
|
-
return actionConfig.review.fields;
|
|
4438
|
-
}
|
|
4439
|
-
return [];
|
|
4561
|
+
const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
|
|
4562
|
+
const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
|
|
4563
|
+
return [...reviewFields, ...formFields];
|
|
4440
4564
|
};
|
|
4441
4565
|
function getAllAnnotationFields(config) {
|
|
4442
4566
|
return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
|
|
@@ -4735,19 +4859,32 @@ function getPendingAction(actions) {
|
|
|
4735
4859
|
}
|
|
4736
4860
|
return pendingActions[0];
|
|
4737
4861
|
}
|
|
4738
|
-
function getCompleteActionAnnotation(
|
|
4862
|
+
function getCompleteActionAnnotation(event2, action) {
|
|
4739
4863
|
if (action.originalActionId) {
|
|
4740
4864
|
const originalAction = event2.actions.find(
|
|
4741
4865
|
({ id }) => id === action.originalActionId
|
|
4742
4866
|
);
|
|
4743
4867
|
if (originalAction?.status === ActionStatus.Requested) {
|
|
4744
|
-
return deepMerge(
|
|
4745
|
-
deepMerge(annotation, originalAction.annotation ?? {}),
|
|
4746
|
-
action.annotation ?? {}
|
|
4747
|
-
);
|
|
4868
|
+
return deepMerge(originalAction.annotation ?? {}, action.annotation ?? {});
|
|
4748
4869
|
}
|
|
4749
4870
|
}
|
|
4750
|
-
return
|
|
4871
|
+
return action.annotation ?? {};
|
|
4872
|
+
}
|
|
4873
|
+
function getCompleteActionContent(event2, action) {
|
|
4874
|
+
const currentContent = "content" in action ? action.content : void 0;
|
|
4875
|
+
if (!action.originalActionId) {
|
|
4876
|
+
return currentContent;
|
|
4877
|
+
}
|
|
4878
|
+
const originalAction = event2.actions.find(
|
|
4879
|
+
({ id }) => id === action.originalActionId
|
|
4880
|
+
);
|
|
4881
|
+
if (originalAction && "content" in originalAction && originalAction.content) {
|
|
4882
|
+
return {
|
|
4883
|
+
...originalAction.content,
|
|
4884
|
+
...currentContent ?? {}
|
|
4885
|
+
};
|
|
4886
|
+
}
|
|
4887
|
+
return currentContent;
|
|
4751
4888
|
}
|
|
4752
4889
|
function getCompleteActionDeclaration(declaration, event2, action) {
|
|
4753
4890
|
if (action.originalActionId) {
|
|
@@ -4767,7 +4904,7 @@ function getAcceptedActions(event2) {
|
|
|
4767
4904
|
return event2.actions.filter(isAcceptedAction).map((action) => ({
|
|
4768
4905
|
...action,
|
|
4769
4906
|
declaration: getCompleteActionDeclaration({}, event2, action),
|
|
4770
|
-
annotation: getCompleteActionAnnotation(
|
|
4907
|
+
annotation: getCompleteActionAnnotation(event2, action)
|
|
4771
4908
|
}));
|
|
4772
4909
|
}
|
|
4773
4910
|
var EXCLUDED_ACTIONS = [
|
|
@@ -5405,7 +5542,54 @@ function createFieldConditionals(fieldId) {
|
|
|
5405
5542
|
}
|
|
5406
5543
|
},
|
|
5407
5544
|
required: [fieldId]
|
|
5408
|
-
})
|
|
5545
|
+
}),
|
|
5546
|
+
/**
|
|
5547
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
5548
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
5549
|
+
* available inside the function body — all logic must be self-contained.
|
|
5550
|
+
*
|
|
5551
|
+
* @example
|
|
5552
|
+
* field('nid').customClientValidator((value) => {
|
|
5553
|
+
* // LUHN check — all logic must be inline
|
|
5554
|
+
* const digits = String(value).split('').map(Number)
|
|
5555
|
+
* // ...
|
|
5556
|
+
* return isValid
|
|
5557
|
+
* })
|
|
5558
|
+
*/
|
|
5559
|
+
customClientValidator(validationFn) {
|
|
5560
|
+
const code = validationFn.toString();
|
|
5561
|
+
return defineFormConditional({
|
|
5562
|
+
type: "object",
|
|
5563
|
+
properties: wrapToPath(
|
|
5564
|
+
{ [fieldId]: { customClientValidator: { code } } },
|
|
5565
|
+
this.$$subfield
|
|
5566
|
+
),
|
|
5567
|
+
required: [fieldId]
|
|
5568
|
+
});
|
|
5569
|
+
},
|
|
5570
|
+
/**
|
|
5571
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
5572
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
5573
|
+
* The function receives the referenced field's value as the first argument and
|
|
5574
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
5575
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
5576
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
5577
|
+
*
|
|
5578
|
+
* For computing a default value without referencing a specific field, use
|
|
5579
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
5580
|
+
*
|
|
5581
|
+
* @example
|
|
5582
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
5583
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
5584
|
+
* )
|
|
5585
|
+
*/
|
|
5586
|
+
customClientEvaluation(computationFn) {
|
|
5587
|
+
return {
|
|
5588
|
+
$$code: computationFn.toString(),
|
|
5589
|
+
$$field: fieldId,
|
|
5590
|
+
$$subfield: this.$$subfield
|
|
5591
|
+
};
|
|
5592
|
+
}
|
|
5409
5593
|
};
|
|
5410
5594
|
}
|
|
5411
5595
|
|
|
@@ -6195,7 +6379,8 @@ var RejectCorrectionActionInput = BaseActionInput.extend(
|
|
|
6195
6379
|
var ApproveCorrectionActionInput = BaseActionInput.extend(
|
|
6196
6380
|
z38.object({
|
|
6197
6381
|
requestId: z38.string(),
|
|
6198
|
-
type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
|
6382
|
+
type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION),
|
|
6383
|
+
content: z38.object({ immediateCorrection: z38.boolean().optional() }).optional()
|
|
6199
6384
|
}).shape
|
|
6200
6385
|
);
|
|
6201
6386
|
var ReadActionInput = BaseActionInput.extend(
|
|
@@ -6344,6 +6529,8 @@ var updateActions = ActionTypes.extract([
|
|
|
6344
6529
|
ActionType.ARCHIVE,
|
|
6345
6530
|
ActionType.PRINT_CERTIFICATE,
|
|
6346
6531
|
ActionType.REQUEST_CORRECTION,
|
|
6532
|
+
ActionType.APPROVE_CORRECTION,
|
|
6533
|
+
ActionType.REJECT_CORRECTION,
|
|
6347
6534
|
ActionType.CUSTOM
|
|
6348
6535
|
]);
|
|
6349
6536
|
function getActionUpdateMetadata(actions) {
|
|
@@ -6358,7 +6545,7 @@ function getActionUpdateMetadata(actions) {
|
|
|
6358
6545
|
"createdAtLocation",
|
|
6359
6546
|
"createdByRole"
|
|
6360
6547
|
];
|
|
6361
|
-
return actions.filter(({ type }) => updateActions.safeParse(type).success).
|
|
6548
|
+
return actions.filter(({ type }) => updateActions.safeParse(type).success).reduce(
|
|
6362
6549
|
(_2, action) => {
|
|
6363
6550
|
if (action.originalActionId) {
|
|
6364
6551
|
const originalAction = actions.find(({ id }) => id === action.originalActionId) ?? action;
|
|
@@ -6371,6 +6558,10 @@ function getActionUpdateMetadata(actions) {
|
|
|
6371
6558
|
}
|
|
6372
6559
|
function getLegalStatuses(actions) {
|
|
6373
6560
|
return {
|
|
6561
|
+
[EventStatus.enum.NOTIFIED]: getDeclarationActionCreationMetadata(
|
|
6562
|
+
ActionType.NOTIFY,
|
|
6563
|
+
actions
|
|
6564
|
+
),
|
|
6374
6565
|
[EventStatus.enum.DECLARED]: getDeclarationActionCreationMetadata(
|
|
6375
6566
|
ActionType.DECLARE,
|
|
6376
6567
|
actions
|
|
@@ -6385,9 +6576,6 @@ function getLegalStatuses(actions) {
|
|
|
6385
6576
|
// ../commons/src/events/state/flags.ts
|
|
6386
6577
|
var import_lodash3 = require("lodash");
|
|
6387
6578
|
var import_date_fns3 = require("date-fns");
|
|
6388
|
-
function isEditInProgress(actions) {
|
|
6389
|
-
return actions.at(-1)?.type === ActionType.EDIT;
|
|
6390
|
-
}
|
|
6391
6579
|
function findPendingCorrectionAction(writeActions2) {
|
|
6392
6580
|
let correctionRequestAction;
|
|
6393
6581
|
for (let i = writeActions2.length - 1; i >= 0; i--) {
|
|
@@ -6402,29 +6590,6 @@ function findPendingCorrectionAction(writeActions2) {
|
|
|
6402
6590
|
}
|
|
6403
6591
|
return correctionRequestAction;
|
|
6404
6592
|
}
|
|
6405
|
-
function isCorrectionRequested(actions) {
|
|
6406
|
-
return findPendingCorrectionAction(actions) !== void 0;
|
|
6407
|
-
}
|
|
6408
|
-
function isDeclarationIncomplete(actions) {
|
|
6409
|
-
return getStatusFromActions(actions) === EventStatus.enum.NOTIFIED;
|
|
6410
|
-
}
|
|
6411
|
-
function isRejected(actions) {
|
|
6412
|
-
const resettingActionTypes = [
|
|
6413
|
-
ActionType.NOTIFY,
|
|
6414
|
-
ActionType.DECLARE,
|
|
6415
|
-
ActionType.EDIT,
|
|
6416
|
-
ActionType.REGISTER
|
|
6417
|
-
];
|
|
6418
|
-
return actions.reduce((prev, { type }) => {
|
|
6419
|
-
if (type === ActionType.REJECT) {
|
|
6420
|
-
return true;
|
|
6421
|
-
}
|
|
6422
|
-
if (resettingActionTypes.includes(type)) {
|
|
6423
|
-
return false;
|
|
6424
|
-
}
|
|
6425
|
-
return prev;
|
|
6426
|
-
}, false);
|
|
6427
|
-
}
|
|
6428
6593
|
function isPotentialDuplicate(actions) {
|
|
6429
6594
|
return actions.reduce((prev, { type }) => {
|
|
6430
6595
|
if (type === ActionType.DUPLICATE_DETECTED) {
|
|
@@ -6452,6 +6617,88 @@ function isFlagConditionMet(conditional, form, action) {
|
|
|
6452
6617
|
}
|
|
6453
6618
|
});
|
|
6454
6619
|
}
|
|
6620
|
+
function actionConfigRemovesFlag(action, flagId, actionsUpToAndIncluding, event2, eventConfiguration) {
|
|
6621
|
+
if (!isActionConfigType(action.type)) {
|
|
6622
|
+
return false;
|
|
6623
|
+
}
|
|
6624
|
+
const actionConfig = getActionConfig({
|
|
6625
|
+
eventConfiguration,
|
|
6626
|
+
actionType: action.type,
|
|
6627
|
+
customActionType: "customActionType" in action ? action.customActionType : void 0
|
|
6628
|
+
});
|
|
6629
|
+
const removeOperations = (actionConfig?.flags ?? []).filter(
|
|
6630
|
+
({ id, operation }) => id === flagId && operation === "remove"
|
|
6631
|
+
);
|
|
6632
|
+
if (removeOperations.length === 0) {
|
|
6633
|
+
return false;
|
|
6634
|
+
}
|
|
6635
|
+
const eventUpToThisAction = { ...event2, actions: actionsUpToAndIncluding };
|
|
6636
|
+
const declaration = aggregateActionDeclarations(eventUpToThisAction);
|
|
6637
|
+
const annotation = aggregateActionAnnotations(eventUpToThisAction);
|
|
6638
|
+
const form = { ...declaration, ...annotation };
|
|
6639
|
+
return removeOperations.some(
|
|
6640
|
+
({ conditional }) => conditional ? isFlagConditionMet(conditional, form, action) : true
|
|
6641
|
+
);
|
|
6642
|
+
}
|
|
6643
|
+
var INHERENT_FLAG_RULES = [
|
|
6644
|
+
{
|
|
6645
|
+
flag: InherentFlags.CORRECTION_REQUESTED,
|
|
6646
|
+
setOn: [ActionType.REQUEST_CORRECTION],
|
|
6647
|
+
resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
|
|
6648
|
+
},
|
|
6649
|
+
{
|
|
6650
|
+
// INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
|
|
6651
|
+
// other status-changing action (see getStatusFromActions).
|
|
6652
|
+
flag: InherentFlags.INCOMPLETE,
|
|
6653
|
+
setOn: [ActionType.NOTIFY],
|
|
6654
|
+
resetOn: [
|
|
6655
|
+
ActionType.CREATE,
|
|
6656
|
+
ActionType.DECLARE,
|
|
6657
|
+
ActionType.REGISTER,
|
|
6658
|
+
ActionType.ARCHIVE
|
|
6659
|
+
]
|
|
6660
|
+
},
|
|
6661
|
+
{
|
|
6662
|
+
flag: InherentFlags.REJECTED,
|
|
6663
|
+
setOn: [ActionType.REJECT],
|
|
6664
|
+
resetOn: [
|
|
6665
|
+
ActionType.NOTIFY,
|
|
6666
|
+
ActionType.DECLARE,
|
|
6667
|
+
ActionType.EDIT,
|
|
6668
|
+
ActionType.REGISTER
|
|
6669
|
+
]
|
|
6670
|
+
},
|
|
6671
|
+
{
|
|
6672
|
+
flag: InherentFlags.POTENTIAL_DUPLICATE,
|
|
6673
|
+
setOn: [ActionType.DUPLICATE_DETECTED],
|
|
6674
|
+
resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
|
|
6675
|
+
},
|
|
6676
|
+
{
|
|
6677
|
+
flag: InherentFlags.EDIT_IN_PROGRESS,
|
|
6678
|
+
setOn: [ActionType.EDIT],
|
|
6679
|
+
resetOnAnyOtherAction: true
|
|
6680
|
+
}
|
|
6681
|
+
];
|
|
6682
|
+
function resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration) {
|
|
6683
|
+
return acceptedActions.reduce((present, action, idx) => {
|
|
6684
|
+
if (rule.setOn.includes(action.type)) {
|
|
6685
|
+
return true;
|
|
6686
|
+
}
|
|
6687
|
+
if (rule.resetOnAnyOtherAction || (rule.resetOn ?? []).includes(action.type)) {
|
|
6688
|
+
return false;
|
|
6689
|
+
}
|
|
6690
|
+
if (actionConfigRemovesFlag(
|
|
6691
|
+
action,
|
|
6692
|
+
rule.flag,
|
|
6693
|
+
acceptedActions.slice(0, idx + 1),
|
|
6694
|
+
event2,
|
|
6695
|
+
eventConfiguration
|
|
6696
|
+
)) {
|
|
6697
|
+
return false;
|
|
6698
|
+
}
|
|
6699
|
+
return present;
|
|
6700
|
+
}, false);
|
|
6701
|
+
}
|
|
6455
6702
|
function resolveEventCustomFlags(event2, eventConfiguration) {
|
|
6456
6703
|
const actions = getAcceptedActions(event2).filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
6457
6704
|
return actions.reduce((acc, action, idx) => {
|
|
@@ -6500,33 +6747,19 @@ function getActionStatusFlags(sortedActions) {
|
|
|
6500
6747
|
return flag2;
|
|
6501
6748
|
});
|
|
6502
6749
|
}
|
|
6503
|
-
function getInherentFlags(sortedActions) {
|
|
6750
|
+
function getInherentFlags(sortedActions, event2, eventConfiguration) {
|
|
6504
6751
|
const acceptedActions = sortedActions.filter(
|
|
6505
6752
|
({ status: status2 }) => status2 === ActionStatus.Accepted
|
|
6506
6753
|
);
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
}
|
|
6511
|
-
if (isDeclarationIncomplete(acceptedActions)) {
|
|
6512
|
-
inherentFlags.push(InherentFlags.INCOMPLETE);
|
|
6513
|
-
}
|
|
6514
|
-
if (isRejected(acceptedActions)) {
|
|
6515
|
-
inherentFlags.push(InherentFlags.REJECTED);
|
|
6516
|
-
}
|
|
6517
|
-
if (isPotentialDuplicate(acceptedActions)) {
|
|
6518
|
-
inherentFlags.push(InherentFlags.POTENTIAL_DUPLICATE);
|
|
6519
|
-
}
|
|
6520
|
-
if (isEditInProgress(acceptedActions)) {
|
|
6521
|
-
inherentFlags.push(InherentFlags.EDIT_IN_PROGRESS);
|
|
6522
|
-
}
|
|
6523
|
-
return inherentFlags;
|
|
6754
|
+
return INHERENT_FLAG_RULES.filter(
|
|
6755
|
+
(rule) => resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration)
|
|
6756
|
+
).map(({ flag: flag2 }) => flag2);
|
|
6524
6757
|
}
|
|
6525
6758
|
function getEventFlags(event2, config) {
|
|
6526
6759
|
const sortedActions = event2.actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
6527
6760
|
return [
|
|
6528
6761
|
...getActionStatusFlags(sortedActions),
|
|
6529
|
-
...getInherentFlags(sortedActions),
|
|
6762
|
+
...getInherentFlags(sortedActions, event2, config),
|
|
6530
6763
|
...resolveEventCustomFlags(event2, config)
|
|
6531
6764
|
];
|
|
6532
6765
|
}
|
|
@@ -6763,7 +6996,7 @@ function getActionAnnotation({
|
|
|
6763
6996
|
const action = (0, import_lodash4.findLast)(activeActions, (a) => a.type === actionType);
|
|
6764
6997
|
const actionWithCompleteAnnotation = action && {
|
|
6765
6998
|
...action,
|
|
6766
|
-
annotation: getCompleteActionAnnotation(
|
|
6999
|
+
annotation: getCompleteActionAnnotation(event2, action)
|
|
6767
7000
|
};
|
|
6768
7001
|
const matchingDraft = draft?.action.type === actionType ? draft : void 0;
|
|
6769
7002
|
const sortedActions = (0, import_lodash4.orderBy)(
|
|
@@ -6835,6 +7068,9 @@ function createFieldConfig(fieldId, options) {
|
|
|
6835
7068
|
}
|
|
6836
7069
|
|
|
6837
7070
|
// ../commons/src/events/field.ts
|
|
7071
|
+
function evaluate(computationFn) {
|
|
7072
|
+
return { $$code: computationFn.toString() };
|
|
7073
|
+
}
|
|
6838
7074
|
function field(fieldId, options = {}) {
|
|
6839
7075
|
return {
|
|
6840
7076
|
...createFieldConditionals(fieldId),
|
|
@@ -7528,6 +7764,11 @@ var TENNIS_CLUB_DECLARATION_REVIEW = {
|
|
|
7528
7764
|
id: "signature.upload.modal.title",
|
|
7529
7765
|
defaultMessage: "Draw signature",
|
|
7530
7766
|
description: "Title for the modal to draw signature"
|
|
7767
|
+
},
|
|
7768
|
+
// Zod applies the schema default at parse time, but this fixture bypasses
|
|
7769
|
+
// parsing — GeneratedInputField accesses configuration.maxFileSize directly.
|
|
7770
|
+
configuration: {
|
|
7771
|
+
maxFileSize: 5 * 1024 * 1024
|
|
7531
7772
|
}
|
|
7532
7773
|
}
|
|
7533
7774
|
]
|
|
@@ -8084,6 +8325,20 @@ var tennisClubMembershipEvent = defineConfig({
|
|
|
8084
8325
|
},
|
|
8085
8326
|
review: TENNIS_CLUB_DECLARATION_REVIEW
|
|
8086
8327
|
},
|
|
8328
|
+
{
|
|
8329
|
+
type: ActionType.NOTIFY,
|
|
8330
|
+
label: {
|
|
8331
|
+
defaultMessage: "Notify health worker",
|
|
8332
|
+
description: "This is shown as the action name anywhere the user can trigger the action from",
|
|
8333
|
+
id: "event.tennis-club-membership.action.notify.label"
|
|
8334
|
+
},
|
|
8335
|
+
flags: [
|
|
8336
|
+
{
|
|
8337
|
+
id: "health-worker-notified",
|
|
8338
|
+
operation: "add"
|
|
8339
|
+
}
|
|
8340
|
+
]
|
|
8341
|
+
},
|
|
8087
8342
|
{
|
|
8088
8343
|
type: ActionType.REJECT,
|
|
8089
8344
|
label: {
|
|
@@ -8326,6 +8581,17 @@ var tennisClubMembershipEvent = defineConfig({
|
|
|
8326
8581
|
}
|
|
8327
8582
|
}
|
|
8328
8583
|
],
|
|
8584
|
+
flags: [
|
|
8585
|
+
{
|
|
8586
|
+
id: "health-worker-notified",
|
|
8587
|
+
requiresAction: false,
|
|
8588
|
+
label: {
|
|
8589
|
+
id: "event.tennis-club-membership.flag.health-worker-notified.label",
|
|
8590
|
+
defaultMessage: "Health worker notified",
|
|
8591
|
+
description: "Label for the health-worker-notified flag"
|
|
8592
|
+
}
|
|
8593
|
+
}
|
|
8594
|
+
],
|
|
8329
8595
|
advancedSearch: [
|
|
8330
8596
|
{
|
|
8331
8597
|
title: {
|
|
@@ -10084,7 +10350,7 @@ function matchesJurisdictionFilter(locationIds, filter, user2) {
|
|
|
10084
10350
|
return locationIds.some((id) => id === user2.primaryOfficeId);
|
|
10085
10351
|
}
|
|
10086
10352
|
if (filter === JurisdictionFilter.enum.administrativeArea) {
|
|
10087
|
-
return user2.administrativeAreaId
|
|
10353
|
+
return !user2.administrativeAreaId || locationIds.some((id) => id === user2.administrativeAreaId);
|
|
10088
10354
|
}
|
|
10089
10355
|
return true;
|
|
10090
10356
|
}
|
|
@@ -10111,6 +10377,25 @@ function canAccessEventWithScope(event2, scope, user2, customActionType) {
|
|
|
10111
10377
|
}
|
|
10112
10378
|
if (scopeUsesDeclaredOptions(scope)) {
|
|
10113
10379
|
const { options } = scope;
|
|
10380
|
+
if (options?.notifiedBy === UserFilter.enum.user) {
|
|
10381
|
+
if (event2.legalStatuses?.NOTIFIED?.createdBy !== user2.id) {
|
|
10382
|
+
return false;
|
|
10383
|
+
}
|
|
10384
|
+
}
|
|
10385
|
+
if (options?.notifiedIn === JurisdictionFilter.enum.location && !matchesJurisdictionFilter(
|
|
10386
|
+
event2.legalStatuses?.NOTIFIED?.createdAtLocation,
|
|
10387
|
+
JurisdictionFilter.enum.location,
|
|
10388
|
+
user2
|
|
10389
|
+
)) {
|
|
10390
|
+
return false;
|
|
10391
|
+
}
|
|
10392
|
+
if (options?.notifiedIn === JurisdictionFilter.enum.administrativeArea && !matchesJurisdictionFilter(
|
|
10393
|
+
event2.legalStatuses?.NOTIFIED?.createdAtLocation,
|
|
10394
|
+
JurisdictionFilter.enum.administrativeArea,
|
|
10395
|
+
user2
|
|
10396
|
+
)) {
|
|
10397
|
+
return false;
|
|
10398
|
+
}
|
|
10114
10399
|
if (options?.declaredBy === UserFilter.enum.user) {
|
|
10115
10400
|
if (event2.legalStatuses?.DECLARED?.createdBy !== user2.id) {
|
|
10116
10401
|
return false;
|
|
@@ -10173,7 +10458,7 @@ function canAccessUserWithScope({
|
|
|
10173
10458
|
}
|
|
10174
10459
|
const hasAdministrativeAreaInHierarchy = userToAccess.administrativeHierarchy.some(
|
|
10175
10460
|
(id) => user2.administrativeAreaId === id
|
|
10176
|
-
) || user2.administrativeAreaId
|
|
10461
|
+
) || !user2.administrativeAreaId;
|
|
10177
10462
|
if (opts?.accessLevel === JurisdictionFilter.enum.administrativeArea && !hasAdministrativeAreaInHierarchy) {
|
|
10178
10463
|
return false;
|
|
10179
10464
|
}
|
|
@@ -10479,18 +10764,19 @@ var ACTION_FILTERS = {
|
|
|
10479
10764
|
function filterActionsByFlags(actions, flags) {
|
|
10480
10765
|
return actions.filter((action) => ACTION_FILTERS[action]?.(flags) ?? true);
|
|
10481
10766
|
}
|
|
10767
|
+
var REJECTED_ACTIONS = [
|
|
10768
|
+
ActionType.READ,
|
|
10769
|
+
ActionType.NOTIFY,
|
|
10770
|
+
ActionType.CUSTOM,
|
|
10771
|
+
ActionType.EDIT,
|
|
10772
|
+
ActionType.ARCHIVE
|
|
10773
|
+
];
|
|
10482
10774
|
function getAvailableActionsWithoutFlagFilters(status2, flags) {
|
|
10483
10775
|
if (flags.includes(InherentFlags.EDIT_IN_PROGRESS)) {
|
|
10484
10776
|
return [ActionType.NOTIFY, ActionType.DECLARE, ActionType.REGISTER];
|
|
10485
10777
|
}
|
|
10486
|
-
if (flags.includes(InherentFlags.REJECTED)) {
|
|
10487
|
-
return
|
|
10488
|
-
ActionType.READ,
|
|
10489
|
-
ActionType.NOTIFY,
|
|
10490
|
-
ActionType.CUSTOM,
|
|
10491
|
-
ActionType.EDIT,
|
|
10492
|
-
ActionType.ARCHIVE
|
|
10493
|
-
];
|
|
10778
|
+
if (flags.includes(InherentFlags.REJECTED) && status2 !== EventStatus.enum.ARCHIVED) {
|
|
10779
|
+
return REJECTED_ACTIONS;
|
|
10494
10780
|
}
|
|
10495
10781
|
return AVAILABLE_ACTIONS_BY_EVENT_STATUS[status2];
|
|
10496
10782
|
}
|