@opencrvs/toolkit 2.0.0-rc.b0a238f → 2.0.0-rc.b0c39c7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/README.md +15 -0
  2. package/build.sh +3 -2
  3. package/create-countryconfig/index.js +50 -20
  4. package/create-countryconfig/package.json +12 -2
  5. package/dist/application-config/index.js +273 -98
  6. package/dist/cli.js +3263 -49
  7. package/dist/commons/api/router.d.ts +117 -21
  8. package/dist/commons/application-config/index.d.ts +1 -0
  9. package/dist/commons/conditionals/conditionals.d.ts +357 -7
  10. package/dist/commons/conditionals/validate.d.ts +51 -2
  11. package/dist/commons/events/ActionConfig.d.ts +35 -2
  12. package/dist/commons/events/ActionDocument.d.ts +6 -0
  13. package/dist/commons/events/ActionInput.d.ts +42 -36
  14. package/dist/commons/events/AdvancedSearchConfig.d.ts +354 -0
  15. package/dist/commons/events/CountryConfigQueryInput.d.ts +42 -0
  16. package/dist/commons/events/Draft.d.ts +2 -3
  17. package/dist/commons/events/EventConfig.d.ts +2 -0
  18. package/dist/commons/events/EventDocument.d.ts +3 -0
  19. package/dist/commons/events/EventIndex.d.ts +25 -0
  20. package/dist/commons/events/EventMetadata.d.ts +26 -0
  21. package/dist/commons/events/FieldConfig.d.ts +388 -50
  22. package/dist/commons/events/FieldType.d.ts +1 -0
  23. package/dist/commons/events/FieldTypeMapping.d.ts +1 -1
  24. package/dist/commons/events/FieldValue.d.ts +6 -0
  25. package/dist/commons/events/WorkqueueConfig.d.ts +189 -150
  26. package/dist/commons/events/field.d.ts +53 -1
  27. package/dist/commons/events/index.d.ts +2 -0
  28. package/dist/commons/events/locations.d.ts +1 -0
  29. package/dist/commons/events/state/flags.d.ts +16 -0
  30. package/dist/commons/events/state/index.d.ts +8 -0
  31. package/dist/commons/events/state/utils.d.ts +21 -287
  32. package/dist/commons/events/utils.d.ts +20 -1
  33. package/dist/conditionals/index.js +63 -5
  34. package/dist/environment/custom-types.d.ts +33 -0
  35. package/dist/environment/custom-types.d.ts.map +1 -0
  36. package/dist/environment/custom-types.js +12 -0
  37. package/dist/environment/derived-variables.d.ts +134 -0
  38. package/dist/environment/derived-variables.d.ts.map +1 -0
  39. package/dist/environment/derived-variables.js +169 -0
  40. package/dist/environment/editor-questions.d.ts +4 -0
  41. package/dist/environment/editor-questions.d.ts.map +1 -0
  42. package/dist/environment/editor-questions.js +67 -0
  43. package/dist/environment/git.d.ts +5 -0
  44. package/dist/environment/git.d.ts.map +1 -0
  45. package/dist/environment/git.js +38 -0
  46. package/dist/environment/github.d.ts +26 -0
  47. package/dist/environment/github.d.ts.map +1 -0
  48. package/dist/environment/github.js +247 -0
  49. package/dist/environment/index.d.ts +5 -0
  50. package/dist/environment/index.d.ts.map +1 -0
  51. package/dist/environment/index.js +71 -0
  52. package/dist/environment/logger.d.ts +15 -0
  53. package/dist/environment/logger.d.ts.map +1 -0
  54. package/dist/environment/logger.js +25 -0
  55. package/dist/environment/manage-users.d.ts +11 -0
  56. package/dist/environment/manage-users.d.ts.map +1 -0
  57. package/dist/environment/manage-users.js +497 -0
  58. package/dist/environment/questions-helper.d.ts +15 -0
  59. package/dist/environment/questions-helper.d.ts.map +1 -0
  60. package/dist/environment/questions-helper.js +70 -0
  61. package/dist/environment/questions.d.ts +199 -0
  62. package/dist/environment/questions.d.ts.map +1 -0
  63. package/dist/environment/questions.js +412 -0
  64. package/dist/environment/setup-environment.d.ts +2 -0
  65. package/dist/environment/setup-environment.d.ts.map +1 -0
  66. package/dist/environment/setup-environment.js +794 -0
  67. package/dist/environment/ssh-keygen.d.ts +5 -0
  68. package/dist/environment/ssh-keygen.d.ts.map +1 -0
  69. package/dist/environment/ssh-keygen.js +21 -0
  70. package/dist/environment/swarm-to-k8s.d.ts +2 -0
  71. package/dist/environment/swarm-to-k8s.d.ts.map +1 -0
  72. package/dist/environment/swarm-to-k8s.js +173 -0
  73. package/dist/environment/templates.d.ts +27 -0
  74. package/dist/environment/templates.d.ts.map +1 -0
  75. package/dist/environment/templates.js +163 -0
  76. package/dist/environment/update-workflows.d.ts +2 -0
  77. package/dist/environment/update-workflows.d.ts.map +1 -0
  78. package/dist/environment/update-workflows.js +169 -0
  79. package/dist/environment/users.d.ts +2 -0
  80. package/dist/environment/users.d.ts.map +1 -0
  81. package/dist/environment/users.js +112 -0
  82. package/dist/environment/utils.d.ts +18 -0
  83. package/dist/environment/utils.d.ts.map +1 -0
  84. package/dist/environment/utils.js +100 -0
  85. package/dist/events/index.js +1115 -247
  86. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +1 -1
  87. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  88. package/dist/migrations/v2.0/checkout-upstream-files.js +1 -1
  89. package/dist/migrations/v2.0/index.js +21 -8
  90. package/dist/notification/index.js +912 -144
  91. package/dist/scopes/index.d.ts +93 -7
  92. package/dist/scopes/index.js +20 -7
  93. package/dist/templates/charts-values/dependencies/values.override.yaml +4 -0
  94. package/dist/templates/charts-values/dependencies/values.yaml +83 -0
  95. package/dist/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
  96. package/dist/templates/charts-values/opencrvs-services/values.yaml +81 -0
  97. package/dist/templates/charts-values/traefik/values.override.yaml +4 -0
  98. package/dist/templates/charts-values/traefik/values.yaml +115 -0
  99. package/dist/templates/inventory/inventory.template.yml +100 -0
  100. package/dist/templates/inventory/production.example.yml +77 -0
  101. package/dist/templates/inventory/qa.example.yml +48 -0
  102. package/opencrvs-toolkit-2.0.0-rc.b0c39c7.tgz +0 -0
  103. package/package.json +20 -2
  104. package/tsconfig.tsbuildinfo +1 -1
  105. package/opencrvs-toolkit-2.0.0-rc.b0a238f.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,
@@ -213,6 +216,10 @@ __export(events_exports, {
213
216
  UUID: () => UUID,
214
217
  UnassignActionInput: () => UnassignActionInput,
215
218
  UserAuditRecordInput: () => UserAuditRecordInput,
219
+ V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS: () => V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS,
220
+ V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP: () => V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP,
221
+ V2_DEFAULT_MOCK_LOCATIONS: () => V2_DEFAULT_MOCK_LOCATIONS,
222
+ V2_DEFAULT_MOCK_LOCATIONS_MAP: () => V2_DEFAULT_MOCK_LOCATIONS_MAP,
216
223
  ValidationConfig: () => ValidationConfig,
217
224
  VerificationActionConfig: () => VerificationActionConfig,
218
225
  VerificationPageConfig: () => VerificationPageConfig,
@@ -234,6 +241,7 @@ __export(events_exports, {
234
241
  ageToDate: () => ageToDate,
235
242
  aggregateActionAnnotations: () => aggregateActionAnnotations,
236
243
  aggregateActionDeclarations: () => aggregateActionDeclarations,
244
+ always: () => always,
237
245
  alwaysTrue: () => alwaysTrue,
238
246
  and: () => and,
239
247
  annotationActions: () => annotationActions,
@@ -241,10 +249,12 @@ __export(events_exports, {
241
249
  applyDraftToEventIndex: () => applyDraftToEventIndex,
242
250
  areCertificateConditionsMet: () => areCertificateConditionsMet,
243
251
  areConditionsMet: () => areConditionsMet,
252
+ buildClientFunctionContext: () => buildClientFunctionContext,
244
253
  buildFormState: () => buildFormState,
245
254
  canAccessEventWithScope: () => canAccessEventWithScope,
246
255
  canAccessOtherUserWithScopes: () => canAccessOtherUserWithScopes,
247
256
  canAccessUserWithScope: () => canAccessUserWithScope,
257
+ compileClientFunction: () => compileClientFunction,
248
258
  compositeFieldTypes: () => compositeFieldTypes,
249
259
  createEmptyDraft: () => createEmptyDraft,
250
260
  createFieldConditionals: () => createFieldConditionals,
@@ -265,6 +275,7 @@ __export(events_exports, {
265
275
  defineWorkqueuesColumns: () => defineWorkqueuesColumns,
266
276
  deserializeQuery: () => deserializeQuery,
267
277
  errorMessages: () => errorMessages,
278
+ evaluate: () => evaluate,
268
279
  event: () => event,
269
280
  eventMetadataLabelMap: () => eventMetadataLabelMap,
270
281
  eventPayloadGenerator: () => eventPayloadGenerator,
@@ -277,6 +288,7 @@ __export(events_exports, {
277
288
  findActiveDraftForEvent: () => findActiveDraftForEvent,
278
289
  findAllFields: () => findAllFields,
279
290
  findLastAssignmentAction: () => findLastAssignmentAction,
291
+ findPendingCorrectionAction: () => findPendingCorrectionAction,
280
292
  findRecordActionPages: () => findRecordActionPages,
281
293
  flag: () => flag,
282
294
  flattenFieldReference: () => flattenFieldReference,
@@ -300,6 +312,7 @@ __export(events_exports, {
300
312
  getActionAnnotation: () => getActionAnnotation,
301
313
  getActionAnnotationFields: () => getActionAnnotationFields,
302
314
  getActionConfig: () => getActionConfig,
315
+ getActionFormFields: () => getActionFormFields,
303
316
  getActionReview: () => getActionReview,
304
317
  getActionReviewFields: () => getActionReviewFields,
305
318
  getAdministrativeAreaHierarchy: () => getAdministrativeAreaHierarchy,
@@ -310,6 +323,7 @@ __export(events_exports, {
310
323
  getAvailableActionsForEvent: () => getAvailableActionsForEvent,
311
324
  getAvailableRolesForUserUpdatePayload: () => getAvailableRolesForUserUpdatePayload,
312
325
  getCompleteActionAnnotation: () => getCompleteActionAnnotation,
326
+ getCompleteActionContent: () => getCompleteActionContent,
313
327
  getCompleteActionDeclaration: () => getCompleteActionDeclaration,
314
328
  getCurrentEventState: () => getCurrentEventState,
315
329
  getCustomActionFields: () => getCustomActionFields,
@@ -318,6 +332,7 @@ __export(events_exports, {
318
332
  getDeclarationFields: () => getDeclarationFields,
319
333
  getDeclarationPages: () => getDeclarationPages,
320
334
  getEventConfigById: () => getEventConfigById,
335
+ getEventFlags: () => getEventFlags,
321
336
  getFilePathsFromEvent: () => getFilePathsFromEvent,
322
337
  getLocationHierarchy: () => getLocationHierarchy,
323
338
  getMixedPath: () => getMixedPath,
@@ -340,6 +355,7 @@ __export(events_exports, {
340
355
  isBulletListFieldType: () => isBulletListFieldType,
341
356
  isButtonFieldType: () => isButtonFieldType,
342
357
  isCheckboxFieldType: () => isCheckboxFieldType,
358
+ isCodeToEvaluate: () => isCodeToEvaluate,
343
359
  isConditionMet: () => isConditionMet,
344
360
  isCountryFieldType: () => isCountryFieldType,
345
361
  isCustomFieldType: () => isCustomFieldType,
@@ -380,6 +396,7 @@ __export(events_exports, {
380
396
  isPageVisible: () => isPageVisible,
381
397
  isParagraphFieldType: () => isParagraphFieldType,
382
398
  isPhoneFieldType: () => isPhoneFieldType,
399
+ isPotentialDuplicate: () => isPotentialDuplicate,
383
400
  isPrintButtonFieldType: () => isPrintButtonFieldType,
384
401
  isQrReaderFieldType: () => isQrReaderFieldType,
385
402
  isQueryParamReaderFieldType: () => isQueryParamReaderFieldType,
@@ -413,12 +430,15 @@ __export(events_exports, {
413
430
  plainDateToLocalDate: () => plainDateToLocalDate,
414
431
  precompileActionSchemas: () => precompileActionSchemas,
415
432
  resolveDateOfEvent: () => resolveDateOfEvent,
433
+ resolveEventCustomFlags: () => resolveEventCustomFlags,
416
434
  resolvePlaceOfEvent: () => resolvePlaceOfEvent,
435
+ runClientFunction: () => runClientFunction,
417
436
  runFieldValidations: () => runFieldValidations,
418
437
  runStructuralValidations: () => runStructuralValidations,
419
438
  safeUnion: () => safeUnion,
420
439
  status: () => status,
421
440
  timePeriodToDateRange: () => timePeriodToDateRange,
441
+ todayISO: () => todayISO,
422
442
  user: () => user,
423
443
  userCanAccessEventWithScopes: () => userCanAccessEventWithScopes,
424
444
  validate: () => validate,
@@ -501,11 +521,13 @@ var scopeOptionsPlaceEvent = z2.object({
501
521
  event: scopeByEvent,
502
522
  placeOfEvent: JurisdictionFilter.optional()
503
523
  }).describe("Options applicable to all record scopes.");
504
- var scopeOptionsDeclared = scopeOptionsPlaceEvent.extend({
524
+ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
525
+ notifiedIn: JurisdictionFilter.optional(),
526
+ notifiedBy: UserFilter.optional(),
505
527
  declaredIn: JurisdictionFilter.optional(),
506
528
  declaredBy: UserFilter.optional()
507
529
  }).describe("Options applicable to actions that may take place after DECLARE");
508
- var AllRecordScopeOptions = scopeOptionsDeclared.extend({
530
+ var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
509
531
  registeredIn: JurisdictionFilter.optional(),
510
532
  registeredBy: UserFilter.optional()
511
533
  }).describe(
@@ -543,6 +565,8 @@ var ResolvedScopeOptionsPlaceEvent = z2.object({
543
565
  "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
544
566
  );
545
567
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
568
+ notifiedIn: UUID.nullish(),
569
+ notifiedBy: z2.string().optional(),
546
570
  declaredIn: UUID.nullish(),
547
571
  declaredBy: z2.string().optional()
548
572
  }).describe(
@@ -588,7 +612,7 @@ var RecordScopeV2 = z2.discriminatedUnion("type", [
588
612
  }),
589
613
  z2.object({
590
614
  type: ScopesWithDeclaredOptions,
591
- options: scopeOptionsDeclared.optional()
615
+ options: scopeOptionsDeclaredOrNotified.optional()
592
616
  }),
593
617
  z2.object({
594
618
  type: ScopesWithFullOptions,
@@ -693,18 +717,27 @@ var unflattenScope = (input) => {
693
717
  return { type, options };
694
718
  };
695
719
  var EncodedScope = z2.string().brand("EncodedScope");
696
- var decodeScope = (query) => {
697
- const scope = qs.parse(query, {
720
+ var decodedScopeCache = /* @__PURE__ */ new Map();
721
+ var decodeScope = (encodedScope) => {
722
+ if (decodedScopeCache.has(encodedScope)) {
723
+ return decodedScopeCache.get(encodedScope);
724
+ }
725
+ const scope = qs.parse(encodedScope, {
698
726
  ignoreQueryPrefix: true,
699
727
  comma: true,
700
728
  allowDots: true
701
729
  });
702
730
  const unflattenedScope = unflattenScope(scope);
703
- return Scope.safeParse(unflattenedScope)?.data;
731
+ const result = Scope.safeParse(unflattenedScope)?.data;
732
+ decodedScopeCache.set(encodedScope, result);
733
+ return result;
704
734
  };
705
735
  var DEFAULT_SCOPE_OPTIONS = {
706
736
  placeOfEvent: JurisdictionFilter.enum.all,
707
- accessLevel: JurisdictionFilter.enum.all
737
+ accessLevel: JurisdictionFilter.enum.all,
738
+ notifiedIn: JurisdictionFilter.enum.all,
739
+ declaredIn: JurisdictionFilter.enum.all,
740
+ registeredIn: JurisdictionFilter.enum.all
708
741
  };
709
742
  function getAcceptedScopesByType({
710
743
  acceptedScopes,
@@ -1077,7 +1110,10 @@ var ActionConditional = z7.discriminatedUnion("type", [
1077
1110
  ShowConditional,
1078
1111
  // Action can be shown to the user in the list but as disabled
1079
1112
  EnableConditional
1080
- ]);
1113
+ ]).meta({
1114
+ id: "ActionConditional",
1115
+ 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."
1116
+ });
1081
1117
  var DisplayOnReviewConditional = z7.object({
1082
1118
  type: z7.literal(ConditionalType.DISPLAY_ON_REVIEW),
1083
1119
  conditional: Conditional
@@ -1092,8 +1128,8 @@ var FieldConditional = z7.discriminatedUnion("type", [
1092
1128
  // Field output can be shown / hidden on the review page
1093
1129
  DisplayOnReviewConditional
1094
1130
  ]).meta({
1095
- description: "Field conditional configuration",
1096
- id: "FieldConditional"
1131
+ id: "FieldConditional",
1132
+ 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."
1097
1133
  });
1098
1134
 
1099
1135
  // ../commons/src/events/FieldType.ts
@@ -1190,6 +1226,11 @@ var FieldTypesToHideInReview = [
1190
1226
  FieldType.ALPHA_PRINT_BUTTON,
1191
1227
  FieldType.ALPHA_HIDDEN
1192
1228
  ];
1229
+ var HiddenFieldTypes = [
1230
+ FieldType.HTTP,
1231
+ FieldType.QUERY_PARAM_READER,
1232
+ FieldType.ALPHA_HIDDEN
1233
+ ];
1193
1234
 
1194
1235
  // ../commons/src/events/FieldValue.ts
1195
1236
  var z12 = __toESM(require("zod/v4"));
@@ -1316,7 +1357,7 @@ function plainDateToLocalDate(date) {
1316
1357
  // ../commons/src/events/FieldValue.ts
1317
1358
  var TextValue = z12.string();
1318
1359
  var HiddenFieldValue = z12.string();
1319
- var NonEmptyTextValue = TextValue.min(1);
1360
+ var NonEmptyTextValue = z12.string().trim().min(1);
1320
1361
  var DateValue = z12.iso.date().describe("Date in the format YYYY-MM-DD");
1321
1362
  var AgeValue = z12.object({
1322
1363
  age: z12.number(),
@@ -1345,6 +1386,7 @@ var DateRangeFieldValue = z12.object({
1345
1386
  var EmailValue = z12.email();
1346
1387
  var CheckboxFieldValue = z12.boolean();
1347
1388
  var NumberFieldValue = z12.number();
1389
+ var SignatureFieldValue = FileFieldValue;
1348
1390
  var ButtonFieldValue = z12.number();
1349
1391
  var VerificationStatusValue = z12.enum([
1350
1392
  "verified",
@@ -1643,8 +1685,9 @@ var RequestedCorrectionAction = ActionBase.extend(
1643
1685
  var ApprovedCorrectionAction = ActionBase.extend(
1644
1686
  z14.object({
1645
1687
  type: z14.literal(ActionType.APPROVE_CORRECTION),
1646
- requestId: z14.string()
1688
+ requestId: z14.string(),
1647
1689
  // TODO move into 'content' property
1690
+ content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
1648
1691
  }).shape
1649
1692
  );
1650
1693
  var RejectedCorrectionAction = ActionBase.extend(
@@ -1736,6 +1779,9 @@ var FlagConfig = z15.object({
1736
1779
  "Indicates if this flag expects an action to be performed to be cleared."
1737
1780
  ),
1738
1781
  label: TranslationConfig.describe("Human readable label of the flag.")
1782
+ }).meta({
1783
+ id: "FlagConfig",
1784
+ description: "Configuration for a custom flag that can be added to or removed from records by event actions."
1739
1785
  });
1740
1786
  var ActionFlagConfig = z15.object({
1741
1787
  id: Flag,
@@ -1743,6 +1789,9 @@ var ActionFlagConfig = z15.object({
1743
1789
  conditional: Conditional.optional().describe(
1744
1790
  "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
1745
1791
  )
1792
+ }).meta({
1793
+ id: "ActionFlagConfig",
1794
+ description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
1746
1795
  });
1747
1796
 
1748
1797
  // ../commons/src/events/EventMetadata.ts
@@ -1772,6 +1821,7 @@ var RegistrationCreationMetadata = ActionCreationMetadata.extend({
1772
1821
  )
1773
1822
  });
1774
1823
  var LegalStatuses = z16.object({
1824
+ [EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
1775
1825
  [EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
1776
1826
  [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
1777
1827
  });
@@ -1913,6 +1963,8 @@ var eventMetadataLabelMap = {
1913
1963
  var EventMetadataDateFieldIdInput = z16.enum([
1914
1964
  "createdAt",
1915
1965
  "updatedAt",
1966
+ "legalStatuses.NOTIFIED.createdAt",
1967
+ "legalStatuses.NOTIFIED.acceptedAt",
1916
1968
  "legalStatuses.DECLARED.createdAt",
1917
1969
  "legalStatuses.DECLARED.acceptedAt",
1918
1970
  "legalStatuses.REGISTERED.createdAt",
@@ -1921,6 +1973,8 @@ var EventMetadataDateFieldIdInput = z16.enum([
1921
1973
  var EventMetadataDateFieldId = z16.enum([
1922
1974
  "event.createdAt",
1923
1975
  "event.updatedAt",
1976
+ "event.legalStatuses.NOTIFIED.createdAt",
1977
+ "event.legalStatuses.NOTIFIED.acceptedAt",
1924
1978
  "event.legalStatuses.DECLARED.createdAt",
1925
1979
  "event.legalStatuses.DECLARED.acceptedAt",
1926
1980
  "event.legalStatuses.REGISTERED.createdAt",
@@ -1980,7 +2034,8 @@ var Range = import_v4.z.object({
1980
2034
  });
1981
2035
  var ContainsFlags = import_v4.z.object({
1982
2036
  anyOf: import_v4.z.array(Flag).optional(),
1983
- noneOf: import_v4.z.array(Flag).optional()
2037
+ noneOf: import_v4.z.array(Flag).optional(),
2038
+ allOf: import_v4.z.array(Flag).optional()
1984
2039
  }).meta({
1985
2040
  id: "ContainsFlags"
1986
2041
  });
@@ -2166,14 +2221,34 @@ var FieldId = import_v43.default.string().superRefine((val, ctx) => {
2166
2221
  }
2167
2222
  }).describe("Unique identifier for the field");
2168
2223
  var FieldReference = import_v43.default.object({
2169
- $$field: FieldId,
2224
+ $$field: FieldId.describe("Id of the field to reference"),
2170
2225
  $$subfield: import_v43.default.array(import_v43.default.string()).optional().default([]).describe(
2171
2226
  'If the FieldValue is an object, subfield can be used to refer to e.g. `["foo", "bar"]` in `{ foo: { bar: 3 } }`'
2227
+ ),
2228
+ $$code: import_v43.default.string().optional().describe(
2229
+ "Serialised client-side function body. When present the expression is evaluated rather than dereferenced."
2230
+ )
2231
+ }).describe(
2232
+ "Reference to a field value, with an optional client-side computation applied."
2233
+ );
2234
+ function isCodeToEvaluate(v) {
2235
+ return !!v && typeof v === "object" && "$$code" in v;
2236
+ }
2237
+ var ComputedDefaultValue = import_v43.default.object({
2238
+ $$code: import_v43.default.string().describe(
2239
+ "Serialised client-side function body. Receives (undefined, context) where context includes $now, $online, and system variables."
2172
2240
  )
2173
- }).describe("Reference to a field by its ID");
2241
+ }).describe("A context-only computation used as a field default value.");
2174
2242
  var ValidationConfig = import_v43.default.object({
2175
- validator: Conditional,
2176
- message: TranslationConfig
2243
+ validator: Conditional.describe(
2244
+ "Conditional expression that must hold for the field value to be considered valid."
2245
+ ),
2246
+ message: TranslationConfig.describe(
2247
+ "Error message displayed when the validator does not hold."
2248
+ )
2249
+ }).meta({
2250
+ id: "ValidationConfig",
2251
+ 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."
2177
2252
  });
2178
2253
  var requiredSchema = import_v43.default.union([
2179
2254
  import_v43.default.boolean(),
@@ -2204,7 +2279,7 @@ var BaseField = import_v43.default.object({
2204
2279
  "Indicates whether the field can be modified during record correction."
2205
2280
  ),
2206
2281
  value: FieldReference.or(import_v43.default.array(FieldReference)).optional().describe(
2207
- "Reference to the source field or fields. When a value is defined, it is copied from the parent field when changed. If multiple references are provided, the first truthy value is used."
2282
+ "Reference to the source field or fields. When a value is defined, it is copied from the parent field when changed. If multiple references are provided, the first truthy value is used. A FieldReference with $$code computes the value via a custom client-side function."
2208
2283
  ),
2209
2284
  analytics: import_v43.default.boolean().default(false).optional().describe(
2210
2285
  "Indicates whether the field is included in analytics. When enabled, its value becomes available in the analytics dashboard."
@@ -2212,30 +2287,40 @@ var BaseField = import_v43.default.object({
2212
2287
  }).describe("Common properties shared across all field types.");
2213
2288
  var Divider = BaseField.extend({
2214
2289
  type: import_v43.default.literal(FieldType.DIVIDER)
2290
+ }).meta({
2291
+ description: "A horizontal line divider",
2292
+ id: "Divider"
2215
2293
  });
2216
2294
  var TextField = BaseField.extend({
2217
2295
  type: import_v43.default.literal(FieldType.TEXT),
2218
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
2296
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2219
2297
  configuration: import_v43.default.object({
2220
2298
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text"),
2221
2299
  type: import_v43.default.enum(["text", "password"]).optional(),
2222
2300
  prefix: TranslationConfig.optional(),
2223
2301
  postfix: TranslationConfig.optional()
2224
2302
  }).default({ type: "text" }).optional()
2225
- }).describe("Text input");
2303
+ }).meta({
2304
+ description: "A text input field",
2305
+ id: "TextField"
2306
+ });
2226
2307
  var NumberField = BaseField.extend({
2227
2308
  type: import_v43.default.literal(FieldType.NUMBER),
2228
- defaultValue: NumberFieldValue.optional(),
2309
+ defaultValue: NumberFieldValue.or(ComputedDefaultValue).optional(),
2229
2310
  configuration: import_v43.default.object({
2230
2311
  min: import_v43.default.number().optional().describe("Minimum value"),
2231
2312
  max: import_v43.default.number().optional().describe("Maximum value"),
2313
+ integer: import_v43.default.boolean().optional().describe("When true, only whole numbers are allowed"),
2232
2314
  prefix: TranslationConfig.optional(),
2233
2315
  postfix: TranslationConfig.optional()
2234
2316
  }).optional()
2235
- }).describe("Number input");
2317
+ }).meta({
2318
+ description: "A number input field",
2319
+ id: "NumberField"
2320
+ });
2236
2321
  var TextAreaField = BaseField.extend({
2237
2322
  type: import_v43.default.literal(FieldType.TEXTAREA),
2238
- defaultValue: NonEmptyTextValue.optional(),
2323
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2239
2324
  configuration: import_v43.default.object({
2240
2325
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text"),
2241
2326
  rows: import_v43.default.number().optional().describe("Number of visible text lines"),
@@ -2243,7 +2328,10 @@ var TextAreaField = BaseField.extend({
2243
2328
  prefix: TranslationConfig.optional(),
2244
2329
  postfix: TranslationConfig.optional()
2245
2330
  }).default({ rows: 4 }).optional()
2246
- }).describe("Multiline text input");
2331
+ }).meta({
2332
+ description: "A multiline text input",
2333
+ id: "TextAreaField"
2334
+ });
2247
2335
  var ImageMimeType = import_v43.default.enum([
2248
2336
  "image/png",
2249
2337
  "image/jpg",
@@ -2266,58 +2354,76 @@ var SignatureField = BaseField.extend({
2266
2354
  signaturePromptLabel: TranslationConfig.describe(
2267
2355
  "Title of the signature modal"
2268
2356
  ),
2269
- defaultValue: FieldValue.optional(),
2357
+ defaultValue: SignatureFieldValue.or(ComputedDefaultValue).optional(),
2270
2358
  configuration: import_v43.default.object({
2271
2359
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
2272
2360
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
2273
2361
  }).default({
2274
2362
  maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
2275
2363
  })
2276
- }).describe("Signature input field");
2364
+ }).meta({
2365
+ description: "A signature input field",
2366
+ id: "SignatureField"
2367
+ });
2277
2368
  var EmailField = BaseField.extend({
2278
2369
  type: import_v43.default.literal(FieldType.EMAIL),
2279
2370
  configuration: import_v43.default.object({
2280
2371
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text")
2281
2372
  }).default({ maxLength: 255 }).optional(),
2282
- defaultValue: NonEmptyTextValue.optional()
2373
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional()
2374
+ }).meta({
2375
+ description: "An email input field",
2376
+ id: "EmailField"
2283
2377
  });
2284
2378
  var DateField = BaseField.extend({
2285
2379
  type: import_v43.default.literal(FieldType.DATE),
2286
- defaultValue: SerializedNowDateTime.or(PlainDate).optional().describe("Default date value(yyyy-MM-dd)"),
2380
+ defaultValue: SerializedNowDateTime.or(PlainDate).or(ComputedDefaultValue).optional().describe("Default date value(yyyy-MM-dd)"),
2287
2381
  configuration: import_v43.default.object({
2288
2382
  notice: TranslationConfig.describe(
2289
2383
  "Text to display above the date input"
2290
2384
  ).optional()
2291
2385
  }).optional()
2292
- }).describe("A single date input (yyyy-MM-dd)");
2386
+ }).meta({
2387
+ description: "A date input (yyyy-MM-dd)",
2388
+ id: "DateField"
2389
+ });
2293
2390
  var AgeField = BaseField.extend({
2294
2391
  type: import_v43.default.literal(FieldType.AGE),
2295
- defaultValue: NumberFieldValue.optional(),
2392
+ defaultValue: NumberFieldValue.or(ComputedDefaultValue).optional(),
2296
2393
  configuration: import_v43.default.object({
2297
2394
  asOfDate: FieldReference,
2298
2395
  prefix: TranslationConfig.optional(),
2299
2396
  postfix: TranslationConfig.optional()
2300
2397
  })
2301
- }).describe("An age input field which uses the current date as the asOfDate");
2398
+ }).meta({
2399
+ description: "An age input field which uses the current date as the asOfDate",
2400
+ id: "AgeField"
2401
+ });
2302
2402
  var TimeField = BaseField.extend({
2303
2403
  type: import_v43.default.literal(FieldType.TIME),
2304
- defaultValue: SerializedNowDateTime.or(TimeValue).optional().describe("Default time value (HH-mm)"),
2404
+ defaultValue: SerializedNowDateTime.or(TimeValue).or(ComputedDefaultValue).optional().describe("Default time value (HH-mm)"),
2305
2405
  configuration: import_v43.default.object({
2306
2406
  use12HourFormat: import_v43.default.boolean().optional().describe("Whether to use 12-hour format"),
2307
2407
  notice: TranslationConfig.describe(
2308
2408
  "Text to display above the time input"
2309
2409
  ).optional()
2310
2410
  }).optional()
2311
- }).describe("A single date input (HH-mm)");
2411
+ }).meta({
2412
+ description: "A single time input (HH-mm)",
2413
+ id: "TimeField"
2414
+ });
2312
2415
  var DateRangeField = BaseField.extend({
2313
2416
  type: import_v43.default.literal(FieldType.DATE_RANGE),
2314
- defaultValue: DateRangeFieldValue.optional(),
2417
+ defaultValue: DateRangeFieldValue.or(ComputedDefaultValue).optional(),
2315
2418
  configuration: import_v43.default.object({
2316
2419
  notice: TranslationConfig.describe(
2317
2420
  "Text to display above the date input"
2318
2421
  ).optional()
2319
2422
  }).optional()
2320
- }).describe("A date range input ({ start: yyyy-MM-dd, end: yyyy-MM-dd })");
2423
+ }).meta({
2424
+ description: "A date range input ({ start: yyyy-MM-dd, end: yyyy-MM-dd })",
2425
+ id: "DateRangeField"
2426
+ });
2321
2427
  var HtmlFontVariant = import_v43.default.enum([
2322
2428
  "reg12",
2323
2429
  "reg14",
@@ -2361,21 +2467,33 @@ var ImageViewField = BaseField.extend({
2361
2467
  type: import_v43.default.literal(FieldType.IMAGE_VIEW),
2362
2468
  defaultValue: NonEmptyTextValue.optional(),
2363
2469
  configuration: ImageConfiguration
2364
- }).describe("A read-only image component for form pages");
2470
+ }).meta({
2471
+ description: "A read-only image component for form pages",
2472
+ id: "ImageViewField"
2473
+ });
2365
2474
  var Paragraph = BaseField.extend({
2366
2475
  type: import_v43.default.literal(FieldType.PARAGRAPH),
2367
2476
  configuration: ParagraphConfiguration
2368
- }).describe("A read-only HTML <p> paragraph");
2477
+ }).meta({
2478
+ description: "A read-only HTML <p> paragraph",
2479
+ id: "Paragraph"
2480
+ });
2369
2481
  var Heading = BaseField.extend({
2370
2482
  type: import_v43.default.literal(FieldType.HEADING),
2371
2483
  configuration: HeadingConfiguration
2372
- }).describe("A read-only heading component for form pages");
2484
+ }).meta({
2485
+ description: "A read-only heading component for form pages",
2486
+ id: "Heading"
2487
+ });
2373
2488
  var PageHeader = BaseField.extend({
2374
2489
  type: import_v43.default.literal(FieldType.PAGE_HEADER)
2375
- }).describe("A read-only header component for form pages");
2490
+ }).meta({
2491
+ description: "A read-only header component for form pages",
2492
+ id: "PageHeader"
2493
+ });
2376
2494
  var File = BaseField.extend({
2377
2495
  type: import_v43.default.literal(FieldType.FILE),
2378
- defaultValue: FileFieldValue.optional(),
2496
+ defaultValue: FileFieldValue.or(ComputedDefaultValue).optional(),
2379
2497
  configuration: import_v43.default.object({
2380
2498
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
2381
2499
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
@@ -2391,7 +2509,10 @@ var File = BaseField.extend({
2391
2509
  }).default({
2392
2510
  maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
2393
2511
  })
2394
- }).describe("File upload");
2512
+ }).meta({
2513
+ description: "A file upload field",
2514
+ id: "File"
2515
+ });
2395
2516
  var SelectOption = import_v43.default.object({
2396
2517
  value: import_v43.default.string().describe("The value of the option"),
2397
2518
  label: import_v43.default.union([import_v43.default.string(), TranslationConfig]).describe("The label of the option"),
@@ -2399,7 +2520,7 @@ var SelectOption = import_v43.default.object({
2399
2520
  });
2400
2521
  var NumberWithUnitField = BaseField.extend({
2401
2522
  type: import_v43.default.literal(FieldType.NUMBER_WITH_UNIT),
2402
- defaultValue: NumberWithUnitFieldValue.optional(),
2523
+ defaultValue: NumberWithUnitFieldValue.or(ComputedDefaultValue).optional(),
2403
2524
  options: import_v43.default.array(SelectOption).describe("A list of options for the unit select"),
2404
2525
  configuration: import_v43.default.object({
2405
2526
  min: import_v43.default.number().optional().describe("Minimum value of the number field"),
@@ -2408,17 +2529,23 @@ var NumberWithUnitField = BaseField.extend({
2408
2529
  "Placeholder for the number field"
2409
2530
  )
2410
2531
  }).optional()
2411
- }).describe("Number with unit input");
2532
+ }).meta({
2533
+ description: "A number with unit input field",
2534
+ id: "NumberWithUnitField"
2535
+ });
2412
2536
  var RadioGroup = BaseField.extend({
2413
2537
  type: import_v43.default.literal(FieldType.RADIO_GROUP),
2414
- defaultValue: TextValue.optional(),
2538
+ defaultValue: TextValue.or(ComputedDefaultValue).optional(),
2415
2539
  options: import_v43.default.array(SelectOption).describe("A list of options"),
2416
2540
  configuration: import_v43.default.object({
2417
2541
  styles: import_v43.default.object({
2418
2542
  size: import_v43.default.enum(["NORMAL", "LARGE"]).optional()
2419
2543
  }).optional()
2420
2544
  }).optional()
2421
- }).describe("Grouped radio options");
2545
+ }).meta({
2546
+ description: "A grouped radio button field",
2547
+ id: "RadioGroup"
2548
+ });
2422
2549
  var BulletList = BaseField.extend({
2423
2550
  type: import_v43.default.literal(FieldType.BULLET_LIST),
2424
2551
  items: import_v43.default.array(TranslationConfig).describe("A list of items"),
@@ -2427,10 +2554,13 @@ var BulletList = BaseField.extend({
2427
2554
  fontVariant: HtmlFontVariant.optional()
2428
2555
  }).optional()
2429
2556
  }).default({})
2430
- }).describe("A list of bullet points");
2557
+ }).meta({
2558
+ description: "A list of bullet points",
2559
+ id: "BulletList"
2560
+ });
2431
2561
  var Select = BaseField.extend({
2432
2562
  type: import_v43.default.literal(FieldType.SELECT),
2433
- defaultValue: TextValue.optional(),
2563
+ defaultValue: TextValue.or(ComputedDefaultValue).optional(),
2434
2564
  options: import_v43.default.array(SelectOption).describe("A list of options"),
2435
2565
  noOptionsMessage: TranslationConfig.optional().describe(
2436
2566
  `
@@ -2442,16 +2572,22 @@ var Select = BaseField.extend({
2442
2572
  { ..., defaultMessage: "'{input}' is not listed among the health facilities." }
2443
2573
  `
2444
2574
  )
2445
- }).describe("Select input");
2575
+ }).meta({
2576
+ description: "A select input field",
2577
+ id: "Select"
2578
+ });
2446
2579
  var SelectDateRangeOption = import_v43.default.object({
2447
2580
  value: SelectDateRangeValue.describe("The value of the option"),
2448
2581
  label: TranslationConfig.describe("The label of the option")
2449
2582
  });
2450
2583
  var SelectDateRangeField = BaseField.extend({
2451
2584
  type: import_v43.default.literal(FieldType.SELECT_DATE_RANGE),
2452
- defaultValue: SelectDateRangeValue.optional(),
2585
+ defaultValue: SelectDateRangeValue.or(ComputedDefaultValue).optional(),
2453
2586
  options: import_v43.default.array(SelectDateRangeOption).describe("A list of options")
2454
- }).describe("Select input with date range options");
2587
+ }).meta({
2588
+ description: "A date range selection field",
2589
+ id: "SelectDateRangeField"
2590
+ });
2455
2591
  var NameConfig = import_v43.default.object({
2456
2592
  firstname: import_v43.default.object({ required: requiredSchema, label: TranslationConfig.optional() }).optional(),
2457
2593
  middlename: import_v43.default.object({ required: requiredSchema, label: TranslationConfig.optional() }).optional(),
@@ -2463,7 +2599,7 @@ var NameField = BaseField.extend({
2463
2599
  firstname: SerializedUserField.or(NonEmptyTextValue).optional(),
2464
2600
  middlename: SerializedUserField.or(NonEmptyTextValue).optional(),
2465
2601
  surname: SerializedUserField.or(NonEmptyTextValue).optional()
2466
- }).optional(),
2602
+ }).or(ComputedDefaultValue).optional(),
2467
2603
  configuration: import_v43.default.object({
2468
2604
  name: NameConfig.default({
2469
2605
  firstname: { required: true },
@@ -2482,26 +2618,41 @@ var NameField = BaseField.extend({
2482
2618
  surname: { required: true }
2483
2619
  }
2484
2620
  }).optional()
2485
- }).describe("Name input field");
2621
+ }).meta({
2622
+ description: "A field for entering a persons name",
2623
+ id: "NameField"
2624
+ });
2486
2625
  var PhoneField = BaseField.extend({
2487
- defaultValue: NonEmptyTextValue.optional(),
2626
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2488
2627
  type: import_v43.default.literal(FieldType.PHONE)
2489
- }).describe("Phone input field");
2628
+ }).meta({
2629
+ description: "A field for entering a phone number",
2630
+ id: "PhoneField"
2631
+ });
2490
2632
  var IdField = BaseField.extend({
2491
- defaultValue: NonEmptyTextValue.optional(),
2633
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2492
2634
  type: import_v43.default.literal(FieldType.ID)
2493
- }).describe("ID input field");
2635
+ }).meta({
2636
+ description: "A field for entering an ID",
2637
+ id: "IdField"
2638
+ });
2494
2639
  var Checkbox = BaseField.extend({
2495
2640
  type: import_v43.default.literal(FieldType.CHECKBOX),
2496
- defaultValue: CheckboxFieldValue.default(false)
2497
- }).describe("Boolean checkbox field");
2641
+ defaultValue: CheckboxFieldValue.or(ComputedDefaultValue).default(false)
2642
+ }).meta({
2643
+ description: "A boolean checkbox field",
2644
+ id: "Checkbox"
2645
+ });
2498
2646
  var Country = BaseField.extend({
2499
2647
  type: import_v43.default.literal(FieldType.COUNTRY),
2500
- defaultValue: NonEmptyTextValue.optional(),
2648
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2501
2649
  optionOverrides: import_v43.default.array(SelectOption.omit({ label: true })).optional().describe(
2502
2650
  "Conditionals for specific countries. Countries not listed are always shown and enabled."
2503
2651
  )
2504
- }).describe("Country select field");
2652
+ }).meta({
2653
+ description: "A field for selecting a country",
2654
+ id: "Country"
2655
+ });
2505
2656
  var AllowedLocations = JurisdictionReference.optional().describe(
2506
2657
  "Limits which location options are selectable depending on user jurisdiction and location."
2507
2658
  );
@@ -2510,28 +2661,33 @@ var AdministrativeAreas = import_v43.default.enum([
2510
2661
  "HEALTH_FACILITY",
2511
2662
  "CRVS_OFFICE"
2512
2663
  ]);
2513
- var AdministrativeAreaConfiguration = import_v43.default.object({
2514
- partOf: FieldReference.optional().describe("Parent location"),
2515
- type: AdministrativeAreas,
2516
- allowedLocations: AllowedLocations
2517
- }).describe("Administrative area options");
2518
2664
  var AdministrativeAreaField = BaseField.extend({
2519
2665
  type: import_v43.default.literal(FieldType.ADMINISTRATIVE_AREA),
2520
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
2521
- configuration: AdministrativeAreaConfiguration
2522
- }).describe("Administrative area input field e.g. facility, office");
2666
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2667
+ configuration: import_v43.default.object({
2668
+ partOf: FieldReference.optional().describe("Parent location"),
2669
+ type: AdministrativeAreas,
2670
+ allowedLocations: AllowedLocations
2671
+ }).describe("Administrative area options")
2672
+ }).meta({
2673
+ description: "Administrative area input field",
2674
+ id: "AdministrativeAreaField"
2675
+ });
2523
2676
  var LocationInput = BaseField.extend({
2524
2677
  type: import_v43.default.literal(FieldType.LOCATION),
2525
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
2678
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2526
2679
  configuration: import_v43.default.object({
2527
2680
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
2528
2681
  allowedLocations: AllowedLocations
2529
2682
  }).optional()
2530
- }).describe("Input field for a location");
2683
+ }).meta({
2684
+ description: "A field for selecting a location",
2685
+ id: "LocationInput"
2686
+ });
2531
2687
  var FileUploadWithOptions = BaseField.extend({
2532
2688
  type: import_v43.default.literal(FieldType.FILE_WITH_OPTIONS),
2533
2689
  options: import_v43.default.array(SelectOption).describe("A list of options"),
2534
- defaultValue: FileFieldWithOptionValue.optional(),
2690
+ defaultValue: FileFieldWithOptionValue.or(ComputedDefaultValue).optional(),
2535
2691
  configuration: import_v43.default.object({
2536
2692
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
2537
2693
  maxImageSize: import_v43.default.object({
@@ -2541,15 +2697,18 @@ var FileUploadWithOptions = BaseField.extend({
2541
2697
  }).default({
2542
2698
  maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
2543
2699
  })
2700
+ }).meta({
2701
+ description: "A field for uploading files with file type options",
2702
+ id: "FileUploadWithOptions"
2544
2703
  });
2545
2704
  var Facility = BaseField.extend({
2546
2705
  type: import_v43.default.literal(FieldType.FACILITY),
2547
- defaultValue: NonEmptyTextValue.optional(),
2706
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2548
2707
  configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2549
2708
  }).describe("Input field for a facility");
2550
2709
  var Office = BaseField.extend({
2551
2710
  type: import_v43.default.literal(FieldType.OFFICE),
2552
- defaultValue: NonEmptyTextValue.optional(),
2711
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2553
2712
  configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2554
2713
  }).describe("Input field for an office");
2555
2714
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
@@ -2585,8 +2744,11 @@ var Address = BaseField.extend({
2585
2744
  ).optional(),
2586
2745
  allowedLocations: AllowedLocations
2587
2746
  }).optional(),
2588
- defaultValue: DefaultAddressFieldValue.optional()
2589
- }).describe("Address input field \u2013 a combination of location and text fields");
2747
+ defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
2748
+ }).meta({
2749
+ description: "Address input field \u2013 a combination of location and text fields",
2750
+ id: "Address"
2751
+ });
2590
2752
  var StaticDataEntry = import_v43.default.object({
2591
2753
  id: import_v43.default.string().describe("ID for the data entry."),
2592
2754
  label: TranslationConfig,
@@ -2601,7 +2763,10 @@ var DataField = BaseField.extend({
2601
2763
  subtitle: TranslationConfig.optional(),
2602
2764
  data: import_v43.default.array(DataEntry)
2603
2765
  })
2604
- }).describe("Data field for displaying read-only data");
2766
+ }).meta({
2767
+ description: "A field for displaying a table of read-only data",
2768
+ id: "DataField"
2769
+ });
2605
2770
  var ButtonSize = import_v43.default.enum(["small", "medium", "large"]);
2606
2771
  var ButtonType = import_v43.default.enum([
2607
2772
  "primary",
@@ -2626,13 +2791,19 @@ var ButtonConfiguration = import_v43.default.object({
2626
2791
  });
2627
2792
  var ButtonField = BaseField.extend({
2628
2793
  type: import_v43.default.literal(FieldType.BUTTON),
2629
- defaultValue: ButtonFieldValue.optional(),
2794
+ defaultValue: ButtonFieldValue.or(ComputedDefaultValue).optional(),
2630
2795
  configuration: ButtonConfiguration
2631
- }).describe("Generic button without any built-in functionality");
2796
+ }).meta({
2797
+ description: "A generic button that can be used to trigger an action",
2798
+ id: "ButtonField"
2799
+ });
2632
2800
  var FieldGroup = BaseField.extend({
2633
2801
  type: import_v43.default.literal(FieldType.FIELD_GROUP),
2634
2802
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
2635
2803
  fields: import_v43.default.lazy(() => import_v43.default.array(FieldConfig))
2804
+ }).meta({
2805
+ description: "A group of fields that are displayed together",
2806
+ id: "FieldGroup"
2636
2807
  });
2637
2808
  var AlphaPrintButton = BaseField.extend({
2638
2809
  type: import_v43.default.literal(FieldType.ALPHA_PRINT_BUTTON),
@@ -2642,10 +2813,13 @@ var AlphaPrintButton = BaseField.extend({
2642
2813
  "Label for the print button"
2643
2814
  )
2644
2815
  })
2645
- }).describe("Print button field for printing certificates");
2816
+ }).meta({
2817
+ description: "An experimental print button field for printing certificates during the declaration process",
2818
+ id: "AlphaPrintButton"
2819
+ });
2646
2820
  var HttpField = BaseField.extend({
2647
2821
  type: import_v43.default.literal(FieldType.HTTP),
2648
- defaultValue: HttpFieldValue.optional(),
2822
+ defaultValue: HttpFieldValue.or(ComputedDefaultValue).optional(),
2649
2823
  configuration: import_v43.default.object({
2650
2824
  trigger: FieldReference.optional().describe(
2651
2825
  "Reference to the field that triggers the HTTP request when its value changes. If not provided, the HTTP request is triggered once on component mount."
@@ -2658,20 +2832,30 @@ var HttpField = BaseField.extend({
2658
2832
  params: import_v43.default.record(import_v43.default.string(), import_v43.default.union([import_v43.default.string(), FieldReference])).optional(),
2659
2833
  timeout: import_v43.default.number().default(15e3).describe("Request timeout in milliseconds")
2660
2834
  })
2661
- }).describe("HTTP request function triggered by a button click or other event");
2835
+ }).meta({
2836
+ 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.",
2837
+ id: "HttpField"
2838
+ });
2662
2839
  var AutocompleteField = BaseField.extend({
2663
2840
  type: import_v43.default.literal(FieldType.AUTOCOMPLETE),
2664
2841
  configuration: import_v43.default.object({
2665
- url: import_v43.default.string().describe("URL to fetch autocomplete suggestions from").optional(),
2842
+ url: import_v43.default.string().describe(
2843
+ "URL to fetch autocomplete suggestions from. This should be a country config server endpoint."
2844
+ ).optional(),
2666
2845
  method: import_v43.default.enum(["GET", "POST"]).default("GET").optional(),
2667
2846
  defaultOptions: import_v43.default.array(
2668
2847
  import_v43.default.object({
2669
2848
  label: import_v43.default.string(),
2670
2849
  value: import_v43.default.string()
2671
2850
  })
2672
- ).optional()
2851
+ ).optional().describe(
2852
+ "Manual entry is supported through configuration, allowing users to provide values not currently represented in the dataset."
2853
+ )
2673
2854
  })
2674
- }).describe("Autocomplete input field");
2855
+ }).meta({
2856
+ 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.",
2857
+ id: "AutocompleteField"
2858
+ });
2675
2859
  var SearchField = HttpField.extend({
2676
2860
  type: import_v43.default.literal(FieldType.SEARCH),
2677
2861
  configuration: SearchQuery.pick({
@@ -2704,6 +2888,9 @@ var SearchField = HttpField.extend({
2704
2888
  ok: TranslationConfig.optional()
2705
2889
  }).optional()
2706
2890
  })
2891
+ }).meta({
2892
+ description: "A search input field",
2893
+ id: "SearchField"
2707
2894
  });
2708
2895
  var LinkButtonField = BaseField.extend({
2709
2896
  type: import_v43.default.literal(FieldType.LINK_BUTTON),
@@ -2712,28 +2899,35 @@ var LinkButtonField = BaseField.extend({
2712
2899
  text: TranslationConfig.describe("Text to display on the button"),
2713
2900
  icon: import_v43.default.string().optional().describe("Icon for the button. You can find icons from OpenCRVS UI-Kit.")
2714
2901
  })
2715
- }).describe("Button that opens a link");
2902
+ }).meta({
2903
+ description: "A button that opens a URL link",
2904
+ id: "LinkButtonField"
2905
+ });
2716
2906
  var VerificationStatus = BaseField.extend({
2717
2907
  type: import_v43.default.literal(FieldType.VERIFICATION_STATUS),
2718
- defaultValue: VerificationStatusValue.optional(),
2908
+ defaultValue: VerificationStatusValue.or(ComputedDefaultValue).optional(),
2719
2909
  configuration: import_v43.default.object({
2720
2910
  status: TranslationConfig.describe("Text to display on the status pill."),
2721
2911
  description: TranslationConfig.describe(
2722
2912
  "Explaining text on the banner in form."
2723
2913
  )
2724
2914
  })
2915
+ }).meta({
2916
+ 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.",
2917
+ id: "VerificationStatus"
2725
2918
  });
2726
2919
  var QueryParamReaderField = BaseField.extend({
2727
2920
  type: import_v43.default.literal(FieldType.QUERY_PARAM_READER),
2728
2921
  configuration: import_v43.default.object({
2729
2922
  pickParams: import_v43.default.array(import_v43.default.string()).describe("List of query parameters to read from the URL")
2730
2923
  })
2731
- }).describe(
2732
- "A field that maps URL query params into form values and clears them afterward"
2733
- );
2924
+ }).meta({
2925
+ description: "A field that maps URL query params into form values and clears them afterward",
2926
+ id: "QueryParamReaderField"
2927
+ });
2734
2928
  var QrReaderField = BaseField.extend({
2735
2929
  type: import_v43.default.literal(FieldType.QR_READER),
2736
- defaultValue: QrReaderFieldValue.optional(),
2930
+ defaultValue: QrReaderFieldValue.or(ComputedDefaultValue).optional(),
2737
2931
  configuration: import_v43.default.object({
2738
2932
  validator: import_v43.default.any().meta({
2739
2933
  description: "JSON Schema to validate the scanned QR code data against before populating the form fields.",
@@ -2741,21 +2935,27 @@ var QrReaderField = BaseField.extend({
2741
2935
  })
2742
2936
  }).optional()
2743
2937
  }).meta({
2744
- description: "Configuration for QR code reader field, including optional JSON Schema validator.",
2938
+ description: "QR code reader field, including optional JSON Schema validator.",
2745
2939
  id: "QrReaderField"
2746
2940
  });
2747
2941
  var IdReaderField = BaseField.extend({
2748
2942
  type: import_v43.default.literal(FieldType.ID_READER),
2749
- defaultValue: IdReaderFieldValue.optional(),
2943
+ defaultValue: IdReaderFieldValue.or(ComputedDefaultValue).optional(),
2750
2944
  methods: import_v43.default.array(
2751
2945
  import_v43.default.union([QrReaderField, LinkButtonField]).describe("Methods for reading an ID")
2752
2946
  )
2947
+ }).meta({
2948
+ description: "A wrapper around nested form fields, specifically QR_READER and LINK_BUTTON. It can hold the QR_READERs value.",
2949
+ id: "IdReaderField"
2753
2950
  });
2754
2951
  var CustomField = BaseField.extend({
2755
2952
  type: import_v43.default.literal(FieldType._EXPERIMENTAL_CUSTOM),
2756
2953
  defaultValue: CustomFieldValue.optional(),
2757
2954
  src: import_v43.default.string().describe("Module source path for the custom field component"),
2758
2955
  configuration: import_v43.default.unknown().optional()
2956
+ }).meta({
2957
+ description: "An expiremental custom field that is defined by a module source path",
2958
+ id: "CustomField"
2759
2959
  });
2760
2960
  var FieldStyleVariant = import_v43.default.enum(["default", "highlighted"]);
2761
2961
  var LoaderField = BaseField.extend({
@@ -2765,22 +2965,25 @@ var LoaderField = BaseField.extend({
2765
2965
  configuration: import_v43.default.object({
2766
2966
  text: TranslationConfig.describe("Display text above the loading spinner")
2767
2967
  })
2768
- }).describe(
2769
- "A non-interactive field that indicates an in progress operation in form"
2770
- );
2968
+ }).meta({
2969
+ description: "A non-interactive field that indicates an in progress operation in form",
2970
+ id: "LoaderField"
2971
+ });
2771
2972
  var HiddenField = BaseField.extend({
2772
2973
  type: import_v43.default.literal(FieldType.ALPHA_HIDDEN),
2773
2974
  required: import_v43.default.boolean().default(false).optional(),
2774
2975
  defaultValue: TextValue.optional()
2775
- }).describe(
2776
- "A non-interactive, hidden field that only hold a value in the form"
2777
- );
2976
+ }).meta({
2977
+ description: "A non-interactive, hidden field that only hold a value in the form",
2978
+ id: "HiddenField"
2979
+ });
2778
2980
  var UserRoleField = BaseField.extend({
2779
2981
  type: import_v43.default.literal(FieldType.USER_ROLE),
2780
2982
  defaultValue: TextValue.optional()
2781
- }).describe(
2782
- "A select dropdown that is automatically populated with available user roles"
2783
- );
2983
+ }).meta({
2984
+ description: "A select dropdown that is automatically populated with available user roles",
2985
+ id: "UserRoleField"
2986
+ });
2784
2987
  var FieldConfig = import_v43.default.discriminatedUnion("type", [
2785
2988
  FieldGroup,
2786
2989
  Address,
@@ -2879,16 +3082,19 @@ var VerificationPageConfig = FormPageConfig.extend({
2879
3082
  type: z21.literal(PageTypes.enum.VERIFICATION),
2880
3083
  actions: VerificationActionConfig
2881
3084
  });
2882
- var PageConfig = z21.discriminatedUnion("type", [
2883
- FormPageConfig,
2884
- VerificationPageConfig
2885
- ]);
3085
+ var PageConfig = z21.discriminatedUnion("type", [FormPageConfig, VerificationPageConfig]).meta({
3086
+ id: "PageConfig",
3087
+ 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."
3088
+ });
2886
3089
 
2887
3090
  // ../commons/src/events/FormConfig.ts
2888
3091
  var DeclarationFormConfig = z22.object({
2889
3092
  label: TranslationConfig.describe("Human readable description of the form"),
2890
3093
  pages: z22.array(FormPageConfig)
2891
- }).describe("Configuration of the declaration form.");
3094
+ }).meta({
3095
+ id: "DeclarationFormConfig",
3096
+ description: "Configuration of the declaration form."
3097
+ });
2892
3098
  var ActionFormConfig = z22.object({
2893
3099
  label: TranslationConfig.describe("Human readable description of the form"),
2894
3100
  pages: z22.array(PageConfig)
@@ -2988,6 +3194,9 @@ var DeduplicationConfig = z23.object({
2988
3194
  id: z23.string(),
2989
3195
  label: TranslationConfig,
2990
3196
  query: Clause
3197
+ }).meta({
3198
+ id: "DeduplicationConfig",
3199
+ 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."
2991
3200
  });
2992
3201
 
2993
3202
  // ../commons/src/events/ActionConfig.ts
@@ -3016,6 +3225,9 @@ var ActionConfigBase = z24.object({
3016
3225
  var DeclarationActionBase = ActionConfigBase.extend({
3017
3226
  deduplication: DeduplicationConfig.optional()
3018
3227
  });
3228
+ var actionConfirmationForm = z24.array(FieldConfig).optional().describe(
3229
+ "Fields rendered on the action confirmation dialog. Submitted values are stored in the action annotation and shown in the audit history."
3230
+ );
3019
3231
  var ReadActionConfig = ActionConfigBase.extend(
3020
3232
  z24.object({
3021
3233
  type: z24.literal(ActionType.READ),
@@ -3025,12 +3237,19 @@ var ReadActionConfig = ActionConfigBase.extend(
3025
3237
  conditionals: z24.never().optional().describe("Read-action can not be disabled or hidden with conditionals.")
3026
3238
  }).shape
3027
3239
  );
3240
+ var NotifyConfig = ActionConfigBase.extend(
3241
+ z24.object({
3242
+ type: z24.literal(ActionType.NOTIFY),
3243
+ form: actionConfirmationForm
3244
+ }).shape
3245
+ );
3028
3246
  var DeclareConfig = DeclarationActionBase.extend(
3029
3247
  z24.object({
3030
3248
  type: z24.literal(ActionType.DECLARE),
3031
3249
  review: DeclarationReviewConfig.describe(
3032
3250
  "Configuration of the review page fields."
3033
3251
  ),
3252
+ form: actionConfirmationForm,
3034
3253
  dialogCopy: z24.object({
3035
3254
  notify: TranslationConfig.describe(
3036
3255
  "Confirmation text for the notify action"
@@ -3046,7 +3265,8 @@ var DeclareConfig = DeclarationActionBase.extend(
3046
3265
  );
3047
3266
  var ArchiveConfig = ActionConfigBase.extend(
3048
3267
  z24.object({
3049
- type: z24.literal(ActionType.ARCHIVE)
3268
+ type: z24.literal(ActionType.ARCHIVE),
3269
+ form: actionConfirmationForm
3050
3270
  }).shape
3051
3271
  );
3052
3272
  var EditActionConfig = ActionConfigBase.extend(
@@ -3067,12 +3287,14 @@ var EditActionConfig = ActionConfigBase.extend(
3067
3287
  );
3068
3288
  var RejectConfig = ActionConfigBase.extend(
3069
3289
  z24.object({
3070
- type: z24.literal(ActionType.REJECT)
3290
+ type: z24.literal(ActionType.REJECT),
3291
+ form: actionConfirmationForm
3071
3292
  }).shape
3072
3293
  );
3073
3294
  var RegisterConfig = DeclarationActionBase.extend(
3074
3295
  z24.object({
3075
- type: z24.literal(ActionType.REGISTER)
3296
+ type: z24.literal(ActionType.REGISTER),
3297
+ form: actionConfirmationForm
3076
3298
  }).shape
3077
3299
  );
3078
3300
  var PrintCertificateActionConfig = ActionConfigBase.extend(
@@ -3105,17 +3327,46 @@ var ActionConfig = z24.discriminatedUnion("type", [
3105
3327
  * OpenAPI references are defined here so our generated OpenAPI spec knows to reuse the models
3106
3328
  * and treat them as "models" instead of duplicating the data structure in each endpoint.
3107
3329
  */
3108
- ReadActionConfig.meta({ id: "ReadActionConfig" }),
3109
- DeclareConfig.meta({ id: "DeclareActionConfig" }),
3110
- RejectConfig.meta({ id: "RejectActionConfig" }),
3111
- RegisterConfig.meta({ id: "RegisterActionConfig" }),
3330
+ ReadActionConfig.meta({
3331
+ id: "ReadActionConfig",
3332
+ description: "Configuration for the read action \u2014 defines the record-tab content displayed on the event overview page."
3333
+ }),
3334
+ NotifyConfig.meta({
3335
+ id: "NotifyActionConfig",
3336
+ description: "Configuration for the notify action. When present, NOTIFY uses this config independently from DECLARE. When absent, NOTIFY falls back to the DeclareActionConfig."
3337
+ }),
3338
+ DeclareConfig.meta({
3339
+ id: "DeclareActionConfig",
3340
+ description: "Configuration for the declare action. Includes review-page fields. NOTIFY falls back to this config when no dedicated NotifyActionConfig is provided."
3341
+ }),
3342
+ RejectConfig.meta({
3343
+ id: "RejectActionConfig",
3344
+ description: "Configuration for rejecting a record before registration."
3345
+ }),
3346
+ RegisterConfig.meta({
3347
+ id: "RegisterActionConfig",
3348
+ description: "Configuration for registering a record."
3349
+ }),
3112
3350
  PrintCertificateActionConfig.meta({
3113
- id: "PrintCertificateActionConfig"
3351
+ id: "PrintCertificateActionConfig",
3352
+ description: "Configuration for printing a certificate of a registered record."
3353
+ }),
3354
+ RequestCorrectionConfig.meta({
3355
+ id: "RequestCorrectionActionConfig",
3356
+ description: "Configuration for requesting a correction on a registered record."
3357
+ }),
3358
+ EditActionConfig.meta({
3359
+ id: "EditActionConfig",
3360
+ description: "Configuration for editing a record before registration."
3114
3361
  }),
3115
- RequestCorrectionConfig.meta({ id: "RequestCorrectionActionConfig" }),
3116
- EditActionConfig.meta({ id: "EditActionConfig" }),
3117
- ArchiveConfig.meta({ id: "ArchiveActionConfig" }),
3118
- CustomActionConfig.meta({ id: "CustomActionConfig" })
3362
+ ArchiveConfig.meta({
3363
+ id: "ArchiveActionConfig",
3364
+ description: "Configuration for archiving a record."
3365
+ }),
3366
+ CustomActionConfig.meta({
3367
+ id: "CustomActionConfig",
3368
+ description: "Configuration for a country-defined custom action. An event may include any number of these."
3369
+ })
3119
3370
  ]).describe(
3120
3371
  "Configuration of an action available for an event. Data collected depends on the action type and is accessible through the annotation property in ActionDocument."
3121
3372
  ).meta({ id: "ActionConfig" });
@@ -3191,7 +3442,10 @@ var Field = BaseField2.extend({
3191
3442
  }).describe("Custom field defined for the summary view.");
3192
3443
  var SummaryConfig = z27.object({
3193
3444
  fields: z27.array(z27.union([Field, ReferenceField])).describe("Fields displayed in the event summary view.")
3194
- }).describe("Configuration of the event summary section.");
3445
+ }).meta({
3446
+ id: "SummaryConfig",
3447
+ 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."
3448
+ });
3195
3449
 
3196
3450
  // ../commons/src/events/AdvancedSearchConfig.ts
3197
3451
  var z28 = __toESM(require("zod/v4"));
@@ -3262,6 +3516,9 @@ var BaseField3 = z28.object({
3262
3516
  ),
3263
3517
  validations: z28.array(ValidationConfig).optional().describe(
3264
3518
  `Option for overriding the field validations specifically for advanced search form.`
3519
+ ),
3520
+ allowedLocations: JurisdictionReference.optional().describe(
3521
+ `Override the allowedLocations for a location field in advanced search. Use this when the declaration form's allowedLocations references a scope (e.g. record.create) that search-only users don't have \u2014 specify record.search scope instead.`
3265
3522
  )
3266
3523
  });
3267
3524
  var SearchQueryParams = z28.object({
@@ -3315,6 +3572,9 @@ var AdvancedSearchField = z28.discriminatedUnion("fieldType", [FieldConfigSchema
3315
3572
  var AdvancedSearchConfig = z28.object({
3316
3573
  title: TranslationConfig.describe("Advanced search tab title"),
3317
3574
  fields: z28.array(AdvancedSearchField).describe("Advanced search fields within the tab.")
3575
+ }).meta({
3576
+ id: "AdvancedSearchConfig",
3577
+ 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()`)."
3318
3578
  });
3319
3579
 
3320
3580
  // ../commons/src/events/utils.ts
@@ -3333,9 +3593,11 @@ var z30 = __toESM(require("zod/v4"));
3333
3593
  var z29 = __toESM(require("zod/v4"));
3334
3594
  function getDynamicNameValue(field3) {
3335
3595
  const nameConfiguration = field3.configuration?.name;
3596
+ const firstnameRequired = nameConfiguration?.firstname?.required ?? field3.required;
3597
+ const surnameRequired = nameConfiguration?.surname?.required ?? field3.required;
3336
3598
  return z29.object({
3337
- firstname: nameConfiguration?.firstname?.required ? NonEmptyTextValue : TextValue,
3338
- surname: nameConfiguration?.surname?.required ? NonEmptyTextValue : TextValue,
3599
+ firstname: firstnameRequired ? NonEmptyTextValue : TextValue,
3600
+ surname: surnameRequired ? NonEmptyTextValue : TextValue,
3339
3601
  middlename: nameConfiguration?.middlename?.required ? NonEmptyTextValue : TextValue.optional()
3340
3602
  });
3341
3603
  }
@@ -3682,7 +3944,7 @@ var isHiddenFieldType = (field3) => {
3682
3944
  return field3.config.type === FieldType.ALPHA_HIDDEN;
3683
3945
  };
3684
3946
  var isNonInteractiveFieldType = (field3) => {
3685
- 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;
3947
+ return field3.type === FieldType.DIVIDER || field3.type === FieldType.PAGE_HEADER || field3.type === FieldType.PARAGRAPH || field3.type === FieldType.HEADING || field3.type === FieldType.BULLET_LIST || field3.type === FieldType.DATA || field3.type === FieldType.ALPHA_PRINT_BUTTON || field3.type === FieldType.LINK_BUTTON || field3.type === FieldType.LOADER;
3686
3948
  };
3687
3949
 
3688
3950
  // ../commons/src/conditionals/validate.ts
@@ -3718,7 +3980,37 @@ function resolveDataPath(rootData, dataPath, instancePath) {
3718
3980
  }
3719
3981
  return current;
3720
3982
  }
3983
+ function todayISO() {
3984
+ return (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
3985
+ }
3986
+ var compiledFunctionCache = /* @__PURE__ */ new Map();
3987
+ function compileClientFunction(code) {
3988
+ let fn = compiledFunctionCache.get(code);
3989
+ if (!fn) {
3990
+ fn = new Function(`return (${code})`)();
3991
+ compiledFunctionCache.set(code, fn);
3992
+ }
3993
+ return fn;
3994
+ }
3721
3995
  (0, import_ajv_formats.default)(ajv);
3996
+ function buildClientFunctionContext(input) {
3997
+ return {
3998
+ $form: input.form,
3999
+ $now: todayISO(),
4000
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
4001
+ $online: isOnline(),
4002
+ $user: input.validatorContext?.user,
4003
+ $event: input.validatorContext?.event,
4004
+ $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
4005
+ user: input.systemVariables?.user,
4006
+ $window: input.systemVariables?.$window,
4007
+ locations: input.locations,
4008
+ adminLevelIds: input.adminLevelIds
4009
+ };
4010
+ }
4011
+ function runClientFunction(code, data, context) {
4012
+ return compileClientFunction(code)(data, context);
4013
+ }
3722
4014
  ajv.addKeyword({
3723
4015
  keyword: "daysFromDate",
3724
4016
  type: "string",
@@ -3763,7 +4055,7 @@ ajv.addKeyword({
3763
4055
  $data: true,
3764
4056
  errors: true,
3765
4057
  // @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
3766
- validate(schema, data, _2, dataContext) {
4058
+ validate(_schema, data, _2, dataContext) {
3767
4059
  const locationIdInput = data;
3768
4060
  const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
3769
4061
  return locations.some((location) => location.id === locationIdInput);
@@ -3794,6 +4086,23 @@ function isAgeValue(value) {
3794
4086
  function mergeWithBaseFormState(values, context) {
3795
4087
  return { ...context.baseFormState, ...values };
3796
4088
  }
4089
+ ajv.addKeyword({
4090
+ keyword: "customClientValidator",
4091
+ schemaType: "object",
4092
+ errors: true,
4093
+ // @ts-expect-error -- AJV's public types don't expose `rootData`. All
4094
+ // `validate()` callers build root data via `buildClientFunctionContext`,
4095
+ // so the cast holds.
4096
+ validate(schema, data, _2, dataContext) {
4097
+ return Boolean(
4098
+ runClientFunction(
4099
+ schema.code,
4100
+ data,
4101
+ dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
4102
+ )
4103
+ );
4104
+ }
4105
+ });
3797
4106
  function validate(schema, data) {
3798
4107
  const validator = ajv.getSchema(schema.$id) || ajv.compile(schema);
3799
4108
  if ("$form" in data) {
@@ -3830,17 +4139,14 @@ function isOnline() {
3830
4139
  }
3831
4140
  return true;
3832
4141
  }
3833
- function isConditionMet(conditional, values, context, eventIndex) {
3834
- return validate(conditional, {
3835
- $form: mergeWithBaseFormState(values, context),
3836
- $now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" }),
3837
- $online: isOnline(),
3838
- $user: context.user,
3839
- $leafAdminStructureLocationIds: context.leafAdminStructureLocationIds ?? [],
3840
- $flags: eventIndex?.flags ?? [],
3841
- $status: eventIndex?.status,
3842
- $event: context.event
3843
- });
4142
+ function isConditionMet(conditional, values, context) {
4143
+ return validate(
4144
+ conditional,
4145
+ buildClientFunctionContext({
4146
+ form: mergeWithBaseFormState(values, context),
4147
+ validatorContext: context
4148
+ })
4149
+ );
3844
4150
  }
3845
4151
  function getConditionalActionsForField(field3, values) {
3846
4152
  if (!field3.conditionals) {
@@ -3848,9 +4154,9 @@ function getConditionalActionsForField(field3, values) {
3848
4154
  }
3849
4155
  return field3.conditionals.filter((conditional) => validate(conditional.conditional, values)).map((conditional) => conditional.type);
3850
4156
  }
3851
- function areConditionsMet(conditions, values, context, event2) {
4157
+ function areConditionsMet(conditions, values, context, _event) {
3852
4158
  return conditions.every(
3853
- (condition) => isConditionMet(condition.conditional, values, context, event2)
4159
+ (condition) => isConditionMet(condition.conditional, values, context)
3854
4160
  );
3855
4161
  }
3856
4162
  function isFieldConditionMet(field3, form, conditionalType, context) {
@@ -3860,14 +4166,13 @@ function isFieldConditionMet(field3, form, conditionalType, context) {
3860
4166
  if (!hasRule) {
3861
4167
  return true;
3862
4168
  }
3863
- const validConditionals = getConditionalActionsForField(field3, {
3864
- $form: mergeWithBaseFormState(form, context),
3865
- $now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" }),
3866
- $online: isOnline(),
3867
- $user: context.user,
3868
- $leafAdminStructureLocationIds: context.leafAdminStructureLocationIds ?? [],
3869
- $event: context.event
3870
- });
4169
+ const validConditionals = getConditionalActionsForField(
4170
+ field3,
4171
+ buildClientFunctionContext({
4172
+ form: mergeWithBaseFormState(form, context),
4173
+ validatorContext: context
4174
+ })
4175
+ );
3871
4176
  return validConditionals.includes(conditionalType);
3872
4177
  }
3873
4178
  function isFieldVisible(field3, form, context) {
@@ -3893,7 +4198,14 @@ function isActionConditionMet(actionConfig, event2, context, conditionalType) {
3893
4198
  if (!rule) {
3894
4199
  return true;
3895
4200
  }
3896
- return isConditionMet(rule.conditional, event2.declaration, context, event2);
4201
+ return validate(rule.conditional, {
4202
+ ...buildClientFunctionContext({
4203
+ form: mergeWithBaseFormState(event2.declaration, context),
4204
+ validatorContext: context
4205
+ }),
4206
+ $flags: event2.flags,
4207
+ $status: event2.status
4208
+ });
3897
4209
  }
3898
4210
  function isActionEnabled(actionConfig, event2, context) {
3899
4211
  return isActionConditionMet(
@@ -4052,19 +4364,10 @@ function runFieldValidations({
4052
4364
  if (!isFieldVisible(field3.config, form, context)) {
4053
4365
  return [];
4054
4366
  }
4055
- const conditionalParameters = {
4056
- $form: mergeWithBaseFormState(form, context),
4057
- $now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" }),
4058
- /**
4059
- * In real use cases, there can be hundreds of thousands of locations.
4060
- * Make sure that the context contains only the locations that are needed for validation.
4061
- * E.g. if the user is a leaf admin, only the leaf locations under their admin structure are needed.
4062
- * Loading few megabytes of locations to memory just for validation is not efficient and will choke the application.
4063
- */
4064
- $leafAdminStructureLocationIds: context.leafAdminStructureLocationIds ?? [],
4065
- $online: isOnline(),
4066
- $user: context.user
4067
- };
4367
+ const conditionalParameters = buildClientFunctionContext({
4368
+ form: mergeWithBaseFormState(form, context),
4369
+ validatorContext: context
4370
+ });
4068
4371
  if (isFieldGroupFieldType(field3)) {
4069
4372
  const subfieldErrors = buildFormState(
4070
4373
  field3.config.fields,
@@ -4203,13 +4506,13 @@ function getActionConfig({
4203
4506
  actionType,
4204
4507
  customActionType
4205
4508
  }) {
4509
+ if (actionType === ActionType.NOTIFY) {
4510
+ return eventConfiguration.actions.find((a) => a.type === ActionType.NOTIFY) ?? eventConfiguration.actions.find((a) => a.type === ActionType.DECLARE);
4511
+ }
4206
4512
  return eventConfiguration.actions.find((a) => {
4207
4513
  if (a.type === ActionType.CUSTOM && customActionType) {
4208
4514
  return a.customActionType === customActionType;
4209
4515
  }
4210
- if (actionType === ActionType.NOTIFY) {
4211
- return a.type === ActionType.DECLARE;
4212
- }
4213
4516
  if (actionType === ActionType.APPROVE_CORRECTION || actionType === ActionType.REJECT_CORRECTION) {
4214
4517
  return a.type === ActionType.REQUEST_CORRECTION;
4215
4518
  }
@@ -4222,7 +4525,19 @@ function getCustomActionFields(eventConfiguration, customActionType) {
4222
4525
  customActionType,
4223
4526
  actionType: ActionType.CUSTOM
4224
4527
  });
4225
- if (!actionConfig || !("form" in actionConfig)) {
4528
+ if (!actionConfig || actionConfig.type !== ActionType.CUSTOM) {
4529
+ return [];
4530
+ }
4531
+ return actionConfig.form;
4532
+ }
4533
+ function getActionFormFields(eventConfiguration, actionType, customActionType) {
4534
+ const actionConfig = eventConfiguration.actions.find((a) => {
4535
+ if (a.type === ActionType.CUSTOM && customActionType) {
4536
+ return a.customActionType === customActionType;
4537
+ }
4538
+ return a.type === actionType;
4539
+ });
4540
+ if (!actionConfig || !("form" in actionConfig) || actionConfig.form == null) {
4226
4541
  return [];
4227
4542
  }
4228
4543
  return actionConfig.form;
@@ -4243,13 +4558,9 @@ var getActionAnnotationFields = (actionConfig) => {
4243
4558
  if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
4244
4559
  return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
4245
4560
  }
4246
- if (actionConfig.type === ActionType.CUSTOM) {
4247
- return actionConfig.form;
4248
- }
4249
- if ("review" in actionConfig) {
4250
- return actionConfig.review.fields;
4251
- }
4252
- return [];
4561
+ const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
4562
+ const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
4563
+ return [...reviewFields, ...formFields];
4253
4564
  };
4254
4565
  function getAllAnnotationFields(config) {
4255
4566
  return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
@@ -4548,19 +4859,32 @@ function getPendingAction(actions) {
4548
4859
  }
4549
4860
  return pendingActions[0];
4550
4861
  }
4551
- function getCompleteActionAnnotation(annotation, event2, action) {
4862
+ function getCompleteActionAnnotation(event2, action) {
4552
4863
  if (action.originalActionId) {
4553
4864
  const originalAction = event2.actions.find(
4554
4865
  ({ id }) => id === action.originalActionId
4555
4866
  );
4556
4867
  if (originalAction?.status === ActionStatus.Requested) {
4557
- return deepMerge(
4558
- deepMerge(annotation, originalAction.annotation ?? {}),
4559
- action.annotation ?? {}
4560
- );
4868
+ return deepMerge(originalAction.annotation ?? {}, action.annotation ?? {});
4561
4869
  }
4562
4870
  }
4563
- return deepMerge(annotation, action.annotation ?? {});
4871
+ return action.annotation ?? {};
4872
+ }
4873
+ function getCompleteActionContent(event2, action) {
4874
+ const currentContent = "content" in action ? action.content : void 0;
4875
+ if (!action.originalActionId) {
4876
+ return currentContent;
4877
+ }
4878
+ const originalAction = event2.actions.find(
4879
+ ({ id }) => id === action.originalActionId
4880
+ );
4881
+ if (originalAction && "content" in originalAction && originalAction.content) {
4882
+ return {
4883
+ ...originalAction.content,
4884
+ ...currentContent ?? {}
4885
+ };
4886
+ }
4887
+ return currentContent;
4564
4888
  }
4565
4889
  function getCompleteActionDeclaration(declaration, event2, action) {
4566
4890
  if (action.originalActionId) {
@@ -4580,7 +4904,7 @@ function getAcceptedActions(event2) {
4580
4904
  return event2.actions.filter(isAcceptedAction).map((action) => ({
4581
4905
  ...action,
4582
4906
  declaration: getCompleteActionDeclaration({}, event2, action),
4583
- annotation: getCompleteActionAnnotation({}, event2, action)
4907
+ annotation: getCompleteActionAnnotation(event2, action)
4584
4908
  }));
4585
4909
  }
4586
4910
  var EXCLUDED_ACTIONS = [
@@ -4668,6 +4992,9 @@ function not(condition) {
4668
4992
  function never2() {
4669
4993
  return not(alwaysTrue());
4670
4994
  }
4995
+ function always() {
4996
+ return defineConditional(alwaysTrue());
4997
+ }
4671
4998
  function jsonFieldPath(field3) {
4672
4999
  return [field3.$$field, ...field3.$$subfield].join("/");
4673
5000
  }
@@ -5215,7 +5542,54 @@ function createFieldConditionals(fieldId) {
5215
5542
  }
5216
5543
  },
5217
5544
  required: [fieldId]
5218
- })
5545
+ }),
5546
+ /**
5547
+ * Custom client-side validator. The provided function is serialised and executed
5548
+ * just-in-time on the client only. External references (e.g. lodash) are not
5549
+ * available inside the function body — all logic must be self-contained.
5550
+ *
5551
+ * @example
5552
+ * field('nid').customClientValidator((value) => {
5553
+ * // LUHN check — all logic must be inline
5554
+ * const digits = String(value).split('').map(Number)
5555
+ * // ...
5556
+ * return isValid
5557
+ * })
5558
+ */
5559
+ customClientValidator(validationFn) {
5560
+ const code = validationFn.toString();
5561
+ return defineFormConditional({
5562
+ type: "object",
5563
+ properties: wrapToPath(
5564
+ { [fieldId]: { customClientValidator: { code } } },
5565
+ this.$$subfield
5566
+ ),
5567
+ required: [fieldId]
5568
+ });
5569
+ },
5570
+ /**
5571
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
5572
+ * that can be used as the `value` property or a DATA component entry.
5573
+ * The function receives the referenced field's value as the first argument and
5574
+ * the full form context as the second; its return value replaces the field reference.
5575
+ * The function is serialised and executed just-in-time on the client only.
5576
+ * External references (e.g. lodash) are not available inside the function body.
5577
+ *
5578
+ * For computing a default value without referencing a specific field, use
5579
+ * `evaluate(fn)` in the `defaultValue` property instead.
5580
+ *
5581
+ * @example
5582
+ * field('a').customClientEvaluation((aValue, ctx) =>
5583
+ * Number(aValue) + Number(ctx.$form.b)
5584
+ * )
5585
+ */
5586
+ customClientEvaluation(computationFn) {
5587
+ return {
5588
+ $$code: computationFn.toString(),
5589
+ $$field: fieldId,
5590
+ $$subfield: this.$$subfield
5591
+ };
5592
+ }
5219
5593
  };
5220
5594
  }
5221
5595
 
@@ -5363,7 +5737,7 @@ var _EventConfigBase = z33.object({
5363
5737
  ),
5364
5738
  label: TranslationConfig.describe("Human-readable label for the event type."),
5365
5739
  actions: z33.array(ActionConfig).describe(
5366
- "Configuration of system-defined actions associated with the event."
5740
+ "Configuration of core and custom actions associated with the event."
5367
5741
  ),
5368
5742
  actionOrder: z33.array(z33.string()).optional().describe(
5369
5743
  "Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
@@ -5375,7 +5749,7 @@ var _EventConfigBase = z33.object({
5375
5749
  "Configuration of fields available in the advanced search feature."
5376
5750
  ),
5377
5751
  flags: z33.array(FlagConfig).optional().default([]).describe(
5378
- "Configuration of flags associated with the actions of this event type."
5752
+ "Configuration of custom flags associated with the actions of this event type."
5379
5753
  ),
5380
5754
  analytics: z33.boolean().optional().default(true).describe(
5381
5755
  "Indicates whether the records of this event type are included in analytics"
@@ -5388,8 +5762,9 @@ var EventConfig = _EventConfigBase.superRefine((event2, ctx) => {
5388
5762
  validateActionFlags(event2, ctx);
5389
5763
  validateActionOrder(event2, ctx);
5390
5764
  }).meta({
5391
- id: "EventConfig"
5392
- }).describe("Configuration defining an event type.");
5765
+ id: "EventConfig",
5766
+ description: "Configuration defining an event type registered in OpenCRVS (for example birth or death)."
5767
+ });
5393
5768
 
5394
5769
  // ../commons/src/events/EventConfigInput.ts
5395
5770
  var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
@@ -5612,6 +5987,9 @@ var WorkqueueColumnValue = z34.object({
5612
5987
  var WorkqueueColumn = z34.object({
5613
5988
  label: TranslationConfig,
5614
5989
  value: WorkqueueColumnValue
5990
+ }).meta({
5991
+ id: "WorkqueueColumn",
5992
+ description: "Configuration for a single workqueue column. The value references an event metadata key (e.g. `dateOfEvent`, `status`, `trackingId`)."
5615
5993
  });
5616
5994
  function defineWorkqueuesColumns(workqueueColumns) {
5617
5995
  return workqueueColumns.map(
@@ -5814,18 +6192,11 @@ var WorkqueueConfigWithoutQuery = WorkqueueConfig.omit({
5814
6192
  query: true,
5815
6193
  columns: true
5816
6194
  });
5817
- var WorkqueueConfigInput = z37.object({
5818
- slug: z37.string().describe("Determines the url of the workqueue."),
5819
- name: TranslationConfig.describe(
5820
- "Title of the workflow (both in navigation and on the page)"
5821
- ),
5822
- query: CountryConfigQueryInputType,
5823
- action: z37.object({ type: WorkqueueActionType }).optional().describe(
5824
- "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."
5825
- ),
5826
- columns: z37.array(WorkqueueColumn).default(mandatoryColumns),
5827
- icon: AvailableIcons,
5828
- emptyMessage: TranslationConfig.optional()
6195
+ var WorkqueueConfigInput = WorkqueueConfig.extend({
6196
+ query: CountryConfigQueryInputType
6197
+ }).meta({
6198
+ id: "WorkqueueConfig",
6199
+ 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."
5829
6200
  });
5830
6201
  function defineWorkqueue(workqueueInput) {
5831
6202
  const queryInput = workqueueInput.query;
@@ -5888,7 +6259,9 @@ var BaseActionInput = z38.object({
5888
6259
  keepAssignment: z38.boolean().optional(),
5889
6260
  keepAssignmentIfAccepted: z38.boolean().optional(),
5890
6261
  keepAssignmentIfRejected: z38.boolean().optional(),
5891
- waitFor: z38.boolean().optional(),
6262
+ waitFor: z38.boolean().default(true).describe(
6263
+ "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."
6264
+ ),
5892
6265
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
5893
6266
  // @TODO: createdAtLocation should be limited to actions that system users can perform. For normal users, it should not be part of the base action.
5894
6267
  createdAtLocation: UUID.nullish().describe(
@@ -6006,7 +6379,8 @@ var RejectCorrectionActionInput = BaseActionInput.extend(
6006
6379
  var ApproveCorrectionActionInput = BaseActionInput.extend(
6007
6380
  z38.object({
6008
6381
  requestId: z38.string(),
6009
- type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
6382
+ type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION),
6383
+ content: z38.object({ immediateCorrection: z38.boolean().optional() }).optional()
6010
6384
  }).shape
6011
6385
  );
6012
6386
  var ReadActionInput = BaseActionInput.extend(
@@ -6068,7 +6442,7 @@ var Draft = z39.object({
6068
6442
  }).describe(
6069
6443
  "A temporary storage for an action. Stored with details of the event, creator and creation time."
6070
6444
  );
6071
- var DraftInput = BaseActionInput.extend({
6445
+ var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
6072
6446
  type: ActionTypes.exclude([ActionTypes.enum.DELETE]),
6073
6447
  status: z39.enum([
6074
6448
  ActionStatus.Requested,
@@ -6155,6 +6529,8 @@ var updateActions = ActionTypes.extract([
6155
6529
  ActionType.ARCHIVE,
6156
6530
  ActionType.PRINT_CERTIFICATE,
6157
6531
  ActionType.REQUEST_CORRECTION,
6532
+ ActionType.APPROVE_CORRECTION,
6533
+ ActionType.REJECT_CORRECTION,
6158
6534
  ActionType.CUSTOM
6159
6535
  ]);
6160
6536
  function getActionUpdateMetadata(actions) {
@@ -6169,7 +6545,7 @@ function getActionUpdateMetadata(actions) {
6169
6545
  "createdAtLocation",
6170
6546
  "createdByRole"
6171
6547
  ];
6172
- return actions.filter(({ type }) => updateActions.safeParse(type).success).filter(({ status: status2 }) => status2 === ActionStatus.Accepted).reduce(
6548
+ return actions.filter(({ type }) => updateActions.safeParse(type).success).reduce(
6173
6549
  (_2, action) => {
6174
6550
  if (action.originalActionId) {
6175
6551
  const originalAction = actions.find(({ id }) => id === action.originalActionId) ?? action;
@@ -6182,6 +6558,10 @@ function getActionUpdateMetadata(actions) {
6182
6558
  }
6183
6559
  function getLegalStatuses(actions) {
6184
6560
  return {
6561
+ [EventStatus.enum.NOTIFIED]: getDeclarationActionCreationMetadata(
6562
+ ActionType.NOTIFY,
6563
+ actions
6564
+ ),
6185
6565
  [EventStatus.enum.DECLARED]: getDeclarationActionCreationMetadata(
6186
6566
  ActionType.DECLARE,
6187
6567
  actions
@@ -6196,28 +6576,19 @@ function getLegalStatuses(actions) {
6196
6576
  // ../commons/src/events/state/flags.ts
6197
6577
  var import_lodash3 = require("lodash");
6198
6578
  var import_date_fns3 = require("date-fns");
6199
- function isEditInProgress(actions) {
6200
- return actions.at(-1)?.type === ActionType.EDIT;
6201
- }
6202
- function isCorrectionRequested(actions) {
6203
- return actions.reduce((prev, { type }) => {
6204
- if (type === ActionType.REQUEST_CORRECTION) {
6205
- return true;
6206
- }
6207
- if (type === ActionType.APPROVE_CORRECTION) {
6208
- return false;
6579
+ function findPendingCorrectionAction(writeActions2) {
6580
+ let correctionRequestAction;
6581
+ for (let i = writeActions2.length - 1; i >= 0; i--) {
6582
+ const action = writeActions2[i];
6583
+ if (action.type === ActionType.APPROVE_CORRECTION || action.type === ActionType.REJECT_CORRECTION) {
6584
+ break;
6209
6585
  }
6210
- if (type === ActionType.REJECT_CORRECTION) {
6211
- return false;
6586
+ if (action.type === ActionType.REQUEST_CORRECTION) {
6587
+ correctionRequestAction = action;
6588
+ break;
6212
6589
  }
6213
- return prev;
6214
- }, false);
6215
- }
6216
- function isDeclarationIncomplete(actions) {
6217
- return getStatusFromActions(actions) === EventStatus.enum.NOTIFIED;
6218
- }
6219
- function isRejected(actions) {
6220
- return actions.at(-1)?.type === ActionType.REJECT;
6590
+ }
6591
+ return correctionRequestAction;
6221
6592
  }
6222
6593
  function isPotentialDuplicate(actions) {
6223
6594
  return actions.reduce((prev, { type }) => {
@@ -6246,6 +6617,88 @@ function isFlagConditionMet(conditional, form, action) {
6246
6617
  }
6247
6618
  });
6248
6619
  }
6620
+ function actionConfigRemovesFlag(action, flagId, actionsUpToAndIncluding, event2, eventConfiguration) {
6621
+ if (!isActionConfigType(action.type)) {
6622
+ return false;
6623
+ }
6624
+ const actionConfig = getActionConfig({
6625
+ eventConfiguration,
6626
+ actionType: action.type,
6627
+ customActionType: "customActionType" in action ? action.customActionType : void 0
6628
+ });
6629
+ const removeOperations = (actionConfig?.flags ?? []).filter(
6630
+ ({ id, operation }) => id === flagId && operation === "remove"
6631
+ );
6632
+ if (removeOperations.length === 0) {
6633
+ return false;
6634
+ }
6635
+ const eventUpToThisAction = { ...event2, actions: actionsUpToAndIncluding };
6636
+ const declaration = aggregateActionDeclarations(eventUpToThisAction);
6637
+ const annotation = aggregateActionAnnotations(eventUpToThisAction);
6638
+ const form = { ...declaration, ...annotation };
6639
+ return removeOperations.some(
6640
+ ({ conditional }) => conditional ? isFlagConditionMet(conditional, form, action) : true
6641
+ );
6642
+ }
6643
+ var INHERENT_FLAG_RULES = [
6644
+ {
6645
+ flag: InherentFlags.CORRECTION_REQUESTED,
6646
+ setOn: [ActionType.REQUEST_CORRECTION],
6647
+ resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
6648
+ },
6649
+ {
6650
+ // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
6651
+ // other status-changing action (see getStatusFromActions).
6652
+ flag: InherentFlags.INCOMPLETE,
6653
+ setOn: [ActionType.NOTIFY],
6654
+ resetOn: [
6655
+ ActionType.CREATE,
6656
+ ActionType.DECLARE,
6657
+ ActionType.REGISTER,
6658
+ ActionType.ARCHIVE
6659
+ ]
6660
+ },
6661
+ {
6662
+ flag: InherentFlags.REJECTED,
6663
+ setOn: [ActionType.REJECT],
6664
+ resetOn: [
6665
+ ActionType.NOTIFY,
6666
+ ActionType.DECLARE,
6667
+ ActionType.EDIT,
6668
+ ActionType.REGISTER
6669
+ ]
6670
+ },
6671
+ {
6672
+ flag: InherentFlags.POTENTIAL_DUPLICATE,
6673
+ setOn: [ActionType.DUPLICATE_DETECTED],
6674
+ resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
6675
+ },
6676
+ {
6677
+ flag: InherentFlags.EDIT_IN_PROGRESS,
6678
+ setOn: [ActionType.EDIT],
6679
+ resetOnAnyOtherAction: true
6680
+ }
6681
+ ];
6682
+ function resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration) {
6683
+ return acceptedActions.reduce((present, action, idx) => {
6684
+ if (rule.setOn.includes(action.type)) {
6685
+ return true;
6686
+ }
6687
+ if (rule.resetOnAnyOtherAction || (rule.resetOn ?? []).includes(action.type)) {
6688
+ return false;
6689
+ }
6690
+ if (actionConfigRemovesFlag(
6691
+ action,
6692
+ rule.flag,
6693
+ acceptedActions.slice(0, idx + 1),
6694
+ event2,
6695
+ eventConfiguration
6696
+ )) {
6697
+ return false;
6698
+ }
6699
+ return present;
6700
+ }, false);
6701
+ }
6249
6702
  function resolveEventCustomFlags(event2, eventConfiguration) {
6250
6703
  const actions = getAcceptedActions(event2).filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
6251
6704
  return actions.reduce((acc, action, idx) => {
@@ -6281,8 +6734,7 @@ function resolveEventCustomFlags(event2, eventConfiguration) {
6281
6734
  return (0, import_lodash3.uniq)(flags);
6282
6735
  }, []);
6283
6736
  }
6284
- function getEventFlags(event2, config) {
6285
- const sortedActions = event2.actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
6737
+ function getActionStatusFlags(sortedActions) {
6286
6738
  const actionStatus = sortedActions.reduce(
6287
6739
  (actionStatuses, { type, status: status2 }) => ({
6288
6740
  ...actionStatuses,
@@ -6290,26 +6742,26 @@ function getEventFlags(event2, config) {
6290
6742
  }),
6291
6743
  {}
6292
6744
  );
6293
- const flags = Object.entries(actionStatus).filter(([, status2]) => status2 !== ActionStatus.Accepted).map(([type, status2]) => {
6745
+ return Object.entries(actionStatus).filter(([, status2]) => status2 !== ActionStatus.Accepted).map(([type, status2]) => {
6294
6746
  const flag2 = joinValues([type, status2], ":").toLowerCase();
6295
6747
  return flag2;
6296
6748
  });
6297
- if (isCorrectionRequested(sortedActions)) {
6298
- flags.push(InherentFlags.CORRECTION_REQUESTED);
6299
- }
6300
- if (isDeclarationIncomplete(sortedActions)) {
6301
- flags.push(InherentFlags.INCOMPLETE);
6302
- }
6303
- if (isRejected(sortedActions)) {
6304
- flags.push(InherentFlags.REJECTED);
6305
- }
6306
- if (isPotentialDuplicate(sortedActions)) {
6307
- flags.push(InherentFlags.POTENTIAL_DUPLICATE);
6308
- }
6309
- if (isEditInProgress(sortedActions)) {
6310
- flags.push(InherentFlags.EDIT_IN_PROGRESS);
6311
- }
6312
- return [...flags, ...resolveEventCustomFlags(event2, config)];
6749
+ }
6750
+ function getInherentFlags(sortedActions, event2, eventConfiguration) {
6751
+ const acceptedActions = sortedActions.filter(
6752
+ ({ status: status2 }) => status2 === ActionStatus.Accepted
6753
+ );
6754
+ return INHERENT_FLAG_RULES.filter(
6755
+ (rule) => resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration)
6756
+ ).map(({ flag: flag2 }) => flag2);
6757
+ }
6758
+ function getEventFlags(event2, config) {
6759
+ const sortedActions = event2.actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
6760
+ return [
6761
+ ...getActionStatusFlags(sortedActions),
6762
+ ...getInherentFlags(sortedActions, event2, config),
6763
+ ...resolveEventCustomFlags(event2, config)
6764
+ ];
6313
6765
  }
6314
6766
 
6315
6767
  // ../commons/src/events/state/index.ts
@@ -6544,7 +6996,7 @@ function getActionAnnotation({
6544
6996
  const action = (0, import_lodash4.findLast)(activeActions, (a) => a.type === actionType);
6545
6997
  const actionWithCompleteAnnotation = action && {
6546
6998
  ...action,
6547
- annotation: getCompleteActionAnnotation({}, event2, action)
6999
+ annotation: getCompleteActionAnnotation(event2, action)
6548
7000
  };
6549
7001
  const matchingDraft = draft?.action.type === actionType ? draft : void 0;
6550
7002
  const sortedActions = (0, import_lodash4.orderBy)(
@@ -6616,6 +7068,9 @@ function createFieldConfig(fieldId, options) {
6616
7068
  }
6617
7069
 
6618
7070
  // ../commons/src/events/field.ts
7071
+ function evaluate(computationFn) {
7072
+ return { $$code: computationFn.toString() };
7073
+ }
6619
7074
  function field(fieldId, options = {}) {
6620
7075
  return {
6621
7076
  ...createFieldConditionals(fieldId),
@@ -7309,6 +7764,11 @@ var TENNIS_CLUB_DECLARATION_REVIEW = {
7309
7764
  id: "signature.upload.modal.title",
7310
7765
  defaultMessage: "Draw signature",
7311
7766
  description: "Title for the modal to draw signature"
7767
+ },
7768
+ // Zod applies the schema default at parse time, but this fixture bypasses
7769
+ // parsing — GeneratedInputField accesses configuration.maxFileSize directly.
7770
+ configuration: {
7771
+ maxFileSize: 5 * 1024 * 1024
7312
7772
  }
7313
7773
  }
7314
7774
  ]
@@ -7865,6 +8325,20 @@ var tennisClubMembershipEvent = defineConfig({
7865
8325
  },
7866
8326
  review: TENNIS_CLUB_DECLARATION_REVIEW
7867
8327
  },
8328
+ {
8329
+ type: ActionType.NOTIFY,
8330
+ label: {
8331
+ defaultMessage: "Notify health worker",
8332
+ description: "This is shown as the action name anywhere the user can trigger the action from",
8333
+ id: "event.tennis-club-membership.action.notify.label"
8334
+ },
8335
+ flags: [
8336
+ {
8337
+ id: "health-worker-notified",
8338
+ operation: "add"
8339
+ }
8340
+ ]
8341
+ },
7868
8342
  {
7869
8343
  type: ActionType.REJECT,
7870
8344
  label: {
@@ -8107,6 +8581,17 @@ var tennisClubMembershipEvent = defineConfig({
8107
8581
  }
8108
8582
  }
8109
8583
  ],
8584
+ flags: [
8585
+ {
8586
+ id: "health-worker-notified",
8587
+ requiresAction: false,
8588
+ label: {
8589
+ id: "event.tennis-club-membership.flag.health-worker-notified.label",
8590
+ defaultMessage: "Health worker notified",
8591
+ description: "Label for the health-worker-notified flag"
8592
+ }
8593
+ }
8594
+ ],
8110
8595
  advancedSearch: [
8111
8596
  {
8112
8597
  title: {
@@ -9865,7 +10350,7 @@ function matchesJurisdictionFilter(locationIds, filter, user2) {
9865
10350
  return locationIds.some((id) => id === user2.primaryOfficeId);
9866
10351
  }
9867
10352
  if (filter === JurisdictionFilter.enum.administrativeArea) {
9868
- return user2.administrativeAreaId === null || locationIds.some((id) => id === user2.administrativeAreaId);
10353
+ return !user2.administrativeAreaId || locationIds.some((id) => id === user2.administrativeAreaId);
9869
10354
  }
9870
10355
  return true;
9871
10356
  }
@@ -9892,6 +10377,25 @@ function canAccessEventWithScope(event2, scope, user2, customActionType) {
9892
10377
  }
9893
10378
  if (scopeUsesDeclaredOptions(scope)) {
9894
10379
  const { options } = scope;
10380
+ if (options?.notifiedBy === UserFilter.enum.user) {
10381
+ if (event2.legalStatuses?.NOTIFIED?.createdBy !== user2.id) {
10382
+ return false;
10383
+ }
10384
+ }
10385
+ if (options?.notifiedIn === JurisdictionFilter.enum.location && !matchesJurisdictionFilter(
10386
+ event2.legalStatuses?.NOTIFIED?.createdAtLocation,
10387
+ JurisdictionFilter.enum.location,
10388
+ user2
10389
+ )) {
10390
+ return false;
10391
+ }
10392
+ if (options?.notifiedIn === JurisdictionFilter.enum.administrativeArea && !matchesJurisdictionFilter(
10393
+ event2.legalStatuses?.NOTIFIED?.createdAtLocation,
10394
+ JurisdictionFilter.enum.administrativeArea,
10395
+ user2
10396
+ )) {
10397
+ return false;
10398
+ }
9895
10399
  if (options?.declaredBy === UserFilter.enum.user) {
9896
10400
  if (event2.legalStatuses?.DECLARED?.createdBy !== user2.id) {
9897
10401
  return false;
@@ -9954,7 +10458,7 @@ function canAccessUserWithScope({
9954
10458
  }
9955
10459
  const hasAdministrativeAreaInHierarchy = userToAccess.administrativeHierarchy.some(
9956
10460
  (id) => user2.administrativeAreaId === id
9957
- ) || user2.administrativeAreaId === null;
10461
+ ) || !user2.administrativeAreaId;
9958
10462
  if (opts?.accessLevel === JurisdictionFilter.enum.administrativeArea && !hasAdministrativeAreaInHierarchy) {
9959
10463
  return false;
9960
10464
  }
@@ -10260,18 +10764,19 @@ var ACTION_FILTERS = {
10260
10764
  function filterActionsByFlags(actions, flags) {
10261
10765
  return actions.filter((action) => ACTION_FILTERS[action]?.(flags) ?? true);
10262
10766
  }
10767
+ var REJECTED_ACTIONS = [
10768
+ ActionType.READ,
10769
+ ActionType.NOTIFY,
10770
+ ActionType.CUSTOM,
10771
+ ActionType.EDIT,
10772
+ ActionType.ARCHIVE
10773
+ ];
10263
10774
  function getAvailableActionsWithoutFlagFilters(status2, flags) {
10264
10775
  if (flags.includes(InherentFlags.EDIT_IN_PROGRESS)) {
10265
10776
  return [ActionType.NOTIFY, ActionType.DECLARE, ActionType.REGISTER];
10266
10777
  }
10267
- if (flags.includes(InherentFlags.REJECTED)) {
10268
- return [
10269
- ActionType.READ,
10270
- ActionType.NOTIFY,
10271
- ActionType.CUSTOM,
10272
- ActionType.EDIT,
10273
- ActionType.ARCHIVE
10274
- ];
10778
+ if (flags.includes(InherentFlags.REJECTED) && status2 !== EventStatus.enum.ARCHIVED) {
10779
+ return REJECTED_ACTIONS;
10275
10780
  }
10276
10781
  return AVAILABLE_ACTIONS_BY_EVENT_STATUS[status2];
10277
10782
  }
@@ -10308,3 +10813,366 @@ function getFilePathsFromEvent(event2) {
10308
10813
  });
10309
10814
  return (0, import_lodash7.uniq)(filepaths);
10310
10815
  }
10816
+
10817
+ // ../commons/src/events/mocks.test.utils.ts
10818
+ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
10819
+ {
10820
+ id: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10821
+ name: "Central",
10822
+ parentId: null,
10823
+ validUntil: null,
10824
+ externalId: "ydyJb1RAy4U1"
10825
+ },
10826
+ {
10827
+ id: "c599b691-fd2d-45e1-abf4-d185de727fb5",
10828
+ name: "Sulaka",
10829
+ parentId: null,
10830
+ validUntil: null,
10831
+ externalId: "pQ8nGxWmZ2Q3"
10832
+ },
10833
+ {
10834
+ id: "7ef2b9c7-5e6d-49f6-ae05-656207d0fc64",
10835
+ name: "Pualula",
10836
+ parentId: null,
10837
+ validUntil: null,
10838
+ externalId: "Aq91DweLmT8k"
10839
+ },
10840
+ {
10841
+ id: "6d1a59df-988c-4021-a846-ccbc021931a7",
10842
+ name: "Chuminga",
10843
+ parentId: null,
10844
+ validUntil: null,
10845
+ externalId: "Rw0fYNh2Xk9a"
10846
+ },
10847
+ {
10848
+ id: "62a0ccb4-880d-4f30-8882-f256007dfff9",
10849
+ name: "Ibombo",
10850
+ parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10851
+ validUntil: null,
10852
+ externalId: "k7DsP4vbN1Qe"
10853
+ },
10854
+ {
10855
+ id: "27160bbd-32d1-4625-812f-860226bfb92a",
10856
+ name: "Isango",
10857
+ parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10858
+ validUntil: null,
10859
+ externalId: "Gm3Z9eQpHw4L"
10860
+ },
10861
+ {
10862
+ id: "967032fd-3f81-478a-826c-30cb8fe121bd",
10863
+ name: "Isamba",
10864
+ parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10865
+ validUntil: null,
10866
+ externalId: "sT0xVu1KqJ7r"
10867
+ },
10868
+ {
10869
+ id: "89a33893-b17d-481d-a26d-6461e7ac1651",
10870
+ name: "Itambo",
10871
+ parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10872
+ validUntil: null,
10873
+ externalId: "Nq6Bv2HpL9Te"
10874
+ },
10875
+ {
10876
+ id: "d42ab2fe-e7ed-470e-8b31-4fb27f9b8250",
10877
+ name: "Ezhi",
10878
+ parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10879
+ validUntil: null,
10880
+ externalId: "xK8cQ0ZRy5Wd"
10881
+ },
10882
+ {
10883
+ id: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
10884
+ name: "Ilanga",
10885
+ parentId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
10886
+ validUntil: null,
10887
+ externalId: "Cq4Jm1XvN8Ls"
10888
+ },
10889
+ // Villages under Ibombo (62a0ccb4-880d-4f30-8882-f256007dfff9)
10890
+ {
10891
+ id: "1d4e5f6a-7b8c-4912-8efa-345678901234",
10892
+ name: "Klow",
10893
+ parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
10894
+ validUntil: null,
10895
+ externalId: "IkYcYBUcyY2"
10896
+ },
10897
+ {
10898
+ id: "2e5f6a7b-8c9d-4a23-8fab-456789012345",
10899
+ name: "Mbondo",
10900
+ parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
10901
+ validUntil: null,
10902
+ externalId: "Qhvv5hvo3mY"
10903
+ },
10904
+ {
10905
+ id: "3f6a7b8c-9d0e-4b34-8abc-567890123456",
10906
+ name: "Ndara",
10907
+ parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
10908
+ validUntil: null,
10909
+ externalId: "crXh068O9TR"
10910
+ },
10911
+ {
10912
+ id: "4a7b8c9d-0e1f-4c45-abcd-678901234567",
10913
+ name: "Olani",
10914
+ parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
10915
+ validUntil: null,
10916
+ externalId: "r00It8Tvvp7"
10917
+ },
10918
+ {
10919
+ id: "5b8c9d0e-1f2a-4d56-bcde-789012345678",
10920
+ name: "Pemba",
10921
+ parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
10922
+ validUntil: null,
10923
+ externalId: "ZnUWsbONIaH"
10924
+ },
10925
+ {
10926
+ id: "6c9d0e1f-2a3b-4e67-8def-890123456789",
10927
+ name: "Quanza",
10928
+ parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
10929
+ validUntil: null,
10930
+ externalId: "fDZycvQTa7l"
10931
+ },
10932
+ {
10933
+ id: "7d0e1f2a-3b4c-4f78-8efa-901234567890",
10934
+ name: "Rivka",
10935
+ parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
10936
+ validUntil: null,
10937
+ externalId: "KqswxCGTELa"
10938
+ },
10939
+ // Villages under Isamba (967032fd-3f81-478a-826c-30cb8fe121bd)
10940
+ {
10941
+ id: "8e1f2a3b-4c5d-4089-8fab-012345678901",
10942
+ name: "Mbula",
10943
+ parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
10944
+ validUntil: null,
10945
+ externalId: "osEbKjRc9Kg"
10946
+ },
10947
+ {
10948
+ id: "9f2a3b4c-5d6e-4190-8abf-123456789012",
10949
+ name: "Ndoki",
10950
+ parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
10951
+ validUntil: null,
10952
+ externalId: "aq4daBUAGr3"
10953
+ },
10954
+ {
10955
+ id: "0a3b4c5d-6e7f-4201-abcd-234567890123",
10956
+ name: "Tsanga",
10957
+ parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
10958
+ validUntil: null,
10959
+ externalId: "cqis6Y8trbJ"
10960
+ },
10961
+ {
10962
+ id: "1b4c5d6e-7f8a-4312-bcde-345678901234",
10963
+ name: "Waziri",
10964
+ parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
10965
+ validUntil: null,
10966
+ externalId: "LMijHPyyx6d"
10967
+ },
10968
+ {
10969
+ id: "2c5d6e7f-8a9b-4423-8def-456789012345",
10970
+ name: "Zimbi",
10971
+ parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
10972
+ validUntil: null,
10973
+ externalId: "pcQYbPuKGZ7"
10974
+ },
10975
+ // Villages under Itambo (89a33893-b17d-481d-a26d-6461e7ac1651)
10976
+ {
10977
+ id: "3d6e7f8a-9b0c-4534-8efa-567890123456",
10978
+ name: "Felani",
10979
+ parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
10980
+ validUntil: null,
10981
+ externalId: "gSqpoCGdMXp"
10982
+ },
10983
+ {
10984
+ id: "4e7f8a9b-0c1d-4645-8fab-678901234567",
10985
+ name: "Goroma",
10986
+ parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
10987
+ validUntil: null,
10988
+ externalId: "KvAAIaNqVrp"
10989
+ },
10990
+ {
10991
+ id: "5f8a9b0c-1d2e-4756-8abc-789012345678",
10992
+ name: "Halifu",
10993
+ parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
10994
+ validUntil: null,
10995
+ externalId: "qe4UnEVt1hv"
10996
+ },
10997
+ {
10998
+ id: "6a9b0c1d-2e3f-4867-abcd-890123456789",
10999
+ name: "Jabari",
11000
+ parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11001
+ validUntil: null,
11002
+ externalId: "yHH9Nz4rLOt"
11003
+ },
11004
+ {
11005
+ id: "7b0c1d2e-3f4a-4978-bcde-901234567890",
11006
+ name: "Kifani",
11007
+ parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11008
+ validUntil: null,
11009
+ externalId: "eSWmXIGeu1I"
11010
+ },
11011
+ {
11012
+ id: "8c1d2e3f-4a5b-4089-8def-012345678901",
11013
+ name: "Lumela",
11014
+ parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11015
+ validUntil: null,
11016
+ externalId: "bh0b3aI1uP3"
11017
+ }
11018
+ ];
11019
+ var V2_DEFAULT_MOCK_LOCATIONS = [
11020
+ {
11021
+ id: "6f6186ce-cd5f-4a5f-810a-2d99e7c4ba12",
11022
+ name: "Central Provincial Office",
11023
+ locationType: "CRVS_OFFICE",
11024
+ administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11025
+ validUntil: null,
11026
+ externalId: "Xr3Df8WpK6Ys"
11027
+ },
11028
+ {
11029
+ id: "b1c2d3e4-f5a6-7890-bcde-f12345678901",
11030
+ name: "Central Health Post",
11031
+ locationType: "HEALTH_FACILITY",
11032
+ administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11033
+ validUntil: null
11034
+ },
11035
+ {
11036
+ id: "028d2c85-ca31-426d-b5d1-2cef545a4902",
11037
+ name: "Ibombo District Office",
11038
+ locationType: "CRVS_OFFICE",
11039
+ administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11040
+ validUntil: null,
11041
+ externalId: "Sm4Nw7GrD2Vy"
11042
+ },
11043
+ {
11044
+ id: "62a0ccb4-4f30-4f30-8882-f256007dff9f",
11045
+ name: "Isamba District Office",
11046
+ locationType: "CRVS_OFFICE",
11047
+ administrativeAreaId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11048
+ validUntil: null,
11049
+ externalId: "Vg1Bq5XeH9Lt"
11050
+ },
11051
+ {
11052
+ id: "954c93e1-13f7-4435-bb82-35e0e215e07d",
11053
+ name: "Isango District Office",
11054
+ locationType: "CRVS_OFFICE",
11055
+ administrativeAreaId: "27160bbd-32d1-4625-812f-860226bfb92a",
11056
+ validUntil: null,
11057
+ externalId: "Je7Lm2XqN9Vz"
11058
+ },
11059
+ {
11060
+ id: "2884f5b9-17b4-49ce-bf4d-f538228935df",
11061
+ name: "Sulaka Provincial Office",
11062
+ locationType: "CRVS_OFFICE",
11063
+ administrativeAreaId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
11064
+ validUntil: null,
11065
+ externalId: "Ht2Wp9KcX5Qv"
11066
+ },
11067
+ {
11068
+ id: "030358c6-54af-44be-821b-8e4af963a49c",
11069
+ name: "Ilanga District Office",
11070
+ locationType: "CRVS_OFFICE",
11071
+ administrativeAreaId: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
11072
+ validUntil: null,
11073
+ externalId: "Yp6Ds1WqN3Xz"
11074
+ },
11075
+ {
11076
+ id: "423d000f-101b-47c0-8b86-21a908067cee",
11077
+ name: "Chamakubi Health Post",
11078
+ locationType: "HEALTH_FACILITY",
11079
+ administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11080
+ validUntil: null,
11081
+ externalId: "M1nFr8LbC2Qy"
11082
+ },
11083
+ {
11084
+ id: "4d3279be-d026-420c-88f7-f0a4ae986973",
11085
+ name: "Ibombo Rural Health Centre",
11086
+ locationType: "HEALTH_FACILITY",
11087
+ administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11088
+ validUntil: null,
11089
+ externalId: "bT7pV6YrW0Xc"
11090
+ },
11091
+ {
11092
+ id: "190902f4-1d77-476a-8947-41145af1db7d",
11093
+ name: "Chikobo Rural Health Centre",
11094
+ locationType: "HEALTH_FACILITY",
11095
+ administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11096
+ validUntil: null,
11097
+ externalId: "zE4qPn2SgJ5d"
11098
+ },
11099
+ {
11100
+ id: "f5ecbd9b-a01e-4a65-910e-70e86ab41b71",
11101
+ name: "Chilochabalenje Health Post",
11102
+ locationType: "HEALTH_FACILITY",
11103
+ administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11104
+ validUntil: null,
11105
+ externalId: "H8vDs1MqR4Uf"
11106
+ },
11107
+ {
11108
+ id: "dbfc178f-7295-4b90-b28d-111c95b03127",
11109
+ name: "Chipeso Rural Health Centre",
11110
+ locationType: "HEALTH_FACILITY",
11111
+ administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11112
+ validUntil: null,
11113
+ externalId: "Qw3uZ9KfX6Lm"
11114
+ },
11115
+ {
11116
+ id: "09862bfe-c7ac-46cd-987b-668681533c80",
11117
+ name: "Chisamba Rural Health Centre",
11118
+ locationType: "HEALTH_FACILITY",
11119
+ administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11120
+ validUntil: null,
11121
+ externalId: "Yr0pCg8LdM2s"
11122
+ },
11123
+ {
11124
+ id: "834ce389-e95b-4fb0-96a0-33e9ab323059",
11125
+ name: "Chitanda Rural Health Centre",
11126
+ locationType: "HEALTH_FACILITY",
11127
+ administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11128
+ validUntil: null,
11129
+ externalId: "tS9gJ4PwB1Qx"
11130
+ },
11131
+ {
11132
+ id: "0431c433-6062-4a4c-aee9-25271aec61ee",
11133
+ name: "Golden Valley Rural Health Centre",
11134
+ locationType: "HEALTH_FACILITY",
11135
+ administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11136
+ validUntil: null,
11137
+ externalId: "Ld7Qm3XsA8Vr"
11138
+ },
11139
+ {
11140
+ id: "bc84d0b6-7ba7-480d-a339-5d9920d90eb2",
11141
+ name: "Ipongo Rural Health Centre",
11142
+ locationType: "HEALTH_FACILITY",
11143
+ administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11144
+ validUntil: null,
11145
+ externalId: "kF2sW9DmH0Bt"
11146
+ },
11147
+ {
11148
+ id: "4cf1f53b-b730-41d2-8649-dff7eeed970d",
11149
+ name: "Itumbwe Health Post",
11150
+ locationType: "HEALTH_FACILITY",
11151
+ administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11152
+ validUntil: null,
11153
+ externalId: "Ue5Xb3VaC7Pq"
11154
+ },
11155
+ {
11156
+ id: "4b3676cb-9355-4942-9eb9-2ce46acaf0e0",
11157
+ name: "Kabangalala Rural Health Centre",
11158
+ locationType: "HEALTH_FACILITY",
11159
+ administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11160
+ validUntil: null,
11161
+ externalId: "Pz8Kc1TqH6Jn"
11162
+ },
11163
+ // Village offices
11164
+ {
11165
+ id: "1f4a5b6c-7d8e-4312-8abc-345678901234",
11166
+ name: "Klow Village Office",
11167
+ locationType: "CRVS_OFFICE",
11168
+ administrativeAreaId: "1d4e5f6a-7b8c-4912-8efa-345678901234",
11169
+ validUntil: null,
11170
+ externalId: "PmAyxAJkxiJ"
11171
+ }
11172
+ ];
11173
+ var V2_DEFAULT_MOCK_LOCATIONS_MAP = new Map(
11174
+ V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, l])
11175
+ );
11176
+ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP = new Map(
11177
+ V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [a.id, a])
11178
+ );