@opencrvs/toolkit 2.0.0-rc.3dce118 → 2.0.0-rc.3ddb687

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/README.md +15 -0
  2. package/build.sh +5 -4
  3. package/create-countryconfig/index.js +50 -20
  4. package/create-countryconfig/package.json +12 -2
  5. package/dist/application-config/index.js +298 -123
  6. package/dist/cli.js +3223 -4688
  7. package/dist/commons/api/router.d.ts +3954 -211
  8. package/dist/commons/application-config/index.d.ts +1 -0
  9. package/dist/commons/conditionals/conditionals.d.ts +360 -10
  10. package/dist/commons/conditionals/validate.d.ts +52 -2
  11. package/dist/commons/events/ActionConfig.d.ts +230 -2
  12. package/dist/commons/events/ActionDocument.d.ts +50 -0
  13. package/dist/commons/events/ActionInput.d.ts +140 -0
  14. package/dist/commons/events/ActionType.d.ts +6 -1
  15. package/dist/commons/events/AdvancedSearchConfig.d.ts +360 -0
  16. package/dist/commons/events/AuditLog.d.ts +2 -0
  17. package/dist/commons/events/CountryConfigQueryInput.d.ts +42 -0
  18. package/dist/commons/events/Draft.d.ts +6 -2
  19. package/dist/commons/events/EventConfig.d.ts +2 -0
  20. package/dist/commons/events/EventDocument.d.ts +25 -0
  21. package/dist/commons/events/EventIndex.d.ts +25 -3
  22. package/dist/commons/events/EventMetadata.d.ts +26 -7
  23. package/dist/commons/events/FieldConfig.d.ts +393 -50
  24. package/dist/commons/events/FieldType.d.ts +1 -0
  25. package/dist/commons/events/FieldTypeMapping.d.ts +1 -1
  26. package/dist/commons/events/FieldValue.d.ts +6 -0
  27. package/dist/commons/events/WorkqueueConfig.d.ts +194 -152
  28. package/dist/commons/events/field.d.ts +53 -1
  29. package/dist/commons/events/index.d.ts +2 -0
  30. package/dist/commons/events/locations.d.ts +1 -0
  31. package/dist/commons/events/scopes.d.ts +1 -0
  32. package/dist/commons/events/state/flags.d.ts +16 -0
  33. package/dist/commons/events/state/index.d.ts +8 -4
  34. package/dist/commons/events/state/utils.d.ts +21 -289
  35. package/dist/commons/events/test.utils.d.ts +9 -1
  36. package/dist/commons/events/utils.d.ts +28 -3
  37. package/dist/conditionals/index.js +65 -5
  38. package/dist/environment/custom-types.d.ts +33 -0
  39. package/dist/environment/custom-types.d.ts.map +1 -0
  40. package/dist/environment/custom-types.js +12 -0
  41. package/dist/environment/derived-variables.d.ts +134 -0
  42. package/dist/environment/derived-variables.d.ts.map +1 -0
  43. package/dist/environment/derived-variables.js +169 -0
  44. package/dist/environment/editor-questions.d.ts +4 -0
  45. package/dist/environment/editor-questions.d.ts.map +1 -0
  46. package/dist/environment/editor-questions.js +67 -0
  47. package/dist/environment/git.d.ts +5 -0
  48. package/dist/environment/git.d.ts.map +1 -0
  49. package/dist/environment/git.js +38 -0
  50. package/dist/environment/github.d.ts +26 -0
  51. package/dist/environment/github.d.ts.map +1 -0
  52. package/dist/environment/github.js +247 -0
  53. package/dist/environment/index.d.ts +5 -0
  54. package/dist/environment/index.d.ts.map +1 -0
  55. package/dist/environment/index.js +71 -0
  56. package/dist/environment/logger.d.ts +15 -0
  57. package/dist/environment/logger.d.ts.map +1 -0
  58. package/dist/environment/logger.js +25 -0
  59. package/dist/environment/manage-users.d.ts +11 -0
  60. package/dist/environment/manage-users.d.ts.map +1 -0
  61. package/dist/environment/manage-users.js +497 -0
  62. package/dist/environment/questions-helper.d.ts +15 -0
  63. package/dist/environment/questions-helper.d.ts.map +1 -0
  64. package/dist/environment/questions-helper.js +70 -0
  65. package/dist/environment/questions.d.ts +199 -0
  66. package/dist/environment/questions.d.ts.map +1 -0
  67. package/dist/environment/questions.js +412 -0
  68. package/dist/environment/setup-environment.d.ts +2 -0
  69. package/dist/environment/setup-environment.d.ts.map +1 -0
  70. package/dist/environment/setup-environment.js +794 -0
  71. package/dist/environment/ssh-keygen.d.ts +5 -0
  72. package/dist/environment/ssh-keygen.d.ts.map +1 -0
  73. package/dist/environment/ssh-keygen.js +21 -0
  74. package/dist/environment/swarm-to-k8s.d.ts +2 -0
  75. package/dist/environment/swarm-to-k8s.d.ts.map +1 -0
  76. package/dist/environment/swarm-to-k8s.js +173 -0
  77. package/dist/environment/templates.d.ts +27 -0
  78. package/dist/environment/templates.d.ts.map +1 -0
  79. package/dist/environment/templates.js +163 -0
  80. package/dist/environment/update-workflows.d.ts +2 -0
  81. package/dist/environment/update-workflows.d.ts.map +1 -0
  82. package/dist/environment/update-workflows.js +169 -0
  83. package/dist/environment/users.d.ts +2 -0
  84. package/dist/environment/users.d.ts.map +1 -0
  85. package/dist/environment/users.js +112 -0
  86. package/dist/environment/utils.d.ts +18 -0
  87. package/dist/environment/utils.d.ts.map +1 -0
  88. package/dist/environment/utils.js +100 -0
  89. package/dist/events/index.js +1272 -299
  90. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +1 -1
  91. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  92. package/dist/migrations/v2.0/checkout-upstream-files.js +1 -2
  93. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +9 -1
  94. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -1
  95. package/dist/migrations/v2.0/delete-infrastructure-directory.js +66 -20
  96. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts +3 -0
  97. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts.map +1 -0
  98. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.js +110 -0
  99. package/dist/migrations/v2.0/index.d.ts +5 -3
  100. package/dist/migrations/v2.0/index.d.ts.map +1 -1
  101. package/dist/migrations/v2.0/index.js +88 -4869
  102. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +11 -1
  103. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -1
  104. package/dist/migrations/v2.0/merge-infrastructure-directory.js +17 -16
  105. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -1
  106. package/dist/migrations/v2.0/migrate-scopes.js +54 -30
  107. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -1
  108. package/dist/migrations/v2.0/migrate-workqueue-configs.js +140 -59
  109. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +3 -0
  110. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +1 -0
  111. package/dist/migrations/v2.1/add-explicit-correction-flags.js +234 -0
  112. package/dist/migrations/v2.1/index.d.ts +6 -0
  113. package/dist/migrations/v2.1/index.d.ts.map +1 -0
  114. package/dist/migrations/v2.1/index.js +218 -0
  115. package/dist/notification/index.js +1038 -163
  116. package/dist/scopes/index.d.ts +100 -8
  117. package/dist/scopes/index.js +22 -7
  118. package/dist/templates/charts-values/dependencies/values.override.yaml +4 -0
  119. package/dist/templates/charts-values/dependencies/values.yaml +83 -0
  120. package/dist/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
  121. package/dist/templates/charts-values/opencrvs-services/values.yaml +81 -0
  122. package/dist/templates/charts-values/traefik/values.override.yaml +4 -0
  123. package/dist/templates/charts-values/traefik/values.yaml +115 -0
  124. package/dist/templates/inventory/inventory.template.yml +100 -0
  125. package/dist/templates/inventory/production.example.yml +77 -0
  126. package/dist/templates/inventory/qa.example.yml +48 -0
  127. package/opencrvs-toolkit-2.0.0-rc.3ddb687.tgz +0 -0
  128. package/package.json +20 -2
  129. package/tsconfig.tsbuildinfo +1 -1
  130. package/opencrvs-toolkit-2.0.0-rc.3dce118.tgz +0 -0
@@ -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,8 +214,13 @@ __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,
220
+ V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS: () => V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS,
221
+ V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP: () => V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP,
222
+ V2_DEFAULT_MOCK_LOCATIONS: () => V2_DEFAULT_MOCK_LOCATIONS,
223
+ V2_DEFAULT_MOCK_LOCATIONS_MAP: () => V2_DEFAULT_MOCK_LOCATIONS_MAP,
216
224
  ValidationConfig: () => ValidationConfig,
217
225
  VerificationActionConfig: () => VerificationActionConfig,
218
226
  VerificationPageConfig: () => VerificationPageConfig,
@@ -234,6 +242,7 @@ __export(events_exports, {
234
242
  ageToDate: () => ageToDate,
235
243
  aggregateActionAnnotations: () => aggregateActionAnnotations,
236
244
  aggregateActionDeclarations: () => aggregateActionDeclarations,
245
+ always: () => always,
237
246
  alwaysTrue: () => alwaysTrue,
238
247
  and: () => and,
239
248
  annotationActions: () => annotationActions,
@@ -241,10 +250,12 @@ __export(events_exports, {
241
250
  applyDraftToEventIndex: () => applyDraftToEventIndex,
242
251
  areCertificateConditionsMet: () => areCertificateConditionsMet,
243
252
  areConditionsMet: () => areConditionsMet,
253
+ buildClientFunctionContext: () => buildClientFunctionContext,
244
254
  buildFormState: () => buildFormState,
245
255
  canAccessEventWithScope: () => canAccessEventWithScope,
246
256
  canAccessOtherUserWithScopes: () => canAccessOtherUserWithScopes,
247
257
  canAccessUserWithScope: () => canAccessUserWithScope,
258
+ compileClientFunction: () => compileClientFunction,
248
259
  compositeFieldTypes: () => compositeFieldTypes,
249
260
  createEmptyDraft: () => createEmptyDraft,
250
261
  createFieldConditionals: () => createFieldConditionals,
@@ -265,6 +276,7 @@ __export(events_exports, {
265
276
  defineWorkqueuesColumns: () => defineWorkqueuesColumns,
266
277
  deserializeQuery: () => deserializeQuery,
267
278
  errorMessages: () => errorMessages,
279
+ evaluate: () => evaluate,
268
280
  event: () => event,
269
281
  eventMetadataLabelMap: () => eventMetadataLabelMap,
270
282
  eventPayloadGenerator: () => eventPayloadGenerator,
@@ -277,6 +289,7 @@ __export(events_exports, {
277
289
  findActiveDraftForEvent: () => findActiveDraftForEvent,
278
290
  findAllFields: () => findAllFields,
279
291
  findLastAssignmentAction: () => findLastAssignmentAction,
292
+ findPendingCorrectionAction: () => findPendingCorrectionAction,
280
293
  findRecordActionPages: () => findRecordActionPages,
281
294
  flag: () => flag,
282
295
  flattenFieldReference: () => flattenFieldReference,
@@ -306,11 +319,11 @@ __export(events_exports, {
306
319
  getAllUniqueFields: () => getAllUniqueFields,
307
320
  getAnnotationFromDrafts: () => getAnnotationFromDrafts,
308
321
  getAssignedUserFromActions: () => getAssignedUserFromActions,
309
- getAssignedUserSignatureFromActions: () => getAssignedUserSignatureFromActions,
310
322
  getAssignmentStatus: () => getAssignmentStatus,
311
323
  getAvailableActionsForEvent: () => getAvailableActionsForEvent,
312
324
  getAvailableRolesForUserUpdatePayload: () => getAvailableRolesForUserUpdatePayload,
313
325
  getCompleteActionAnnotation: () => getCompleteActionAnnotation,
326
+ getCompleteActionContent: () => getCompleteActionContent,
314
327
  getCompleteActionDeclaration: () => getCompleteActionDeclaration,
315
328
  getCurrentEventState: () => getCurrentEventState,
316
329
  getCustomActionFields: () => getCustomActionFields,
@@ -319,6 +332,7 @@ __export(events_exports, {
319
332
  getDeclarationFields: () => getDeclarationFields,
320
333
  getDeclarationPages: () => getDeclarationPages,
321
334
  getEventConfigById: () => getEventConfigById,
335
+ getEventFlags: () => getEventFlags,
322
336
  getFilePathsFromEvent: () => getFilePathsFromEvent,
323
337
  getLocationHierarchy: () => getLocationHierarchy,
324
338
  getMixedPath: () => getMixedPath,
@@ -341,6 +355,7 @@ __export(events_exports, {
341
355
  isBulletListFieldType: () => isBulletListFieldType,
342
356
  isButtonFieldType: () => isButtonFieldType,
343
357
  isCheckboxFieldType: () => isCheckboxFieldType,
358
+ isCodeToEvaluate: () => isCodeToEvaluate,
344
359
  isConditionMet: () => isConditionMet,
345
360
  isCountryFieldType: () => isCountryFieldType,
346
361
  isCustomFieldType: () => isCustomFieldType,
@@ -381,6 +396,7 @@ __export(events_exports, {
381
396
  isPageVisible: () => isPageVisible,
382
397
  isParagraphFieldType: () => isParagraphFieldType,
383
398
  isPhoneFieldType: () => isPhoneFieldType,
399
+ isPotentialDuplicate: () => isPotentialDuplicate,
384
400
  isPrintButtonFieldType: () => isPrintButtonFieldType,
385
401
  isQrReaderFieldType: () => isQrReaderFieldType,
386
402
  isQueryParamReaderFieldType: () => isQueryParamReaderFieldType,
@@ -414,12 +430,15 @@ __export(events_exports, {
414
430
  plainDateToLocalDate: () => plainDateToLocalDate,
415
431
  precompileActionSchemas: () => precompileActionSchemas,
416
432
  resolveDateOfEvent: () => resolveDateOfEvent,
433
+ resolveEventCustomFlags: () => resolveEventCustomFlags,
417
434
  resolvePlaceOfEvent: () => resolvePlaceOfEvent,
435
+ runClientFunction: () => runClientFunction,
418
436
  runFieldValidations: () => runFieldValidations,
419
437
  runStructuralValidations: () => runStructuralValidations,
420
438
  safeUnion: () => safeUnion,
421
439
  status: () => status,
422
440
  timePeriodToDateRange: () => timePeriodToDateRange,
441
+ todayISO: () => todayISO,
423
442
  user: () => user,
424
443
  userCanAccessEventWithScopes: () => userCanAccessEventWithScopes,
425
444
  validate: () => validate,
@@ -463,6 +482,7 @@ var RecordScopeTypeV2 = z2.enum([
463
482
  "record.edit",
464
483
  "record.reject",
465
484
  "record.archive",
485
+ "record.unarchive",
466
486
  "record.review-duplicates",
467
487
  "record.register",
468
488
  "record.print-certified-copies",
@@ -502,11 +522,13 @@ var scopeOptionsPlaceEvent = z2.object({
502
522
  event: scopeByEvent,
503
523
  placeOfEvent: JurisdictionFilter.optional()
504
524
  }).describe("Options applicable to all record scopes.");
505
- var scopeOptionsDeclared = scopeOptionsPlaceEvent.extend({
525
+ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
526
+ notifiedIn: JurisdictionFilter.optional(),
527
+ notifiedBy: UserFilter.optional(),
506
528
  declaredIn: JurisdictionFilter.optional(),
507
529
  declaredBy: UserFilter.optional()
508
530
  }).describe("Options applicable to actions that may take place after DECLARE");
509
- var AllRecordScopeOptions = scopeOptionsDeclared.extend({
531
+ var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
510
532
  registeredIn: JurisdictionFilter.optional(),
511
533
  registeredBy: UserFilter.optional()
512
534
  }).describe(
@@ -544,6 +566,8 @@ var ResolvedScopeOptionsPlaceEvent = z2.object({
544
566
  "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
545
567
  );
546
568
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
569
+ notifiedIn: UUID.nullish(),
570
+ notifiedBy: z2.string().optional(),
547
571
  declaredIn: UUID.nullish(),
548
572
  declaredBy: z2.string().optional()
549
573
  }).describe(
@@ -564,6 +588,7 @@ var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
564
588
  "record.edit",
565
589
  "record.reject",
566
590
  "record.archive",
591
+ "record.unarchive",
567
592
  "record.review-duplicates",
568
593
  "record.register"
569
594
  ]);
@@ -589,7 +614,7 @@ var RecordScopeV2 = z2.discriminatedUnion("type", [
589
614
  }),
590
615
  z2.object({
591
616
  type: ScopesWithDeclaredOptions,
592
- options: scopeOptionsDeclared.optional()
617
+ options: scopeOptionsDeclaredOrNotified.optional()
593
618
  }),
594
619
  z2.object({
595
620
  type: ScopesWithFullOptions,
@@ -694,18 +719,27 @@ var unflattenScope = (input) => {
694
719
  return { type, options };
695
720
  };
696
721
  var EncodedScope = z2.string().brand("EncodedScope");
697
- var decodeScope = (query) => {
698
- const scope = qs.parse(query, {
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, {
699
728
  ignoreQueryPrefix: true,
700
729
  comma: true,
701
730
  allowDots: true
702
731
  });
703
732
  const unflattenedScope = unflattenScope(scope);
704
- return Scope.safeParse(unflattenedScope)?.data;
733
+ const result = Scope.safeParse(unflattenedScope)?.data;
734
+ decodedScopeCache.set(encodedScope, result);
735
+ return result;
705
736
  };
706
737
  var DEFAULT_SCOPE_OPTIONS = {
707
738
  placeOfEvent: JurisdictionFilter.enum.all,
708
- accessLevel: JurisdictionFilter.enum.all
739
+ accessLevel: JurisdictionFilter.enum.all,
740
+ notifiedIn: JurisdictionFilter.enum.all,
741
+ declaredIn: JurisdictionFilter.enum.all,
742
+ registeredIn: JurisdictionFilter.enum.all
709
743
  };
710
744
  function getAcceptedScopesByType({
711
745
  acceptedScopes,
@@ -741,6 +775,7 @@ var ActionType = {
741
775
  MARK_AS_DUPLICATE: "MARK_AS_DUPLICATE",
742
776
  MARK_AS_NOT_DUPLICATE: "MARK_AS_NOT_DUPLICATE",
743
777
  ARCHIVE: "ARCHIVE",
778
+ UNARCHIVE: "UNARCHIVE",
744
779
  // Record actions
745
780
  PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
746
781
  REQUEST_CORRECTION: "REQUEST_CORRECTION",
@@ -760,6 +795,7 @@ var ConfirmableActions = [
760
795
  ActionType.REGISTER,
761
796
  ActionType.REJECT,
762
797
  ActionType.ARCHIVE,
798
+ ActionType.UNARCHIVE,
763
799
  ActionType.PRINT_CERTIFICATE,
764
800
  ActionType.REQUEST_CORRECTION,
765
801
  ActionType.APPROVE_CORRECTION,
@@ -778,6 +814,7 @@ var ActionTypes = z4.enum([
778
814
  "MARK_AS_DUPLICATE",
779
815
  "MARK_AS_NOT_DUPLICATE",
780
816
  "ARCHIVE",
817
+ "UNARCHIVE",
781
818
  "PRINT_CERTIFICATE",
782
819
  "REQUEST_CORRECTION",
783
820
  "REJECT_CORRECTION",
@@ -821,6 +858,7 @@ var WorkqueueActionType = ActionTypes.extract([
821
858
  ActionType.REJECT,
822
859
  ActionType.MARK_AS_DUPLICATE,
823
860
  ActionType.ARCHIVE,
861
+ ActionType.UNARCHIVE,
824
862
  ActionType.PRINT_CERTIFICATE,
825
863
  ActionType.REQUEST_CORRECTION
826
864
  ]);
@@ -885,6 +923,7 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
885
923
  "event.actions.unassign.request",
886
924
  "event.actions.read.request",
887
925
  "event.actions.archive.request",
926
+ "event.actions.unarchive.request",
888
927
  "event.actions.reinstate.request",
889
928
  "event.actions.print_certificate.request",
890
929
  "event.actions.correction.request.request",
@@ -1078,7 +1117,10 @@ var ActionConditional = z7.discriminatedUnion("type", [
1078
1117
  ShowConditional,
1079
1118
  // Action can be shown to the user in the list but as disabled
1080
1119
  EnableConditional
1081
- ]);
1120
+ ]).meta({
1121
+ id: "ActionConditional",
1122
+ description: "Conditional gating whether an action is shown (SHOW) or enabled (ENABLE). When omitted from an action, the action is shown and enabled for everyone."
1123
+ });
1082
1124
  var DisplayOnReviewConditional = z7.object({
1083
1125
  type: z7.literal(ConditionalType.DISPLAY_ON_REVIEW),
1084
1126
  conditional: Conditional
@@ -1093,8 +1135,8 @@ var FieldConditional = z7.discriminatedUnion("type", [
1093
1135
  // Field output can be shown / hidden on the review page
1094
1136
  DisplayOnReviewConditional
1095
1137
  ]).meta({
1096
- description: "Field conditional configuration",
1097
- id: "FieldConditional"
1138
+ id: "FieldConditional",
1139
+ description: "Conditional gating whether a form field is shown (SHOW), enabled (ENABLE), or displayed on the review page (DISPLAY_ON_REVIEW). When omitted, the field is shown and enabled for everyone, and is displayed on review whenever it has a value."
1098
1140
  });
1099
1141
 
1100
1142
  // ../commons/src/events/FieldType.ts
@@ -1191,6 +1233,11 @@ var FieldTypesToHideInReview = [
1191
1233
  FieldType.ALPHA_PRINT_BUTTON,
1192
1234
  FieldType.ALPHA_HIDDEN
1193
1235
  ];
1236
+ var HiddenFieldTypes = [
1237
+ FieldType.HTTP,
1238
+ FieldType.QUERY_PARAM_READER,
1239
+ FieldType.ALPHA_HIDDEN
1240
+ ];
1194
1241
 
1195
1242
  // ../commons/src/events/FieldValue.ts
1196
1243
  var z12 = __toESM(require("zod/v4"));
@@ -1317,7 +1364,7 @@ function plainDateToLocalDate(date) {
1317
1364
  // ../commons/src/events/FieldValue.ts
1318
1365
  var TextValue = z12.string();
1319
1366
  var HiddenFieldValue = z12.string();
1320
- var NonEmptyTextValue = TextValue.min(1);
1367
+ var NonEmptyTextValue = z12.string().trim().min(1);
1321
1368
  var DateValue = z12.iso.date().describe("Date in the format YYYY-MM-DD");
1322
1369
  var AgeValue = z12.object({
1323
1370
  age: z12.number(),
@@ -1346,6 +1393,7 @@ var DateRangeFieldValue = z12.object({
1346
1393
  var EmailValue = z12.email();
1347
1394
  var CheckboxFieldValue = z12.boolean();
1348
1395
  var NumberFieldValue = z12.number();
1396
+ var SignatureFieldValue = FileFieldValue;
1349
1397
  var ButtonFieldValue = z12.number();
1350
1398
  var VerificationStatusValue = z12.enum([
1351
1399
  "verified",
@@ -1414,28 +1462,20 @@ function schemaPriority(schema) {
1414
1462
  return idx === -1 ? 9999 : idx;
1415
1463
  }
1416
1464
  function safeUnion(schemas) {
1465
+ const sortedSchemas = [...schemas].sort(
1466
+ (a, b) => schemaPriority(a) - schemaPriority(b)
1467
+ );
1417
1468
  return z12.any().superRefine((val, ctx) => {
1418
- const successful = schemas.filter((s) => s.safeParse(val).success);
1419
- if (successful.length === 1) {
1420
- return;
1421
- }
1422
- if (successful.length === 0) {
1423
- ctx.addIssue({
1424
- code: "invalid_type",
1425
- expected: "custom",
1426
- message: "Value does not match any schema"
1427
- });
1428
- return;
1429
- }
1430
- successful.sort((a, b) => schemaPriority(a) - schemaPriority(b));
1431
- const best = successful[0];
1432
- if (!best.safeParse(val).success) {
1433
- ctx.addIssue({
1434
- expected: "custom",
1435
- code: "invalid_type",
1436
- message: "Value did not match the best schema"
1437
- });
1469
+ for (const schema of sortedSchemas) {
1470
+ if (schema.safeParse(val).success) {
1471
+ return;
1472
+ }
1438
1473
  }
1474
+ ctx.addIssue({
1475
+ code: "invalid_type",
1476
+ expected: "custom",
1477
+ message: "Value does not match any schema"
1478
+ });
1439
1479
  }).meta({
1440
1480
  description: "Value that matches exactly one of the possible schema types (TextValue, DateValue, DateRangeFieldValue). The best matching schema is chosen by priority."
1441
1481
  });
@@ -1617,6 +1657,11 @@ var ArchiveAction = ActionBase.extend(
1617
1657
  content: ReasonContent
1618
1658
  }).shape
1619
1659
  );
1660
+ var UnarchiveAction = ActionBase.extend(
1661
+ z14.object({
1662
+ type: z14.literal(ActionType.UNARCHIVE)
1663
+ }).shape
1664
+ );
1620
1665
  var CreatedAction = ActionBase.extend(
1621
1666
  z14.object({
1622
1667
  type: z14.literal(ActionType.CREATE)
@@ -1652,8 +1697,9 @@ var RequestedCorrectionAction = ActionBase.extend(
1652
1697
  var ApprovedCorrectionAction = ActionBase.extend(
1653
1698
  z14.object({
1654
1699
  type: z14.literal(ActionType.APPROVE_CORRECTION),
1655
- requestId: z14.string()
1700
+ requestId: z14.string(),
1656
1701
  // TODO move into 'content' property
1702
+ content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
1657
1703
  }).shape
1658
1704
  );
1659
1705
  var RejectedCorrectionAction = ActionBase.extend(
@@ -1682,6 +1728,7 @@ var ActionDocument = z14.discriminatedUnion("type", [
1682
1728
  MarkNotDuplicateAction.meta({ id: "MarkNotDuplicateAction" }),
1683
1729
  MarkAsDuplicateAction.meta({ id: "MarkAsDuplicateAction" }),
1684
1730
  ArchiveAction.meta({ id: "ArchiveAction" }),
1731
+ UnarchiveAction.meta({ id: "UnarchiveAction" }),
1685
1732
  NotifiedAction.meta({ id: "NotifiedAction" }),
1686
1733
  RegisterAction.meta({ id: "RegisterAction" }),
1687
1734
  DeclareAction.meta({ id: "DeclareAction" }),
@@ -1745,6 +1792,9 @@ var FlagConfig = z15.object({
1745
1792
  "Indicates if this flag expects an action to be performed to be cleared."
1746
1793
  ),
1747
1794
  label: TranslationConfig.describe("Human readable label of the flag.")
1795
+ }).meta({
1796
+ id: "FlagConfig",
1797
+ description: "Configuration for a custom flag that can be added to or removed from records by event actions."
1748
1798
  });
1749
1799
  var ActionFlagConfig = z15.object({
1750
1800
  id: Flag,
@@ -1752,6 +1802,9 @@ var ActionFlagConfig = z15.object({
1752
1802
  conditional: Conditional.optional().describe(
1753
1803
  "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
1754
1804
  )
1805
+ }).meta({
1806
+ id: "ActionFlagConfig",
1807
+ description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
1755
1808
  });
1756
1809
 
1757
1810
  // ../commons/src/events/EventMetadata.ts
@@ -1773,8 +1826,7 @@ var ActionCreationMetadata = z16.object({
1773
1826
  ),
1774
1827
  createdByUserType: z16.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1775
1828
  acceptedAt: z16.iso.datetime().describe("Timestamp when the action request was accepted."),
1776
- createdByRole: z16.string().optional().describe("Role of the user at the time of action request creation."),
1777
- createdBySignature: z16.string().nullish().describe("Signature of the user who created the action request.")
1829
+ createdByRole: z16.string().optional().describe("Role of the user at the time of action request creation.")
1778
1830
  });
1779
1831
  var RegistrationCreationMetadata = ActionCreationMetadata.extend({
1780
1832
  registrationNumber: z16.string().describe(
@@ -1782,6 +1834,7 @@ var RegistrationCreationMetadata = ActionCreationMetadata.extend({
1782
1834
  )
1783
1835
  });
1784
1836
  var LegalStatuses = z16.object({
1837
+ [EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
1785
1838
  [EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
1786
1839
  [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
1787
1840
  });
@@ -1802,9 +1855,6 @@ var EventMetadata = z16.object({
1802
1855
  createdAtLocation: UUID.nullish().describe(
1803
1856
  "Location of the user who created the event."
1804
1857
  ),
1805
- createdBySignature: DocumentPath.nullish().describe(
1806
- "Signature of the user who created the event."
1807
- ),
1808
1858
  updatedAtLocation: UUID.nullish().describe(
1809
1859
  "Location of the user who last changed the status."
1810
1860
  ),
@@ -1926,6 +1976,8 @@ var eventMetadataLabelMap = {
1926
1976
  var EventMetadataDateFieldIdInput = z16.enum([
1927
1977
  "createdAt",
1928
1978
  "updatedAt",
1979
+ "legalStatuses.NOTIFIED.createdAt",
1980
+ "legalStatuses.NOTIFIED.acceptedAt",
1929
1981
  "legalStatuses.DECLARED.createdAt",
1930
1982
  "legalStatuses.DECLARED.acceptedAt",
1931
1983
  "legalStatuses.REGISTERED.createdAt",
@@ -1934,6 +1986,8 @@ var EventMetadataDateFieldIdInput = z16.enum([
1934
1986
  var EventMetadataDateFieldId = z16.enum([
1935
1987
  "event.createdAt",
1936
1988
  "event.updatedAt",
1989
+ "event.legalStatuses.NOTIFIED.createdAt",
1990
+ "event.legalStatuses.NOTIFIED.acceptedAt",
1937
1991
  "event.legalStatuses.DECLARED.createdAt",
1938
1992
  "event.legalStatuses.DECLARED.acceptedAt",
1939
1993
  "event.legalStatuses.REGISTERED.createdAt",
@@ -1993,7 +2047,8 @@ var Range = import_v4.z.object({
1993
2047
  });
1994
2048
  var ContainsFlags = import_v4.z.object({
1995
2049
  anyOf: import_v4.z.array(Flag).optional(),
1996
- noneOf: import_v4.z.array(Flag).optional()
2050
+ noneOf: import_v4.z.array(Flag).optional(),
2051
+ allOf: import_v4.z.array(Flag).optional()
1997
2052
  }).meta({
1998
2053
  id: "ContainsFlags"
1999
2054
  });
@@ -2179,14 +2234,34 @@ var FieldId = import_v43.default.string().superRefine((val, ctx) => {
2179
2234
  }
2180
2235
  }).describe("Unique identifier for the field");
2181
2236
  var FieldReference = import_v43.default.object({
2182
- $$field: FieldId,
2237
+ $$field: FieldId.describe("Id of the field to reference"),
2183
2238
  $$subfield: import_v43.default.array(import_v43.default.string()).optional().default([]).describe(
2184
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."
2185
2253
  )
2186
- }).describe("Reference to a field by its ID");
2254
+ }).describe("A context-only computation used as a field default value.");
2187
2255
  var ValidationConfig = import_v43.default.object({
2188
- validator: Conditional,
2189
- message: TranslationConfig
2256
+ validator: Conditional.describe(
2257
+ "Conditional expression that must hold for the field value to be considered valid."
2258
+ ),
2259
+ message: TranslationConfig.describe(
2260
+ "Error message displayed when the validator does not hold."
2261
+ )
2262
+ }).meta({
2263
+ id: "ValidationConfig",
2264
+ description: "Validation rule applied to a form field. The validator is a conditional expression that must hold for the field value to be considered valid."
2190
2265
  });
2191
2266
  var requiredSchema = import_v43.default.union([
2192
2267
  import_v43.default.boolean(),
@@ -2217,7 +2292,7 @@ var BaseField = import_v43.default.object({
2217
2292
  "Indicates whether the field can be modified during record correction."
2218
2293
  ),
2219
2294
  value: FieldReference.or(import_v43.default.array(FieldReference)).optional().describe(
2220
- "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."
2221
2296
  ),
2222
2297
  analytics: import_v43.default.boolean().default(false).optional().describe(
2223
2298
  "Indicates whether the field is included in analytics. When enabled, its value becomes available in the analytics dashboard."
@@ -2225,30 +2300,40 @@ var BaseField = import_v43.default.object({
2225
2300
  }).describe("Common properties shared across all field types.");
2226
2301
  var Divider = BaseField.extend({
2227
2302
  type: import_v43.default.literal(FieldType.DIVIDER)
2303
+ }).meta({
2304
+ description: "A horizontal line divider",
2305
+ id: "Divider"
2228
2306
  });
2229
2307
  var TextField = BaseField.extend({
2230
2308
  type: import_v43.default.literal(FieldType.TEXT),
2231
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
2309
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2232
2310
  configuration: import_v43.default.object({
2233
2311
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text"),
2234
2312
  type: import_v43.default.enum(["text", "password"]).optional(),
2235
2313
  prefix: TranslationConfig.optional(),
2236
2314
  postfix: TranslationConfig.optional()
2237
2315
  }).default({ type: "text" }).optional()
2238
- }).describe("Text input");
2316
+ }).meta({
2317
+ description: "A text input field",
2318
+ id: "TextField"
2319
+ });
2239
2320
  var NumberField = BaseField.extend({
2240
2321
  type: import_v43.default.literal(FieldType.NUMBER),
2241
- defaultValue: NumberFieldValue.optional(),
2322
+ defaultValue: NumberFieldValue.or(ComputedDefaultValue).optional(),
2242
2323
  configuration: import_v43.default.object({
2243
2324
  min: import_v43.default.number().optional().describe("Minimum value"),
2244
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"),
2245
2327
  prefix: TranslationConfig.optional(),
2246
2328
  postfix: TranslationConfig.optional()
2247
2329
  }).optional()
2248
- }).describe("Number input");
2330
+ }).meta({
2331
+ description: "A number input field",
2332
+ id: "NumberField"
2333
+ });
2249
2334
  var TextAreaField = BaseField.extend({
2250
2335
  type: import_v43.default.literal(FieldType.TEXTAREA),
2251
- defaultValue: NonEmptyTextValue.optional(),
2336
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2252
2337
  configuration: import_v43.default.object({
2253
2338
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text"),
2254
2339
  rows: import_v43.default.number().optional().describe("Number of visible text lines"),
@@ -2256,7 +2341,10 @@ var TextAreaField = BaseField.extend({
2256
2341
  prefix: TranslationConfig.optional(),
2257
2342
  postfix: TranslationConfig.optional()
2258
2343
  }).default({ rows: 4 }).optional()
2259
- }).describe("Multiline text input");
2344
+ }).meta({
2345
+ description: "A multiline text input",
2346
+ id: "TextAreaField"
2347
+ });
2260
2348
  var ImageMimeType = import_v43.default.enum([
2261
2349
  "image/png",
2262
2350
  "image/jpg",
@@ -2279,58 +2367,76 @@ var SignatureField = BaseField.extend({
2279
2367
  signaturePromptLabel: TranslationConfig.describe(
2280
2368
  "Title of the signature modal"
2281
2369
  ),
2282
- defaultValue: FieldValue.optional(),
2370
+ defaultValue: SignatureFieldValue.or(ComputedDefaultValue).optional(),
2283
2371
  configuration: import_v43.default.object({
2284
2372
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
2285
2373
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
2286
2374
  }).default({
2287
2375
  maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
2288
2376
  })
2289
- }).describe("Signature input field");
2377
+ }).meta({
2378
+ description: "A signature input field",
2379
+ id: "SignatureField"
2380
+ });
2290
2381
  var EmailField = BaseField.extend({
2291
2382
  type: import_v43.default.literal(FieldType.EMAIL),
2292
2383
  configuration: import_v43.default.object({
2293
2384
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text")
2294
2385
  }).default({ maxLength: 255 }).optional(),
2295
- defaultValue: NonEmptyTextValue.optional()
2386
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional()
2387
+ }).meta({
2388
+ description: "An email input field",
2389
+ id: "EmailField"
2296
2390
  });
2297
2391
  var DateField = BaseField.extend({
2298
2392
  type: import_v43.default.literal(FieldType.DATE),
2299
- 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)"),
2300
2394
  configuration: import_v43.default.object({
2301
2395
  notice: TranslationConfig.describe(
2302
2396
  "Text to display above the date input"
2303
2397
  ).optional()
2304
2398
  }).optional()
2305
- }).describe("A single date input (yyyy-MM-dd)");
2399
+ }).meta({
2400
+ description: "A date input (yyyy-MM-dd)",
2401
+ id: "DateField"
2402
+ });
2306
2403
  var AgeField = BaseField.extend({
2307
2404
  type: import_v43.default.literal(FieldType.AGE),
2308
- defaultValue: NumberFieldValue.optional(),
2405
+ defaultValue: NumberFieldValue.or(ComputedDefaultValue).optional(),
2309
2406
  configuration: import_v43.default.object({
2310
2407
  asOfDate: FieldReference,
2311
2408
  prefix: TranslationConfig.optional(),
2312
2409
  postfix: TranslationConfig.optional()
2313
2410
  })
2314
- }).describe("An age input field which uses the current date as the asOfDate");
2411
+ }).meta({
2412
+ description: "An age input field which uses the current date as the asOfDate",
2413
+ id: "AgeField"
2414
+ });
2315
2415
  var TimeField = BaseField.extend({
2316
2416
  type: import_v43.default.literal(FieldType.TIME),
2317
- 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)"),
2318
2418
  configuration: import_v43.default.object({
2319
2419
  use12HourFormat: import_v43.default.boolean().optional().describe("Whether to use 12-hour format"),
2320
2420
  notice: TranslationConfig.describe(
2321
2421
  "Text to display above the time input"
2322
2422
  ).optional()
2323
2423
  }).optional()
2324
- }).describe("A single date input (HH-mm)");
2424
+ }).meta({
2425
+ description: "A single time input (HH-mm)",
2426
+ id: "TimeField"
2427
+ });
2325
2428
  var DateRangeField = BaseField.extend({
2326
2429
  type: import_v43.default.literal(FieldType.DATE_RANGE),
2327
- defaultValue: DateRangeFieldValue.optional(),
2430
+ defaultValue: DateRangeFieldValue.or(ComputedDefaultValue).optional(),
2328
2431
  configuration: import_v43.default.object({
2329
2432
  notice: TranslationConfig.describe(
2330
2433
  "Text to display above the date input"
2331
2434
  ).optional()
2332
2435
  }).optional()
2333
- }).describe("A date range input ({ start: yyyy-MM-dd, end: yyyy-MM-dd })");
2436
+ }).meta({
2437
+ description: "A date range input ({ start: yyyy-MM-dd, end: yyyy-MM-dd })",
2438
+ id: "DateRangeField"
2439
+ });
2334
2440
  var HtmlFontVariant = import_v43.default.enum([
2335
2441
  "reg12",
2336
2442
  "reg14",
@@ -2374,21 +2480,33 @@ var ImageViewField = BaseField.extend({
2374
2480
  type: import_v43.default.literal(FieldType.IMAGE_VIEW),
2375
2481
  defaultValue: NonEmptyTextValue.optional(),
2376
2482
  configuration: ImageConfiguration
2377
- }).describe("A read-only image component for form pages");
2483
+ }).meta({
2484
+ description: "A read-only image component for form pages",
2485
+ id: "ImageViewField"
2486
+ });
2378
2487
  var Paragraph = BaseField.extend({
2379
2488
  type: import_v43.default.literal(FieldType.PARAGRAPH),
2380
2489
  configuration: ParagraphConfiguration
2381
- }).describe("A read-only HTML <p> paragraph");
2490
+ }).meta({
2491
+ description: "A read-only HTML <p> paragraph",
2492
+ id: "Paragraph"
2493
+ });
2382
2494
  var Heading = BaseField.extend({
2383
2495
  type: import_v43.default.literal(FieldType.HEADING),
2384
2496
  configuration: HeadingConfiguration
2385
- }).describe("A read-only heading component for form pages");
2497
+ }).meta({
2498
+ description: "A read-only heading component for form pages",
2499
+ id: "Heading"
2500
+ });
2386
2501
  var PageHeader = BaseField.extend({
2387
2502
  type: import_v43.default.literal(FieldType.PAGE_HEADER)
2388
- }).describe("A read-only header component for form pages");
2503
+ }).meta({
2504
+ description: "A read-only header component for form pages",
2505
+ id: "PageHeader"
2506
+ });
2389
2507
  var File = BaseField.extend({
2390
2508
  type: import_v43.default.literal(FieldType.FILE),
2391
- defaultValue: FileFieldValue.optional(),
2509
+ defaultValue: FileFieldValue.or(ComputedDefaultValue).optional(),
2392
2510
  configuration: import_v43.default.object({
2393
2511
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
2394
2512
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
@@ -2404,7 +2522,10 @@ var File = BaseField.extend({
2404
2522
  }).default({
2405
2523
  maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
2406
2524
  })
2407
- }).describe("File upload");
2525
+ }).meta({
2526
+ description: "A file upload field",
2527
+ id: "File"
2528
+ });
2408
2529
  var SelectOption = import_v43.default.object({
2409
2530
  value: import_v43.default.string().describe("The value of the option"),
2410
2531
  label: import_v43.default.union([import_v43.default.string(), TranslationConfig]).describe("The label of the option"),
@@ -2412,7 +2533,7 @@ var SelectOption = import_v43.default.object({
2412
2533
  });
2413
2534
  var NumberWithUnitField = BaseField.extend({
2414
2535
  type: import_v43.default.literal(FieldType.NUMBER_WITH_UNIT),
2415
- defaultValue: NumberWithUnitFieldValue.optional(),
2536
+ defaultValue: NumberWithUnitFieldValue.or(ComputedDefaultValue).optional(),
2416
2537
  options: import_v43.default.array(SelectOption).describe("A list of options for the unit select"),
2417
2538
  configuration: import_v43.default.object({
2418
2539
  min: import_v43.default.number().optional().describe("Minimum value of the number field"),
@@ -2421,17 +2542,23 @@ var NumberWithUnitField = BaseField.extend({
2421
2542
  "Placeholder for the number field"
2422
2543
  )
2423
2544
  }).optional()
2424
- }).describe("Number with unit input");
2545
+ }).meta({
2546
+ description: "A number with unit input field",
2547
+ id: "NumberWithUnitField"
2548
+ });
2425
2549
  var RadioGroup = BaseField.extend({
2426
2550
  type: import_v43.default.literal(FieldType.RADIO_GROUP),
2427
- defaultValue: TextValue.optional(),
2551
+ defaultValue: TextValue.or(ComputedDefaultValue).optional(),
2428
2552
  options: import_v43.default.array(SelectOption).describe("A list of options"),
2429
2553
  configuration: import_v43.default.object({
2430
2554
  styles: import_v43.default.object({
2431
2555
  size: import_v43.default.enum(["NORMAL", "LARGE"]).optional()
2432
2556
  }).optional()
2433
2557
  }).optional()
2434
- }).describe("Grouped radio options");
2558
+ }).meta({
2559
+ description: "A grouped radio button field",
2560
+ id: "RadioGroup"
2561
+ });
2435
2562
  var BulletList = BaseField.extend({
2436
2563
  type: import_v43.default.literal(FieldType.BULLET_LIST),
2437
2564
  items: import_v43.default.array(TranslationConfig).describe("A list of items"),
@@ -2440,10 +2567,13 @@ var BulletList = BaseField.extend({
2440
2567
  fontVariant: HtmlFontVariant.optional()
2441
2568
  }).optional()
2442
2569
  }).default({})
2443
- }).describe("A list of bullet points");
2570
+ }).meta({
2571
+ description: "A list of bullet points",
2572
+ id: "BulletList"
2573
+ });
2444
2574
  var Select = BaseField.extend({
2445
2575
  type: import_v43.default.literal(FieldType.SELECT),
2446
- defaultValue: TextValue.optional(),
2576
+ defaultValue: TextValue.or(ComputedDefaultValue).optional(),
2447
2577
  options: import_v43.default.array(SelectOption).describe("A list of options"),
2448
2578
  noOptionsMessage: TranslationConfig.optional().describe(
2449
2579
  `
@@ -2455,16 +2585,22 @@ var Select = BaseField.extend({
2455
2585
  { ..., defaultMessage: "'{input}' is not listed among the health facilities." }
2456
2586
  `
2457
2587
  )
2458
- }).describe("Select input");
2588
+ }).meta({
2589
+ description: "A select input field",
2590
+ id: "Select"
2591
+ });
2459
2592
  var SelectDateRangeOption = import_v43.default.object({
2460
2593
  value: SelectDateRangeValue.describe("The value of the option"),
2461
2594
  label: TranslationConfig.describe("The label of the option")
2462
2595
  });
2463
2596
  var SelectDateRangeField = BaseField.extend({
2464
2597
  type: import_v43.default.literal(FieldType.SELECT_DATE_RANGE),
2465
- defaultValue: SelectDateRangeValue.optional(),
2598
+ defaultValue: SelectDateRangeValue.or(ComputedDefaultValue).optional(),
2466
2599
  options: import_v43.default.array(SelectDateRangeOption).describe("A list of options")
2467
- }).describe("Select input with date range options");
2600
+ }).meta({
2601
+ description: "A date range selection field",
2602
+ id: "SelectDateRangeField"
2603
+ });
2468
2604
  var NameConfig = import_v43.default.object({
2469
2605
  firstname: import_v43.default.object({ required: requiredSchema, label: TranslationConfig.optional() }).optional(),
2470
2606
  middlename: import_v43.default.object({ required: requiredSchema, label: TranslationConfig.optional() }).optional(),
@@ -2476,7 +2612,7 @@ var NameField = BaseField.extend({
2476
2612
  firstname: SerializedUserField.or(NonEmptyTextValue).optional(),
2477
2613
  middlename: SerializedUserField.or(NonEmptyTextValue).optional(),
2478
2614
  surname: SerializedUserField.or(NonEmptyTextValue).optional()
2479
- }).optional(),
2615
+ }).or(ComputedDefaultValue).optional(),
2480
2616
  configuration: import_v43.default.object({
2481
2617
  name: NameConfig.default({
2482
2618
  firstname: { required: true },
@@ -2495,26 +2631,41 @@ var NameField = BaseField.extend({
2495
2631
  surname: { required: true }
2496
2632
  }
2497
2633
  }).optional()
2498
- }).describe("Name input field");
2634
+ }).meta({
2635
+ description: "A field for entering a persons name",
2636
+ id: "NameField"
2637
+ });
2499
2638
  var PhoneField = BaseField.extend({
2500
- defaultValue: NonEmptyTextValue.optional(),
2639
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2501
2640
  type: import_v43.default.literal(FieldType.PHONE)
2502
- }).describe("Phone input field");
2641
+ }).meta({
2642
+ description: "A field for entering a phone number",
2643
+ id: "PhoneField"
2644
+ });
2503
2645
  var IdField = BaseField.extend({
2504
- defaultValue: NonEmptyTextValue.optional(),
2646
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2505
2647
  type: import_v43.default.literal(FieldType.ID)
2506
- }).describe("ID input field");
2648
+ }).meta({
2649
+ description: "A field for entering an ID",
2650
+ id: "IdField"
2651
+ });
2507
2652
  var Checkbox = BaseField.extend({
2508
2653
  type: import_v43.default.literal(FieldType.CHECKBOX),
2509
- defaultValue: CheckboxFieldValue.default(false)
2510
- }).describe("Boolean checkbox field");
2654
+ defaultValue: CheckboxFieldValue.or(ComputedDefaultValue).default(false)
2655
+ }).meta({
2656
+ description: "A boolean checkbox field",
2657
+ id: "Checkbox"
2658
+ });
2511
2659
  var Country = BaseField.extend({
2512
2660
  type: import_v43.default.literal(FieldType.COUNTRY),
2513
- defaultValue: NonEmptyTextValue.optional(),
2661
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2514
2662
  optionOverrides: import_v43.default.array(SelectOption.omit({ label: true })).optional().describe(
2515
2663
  "Conditionals for specific countries. Countries not listed are always shown and enabled."
2516
2664
  )
2517
- }).describe("Country select field");
2665
+ }).meta({
2666
+ description: "A field for selecting a country",
2667
+ id: "Country"
2668
+ });
2518
2669
  var AllowedLocations = JurisdictionReference.optional().describe(
2519
2670
  "Limits which location options are selectable depending on user jurisdiction and location."
2520
2671
  );
@@ -2523,28 +2674,33 @@ var AdministrativeAreas = import_v43.default.enum([
2523
2674
  "HEALTH_FACILITY",
2524
2675
  "CRVS_OFFICE"
2525
2676
  ]);
2526
- var AdministrativeAreaConfiguration = import_v43.default.object({
2527
- partOf: FieldReference.optional().describe("Parent location"),
2528
- type: AdministrativeAreas,
2529
- allowedLocations: AllowedLocations
2530
- }).describe("Administrative area options");
2531
2677
  var AdministrativeAreaField = BaseField.extend({
2532
2678
  type: import_v43.default.literal(FieldType.ADMINISTRATIVE_AREA),
2533
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
2534
- configuration: AdministrativeAreaConfiguration
2535
- }).describe("Administrative area input field e.g. facility, office");
2679
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2680
+ configuration: import_v43.default.object({
2681
+ partOf: FieldReference.optional().describe("Parent location"),
2682
+ type: AdministrativeAreas,
2683
+ allowedLocations: AllowedLocations
2684
+ }).describe("Administrative area options")
2685
+ }).meta({
2686
+ description: "Administrative area input field",
2687
+ id: "AdministrativeAreaField"
2688
+ });
2536
2689
  var LocationInput = BaseField.extend({
2537
2690
  type: import_v43.default.literal(FieldType.LOCATION),
2538
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
2691
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2539
2692
  configuration: import_v43.default.object({
2540
2693
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
2541
2694
  allowedLocations: AllowedLocations
2542
2695
  }).optional()
2543
- }).describe("Input field for a location");
2696
+ }).meta({
2697
+ description: "A field for selecting a location",
2698
+ id: "LocationInput"
2699
+ });
2544
2700
  var FileUploadWithOptions = BaseField.extend({
2545
2701
  type: import_v43.default.literal(FieldType.FILE_WITH_OPTIONS),
2546
2702
  options: import_v43.default.array(SelectOption).describe("A list of options"),
2547
- defaultValue: FileFieldWithOptionValue.optional(),
2703
+ defaultValue: FileFieldWithOptionValue.or(ComputedDefaultValue).optional(),
2548
2704
  configuration: import_v43.default.object({
2549
2705
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
2550
2706
  maxImageSize: import_v43.default.object({
@@ -2554,15 +2710,18 @@ var FileUploadWithOptions = BaseField.extend({
2554
2710
  }).default({
2555
2711
  maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
2556
2712
  })
2713
+ }).meta({
2714
+ description: "A field for uploading files with file type options",
2715
+ id: "FileUploadWithOptions"
2557
2716
  });
2558
2717
  var Facility = BaseField.extend({
2559
2718
  type: import_v43.default.literal(FieldType.FACILITY),
2560
- defaultValue: NonEmptyTextValue.optional(),
2719
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2561
2720
  configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2562
2721
  }).describe("Input field for a facility");
2563
2722
  var Office = BaseField.extend({
2564
2723
  type: import_v43.default.literal(FieldType.OFFICE),
2565
- defaultValue: NonEmptyTextValue.optional(),
2724
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2566
2725
  configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2567
2726
  }).describe("Input field for an office");
2568
2727
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
@@ -2598,8 +2757,11 @@ var Address = BaseField.extend({
2598
2757
  ).optional(),
2599
2758
  allowedLocations: AllowedLocations
2600
2759
  }).optional(),
2601
- defaultValue: DefaultAddressFieldValue.optional()
2602
- }).describe("Address input field \u2013 a combination of location and text fields");
2760
+ defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
2761
+ }).meta({
2762
+ description: "Address input field \u2013 a combination of location and text fields",
2763
+ id: "Address"
2764
+ });
2603
2765
  var StaticDataEntry = import_v43.default.object({
2604
2766
  id: import_v43.default.string().describe("ID for the data entry."),
2605
2767
  label: TranslationConfig,
@@ -2614,7 +2776,10 @@ var DataField = BaseField.extend({
2614
2776
  subtitle: TranslationConfig.optional(),
2615
2777
  data: import_v43.default.array(DataEntry)
2616
2778
  })
2617
- }).describe("Data field for displaying read-only data");
2779
+ }).meta({
2780
+ description: "A field for displaying a table of read-only data",
2781
+ id: "DataField"
2782
+ });
2618
2783
  var ButtonSize = import_v43.default.enum(["small", "medium", "large"]);
2619
2784
  var ButtonType = import_v43.default.enum([
2620
2785
  "primary",
@@ -2639,13 +2804,19 @@ var ButtonConfiguration = import_v43.default.object({
2639
2804
  });
2640
2805
  var ButtonField = BaseField.extend({
2641
2806
  type: import_v43.default.literal(FieldType.BUTTON),
2642
- defaultValue: ButtonFieldValue.optional(),
2807
+ defaultValue: ButtonFieldValue.or(ComputedDefaultValue).optional(),
2643
2808
  configuration: ButtonConfiguration
2644
- }).describe("Generic button without any built-in functionality");
2809
+ }).meta({
2810
+ description: "A generic button that can be used to trigger an action",
2811
+ id: "ButtonField"
2812
+ });
2645
2813
  var FieldGroup = BaseField.extend({
2646
2814
  type: import_v43.default.literal(FieldType.FIELD_GROUP),
2647
2815
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
2648
2816
  fields: import_v43.default.lazy(() => import_v43.default.array(FieldConfig))
2817
+ }).meta({
2818
+ description: "A group of fields that are displayed together",
2819
+ id: "FieldGroup"
2649
2820
  });
2650
2821
  var AlphaPrintButton = BaseField.extend({
2651
2822
  type: import_v43.default.literal(FieldType.ALPHA_PRINT_BUTTON),
@@ -2655,10 +2826,13 @@ var AlphaPrintButton = BaseField.extend({
2655
2826
  "Label for the print button"
2656
2827
  )
2657
2828
  })
2658
- }).describe("Print button field for printing certificates");
2829
+ }).meta({
2830
+ description: "An experimental print button field for printing certificates during the declaration process",
2831
+ id: "AlphaPrintButton"
2832
+ });
2659
2833
  var HttpField = BaseField.extend({
2660
2834
  type: import_v43.default.literal(FieldType.HTTP),
2661
- defaultValue: HttpFieldValue.optional(),
2835
+ defaultValue: HttpFieldValue.or(ComputedDefaultValue).optional(),
2662
2836
  configuration: import_v43.default.object({
2663
2837
  trigger: FieldReference.optional().describe(
2664
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."
@@ -2671,20 +2845,30 @@ var HttpField = BaseField.extend({
2671
2845
  params: import_v43.default.record(import_v43.default.string(), import_v43.default.union([import_v43.default.string(), FieldReference])).optional(),
2672
2846
  timeout: import_v43.default.number().default(15e3).describe("Request timeout in milliseconds")
2673
2847
  })
2674
- }).describe("HTTP request function triggered by a button click or other event");
2848
+ }).meta({
2849
+ description: "Makes a background HTTP request to an external service and stores the response so other fields can use it. Has no visible UI \u2014 pair with LOADER to show request status.",
2850
+ id: "HttpField"
2851
+ });
2675
2852
  var AutocompleteField = BaseField.extend({
2676
2853
  type: import_v43.default.literal(FieldType.AUTOCOMPLETE),
2677
2854
  configuration: import_v43.default.object({
2678
- url: import_v43.default.string().describe("URL to fetch autocomplete suggestions from").optional(),
2855
+ url: import_v43.default.string().describe(
2856
+ "URL to fetch autocomplete suggestions from. This should be a country config server endpoint."
2857
+ ).optional(),
2679
2858
  method: import_v43.default.enum(["GET", "POST"]).default("GET").optional(),
2680
2859
  defaultOptions: import_v43.default.array(
2681
2860
  import_v43.default.object({
2682
2861
  label: import_v43.default.string(),
2683
2862
  value: import_v43.default.string()
2684
2863
  })
2685
- ).optional()
2864
+ ).optional().describe(
2865
+ "Manual entry is supported through configuration, allowing users to provide values not currently represented in the dataset."
2866
+ )
2686
2867
  })
2687
- }).describe("Autocomplete input field");
2868
+ }).meta({
2869
+ description: "Generic autocomplete component designed for use with large dictionary-based datasets. The component supports dynamic retrieval of options from configurable data sources and is intended for datasets that may contain tens or hundreds of thousands of records.",
2870
+ id: "AutocompleteField"
2871
+ });
2688
2872
  var SearchField = HttpField.extend({
2689
2873
  type: import_v43.default.literal(FieldType.SEARCH),
2690
2874
  configuration: SearchQuery.pick({
@@ -2717,6 +2901,9 @@ var SearchField = HttpField.extend({
2717
2901
  ok: TranslationConfig.optional()
2718
2902
  }).optional()
2719
2903
  })
2904
+ }).meta({
2905
+ description: "A search input field",
2906
+ id: "SearchField"
2720
2907
  });
2721
2908
  var LinkButtonField = BaseField.extend({
2722
2909
  type: import_v43.default.literal(FieldType.LINK_BUTTON),
@@ -2725,28 +2912,35 @@ var LinkButtonField = BaseField.extend({
2725
2912
  text: TranslationConfig.describe("Text to display on the button"),
2726
2913
  icon: import_v43.default.string().optional().describe("Icon for the button. You can find icons from OpenCRVS UI-Kit.")
2727
2914
  })
2728
- }).describe("Button that opens a link");
2915
+ }).meta({
2916
+ description: "A button that opens a URL link",
2917
+ id: "LinkButtonField"
2918
+ });
2729
2919
  var VerificationStatus = BaseField.extend({
2730
2920
  type: import_v43.default.literal(FieldType.VERIFICATION_STATUS),
2731
- defaultValue: VerificationStatusValue.optional(),
2921
+ defaultValue: VerificationStatusValue.or(ComputedDefaultValue).optional(),
2732
2922
  configuration: import_v43.default.object({
2733
2923
  status: TranslationConfig.describe("Text to display on the status pill."),
2734
2924
  description: TranslationConfig.describe(
2735
2925
  "Explaining text on the banner in form."
2736
2926
  )
2737
2927
  })
2928
+ }).meta({
2929
+ description: "Displays a verification state (e.g. ID verified / pending). Often paired with ID_READER \u2014 it can read its value off an ID_READER rather than holding its own.",
2930
+ id: "VerificationStatus"
2738
2931
  });
2739
2932
  var QueryParamReaderField = BaseField.extend({
2740
2933
  type: import_v43.default.literal(FieldType.QUERY_PARAM_READER),
2741
2934
  configuration: import_v43.default.object({
2742
2935
  pickParams: import_v43.default.array(import_v43.default.string()).describe("List of query parameters to read from the URL")
2743
2936
  })
2744
- }).describe(
2745
- "A field that maps URL query params into form values and clears them afterward"
2746
- );
2937
+ }).meta({
2938
+ description: "A field that maps URL query params into form values and clears them afterward",
2939
+ id: "QueryParamReaderField"
2940
+ });
2747
2941
  var QrReaderField = BaseField.extend({
2748
2942
  type: import_v43.default.literal(FieldType.QR_READER),
2749
- defaultValue: QrReaderFieldValue.optional(),
2943
+ defaultValue: QrReaderFieldValue.or(ComputedDefaultValue).optional(),
2750
2944
  configuration: import_v43.default.object({
2751
2945
  validator: import_v43.default.any().meta({
2752
2946
  description: "JSON Schema to validate the scanned QR code data against before populating the form fields.",
@@ -2754,21 +2948,27 @@ var QrReaderField = BaseField.extend({
2754
2948
  })
2755
2949
  }).optional()
2756
2950
  }).meta({
2757
- description: "Configuration for QR code reader field, including optional JSON Schema validator.",
2951
+ description: "QR code reader field, including optional JSON Schema validator.",
2758
2952
  id: "QrReaderField"
2759
2953
  });
2760
2954
  var IdReaderField = BaseField.extend({
2761
2955
  type: import_v43.default.literal(FieldType.ID_READER),
2762
- defaultValue: IdReaderFieldValue.optional(),
2956
+ defaultValue: IdReaderFieldValue.or(ComputedDefaultValue).optional(),
2763
2957
  methods: import_v43.default.array(
2764
2958
  import_v43.default.union([QrReaderField, LinkButtonField]).describe("Methods for reading an ID")
2765
2959
  )
2960
+ }).meta({
2961
+ description: "A wrapper around nested form fields, specifically QR_READER and LINK_BUTTON. It can hold the QR_READERs value.",
2962
+ id: "IdReaderField"
2766
2963
  });
2767
2964
  var CustomField = BaseField.extend({
2768
2965
  type: import_v43.default.literal(FieldType._EXPERIMENTAL_CUSTOM),
2769
2966
  defaultValue: CustomFieldValue.optional(),
2770
2967
  src: import_v43.default.string().describe("Module source path for the custom field component"),
2771
2968
  configuration: import_v43.default.unknown().optional()
2969
+ }).meta({
2970
+ description: "An expiremental custom field that is defined by a module source path",
2971
+ id: "CustomField"
2772
2972
  });
2773
2973
  var FieldStyleVariant = import_v43.default.enum(["default", "highlighted"]);
2774
2974
  var LoaderField = BaseField.extend({
@@ -2778,22 +2978,25 @@ var LoaderField = BaseField.extend({
2778
2978
  configuration: import_v43.default.object({
2779
2979
  text: TranslationConfig.describe("Display text above the loading spinner")
2780
2980
  })
2781
- }).describe(
2782
- "A non-interactive field that indicates an in progress operation in form"
2783
- );
2981
+ }).meta({
2982
+ description: "A non-interactive field that indicates an in progress operation in form",
2983
+ id: "LoaderField"
2984
+ });
2784
2985
  var HiddenField = BaseField.extend({
2785
2986
  type: import_v43.default.literal(FieldType.ALPHA_HIDDEN),
2786
2987
  required: import_v43.default.boolean().default(false).optional(),
2787
2988
  defaultValue: TextValue.optional()
2788
- }).describe(
2789
- "A non-interactive, hidden field that only hold a value in the form"
2790
- );
2989
+ }).meta({
2990
+ description: "A non-interactive, hidden field that only hold a value in the form",
2991
+ id: "HiddenField"
2992
+ });
2791
2993
  var UserRoleField = BaseField.extend({
2792
2994
  type: import_v43.default.literal(FieldType.USER_ROLE),
2793
2995
  defaultValue: TextValue.optional()
2794
- }).describe(
2795
- "A select dropdown that is automatically populated with available user roles"
2796
- );
2996
+ }).meta({
2997
+ description: "A select dropdown that is automatically populated with available user roles",
2998
+ id: "UserRoleField"
2999
+ });
2797
3000
  var FieldConfig = import_v43.default.discriminatedUnion("type", [
2798
3001
  FieldGroup,
2799
3002
  Address,
@@ -2892,16 +3095,19 @@ var VerificationPageConfig = FormPageConfig.extend({
2892
3095
  type: z21.literal(PageTypes.enum.VERIFICATION),
2893
3096
  actions: VerificationActionConfig
2894
3097
  });
2895
- var PageConfig = z21.discriminatedUnion("type", [
2896
- FormPageConfig,
2897
- VerificationPageConfig
2898
- ]);
3098
+ var PageConfig = z21.discriminatedUnion("type", [FormPageConfig, VerificationPageConfig]).meta({
3099
+ id: "PageConfig",
3100
+ description: "Configuration for a single page in a form. Either a form page with fields and a continue button, or a verification page with verify/cancel options."
3101
+ });
2899
3102
 
2900
3103
  // ../commons/src/events/FormConfig.ts
2901
3104
  var DeclarationFormConfig = z22.object({
2902
3105
  label: TranslationConfig.describe("Human readable description of the form"),
2903
3106
  pages: z22.array(FormPageConfig)
2904
- }).describe("Configuration of the declaration form.");
3107
+ }).meta({
3108
+ id: "DeclarationFormConfig",
3109
+ description: "Configuration of the declaration form."
3110
+ });
2905
3111
  var ActionFormConfig = z22.object({
2906
3112
  label: TranslationConfig.describe("Human readable description of the form"),
2907
3113
  pages: z22.array(PageConfig)
@@ -3001,6 +3207,9 @@ var DeduplicationConfig = z23.object({
3001
3207
  id: z23.string(),
3002
3208
  label: TranslationConfig,
3003
3209
  query: Clause
3210
+ }).meta({
3211
+ id: "DeduplicationConfig",
3212
+ description: "Configuration for duplicate detection on a declare or register action. The query is built from fuzzy / strict / date-range matchers combined with and/or/not."
3004
3213
  });
3005
3214
 
3006
3215
  // ../commons/src/events/ActionConfig.ts
@@ -3038,6 +3247,57 @@ var ReadActionConfig = ActionConfigBase.extend(
3038
3247
  conditionals: z24.never().optional().describe("Read-action can not be disabled or hidden with conditionals.")
3039
3248
  }).shape
3040
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
+ );
3041
3301
  var DeclareConfig = DeclarationActionBase.extend(
3042
3302
  z24.object({
3043
3303
  type: z24.literal(ActionType.DECLARE),
@@ -3062,6 +3322,11 @@ var ArchiveConfig = ActionConfigBase.extend(
3062
3322
  type: z24.literal(ActionType.ARCHIVE)
3063
3323
  }).shape
3064
3324
  );
3325
+ var UnarchiveConfig = ActionConfigBase.extend(
3326
+ z24.object({
3327
+ type: z24.literal(ActionType.UNARCHIVE)
3328
+ }).shape
3329
+ );
3065
3330
  var EditActionConfig = ActionConfigBase.extend(
3066
3331
  z24.object({
3067
3332
  type: z24.literal(ActionType.EDIT),
@@ -3100,7 +3365,17 @@ var RequestCorrectionConfig = ActionConfigBase.extend(
3100
3365
  correctionForm: ActionFormConfig
3101
3366
  }).shape
3102
3367
  );
3103
- var CustomActionConfig = ActionConfigBase.merge(
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(
3104
3379
  z24.object({
3105
3380
  type: z24.literal(ActionType.CUSTOM),
3106
3381
  customActionType: z24.string().describe("Type identifier of the custom action."),
@@ -3111,24 +3386,89 @@ var CustomActionConfig = ActionConfigBase.merge(
3111
3386
  auditHistoryLabel: TranslationConfig.describe(
3112
3387
  'The label to show in audit history for this action. For example "Approved".'
3113
3388
  )
3114
- })
3389
+ }).shape
3115
3390
  );
3116
3391
  var ActionConfig = z24.discriminatedUnion("type", [
3117
3392
  /*
3118
3393
  * OpenAPI references are defined here so our generated OpenAPI spec knows to reuse the models
3119
3394
  * and treat them as "models" instead of duplicating the data structure in each endpoint.
3120
3395
  */
3121
- ReadActionConfig.meta({ id: "ReadActionConfig" }),
3122
- DeclareConfig.meta({ id: "DeclareActionConfig" }),
3123
- RejectConfig.meta({ id: "RejectActionConfig" }),
3124
- RegisterConfig.meta({ id: "RegisterActionConfig" }),
3396
+ ReadActionConfig.meta({
3397
+ id: "ReadActionConfig",
3398
+ description: "Configuration for the read action \u2014 defines the record-tab content displayed on the event overview page."
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
+ }),
3416
+ DeclareConfig.meta({
3417
+ id: "DeclareActionConfig",
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."
3431
+ }),
3432
+ RejectConfig.meta({
3433
+ id: "RejectActionConfig",
3434
+ description: "Configuration for rejecting a record before registration."
3435
+ }),
3436
+ RegisterConfig.meta({
3437
+ id: "RegisterActionConfig",
3438
+ description: "Configuration for registering a record."
3439
+ }),
3125
3440
  PrintCertificateActionConfig.meta({
3126
- id: "PrintCertificateActionConfig"
3441
+ id: "PrintCertificateActionConfig",
3442
+ description: "Configuration for printing a certificate of a registered record."
3443
+ }),
3444
+ RequestCorrectionConfig.meta({
3445
+ id: "RequestCorrectionActionConfig",
3446
+ description: "Configuration for requesting a correction on a registered record."
3447
+ }),
3448
+ ApproveCorrectionConfig.meta({
3449
+ id: "ApproveCorrectionActionConfig",
3450
+ description: "Configuration for approving a requested correction."
3127
3451
  }),
3128
- RequestCorrectionConfig.meta({ id: "RequestCorrectionActionConfig" }),
3129
- EditActionConfig.meta({ id: "EditActionConfig" }),
3130
- ArchiveConfig.meta({ id: "ArchiveActionConfig" }),
3131
- CustomActionConfig.meta({ id: "CustomActionConfig" })
3452
+ RejectCorrectionConfig.meta({
3453
+ id: "RejectCorrectionActionConfig",
3454
+ description: "Configuration for rejecting a requested correction."
3455
+ }),
3456
+ EditActionConfig.meta({
3457
+ id: "EditActionConfig",
3458
+ description: "Configuration for editing a record before registration."
3459
+ }),
3460
+ ArchiveConfig.meta({
3461
+ id: "ArchiveActionConfig",
3462
+ description: "Configuration for archiving a record."
3463
+ }),
3464
+ UnarchiveConfig.meta({
3465
+ id: "UnarchiveActionConfig",
3466
+ description: "Configuration for unarchiving a record."
3467
+ }),
3468
+ CustomActionConfig.meta({
3469
+ id: "CustomActionConfig",
3470
+ description: "Configuration for a country-defined custom action. An event may include any number of these."
3471
+ })
3132
3472
  ]).describe(
3133
3473
  "Configuration of an action available for an event. Data collected depends on the action type and is accessible through the annotation property in ActionDocument."
3134
3474
  ).meta({ id: "ActionConfig" });
@@ -3204,7 +3544,10 @@ var Field = BaseField2.extend({
3204
3544
  }).describe("Custom field defined for the summary view.");
3205
3545
  var SummaryConfig = z27.object({
3206
3546
  fields: z27.array(z27.union([Field, ReferenceField])).describe("Fields displayed in the event summary view.")
3207
- }).describe("Configuration of the event summary section.");
3547
+ }).meta({
3548
+ id: "SummaryConfig",
3549
+ description: "Configuration of the event overview page. Defines which declaration fields appear in the record summary, optionally with custom labels, empty-value messages, and templated values."
3550
+ });
3208
3551
 
3209
3552
  // ../commons/src/events/AdvancedSearchConfig.ts
3210
3553
  var z28 = __toESM(require("zod/v4"));
@@ -3275,6 +3618,9 @@ var BaseField3 = z28.object({
3275
3618
  ),
3276
3619
  validations: z28.array(ValidationConfig).optional().describe(
3277
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.`
3278
3624
  )
3279
3625
  });
3280
3626
  var SearchQueryParams = z28.object({
@@ -3328,6 +3674,9 @@ var AdvancedSearchField = z28.discriminatedUnion("fieldType", [FieldConfigSchema
3328
3674
  var AdvancedSearchConfig = z28.object({
3329
3675
  title: TranslationConfig.describe("Advanced search tab title"),
3330
3676
  fields: z28.array(AdvancedSearchField).describe("Advanced search fields within the tab.")
3677
+ }).meta({
3678
+ id: "AdvancedSearchConfig",
3679
+ description: "Configuration of one advanced search tab. Each tab has a title and a list of searchable fields \u2014 either declaration fields (via `field()`) or event metadata (via `event()`)."
3331
3680
  });
3332
3681
 
3333
3682
  // ../commons/src/events/utils.ts
@@ -3346,9 +3695,11 @@ var z30 = __toESM(require("zod/v4"));
3346
3695
  var z29 = __toESM(require("zod/v4"));
3347
3696
  function getDynamicNameValue(field3) {
3348
3697
  const nameConfiguration = field3.configuration?.name;
3698
+ const firstnameRequired = nameConfiguration?.firstname?.required ?? field3.required;
3699
+ const surnameRequired = nameConfiguration?.surname?.required ?? field3.required;
3349
3700
  return z29.object({
3350
- firstname: nameConfiguration?.firstname?.required ? NonEmptyTextValue : TextValue,
3351
- surname: nameConfiguration?.surname?.required ? NonEmptyTextValue : TextValue,
3701
+ firstname: firstnameRequired ? NonEmptyTextValue : TextValue,
3702
+ surname: surnameRequired ? NonEmptyTextValue : TextValue,
3352
3703
  middlename: nameConfiguration?.middlename?.required ? NonEmptyTextValue : TextValue.optional()
3353
3704
  });
3354
3705
  }
@@ -3695,7 +4046,7 @@ var isHiddenFieldType = (field3) => {
3695
4046
  return field3.config.type === FieldType.ALPHA_HIDDEN;
3696
4047
  };
3697
4048
  var isNonInteractiveFieldType = (field3) => {
3698
- 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.HTTP || field3.type === FieldType.LINK_BUTTON || field3.type === FieldType.QUERY_PARAM_READER || field3.type === FieldType.LOADER;
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;
3699
4050
  };
3700
4051
 
3701
4052
  // ../commons/src/conditionals/validate.ts
@@ -3731,7 +4082,37 @@ function resolveDataPath(rootData, dataPath, instancePath) {
3731
4082
  }
3732
4083
  return current;
3733
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
+ }
3734
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
+ }
3735
4116
  ajv.addKeyword({
3736
4117
  keyword: "daysFromDate",
3737
4118
  type: "string",
@@ -3776,7 +4157,7 @@ ajv.addKeyword({
3776
4157
  $data: true,
3777
4158
  errors: true,
3778
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.
3779
- validate(schema, data, _2, dataContext) {
4160
+ validate(_schema, data, _2, dataContext) {
3780
4161
  const locationIdInput = data;
3781
4162
  const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
3782
4163
  return locations.some((location) => location.id === locationIdInput);
@@ -3804,6 +4185,26 @@ function precompileActionSchemas(eventConfigurations) {
3804
4185
  function isAgeValue(value) {
3805
4186
  return typeof value === "object" && value !== null && "age" in value && typeof value.age === "number";
3806
4187
  }
4188
+ function mergeWithBaseFormState(values, context) {
4189
+ return { ...context.baseFormState, ...values };
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
+ });
3807
4208
  function validate(schema, data) {
3808
4209
  const validator = ajv.getSchema(schema.$id) || ajv.compile(schema);
3809
4210
  if ("$form" in data) {
@@ -3840,17 +4241,14 @@ function isOnline() {
3840
4241
  }
3841
4242
  return true;
3842
4243
  }
3843
- function isConditionMet(conditional, values, context, eventIndex) {
3844
- return validate(conditional, {
3845
- $form: values,
3846
- $now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" }),
3847
- $online: isOnline(),
3848
- $user: context.user,
3849
- $leafAdminStructureLocationIds: context.leafAdminStructureLocationIds ?? [],
3850
- $flags: eventIndex?.flags ?? [],
3851
- $status: eventIndex?.status,
3852
- $event: context.event
3853
- });
4244
+ function isConditionMet(conditional, values, context) {
4245
+ return validate(
4246
+ conditional,
4247
+ buildClientFunctionContext({
4248
+ form: mergeWithBaseFormState(values, context),
4249
+ validatorContext: context
4250
+ })
4251
+ );
3854
4252
  }
3855
4253
  function getConditionalActionsForField(field3, values) {
3856
4254
  if (!field3.conditionals) {
@@ -3858,9 +4256,9 @@ function getConditionalActionsForField(field3, values) {
3858
4256
  }
3859
4257
  return field3.conditionals.filter((conditional) => validate(conditional.conditional, values)).map((conditional) => conditional.type);
3860
4258
  }
3861
- function areConditionsMet(conditions, values, context, event2) {
4259
+ function areConditionsMet(conditions, values, context, _event) {
3862
4260
  return conditions.every(
3863
- (condition) => isConditionMet(condition.conditional, values, context, event2)
4261
+ (condition) => isConditionMet(condition.conditional, values, context)
3864
4262
  );
3865
4263
  }
3866
4264
  function isFieldConditionMet(field3, form, conditionalType, context) {
@@ -3870,14 +4268,13 @@ function isFieldConditionMet(field3, form, conditionalType, context) {
3870
4268
  if (!hasRule) {
3871
4269
  return true;
3872
4270
  }
3873
- const validConditionals = getConditionalActionsForField(field3, {
3874
- $form: form,
3875
- $now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" }),
3876
- $online: isOnline(),
3877
- $user: context.user,
3878
- $leafAdminStructureLocationIds: context.leafAdminStructureLocationIds ?? [],
3879
- $event: context.event
3880
- });
4271
+ const validConditionals = getConditionalActionsForField(
4272
+ field3,
4273
+ buildClientFunctionContext({
4274
+ form: mergeWithBaseFormState(form, context),
4275
+ validatorContext: context
4276
+ })
4277
+ );
3881
4278
  return validConditionals.includes(conditionalType);
3882
4279
  }
3883
4280
  function isFieldVisible(field3, form, context) {
@@ -3903,7 +4300,14 @@ function isActionConditionMet(actionConfig, event2, context, conditionalType) {
3903
4300
  if (!rule) {
3904
4301
  return true;
3905
4302
  }
3906
- return isConditionMet(rule.conditional, event2.declaration, context, event2);
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
+ });
3907
4311
  }
3908
4312
  function isActionEnabled(actionConfig, event2, context) {
3909
4313
  return isActionConditionMet(
@@ -4062,19 +4466,10 @@ function runFieldValidations({
4062
4466
  if (!isFieldVisible(field3.config, form, context)) {
4063
4467
  return [];
4064
4468
  }
4065
- const conditionalParameters = {
4066
- $form: form,
4067
- $now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" }),
4068
- /**
4069
- * In real use cases, there can be hundreds of thousands of locations.
4070
- * Make sure that the context contains only the locations that are needed for validation.
4071
- * E.g. if the user is a leaf admin, only the leaf locations under their admin structure are needed.
4072
- * Loading few megabytes of locations to memory just for validation is not efficient and will choke the application.
4073
- */
4074
- $leafAdminStructureLocationIds: context.leafAdminStructureLocationIds ?? [],
4075
- $online: isOnline(),
4076
- $user: context.user
4077
- };
4469
+ const conditionalParameters = buildClientFunctionContext({
4470
+ form: mergeWithBaseFormState(form, context),
4471
+ validatorContext: context
4472
+ });
4078
4473
  if (isFieldGroupFieldType(field3)) {
4079
4474
  const subfieldErrors = buildFormState(
4080
4475
  field3.config.fields,
@@ -4213,16 +4608,13 @@ function getActionConfig({
4213
4608
  actionType,
4214
4609
  customActionType
4215
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
+ }
4216
4614
  return eventConfiguration.actions.find((a) => {
4217
4615
  if (a.type === ActionType.CUSTOM && customActionType) {
4218
4616
  return a.customActionType === customActionType;
4219
4617
  }
4220
- if (actionType === ActionType.NOTIFY) {
4221
- return a.type === ActionType.DECLARE;
4222
- }
4223
- if (actionType === ActionType.APPROVE_CORRECTION || actionType === ActionType.REJECT_CORRECTION) {
4224
- return a.type === ActionType.REQUEST_CORRECTION;
4225
- }
4226
4618
  return a.type === actionType;
4227
4619
  });
4228
4620
  }
@@ -4256,7 +4648,7 @@ var getActionAnnotationFields = (actionConfig) => {
4256
4648
  if (actionConfig.type === ActionType.CUSTOM) {
4257
4649
  return actionConfig.form;
4258
4650
  }
4259
- if ("review" in actionConfig) {
4651
+ if ("review" in actionConfig && actionConfig.review != null) {
4260
4652
  return actionConfig.review.fields;
4261
4653
  }
4262
4654
  return [];
@@ -4307,17 +4699,16 @@ function isPageVisible(page, formValues, context) {
4307
4699
  }
4308
4700
  return isConditionMet(page.conditional, formValues, context);
4309
4701
  }
4310
- function omitHiddenFields(fields, formValues, validatorContext, includeHiddenFieldsWithNullValues = false, declarationContext) {
4702
+ function omitHiddenFields(fields, formValues, validatorContext, includeHiddenFieldsWithNullValues = false) {
4311
4703
  const base = (0, import_lodash.cloneDeep)(formValues);
4312
4704
  function fn(prevVisibilityContext) {
4313
- const visibilityForm = declarationContext ? { ...declarationContext, ...prevVisibilityContext } : prevVisibilityContext;
4314
4705
  const cleaned = (0, import_lodash.omitBy)(base, (value, fieldId) => {
4315
4706
  const fieldConfig = fields.filter((f) => f.id === fieldId);
4316
4707
  if (!fieldConfig.length) {
4317
4708
  return false;
4318
4709
  }
4319
4710
  const isHidden = fieldConfig.every(
4320
- (f) => !isFieldVisible(f, visibilityForm, validatorContext)
4711
+ (f) => !isFieldVisible(f, prevVisibilityContext, validatorContext)
4321
4712
  );
4322
4713
  if (!isHidden) {
4323
4714
  return false;
@@ -4335,7 +4726,7 @@ function omitHiddenPaginatedFields(formConfig, values, validatorContext, include
4335
4726
  const visibleFields = formConfig.pages.filter((p) => isPageVisible(p, values, validatorContext)).flatMap((p) => p.fields);
4336
4727
  const hiddenFields = formConfig.pages.filter((p) => !isPageVisible(p, values, validatorContext)).flatMap((p) => p.fields);
4337
4728
  const valuesExceptHiddenPage = (0, import_lodash.omitBy)(values, (_2, fieldId) => {
4338
- return hiddenFields.some((f) => f.id === fieldId);
4729
+ return hiddenFields.some((f) => f.id === fieldId) && !visibleFields.some((f) => f.id === fieldId);
4339
4730
  });
4340
4731
  return omitHiddenFields(
4341
4732
  visibleFields,
@@ -4382,13 +4773,10 @@ function getVisibleVerificationPageIds(pages, annotation, context) {
4382
4773
  }
4383
4774
  function omitHiddenAnnotationFields(actionConfig, declaration, annotation, context) {
4384
4775
  const annotationFields = getActionAnnotationFields(actionConfig);
4385
- return omitHiddenFields(
4386
- annotationFields,
4387
- annotation,
4388
- context,
4389
- false,
4390
- declaration
4391
- );
4776
+ return omitHiddenFields(annotationFields, annotation, {
4777
+ ...context,
4778
+ baseFormState: declaration
4779
+ });
4392
4780
  }
4393
4781
  function deepMerge(currentDocument, actionDocument) {
4394
4782
  const currentDocumentClone = (0, import_lodash.cloneDeep)(currentDocument);
@@ -4562,19 +4950,32 @@ function getPendingAction(actions) {
4562
4950
  }
4563
4951
  return pendingActions[0];
4564
4952
  }
4565
- function getCompleteActionAnnotation(annotation, event2, action) {
4953
+ function getCompleteActionAnnotation(event2, action) {
4566
4954
  if (action.originalActionId) {
4567
4955
  const originalAction = event2.actions.find(
4568
4956
  ({ id }) => id === action.originalActionId
4569
4957
  );
4570
4958
  if (originalAction?.status === ActionStatus.Requested) {
4571
- return deepMerge(
4572
- deepMerge(annotation, originalAction.annotation ?? {}),
4573
- action.annotation ?? {}
4574
- );
4959
+ return deepMerge(originalAction.annotation ?? {}, action.annotation ?? {});
4575
4960
  }
4576
4961
  }
4577
- return deepMerge(annotation, action.annotation ?? {});
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;
4578
4979
  }
4579
4980
  function getCompleteActionDeclaration(declaration, event2, action) {
4580
4981
  if (action.originalActionId) {
@@ -4594,7 +4995,7 @@ function getAcceptedActions(event2) {
4594
4995
  return event2.actions.filter(isAcceptedAction).map((action) => ({
4595
4996
  ...action,
4596
4997
  declaration: getCompleteActionDeclaration({}, event2, action),
4597
- annotation: getCompleteActionAnnotation({}, event2, action)
4998
+ annotation: getCompleteActionAnnotation(event2, action)
4598
4999
  }));
4599
5000
  }
4600
5001
  var EXCLUDED_ACTIONS = [
@@ -4682,6 +5083,9 @@ function not(condition) {
4682
5083
  function never2() {
4683
5084
  return not(alwaysTrue());
4684
5085
  }
5086
+ function always() {
5087
+ return defineConditional(alwaysTrue());
5088
+ }
4685
5089
  function jsonFieldPath(field3) {
4686
5090
  return [field3.$$field, ...field3.$$subfield].join("/");
4687
5091
  }
@@ -5229,7 +5633,54 @@ function createFieldConditionals(fieldId) {
5229
5633
  }
5230
5634
  },
5231
5635
  required: [fieldId]
5232
- })
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
+ }
5233
5684
  };
5234
5685
  }
5235
5686
 
@@ -5317,7 +5768,7 @@ function validateActionFlags(event2, ctx) {
5317
5768
  const isInherentFlag = (value) => Object.values(InherentFlags).includes(value);
5318
5769
  const configuredFlagIds = event2.flags.map((flag2) => flag2.id);
5319
5770
  const actionFlagIds = event2.actions.flatMap(
5320
- (action) => action.flags.map((flag2) => flag2.id)
5771
+ (action) => (action.flags ?? []).map((flag2) => flag2.id)
5321
5772
  );
5322
5773
  for (const actionFlagId of actionFlagIds) {
5323
5774
  const isConfigured = configuredFlagIds.includes(actionFlagId);
@@ -5377,7 +5828,7 @@ var _EventConfigBase = z33.object({
5377
5828
  ),
5378
5829
  label: TranslationConfig.describe("Human-readable label for the event type."),
5379
5830
  actions: z33.array(ActionConfig).describe(
5380
- "Configuration of system-defined actions associated with the event."
5831
+ "Configuration of core and custom actions associated with the event."
5381
5832
  ),
5382
5833
  actionOrder: z33.array(z33.string()).optional().describe(
5383
5834
  "Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
@@ -5389,7 +5840,7 @@ var _EventConfigBase = z33.object({
5389
5840
  "Configuration of fields available in the advanced search feature."
5390
5841
  ),
5391
5842
  flags: z33.array(FlagConfig).optional().default([]).describe(
5392
- "Configuration of flags associated with the actions of this event type."
5843
+ "Configuration of custom flags associated with the actions of this event type."
5393
5844
  ),
5394
5845
  analytics: z33.boolean().optional().default(true).describe(
5395
5846
  "Indicates whether the records of this event type are included in analytics"
@@ -5402,8 +5853,9 @@ var EventConfig = _EventConfigBase.superRefine((event2, ctx) => {
5402
5853
  validateActionFlags(event2, ctx);
5403
5854
  validateActionOrder(event2, ctx);
5404
5855
  }).meta({
5405
- id: "EventConfig"
5406
- }).describe("Configuration defining an event type.");
5856
+ id: "EventConfig",
5857
+ description: "Configuration defining an event type registered in OpenCRVS (for example birth or death)."
5858
+ });
5407
5859
 
5408
5860
  // ../commons/src/events/EventConfigInput.ts
5409
5861
  var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
@@ -5626,6 +6078,9 @@ var WorkqueueColumnValue = z34.object({
5626
6078
  var WorkqueueColumn = z34.object({
5627
6079
  label: TranslationConfig,
5628
6080
  value: WorkqueueColumnValue
6081
+ }).meta({
6082
+ id: "WorkqueueColumn",
6083
+ description: "Configuration for a single workqueue column. The value references an event metadata key (e.g. `dateOfEvent`, `status`, `trackingId`)."
5629
6084
  });
5630
6085
  function defineWorkqueuesColumns(workqueueColumns) {
5631
6086
  return workqueueColumns.map(
@@ -5828,18 +6283,11 @@ var WorkqueueConfigWithoutQuery = WorkqueueConfig.omit({
5828
6283
  query: true,
5829
6284
  columns: true
5830
6285
  });
5831
- var WorkqueueConfigInput = z37.object({
5832
- slug: z37.string().describe("Determines the url of the workqueue."),
5833
- name: TranslationConfig.describe(
5834
- "Title of the workflow (both in navigation and on the page)"
5835
- ),
5836
- query: CountryConfigQueryInputType,
5837
- action: z37.object({ type: WorkqueueActionType }).optional().describe(
5838
- "Workqueue call-to-action button configuration. This determines the quick action button shown on each event card and the action taken when the button is clicked."
5839
- ),
5840
- columns: z37.array(WorkqueueColumn).default(mandatoryColumns),
5841
- icon: AvailableIcons,
5842
- emptyMessage: TranslationConfig.optional()
6286
+ var WorkqueueConfigInput = WorkqueueConfig.extend({
6287
+ query: CountryConfigQueryInputType
6288
+ }).meta({
6289
+ id: "WorkqueueConfig",
6290
+ description: "Configuration for a single workqueue. Defines the filter applied to the event index, the quick-action button, the columns shown on each row, and the message rendered when the queue is empty."
5843
6291
  });
5844
6292
  function defineWorkqueue(workqueueInput) {
5845
6293
  const queryInput = workqueueInput.query;
@@ -5900,6 +6348,11 @@ var BaseActionInput = z38.object({
5900
6348
  originalActionId: UUID.optional(),
5901
6349
  // should not be part of base action.
5902
6350
  keepAssignment: z38.boolean().optional(),
6351
+ keepAssignmentIfAccepted: z38.boolean().optional(),
6352
+ keepAssignmentIfRejected: z38.boolean().optional(),
6353
+ waitFor: z38.boolean().default(true).describe(
6354
+ "Whether action waits for the indexing before returning. Defaults to true. Setting this to to false completes faster but might lead to stale data in the client if the client tries to read the event immediately after performing the action. Use with care."
6355
+ ),
5903
6356
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
5904
6357
  // @TODO: createdAtLocation should be limited to actions that system users can perform. For normal users, it should not be part of the base action.
5905
6358
  createdAtLocation: UUID.nullish().describe(
@@ -5990,6 +6443,11 @@ var ArchiveActionInput = BaseActionInput.extend(
5990
6443
  content: ReasonContent
5991
6444
  }).shape
5992
6445
  );
6446
+ var UnarchiveActionInput = BaseActionInput.extend(
6447
+ z38.object({
6448
+ type: z38.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
6449
+ }).shape
6450
+ );
5993
6451
  var AssignActionInput = BaseActionInput.extend(
5994
6452
  z38.object({
5995
6453
  type: z38.literal(ActionType.ASSIGN),
@@ -6017,7 +6475,8 @@ var RejectCorrectionActionInput = BaseActionInput.extend(
6017
6475
  var ApproveCorrectionActionInput = BaseActionInput.extend(
6018
6476
  z38.object({
6019
6477
  requestId: z38.string(),
6020
- 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()
6021
6480
  }).shape
6022
6481
  );
6023
6482
  var ReadActionInput = BaseActionInput.extend(
@@ -6050,6 +6509,7 @@ var ActionInput = z38.discriminatedUnion("type", [
6050
6509
  id: "MarkNotDuplicateActionInput"
6051
6510
  }),
6052
6511
  ArchiveActionInput.meta({ id: "ArchiveActionInput" }),
6512
+ UnarchiveActionInput.meta({ id: "UnarchiveActionInput" }),
6053
6513
  AssignActionInput.meta({ id: "AssignActionInput" }),
6054
6514
  UnassignActionInput.meta({ id: "UnassignActionInput" }),
6055
6515
  PrintCertificateActionInput.meta({ id: "PrintCertificateActionInput" }),
@@ -6079,7 +6539,7 @@ var Draft = z39.object({
6079
6539
  }).describe(
6080
6540
  "A temporary storage for an action. Stored with details of the event, creator and creation time."
6081
6541
  );
6082
- var DraftInput = BaseActionInput.extend({
6542
+ var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
6083
6543
  type: ActionTypes.exclude([ActionTypes.enum.DELETE]),
6084
6544
  status: z39.enum([
6085
6545
  ActionStatus.Requested,
@@ -6153,7 +6613,6 @@ function getDeclarationActionCreationMetadata(actionType, actions) {
6153
6613
  createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
6154
6614
  acceptedAt: acceptAction.createdAt,
6155
6615
  createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
6156
- createdBySignature: requestAction?.createdBySignature ?? acceptAction.createdBySignature,
6157
6616
  registrationNumber
6158
6617
  };
6159
6618
  }
@@ -6165,8 +6624,11 @@ var updateActions = ActionTypes.extract([
6165
6624
  ActionType.REGISTER,
6166
6625
  ActionType.REJECT,
6167
6626
  ActionType.ARCHIVE,
6627
+ ActionType.UNARCHIVE,
6168
6628
  ActionType.PRINT_CERTIFICATE,
6169
6629
  ActionType.REQUEST_CORRECTION,
6630
+ ActionType.APPROVE_CORRECTION,
6631
+ ActionType.REJECT_CORRECTION,
6170
6632
  ActionType.CUSTOM
6171
6633
  ]);
6172
6634
  function getActionUpdateMetadata(actions) {
@@ -6181,7 +6643,7 @@ function getActionUpdateMetadata(actions) {
6181
6643
  "createdAtLocation",
6182
6644
  "createdByRole"
6183
6645
  ];
6184
- return actions.filter(({ type }) => updateActions.safeParse(type).success).filter(({ status: status2 }) => status2 === ActionStatus.Accepted).reduce(
6646
+ return actions.filter(({ type }) => updateActions.safeParse(type).success).reduce(
6185
6647
  (_2, action) => {
6186
6648
  if (action.originalActionId) {
6187
6649
  const originalAction = actions.find(({ id }) => id === action.originalActionId) ?? action;
@@ -6194,6 +6656,10 @@ function getActionUpdateMetadata(actions) {
6194
6656
  }
6195
6657
  function getLegalStatuses(actions) {
6196
6658
  return {
6659
+ [EventStatus.enum.NOTIFIED]: getDeclarationActionCreationMetadata(
6660
+ ActionType.NOTIFY,
6661
+ actions
6662
+ ),
6197
6663
  [EventStatus.enum.DECLARED]: getDeclarationActionCreationMetadata(
6198
6664
  ActionType.DECLARE,
6199
6665
  actions
@@ -6208,28 +6674,19 @@ function getLegalStatuses(actions) {
6208
6674
  // ../commons/src/events/state/flags.ts
6209
6675
  var import_lodash3 = require("lodash");
6210
6676
  var import_date_fns3 = require("date-fns");
6211
- function isEditInProgress(actions) {
6212
- return actions.at(-1)?.type === ActionType.EDIT;
6213
- }
6214
- function isCorrectionRequested(actions) {
6215
- return actions.reduce((prev, { type }) => {
6216
- if (type === ActionType.REQUEST_CORRECTION) {
6217
- return true;
6218
- }
6219
- if (type === ActionType.APPROVE_CORRECTION) {
6220
- return false;
6677
+ function findPendingCorrectionAction(writeActions2) {
6678
+ let correctionRequestAction;
6679
+ for (let i = writeActions2.length - 1; i >= 0; i--) {
6680
+ const action = writeActions2[i];
6681
+ if (action.type === ActionType.APPROVE_CORRECTION || action.type === ActionType.REJECT_CORRECTION) {
6682
+ break;
6221
6683
  }
6222
- if (type === ActionType.REJECT_CORRECTION) {
6223
- return false;
6684
+ if (action.type === ActionType.REQUEST_CORRECTION) {
6685
+ correctionRequestAction = action;
6686
+ break;
6224
6687
  }
6225
- return prev;
6226
- }, false);
6227
- }
6228
- function isDeclarationIncomplete(actions) {
6229
- return getStatusFromActions(actions) === EventStatus.enum.NOTIFIED;
6230
- }
6231
- function isRejected(actions) {
6232
- return actions.at(-1)?.type === ActionType.REJECT;
6688
+ }
6689
+ return correctionRequestAction;
6233
6690
  }
6234
6691
  function isPotentialDuplicate(actions) {
6235
6692
  return actions.reduce((prev, { type }) => {
@@ -6258,6 +6715,85 @@ function isFlagConditionMet(conditional, form, action) {
6258
6715
  }
6259
6716
  });
6260
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
+ }
6261
6797
  function resolveEventCustomFlags(event2, eventConfiguration) {
6262
6798
  const actions = getAcceptedActions(event2).filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
6263
6799
  return actions.reduce((acc, action, idx) => {
@@ -6279,7 +6815,7 @@ function resolveEventCustomFlags(event2, eventConfiguration) {
6279
6815
  const declaration = aggregateActionDeclarations(eventUpToThisAction);
6280
6816
  const annotation = aggregateActionAnnotations(eventUpToThisAction);
6281
6817
  const form = { ...declaration, ...annotation };
6282
- const flagsWithMetConditions = actionConfig.flags.filter(
6818
+ const flagsWithMetConditions = (actionConfig.flags ?? []).filter(
6283
6819
  ({ conditional }) => (
6284
6820
  // If conditional is not provided, the flag is resolved
6285
6821
  conditional ? isFlagConditionMet(conditional, form, action) : true
@@ -6293,8 +6829,7 @@ function resolveEventCustomFlags(event2, eventConfiguration) {
6293
6829
  return (0, import_lodash3.uniq)(flags);
6294
6830
  }, []);
6295
6831
  }
6296
- function getEventFlags(event2, config) {
6297
- const sortedActions = event2.actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
6832
+ function getActionStatusFlags(sortedActions) {
6298
6833
  const actionStatus = sortedActions.reduce(
6299
6834
  (actionStatuses, { type, status: status2 }) => ({
6300
6835
  ...actionStatuses,
@@ -6302,31 +6837,51 @@ function getEventFlags(event2, config) {
6302
6837
  }),
6303
6838
  {}
6304
6839
  );
6305
- const flags = Object.entries(actionStatus).filter(([, status2]) => status2 !== ActionStatus.Accepted).map(([type, status2]) => {
6840
+ return Object.entries(actionStatus).filter(([, status2]) => status2 !== ActionStatus.Accepted).map(([type, status2]) => {
6306
6841
  const flag2 = joinValues([type, status2], ":").toLowerCase();
6307
6842
  return flag2;
6308
6843
  });
6309
- if (isCorrectionRequested(sortedActions)) {
6310
- flags.push(InherentFlags.CORRECTION_REQUESTED);
6311
- }
6312
- if (isDeclarationIncomplete(sortedActions)) {
6313
- flags.push(InherentFlags.INCOMPLETE);
6314
- }
6315
- if (isRejected(sortedActions)) {
6316
- flags.push(InherentFlags.REJECTED);
6317
- }
6318
- if (isPotentialDuplicate(sortedActions)) {
6319
- flags.push(InherentFlags.POTENTIAL_DUPLICATE);
6320
- }
6321
- if (isEditInProgress(sortedActions)) {
6322
- flags.push(InherentFlags.EDIT_IN_PROGRESS);
6323
- }
6324
- return [...flags, ...resolveEventCustomFlags(event2, config)];
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
+ ];
6325
6860
  }
6326
6861
 
6327
6862
  // ../commons/src/events/state/index.ts
6328
6863
  function getStatusFromActions(actions) {
6329
- return actions.filter(({ status: status2 }) => status2 === ActionStatus.Accepted).reduce((status2, action) => {
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) => {
6330
6885
  switch (action.type) {
6331
6886
  case ActionType.CREATE:
6332
6887
  return EventStatus.enum.CREATED;
@@ -6334,10 +6889,11 @@ function getStatusFromActions(actions) {
6334
6889
  return EventStatus.enum.DECLARED;
6335
6890
  case ActionType.REGISTER:
6336
6891
  return EventStatus.enum.REGISTERED;
6337
- case ActionType.ARCHIVE:
6338
- return EventStatus.enum.ARCHIVED;
6339
6892
  case ActionType.NOTIFY:
6340
6893
  return EventStatus.enum.NOTIFIED;
6894
+ // Already filtered out above; listed here only to satisfy exhaustiveness.
6895
+ case ActionType.ARCHIVE:
6896
+ case ActionType.UNARCHIVE:
6341
6897
  case ActionType.CUSTOM:
6342
6898
  case ActionType.PRINT_CERTIFICATE:
6343
6899
  case ActionType.ASSIGN:
@@ -6367,17 +6923,6 @@ function getAssignedUserFromActions(actions) {
6367
6923
  return user2;
6368
6924
  }, null);
6369
6925
  }
6370
- function getAssignedUserSignatureFromActions(actions) {
6371
- return actions.reduce((signature, action) => {
6372
- if (action.type === ActionType.ASSIGN) {
6373
- return action.createdBySignature || null;
6374
- }
6375
- if (action.type === ActionType.UNASSIGN) {
6376
- return null;
6377
- }
6378
- return signature;
6379
- }, null);
6380
- }
6381
6926
  function deepDropNulls(obj) {
6382
6927
  if (Array.isArray(obj)) {
6383
6928
  return obj.map(deepDropNulls);
@@ -6473,10 +7018,8 @@ function getCurrentEventState(event2, config) {
6473
7018
  createdBy: creationAction.createdBy,
6474
7019
  createdByUserType: creationAction.createdByUserType,
6475
7020
  createdAtLocation: creationAction.createdAtLocation,
6476
- createdBySignature: creationAction.createdBySignature,
6477
7021
  updatedAt: acceptedActionMetadata.createdAt,
6478
7022
  assignedTo: getAssignedUserFromActions(acceptedActions),
6479
- assignedToSignature: getAssignedUserSignatureFromActions(acceptedActions),
6480
7023
  updatedBy: requestActionMetadata.createdBy,
6481
7024
  updatedAtLocation: requestActionMetadata.createdAtLocation,
6482
7025
  declaration,
@@ -6569,7 +7112,7 @@ function getActionAnnotation({
6569
7112
  const action = (0, import_lodash4.findLast)(activeActions, (a) => a.type === actionType);
6570
7113
  const actionWithCompleteAnnotation = action && {
6571
7114
  ...action,
6572
- annotation: getCompleteActionAnnotation({}, event2, action)
7115
+ annotation: getCompleteActionAnnotation(event2, action)
6573
7116
  };
6574
7117
  const matchingDraft = draft?.action.type === actionType ? draft : void 0;
6575
7118
  const sortedActions = (0, import_lodash4.orderBy)(
@@ -6641,6 +7184,9 @@ function createFieldConfig(fieldId, options) {
6641
7184
  }
6642
7185
 
6643
7186
  // ../commons/src/events/field.ts
7187
+ function evaluate(computationFn) {
7188
+ return { $$code: computationFn.toString() };
7189
+ }
6644
7190
  function field(fieldId, options = {}) {
6645
7191
  return {
6646
7192
  ...createFieldConditionals(fieldId),
@@ -7334,6 +7880,11 @@ var TENNIS_CLUB_DECLARATION_REVIEW = {
7334
7880
  id: "signature.upload.modal.title",
7335
7881
  defaultMessage: "Draw signature",
7336
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
7337
7888
  }
7338
7889
  }
7339
7890
  ]
@@ -7890,6 +8441,20 @@ var tennisClubMembershipEvent = defineConfig({
7890
8441
  },
7891
8442
  review: TENNIS_CLUB_DECLARATION_REVIEW
7892
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
+ },
7893
8458
  {
7894
8459
  type: ActionType.REJECT,
7895
8460
  label: {
@@ -8132,6 +8697,17 @@ var tennisClubMembershipEvent = defineConfig({
8132
8697
  }
8133
8698
  }
8134
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
+ ],
8135
8711
  advancedSearch: [
8136
8712
  {
8137
8713
  title: {
@@ -9402,6 +9978,14 @@ function eventPayloadGenerator(rng, configuration = tennisClubMembershipEvent) {
9402
9978
  },
9403
9979
  ...input
9404
9980
  }),
9981
+ unarchive: (eventId, input = {}) => ({
9982
+ type: ActionType.UNARCHIVE,
9983
+ transactionId: input.transactionId ?? getUUID(),
9984
+ declaration: {},
9985
+ annotation: {},
9986
+ eventId,
9987
+ ...input
9988
+ }),
9405
9989
  reject: (eventId, input = {}) => ({
9406
9990
  type: ActionType.REJECT,
9407
9991
  transactionId: input.transactionId ?? getUUID(),
@@ -9560,6 +10144,7 @@ function generateActionDocument({
9560
10144
  case ActionType.NOTIFY:
9561
10145
  case ActionType.REGISTER:
9562
10146
  case ActionType.REQUEST_CORRECTION:
10147
+ case ActionType.UNARCHIVE:
9563
10148
  return { ...actionBase, type: action };
9564
10149
  case ActionType.EDIT:
9565
10150
  return {
@@ -9735,7 +10320,6 @@ var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
9735
10320
  createdBy: overrides.createdBy ?? generateUuid(rng),
9736
10321
  createdAtLocation: overrides.createdAtLocation ?? generateUuid(rng),
9737
10322
  updatedAtLocation: overrides.updatedAtLocation ?? generateUuid(rng),
9738
- createdBySignature: overrides.createdBySignature ?? generateRandomSignature(rng),
9739
10323
  updatedAt: overrides.updatedAt ?? (0, import_date_fns4.addDays)(new Date(createdAt), 1).toISOString(),
9740
10324
  assignedTo: overrides.assignedTo ?? null,
9741
10325
  updatedBy: overrides.updatedBy ?? generateUuid(rng),
@@ -9891,7 +10475,7 @@ function matchesJurisdictionFilter(locationIds, filter, user2) {
9891
10475
  return locationIds.some((id) => id === user2.primaryOfficeId);
9892
10476
  }
9893
10477
  if (filter === JurisdictionFilter.enum.administrativeArea) {
9894
- return user2.administrativeAreaId === null || locationIds.some((id) => id === user2.administrativeAreaId);
10478
+ return !user2.administrativeAreaId || locationIds.some((id) => id === user2.administrativeAreaId);
9895
10479
  }
9896
10480
  return true;
9897
10481
  }
@@ -9918,6 +10502,25 @@ function canAccessEventWithScope(event2, scope, user2, customActionType) {
9918
10502
  }
9919
10503
  if (scopeUsesDeclaredOptions(scope)) {
9920
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
+ }
9921
10524
  if (options?.declaredBy === UserFilter.enum.user) {
9922
10525
  if (event2.legalStatuses?.DECLARED?.createdBy !== user2.id) {
9923
10526
  return false;
@@ -9980,7 +10583,7 @@ function canAccessUserWithScope({
9980
10583
  }
9981
10584
  const hasAdministrativeAreaInHierarchy = userToAccess.administrativeHierarchy.some(
9982
10585
  (id) => user2.administrativeAreaId === id
9983
- ) || user2.administrativeAreaId === null;
10586
+ ) || !user2.administrativeAreaId;
9984
10587
  if (opts?.accessLevel === JurisdictionFilter.enum.administrativeArea && !hasAdministrativeAreaInHierarchy) {
9985
10588
  return false;
9986
10589
  }
@@ -10060,6 +10663,7 @@ var ACTION_SCOPE_MAP = {
10060
10663
  [ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
10061
10664
  [ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
10062
10665
  [ActionType.ARCHIVE]: ["record.archive"],
10666
+ [ActionType.UNARCHIVE]: ["record.unarchive"],
10063
10667
  [ActionType.REJECT]: ["record.reject"],
10064
10668
  [ActionType.ASSIGN]: null,
10065
10669
  [ActionType.UNASSIGN]: null,
@@ -10266,7 +10870,11 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
10266
10870
  ActionType.CUSTOM,
10267
10871
  ClientSpecificAction.REVIEW_CORRECTION_REQUEST
10268
10872
  ],
10269
- [EventStatus.enum.ARCHIVED]: [ActionType.READ, ActionType.CUSTOM]
10873
+ [EventStatus.enum.ARCHIVED]: [
10874
+ ActionType.READ,
10875
+ ActionType.CUSTOM,
10876
+ ActionType.UNARCHIVE
10877
+ ]
10270
10878
  };
10271
10879
  var ACTION_FILTERS = {
10272
10880
  [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
@@ -10279,6 +10887,7 @@ var ACTION_FILTERS = {
10279
10887
  [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
10280
10888
  [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
10281
10889
  [ActionType.ARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
10890
+ [ActionType.UNARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
10282
10891
  [ActionType.ASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
10283
10892
  [ActionType.UNASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
10284
10893
  [ActionType.CUSTOM]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested"))
@@ -10286,18 +10895,19 @@ var ACTION_FILTERS = {
10286
10895
  function filterActionsByFlags(actions, flags) {
10287
10896
  return actions.filter((action) => ACTION_FILTERS[action]?.(flags) ?? true);
10288
10897
  }
10898
+ var REJECTED_ACTIONS = [
10899
+ ActionType.READ,
10900
+ ActionType.NOTIFY,
10901
+ ActionType.CUSTOM,
10902
+ ActionType.EDIT,
10903
+ ActionType.ARCHIVE
10904
+ ];
10289
10905
  function getAvailableActionsWithoutFlagFilters(status2, flags) {
10290
10906
  if (flags.includes(InherentFlags.EDIT_IN_PROGRESS)) {
10291
10907
  return [ActionType.NOTIFY, ActionType.DECLARE, ActionType.REGISTER];
10292
10908
  }
10293
- if (flags.includes(InherentFlags.REJECTED)) {
10294
- return [
10295
- ActionType.READ,
10296
- ActionType.NOTIFY,
10297
- ActionType.CUSTOM,
10298
- ActionType.EDIT,
10299
- ActionType.ARCHIVE
10300
- ];
10909
+ if (flags.includes(InherentFlags.REJECTED) && status2 !== EventStatus.enum.ARCHIVED) {
10910
+ return REJECTED_ACTIONS;
10301
10911
  }
10302
10912
  return AVAILABLE_ACTIONS_BY_EVENT_STATUS[status2];
10303
10913
  }
@@ -10334,3 +10944,366 @@ function getFilePathsFromEvent(event2) {
10334
10944
  });
10335
10945
  return (0, import_lodash7.uniq)(filepaths);
10336
10946
  }
10947
+
10948
+ // ../commons/src/events/mocks.test.utils.ts
10949
+ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
10950
+ {
10951
+ id: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10952
+ name: "Central",
10953
+ parentId: null,
10954
+ validUntil: null,
10955
+ externalId: "ydyJb1RAy4U1"
10956
+ },
10957
+ {
10958
+ id: "c599b691-fd2d-45e1-abf4-d185de727fb5",
10959
+ name: "Sulaka",
10960
+ parentId: null,
10961
+ validUntil: null,
10962
+ externalId: "pQ8nGxWmZ2Q3"
10963
+ },
10964
+ {
10965
+ id: "7ef2b9c7-5e6d-49f6-ae05-656207d0fc64",
10966
+ name: "Pualula",
10967
+ parentId: null,
10968
+ validUntil: null,
10969
+ externalId: "Aq91DweLmT8k"
10970
+ },
10971
+ {
10972
+ id: "6d1a59df-988c-4021-a846-ccbc021931a7",
10973
+ name: "Chuminga",
10974
+ parentId: null,
10975
+ validUntil: null,
10976
+ externalId: "Rw0fYNh2Xk9a"
10977
+ },
10978
+ {
10979
+ id: "62a0ccb4-880d-4f30-8882-f256007dfff9",
10980
+ name: "Ibombo",
10981
+ parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10982
+ validUntil: null,
10983
+ externalId: "k7DsP4vbN1Qe"
10984
+ },
10985
+ {
10986
+ id: "27160bbd-32d1-4625-812f-860226bfb92a",
10987
+ name: "Isango",
10988
+ parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10989
+ validUntil: null,
10990
+ externalId: "Gm3Z9eQpHw4L"
10991
+ },
10992
+ {
10993
+ id: "967032fd-3f81-478a-826c-30cb8fe121bd",
10994
+ name: "Isamba",
10995
+ parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10996
+ validUntil: null,
10997
+ externalId: "sT0xVu1KqJ7r"
10998
+ },
10999
+ {
11000
+ id: "89a33893-b17d-481d-a26d-6461e7ac1651",
11001
+ name: "Itambo",
11002
+ parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11003
+ validUntil: null,
11004
+ externalId: "Nq6Bv2HpL9Te"
11005
+ },
11006
+ {
11007
+ id: "d42ab2fe-e7ed-470e-8b31-4fb27f9b8250",
11008
+ name: "Ezhi",
11009
+ parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11010
+ validUntil: null,
11011
+ externalId: "xK8cQ0ZRy5Wd"
11012
+ },
11013
+ {
11014
+ id: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
11015
+ name: "Ilanga",
11016
+ parentId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
11017
+ validUntil: null,
11018
+ externalId: "Cq4Jm1XvN8Ls"
11019
+ },
11020
+ // Villages under Ibombo (62a0ccb4-880d-4f30-8882-f256007dfff9)
11021
+ {
11022
+ id: "1d4e5f6a-7b8c-4912-8efa-345678901234",
11023
+ name: "Klow",
11024
+ parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11025
+ validUntil: null,
11026
+ externalId: "IkYcYBUcyY2"
11027
+ },
11028
+ {
11029
+ id: "2e5f6a7b-8c9d-4a23-8fab-456789012345",
11030
+ name: "Mbondo",
11031
+ parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11032
+ validUntil: null,
11033
+ externalId: "Qhvv5hvo3mY"
11034
+ },
11035
+ {
11036
+ id: "3f6a7b8c-9d0e-4b34-8abc-567890123456",
11037
+ name: "Ndara",
11038
+ parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11039
+ validUntil: null,
11040
+ externalId: "crXh068O9TR"
11041
+ },
11042
+ {
11043
+ id: "4a7b8c9d-0e1f-4c45-abcd-678901234567",
11044
+ name: "Olani",
11045
+ parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11046
+ validUntil: null,
11047
+ externalId: "r00It8Tvvp7"
11048
+ },
11049
+ {
11050
+ id: "5b8c9d0e-1f2a-4d56-bcde-789012345678",
11051
+ name: "Pemba",
11052
+ parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11053
+ validUntil: null,
11054
+ externalId: "ZnUWsbONIaH"
11055
+ },
11056
+ {
11057
+ id: "6c9d0e1f-2a3b-4e67-8def-890123456789",
11058
+ name: "Quanza",
11059
+ parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11060
+ validUntil: null,
11061
+ externalId: "fDZycvQTa7l"
11062
+ },
11063
+ {
11064
+ id: "7d0e1f2a-3b4c-4f78-8efa-901234567890",
11065
+ name: "Rivka",
11066
+ parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11067
+ validUntil: null,
11068
+ externalId: "KqswxCGTELa"
11069
+ },
11070
+ // Villages under Isamba (967032fd-3f81-478a-826c-30cb8fe121bd)
11071
+ {
11072
+ id: "8e1f2a3b-4c5d-4089-8fab-012345678901",
11073
+ name: "Mbula",
11074
+ parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11075
+ validUntil: null,
11076
+ externalId: "osEbKjRc9Kg"
11077
+ },
11078
+ {
11079
+ id: "9f2a3b4c-5d6e-4190-8abf-123456789012",
11080
+ name: "Ndoki",
11081
+ parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11082
+ validUntil: null,
11083
+ externalId: "aq4daBUAGr3"
11084
+ },
11085
+ {
11086
+ id: "0a3b4c5d-6e7f-4201-abcd-234567890123",
11087
+ name: "Tsanga",
11088
+ parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11089
+ validUntil: null,
11090
+ externalId: "cqis6Y8trbJ"
11091
+ },
11092
+ {
11093
+ id: "1b4c5d6e-7f8a-4312-bcde-345678901234",
11094
+ name: "Waziri",
11095
+ parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11096
+ validUntil: null,
11097
+ externalId: "LMijHPyyx6d"
11098
+ },
11099
+ {
11100
+ id: "2c5d6e7f-8a9b-4423-8def-456789012345",
11101
+ name: "Zimbi",
11102
+ parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11103
+ validUntil: null,
11104
+ externalId: "pcQYbPuKGZ7"
11105
+ },
11106
+ // Villages under Itambo (89a33893-b17d-481d-a26d-6461e7ac1651)
11107
+ {
11108
+ id: "3d6e7f8a-9b0c-4534-8efa-567890123456",
11109
+ name: "Felani",
11110
+ parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11111
+ validUntil: null,
11112
+ externalId: "gSqpoCGdMXp"
11113
+ },
11114
+ {
11115
+ id: "4e7f8a9b-0c1d-4645-8fab-678901234567",
11116
+ name: "Goroma",
11117
+ parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11118
+ validUntil: null,
11119
+ externalId: "KvAAIaNqVrp"
11120
+ },
11121
+ {
11122
+ id: "5f8a9b0c-1d2e-4756-8abc-789012345678",
11123
+ name: "Halifu",
11124
+ parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11125
+ validUntil: null,
11126
+ externalId: "qe4UnEVt1hv"
11127
+ },
11128
+ {
11129
+ id: "6a9b0c1d-2e3f-4867-abcd-890123456789",
11130
+ name: "Jabari",
11131
+ parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11132
+ validUntil: null,
11133
+ externalId: "yHH9Nz4rLOt"
11134
+ },
11135
+ {
11136
+ id: "7b0c1d2e-3f4a-4978-bcde-901234567890",
11137
+ name: "Kifani",
11138
+ parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11139
+ validUntil: null,
11140
+ externalId: "eSWmXIGeu1I"
11141
+ },
11142
+ {
11143
+ id: "8c1d2e3f-4a5b-4089-8def-012345678901",
11144
+ name: "Lumela",
11145
+ parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11146
+ validUntil: null,
11147
+ externalId: "bh0b3aI1uP3"
11148
+ }
11149
+ ];
11150
+ var V2_DEFAULT_MOCK_LOCATIONS = [
11151
+ {
11152
+ id: "6f6186ce-cd5f-4a5f-810a-2d99e7c4ba12",
11153
+ name: "Central Provincial Office",
11154
+ locationType: "CRVS_OFFICE",
11155
+ administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11156
+ validUntil: null,
11157
+ externalId: "Xr3Df8WpK6Ys"
11158
+ },
11159
+ {
11160
+ id: "b1c2d3e4-f5a6-7890-bcde-f12345678901",
11161
+ name: "Central Health Post",
11162
+ locationType: "HEALTH_FACILITY",
11163
+ administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11164
+ validUntil: null
11165
+ },
11166
+ {
11167
+ id: "028d2c85-ca31-426d-b5d1-2cef545a4902",
11168
+ name: "Ibombo District Office",
11169
+ locationType: "CRVS_OFFICE",
11170
+ administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11171
+ validUntil: null,
11172
+ externalId: "Sm4Nw7GrD2Vy"
11173
+ },
11174
+ {
11175
+ id: "62a0ccb4-4f30-4f30-8882-f256007dff9f",
11176
+ name: "Isamba District Office",
11177
+ locationType: "CRVS_OFFICE",
11178
+ administrativeAreaId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11179
+ validUntil: null,
11180
+ externalId: "Vg1Bq5XeH9Lt"
11181
+ },
11182
+ {
11183
+ id: "954c93e1-13f7-4435-bb82-35e0e215e07d",
11184
+ name: "Isango District Office",
11185
+ locationType: "CRVS_OFFICE",
11186
+ administrativeAreaId: "27160bbd-32d1-4625-812f-860226bfb92a",
11187
+ validUntil: null,
11188
+ externalId: "Je7Lm2XqN9Vz"
11189
+ },
11190
+ {
11191
+ id: "2884f5b9-17b4-49ce-bf4d-f538228935df",
11192
+ name: "Sulaka Provincial Office",
11193
+ locationType: "CRVS_OFFICE",
11194
+ administrativeAreaId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
11195
+ validUntil: null,
11196
+ externalId: "Ht2Wp9KcX5Qv"
11197
+ },
11198
+ {
11199
+ id: "030358c6-54af-44be-821b-8e4af963a49c",
11200
+ name: "Ilanga District Office",
11201
+ locationType: "CRVS_OFFICE",
11202
+ administrativeAreaId: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
11203
+ validUntil: null,
11204
+ externalId: "Yp6Ds1WqN3Xz"
11205
+ },
11206
+ {
11207
+ id: "423d000f-101b-47c0-8b86-21a908067cee",
11208
+ name: "Chamakubi Health Post",
11209
+ locationType: "HEALTH_FACILITY",
11210
+ administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11211
+ validUntil: null,
11212
+ externalId: "M1nFr8LbC2Qy"
11213
+ },
11214
+ {
11215
+ id: "4d3279be-d026-420c-88f7-f0a4ae986973",
11216
+ name: "Ibombo Rural Health Centre",
11217
+ locationType: "HEALTH_FACILITY",
11218
+ administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11219
+ validUntil: null,
11220
+ externalId: "bT7pV6YrW0Xc"
11221
+ },
11222
+ {
11223
+ id: "190902f4-1d77-476a-8947-41145af1db7d",
11224
+ name: "Chikobo Rural Health Centre",
11225
+ locationType: "HEALTH_FACILITY",
11226
+ administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11227
+ validUntil: null,
11228
+ externalId: "zE4qPn2SgJ5d"
11229
+ },
11230
+ {
11231
+ id: "f5ecbd9b-a01e-4a65-910e-70e86ab41b71",
11232
+ name: "Chilochabalenje Health Post",
11233
+ locationType: "HEALTH_FACILITY",
11234
+ administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11235
+ validUntil: null,
11236
+ externalId: "H8vDs1MqR4Uf"
11237
+ },
11238
+ {
11239
+ id: "dbfc178f-7295-4b90-b28d-111c95b03127",
11240
+ name: "Chipeso Rural Health Centre",
11241
+ locationType: "HEALTH_FACILITY",
11242
+ administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11243
+ validUntil: null,
11244
+ externalId: "Qw3uZ9KfX6Lm"
11245
+ },
11246
+ {
11247
+ id: "09862bfe-c7ac-46cd-987b-668681533c80",
11248
+ name: "Chisamba Rural Health Centre",
11249
+ locationType: "HEALTH_FACILITY",
11250
+ administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11251
+ validUntil: null,
11252
+ externalId: "Yr0pCg8LdM2s"
11253
+ },
11254
+ {
11255
+ id: "834ce389-e95b-4fb0-96a0-33e9ab323059",
11256
+ name: "Chitanda Rural Health Centre",
11257
+ locationType: "HEALTH_FACILITY",
11258
+ administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11259
+ validUntil: null,
11260
+ externalId: "tS9gJ4PwB1Qx"
11261
+ },
11262
+ {
11263
+ id: "0431c433-6062-4a4c-aee9-25271aec61ee",
11264
+ name: "Golden Valley Rural Health Centre",
11265
+ locationType: "HEALTH_FACILITY",
11266
+ administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11267
+ validUntil: null,
11268
+ externalId: "Ld7Qm3XsA8Vr"
11269
+ },
11270
+ {
11271
+ id: "bc84d0b6-7ba7-480d-a339-5d9920d90eb2",
11272
+ name: "Ipongo Rural Health Centre",
11273
+ locationType: "HEALTH_FACILITY",
11274
+ administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11275
+ validUntil: null,
11276
+ externalId: "kF2sW9DmH0Bt"
11277
+ },
11278
+ {
11279
+ id: "4cf1f53b-b730-41d2-8649-dff7eeed970d",
11280
+ name: "Itumbwe Health Post",
11281
+ locationType: "HEALTH_FACILITY",
11282
+ administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11283
+ validUntil: null,
11284
+ externalId: "Ue5Xb3VaC7Pq"
11285
+ },
11286
+ {
11287
+ id: "4b3676cb-9355-4942-9eb9-2ce46acaf0e0",
11288
+ name: "Kabangalala Rural Health Centre",
11289
+ locationType: "HEALTH_FACILITY",
11290
+ administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11291
+ validUntil: null,
11292
+ externalId: "Pz8Kc1TqH6Jn"
11293
+ },
11294
+ // Village offices
11295
+ {
11296
+ id: "1f4a5b6c-7d8e-4312-8abc-345678901234",
11297
+ name: "Klow Village Office",
11298
+ locationType: "CRVS_OFFICE",
11299
+ administrativeAreaId: "1d4e5f6a-7b8c-4912-8efa-345678901234",
11300
+ validUntil: null,
11301
+ externalId: "PmAyxAJkxiJ"
11302
+ }
11303
+ ];
11304
+ var V2_DEFAULT_MOCK_LOCATIONS_MAP = new Map(
11305
+ V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, l])
11306
+ );
11307
+ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP = new Map(
11308
+ V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [a.id, a])
11309
+ );