@opencrvs/toolkit 2.1.0-rc.b0003b1 → 2.1.0-rc.b2f00ee

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 (78) hide show
  1. package/build.sh +2 -2
  2. package/dist/application-config/index.js +15 -1
  3. package/dist/cli.js +165 -5154
  4. package/dist/commons/api/router.d.ts +3667 -2887
  5. package/dist/commons/application-config/index.d.ts +6 -6
  6. package/dist/commons/conditionals/conditionals.d.ts +32 -323
  7. package/dist/commons/events/ActionConfig.d.ts +279 -70
  8. package/dist/commons/events/ActionDocument.d.ts +155 -111
  9. package/dist/commons/events/ActionInput.d.ts +26 -6
  10. package/dist/commons/events/ActionType.d.ts +63 -58
  11. package/dist/commons/events/AdvancedSearchConfig.d.ts +513 -501
  12. package/dist/commons/events/AuditLog.d.ts +151 -40
  13. package/dist/commons/events/CompositeFieldValue.d.ts +4 -4
  14. package/dist/commons/events/Conditional.d.ts +3 -3
  15. package/dist/commons/events/CountryConfigQueryInput.d.ts +590 -590
  16. package/dist/commons/events/Draft.d.ts +37 -35
  17. package/dist/commons/events/DynamicFieldValue.d.ts +9 -9
  18. package/dist/commons/events/EventConfig.d.ts +5 -5
  19. package/dist/commons/events/EventDocument.d.ts +66 -44
  20. package/dist/commons/events/EventIndex.d.ts +62 -62
  21. package/dist/commons/events/EventMetadata.d.ts +40 -40
  22. package/dist/commons/events/FieldConfig.d.ts +341 -331
  23. package/dist/commons/events/FieldType.d.ts +51 -51
  24. package/dist/commons/events/FieldTypeMapping.d.ts +100 -100
  25. package/dist/commons/events/FieldValue.d.ts +12 -12
  26. package/dist/commons/events/Flag.d.ts +15 -15
  27. package/dist/commons/events/TemplateConfig.d.ts +1 -1
  28. package/dist/commons/events/WorkqueueColumnConfig.d.ts +40 -40
  29. package/dist/commons/events/WorkqueueConfig.d.ts +827 -824
  30. package/dist/commons/events/deduplication.d.ts +1 -1
  31. package/dist/commons/events/event.d.ts +2 -2
  32. package/dist/commons/events/field.d.ts +69 -198
  33. package/dist/commons/events/index.d.ts +1 -0
  34. package/dist/commons/events/locationPayloads.d.ts +95 -0
  35. package/dist/commons/events/locations.d.ts +103 -6
  36. package/dist/commons/events/mocks.test.utils.d.ts +18 -4
  37. package/dist/commons/events/scopes.d.ts +5 -4
  38. package/dist/commons/events/state/index.d.ts +17 -17
  39. package/dist/commons/events/state/utils.d.ts +7 -7
  40. package/dist/commons/events/test.utils.d.ts +44 -39
  41. package/dist/commons/events/utils.d.ts +127 -105
  42. package/dist/commons/notification/UserNotifications.d.ts +10 -10
  43. package/dist/conditionals/index.js +3 -0
  44. package/dist/environment/derived-variables.d.ts +119 -131
  45. package/dist/environment/derived-variables.d.ts.map +1 -1
  46. package/dist/environment/derived-variables.js +0 -14
  47. package/dist/environment/logger.d.ts +3 -12
  48. package/dist/environment/logger.d.ts.map +1 -1
  49. package/dist/environment/manage-users.js +17 -7
  50. package/dist/environment/questions.d.ts +75 -74
  51. package/dist/environment/questions.d.ts.map +1 -1
  52. package/dist/environment/setup-environment.js +8 -28
  53. package/dist/environment/swarm-to-k8s.js +17 -7
  54. package/dist/environment/update-workflows.js +17 -7
  55. package/dist/environment/users.js +17 -7
  56. package/dist/environment/utils.d.ts +1 -1
  57. package/dist/environment/utils.js +17 -7
  58. package/dist/events/deduplication.d.ts +1 -1
  59. package/dist/events/index.js +380 -88
  60. package/dist/migrations/v2.0/convert-config-files-to-ts.js +17 -7
  61. package/dist/migrations/v2.0/index.js +88 -5144
  62. package/dist/migrations/v2.0/migrate-application-config-url.js +4 -3
  63. package/dist/migrations/v2.0/remove-hearth-migrations.js +17 -7
  64. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +3 -0
  65. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +1 -0
  66. package/dist/migrations/v2.1/add-explicit-correction-flags.js +234 -0
  67. package/dist/migrations/v2.1/index.d.ts +6 -0
  68. package/dist/migrations/v2.1/index.d.ts.map +1 -0
  69. package/dist/migrations/v2.1/index.js +218 -0
  70. package/dist/notification/index.js +328 -104
  71. package/dist/scopes/index.d.ts +148 -140
  72. package/dist/scopes/index.js +3 -0
  73. package/dist/templates/charts-values/dependencies/values.yaml +0 -3
  74. package/dist/templates/charts-values/opencrvs-services/values.yaml +0 -4
  75. package/opencrvs-toolkit-2.1.0-rc.b2f00ee.tgz +0 -0
  76. package/package.json +5 -5
  77. package/tsconfig.tsbuildinfo +1 -1
  78. package/opencrvs-toolkit-2.1.0-rc.b0003b1.tgz +0 -0
@@ -80,6 +80,8 @@ __export(events_exports, {
80
80
  ConditionalType: () => ConditionalType,
81
81
  ConfirmableActions: () => ConfirmableActions,
82
82
  ContainsFlags: () => ContainsFlags,
83
+ CreateAdministrativeAreaPayload: () => CreateAdministrativeAreaPayload,
84
+ CreateLocationPayload: () => CreateLocationPayload,
83
85
  CustomActionInput: () => CustomActionInput,
84
86
  CustomFieldValue: () => CustomFieldValue,
85
87
  CustomFlag: () => CustomFlag,
@@ -161,7 +163,9 @@ __export(events_exports, {
161
163
  LanguageConfig: () => LanguageConfig,
162
164
  LegalStatuses: () => LegalStatuses,
163
165
  Location: () => Location,
166
+ LocationStatus: () => LocationStatus,
164
167
  LocationTypeV1: () => LocationTypeV1,
168
+ LocationVersion: () => LocationVersion,
165
169
  METADATA_FIELD_PREFIX: () => METADATA_FIELD_PREFIX,
166
170
  MarkAsDuplicateActionInput: () => MarkAsDuplicateActionInput,
167
171
  MarkNotDuplicateActionInput: () => MarkNotDuplicateActionInput,
@@ -201,6 +205,8 @@ __export(events_exports, {
201
205
  SelectDateRangeOption: () => SelectDateRangeOption,
202
206
  SelectDateRangeValue: () => SelectDateRangeValue,
203
207
  SelectOption: () => SelectOption,
208
+ SetAdministrativeAreaPayload: () => SetAdministrativeAreaPayload,
209
+ SetLocationPayload: () => SetLocationPayload,
204
210
  ShowConditional: () => ShowConditional,
205
211
  SignatureFieldValue: () => SignatureFieldValue,
206
212
  StaticDataEntry: () => StaticDataEntry,
@@ -214,7 +220,10 @@ __export(events_exports, {
214
220
  TimeValue: () => TimeValue,
215
221
  TranslationConfig: () => TranslationConfig,
216
222
  UUID: () => UUID,
223
+ UnarchiveActionInput: () => UnarchiveActionInput,
217
224
  UnassignActionInput: () => UnassignActionInput,
225
+ UpdateAdministrativeAreaPayload: () => UpdateAdministrativeAreaPayload,
226
+ UpdateLocationPayload: () => UpdateLocationPayload,
218
227
  UserAuditRecordInput: () => UserAuditRecordInput,
219
228
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS: () => V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS,
220
229
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP: () => V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP,
@@ -224,6 +233,8 @@ __export(events_exports, {
224
233
  VerificationActionConfig: () => VerificationActionConfig,
225
234
  VerificationPageConfig: () => VerificationPageConfig,
226
235
  VerificationStatusValue: () => VerificationStatusValue,
236
+ WithdrawAdministrativeAreaVersionPayload: () => WithdrawAdministrativeAreaVersionPayload,
237
+ WithdrawLocationVersionPayload: () => WithdrawLocationVersionPayload,
227
238
  Within: () => Within,
228
239
  WorkqueueActionType: () => WorkqueueActionType,
229
240
  WorkqueueColumn: () => WorkqueueColumn,
@@ -312,6 +323,7 @@ __export(events_exports, {
312
323
  getActionAnnotation: () => getActionAnnotation,
313
324
  getActionAnnotationFields: () => getActionAnnotationFields,
314
325
  getActionConfig: () => getActionConfig,
326
+ getActionFormFields: () => getActionFormFields,
315
327
  getActionReview: () => getActionReview,
316
328
  getActionReviewFields: () => getActionReviewFields,
317
329
  getAdministrativeAreaHierarchy: () => getAdministrativeAreaHierarchy,
@@ -341,6 +353,7 @@ __export(events_exports, {
341
353
  getStatusFromActions: () => getStatusFromActions,
342
354
  getValidatorsForField: () => getValidatorsForField,
343
355
  getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
356
+ hasActiveExternalIdOnOrAfter: () => hasActiveExternalIdOnOrAfter,
344
357
  hasAnyOfScopes: () => hasAnyOfScopes,
345
358
  isActionAvailable: () => isActionAvailable,
346
359
  isActionConfigType: () => isActionConfigType,
@@ -431,6 +444,7 @@ __export(events_exports, {
431
444
  resolveDateOfEvent: () => resolveDateOfEvent,
432
445
  resolveEventCustomFlags: () => resolveEventCustomFlags,
433
446
  resolvePlaceOfEvent: () => resolvePlaceOfEvent,
447
+ resolveVersion: () => resolveVersion,
434
448
  runClientFunction: () => runClientFunction,
435
449
  runFieldValidations: () => runFieldValidations,
436
450
  runStructuralValidations: () => runStructuralValidations,
@@ -481,6 +495,7 @@ var RecordScopeTypeV2 = z2.enum([
481
495
  "record.edit",
482
496
  "record.reject",
483
497
  "record.archive",
498
+ "record.unarchive",
484
499
  "record.review-duplicates",
485
500
  "record.register",
486
501
  "record.print-certified-copies",
@@ -497,6 +512,7 @@ var PlainScopeType = z2.enum([
497
512
  "integration.create",
498
513
  "record.import",
499
514
  "config.update-all",
515
+ "location.edit",
500
516
  "attachment.upload",
501
517
  "profile.electronic-signature",
502
518
  "user.read-only-my-audit",
@@ -586,6 +602,7 @@ var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
586
602
  "record.edit",
587
603
  "record.reject",
588
604
  "record.archive",
605
+ "record.unarchive",
589
606
  "record.review-duplicates",
590
607
  "record.register"
591
608
  ]);
@@ -772,6 +789,7 @@ var ActionType = {
772
789
  MARK_AS_DUPLICATE: "MARK_AS_DUPLICATE",
773
790
  MARK_AS_NOT_DUPLICATE: "MARK_AS_NOT_DUPLICATE",
774
791
  ARCHIVE: "ARCHIVE",
792
+ UNARCHIVE: "UNARCHIVE",
775
793
  // Record actions
776
794
  PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
777
795
  REQUEST_CORRECTION: "REQUEST_CORRECTION",
@@ -791,6 +809,7 @@ var ConfirmableActions = [
791
809
  ActionType.REGISTER,
792
810
  ActionType.REJECT,
793
811
  ActionType.ARCHIVE,
812
+ ActionType.UNARCHIVE,
794
813
  ActionType.PRINT_CERTIFICATE,
795
814
  ActionType.REQUEST_CORRECTION,
796
815
  ActionType.APPROVE_CORRECTION,
@@ -809,6 +828,7 @@ var ActionTypes = z4.enum([
809
828
  "MARK_AS_DUPLICATE",
810
829
  "MARK_AS_NOT_DUPLICATE",
811
830
  "ARCHIVE",
831
+ "UNARCHIVE",
812
832
  "PRINT_CERTIFICATE",
813
833
  "REQUEST_CORRECTION",
814
834
  "REJECT_CORRECTION",
@@ -852,6 +872,7 @@ var WorkqueueActionType = ActionTypes.extract([
852
872
  ActionType.REJECT,
853
873
  ActionType.MARK_AS_DUPLICATE,
854
874
  ActionType.ARCHIVE,
875
+ ActionType.UNARCHIVE,
855
876
  ActionType.PRINT_CERTIFICATE,
856
877
  ActionType.REQUEST_CORRECTION
857
878
  ]);
@@ -916,6 +937,7 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
916
937
  "event.actions.unassign.request",
917
938
  "event.actions.read.request",
918
939
  "event.actions.archive.request",
940
+ "event.actions.unarchive.request",
919
941
  "event.actions.reinstate.request",
920
942
  "event.actions.print_certificate.request",
921
943
  "event.actions.correction.request.request",
@@ -973,6 +995,62 @@ var IntegrationRefreshSecretEntrySchema = AuditLogEntryBase.extend({
973
995
  requestData: z5.object({ id: z5.string() }),
974
996
  responseSummary: z5.object({ clientId: z5.string() })
975
997
  });
998
+ var createdVersionFields = {
999
+ id: z5.string(),
1000
+ versionId: z5.string(),
1001
+ name: z5.string(),
1002
+ externalId: z5.string().nullish(),
1003
+ effectiveFrom: z5.string(),
1004
+ status: z5.string()
1005
+ };
1006
+ var LocationCreateEntrySchema = AuditLogEntryBase.extend({
1007
+ operation: z5.literal("locations.create"),
1008
+ requestData: z5.object({
1009
+ ...createdVersionFields,
1010
+ administrativeAreaId: z5.string().nullish(),
1011
+ locationType: z5.string().nullish()
1012
+ })
1013
+ });
1014
+ var AdministrativeAreaCreateEntrySchema = AuditLogEntryBase.extend({
1015
+ operation: z5.literal("administrativeAreas.create"),
1016
+ requestData: z5.object({
1017
+ ...createdVersionFields,
1018
+ parentId: z5.string().nullish()
1019
+ })
1020
+ });
1021
+ var ChangedStringField = z5.object({ from: z5.string(), to: z5.string() });
1022
+ var ChangedNullableStringField = z5.object({
1023
+ from: z5.string().nullable(),
1024
+ to: z5.string().nullable()
1025
+ });
1026
+ var updatedVersionRequestData = z5.object({
1027
+ id: z5.string(),
1028
+ versionId: z5.string(),
1029
+ name: z5.string(),
1030
+ externalId: z5.string().nullish(),
1031
+ status: z5.string(),
1032
+ effectiveFrom: z5.string(),
1033
+ lastVersionId: z5.string()
1034
+ });
1035
+ var updatedVersionResponseSummary = z5.object({
1036
+ previousVersionId: z5.string(),
1037
+ versionId: z5.string(),
1038
+ changed: z5.object({
1039
+ name: ChangedStringField.optional(),
1040
+ externalId: ChangedNullableStringField.optional(),
1041
+ status: ChangedStringField.optional()
1042
+ })
1043
+ });
1044
+ var LocationUpdateEntrySchema = AuditLogEntryBase.extend({
1045
+ operation: z5.literal("locations.update"),
1046
+ requestData: updatedVersionRequestData,
1047
+ responseSummary: updatedVersionResponseSummary
1048
+ });
1049
+ var AdministrativeAreaUpdateEntrySchema = AuditLogEntryBase.extend({
1050
+ operation: z5.literal("administrativeAreas.update"),
1051
+ requestData: updatedVersionRequestData,
1052
+ responseSummary: updatedVersionResponseSummary
1053
+ });
976
1054
  var AttachmentUploadEntrySchema = AuditLogEntryBase.extend({
977
1055
  operation: z5.literal("attachments.upload"),
978
1056
  requestData: z5.object({
@@ -1048,6 +1126,10 @@ var AuditLogEntrySchema = z5.discriminatedUnion("operation", [
1048
1126
  IntegrationActivateEntrySchema,
1049
1127
  IntegrationDeleteEntrySchema,
1050
1128
  IntegrationRefreshSecretEntrySchema,
1129
+ LocationCreateEntrySchema,
1130
+ LocationUpdateEntrySchema,
1131
+ AdministrativeAreaUpdateEntrySchema,
1132
+ AdministrativeAreaCreateEntrySchema,
1051
1133
  AttachmentUploadEntrySchema,
1052
1134
  UserCreateEntrySchema,
1053
1135
  UserReasonEntrySchema,
@@ -1649,6 +1731,11 @@ var ArchiveAction = ActionBase.extend(
1649
1731
  content: ReasonContent
1650
1732
  }).shape
1651
1733
  );
1734
+ var UnarchiveAction = ActionBase.extend(
1735
+ z14.object({
1736
+ type: z14.literal(ActionType.UNARCHIVE)
1737
+ }).shape
1738
+ );
1652
1739
  var CreatedAction = ActionBase.extend(
1653
1740
  z14.object({
1654
1741
  type: z14.literal(ActionType.CREATE)
@@ -1662,9 +1749,10 @@ var NotifiedAction = ActionBase.extend(
1662
1749
  var EditAction = ActionBase.extend(
1663
1750
  z14.object({
1664
1751
  type: z14.literal(ActionType.EDIT),
1752
+ /** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
1665
1753
  content: z14.object({
1666
1754
  comment: z14.string().describe("Comment for the edit action.").optional()
1667
- })
1755
+ }).optional()
1668
1756
  }).shape
1669
1757
  );
1670
1758
  var PrintContent = z14.object({
@@ -1715,6 +1803,7 @@ var ActionDocument = z14.discriminatedUnion("type", [
1715
1803
  MarkNotDuplicateAction.meta({ id: "MarkNotDuplicateAction" }),
1716
1804
  MarkAsDuplicateAction.meta({ id: "MarkAsDuplicateAction" }),
1717
1805
  ArchiveAction.meta({ id: "ArchiveAction" }),
1806
+ UnarchiveAction.meta({ id: "UnarchiveAction" }),
1718
1807
  NotifiedAction.meta({ id: "NotifiedAction" }),
1719
1808
  RegisterAction.meta({ id: "RegisterAction" }),
1720
1809
  DeclareAction.meta({ id: "DeclareAction" }),
@@ -3224,6 +3313,9 @@ var ActionConfigBase = z24.object({
3224
3313
  var DeclarationActionBase = ActionConfigBase.extend({
3225
3314
  deduplication: DeduplicationConfig.optional()
3226
3315
  });
3316
+ var actionConfirmationForm = z24.array(FieldConfig).optional().describe(
3317
+ "Fields rendered on the action confirmation dialog. Submitted values are stored in the action annotation and shown in the audit history."
3318
+ );
3227
3319
  var ReadActionConfig = ActionConfigBase.extend(
3228
3320
  z24.object({
3229
3321
  type: z24.literal(ActionType.READ),
@@ -3235,7 +3327,54 @@ var ReadActionConfig = ActionConfigBase.extend(
3235
3327
  );
3236
3328
  var NotifyConfig = ActionConfigBase.extend(
3237
3329
  z24.object({
3238
- type: z24.literal(ActionType.NOTIFY)
3330
+ type: z24.literal(ActionType.NOTIFY),
3331
+ form: actionConfirmationForm
3332
+ }).shape
3333
+ );
3334
+ var DuplicateDetectedConfig = ActionConfigBase.extend(
3335
+ z24.object({
3336
+ type: z24.literal(ActionType.DUPLICATE_DETECTED),
3337
+ label: z24.never().optional().describe(
3338
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no label."
3339
+ ),
3340
+ supportingCopy: z24.never().optional(),
3341
+ icon: z24.never().optional().describe(
3342
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no icon."
3343
+ ),
3344
+ conditionals: z24.never().optional().describe(
3345
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it cannot be disabled or hidden with conditionals."
3346
+ )
3347
+ }).shape
3348
+ );
3349
+ var MarkAsDuplicateConfig = ActionConfigBase.extend(
3350
+ z24.object({
3351
+ type: z24.literal(ActionType.MARK_AS_DUPLICATE)
3352
+ }).shape
3353
+ );
3354
+ var MarkAsNotDuplicateConfig = ActionConfigBase.extend(
3355
+ z24.object({
3356
+ type: z24.literal(ActionType.MARK_AS_NOT_DUPLICATE)
3357
+ }).shape
3358
+ );
3359
+ var AssignConfig = ActionConfigBase.extend(
3360
+ z24.object({
3361
+ type: z24.literal(ActionType.ASSIGN),
3362
+ flags: z24.never().optional().describe(
3363
+ "ASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
3364
+ )
3365
+ }).shape
3366
+ );
3367
+ var UnassignConfig = ActionConfigBase.extend(
3368
+ z24.object({
3369
+ type: z24.literal(ActionType.UNASSIGN),
3370
+ flags: z24.never().optional().describe(
3371
+ "UNASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
3372
+ )
3373
+ }).shape
3374
+ );
3375
+ var DeleteConfig = ActionConfigBase.extend(
3376
+ z24.object({
3377
+ type: z24.literal(ActionType.DELETE)
3239
3378
  }).shape
3240
3379
  );
3241
3380
  var DeclareConfig = DeclarationActionBase.extend(
@@ -3244,6 +3383,7 @@ var DeclareConfig = DeclarationActionBase.extend(
3244
3383
  review: DeclarationReviewConfig.describe(
3245
3384
  "Configuration of the review page fields."
3246
3385
  ),
3386
+ form: actionConfirmationForm,
3247
3387
  dialogCopy: z24.object({
3248
3388
  notify: TranslationConfig.describe(
3249
3389
  "Confirmation text for the notify action"
@@ -3259,7 +3399,13 @@ var DeclareConfig = DeclarationActionBase.extend(
3259
3399
  );
3260
3400
  var ArchiveConfig = ActionConfigBase.extend(
3261
3401
  z24.object({
3262
- type: z24.literal(ActionType.ARCHIVE)
3402
+ type: z24.literal(ActionType.ARCHIVE),
3403
+ form: actionConfirmationForm
3404
+ }).shape
3405
+ );
3406
+ var UnarchiveConfig = ActionConfigBase.extend(
3407
+ z24.object({
3408
+ type: z24.literal(ActionType.UNARCHIVE)
3263
3409
  }).shape
3264
3410
  );
3265
3411
  var EditActionConfig = ActionConfigBase.extend(
@@ -3280,12 +3426,14 @@ var EditActionConfig = ActionConfigBase.extend(
3280
3426
  );
3281
3427
  var RejectConfig = ActionConfigBase.extend(
3282
3428
  z24.object({
3283
- type: z24.literal(ActionType.REJECT)
3429
+ type: z24.literal(ActionType.REJECT),
3430
+ form: actionConfirmationForm
3284
3431
  }).shape
3285
3432
  );
3286
3433
  var RegisterConfig = DeclarationActionBase.extend(
3287
3434
  z24.object({
3288
- type: z24.literal(ActionType.REGISTER)
3435
+ type: z24.literal(ActionType.REGISTER),
3436
+ form: actionConfirmationForm
3289
3437
  }).shape
3290
3438
  );
3291
3439
  var PrintCertificateActionConfig = ActionConfigBase.extend(
@@ -3300,7 +3448,17 @@ var RequestCorrectionConfig = ActionConfigBase.extend(
3300
3448
  correctionForm: ActionFormConfig
3301
3449
  }).shape
3302
3450
  );
3303
- var CustomActionConfig = ActionConfigBase.merge(
3451
+ var ApproveCorrectionConfig = ActionConfigBase.extend(
3452
+ z24.object({
3453
+ type: z24.literal(ActionType.APPROVE_CORRECTION)
3454
+ }).shape
3455
+ );
3456
+ var RejectCorrectionConfig = ActionConfigBase.extend(
3457
+ z24.object({
3458
+ type: z24.literal(ActionType.REJECT_CORRECTION)
3459
+ }).shape
3460
+ );
3461
+ var CustomActionConfig = ActionConfigBase.extend(
3304
3462
  z24.object({
3305
3463
  type: z24.literal(ActionType.CUSTOM),
3306
3464
  customActionType: z24.string().describe("Type identifier of the custom action."),
@@ -3311,7 +3469,7 @@ var CustomActionConfig = ActionConfigBase.merge(
3311
3469
  auditHistoryLabel: TranslationConfig.describe(
3312
3470
  'The label to show in audit history for this action. For example "Approved".'
3313
3471
  )
3314
- })
3472
+ }).shape
3315
3473
  );
3316
3474
  var ActionConfig = z24.discriminatedUnion("type", [
3317
3475
  /*
@@ -3322,6 +3480,18 @@ var ActionConfig = z24.discriminatedUnion("type", [
3322
3480
  id: "ReadActionConfig",
3323
3481
  description: "Configuration for the read action \u2014 defines the record-tab content displayed on the event overview page."
3324
3482
  }),
3483
+ AssignConfig.meta({
3484
+ id: "AssignActionConfig",
3485
+ description: "Configuration for assigning a record to the current user."
3486
+ }),
3487
+ UnassignConfig.meta({
3488
+ id: "UnassignActionConfig",
3489
+ description: "Configuration for unassigning a record from its current assignee."
3490
+ }),
3491
+ DeleteConfig.meta({
3492
+ id: "DeleteActionConfig",
3493
+ description: "Configuration for deleting a draft record."
3494
+ }),
3325
3495
  NotifyConfig.meta({
3326
3496
  id: "NotifyActionConfig",
3327
3497
  description: "Configuration for the notify action. When present, NOTIFY uses this config independently from DECLARE. When absent, NOTIFY falls back to the DeclareActionConfig."
@@ -3330,6 +3500,18 @@ var ActionConfig = z24.discriminatedUnion("type", [
3330
3500
  id: "DeclareActionConfig",
3331
3501
  description: "Configuration for the declare action. Includes review-page fields. NOTIFY falls back to this config when no dedicated NotifyActionConfig is provided."
3332
3502
  }),
3503
+ DuplicateDetectedConfig.meta({
3504
+ id: "DuplicateDetectedActionConfig",
3505
+ description: "Configuration for the system-generated duplicate-detection action. Never shown as a button, so it only supports flags \u2014 not label, icon, or conditionals."
3506
+ }),
3507
+ MarkAsDuplicateConfig.meta({
3508
+ id: "MarkAsDuplicateActionConfig",
3509
+ description: "Configuration for marking a record as a duplicate."
3510
+ }),
3511
+ MarkAsNotDuplicateConfig.meta({
3512
+ id: "MarkAsNotDuplicateActionConfig",
3513
+ description: "Configuration for marking a record as not a duplicate, after it was previously flagged as one."
3514
+ }),
3333
3515
  RejectConfig.meta({
3334
3516
  id: "RejectActionConfig",
3335
3517
  description: "Configuration for rejecting a record before registration."
@@ -3346,6 +3528,14 @@ var ActionConfig = z24.discriminatedUnion("type", [
3346
3528
  id: "RequestCorrectionActionConfig",
3347
3529
  description: "Configuration for requesting a correction on a registered record."
3348
3530
  }),
3531
+ ApproveCorrectionConfig.meta({
3532
+ id: "ApproveCorrectionActionConfig",
3533
+ description: "Configuration for approving a requested correction."
3534
+ }),
3535
+ RejectCorrectionConfig.meta({
3536
+ id: "RejectCorrectionActionConfig",
3537
+ description: "Configuration for rejecting a requested correction."
3538
+ }),
3349
3539
  EditActionConfig.meta({
3350
3540
  id: "EditActionConfig",
3351
3541
  description: "Configuration for editing a record before registration."
@@ -3354,6 +3544,10 @@ var ActionConfig = z24.discriminatedUnion("type", [
3354
3544
  id: "ArchiveActionConfig",
3355
3545
  description: "Configuration for archiving a record."
3356
3546
  }),
3547
+ UnarchiveConfig.meta({
3548
+ id: "UnarchiveActionConfig",
3549
+ description: "Configuration for unarchiving a record."
3550
+ }),
3357
3551
  CustomActionConfig.meta({
3358
3552
  id: "CustomActionConfig",
3359
3553
  description: "Configuration for a country-defined custom action. An event may include any number of these."
@@ -4504,9 +4698,6 @@ function getActionConfig({
4504
4698
  if (a.type === ActionType.CUSTOM && customActionType) {
4505
4699
  return a.customActionType === customActionType;
4506
4700
  }
4507
- if (actionType === ActionType.APPROVE_CORRECTION || actionType === ActionType.REJECT_CORRECTION) {
4508
- return a.type === ActionType.REQUEST_CORRECTION;
4509
- }
4510
4701
  return a.type === actionType;
4511
4702
  });
4512
4703
  }
@@ -4516,7 +4707,19 @@ function getCustomActionFields(eventConfiguration, customActionType) {
4516
4707
  customActionType,
4517
4708
  actionType: ActionType.CUSTOM
4518
4709
  });
4519
- if (!actionConfig || !("form" in actionConfig)) {
4710
+ if (!actionConfig || actionConfig.type !== ActionType.CUSTOM) {
4711
+ return [];
4712
+ }
4713
+ return actionConfig.form;
4714
+ }
4715
+ function getActionFormFields(eventConfiguration, actionType, customActionType) {
4716
+ const actionConfig = eventConfiguration.actions.find((a) => {
4717
+ if (a.type === ActionType.CUSTOM && customActionType) {
4718
+ return a.customActionType === customActionType;
4719
+ }
4720
+ return a.type === actionType;
4721
+ });
4722
+ if (!actionConfig || !("form" in actionConfig) || actionConfig.form == null) {
4520
4723
  return [];
4521
4724
  }
4522
4725
  return actionConfig.form;
@@ -4537,13 +4740,9 @@ var getActionAnnotationFields = (actionConfig) => {
4537
4740
  if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
4538
4741
  return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
4539
4742
  }
4540
- if (actionConfig.type === ActionType.CUSTOM) {
4541
- return actionConfig.form;
4542
- }
4543
- if ("review" in actionConfig && actionConfig.review != null) {
4544
- return actionConfig.review.fields;
4545
- }
4546
- return [];
4743
+ const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
4744
+ const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
4745
+ return [...reviewFields, ...formFields];
4547
4746
  };
4548
4747
  function getAllAnnotationFields(config) {
4549
4748
  return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
@@ -5660,7 +5859,7 @@ function validateActionFlags(event2, ctx) {
5660
5859
  const isInherentFlag = (value) => Object.values(InherentFlags).includes(value);
5661
5860
  const configuredFlagIds = event2.flags.map((flag2) => flag2.id);
5662
5861
  const actionFlagIds = event2.actions.flatMap(
5663
- (action) => action.flags.map((flag2) => flag2.id)
5862
+ (action) => (action.flags ?? []).map((flag2) => flag2.id)
5664
5863
  );
5665
5864
  for (const actionFlagId of actionFlagIds) {
5666
5865
  const isConfigured = configuredFlagIds.includes(actionFlagId);
@@ -6290,10 +6489,7 @@ var DeclareActionInput = BaseActionInput.extend(
6290
6489
  );
6291
6490
  var EditActionInput = BaseActionInput.extend(
6292
6491
  z38.object({
6293
- type: z38.literal(ActionType.EDIT).default(ActionType.EDIT),
6294
- content: z38.object({
6295
- comment: z38.string().describe("Comment for the edit action.").optional()
6296
- })
6492
+ type: z38.literal(ActionType.EDIT).default(ActionType.EDIT)
6297
6493
  }).shape
6298
6494
  );
6299
6495
  var PrintCertificateActionInput = BaseActionInput.extend(
@@ -6335,6 +6531,11 @@ var ArchiveActionInput = BaseActionInput.extend(
6335
6531
  content: ReasonContent
6336
6532
  }).shape
6337
6533
  );
6534
+ var UnarchiveActionInput = BaseActionInput.extend(
6535
+ z38.object({
6536
+ type: z38.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
6537
+ }).shape
6538
+ );
6338
6539
  var AssignActionInput = BaseActionInput.extend(
6339
6540
  z38.object({
6340
6541
  type: z38.literal(ActionType.ASSIGN),
@@ -6396,6 +6597,7 @@ var ActionInput = z38.discriminatedUnion("type", [
6396
6597
  id: "MarkNotDuplicateActionInput"
6397
6598
  }),
6398
6599
  ArchiveActionInput.meta({ id: "ArchiveActionInput" }),
6600
+ UnarchiveActionInput.meta({ id: "UnarchiveActionInput" }),
6399
6601
  AssignActionInput.meta({ id: "AssignActionInput" }),
6400
6602
  UnassignActionInput.meta({ id: "UnassignActionInput" }),
6401
6603
  PrintCertificateActionInput.meta({ id: "PrintCertificateActionInput" }),
@@ -6510,6 +6712,7 @@ var updateActions = ActionTypes.extract([
6510
6712
  ActionType.REGISTER,
6511
6713
  ActionType.REJECT,
6512
6714
  ActionType.ARCHIVE,
6715
+ ActionType.UNARCHIVE,
6513
6716
  ActionType.PRINT_CERTIFICATE,
6514
6717
  ActionType.REQUEST_CORRECTION,
6515
6718
  ActionType.APPROVE_CORRECTION,
@@ -6631,15 +6834,12 @@ var INHERENT_FLAG_RULES = [
6631
6834
  },
6632
6835
  {
6633
6836
  // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
6634
- // other status-changing action (see getStatusFromActions).
6837
+ // other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
6838
+ // are deliberately excluded so the flag freezes across an archive/unarchive
6839
+ // round trip and comes back exactly as it was.
6635
6840
  flag: InherentFlags.INCOMPLETE,
6636
6841
  setOn: [ActionType.NOTIFY],
6637
- resetOn: [
6638
- ActionType.CREATE,
6639
- ActionType.DECLARE,
6640
- ActionType.REGISTER,
6641
- ActionType.ARCHIVE
6642
- ]
6842
+ resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
6643
6843
  },
6644
6844
  {
6645
6845
  flag: InherentFlags.REJECTED,
@@ -6703,7 +6903,7 @@ function resolveEventCustomFlags(event2, eventConfiguration) {
6703
6903
  const declaration = aggregateActionDeclarations(eventUpToThisAction);
6704
6904
  const annotation = aggregateActionAnnotations(eventUpToThisAction);
6705
6905
  const form = { ...declaration, ...annotation };
6706
- const flagsWithMetConditions = actionConfig.flags.filter(
6906
+ const flagsWithMetConditions = (actionConfig.flags ?? []).filter(
6707
6907
  ({ conditional }) => (
6708
6908
  // If conditional is not provided, the flag is resolved
6709
6909
  conditional ? isFlagConditionMet(conditional, form, action) : true
@@ -6749,7 +6949,27 @@ function getEventFlags(event2, config) {
6749
6949
 
6750
6950
  // ../commons/src/events/state/index.ts
6751
6951
  function getStatusFromActions(actions) {
6752
- return actions.filter(({ status: status2 }) => status2 === ActionStatus.Accepted).reduce((status2, action) => {
6952
+ const acceptedActions = actions.filter(
6953
+ ({ status: status2 }) => status2 === ActionStatus.Accepted
6954
+ );
6955
+ const isCurrentlyArchived = acceptedActions.reduce(
6956
+ (archived, action) => {
6957
+ if (action.type === ActionType.ARCHIVE) {
6958
+ return true;
6959
+ }
6960
+ if (action.type === ActionType.UNARCHIVE) {
6961
+ return false;
6962
+ }
6963
+ return archived;
6964
+ },
6965
+ false
6966
+ );
6967
+ if (isCurrentlyArchived) {
6968
+ return EventStatus.enum.ARCHIVED;
6969
+ }
6970
+ return acceptedActions.filter(
6971
+ ({ type }) => type !== ActionType.ARCHIVE && type !== ActionType.UNARCHIVE
6972
+ ).reduce((status2, action) => {
6753
6973
  switch (action.type) {
6754
6974
  case ActionType.CREATE:
6755
6975
  return EventStatus.enum.CREATED;
@@ -6757,10 +6977,11 @@ function getStatusFromActions(actions) {
6757
6977
  return EventStatus.enum.DECLARED;
6758
6978
  case ActionType.REGISTER:
6759
6979
  return EventStatus.enum.REGISTERED;
6760
- case ActionType.ARCHIVE:
6761
- return EventStatus.enum.ARCHIVED;
6762
6980
  case ActionType.NOTIFY:
6763
6981
  return EventStatus.enum.NOTIFIED;
6982
+ // Already filtered out above; listed here only to satisfy exhaustiveness.
6983
+ case ActionType.ARCHIVE:
6984
+ case ActionType.UNARCHIVE:
6764
6985
  case ActionType.CUSTOM:
6765
6986
  case ActionType.PRINT_CERTIFICATE:
6766
6987
  case ActionType.ASSIGN:
@@ -9813,7 +10034,6 @@ function eventPayloadGenerator(rng, configuration = tennisClubMembershipEvent) {
9813
10034
  },
9814
10035
  edit: (eventId, input = {}) => ({
9815
10036
  type: ActionType.EDIT,
9816
- content: { comment: "Test comment" },
9817
10037
  transactionId: input.transactionId ?? getUUID(),
9818
10038
  declaration: input.declaration ?? generateActionDeclarationInput(configuration, ActionType.EDIT, rng),
9819
10039
  annotation: input.annotation ?? generateActionAnnotationInput(configuration, ActionType.EDIT, rng),
@@ -9845,6 +10065,14 @@ function eventPayloadGenerator(rng, configuration = tennisClubMembershipEvent) {
9845
10065
  },
9846
10066
  ...input
9847
10067
  }),
10068
+ unarchive: (eventId, input = {}) => ({
10069
+ type: ActionType.UNARCHIVE,
10070
+ transactionId: input.transactionId ?? getUUID(),
10071
+ declaration: {},
10072
+ annotation: {},
10073
+ eventId,
10074
+ ...input
10075
+ }),
9848
10076
  reject: (eventId, input = {}) => ({
9849
10077
  type: ActionType.REJECT,
9850
10078
  transactionId: input.transactionId ?? getUUID(),
@@ -10003,6 +10231,7 @@ function generateActionDocument({
10003
10231
  case ActionType.NOTIFY:
10004
10232
  case ActionType.REGISTER:
10005
10233
  case ActionType.REQUEST_CORRECTION:
10234
+ case ActionType.UNARCHIVE:
10006
10235
  return { ...actionBase, type: action };
10007
10236
  case ActionType.EDIT:
10008
10237
  return {
@@ -10310,21 +10539,60 @@ var LocationTypeV1 = z43.enum([
10310
10539
  "CRVS_OFFICE",
10311
10540
  "HEALTH_FACILITY"
10312
10541
  ]);
10542
+ var LocationStatus = z43.enum(["active", "inactive"]);
10543
+ var LocationVersion = z43.object({
10544
+ versionId: UUID,
10545
+ effectiveFrom: z43.iso.date(),
10546
+ name: z43.string(),
10547
+ externalId: z43.string().nullish(),
10548
+ status: LocationStatus
10549
+ });
10313
10550
  var AdministrativeArea = z43.object({
10314
10551
  id: UUID,
10315
10552
  name: z43.string(),
10316
10553
  externalId: z43.string().nullish(),
10317
10554
  parentId: UUID.nullable(),
10318
- validUntil: z43.iso.datetime().nullable()
10555
+ status: LocationStatus,
10556
+ versions: z43.array(LocationVersion)
10319
10557
  });
10320
10558
  var Location = z43.object({
10321
10559
  id: UUID,
10322
10560
  name: z43.string(),
10323
10561
  externalId: z43.string().nullish(),
10324
10562
  administrativeAreaId: UUID.nullable(),
10325
- validUntil: z43.iso.datetime().nullable(),
10563
+ locationType: z43.string().nullable(),
10564
+ status: LocationStatus,
10565
+ versions: z43.array(LocationVersion)
10566
+ });
10567
+ var SetLocationPayload = z43.object({
10568
+ id: UUID,
10569
+ name: z43.string(),
10570
+ externalId: z43.string().nullish(),
10571
+ administrativeAreaId: UUID.nullable(),
10326
10572
  locationType: z43.string().nullable()
10327
10573
  });
10574
+ var SetAdministrativeAreaPayload = z43.object({
10575
+ id: UUID,
10576
+ name: z43.string(),
10577
+ externalId: z43.string().nullish(),
10578
+ parentId: UUID.nullable()
10579
+ });
10580
+ function resolveVersion(versions, anchor) {
10581
+ let resolved = versions[0];
10582
+ for (const version of versions) {
10583
+ if (version.effectiveFrom <= anchor) {
10584
+ resolved = version;
10585
+ }
10586
+ }
10587
+ return resolved;
10588
+ }
10589
+ function hasActiveExternalIdOnOrAfter(versions, externalId, anchor) {
10590
+ const inEffectAtAnchor = resolveVersion(versions, anchor);
10591
+ const laterVersions = versions.filter((v) => v.effectiveFrom > anchor);
10592
+ return [inEffectAtAnchor, ...laterVersions].some(
10593
+ (v) => v.externalId === externalId && v.status === "active"
10594
+ );
10595
+ }
10328
10596
  function matchesJurisdictionFilter(locationIds, filter, user2) {
10329
10597
  if (!locationIds) {
10330
10598
  return false;
@@ -10521,6 +10789,7 @@ var ACTION_SCOPE_MAP = {
10521
10789
  [ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
10522
10790
  [ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
10523
10791
  [ActionType.ARCHIVE]: ["record.archive"],
10792
+ [ActionType.UNARCHIVE]: ["record.unarchive"],
10524
10793
  [ActionType.REJECT]: ["record.reject"],
10525
10794
  [ActionType.ASSIGN]: null,
10526
10795
  [ActionType.UNASSIGN]: null,
@@ -10727,7 +10996,11 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
10727
10996
  ActionType.CUSTOM,
10728
10997
  ClientSpecificAction.REVIEW_CORRECTION_REQUEST
10729
10998
  ],
10730
- [EventStatus.enum.ARCHIVED]: [ActionType.READ, ActionType.CUSTOM]
10999
+ [EventStatus.enum.ARCHIVED]: [
11000
+ ActionType.READ,
11001
+ ActionType.CUSTOM,
11002
+ ActionType.UNARCHIVE
11003
+ ]
10731
11004
  };
10732
11005
  var ACTION_FILTERS = {
10733
11006
  [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
@@ -10740,6 +11013,7 @@ var ACTION_FILTERS = {
10740
11013
  [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
10741
11014
  [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
10742
11015
  [ActionType.ARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
11016
+ [ActionType.UNARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
10743
11017
  [ActionType.ASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
10744
11018
  [ActionType.UNASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
10745
11019
  [ActionType.CUSTOM]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested"))
@@ -10798,75 +11072,80 @@ function getFilePathsFromEvent(event2) {
10798
11072
  }
10799
11073
 
10800
11074
  // ../commons/src/events/mocks.test.utils.ts
10801
- var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
11075
+ function withVersionFields(entity) {
11076
+ return {
11077
+ ...entity,
11078
+ status: "active",
11079
+ versions: [
11080
+ {
11081
+ versionId: entity.id,
11082
+ effectiveFrom: "0001-01-01",
11083
+ name: entity.name,
11084
+ externalId: entity.externalId ?? null,
11085
+ status: "active"
11086
+ }
11087
+ ]
11088
+ };
11089
+ }
11090
+ var MOCK_ADMINISTRATIVE_AREAS_BASE = [
10802
11091
  {
10803
11092
  id: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10804
11093
  name: "Central",
10805
11094
  parentId: null,
10806
- validUntil: null,
10807
11095
  externalId: "ydyJb1RAy4U1"
10808
11096
  },
10809
11097
  {
10810
11098
  id: "c599b691-fd2d-45e1-abf4-d185de727fb5",
10811
11099
  name: "Sulaka",
10812
11100
  parentId: null,
10813
- validUntil: null,
10814
11101
  externalId: "pQ8nGxWmZ2Q3"
10815
11102
  },
10816
11103
  {
10817
11104
  id: "7ef2b9c7-5e6d-49f6-ae05-656207d0fc64",
10818
11105
  name: "Pualula",
10819
11106
  parentId: null,
10820
- validUntil: null,
10821
11107
  externalId: "Aq91DweLmT8k"
10822
11108
  },
10823
11109
  {
10824
11110
  id: "6d1a59df-988c-4021-a846-ccbc021931a7",
10825
11111
  name: "Chuminga",
10826
11112
  parentId: null,
10827
- validUntil: null,
10828
11113
  externalId: "Rw0fYNh2Xk9a"
10829
11114
  },
10830
11115
  {
10831
11116
  id: "62a0ccb4-880d-4f30-8882-f256007dfff9",
10832
11117
  name: "Ibombo",
10833
11118
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10834
- validUntil: null,
10835
11119
  externalId: "k7DsP4vbN1Qe"
10836
11120
  },
10837
11121
  {
10838
11122
  id: "27160bbd-32d1-4625-812f-860226bfb92a",
10839
11123
  name: "Isango",
10840
11124
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10841
- validUntil: null,
10842
11125
  externalId: "Gm3Z9eQpHw4L"
10843
11126
  },
10844
11127
  {
10845
11128
  id: "967032fd-3f81-478a-826c-30cb8fe121bd",
10846
11129
  name: "Isamba",
10847
11130
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10848
- validUntil: null,
10849
11131
  externalId: "sT0xVu1KqJ7r"
10850
11132
  },
10851
11133
  {
10852
11134
  id: "89a33893-b17d-481d-a26d-6461e7ac1651",
10853
11135
  name: "Itambo",
10854
11136
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10855
- validUntil: null,
10856
11137
  externalId: "Nq6Bv2HpL9Te"
10857
11138
  },
10858
11139
  {
10859
11140
  id: "d42ab2fe-e7ed-470e-8b31-4fb27f9b8250",
10860
11141
  name: "Ezhi",
10861
11142
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10862
- validUntil: null,
10863
11143
  externalId: "xK8cQ0ZRy5Wd"
10864
11144
  },
10865
11145
  {
10866
11146
  id: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
10867
11147
  name: "Ilanga",
10868
11148
  parentId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
10869
- validUntil: null,
10870
11149
  externalId: "Cq4Jm1XvN8Ls"
10871
11150
  },
10872
11151
  // Villages under Ibombo (62a0ccb4-880d-4f30-8882-f256007dfff9)
@@ -10874,49 +11153,42 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
10874
11153
  id: "1d4e5f6a-7b8c-4912-8efa-345678901234",
10875
11154
  name: "Klow",
10876
11155
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
10877
- validUntil: null,
10878
11156
  externalId: "IkYcYBUcyY2"
10879
11157
  },
10880
11158
  {
10881
11159
  id: "2e5f6a7b-8c9d-4a23-8fab-456789012345",
10882
11160
  name: "Mbondo",
10883
11161
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
10884
- validUntil: null,
10885
11162
  externalId: "Qhvv5hvo3mY"
10886
11163
  },
10887
11164
  {
10888
11165
  id: "3f6a7b8c-9d0e-4b34-8abc-567890123456",
10889
11166
  name: "Ndara",
10890
11167
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
10891
- validUntil: null,
10892
11168
  externalId: "crXh068O9TR"
10893
11169
  },
10894
11170
  {
10895
11171
  id: "4a7b8c9d-0e1f-4c45-abcd-678901234567",
10896
11172
  name: "Olani",
10897
11173
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
10898
- validUntil: null,
10899
11174
  externalId: "r00It8Tvvp7"
10900
11175
  },
10901
11176
  {
10902
11177
  id: "5b8c9d0e-1f2a-4d56-bcde-789012345678",
10903
11178
  name: "Pemba",
10904
11179
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
10905
- validUntil: null,
10906
11180
  externalId: "ZnUWsbONIaH"
10907
11181
  },
10908
11182
  {
10909
11183
  id: "6c9d0e1f-2a3b-4e67-8def-890123456789",
10910
11184
  name: "Quanza",
10911
11185
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
10912
- validUntil: null,
10913
11186
  externalId: "fDZycvQTa7l"
10914
11187
  },
10915
11188
  {
10916
11189
  id: "7d0e1f2a-3b4c-4f78-8efa-901234567890",
10917
11190
  name: "Rivka",
10918
11191
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
10919
- validUntil: null,
10920
11192
  externalId: "KqswxCGTELa"
10921
11193
  },
10922
11194
  // Villages under Isamba (967032fd-3f81-478a-826c-30cb8fe121bd)
@@ -10924,35 +11196,30 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
10924
11196
  id: "8e1f2a3b-4c5d-4089-8fab-012345678901",
10925
11197
  name: "Mbula",
10926
11198
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
10927
- validUntil: null,
10928
11199
  externalId: "osEbKjRc9Kg"
10929
11200
  },
10930
11201
  {
10931
11202
  id: "9f2a3b4c-5d6e-4190-8abf-123456789012",
10932
11203
  name: "Ndoki",
10933
11204
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
10934
- validUntil: null,
10935
11205
  externalId: "aq4daBUAGr3"
10936
11206
  },
10937
11207
  {
10938
11208
  id: "0a3b4c5d-6e7f-4201-abcd-234567890123",
10939
11209
  name: "Tsanga",
10940
11210
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
10941
- validUntil: null,
10942
11211
  externalId: "cqis6Y8trbJ"
10943
11212
  },
10944
11213
  {
10945
11214
  id: "1b4c5d6e-7f8a-4312-bcde-345678901234",
10946
11215
  name: "Waziri",
10947
11216
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
10948
- validUntil: null,
10949
11217
  externalId: "LMijHPyyx6d"
10950
11218
  },
10951
11219
  {
10952
11220
  id: "2c5d6e7f-8a9b-4423-8def-456789012345",
10953
11221
  name: "Zimbi",
10954
11222
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
10955
- validUntil: null,
10956
11223
  externalId: "pcQYbPuKGZ7"
10957
11224
  },
10958
11225
  // Villages under Itambo (89a33893-b17d-481d-a26d-6461e7ac1651)
@@ -10960,67 +11227,59 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
10960
11227
  id: "3d6e7f8a-9b0c-4534-8efa-567890123456",
10961
11228
  name: "Felani",
10962
11229
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
10963
- validUntil: null,
10964
11230
  externalId: "gSqpoCGdMXp"
10965
11231
  },
10966
11232
  {
10967
11233
  id: "4e7f8a9b-0c1d-4645-8fab-678901234567",
10968
11234
  name: "Goroma",
10969
11235
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
10970
- validUntil: null,
10971
11236
  externalId: "KvAAIaNqVrp"
10972
11237
  },
10973
11238
  {
10974
11239
  id: "5f8a9b0c-1d2e-4756-8abc-789012345678",
10975
11240
  name: "Halifu",
10976
11241
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
10977
- validUntil: null,
10978
11242
  externalId: "qe4UnEVt1hv"
10979
11243
  },
10980
11244
  {
10981
11245
  id: "6a9b0c1d-2e3f-4867-abcd-890123456789",
10982
11246
  name: "Jabari",
10983
11247
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
10984
- validUntil: null,
10985
11248
  externalId: "yHH9Nz4rLOt"
10986
11249
  },
10987
11250
  {
10988
11251
  id: "7b0c1d2e-3f4a-4978-bcde-901234567890",
10989
11252
  name: "Kifani",
10990
11253
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
10991
- validUntil: null,
10992
11254
  externalId: "eSWmXIGeu1I"
10993
11255
  },
10994
11256
  {
10995
11257
  id: "8c1d2e3f-4a5b-4089-8def-012345678901",
10996
11258
  name: "Lumela",
10997
11259
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
10998
- validUntil: null,
10999
11260
  externalId: "bh0b3aI1uP3"
11000
11261
  }
11001
11262
  ];
11002
- var V2_DEFAULT_MOCK_LOCATIONS = [
11263
+ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = MOCK_ADMINISTRATIVE_AREAS_BASE.map(withVersionFields);
11264
+ var MOCK_LOCATIONS_BASE = [
11003
11265
  {
11004
11266
  id: "6f6186ce-cd5f-4a5f-810a-2d99e7c4ba12",
11005
11267
  name: "Central Provincial Office",
11006
11268
  locationType: "CRVS_OFFICE",
11007
11269
  administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11008
- validUntil: null,
11009
11270
  externalId: "Xr3Df8WpK6Ys"
11010
11271
  },
11011
11272
  {
11012
11273
  id: "b1c2d3e4-f5a6-7890-bcde-f12345678901",
11013
11274
  name: "Central Health Post",
11014
11275
  locationType: "HEALTH_FACILITY",
11015
- administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11016
- validUntil: null
11276
+ administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c"
11017
11277
  },
11018
11278
  {
11019
11279
  id: "028d2c85-ca31-426d-b5d1-2cef545a4902",
11020
11280
  name: "Ibombo District Office",
11021
11281
  locationType: "CRVS_OFFICE",
11022
11282
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11023
- validUntil: null,
11024
11283
  externalId: "Sm4Nw7GrD2Vy"
11025
11284
  },
11026
11285
  {
@@ -11028,7 +11287,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11028
11287
  name: "Isamba District Office",
11029
11288
  locationType: "CRVS_OFFICE",
11030
11289
  administrativeAreaId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11031
- validUntil: null,
11032
11290
  externalId: "Vg1Bq5XeH9Lt"
11033
11291
  },
11034
11292
  {
@@ -11036,7 +11294,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11036
11294
  name: "Isango District Office",
11037
11295
  locationType: "CRVS_OFFICE",
11038
11296
  administrativeAreaId: "27160bbd-32d1-4625-812f-860226bfb92a",
11039
- validUntil: null,
11040
11297
  externalId: "Je7Lm2XqN9Vz"
11041
11298
  },
11042
11299
  {
@@ -11044,7 +11301,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11044
11301
  name: "Sulaka Provincial Office",
11045
11302
  locationType: "CRVS_OFFICE",
11046
11303
  administrativeAreaId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
11047
- validUntil: null,
11048
11304
  externalId: "Ht2Wp9KcX5Qv"
11049
11305
  },
11050
11306
  {
@@ -11052,7 +11308,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11052
11308
  name: "Ilanga District Office",
11053
11309
  locationType: "CRVS_OFFICE",
11054
11310
  administrativeAreaId: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
11055
- validUntil: null,
11056
11311
  externalId: "Yp6Ds1WqN3Xz"
11057
11312
  },
11058
11313
  {
@@ -11060,7 +11315,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11060
11315
  name: "Chamakubi Health Post",
11061
11316
  locationType: "HEALTH_FACILITY",
11062
11317
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11063
- validUntil: null,
11064
11318
  externalId: "M1nFr8LbC2Qy"
11065
11319
  },
11066
11320
  {
@@ -11068,7 +11322,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11068
11322
  name: "Ibombo Rural Health Centre",
11069
11323
  locationType: "HEALTH_FACILITY",
11070
11324
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11071
- validUntil: null,
11072
11325
  externalId: "bT7pV6YrW0Xc"
11073
11326
  },
11074
11327
  {
@@ -11076,7 +11329,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11076
11329
  name: "Chikobo Rural Health Centre",
11077
11330
  locationType: "HEALTH_FACILITY",
11078
11331
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11079
- validUntil: null,
11080
11332
  externalId: "zE4qPn2SgJ5d"
11081
11333
  },
11082
11334
  {
@@ -11084,7 +11336,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11084
11336
  name: "Chilochabalenje Health Post",
11085
11337
  locationType: "HEALTH_FACILITY",
11086
11338
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11087
- validUntil: null,
11088
11339
  externalId: "H8vDs1MqR4Uf"
11089
11340
  },
11090
11341
  {
@@ -11092,7 +11343,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11092
11343
  name: "Chipeso Rural Health Centre",
11093
11344
  locationType: "HEALTH_FACILITY",
11094
11345
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11095
- validUntil: null,
11096
11346
  externalId: "Qw3uZ9KfX6Lm"
11097
11347
  },
11098
11348
  {
@@ -11100,7 +11350,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11100
11350
  name: "Chisamba Rural Health Centre",
11101
11351
  locationType: "HEALTH_FACILITY",
11102
11352
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11103
- validUntil: null,
11104
11353
  externalId: "Yr0pCg8LdM2s"
11105
11354
  },
11106
11355
  {
@@ -11108,7 +11357,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11108
11357
  name: "Chitanda Rural Health Centre",
11109
11358
  locationType: "HEALTH_FACILITY",
11110
11359
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11111
- validUntil: null,
11112
11360
  externalId: "tS9gJ4PwB1Qx"
11113
11361
  },
11114
11362
  {
@@ -11116,7 +11364,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11116
11364
  name: "Golden Valley Rural Health Centre",
11117
11365
  locationType: "HEALTH_FACILITY",
11118
11366
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11119
- validUntil: null,
11120
11367
  externalId: "Ld7Qm3XsA8Vr"
11121
11368
  },
11122
11369
  {
@@ -11124,7 +11371,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11124
11371
  name: "Ipongo Rural Health Centre",
11125
11372
  locationType: "HEALTH_FACILITY",
11126
11373
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11127
- validUntil: null,
11128
11374
  externalId: "kF2sW9DmH0Bt"
11129
11375
  },
11130
11376
  {
@@ -11132,7 +11378,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11132
11378
  name: "Itumbwe Health Post",
11133
11379
  locationType: "HEALTH_FACILITY",
11134
11380
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11135
- validUntil: null,
11136
11381
  externalId: "Ue5Xb3VaC7Pq"
11137
11382
  },
11138
11383
  {
@@ -11140,7 +11385,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11140
11385
  name: "Kabangalala Rural Health Centre",
11141
11386
  locationType: "HEALTH_FACILITY",
11142
11387
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11143
- validUntil: null,
11144
11388
  externalId: "Pz8Kc1TqH6Jn"
11145
11389
  },
11146
11390
  // Village offices
@@ -11149,13 +11393,61 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11149
11393
  name: "Klow Village Office",
11150
11394
  locationType: "CRVS_OFFICE",
11151
11395
  administrativeAreaId: "1d4e5f6a-7b8c-4912-8efa-345678901234",
11152
- validUntil: null,
11153
11396
  externalId: "PmAyxAJkxiJ"
11154
11397
  }
11155
11398
  ];
11399
+ var V2_DEFAULT_MOCK_LOCATIONS = MOCK_LOCATIONS_BASE.map(withVersionFields);
11156
11400
  var V2_DEFAULT_MOCK_LOCATIONS_MAP = new Map(
11157
11401
  V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, l])
11158
11402
  );
11159
11403
  var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP = new Map(
11160
11404
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [a.id, a])
11161
11405
  );
11406
+
11407
+ // ../commons/src/events/locationPayloads.ts
11408
+ var z44 = __toESM(require("zod/v4"));
11409
+ var CreateLocationPayload = z44.object({
11410
+ id: UUID.optional(),
11411
+ versionId: UUID.optional(),
11412
+ name: z44.string(),
11413
+ externalId: z44.string().nullish(),
11414
+ administrativeAreaId: UUID.nullable(),
11415
+ locationType: z44.string().nullable(),
11416
+ effectiveFrom: z44.iso.date().optional(),
11417
+ status: LocationStatus.default("active")
11418
+ });
11419
+ var UpdateLocationPayload = z44.strictObject({
11420
+ id: UUID,
11421
+ versionId: UUID.optional(),
11422
+ name: z44.string(),
11423
+ externalId: z44.string().nullish(),
11424
+ status: LocationStatus,
11425
+ effectiveFrom: z44.iso.date().optional(),
11426
+ lastVersionId: UUID
11427
+ });
11428
+ var WithdrawLocationVersionPayload = z44.object({
11429
+ id: UUID,
11430
+ versionId: UUID
11431
+ });
11432
+ var CreateAdministrativeAreaPayload = z44.object({
11433
+ id: UUID.optional(),
11434
+ versionId: UUID.optional(),
11435
+ name: z44.string(),
11436
+ externalId: z44.string().nullish(),
11437
+ parentId: UUID.nullable(),
11438
+ effectiveFrom: z44.iso.date().optional(),
11439
+ status: LocationStatus.default("active")
11440
+ });
11441
+ var UpdateAdministrativeAreaPayload = z44.strictObject({
11442
+ id: UUID,
11443
+ versionId: UUID.optional(),
11444
+ name: z44.string(),
11445
+ externalId: z44.string().nullish(),
11446
+ status: LocationStatus,
11447
+ effectiveFrom: z44.iso.date().optional(),
11448
+ lastVersionId: UUID
11449
+ });
11450
+ var WithdrawAdministrativeAreaVersionPayload = z44.object({
11451
+ id: UUID,
11452
+ versionId: UUID
11453
+ });