@opencrvs/toolkit 2.0.0-rc.9954a7c → 2.0.0-rc.99921a2
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 +5 -4
- package/dist/application-config/index.js +82 -40
- package/dist/cli.js +3186 -4915
- package/dist/commons/api/router.d.ts +700 -22
- package/dist/commons/application-config/index.d.ts +1 -0
- package/dist/commons/conditionals/conditionals.d.ts +354 -10
- package/dist/commons/conditionals/validate.d.ts +51 -2
- package/dist/commons/events/ActionConfig.d.ts +230 -2
- package/dist/commons/events/ActionDocument.d.ts +50 -0
- package/dist/commons/events/ActionInput.d.ts +32 -0
- package/dist/commons/events/ActionType.d.ts +6 -1
- package/dist/commons/events/AdvancedSearchConfig.d.ts +360 -0
- package/dist/commons/events/AuditLog.d.ts +2 -0
- package/dist/commons/events/CountryConfigQueryInput.d.ts +42 -0
- package/dist/commons/events/Draft.d.ts +2 -0
- package/dist/commons/events/EventConfig.d.ts +2 -0
- package/dist/commons/events/EventDocument.d.ts +25 -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 +393 -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 +44 -2
- 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/scopes.d.ts +1 -0
- package/dist/commons/events/state/flags.d.ts +14 -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/test.utils.d.ts +9 -1
- package/dist/commons/events/utils.d.ts +27 -2
- package/dist/conditionals/index.js +60 -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 +600 -158
- 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 +88 -5133
- package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +3 -0
- package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +1 -0
- package/dist/migrations/v2.1/add-explicit-correction-flags.js +234 -0
- package/dist/migrations/v2.1/index.d.ts +6 -0
- package/dist/migrations/v2.1/index.d.ts.map +1 -0
- package/dist/migrations/v2.1/index.js +218 -0
- package/dist/notification/index.js +389 -49
- package/dist/scopes/index.d.ts +100 -8
- package/dist/scopes/index.js +21 -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.99921a2.tgz +0 -0
- package/package.json +15 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/opencrvs-toolkit-2.0.0-rc.9954a7c.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,
|
|
@@ -211,6 +214,7 @@ __export(events_exports, {
|
|
|
211
214
|
TimeValue: () => TimeValue,
|
|
212
215
|
TranslationConfig: () => TranslationConfig,
|
|
213
216
|
UUID: () => UUID,
|
|
217
|
+
UnarchiveActionInput: () => UnarchiveActionInput,
|
|
214
218
|
UnassignActionInput: () => UnassignActionInput,
|
|
215
219
|
UserAuditRecordInput: () => UserAuditRecordInput,
|
|
216
220
|
V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS: () => V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS,
|
|
@@ -246,10 +250,12 @@ __export(events_exports, {
|
|
|
246
250
|
applyDraftToEventIndex: () => applyDraftToEventIndex,
|
|
247
251
|
areCertificateConditionsMet: () => areCertificateConditionsMet,
|
|
248
252
|
areConditionsMet: () => areConditionsMet,
|
|
253
|
+
buildClientFunctionContext: () => buildClientFunctionContext,
|
|
249
254
|
buildFormState: () => buildFormState,
|
|
250
255
|
canAccessEventWithScope: () => canAccessEventWithScope,
|
|
251
256
|
canAccessOtherUserWithScopes: () => canAccessOtherUserWithScopes,
|
|
252
257
|
canAccessUserWithScope: () => canAccessUserWithScope,
|
|
258
|
+
compileClientFunction: () => compileClientFunction,
|
|
253
259
|
compositeFieldTypes: () => compositeFieldTypes,
|
|
254
260
|
createEmptyDraft: () => createEmptyDraft,
|
|
255
261
|
createFieldConditionals: () => createFieldConditionals,
|
|
@@ -270,6 +276,7 @@ __export(events_exports, {
|
|
|
270
276
|
defineWorkqueuesColumns: () => defineWorkqueuesColumns,
|
|
271
277
|
deserializeQuery: () => deserializeQuery,
|
|
272
278
|
errorMessages: () => errorMessages,
|
|
279
|
+
evaluate: () => evaluate,
|
|
273
280
|
event: () => event,
|
|
274
281
|
eventMetadataLabelMap: () => eventMetadataLabelMap,
|
|
275
282
|
eventPayloadGenerator: () => eventPayloadGenerator,
|
|
@@ -282,6 +289,7 @@ __export(events_exports, {
|
|
|
282
289
|
findActiveDraftForEvent: () => findActiveDraftForEvent,
|
|
283
290
|
findAllFields: () => findAllFields,
|
|
284
291
|
findLastAssignmentAction: () => findLastAssignmentAction,
|
|
292
|
+
findPendingCorrectionAction: () => findPendingCorrectionAction,
|
|
285
293
|
findRecordActionPages: () => findRecordActionPages,
|
|
286
294
|
flag: () => flag,
|
|
287
295
|
flattenFieldReference: () => flattenFieldReference,
|
|
@@ -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,
|
|
@@ -467,6 +482,7 @@ var RecordScopeTypeV2 = z2.enum([
|
|
|
467
482
|
"record.edit",
|
|
468
483
|
"record.reject",
|
|
469
484
|
"record.archive",
|
|
485
|
+
"record.unarchive",
|
|
470
486
|
"record.review-duplicates",
|
|
471
487
|
"record.register",
|
|
472
488
|
"record.print-certified-copies",
|
|
@@ -506,11 +522,13 @@ var scopeOptionsPlaceEvent = z2.object({
|
|
|
506
522
|
event: scopeByEvent,
|
|
507
523
|
placeOfEvent: JurisdictionFilter.optional()
|
|
508
524
|
}).describe("Options applicable to all record scopes.");
|
|
509
|
-
var
|
|
525
|
+
var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
|
|
526
|
+
notifiedIn: JurisdictionFilter.optional(),
|
|
527
|
+
notifiedBy: UserFilter.optional(),
|
|
510
528
|
declaredIn: JurisdictionFilter.optional(),
|
|
511
529
|
declaredBy: UserFilter.optional()
|
|
512
530
|
}).describe("Options applicable to actions that may take place after DECLARE");
|
|
513
|
-
var AllRecordScopeOptions =
|
|
531
|
+
var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
|
|
514
532
|
registeredIn: JurisdictionFilter.optional(),
|
|
515
533
|
registeredBy: UserFilter.optional()
|
|
516
534
|
}).describe(
|
|
@@ -548,6 +566,8 @@ var ResolvedScopeOptionsPlaceEvent = z2.object({
|
|
|
548
566
|
"Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
|
|
549
567
|
);
|
|
550
568
|
var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
|
|
569
|
+
notifiedIn: UUID.nullish(),
|
|
570
|
+
notifiedBy: z2.string().optional(),
|
|
551
571
|
declaredIn: UUID.nullish(),
|
|
552
572
|
declaredBy: z2.string().optional()
|
|
553
573
|
}).describe(
|
|
@@ -568,6 +588,7 @@ var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
|
|
|
568
588
|
"record.edit",
|
|
569
589
|
"record.reject",
|
|
570
590
|
"record.archive",
|
|
591
|
+
"record.unarchive",
|
|
571
592
|
"record.review-duplicates",
|
|
572
593
|
"record.register"
|
|
573
594
|
]);
|
|
@@ -593,7 +614,7 @@ var RecordScopeV2 = z2.discriminatedUnion("type", [
|
|
|
593
614
|
}),
|
|
594
615
|
z2.object({
|
|
595
616
|
type: ScopesWithDeclaredOptions,
|
|
596
|
-
options:
|
|
617
|
+
options: scopeOptionsDeclaredOrNotified.optional()
|
|
597
618
|
}),
|
|
598
619
|
z2.object({
|
|
599
620
|
type: ScopesWithFullOptions,
|
|
@@ -698,20 +719,27 @@ var unflattenScope = (input) => {
|
|
|
698
719
|
return { type, options };
|
|
699
720
|
};
|
|
700
721
|
var EncodedScope = z2.string().brand("EncodedScope");
|
|
701
|
-
var
|
|
702
|
-
|
|
722
|
+
var decodedScopeCache = /* @__PURE__ */ new Map();
|
|
723
|
+
var decodeScope = (encodedScope) => {
|
|
724
|
+
if (decodedScopeCache.has(encodedScope)) {
|
|
725
|
+
return decodedScopeCache.get(encodedScope);
|
|
726
|
+
}
|
|
727
|
+
const scope = qs.parse(encodedScope, {
|
|
703
728
|
ignoreQueryPrefix: true,
|
|
704
729
|
comma: true,
|
|
705
730
|
allowDots: true
|
|
706
731
|
});
|
|
707
732
|
const unflattenedScope = unflattenScope(scope);
|
|
708
|
-
|
|
733
|
+
const result = Scope.safeParse(unflattenedScope)?.data;
|
|
734
|
+
decodedScopeCache.set(encodedScope, result);
|
|
735
|
+
return result;
|
|
709
736
|
};
|
|
710
737
|
var DEFAULT_SCOPE_OPTIONS = {
|
|
711
738
|
placeOfEvent: JurisdictionFilter.enum.all,
|
|
712
739
|
accessLevel: JurisdictionFilter.enum.all,
|
|
713
|
-
|
|
714
|
-
declaredIn: JurisdictionFilter.enum.all
|
|
740
|
+
notifiedIn: JurisdictionFilter.enum.all,
|
|
741
|
+
declaredIn: JurisdictionFilter.enum.all,
|
|
742
|
+
registeredIn: JurisdictionFilter.enum.all
|
|
715
743
|
};
|
|
716
744
|
function getAcceptedScopesByType({
|
|
717
745
|
acceptedScopes,
|
|
@@ -747,6 +775,7 @@ var ActionType = {
|
|
|
747
775
|
MARK_AS_DUPLICATE: "MARK_AS_DUPLICATE",
|
|
748
776
|
MARK_AS_NOT_DUPLICATE: "MARK_AS_NOT_DUPLICATE",
|
|
749
777
|
ARCHIVE: "ARCHIVE",
|
|
778
|
+
UNARCHIVE: "UNARCHIVE",
|
|
750
779
|
// Record actions
|
|
751
780
|
PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
|
|
752
781
|
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
|
@@ -766,6 +795,7 @@ var ConfirmableActions = [
|
|
|
766
795
|
ActionType.REGISTER,
|
|
767
796
|
ActionType.REJECT,
|
|
768
797
|
ActionType.ARCHIVE,
|
|
798
|
+
ActionType.UNARCHIVE,
|
|
769
799
|
ActionType.PRINT_CERTIFICATE,
|
|
770
800
|
ActionType.REQUEST_CORRECTION,
|
|
771
801
|
ActionType.APPROVE_CORRECTION,
|
|
@@ -784,6 +814,7 @@ var ActionTypes = z4.enum([
|
|
|
784
814
|
"MARK_AS_DUPLICATE",
|
|
785
815
|
"MARK_AS_NOT_DUPLICATE",
|
|
786
816
|
"ARCHIVE",
|
|
817
|
+
"UNARCHIVE",
|
|
787
818
|
"PRINT_CERTIFICATE",
|
|
788
819
|
"REQUEST_CORRECTION",
|
|
789
820
|
"REJECT_CORRECTION",
|
|
@@ -827,6 +858,7 @@ var WorkqueueActionType = ActionTypes.extract([
|
|
|
827
858
|
ActionType.REJECT,
|
|
828
859
|
ActionType.MARK_AS_DUPLICATE,
|
|
829
860
|
ActionType.ARCHIVE,
|
|
861
|
+
ActionType.UNARCHIVE,
|
|
830
862
|
ActionType.PRINT_CERTIFICATE,
|
|
831
863
|
ActionType.REQUEST_CORRECTION
|
|
832
864
|
]);
|
|
@@ -891,6 +923,7 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
|
|
|
891
923
|
"event.actions.unassign.request",
|
|
892
924
|
"event.actions.read.request",
|
|
893
925
|
"event.actions.archive.request",
|
|
926
|
+
"event.actions.unarchive.request",
|
|
894
927
|
"event.actions.reinstate.request",
|
|
895
928
|
"event.actions.print_certificate.request",
|
|
896
929
|
"event.actions.correction.request.request",
|
|
@@ -1200,6 +1233,11 @@ var FieldTypesToHideInReview = [
|
|
|
1200
1233
|
FieldType.ALPHA_PRINT_BUTTON,
|
|
1201
1234
|
FieldType.ALPHA_HIDDEN
|
|
1202
1235
|
];
|
|
1236
|
+
var HiddenFieldTypes = [
|
|
1237
|
+
FieldType.HTTP,
|
|
1238
|
+
FieldType.QUERY_PARAM_READER,
|
|
1239
|
+
FieldType.ALPHA_HIDDEN
|
|
1240
|
+
];
|
|
1203
1241
|
|
|
1204
1242
|
// ../commons/src/events/FieldValue.ts
|
|
1205
1243
|
var z12 = __toESM(require("zod/v4"));
|
|
@@ -1326,7 +1364,7 @@ function plainDateToLocalDate(date) {
|
|
|
1326
1364
|
// ../commons/src/events/FieldValue.ts
|
|
1327
1365
|
var TextValue = z12.string();
|
|
1328
1366
|
var HiddenFieldValue = z12.string();
|
|
1329
|
-
var NonEmptyTextValue =
|
|
1367
|
+
var NonEmptyTextValue = z12.string().trim().min(1);
|
|
1330
1368
|
var DateValue = z12.iso.date().describe("Date in the format YYYY-MM-DD");
|
|
1331
1369
|
var AgeValue = z12.object({
|
|
1332
1370
|
age: z12.number(),
|
|
@@ -1355,6 +1393,7 @@ var DateRangeFieldValue = z12.object({
|
|
|
1355
1393
|
var EmailValue = z12.email();
|
|
1356
1394
|
var CheckboxFieldValue = z12.boolean();
|
|
1357
1395
|
var NumberFieldValue = z12.number();
|
|
1396
|
+
var SignatureFieldValue = FileFieldValue;
|
|
1358
1397
|
var ButtonFieldValue = z12.number();
|
|
1359
1398
|
var VerificationStatusValue = z12.enum([
|
|
1360
1399
|
"verified",
|
|
@@ -1618,6 +1657,11 @@ var ArchiveAction = ActionBase.extend(
|
|
|
1618
1657
|
content: ReasonContent
|
|
1619
1658
|
}).shape
|
|
1620
1659
|
);
|
|
1660
|
+
var UnarchiveAction = ActionBase.extend(
|
|
1661
|
+
z14.object({
|
|
1662
|
+
type: z14.literal(ActionType.UNARCHIVE)
|
|
1663
|
+
}).shape
|
|
1664
|
+
);
|
|
1621
1665
|
var CreatedAction = ActionBase.extend(
|
|
1622
1666
|
z14.object({
|
|
1623
1667
|
type: z14.literal(ActionType.CREATE)
|
|
@@ -1653,8 +1697,9 @@ var RequestedCorrectionAction = ActionBase.extend(
|
|
|
1653
1697
|
var ApprovedCorrectionAction = ActionBase.extend(
|
|
1654
1698
|
z14.object({
|
|
1655
1699
|
type: z14.literal(ActionType.APPROVE_CORRECTION),
|
|
1656
|
-
requestId: z14.string()
|
|
1700
|
+
requestId: z14.string(),
|
|
1657
1701
|
// TODO move into 'content' property
|
|
1702
|
+
content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
|
|
1658
1703
|
}).shape
|
|
1659
1704
|
);
|
|
1660
1705
|
var RejectedCorrectionAction = ActionBase.extend(
|
|
@@ -1683,6 +1728,7 @@ var ActionDocument = z14.discriminatedUnion("type", [
|
|
|
1683
1728
|
MarkNotDuplicateAction.meta({ id: "MarkNotDuplicateAction" }),
|
|
1684
1729
|
MarkAsDuplicateAction.meta({ id: "MarkAsDuplicateAction" }),
|
|
1685
1730
|
ArchiveAction.meta({ id: "ArchiveAction" }),
|
|
1731
|
+
UnarchiveAction.meta({ id: "UnarchiveAction" }),
|
|
1686
1732
|
NotifiedAction.meta({ id: "NotifiedAction" }),
|
|
1687
1733
|
RegisterAction.meta({ id: "RegisterAction" }),
|
|
1688
1734
|
DeclareAction.meta({ id: "DeclareAction" }),
|
|
@@ -1788,6 +1834,7 @@ var RegistrationCreationMetadata = ActionCreationMetadata.extend({
|
|
|
1788
1834
|
)
|
|
1789
1835
|
});
|
|
1790
1836
|
var LegalStatuses = z16.object({
|
|
1837
|
+
[EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
|
|
1791
1838
|
[EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
|
|
1792
1839
|
[EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
|
|
1793
1840
|
});
|
|
@@ -1929,6 +1976,8 @@ var eventMetadataLabelMap = {
|
|
|
1929
1976
|
var EventMetadataDateFieldIdInput = z16.enum([
|
|
1930
1977
|
"createdAt",
|
|
1931
1978
|
"updatedAt",
|
|
1979
|
+
"legalStatuses.NOTIFIED.createdAt",
|
|
1980
|
+
"legalStatuses.NOTIFIED.acceptedAt",
|
|
1932
1981
|
"legalStatuses.DECLARED.createdAt",
|
|
1933
1982
|
"legalStatuses.DECLARED.acceptedAt",
|
|
1934
1983
|
"legalStatuses.REGISTERED.createdAt",
|
|
@@ -1937,6 +1986,8 @@ var EventMetadataDateFieldIdInput = z16.enum([
|
|
|
1937
1986
|
var EventMetadataDateFieldId = z16.enum([
|
|
1938
1987
|
"event.createdAt",
|
|
1939
1988
|
"event.updatedAt",
|
|
1989
|
+
"event.legalStatuses.NOTIFIED.createdAt",
|
|
1990
|
+
"event.legalStatuses.NOTIFIED.acceptedAt",
|
|
1940
1991
|
"event.legalStatuses.DECLARED.createdAt",
|
|
1941
1992
|
"event.legalStatuses.DECLARED.acceptedAt",
|
|
1942
1993
|
"event.legalStatuses.REGISTERED.createdAt",
|
|
@@ -1996,7 +2047,8 @@ var Range = import_v4.z.object({
|
|
|
1996
2047
|
});
|
|
1997
2048
|
var ContainsFlags = import_v4.z.object({
|
|
1998
2049
|
anyOf: import_v4.z.array(Flag).optional(),
|
|
1999
|
-
noneOf: import_v4.z.array(Flag).optional()
|
|
2050
|
+
noneOf: import_v4.z.array(Flag).optional(),
|
|
2051
|
+
allOf: import_v4.z.array(Flag).optional()
|
|
2000
2052
|
}).meta({
|
|
2001
2053
|
id: "ContainsFlags"
|
|
2002
2054
|
});
|
|
@@ -2185,8 +2237,21 @@ var FieldReference = import_v43.default.object({
|
|
|
2185
2237
|
$$field: FieldId.describe("Id of the field to reference"),
|
|
2186
2238
|
$$subfield: import_v43.default.array(import_v43.default.string()).optional().default([]).describe(
|
|
2187
2239
|
'If the FieldValue is an object, subfield can be used to refer to e.g. `["foo", "bar"]` in `{ foo: { bar: 3 } }`'
|
|
2240
|
+
),
|
|
2241
|
+
$$code: import_v43.default.string().optional().describe(
|
|
2242
|
+
"Serialised client-side function body. When present the expression is evaluated rather than dereferenced."
|
|
2243
|
+
)
|
|
2244
|
+
}).describe(
|
|
2245
|
+
"Reference to a field value, with an optional client-side computation applied."
|
|
2246
|
+
);
|
|
2247
|
+
function isCodeToEvaluate(v) {
|
|
2248
|
+
return !!v && typeof v === "object" && "$$code" in v;
|
|
2249
|
+
}
|
|
2250
|
+
var ComputedDefaultValue = import_v43.default.object({
|
|
2251
|
+
$$code: import_v43.default.string().describe(
|
|
2252
|
+
"Serialised client-side function body. Receives (undefined, context) where context includes $now, $online, and system variables."
|
|
2188
2253
|
)
|
|
2189
|
-
}).describe("
|
|
2254
|
+
}).describe("A context-only computation used as a field default value.");
|
|
2190
2255
|
var ValidationConfig = import_v43.default.object({
|
|
2191
2256
|
validator: Conditional.describe(
|
|
2192
2257
|
"Conditional expression that must hold for the field value to be considered valid."
|
|
@@ -2227,7 +2292,7 @@ var BaseField = import_v43.default.object({
|
|
|
2227
2292
|
"Indicates whether the field can be modified during record correction."
|
|
2228
2293
|
),
|
|
2229
2294
|
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."
|
|
2295
|
+
"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
2296
|
),
|
|
2232
2297
|
analytics: import_v43.default.boolean().default(false).optional().describe(
|
|
2233
2298
|
"Indicates whether the field is included in analytics. When enabled, its value becomes available in the analytics dashboard."
|
|
@@ -2241,7 +2306,7 @@ var Divider = BaseField.extend({
|
|
|
2241
2306
|
});
|
|
2242
2307
|
var TextField = BaseField.extend({
|
|
2243
2308
|
type: import_v43.default.literal(FieldType.TEXT),
|
|
2244
|
-
defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
|
|
2309
|
+
defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
|
|
2245
2310
|
configuration: import_v43.default.object({
|
|
2246
2311
|
maxLength: import_v43.default.number().optional().describe("Maximum length of the text"),
|
|
2247
2312
|
type: import_v43.default.enum(["text", "password"]).optional(),
|
|
@@ -2254,10 +2319,11 @@ var TextField = BaseField.extend({
|
|
|
2254
2319
|
});
|
|
2255
2320
|
var NumberField = BaseField.extend({
|
|
2256
2321
|
type: import_v43.default.literal(FieldType.NUMBER),
|
|
2257
|
-
defaultValue: NumberFieldValue.optional(),
|
|
2322
|
+
defaultValue: NumberFieldValue.or(ComputedDefaultValue).optional(),
|
|
2258
2323
|
configuration: import_v43.default.object({
|
|
2259
2324
|
min: import_v43.default.number().optional().describe("Minimum value"),
|
|
2260
2325
|
max: import_v43.default.number().optional().describe("Maximum value"),
|
|
2326
|
+
integer: import_v43.default.boolean().optional().describe("When true, only whole numbers are allowed"),
|
|
2261
2327
|
prefix: TranslationConfig.optional(),
|
|
2262
2328
|
postfix: TranslationConfig.optional()
|
|
2263
2329
|
}).optional()
|
|
@@ -2267,7 +2333,7 @@ var NumberField = BaseField.extend({
|
|
|
2267
2333
|
});
|
|
2268
2334
|
var TextAreaField = BaseField.extend({
|
|
2269
2335
|
type: import_v43.default.literal(FieldType.TEXTAREA),
|
|
2270
|
-
defaultValue: NonEmptyTextValue.optional(),
|
|
2336
|
+
defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
|
|
2271
2337
|
configuration: import_v43.default.object({
|
|
2272
2338
|
maxLength: import_v43.default.number().optional().describe("Maximum length of the text"),
|
|
2273
2339
|
rows: import_v43.default.number().optional().describe("Number of visible text lines"),
|
|
@@ -2301,7 +2367,7 @@ var SignatureField = BaseField.extend({
|
|
|
2301
2367
|
signaturePromptLabel: TranslationConfig.describe(
|
|
2302
2368
|
"Title of the signature modal"
|
|
2303
2369
|
),
|
|
2304
|
-
defaultValue:
|
|
2370
|
+
defaultValue: SignatureFieldValue.or(ComputedDefaultValue).optional(),
|
|
2305
2371
|
configuration: import_v43.default.object({
|
|
2306
2372
|
maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
|
|
2307
2373
|
acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
|
|
@@ -2317,14 +2383,14 @@ var EmailField = BaseField.extend({
|
|
|
2317
2383
|
configuration: import_v43.default.object({
|
|
2318
2384
|
maxLength: import_v43.default.number().optional().describe("Maximum length of the text")
|
|
2319
2385
|
}).default({ maxLength: 255 }).optional(),
|
|
2320
|
-
defaultValue: NonEmptyTextValue.optional()
|
|
2386
|
+
defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional()
|
|
2321
2387
|
}).meta({
|
|
2322
2388
|
description: "An email input field",
|
|
2323
2389
|
id: "EmailField"
|
|
2324
2390
|
});
|
|
2325
2391
|
var DateField = BaseField.extend({
|
|
2326
2392
|
type: import_v43.default.literal(FieldType.DATE),
|
|
2327
|
-
defaultValue: SerializedNowDateTime.or(PlainDate).optional().describe("Default date value(yyyy-MM-dd)"),
|
|
2393
|
+
defaultValue: SerializedNowDateTime.or(PlainDate).or(ComputedDefaultValue).optional().describe("Default date value(yyyy-MM-dd)"),
|
|
2328
2394
|
configuration: import_v43.default.object({
|
|
2329
2395
|
notice: TranslationConfig.describe(
|
|
2330
2396
|
"Text to display above the date input"
|
|
@@ -2336,7 +2402,7 @@ var DateField = BaseField.extend({
|
|
|
2336
2402
|
});
|
|
2337
2403
|
var AgeField = BaseField.extend({
|
|
2338
2404
|
type: import_v43.default.literal(FieldType.AGE),
|
|
2339
|
-
defaultValue: NumberFieldValue.optional(),
|
|
2405
|
+
defaultValue: NumberFieldValue.or(ComputedDefaultValue).optional(),
|
|
2340
2406
|
configuration: import_v43.default.object({
|
|
2341
2407
|
asOfDate: FieldReference,
|
|
2342
2408
|
prefix: TranslationConfig.optional(),
|
|
@@ -2348,7 +2414,7 @@ var AgeField = BaseField.extend({
|
|
|
2348
2414
|
});
|
|
2349
2415
|
var TimeField = BaseField.extend({
|
|
2350
2416
|
type: import_v43.default.literal(FieldType.TIME),
|
|
2351
|
-
defaultValue: SerializedNowDateTime.or(TimeValue).optional().describe("Default time value (HH-mm)"),
|
|
2417
|
+
defaultValue: SerializedNowDateTime.or(TimeValue).or(ComputedDefaultValue).optional().describe("Default time value (HH-mm)"),
|
|
2352
2418
|
configuration: import_v43.default.object({
|
|
2353
2419
|
use12HourFormat: import_v43.default.boolean().optional().describe("Whether to use 12-hour format"),
|
|
2354
2420
|
notice: TranslationConfig.describe(
|
|
@@ -2361,7 +2427,7 @@ var TimeField = BaseField.extend({
|
|
|
2361
2427
|
});
|
|
2362
2428
|
var DateRangeField = BaseField.extend({
|
|
2363
2429
|
type: import_v43.default.literal(FieldType.DATE_RANGE),
|
|
2364
|
-
defaultValue: DateRangeFieldValue.optional(),
|
|
2430
|
+
defaultValue: DateRangeFieldValue.or(ComputedDefaultValue).optional(),
|
|
2365
2431
|
configuration: import_v43.default.object({
|
|
2366
2432
|
notice: TranslationConfig.describe(
|
|
2367
2433
|
"Text to display above the date input"
|
|
@@ -2440,7 +2506,7 @@ var PageHeader = BaseField.extend({
|
|
|
2440
2506
|
});
|
|
2441
2507
|
var File = BaseField.extend({
|
|
2442
2508
|
type: import_v43.default.literal(FieldType.FILE),
|
|
2443
|
-
defaultValue: FileFieldValue.optional(),
|
|
2509
|
+
defaultValue: FileFieldValue.or(ComputedDefaultValue).optional(),
|
|
2444
2510
|
configuration: import_v43.default.object({
|
|
2445
2511
|
maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
|
|
2446
2512
|
acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
|
|
@@ -2467,7 +2533,7 @@ var SelectOption = import_v43.default.object({
|
|
|
2467
2533
|
});
|
|
2468
2534
|
var NumberWithUnitField = BaseField.extend({
|
|
2469
2535
|
type: import_v43.default.literal(FieldType.NUMBER_WITH_UNIT),
|
|
2470
|
-
defaultValue: NumberWithUnitFieldValue.optional(),
|
|
2536
|
+
defaultValue: NumberWithUnitFieldValue.or(ComputedDefaultValue).optional(),
|
|
2471
2537
|
options: import_v43.default.array(SelectOption).describe("A list of options for the unit select"),
|
|
2472
2538
|
configuration: import_v43.default.object({
|
|
2473
2539
|
min: import_v43.default.number().optional().describe("Minimum value of the number field"),
|
|
@@ -2482,7 +2548,7 @@ var NumberWithUnitField = BaseField.extend({
|
|
|
2482
2548
|
});
|
|
2483
2549
|
var RadioGroup = BaseField.extend({
|
|
2484
2550
|
type: import_v43.default.literal(FieldType.RADIO_GROUP),
|
|
2485
|
-
defaultValue: TextValue.optional(),
|
|
2551
|
+
defaultValue: TextValue.or(ComputedDefaultValue).optional(),
|
|
2486
2552
|
options: import_v43.default.array(SelectOption).describe("A list of options"),
|
|
2487
2553
|
configuration: import_v43.default.object({
|
|
2488
2554
|
styles: import_v43.default.object({
|
|
@@ -2507,7 +2573,7 @@ var BulletList = BaseField.extend({
|
|
|
2507
2573
|
});
|
|
2508
2574
|
var Select = BaseField.extend({
|
|
2509
2575
|
type: import_v43.default.literal(FieldType.SELECT),
|
|
2510
|
-
defaultValue: TextValue.optional(),
|
|
2576
|
+
defaultValue: TextValue.or(ComputedDefaultValue).optional(),
|
|
2511
2577
|
options: import_v43.default.array(SelectOption).describe("A list of options"),
|
|
2512
2578
|
noOptionsMessage: TranslationConfig.optional().describe(
|
|
2513
2579
|
`
|
|
@@ -2529,7 +2595,7 @@ var SelectDateRangeOption = import_v43.default.object({
|
|
|
2529
2595
|
});
|
|
2530
2596
|
var SelectDateRangeField = BaseField.extend({
|
|
2531
2597
|
type: import_v43.default.literal(FieldType.SELECT_DATE_RANGE),
|
|
2532
|
-
defaultValue: SelectDateRangeValue.optional(),
|
|
2598
|
+
defaultValue: SelectDateRangeValue.or(ComputedDefaultValue).optional(),
|
|
2533
2599
|
options: import_v43.default.array(SelectDateRangeOption).describe("A list of options")
|
|
2534
2600
|
}).meta({
|
|
2535
2601
|
description: "A date range selection field",
|
|
@@ -2546,7 +2612,7 @@ var NameField = BaseField.extend({
|
|
|
2546
2612
|
firstname: SerializedUserField.or(NonEmptyTextValue).optional(),
|
|
2547
2613
|
middlename: SerializedUserField.or(NonEmptyTextValue).optional(),
|
|
2548
2614
|
surname: SerializedUserField.or(NonEmptyTextValue).optional()
|
|
2549
|
-
}).optional(),
|
|
2615
|
+
}).or(ComputedDefaultValue).optional(),
|
|
2550
2616
|
configuration: import_v43.default.object({
|
|
2551
2617
|
name: NameConfig.default({
|
|
2552
2618
|
firstname: { required: true },
|
|
@@ -2570,14 +2636,14 @@ var NameField = BaseField.extend({
|
|
|
2570
2636
|
id: "NameField"
|
|
2571
2637
|
});
|
|
2572
2638
|
var PhoneField = BaseField.extend({
|
|
2573
|
-
defaultValue: NonEmptyTextValue.optional(),
|
|
2639
|
+
defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
|
|
2574
2640
|
type: import_v43.default.literal(FieldType.PHONE)
|
|
2575
2641
|
}).meta({
|
|
2576
2642
|
description: "A field for entering a phone number",
|
|
2577
2643
|
id: "PhoneField"
|
|
2578
2644
|
});
|
|
2579
2645
|
var IdField = BaseField.extend({
|
|
2580
|
-
defaultValue: NonEmptyTextValue.optional(),
|
|
2646
|
+
defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
|
|
2581
2647
|
type: import_v43.default.literal(FieldType.ID)
|
|
2582
2648
|
}).meta({
|
|
2583
2649
|
description: "A field for entering an ID",
|
|
@@ -2585,14 +2651,14 @@ var IdField = BaseField.extend({
|
|
|
2585
2651
|
});
|
|
2586
2652
|
var Checkbox = BaseField.extend({
|
|
2587
2653
|
type: import_v43.default.literal(FieldType.CHECKBOX),
|
|
2588
|
-
defaultValue: CheckboxFieldValue.default(false)
|
|
2654
|
+
defaultValue: CheckboxFieldValue.or(ComputedDefaultValue).default(false)
|
|
2589
2655
|
}).meta({
|
|
2590
2656
|
description: "A boolean checkbox field",
|
|
2591
2657
|
id: "Checkbox"
|
|
2592
2658
|
});
|
|
2593
2659
|
var Country = BaseField.extend({
|
|
2594
2660
|
type: import_v43.default.literal(FieldType.COUNTRY),
|
|
2595
|
-
defaultValue: NonEmptyTextValue.optional(),
|
|
2661
|
+
defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
|
|
2596
2662
|
optionOverrides: import_v43.default.array(SelectOption.omit({ label: true })).optional().describe(
|
|
2597
2663
|
"Conditionals for specific countries. Countries not listed are always shown and enabled."
|
|
2598
2664
|
)
|
|
@@ -2610,7 +2676,7 @@ var AdministrativeAreas = import_v43.default.enum([
|
|
|
2610
2676
|
]);
|
|
2611
2677
|
var AdministrativeAreaField = BaseField.extend({
|
|
2612
2678
|
type: import_v43.default.literal(FieldType.ADMINISTRATIVE_AREA),
|
|
2613
|
-
defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
|
|
2679
|
+
defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
|
|
2614
2680
|
configuration: import_v43.default.object({
|
|
2615
2681
|
partOf: FieldReference.optional().describe("Parent location"),
|
|
2616
2682
|
type: AdministrativeAreas,
|
|
@@ -2622,7 +2688,7 @@ var AdministrativeAreaField = BaseField.extend({
|
|
|
2622
2688
|
});
|
|
2623
2689
|
var LocationInput = BaseField.extend({
|
|
2624
2690
|
type: import_v43.default.literal(FieldType.LOCATION),
|
|
2625
|
-
defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
|
|
2691
|
+
defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
|
|
2626
2692
|
configuration: import_v43.default.object({
|
|
2627
2693
|
locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
|
|
2628
2694
|
allowedLocations: AllowedLocations
|
|
@@ -2634,7 +2700,7 @@ var LocationInput = BaseField.extend({
|
|
|
2634
2700
|
var FileUploadWithOptions = BaseField.extend({
|
|
2635
2701
|
type: import_v43.default.literal(FieldType.FILE_WITH_OPTIONS),
|
|
2636
2702
|
options: import_v43.default.array(SelectOption).describe("A list of options"),
|
|
2637
|
-
defaultValue: FileFieldWithOptionValue.optional(),
|
|
2703
|
+
defaultValue: FileFieldWithOptionValue.or(ComputedDefaultValue).optional(),
|
|
2638
2704
|
configuration: import_v43.default.object({
|
|
2639
2705
|
maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
|
|
2640
2706
|
maxImageSize: import_v43.default.object({
|
|
@@ -2650,12 +2716,12 @@ var FileUploadWithOptions = BaseField.extend({
|
|
|
2650
2716
|
});
|
|
2651
2717
|
var Facility = BaseField.extend({
|
|
2652
2718
|
type: import_v43.default.literal(FieldType.FACILITY),
|
|
2653
|
-
defaultValue: NonEmptyTextValue.optional(),
|
|
2719
|
+
defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
|
|
2654
2720
|
configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
|
|
2655
2721
|
}).describe("Input field for a facility");
|
|
2656
2722
|
var Office = BaseField.extend({
|
|
2657
2723
|
type: import_v43.default.literal(FieldType.OFFICE),
|
|
2658
|
-
defaultValue: NonEmptyTextValue.optional(),
|
|
2724
|
+
defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
|
|
2659
2725
|
configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
|
|
2660
2726
|
}).describe("Input field for an office");
|
|
2661
2727
|
var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
|
|
@@ -2691,7 +2757,7 @@ var Address = BaseField.extend({
|
|
|
2691
2757
|
).optional(),
|
|
2692
2758
|
allowedLocations: AllowedLocations
|
|
2693
2759
|
}).optional(),
|
|
2694
|
-
defaultValue: DefaultAddressFieldValue.optional()
|
|
2760
|
+
defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
|
|
2695
2761
|
}).meta({
|
|
2696
2762
|
description: "Address input field \u2013 a combination of location and text fields",
|
|
2697
2763
|
id: "Address"
|
|
@@ -2738,7 +2804,7 @@ var ButtonConfiguration = import_v43.default.object({
|
|
|
2738
2804
|
});
|
|
2739
2805
|
var ButtonField = BaseField.extend({
|
|
2740
2806
|
type: import_v43.default.literal(FieldType.BUTTON),
|
|
2741
|
-
defaultValue: ButtonFieldValue.optional(),
|
|
2807
|
+
defaultValue: ButtonFieldValue.or(ComputedDefaultValue).optional(),
|
|
2742
2808
|
configuration: ButtonConfiguration
|
|
2743
2809
|
}).meta({
|
|
2744
2810
|
description: "A generic button that can be used to trigger an action",
|
|
@@ -2766,7 +2832,7 @@ var AlphaPrintButton = BaseField.extend({
|
|
|
2766
2832
|
});
|
|
2767
2833
|
var HttpField = BaseField.extend({
|
|
2768
2834
|
type: import_v43.default.literal(FieldType.HTTP),
|
|
2769
|
-
defaultValue: HttpFieldValue.optional(),
|
|
2835
|
+
defaultValue: HttpFieldValue.or(ComputedDefaultValue).optional(),
|
|
2770
2836
|
configuration: import_v43.default.object({
|
|
2771
2837
|
trigger: FieldReference.optional().describe(
|
|
2772
2838
|
"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 +2918,7 @@ var LinkButtonField = BaseField.extend({
|
|
|
2852
2918
|
});
|
|
2853
2919
|
var VerificationStatus = BaseField.extend({
|
|
2854
2920
|
type: import_v43.default.literal(FieldType.VERIFICATION_STATUS),
|
|
2855
|
-
defaultValue: VerificationStatusValue.optional(),
|
|
2921
|
+
defaultValue: VerificationStatusValue.or(ComputedDefaultValue).optional(),
|
|
2856
2922
|
configuration: import_v43.default.object({
|
|
2857
2923
|
status: TranslationConfig.describe("Text to display on the status pill."),
|
|
2858
2924
|
description: TranslationConfig.describe(
|
|
@@ -2874,7 +2940,7 @@ var QueryParamReaderField = BaseField.extend({
|
|
|
2874
2940
|
});
|
|
2875
2941
|
var QrReaderField = BaseField.extend({
|
|
2876
2942
|
type: import_v43.default.literal(FieldType.QR_READER),
|
|
2877
|
-
defaultValue: QrReaderFieldValue.optional(),
|
|
2943
|
+
defaultValue: QrReaderFieldValue.or(ComputedDefaultValue).optional(),
|
|
2878
2944
|
configuration: import_v43.default.object({
|
|
2879
2945
|
validator: import_v43.default.any().meta({
|
|
2880
2946
|
description: "JSON Schema to validate the scanned QR code data against before populating the form fields.",
|
|
@@ -2887,7 +2953,7 @@ var QrReaderField = BaseField.extend({
|
|
|
2887
2953
|
});
|
|
2888
2954
|
var IdReaderField = BaseField.extend({
|
|
2889
2955
|
type: import_v43.default.literal(FieldType.ID_READER),
|
|
2890
|
-
defaultValue: IdReaderFieldValue.optional(),
|
|
2956
|
+
defaultValue: IdReaderFieldValue.or(ComputedDefaultValue).optional(),
|
|
2891
2957
|
methods: import_v43.default.array(
|
|
2892
2958
|
import_v43.default.union([QrReaderField, LinkButtonField]).describe("Methods for reading an ID")
|
|
2893
2959
|
)
|
|
@@ -3181,6 +3247,57 @@ var ReadActionConfig = ActionConfigBase.extend(
|
|
|
3181
3247
|
conditionals: z24.never().optional().describe("Read-action can not be disabled or hidden with conditionals.")
|
|
3182
3248
|
}).shape
|
|
3183
3249
|
);
|
|
3250
|
+
var NotifyConfig = ActionConfigBase.extend(
|
|
3251
|
+
z24.object({
|
|
3252
|
+
type: z24.literal(ActionType.NOTIFY)
|
|
3253
|
+
}).shape
|
|
3254
|
+
);
|
|
3255
|
+
var DuplicateDetectedConfig = ActionConfigBase.extend(
|
|
3256
|
+
z24.object({
|
|
3257
|
+
type: z24.literal(ActionType.DUPLICATE_DETECTED),
|
|
3258
|
+
label: z24.never().optional().describe(
|
|
3259
|
+
"DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no label."
|
|
3260
|
+
),
|
|
3261
|
+
supportingCopy: z24.never().optional(),
|
|
3262
|
+
icon: z24.never().optional().describe(
|
|
3263
|
+
"DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no icon."
|
|
3264
|
+
),
|
|
3265
|
+
conditionals: z24.never().optional().describe(
|
|
3266
|
+
"DUPLICATE_DETECTED is system-generated and never shown as a button, so it cannot be disabled or hidden with conditionals."
|
|
3267
|
+
)
|
|
3268
|
+
}).shape
|
|
3269
|
+
);
|
|
3270
|
+
var MarkAsDuplicateConfig = ActionConfigBase.extend(
|
|
3271
|
+
z24.object({
|
|
3272
|
+
type: z24.literal(ActionType.MARK_AS_DUPLICATE)
|
|
3273
|
+
}).shape
|
|
3274
|
+
);
|
|
3275
|
+
var MarkAsNotDuplicateConfig = ActionConfigBase.extend(
|
|
3276
|
+
z24.object({
|
|
3277
|
+
type: z24.literal(ActionType.MARK_AS_NOT_DUPLICATE)
|
|
3278
|
+
}).shape
|
|
3279
|
+
);
|
|
3280
|
+
var AssignConfig = ActionConfigBase.extend(
|
|
3281
|
+
z24.object({
|
|
3282
|
+
type: z24.literal(ActionType.ASSIGN),
|
|
3283
|
+
flags: z24.never().optional().describe(
|
|
3284
|
+
"ASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
|
|
3285
|
+
)
|
|
3286
|
+
}).shape
|
|
3287
|
+
);
|
|
3288
|
+
var UnassignConfig = ActionConfigBase.extend(
|
|
3289
|
+
z24.object({
|
|
3290
|
+
type: z24.literal(ActionType.UNASSIGN),
|
|
3291
|
+
flags: z24.never().optional().describe(
|
|
3292
|
+
"UNASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
|
|
3293
|
+
)
|
|
3294
|
+
}).shape
|
|
3295
|
+
);
|
|
3296
|
+
var DeleteConfig = ActionConfigBase.extend(
|
|
3297
|
+
z24.object({
|
|
3298
|
+
type: z24.literal(ActionType.DELETE)
|
|
3299
|
+
}).shape
|
|
3300
|
+
);
|
|
3184
3301
|
var DeclareConfig = DeclarationActionBase.extend(
|
|
3185
3302
|
z24.object({
|
|
3186
3303
|
type: z24.literal(ActionType.DECLARE),
|
|
@@ -3205,6 +3322,11 @@ var ArchiveConfig = ActionConfigBase.extend(
|
|
|
3205
3322
|
type: z24.literal(ActionType.ARCHIVE)
|
|
3206
3323
|
}).shape
|
|
3207
3324
|
);
|
|
3325
|
+
var UnarchiveConfig = ActionConfigBase.extend(
|
|
3326
|
+
z24.object({
|
|
3327
|
+
type: z24.literal(ActionType.UNARCHIVE)
|
|
3328
|
+
}).shape
|
|
3329
|
+
);
|
|
3208
3330
|
var EditActionConfig = ActionConfigBase.extend(
|
|
3209
3331
|
z24.object({
|
|
3210
3332
|
type: z24.literal(ActionType.EDIT),
|
|
@@ -3243,7 +3365,17 @@ var RequestCorrectionConfig = ActionConfigBase.extend(
|
|
|
3243
3365
|
correctionForm: ActionFormConfig
|
|
3244
3366
|
}).shape
|
|
3245
3367
|
);
|
|
3246
|
-
var
|
|
3368
|
+
var ApproveCorrectionConfig = ActionConfigBase.extend(
|
|
3369
|
+
z24.object({
|
|
3370
|
+
type: z24.literal(ActionType.APPROVE_CORRECTION)
|
|
3371
|
+
}).shape
|
|
3372
|
+
);
|
|
3373
|
+
var RejectCorrectionConfig = ActionConfigBase.extend(
|
|
3374
|
+
z24.object({
|
|
3375
|
+
type: z24.literal(ActionType.REJECT_CORRECTION)
|
|
3376
|
+
}).shape
|
|
3377
|
+
);
|
|
3378
|
+
var CustomActionConfig = ActionConfigBase.extend(
|
|
3247
3379
|
z24.object({
|
|
3248
3380
|
type: z24.literal(ActionType.CUSTOM),
|
|
3249
3381
|
customActionType: z24.string().describe("Type identifier of the custom action."),
|
|
@@ -3254,7 +3386,7 @@ var CustomActionConfig = ActionConfigBase.merge(
|
|
|
3254
3386
|
auditHistoryLabel: TranslationConfig.describe(
|
|
3255
3387
|
'The label to show in audit history for this action. For example "Approved".'
|
|
3256
3388
|
)
|
|
3257
|
-
})
|
|
3389
|
+
}).shape
|
|
3258
3390
|
);
|
|
3259
3391
|
var ActionConfig = z24.discriminatedUnion("type", [
|
|
3260
3392
|
/*
|
|
@@ -3265,9 +3397,37 @@ var ActionConfig = z24.discriminatedUnion("type", [
|
|
|
3265
3397
|
id: "ReadActionConfig",
|
|
3266
3398
|
description: "Configuration for the read action \u2014 defines the record-tab content displayed on the event overview page."
|
|
3267
3399
|
}),
|
|
3400
|
+
AssignConfig.meta({
|
|
3401
|
+
id: "AssignActionConfig",
|
|
3402
|
+
description: "Configuration for assigning a record to the current user."
|
|
3403
|
+
}),
|
|
3404
|
+
UnassignConfig.meta({
|
|
3405
|
+
id: "UnassignActionConfig",
|
|
3406
|
+
description: "Configuration for unassigning a record from its current assignee."
|
|
3407
|
+
}),
|
|
3408
|
+
DeleteConfig.meta({
|
|
3409
|
+
id: "DeleteActionConfig",
|
|
3410
|
+
description: "Configuration for deleting a draft record."
|
|
3411
|
+
}),
|
|
3412
|
+
NotifyConfig.meta({
|
|
3413
|
+
id: "NotifyActionConfig",
|
|
3414
|
+
description: "Configuration for the notify action. When present, NOTIFY uses this config independently from DECLARE. When absent, NOTIFY falls back to the DeclareActionConfig."
|
|
3415
|
+
}),
|
|
3268
3416
|
DeclareConfig.meta({
|
|
3269
3417
|
id: "DeclareActionConfig",
|
|
3270
|
-
description: "Configuration for the declare action. Includes review-page fields.
|
|
3418
|
+
description: "Configuration for the declare action. Includes review-page fields. NOTIFY falls back to this config when no dedicated NotifyActionConfig is provided."
|
|
3419
|
+
}),
|
|
3420
|
+
DuplicateDetectedConfig.meta({
|
|
3421
|
+
id: "DuplicateDetectedActionConfig",
|
|
3422
|
+
description: "Configuration for the system-generated duplicate-detection action. Never shown as a button, so it only supports flags \u2014 not label, icon, or conditionals."
|
|
3423
|
+
}),
|
|
3424
|
+
MarkAsDuplicateConfig.meta({
|
|
3425
|
+
id: "MarkAsDuplicateActionConfig",
|
|
3426
|
+
description: "Configuration for marking a record as a duplicate."
|
|
3427
|
+
}),
|
|
3428
|
+
MarkAsNotDuplicateConfig.meta({
|
|
3429
|
+
id: "MarkAsNotDuplicateActionConfig",
|
|
3430
|
+
description: "Configuration for marking a record as not a duplicate, after it was previously flagged as one."
|
|
3271
3431
|
}),
|
|
3272
3432
|
RejectConfig.meta({
|
|
3273
3433
|
id: "RejectActionConfig",
|
|
@@ -3285,6 +3445,14 @@ var ActionConfig = z24.discriminatedUnion("type", [
|
|
|
3285
3445
|
id: "RequestCorrectionActionConfig",
|
|
3286
3446
|
description: "Configuration for requesting a correction on a registered record."
|
|
3287
3447
|
}),
|
|
3448
|
+
ApproveCorrectionConfig.meta({
|
|
3449
|
+
id: "ApproveCorrectionActionConfig",
|
|
3450
|
+
description: "Configuration for approving a requested correction."
|
|
3451
|
+
}),
|
|
3452
|
+
RejectCorrectionConfig.meta({
|
|
3453
|
+
id: "RejectCorrectionActionConfig",
|
|
3454
|
+
description: "Configuration for rejecting a requested correction."
|
|
3455
|
+
}),
|
|
3288
3456
|
EditActionConfig.meta({
|
|
3289
3457
|
id: "EditActionConfig",
|
|
3290
3458
|
description: "Configuration for editing a record before registration."
|
|
@@ -3293,6 +3461,10 @@ var ActionConfig = z24.discriminatedUnion("type", [
|
|
|
3293
3461
|
id: "ArchiveActionConfig",
|
|
3294
3462
|
description: "Configuration for archiving a record."
|
|
3295
3463
|
}),
|
|
3464
|
+
UnarchiveConfig.meta({
|
|
3465
|
+
id: "UnarchiveActionConfig",
|
|
3466
|
+
description: "Configuration for unarchiving a record."
|
|
3467
|
+
}),
|
|
3296
3468
|
CustomActionConfig.meta({
|
|
3297
3469
|
id: "CustomActionConfig",
|
|
3298
3470
|
description: "Configuration for a country-defined custom action. An event may include any number of these."
|
|
@@ -3446,6 +3618,9 @@ var BaseField3 = z28.object({
|
|
|
3446
3618
|
),
|
|
3447
3619
|
validations: z28.array(ValidationConfig).optional().describe(
|
|
3448
3620
|
`Option for overriding the field validations specifically for advanced search form.`
|
|
3621
|
+
),
|
|
3622
|
+
allowedLocations: JurisdictionReference.optional().describe(
|
|
3623
|
+
`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
3624
|
)
|
|
3450
3625
|
});
|
|
3451
3626
|
var SearchQueryParams = z28.object({
|
|
@@ -3520,9 +3695,11 @@ var z30 = __toESM(require("zod/v4"));
|
|
|
3520
3695
|
var z29 = __toESM(require("zod/v4"));
|
|
3521
3696
|
function getDynamicNameValue(field3) {
|
|
3522
3697
|
const nameConfiguration = field3.configuration?.name;
|
|
3698
|
+
const firstnameRequired = nameConfiguration?.firstname?.required ?? field3.required;
|
|
3699
|
+
const surnameRequired = nameConfiguration?.surname?.required ?? field3.required;
|
|
3523
3700
|
return z29.object({
|
|
3524
|
-
firstname:
|
|
3525
|
-
surname:
|
|
3701
|
+
firstname: firstnameRequired ? NonEmptyTextValue : TextValue,
|
|
3702
|
+
surname: surnameRequired ? NonEmptyTextValue : TextValue,
|
|
3526
3703
|
middlename: nameConfiguration?.middlename?.required ? NonEmptyTextValue : TextValue.optional()
|
|
3527
3704
|
});
|
|
3528
3705
|
}
|
|
@@ -3869,7 +4046,7 @@ var isHiddenFieldType = (field3) => {
|
|
|
3869
4046
|
return field3.config.type === FieldType.ALPHA_HIDDEN;
|
|
3870
4047
|
};
|
|
3871
4048
|
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.
|
|
4049
|
+
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
4050
|
};
|
|
3874
4051
|
|
|
3875
4052
|
// ../commons/src/conditionals/validate.ts
|
|
@@ -3905,7 +4082,37 @@ function resolveDataPath(rootData, dataPath, instancePath) {
|
|
|
3905
4082
|
}
|
|
3906
4083
|
return current;
|
|
3907
4084
|
}
|
|
4085
|
+
function todayISO() {
|
|
4086
|
+
return (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
|
|
4087
|
+
}
|
|
4088
|
+
var compiledFunctionCache = /* @__PURE__ */ new Map();
|
|
4089
|
+
function compileClientFunction(code) {
|
|
4090
|
+
let fn = compiledFunctionCache.get(code);
|
|
4091
|
+
if (!fn) {
|
|
4092
|
+
fn = new Function(`return (${code})`)();
|
|
4093
|
+
compiledFunctionCache.set(code, fn);
|
|
4094
|
+
}
|
|
4095
|
+
return fn;
|
|
4096
|
+
}
|
|
3908
4097
|
(0, import_ajv_formats.default)(ajv);
|
|
4098
|
+
function buildClientFunctionContext(input) {
|
|
4099
|
+
return {
|
|
4100
|
+
$form: input.form,
|
|
4101
|
+
$now: todayISO(),
|
|
4102
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
4103
|
+
$online: isOnline(),
|
|
4104
|
+
$user: input.validatorContext?.user,
|
|
4105
|
+
$event: input.validatorContext?.event,
|
|
4106
|
+
$leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
|
|
4107
|
+
user: input.systemVariables?.user,
|
|
4108
|
+
$window: input.systemVariables?.$window,
|
|
4109
|
+
locations: input.locations,
|
|
4110
|
+
adminLevelIds: input.adminLevelIds
|
|
4111
|
+
};
|
|
4112
|
+
}
|
|
4113
|
+
function runClientFunction(code, data, context) {
|
|
4114
|
+
return compileClientFunction(code)(data, context);
|
|
4115
|
+
}
|
|
3909
4116
|
ajv.addKeyword({
|
|
3910
4117
|
keyword: "daysFromDate",
|
|
3911
4118
|
type: "string",
|
|
@@ -3950,7 +4157,7 @@ ajv.addKeyword({
|
|
|
3950
4157
|
$data: true,
|
|
3951
4158
|
errors: true,
|
|
3952
4159
|
// @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(
|
|
4160
|
+
validate(_schema, data, _2, dataContext) {
|
|
3954
4161
|
const locationIdInput = data;
|
|
3955
4162
|
const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
|
|
3956
4163
|
return locations.some((location) => location.id === locationIdInput);
|
|
@@ -3981,6 +4188,23 @@ function isAgeValue(value) {
|
|
|
3981
4188
|
function mergeWithBaseFormState(values, context) {
|
|
3982
4189
|
return { ...context.baseFormState, ...values };
|
|
3983
4190
|
}
|
|
4191
|
+
ajv.addKeyword({
|
|
4192
|
+
keyword: "customClientValidator",
|
|
4193
|
+
schemaType: "object",
|
|
4194
|
+
errors: true,
|
|
4195
|
+
// @ts-expect-error -- AJV's public types don't expose `rootData`. All
|
|
4196
|
+
// `validate()` callers build root data via `buildClientFunctionContext`,
|
|
4197
|
+
// so the cast holds.
|
|
4198
|
+
validate(schema, data, _2, dataContext) {
|
|
4199
|
+
return Boolean(
|
|
4200
|
+
runClientFunction(
|
|
4201
|
+
schema.code,
|
|
4202
|
+
data,
|
|
4203
|
+
dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
|
|
4204
|
+
)
|
|
4205
|
+
);
|
|
4206
|
+
}
|
|
4207
|
+
});
|
|
3984
4208
|
function validate(schema, data) {
|
|
3985
4209
|
const validator = ajv.getSchema(schema.$id) || ajv.compile(schema);
|
|
3986
4210
|
if ("$form" in data) {
|
|
@@ -4017,17 +4241,14 @@ function isOnline() {
|
|
|
4017
4241
|
}
|
|
4018
4242
|
return true;
|
|
4019
4243
|
}
|
|
4020
|
-
function isConditionMet(conditional, values, context
|
|
4021
|
-
return validate(
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
$status: eventIndex?.status,
|
|
4029
|
-
$event: context.event
|
|
4030
|
-
});
|
|
4244
|
+
function isConditionMet(conditional, values, context) {
|
|
4245
|
+
return validate(
|
|
4246
|
+
conditional,
|
|
4247
|
+
buildClientFunctionContext({
|
|
4248
|
+
form: mergeWithBaseFormState(values, context),
|
|
4249
|
+
validatorContext: context
|
|
4250
|
+
})
|
|
4251
|
+
);
|
|
4031
4252
|
}
|
|
4032
4253
|
function getConditionalActionsForField(field3, values) {
|
|
4033
4254
|
if (!field3.conditionals) {
|
|
@@ -4035,9 +4256,9 @@ function getConditionalActionsForField(field3, values) {
|
|
|
4035
4256
|
}
|
|
4036
4257
|
return field3.conditionals.filter((conditional) => validate(conditional.conditional, values)).map((conditional) => conditional.type);
|
|
4037
4258
|
}
|
|
4038
|
-
function areConditionsMet(conditions, values, context,
|
|
4259
|
+
function areConditionsMet(conditions, values, context, _event) {
|
|
4039
4260
|
return conditions.every(
|
|
4040
|
-
(condition) => isConditionMet(condition.conditional, values, context
|
|
4261
|
+
(condition) => isConditionMet(condition.conditional, values, context)
|
|
4041
4262
|
);
|
|
4042
4263
|
}
|
|
4043
4264
|
function isFieldConditionMet(field3, form, conditionalType, context) {
|
|
@@ -4047,14 +4268,13 @@ function isFieldConditionMet(field3, form, conditionalType, context) {
|
|
|
4047
4268
|
if (!hasRule) {
|
|
4048
4269
|
return true;
|
|
4049
4270
|
}
|
|
4050
|
-
const validConditionals = getConditionalActionsForField(
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
});
|
|
4271
|
+
const validConditionals = getConditionalActionsForField(
|
|
4272
|
+
field3,
|
|
4273
|
+
buildClientFunctionContext({
|
|
4274
|
+
form: mergeWithBaseFormState(form, context),
|
|
4275
|
+
validatorContext: context
|
|
4276
|
+
})
|
|
4277
|
+
);
|
|
4058
4278
|
return validConditionals.includes(conditionalType);
|
|
4059
4279
|
}
|
|
4060
4280
|
function isFieldVisible(field3, form, context) {
|
|
@@ -4080,7 +4300,14 @@ function isActionConditionMet(actionConfig, event2, context, conditionalType) {
|
|
|
4080
4300
|
if (!rule) {
|
|
4081
4301
|
return true;
|
|
4082
4302
|
}
|
|
4083
|
-
return
|
|
4303
|
+
return validate(rule.conditional, {
|
|
4304
|
+
...buildClientFunctionContext({
|
|
4305
|
+
form: mergeWithBaseFormState(event2.declaration, context),
|
|
4306
|
+
validatorContext: context
|
|
4307
|
+
}),
|
|
4308
|
+
$flags: event2.flags,
|
|
4309
|
+
$status: event2.status
|
|
4310
|
+
});
|
|
4084
4311
|
}
|
|
4085
4312
|
function isActionEnabled(actionConfig, event2, context) {
|
|
4086
4313
|
return isActionConditionMet(
|
|
@@ -4239,19 +4466,10 @@ function runFieldValidations({
|
|
|
4239
4466
|
if (!isFieldVisible(field3.config, form, context)) {
|
|
4240
4467
|
return [];
|
|
4241
4468
|
}
|
|
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
|
-
};
|
|
4469
|
+
const conditionalParameters = buildClientFunctionContext({
|
|
4470
|
+
form: mergeWithBaseFormState(form, context),
|
|
4471
|
+
validatorContext: context
|
|
4472
|
+
});
|
|
4255
4473
|
if (isFieldGroupFieldType(field3)) {
|
|
4256
4474
|
const subfieldErrors = buildFormState(
|
|
4257
4475
|
field3.config.fields,
|
|
@@ -4390,16 +4608,13 @@ function getActionConfig({
|
|
|
4390
4608
|
actionType,
|
|
4391
4609
|
customActionType
|
|
4392
4610
|
}) {
|
|
4611
|
+
if (actionType === ActionType.NOTIFY) {
|
|
4612
|
+
return eventConfiguration.actions.find((a) => a.type === ActionType.NOTIFY) ?? eventConfiguration.actions.find((a) => a.type === ActionType.DECLARE);
|
|
4613
|
+
}
|
|
4393
4614
|
return eventConfiguration.actions.find((a) => {
|
|
4394
4615
|
if (a.type === ActionType.CUSTOM && customActionType) {
|
|
4395
4616
|
return a.customActionType === customActionType;
|
|
4396
4617
|
}
|
|
4397
|
-
if (actionType === ActionType.NOTIFY) {
|
|
4398
|
-
return a.type === ActionType.DECLARE;
|
|
4399
|
-
}
|
|
4400
|
-
if (actionType === ActionType.APPROVE_CORRECTION || actionType === ActionType.REJECT_CORRECTION) {
|
|
4401
|
-
return a.type === ActionType.REQUEST_CORRECTION;
|
|
4402
|
-
}
|
|
4403
4618
|
return a.type === actionType;
|
|
4404
4619
|
});
|
|
4405
4620
|
}
|
|
@@ -4433,7 +4648,7 @@ var getActionAnnotationFields = (actionConfig) => {
|
|
|
4433
4648
|
if (actionConfig.type === ActionType.CUSTOM) {
|
|
4434
4649
|
return actionConfig.form;
|
|
4435
4650
|
}
|
|
4436
|
-
if ("review" in actionConfig) {
|
|
4651
|
+
if ("review" in actionConfig && actionConfig.review != null) {
|
|
4437
4652
|
return actionConfig.review.fields;
|
|
4438
4653
|
}
|
|
4439
4654
|
return [];
|
|
@@ -4735,19 +4950,32 @@ function getPendingAction(actions) {
|
|
|
4735
4950
|
}
|
|
4736
4951
|
return pendingActions[0];
|
|
4737
4952
|
}
|
|
4738
|
-
function getCompleteActionAnnotation(
|
|
4953
|
+
function getCompleteActionAnnotation(event2, action) {
|
|
4739
4954
|
if (action.originalActionId) {
|
|
4740
4955
|
const originalAction = event2.actions.find(
|
|
4741
4956
|
({ id }) => id === action.originalActionId
|
|
4742
4957
|
);
|
|
4743
4958
|
if (originalAction?.status === ActionStatus.Requested) {
|
|
4744
|
-
return deepMerge(
|
|
4745
|
-
deepMerge(annotation, originalAction.annotation ?? {}),
|
|
4746
|
-
action.annotation ?? {}
|
|
4747
|
-
);
|
|
4959
|
+
return deepMerge(originalAction.annotation ?? {}, action.annotation ?? {});
|
|
4748
4960
|
}
|
|
4749
4961
|
}
|
|
4750
|
-
return
|
|
4962
|
+
return action.annotation ?? {};
|
|
4963
|
+
}
|
|
4964
|
+
function getCompleteActionContent(event2, action) {
|
|
4965
|
+
const currentContent = "content" in action ? action.content : void 0;
|
|
4966
|
+
if (!action.originalActionId) {
|
|
4967
|
+
return currentContent;
|
|
4968
|
+
}
|
|
4969
|
+
const originalAction = event2.actions.find(
|
|
4970
|
+
({ id }) => id === action.originalActionId
|
|
4971
|
+
);
|
|
4972
|
+
if (originalAction && "content" in originalAction && originalAction.content) {
|
|
4973
|
+
return {
|
|
4974
|
+
...originalAction.content,
|
|
4975
|
+
...currentContent ?? {}
|
|
4976
|
+
};
|
|
4977
|
+
}
|
|
4978
|
+
return currentContent;
|
|
4751
4979
|
}
|
|
4752
4980
|
function getCompleteActionDeclaration(declaration, event2, action) {
|
|
4753
4981
|
if (action.originalActionId) {
|
|
@@ -4767,7 +4995,7 @@ function getAcceptedActions(event2) {
|
|
|
4767
4995
|
return event2.actions.filter(isAcceptedAction).map((action) => ({
|
|
4768
4996
|
...action,
|
|
4769
4997
|
declaration: getCompleteActionDeclaration({}, event2, action),
|
|
4770
|
-
annotation: getCompleteActionAnnotation(
|
|
4998
|
+
annotation: getCompleteActionAnnotation(event2, action)
|
|
4771
4999
|
}));
|
|
4772
5000
|
}
|
|
4773
5001
|
var EXCLUDED_ACTIONS = [
|
|
@@ -5405,7 +5633,54 @@ function createFieldConditionals(fieldId) {
|
|
|
5405
5633
|
}
|
|
5406
5634
|
},
|
|
5407
5635
|
required: [fieldId]
|
|
5408
|
-
})
|
|
5636
|
+
}),
|
|
5637
|
+
/**
|
|
5638
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
5639
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
5640
|
+
* available inside the function body — all logic must be self-contained.
|
|
5641
|
+
*
|
|
5642
|
+
* @example
|
|
5643
|
+
* field('nid').customClientValidator((value) => {
|
|
5644
|
+
* // LUHN check — all logic must be inline
|
|
5645
|
+
* const digits = String(value).split('').map(Number)
|
|
5646
|
+
* // ...
|
|
5647
|
+
* return isValid
|
|
5648
|
+
* })
|
|
5649
|
+
*/
|
|
5650
|
+
customClientValidator(validationFn) {
|
|
5651
|
+
const code = validationFn.toString();
|
|
5652
|
+
return defineFormConditional({
|
|
5653
|
+
type: "object",
|
|
5654
|
+
properties: wrapToPath(
|
|
5655
|
+
{ [fieldId]: { customClientValidator: { code } } },
|
|
5656
|
+
this.$$subfield
|
|
5657
|
+
),
|
|
5658
|
+
required: [fieldId]
|
|
5659
|
+
});
|
|
5660
|
+
},
|
|
5661
|
+
/**
|
|
5662
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
5663
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
5664
|
+
* The function receives the referenced field's value as the first argument and
|
|
5665
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
5666
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
5667
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
5668
|
+
*
|
|
5669
|
+
* For computing a default value without referencing a specific field, use
|
|
5670
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
5671
|
+
*
|
|
5672
|
+
* @example
|
|
5673
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
5674
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
5675
|
+
* )
|
|
5676
|
+
*/
|
|
5677
|
+
customClientEvaluation(computationFn) {
|
|
5678
|
+
return {
|
|
5679
|
+
$$code: computationFn.toString(),
|
|
5680
|
+
$$field: fieldId,
|
|
5681
|
+
$$subfield: this.$$subfield
|
|
5682
|
+
};
|
|
5683
|
+
}
|
|
5409
5684
|
};
|
|
5410
5685
|
}
|
|
5411
5686
|
|
|
@@ -5493,7 +5768,7 @@ function validateActionFlags(event2, ctx) {
|
|
|
5493
5768
|
const isInherentFlag = (value) => Object.values(InherentFlags).includes(value);
|
|
5494
5769
|
const configuredFlagIds = event2.flags.map((flag2) => flag2.id);
|
|
5495
5770
|
const actionFlagIds = event2.actions.flatMap(
|
|
5496
|
-
(action) => action.flags.map((flag2) => flag2.id)
|
|
5771
|
+
(action) => (action.flags ?? []).map((flag2) => flag2.id)
|
|
5497
5772
|
);
|
|
5498
5773
|
for (const actionFlagId of actionFlagIds) {
|
|
5499
5774
|
const isConfigured = configuredFlagIds.includes(actionFlagId);
|
|
@@ -6168,6 +6443,11 @@ var ArchiveActionInput = BaseActionInput.extend(
|
|
|
6168
6443
|
content: ReasonContent
|
|
6169
6444
|
}).shape
|
|
6170
6445
|
);
|
|
6446
|
+
var UnarchiveActionInput = BaseActionInput.extend(
|
|
6447
|
+
z38.object({
|
|
6448
|
+
type: z38.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
|
|
6449
|
+
}).shape
|
|
6450
|
+
);
|
|
6171
6451
|
var AssignActionInput = BaseActionInput.extend(
|
|
6172
6452
|
z38.object({
|
|
6173
6453
|
type: z38.literal(ActionType.ASSIGN),
|
|
@@ -6195,7 +6475,8 @@ var RejectCorrectionActionInput = BaseActionInput.extend(
|
|
|
6195
6475
|
var ApproveCorrectionActionInput = BaseActionInput.extend(
|
|
6196
6476
|
z38.object({
|
|
6197
6477
|
requestId: z38.string(),
|
|
6198
|
-
type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
|
|
6478
|
+
type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION),
|
|
6479
|
+
content: z38.object({ immediateCorrection: z38.boolean().optional() }).optional()
|
|
6199
6480
|
}).shape
|
|
6200
6481
|
);
|
|
6201
6482
|
var ReadActionInput = BaseActionInput.extend(
|
|
@@ -6228,6 +6509,7 @@ var ActionInput = z38.discriminatedUnion("type", [
|
|
|
6228
6509
|
id: "MarkNotDuplicateActionInput"
|
|
6229
6510
|
}),
|
|
6230
6511
|
ArchiveActionInput.meta({ id: "ArchiveActionInput" }),
|
|
6512
|
+
UnarchiveActionInput.meta({ id: "UnarchiveActionInput" }),
|
|
6231
6513
|
AssignActionInput.meta({ id: "AssignActionInput" }),
|
|
6232
6514
|
UnassignActionInput.meta({ id: "UnassignActionInput" }),
|
|
6233
6515
|
PrintCertificateActionInput.meta({ id: "PrintCertificateActionInput" }),
|
|
@@ -6342,8 +6624,11 @@ var updateActions = ActionTypes.extract([
|
|
|
6342
6624
|
ActionType.REGISTER,
|
|
6343
6625
|
ActionType.REJECT,
|
|
6344
6626
|
ActionType.ARCHIVE,
|
|
6627
|
+
ActionType.UNARCHIVE,
|
|
6345
6628
|
ActionType.PRINT_CERTIFICATE,
|
|
6346
6629
|
ActionType.REQUEST_CORRECTION,
|
|
6630
|
+
ActionType.APPROVE_CORRECTION,
|
|
6631
|
+
ActionType.REJECT_CORRECTION,
|
|
6347
6632
|
ActionType.CUSTOM
|
|
6348
6633
|
]);
|
|
6349
6634
|
function getActionUpdateMetadata(actions) {
|
|
@@ -6358,7 +6643,7 @@ function getActionUpdateMetadata(actions) {
|
|
|
6358
6643
|
"createdAtLocation",
|
|
6359
6644
|
"createdByRole"
|
|
6360
6645
|
];
|
|
6361
|
-
return actions.filter(({ type }) => updateActions.safeParse(type).success).
|
|
6646
|
+
return actions.filter(({ type }) => updateActions.safeParse(type).success).reduce(
|
|
6362
6647
|
(_2, action) => {
|
|
6363
6648
|
if (action.originalActionId) {
|
|
6364
6649
|
const originalAction = actions.find(({ id }) => id === action.originalActionId) ?? action;
|
|
@@ -6371,6 +6656,10 @@ function getActionUpdateMetadata(actions) {
|
|
|
6371
6656
|
}
|
|
6372
6657
|
function getLegalStatuses(actions) {
|
|
6373
6658
|
return {
|
|
6659
|
+
[EventStatus.enum.NOTIFIED]: getDeclarationActionCreationMetadata(
|
|
6660
|
+
ActionType.NOTIFY,
|
|
6661
|
+
actions
|
|
6662
|
+
),
|
|
6374
6663
|
[EventStatus.enum.DECLARED]: getDeclarationActionCreationMetadata(
|
|
6375
6664
|
ActionType.DECLARE,
|
|
6376
6665
|
actions
|
|
@@ -6385,34 +6674,20 @@ function getLegalStatuses(actions) {
|
|
|
6385
6674
|
// ../commons/src/events/state/flags.ts
|
|
6386
6675
|
var import_lodash3 = require("lodash");
|
|
6387
6676
|
var import_date_fns3 = require("date-fns");
|
|
6388
|
-
function isEditInProgress(actions) {
|
|
6389
|
-
return actions.at(-1)?.type === ActionType.EDIT;
|
|
6390
|
-
}
|
|
6391
6677
|
function findPendingCorrectionAction(writeActions2) {
|
|
6392
6678
|
let correctionRequestAction;
|
|
6393
6679
|
for (let i = writeActions2.length - 1; i >= 0; i--) {
|
|
6394
6680
|
const action = writeActions2[i];
|
|
6395
|
-
if (action.
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
break;
|
|
6402
|
-
}
|
|
6681
|
+
if (action.type === ActionType.APPROVE_CORRECTION || action.type === ActionType.REJECT_CORRECTION) {
|
|
6682
|
+
break;
|
|
6683
|
+
}
|
|
6684
|
+
if (action.type === ActionType.REQUEST_CORRECTION) {
|
|
6685
|
+
correctionRequestAction = action;
|
|
6686
|
+
break;
|
|
6403
6687
|
}
|
|
6404
6688
|
}
|
|
6405
6689
|
return correctionRequestAction;
|
|
6406
6690
|
}
|
|
6407
|
-
function isCorrectionRequested(actions) {
|
|
6408
|
-
return findPendingCorrectionAction(actions) !== void 0;
|
|
6409
|
-
}
|
|
6410
|
-
function isDeclarationIncomplete(actions) {
|
|
6411
|
-
return getStatusFromActions(actions) === EventStatus.enum.NOTIFIED;
|
|
6412
|
-
}
|
|
6413
|
-
function isRejected(actions) {
|
|
6414
|
-
return actions.at(-1)?.type === ActionType.REJECT;
|
|
6415
|
-
}
|
|
6416
6691
|
function isPotentialDuplicate(actions) {
|
|
6417
6692
|
return actions.reduce((prev, { type }) => {
|
|
6418
6693
|
if (type === ActionType.DUPLICATE_DETECTED) {
|
|
@@ -6440,6 +6715,85 @@ function isFlagConditionMet(conditional, form, action) {
|
|
|
6440
6715
|
}
|
|
6441
6716
|
});
|
|
6442
6717
|
}
|
|
6718
|
+
function actionConfigRemovesFlag(action, flagId, actionsUpToAndIncluding, event2, eventConfiguration) {
|
|
6719
|
+
if (!isActionConfigType(action.type)) {
|
|
6720
|
+
return false;
|
|
6721
|
+
}
|
|
6722
|
+
const actionConfig = getActionConfig({
|
|
6723
|
+
eventConfiguration,
|
|
6724
|
+
actionType: action.type,
|
|
6725
|
+
customActionType: "customActionType" in action ? action.customActionType : void 0
|
|
6726
|
+
});
|
|
6727
|
+
const removeOperations = (actionConfig?.flags ?? []).filter(
|
|
6728
|
+
({ id, operation }) => id === flagId && operation === "remove"
|
|
6729
|
+
);
|
|
6730
|
+
if (removeOperations.length === 0) {
|
|
6731
|
+
return false;
|
|
6732
|
+
}
|
|
6733
|
+
const eventUpToThisAction = { ...event2, actions: actionsUpToAndIncluding };
|
|
6734
|
+
const declaration = aggregateActionDeclarations(eventUpToThisAction);
|
|
6735
|
+
const annotation = aggregateActionAnnotations(eventUpToThisAction);
|
|
6736
|
+
const form = { ...declaration, ...annotation };
|
|
6737
|
+
return removeOperations.some(
|
|
6738
|
+
({ conditional }) => conditional ? isFlagConditionMet(conditional, form, action) : true
|
|
6739
|
+
);
|
|
6740
|
+
}
|
|
6741
|
+
var INHERENT_FLAG_RULES = [
|
|
6742
|
+
{
|
|
6743
|
+
flag: InherentFlags.CORRECTION_REQUESTED,
|
|
6744
|
+
setOn: [ActionType.REQUEST_CORRECTION],
|
|
6745
|
+
resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
|
|
6746
|
+
},
|
|
6747
|
+
{
|
|
6748
|
+
// INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
|
|
6749
|
+
// other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
|
|
6750
|
+
// are deliberately excluded so the flag freezes across an archive/unarchive
|
|
6751
|
+
// round trip and comes back exactly as it was.
|
|
6752
|
+
flag: InherentFlags.INCOMPLETE,
|
|
6753
|
+
setOn: [ActionType.NOTIFY],
|
|
6754
|
+
resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
|
|
6755
|
+
},
|
|
6756
|
+
{
|
|
6757
|
+
flag: InherentFlags.REJECTED,
|
|
6758
|
+
setOn: [ActionType.REJECT],
|
|
6759
|
+
resetOn: [
|
|
6760
|
+
ActionType.NOTIFY,
|
|
6761
|
+
ActionType.DECLARE,
|
|
6762
|
+
ActionType.EDIT,
|
|
6763
|
+
ActionType.REGISTER
|
|
6764
|
+
]
|
|
6765
|
+
},
|
|
6766
|
+
{
|
|
6767
|
+
flag: InherentFlags.POTENTIAL_DUPLICATE,
|
|
6768
|
+
setOn: [ActionType.DUPLICATE_DETECTED],
|
|
6769
|
+
resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
|
|
6770
|
+
},
|
|
6771
|
+
{
|
|
6772
|
+
flag: InherentFlags.EDIT_IN_PROGRESS,
|
|
6773
|
+
setOn: [ActionType.EDIT],
|
|
6774
|
+
resetOnAnyOtherAction: true
|
|
6775
|
+
}
|
|
6776
|
+
];
|
|
6777
|
+
function resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration) {
|
|
6778
|
+
return acceptedActions.reduce((present, action, idx) => {
|
|
6779
|
+
if (rule.setOn.includes(action.type)) {
|
|
6780
|
+
return true;
|
|
6781
|
+
}
|
|
6782
|
+
if (rule.resetOnAnyOtherAction || (rule.resetOn ?? []).includes(action.type)) {
|
|
6783
|
+
return false;
|
|
6784
|
+
}
|
|
6785
|
+
if (actionConfigRemovesFlag(
|
|
6786
|
+
action,
|
|
6787
|
+
rule.flag,
|
|
6788
|
+
acceptedActions.slice(0, idx + 1),
|
|
6789
|
+
event2,
|
|
6790
|
+
eventConfiguration
|
|
6791
|
+
)) {
|
|
6792
|
+
return false;
|
|
6793
|
+
}
|
|
6794
|
+
return present;
|
|
6795
|
+
}, false);
|
|
6796
|
+
}
|
|
6443
6797
|
function resolveEventCustomFlags(event2, eventConfiguration) {
|
|
6444
6798
|
const actions = getAcceptedActions(event2).filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
6445
6799
|
return actions.reduce((acc, action, idx) => {
|
|
@@ -6461,7 +6815,7 @@ function resolveEventCustomFlags(event2, eventConfiguration) {
|
|
|
6461
6815
|
const declaration = aggregateActionDeclarations(eventUpToThisAction);
|
|
6462
6816
|
const annotation = aggregateActionAnnotations(eventUpToThisAction);
|
|
6463
6817
|
const form = { ...declaration, ...annotation };
|
|
6464
|
-
const flagsWithMetConditions = actionConfig.flags.filter(
|
|
6818
|
+
const flagsWithMetConditions = (actionConfig.flags ?? []).filter(
|
|
6465
6819
|
({ conditional }) => (
|
|
6466
6820
|
// If conditional is not provided, the flag is resolved
|
|
6467
6821
|
conditional ? isFlagConditionMet(conditional, form, action) : true
|
|
@@ -6475,8 +6829,7 @@ function resolveEventCustomFlags(event2, eventConfiguration) {
|
|
|
6475
6829
|
return (0, import_lodash3.uniq)(flags);
|
|
6476
6830
|
}, []);
|
|
6477
6831
|
}
|
|
6478
|
-
function
|
|
6479
|
-
const sortedActions = event2.actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
6832
|
+
function getActionStatusFlags(sortedActions) {
|
|
6480
6833
|
const actionStatus = sortedActions.reduce(
|
|
6481
6834
|
(actionStatuses, { type, status: status2 }) => ({
|
|
6482
6835
|
...actionStatuses,
|
|
@@ -6484,31 +6837,51 @@ function getEventFlags(event2, config) {
|
|
|
6484
6837
|
}),
|
|
6485
6838
|
{}
|
|
6486
6839
|
);
|
|
6487
|
-
|
|
6840
|
+
return Object.entries(actionStatus).filter(([, status2]) => status2 !== ActionStatus.Accepted).map(([type, status2]) => {
|
|
6488
6841
|
const flag2 = joinValues([type, status2], ":").toLowerCase();
|
|
6489
6842
|
return flag2;
|
|
6490
6843
|
});
|
|
6491
|
-
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6844
|
+
}
|
|
6845
|
+
function getInherentFlags(sortedActions, event2, eventConfiguration) {
|
|
6846
|
+
const acceptedActions = sortedActions.filter(
|
|
6847
|
+
({ status: status2 }) => status2 === ActionStatus.Accepted
|
|
6848
|
+
);
|
|
6849
|
+
return INHERENT_FLAG_RULES.filter(
|
|
6850
|
+
(rule) => resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration)
|
|
6851
|
+
).map(({ flag: flag2 }) => flag2);
|
|
6852
|
+
}
|
|
6853
|
+
function getEventFlags(event2, config) {
|
|
6854
|
+
const sortedActions = event2.actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
6855
|
+
return [
|
|
6856
|
+
...getActionStatusFlags(sortedActions),
|
|
6857
|
+
...getInherentFlags(sortedActions, event2, config),
|
|
6858
|
+
...resolveEventCustomFlags(event2, config)
|
|
6859
|
+
];
|
|
6507
6860
|
}
|
|
6508
6861
|
|
|
6509
6862
|
// ../commons/src/events/state/index.ts
|
|
6510
6863
|
function getStatusFromActions(actions) {
|
|
6511
|
-
|
|
6864
|
+
const acceptedActions = actions.filter(
|
|
6865
|
+
({ status: status2 }) => status2 === ActionStatus.Accepted
|
|
6866
|
+
);
|
|
6867
|
+
const isCurrentlyArchived = acceptedActions.reduce(
|
|
6868
|
+
(archived, action) => {
|
|
6869
|
+
if (action.type === ActionType.ARCHIVE) {
|
|
6870
|
+
return true;
|
|
6871
|
+
}
|
|
6872
|
+
if (action.type === ActionType.UNARCHIVE) {
|
|
6873
|
+
return false;
|
|
6874
|
+
}
|
|
6875
|
+
return archived;
|
|
6876
|
+
},
|
|
6877
|
+
false
|
|
6878
|
+
);
|
|
6879
|
+
if (isCurrentlyArchived) {
|
|
6880
|
+
return EventStatus.enum.ARCHIVED;
|
|
6881
|
+
}
|
|
6882
|
+
return acceptedActions.filter(
|
|
6883
|
+
({ type }) => type !== ActionType.ARCHIVE && type !== ActionType.UNARCHIVE
|
|
6884
|
+
).reduce((status2, action) => {
|
|
6512
6885
|
switch (action.type) {
|
|
6513
6886
|
case ActionType.CREATE:
|
|
6514
6887
|
return EventStatus.enum.CREATED;
|
|
@@ -6516,10 +6889,11 @@ function getStatusFromActions(actions) {
|
|
|
6516
6889
|
return EventStatus.enum.DECLARED;
|
|
6517
6890
|
case ActionType.REGISTER:
|
|
6518
6891
|
return EventStatus.enum.REGISTERED;
|
|
6519
|
-
case ActionType.ARCHIVE:
|
|
6520
|
-
return EventStatus.enum.ARCHIVED;
|
|
6521
6892
|
case ActionType.NOTIFY:
|
|
6522
6893
|
return EventStatus.enum.NOTIFIED;
|
|
6894
|
+
// Already filtered out above; listed here only to satisfy exhaustiveness.
|
|
6895
|
+
case ActionType.ARCHIVE:
|
|
6896
|
+
case ActionType.UNARCHIVE:
|
|
6523
6897
|
case ActionType.CUSTOM:
|
|
6524
6898
|
case ActionType.PRINT_CERTIFICATE:
|
|
6525
6899
|
case ActionType.ASSIGN:
|
|
@@ -6738,7 +7112,7 @@ function getActionAnnotation({
|
|
|
6738
7112
|
const action = (0, import_lodash4.findLast)(activeActions, (a) => a.type === actionType);
|
|
6739
7113
|
const actionWithCompleteAnnotation = action && {
|
|
6740
7114
|
...action,
|
|
6741
|
-
annotation: getCompleteActionAnnotation(
|
|
7115
|
+
annotation: getCompleteActionAnnotation(event2, action)
|
|
6742
7116
|
};
|
|
6743
7117
|
const matchingDraft = draft?.action.type === actionType ? draft : void 0;
|
|
6744
7118
|
const sortedActions = (0, import_lodash4.orderBy)(
|
|
@@ -6810,6 +7184,9 @@ function createFieldConfig(fieldId, options) {
|
|
|
6810
7184
|
}
|
|
6811
7185
|
|
|
6812
7186
|
// ../commons/src/events/field.ts
|
|
7187
|
+
function evaluate(computationFn) {
|
|
7188
|
+
return { $$code: computationFn.toString() };
|
|
7189
|
+
}
|
|
6813
7190
|
function field(fieldId, options = {}) {
|
|
6814
7191
|
return {
|
|
6815
7192
|
...createFieldConditionals(fieldId),
|
|
@@ -7503,6 +7880,11 @@ var TENNIS_CLUB_DECLARATION_REVIEW = {
|
|
|
7503
7880
|
id: "signature.upload.modal.title",
|
|
7504
7881
|
defaultMessage: "Draw signature",
|
|
7505
7882
|
description: "Title for the modal to draw signature"
|
|
7883
|
+
},
|
|
7884
|
+
// Zod applies the schema default at parse time, but this fixture bypasses
|
|
7885
|
+
// parsing — GeneratedInputField accesses configuration.maxFileSize directly.
|
|
7886
|
+
configuration: {
|
|
7887
|
+
maxFileSize: 5 * 1024 * 1024
|
|
7506
7888
|
}
|
|
7507
7889
|
}
|
|
7508
7890
|
]
|
|
@@ -8059,6 +8441,20 @@ var tennisClubMembershipEvent = defineConfig({
|
|
|
8059
8441
|
},
|
|
8060
8442
|
review: TENNIS_CLUB_DECLARATION_REVIEW
|
|
8061
8443
|
},
|
|
8444
|
+
{
|
|
8445
|
+
type: ActionType.NOTIFY,
|
|
8446
|
+
label: {
|
|
8447
|
+
defaultMessage: "Notify health worker",
|
|
8448
|
+
description: "This is shown as the action name anywhere the user can trigger the action from",
|
|
8449
|
+
id: "event.tennis-club-membership.action.notify.label"
|
|
8450
|
+
},
|
|
8451
|
+
flags: [
|
|
8452
|
+
{
|
|
8453
|
+
id: "health-worker-notified",
|
|
8454
|
+
operation: "add"
|
|
8455
|
+
}
|
|
8456
|
+
]
|
|
8457
|
+
},
|
|
8062
8458
|
{
|
|
8063
8459
|
type: ActionType.REJECT,
|
|
8064
8460
|
label: {
|
|
@@ -8301,6 +8697,17 @@ var tennisClubMembershipEvent = defineConfig({
|
|
|
8301
8697
|
}
|
|
8302
8698
|
}
|
|
8303
8699
|
],
|
|
8700
|
+
flags: [
|
|
8701
|
+
{
|
|
8702
|
+
id: "health-worker-notified",
|
|
8703
|
+
requiresAction: false,
|
|
8704
|
+
label: {
|
|
8705
|
+
id: "event.tennis-club-membership.flag.health-worker-notified.label",
|
|
8706
|
+
defaultMessage: "Health worker notified",
|
|
8707
|
+
description: "Label for the health-worker-notified flag"
|
|
8708
|
+
}
|
|
8709
|
+
}
|
|
8710
|
+
],
|
|
8304
8711
|
advancedSearch: [
|
|
8305
8712
|
{
|
|
8306
8713
|
title: {
|
|
@@ -9571,6 +9978,14 @@ function eventPayloadGenerator(rng, configuration = tennisClubMembershipEvent) {
|
|
|
9571
9978
|
},
|
|
9572
9979
|
...input
|
|
9573
9980
|
}),
|
|
9981
|
+
unarchive: (eventId, input = {}) => ({
|
|
9982
|
+
type: ActionType.UNARCHIVE,
|
|
9983
|
+
transactionId: input.transactionId ?? getUUID(),
|
|
9984
|
+
declaration: {},
|
|
9985
|
+
annotation: {},
|
|
9986
|
+
eventId,
|
|
9987
|
+
...input
|
|
9988
|
+
}),
|
|
9574
9989
|
reject: (eventId, input = {}) => ({
|
|
9575
9990
|
type: ActionType.REJECT,
|
|
9576
9991
|
transactionId: input.transactionId ?? getUUID(),
|
|
@@ -9729,6 +10144,7 @@ function generateActionDocument({
|
|
|
9729
10144
|
case ActionType.NOTIFY:
|
|
9730
10145
|
case ActionType.REGISTER:
|
|
9731
10146
|
case ActionType.REQUEST_CORRECTION:
|
|
10147
|
+
case ActionType.UNARCHIVE:
|
|
9732
10148
|
return { ...actionBase, type: action };
|
|
9733
10149
|
case ActionType.EDIT:
|
|
9734
10150
|
return {
|
|
@@ -10059,7 +10475,7 @@ function matchesJurisdictionFilter(locationIds, filter, user2) {
|
|
|
10059
10475
|
return locationIds.some((id) => id === user2.primaryOfficeId);
|
|
10060
10476
|
}
|
|
10061
10477
|
if (filter === JurisdictionFilter.enum.administrativeArea) {
|
|
10062
|
-
return user2.administrativeAreaId
|
|
10478
|
+
return !user2.administrativeAreaId || locationIds.some((id) => id === user2.administrativeAreaId);
|
|
10063
10479
|
}
|
|
10064
10480
|
return true;
|
|
10065
10481
|
}
|
|
@@ -10086,6 +10502,25 @@ function canAccessEventWithScope(event2, scope, user2, customActionType) {
|
|
|
10086
10502
|
}
|
|
10087
10503
|
if (scopeUsesDeclaredOptions(scope)) {
|
|
10088
10504
|
const { options } = scope;
|
|
10505
|
+
if (options?.notifiedBy === UserFilter.enum.user) {
|
|
10506
|
+
if (event2.legalStatuses?.NOTIFIED?.createdBy !== user2.id) {
|
|
10507
|
+
return false;
|
|
10508
|
+
}
|
|
10509
|
+
}
|
|
10510
|
+
if (options?.notifiedIn === JurisdictionFilter.enum.location && !matchesJurisdictionFilter(
|
|
10511
|
+
event2.legalStatuses?.NOTIFIED?.createdAtLocation,
|
|
10512
|
+
JurisdictionFilter.enum.location,
|
|
10513
|
+
user2
|
|
10514
|
+
)) {
|
|
10515
|
+
return false;
|
|
10516
|
+
}
|
|
10517
|
+
if (options?.notifiedIn === JurisdictionFilter.enum.administrativeArea && !matchesJurisdictionFilter(
|
|
10518
|
+
event2.legalStatuses?.NOTIFIED?.createdAtLocation,
|
|
10519
|
+
JurisdictionFilter.enum.administrativeArea,
|
|
10520
|
+
user2
|
|
10521
|
+
)) {
|
|
10522
|
+
return false;
|
|
10523
|
+
}
|
|
10089
10524
|
if (options?.declaredBy === UserFilter.enum.user) {
|
|
10090
10525
|
if (event2.legalStatuses?.DECLARED?.createdBy !== user2.id) {
|
|
10091
10526
|
return false;
|
|
@@ -10148,7 +10583,7 @@ function canAccessUserWithScope({
|
|
|
10148
10583
|
}
|
|
10149
10584
|
const hasAdministrativeAreaInHierarchy = userToAccess.administrativeHierarchy.some(
|
|
10150
10585
|
(id) => user2.administrativeAreaId === id
|
|
10151
|
-
) || user2.administrativeAreaId
|
|
10586
|
+
) || !user2.administrativeAreaId;
|
|
10152
10587
|
if (opts?.accessLevel === JurisdictionFilter.enum.administrativeArea && !hasAdministrativeAreaInHierarchy) {
|
|
10153
10588
|
return false;
|
|
10154
10589
|
}
|
|
@@ -10228,6 +10663,7 @@ var ACTION_SCOPE_MAP = {
|
|
|
10228
10663
|
[ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
|
|
10229
10664
|
[ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
|
|
10230
10665
|
[ActionType.ARCHIVE]: ["record.archive"],
|
|
10666
|
+
[ActionType.UNARCHIVE]: ["record.unarchive"],
|
|
10231
10667
|
[ActionType.REJECT]: ["record.reject"],
|
|
10232
10668
|
[ActionType.ASSIGN]: null,
|
|
10233
10669
|
[ActionType.UNASSIGN]: null,
|
|
@@ -10434,7 +10870,11 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
|
|
|
10434
10870
|
ActionType.CUSTOM,
|
|
10435
10871
|
ClientSpecificAction.REVIEW_CORRECTION_REQUEST
|
|
10436
10872
|
],
|
|
10437
|
-
[EventStatus.enum.ARCHIVED]: [
|
|
10873
|
+
[EventStatus.enum.ARCHIVED]: [
|
|
10874
|
+
ActionType.READ,
|
|
10875
|
+
ActionType.CUSTOM,
|
|
10876
|
+
ActionType.UNARCHIVE
|
|
10877
|
+
]
|
|
10438
10878
|
};
|
|
10439
10879
|
var ACTION_FILTERS = {
|
|
10440
10880
|
[ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
@@ -10447,6 +10887,7 @@ var ACTION_FILTERS = {
|
|
|
10447
10887
|
[ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
10448
10888
|
[ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
10449
10889
|
[ActionType.ARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
10890
|
+
[ActionType.UNARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
10450
10891
|
[ActionType.ASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
10451
10892
|
[ActionType.UNASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
10452
10893
|
[ActionType.CUSTOM]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested"))
|
|
@@ -10454,18 +10895,19 @@ var ACTION_FILTERS = {
|
|
|
10454
10895
|
function filterActionsByFlags(actions, flags) {
|
|
10455
10896
|
return actions.filter((action) => ACTION_FILTERS[action]?.(flags) ?? true);
|
|
10456
10897
|
}
|
|
10898
|
+
var REJECTED_ACTIONS = [
|
|
10899
|
+
ActionType.READ,
|
|
10900
|
+
ActionType.NOTIFY,
|
|
10901
|
+
ActionType.CUSTOM,
|
|
10902
|
+
ActionType.EDIT,
|
|
10903
|
+
ActionType.ARCHIVE
|
|
10904
|
+
];
|
|
10457
10905
|
function getAvailableActionsWithoutFlagFilters(status2, flags) {
|
|
10458
10906
|
if (flags.includes(InherentFlags.EDIT_IN_PROGRESS)) {
|
|
10459
10907
|
return [ActionType.NOTIFY, ActionType.DECLARE, ActionType.REGISTER];
|
|
10460
10908
|
}
|
|
10461
|
-
if (flags.includes(InherentFlags.REJECTED)) {
|
|
10462
|
-
return
|
|
10463
|
-
ActionType.READ,
|
|
10464
|
-
ActionType.NOTIFY,
|
|
10465
|
-
ActionType.CUSTOM,
|
|
10466
|
-
ActionType.EDIT,
|
|
10467
|
-
ActionType.ARCHIVE
|
|
10468
|
-
];
|
|
10909
|
+
if (flags.includes(InherentFlags.REJECTED) && status2 !== EventStatus.enum.ARCHIVED) {
|
|
10910
|
+
return REJECTED_ACTIONS;
|
|
10469
10911
|
}
|
|
10470
10912
|
return AVAILABLE_ACTIONS_BY_EVENT_STATUS[status2];
|
|
10471
10913
|
}
|