@opencrvs/toolkit 1.9.12-rc.f5ca5e6 → 1.9.12-rc.f687751

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 (128) hide show
  1. package/build.sh +8 -0
  2. package/dist/application-config/index.js +2045 -41
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +4841 -0
  6. package/dist/commons/api/router.d.ts +475 -244
  7. package/dist/commons/application-config/index.d.ts +13 -16
  8. package/dist/commons/conditionals/conditionals.d.ts +8 -8
  9. package/dist/commons/events/ActionDocument.d.ts +196 -196
  10. package/dist/commons/events/ActionInput.d.ts +113 -113
  11. package/dist/commons/events/ActionType.d.ts +3 -3
  12. package/dist/commons/events/AdvancedSearchConfig.d.ts +6 -0
  13. package/dist/commons/events/AuditLog.d.ts +347 -163
  14. package/dist/commons/events/CompositeFieldValue.d.ts +4 -4
  15. package/dist/commons/events/CountryConfigQueryInput.d.ts +461 -190
  16. package/dist/commons/events/Draft.d.ts +9 -9
  17. package/dist/commons/events/DynamicFieldValue.d.ts +37 -19
  18. package/dist/commons/events/EventConfig.d.ts +3 -1
  19. package/dist/commons/events/EventDocument.d.ts +80 -80
  20. package/dist/commons/events/EventIndex.d.ts +35 -27
  21. package/dist/commons/events/EventInput.d.ts +1 -1
  22. package/dist/commons/events/EventMetadata.d.ts +19 -19
  23. package/dist/commons/events/FieldConfig.d.ts +287 -71
  24. package/dist/commons/events/FieldType.d.ts +2 -1
  25. package/dist/commons/events/FieldTypeMapping.d.ts +98 -72
  26. package/dist/commons/events/FieldValue.d.ts +54 -26
  27. package/dist/commons/events/PlainDate.d.ts +1 -1
  28. package/dist/commons/events/WorkqueueColumnConfig.d.ts +7 -7
  29. package/dist/commons/events/WorkqueueConfig.d.ts +443 -199
  30. package/dist/commons/events/defineConfig.d.ts +0 -4
  31. package/dist/commons/events/locations.d.ts +4 -4
  32. package/dist/commons/events/scopes.d.ts +4 -3
  33. package/dist/commons/events/state/index.d.ts +2 -2
  34. package/dist/commons/events/state/utils.d.ts +1 -1
  35. package/dist/commons/events/test.utils.d.ts +2 -2
  36. package/dist/commons/events/utils.d.ts +3 -175
  37. package/dist/commons/notification/UserNotifications.d.ts +21 -1
  38. package/dist/conditionals/index.js +74 -359
  39. package/dist/events/index.js +1207 -1260
  40. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts +3 -0
  41. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +1 -0
  42. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +404 -0
  43. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +3 -0
  44. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +1 -0
  45. package/dist/migrations/v2.0/add-resend-invite-notification.js +345 -0
  46. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +22 -0
  47. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -0
  48. package/dist/migrations/v2.0/checkout-upstream-files.js +147 -0
  49. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts +2 -0
  50. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -0
  51. package/dist/migrations/v2.0/convert-config-files-to-ts.js +828 -0
  52. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts +3 -0
  53. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +1 -0
  54. package/dist/migrations/v2.0/convert-paragraph-to-heading.js +158 -0
  55. package/dist/migrations/v2.0/create-events-index.d.ts +3 -0
  56. package/dist/migrations/v2.0/create-events-index.d.ts.map +1 -0
  57. package/dist/migrations/v2.0/create-events-index.js +325 -0
  58. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +3 -0
  59. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -0
  60. package/dist/migrations/v2.0/delete-infrastructure-directory.js +77 -0
  61. package/dist/migrations/v2.0/index.d.ts +11 -0
  62. package/dist/migrations/v2.0/index.d.ts.map +1 -0
  63. package/dist/migrations/v2.0/index.js +4751 -0
  64. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts +3 -0
  65. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -0
  66. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +343 -0
  67. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +3 -0
  68. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -0
  69. package/dist/migrations/v2.0/merge-infrastructure-directory.js +221 -0
  70. package/dist/migrations/v2.0/migrate-application-config-url.d.ts +3 -0
  71. package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +1 -0
  72. package/dist/migrations/v2.0/migrate-application-config-url.js +342 -0
  73. package/dist/migrations/v2.0/migrate-scopes.d.ts +3 -0
  74. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -0
  75. package/dist/migrations/v2.0/migrate-scopes.js +281 -0
  76. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts +3 -0
  77. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +1 -0
  78. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +267 -0
  79. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts +3 -0
  80. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -0
  81. package/dist/migrations/v2.0/migrate-workqueue-configs.js +236 -0
  82. package/dist/migrations/v2.0/remove-delete-actions.d.ts +3 -0
  83. package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +1 -0
  84. package/dist/migrations/v2.0/remove-delete-actions.js +156 -0
  85. package/dist/migrations/v2.0/remove-demo-scope.d.ts +3 -0
  86. package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -0
  87. package/dist/migrations/v2.0/remove-demo-scope.js +74 -0
  88. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts +3 -0
  89. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +1 -0
  90. package/dist/migrations/v2.0/remove-deprecated-imports.js +96 -0
  91. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +3 -0
  92. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +1 -0
  93. package/dist/migrations/v2.0/remove-fhir-url-helpers.js +163 -0
  94. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts +3 -0
  95. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -0
  96. package/dist/migrations/v2.0/remove-hearth-migrations.js +77 -0
  97. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +3 -0
  98. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +1 -0
  99. package/dist/migrations/v2.0/remove-old-statistics-service.js +356 -0
  100. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts +3 -0
  101. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +1 -0
  102. package/dist/migrations/v2.0/remove-pending-certification-flag.js +109 -0
  103. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts +3 -0
  104. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +1 -0
  105. package/dist/migrations/v2.0/remove-review-from-register-action.js +163 -0
  106. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +3 -0
  107. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +1 -0
  108. package/dist/migrations/v2.0/remove-unused-environment-variables.js +186 -0
  109. package/dist/migrations/v2.0/rename-api-paths.d.ts +3 -0
  110. package/dist/migrations/v2.0/rename-api-paths.d.ts.map +1 -0
  111. package/dist/migrations/v2.0/rename-api-paths.js +187 -0
  112. package/dist/migrations/v2.0/rename-location-parent-id.d.ts +3 -0
  113. package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +1 -0
  114. package/dist/migrations/v2.0/rename-location-parent-id.js +180 -0
  115. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts +3 -0
  116. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +1 -0
  117. package/dist/migrations/v2.0/simplify-analytics-precalculations.js +195 -0
  118. package/dist/migrations/v2.0/update-package-json.d.ts +3 -0
  119. package/dist/migrations/v2.0/update-package-json.d.ts.map +1 -0
  120. package/dist/migrations/v2.0/update-package-json.js +105 -0
  121. package/dist/notification/index.js +1013 -1135
  122. package/dist/scopes/index.d.ts +389 -152
  123. package/dist/scopes/index.js +128 -322
  124. package/opencrvs-toolkit-1.9.12-rc.f687751.tgz +0 -0
  125. package/package.json +11 -7
  126. package/tsconfig.json +3 -0
  127. package/tsconfig.tsbuildinfo +1 -1
  128. package/opencrvs-toolkit-1.9.12-rc.f5ca5e6.tgz +0 -0
@@ -63,6 +63,9 @@ __export(events_exports, {
63
63
  AssignActionInput: () => AssignActionInput,
64
64
  AssignmentStatus: () => AssignmentStatus,
65
65
  AsyncRejectActionDocument: () => AsyncRejectActionDocument,
66
+ AuditLogEntrySchema: () => AuditLogEntrySchema,
67
+ AutocompleteUpdateValue: () => AutocompleteUpdateValue,
68
+ AutocompleteValue: () => AutocompleteValue,
66
69
  BaseActionInput: () => BaseActionInput,
67
70
  BearerTokenByUserType: () => BearerTokenByUserType,
68
71
  ButtonFieldValue: () => ButtonFieldValue,
@@ -329,6 +332,7 @@ __export(events_exports, {
329
332
  isAddressFieldType: () => isAddressFieldType,
330
333
  isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
331
334
  isAgeFieldType: () => isAgeFieldType,
335
+ isAutocompleteFieldType: () => isAutocompleteFieldType,
332
336
  isBulletListFieldType: () => isBulletListFieldType,
333
337
  isButtonFieldType: () => isButtonFieldType,
334
338
  isCheckboxFieldType: () => isCheckboxFieldType,
@@ -422,111 +426,267 @@ __export(events_exports, {
422
426
  module.exports = __toCommonJS(events_exports);
423
427
 
424
428
  // ../commons/src/events/AuditLog.ts
429
+ var z5 = __toESM(require("zod/v4"));
430
+
431
+ // ../commons/src/authentication.ts
432
+ var import_jwt_decode = __toESM(require("jwt-decode"));
433
+ var z3 = __toESM(require("zod/v4"));
434
+
435
+ // ../commons/src/scopes.ts
436
+ var z2 = __toESM(require("zod/v4"));
437
+ var qs = __toESM(require("qs"));
438
+
439
+ // ../commons/src/uuid.ts
440
+ var import_uuid = require("uuid");
425
441
  var z = __toESM(require("zod/v4"));
426
- var UserAuditRecordInput = z.discriminatedUnion("operation", [
427
- z.object({
428
- operation: z.literal("user.create_user"),
429
- requestData: z.object({
430
- subjectId: z.string(),
431
- role: z.string(),
432
- primaryOfficeId: z.string()
433
- }),
434
- responseSummary: z.object({})
435
- }),
436
- z.object({
437
- operation: z.literal("user.deactivate"),
438
- requestData: z.object({
439
- subjectId: z.string(),
440
- reason: z.string(),
441
- comment: z.string().optional()
442
- }),
443
- responseSummary: z.object({})
444
- }),
445
- z.object({
446
- operation: z.literal("user.reactivate"),
447
- requestData: z.object({
448
- subjectId: z.string(),
449
- reason: z.string(),
450
- comment: z.string().optional()
451
- }),
452
- responseSummary: z.object({})
453
- }),
454
- z.object({
455
- operation: z.literal("user.edit_user"),
456
- requestData: z.object({ subjectId: z.string() }),
457
- responseSummary: z.object({})
458
- }),
459
- z.object({
460
- operation: z.literal("user.email_address_changed"),
461
- requestData: z.object({ subjectId: z.string() }),
462
- responseSummary: z.object({ email: z.string() })
442
+ var UUID = z.uuid().brand("UUID");
443
+ function getUUID() {
444
+ return (0, import_uuid.v4)();
445
+ }
446
+
447
+ // ../commons/src/scopes.ts
448
+ var JurisdictionFilter = z2.enum(["administrativeArea", "location", "all"]).describe(
449
+ "Filters based on user jurisdiction relative to their office location in hierarchy."
450
+ );
451
+ var UserFilter = z2.enum(["user"]).describe("Filters based on the user. Limits to self.");
452
+ var RecordScopeTypeV2 = z2.enum([
453
+ "record.search",
454
+ "record.create",
455
+ "record.read",
456
+ "record.declare",
457
+ "record.notify",
458
+ "record.edit",
459
+ "record.reject",
460
+ "record.archive",
461
+ "record.review-duplicates",
462
+ "record.register",
463
+ "record.print-certified-copies",
464
+ "record.request-correction",
465
+ "record.correct",
466
+ "record.unassign-others",
467
+ "record.custom-action"
468
+ ]);
469
+ var PlainScopeType = z2.enum([
470
+ // Misc. system scopes
471
+ "bypassratelimit",
472
+ "record.reindex",
473
+ "user.data-seeding",
474
+ "integration.create",
475
+ "record.import",
476
+ "config.update-all",
477
+ "attachment.upload",
478
+ "profile.electronic-signature",
479
+ "user.read-only-my-audit",
480
+ // Performance dashboard
481
+ "performance.read",
482
+ "performance.read-dashboards",
483
+ "performance.vital-statistics-export",
484
+ // Scopes used exclusively by countryconfig integration token
485
+ "record.confirm-registration",
486
+ "record.reject-registration"
487
+ ]);
488
+ var scopeByEvent = z2.preprocess(
489
+ (val) => val === void 0 ? void 0 : [val].flat(),
490
+ z2.array(z2.string()).optional()
491
+ ).describe("Event type, e.g. birth, death");
492
+ var scopeOptionsPlaceEvent = z2.object({
493
+ event: scopeByEvent,
494
+ placeOfEvent: JurisdictionFilter.optional()
495
+ }).describe("Options applicable to all record scopes.");
496
+ var scopeOptionsDeclared = scopeOptionsPlaceEvent.extend({
497
+ declaredIn: JurisdictionFilter.optional(),
498
+ declaredBy: UserFilter.optional()
499
+ }).describe("Options applicable to actions that may take place after DECLARE");
500
+ var AllRecordScopeOptions = scopeOptionsDeclared.extend({
501
+ registeredIn: JurisdictionFilter.optional(),
502
+ registeredBy: UserFilter.optional()
503
+ }).describe(
504
+ "Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
505
+ );
506
+ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
507
+ customActionTypes: z2.preprocess(
508
+ (val) => val === void 0 ? void 0 : [val].flat(),
509
+ z2.array(z2.string()).optional()
510
+ ).describe("Allowed custom action types")
511
+ });
512
+ var AccessLevelOptions = z2.object({
513
+ accessLevel: JurisdictionFilter.optional()
514
+ });
515
+ var WorkqueueOrDashboardOptions = z2.object({
516
+ ids: z2.preprocess(
517
+ (val) => val === void 0 ? void 0 : [val].flat(),
518
+ z2.array(z2.string())
519
+ ).describe("Must contain a list of workqueue or dashboard ids.")
520
+ });
521
+ var AllScopeOptions = z2.object({
522
+ ...AllRecordScopeOptions.shape,
523
+ ...AccessLevelOptions.shape,
524
+ ...WorkqueueOrDashboardOptions.shape
525
+ });
526
+ var ScopeOptionKey = AllScopeOptions.keyof();
527
+ var ResolvedScopeOptionsPlaceEvent = z2.object({
528
+ event: scopeByEvent,
529
+ placeOfEvent: UUID.nullish()
530
+ }).describe(
531
+ "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
532
+ );
533
+ var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
534
+ declaredIn: UUID.nullish(),
535
+ declaredBy: z2.string().optional()
536
+ }).describe(
537
+ "Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
538
+ );
539
+ var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
540
+ registeredIn: UUID.nullish(),
541
+ registeredBy: z2.string().optional()
542
+ }).describe(
543
+ "Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
544
+ );
545
+ var ScopesWithPlaceEventOptions = RecordScopeTypeV2.extract([
546
+ "record.create",
547
+ "record.declare",
548
+ "record.notify"
549
+ ]);
550
+ var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
551
+ "record.edit",
552
+ "record.reject",
553
+ "record.archive",
554
+ "record.review-duplicates",
555
+ "record.register"
556
+ ]);
557
+ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
558
+ "record.search",
559
+ "record.read",
560
+ "record.request-correction",
561
+ "record.correct",
562
+ "record.unassign-others"
563
+ ]);
564
+ var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
565
+ templates: z2.preprocess(
566
+ (val) => val === void 0 ? void 0 : [val].flat(),
567
+ z2.array(z2.string()).optional()
568
+ ).describe(
569
+ "Template IDs for certified copies. Controls which certificate templates are returned to the client via the config service. Certificate printing is a client-side operation \u2014 this option is not validated when the printCertificate action is submitted."
570
+ )
571
+ });
572
+ var RecordScopeV2 = z2.discriminatedUnion("type", [
573
+ z2.object({
574
+ type: ScopesWithPlaceEventOptions,
575
+ options: scopeOptionsPlaceEvent.optional()
463
576
  }),
464
- z.object({
465
- operation: z.literal("user.logged_in"),
466
- requestData: z.object({ subjectId: z.string() }),
467
- responseSummary: z.object({})
577
+ z2.object({
578
+ type: ScopesWithDeclaredOptions,
579
+ options: scopeOptionsDeclared.optional()
468
580
  }),
469
- z.object({
470
- operation: z.literal("user.logged_out"),
471
- requestData: z.object({ subjectId: z.string() }),
472
- responseSummary: z.object({})
581
+ z2.object({
582
+ type: ScopesWithFullOptions,
583
+ options: AllRecordScopeOptions.optional()
473
584
  }),
474
- z.object({
475
- operation: z.literal("user.password_changed"),
476
- requestData: z.object({ subjectId: z.string() }),
477
- responseSummary: z.object({})
585
+ z2.object({
586
+ type: z2.literal("record.custom-action"),
587
+ options: CustomActionScopeOptions.optional()
478
588
  }),
479
- z.object({
480
- operation: z.literal("user.password_reset"),
481
- requestData: z.object({ subjectId: z.string() }),
482
- responseSummary: z.object({})
589
+ z2.object({
590
+ type: z2.literal("record.print-certified-copies"),
591
+ options: ScopeOptionsPrintCertifiedCopies.optional()
592
+ })
593
+ ]).describe(
594
+ "Scopes used to check user's permission to perform actions on a record."
595
+ );
596
+ function scopeUsesDeclaredOptions(scope) {
597
+ return !ScopesWithPlaceEventOptions.options.some((opt) => opt === scope.type);
598
+ }
599
+ function scopeUsesFullOptions(scope) {
600
+ return ScopesWithFullOptions.options.some((opt) => opt === scope.type);
601
+ }
602
+ function scopeUsesPrintCertifiedCopiesOptions(scope) {
603
+ return scope.type === "record.print-certified-copies";
604
+ }
605
+ function isCustomActionScope(scope) {
606
+ return scope.type === "record.custom-action";
607
+ }
608
+ var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
609
+ z2.object({
610
+ type: ScopesWithPlaceEventOptions,
611
+ options: ResolvedScopeOptionsPlaceEvent.optional()
483
612
  }),
484
- z.object({
485
- operation: z.literal("user.password_reset_by_admin"),
486
- requestData: z.object({ subjectId: z.string() }),
487
- responseSummary: z.object({})
613
+ z2.object({
614
+ type: ScopesWithDeclaredOptions,
615
+ options: ResolvedScopeOptionsDeclared.optional()
488
616
  }),
489
- z.object({
490
- operation: z.literal("user.phone_number_changed"),
491
- requestData: z.object({ subjectId: z.string() }),
492
- responseSummary: z.object({ phoneNumber: z.string() })
617
+ z2.object({
618
+ type: ScopesWithFullOptions,
619
+ options: ResolvedScopeOptionsFull.optional()
493
620
  }),
494
- z.object({
495
- operation: z.literal("user.username_reminder"),
496
- requestData: z.object({ subjectId: z.string() }),
497
- responseSummary: z.object({})
621
+ z2.object({
622
+ type: z2.literal("record.print-certified-copies"),
623
+ options: ResolvedScopeOptionsFull.extend({
624
+ templates: z2.array(z2.string()).optional()
625
+ }).optional()
626
+ })
627
+ ]).describe("Resolved scope with location/user IDs instead of filters.");
628
+ var SystemScopeType = z2.enum([
629
+ "organisation.read-locations",
630
+ "user.read",
631
+ "user.create",
632
+ "user.edit"
633
+ ]);
634
+ var Scope = z2.discriminatedUnion("type", [
635
+ z2.object({ type: PlainScopeType }),
636
+ ...RecordScopeV2.options,
637
+ z2.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
638
+ z2.object({
639
+ type: z2.literal("workqueue"),
640
+ options: WorkqueueOrDashboardOptions
498
641
  }),
499
- z.object({
500
- operation: z.literal("user.username_reminder_by_admin"),
501
- requestData: z.object({ subjectId: z.string() }),
502
- responseSummary: z.object({})
642
+ z2.object({
643
+ type: z2.literal("dashboard.view"),
644
+ options: WorkqueueOrDashboardOptions
503
645
  })
504
646
  ]);
647
+ var ScopeType = z2.enum([
648
+ ...SystemScopeType.options,
649
+ ...RecordScopeTypeV2.options,
650
+ ...PlainScopeType.options,
651
+ "workqueue",
652
+ "dashboard.view"
653
+ ]);
654
+ var unflattenScope = (input) => {
655
+ const { type, ...options } = input;
656
+ return { type, options };
657
+ };
658
+ var EncodedScope = z2.string().brand("EncodedScope");
659
+ var decodeScope = (query) => {
660
+ const scope = qs.parse(query, {
661
+ ignoreQueryPrefix: true,
662
+ comma: true,
663
+ allowDots: true
664
+ });
665
+ const unflattenedScope = unflattenScope(scope);
666
+ return Scope.safeParse(unflattenedScope)?.data;
667
+ };
668
+ var DEFAULT_SCOPE_OPTIONS = {
669
+ placeOfEvent: JurisdictionFilter.enum.all,
670
+ accessLevel: JurisdictionFilter.enum.all
671
+ };
672
+ function getAcceptedScopesByType({
673
+ acceptedScopes,
674
+ scopes
675
+ }) {
676
+ return scopes.map((scope) => {
677
+ const parsedScope = decodeScope(scope);
678
+ return parsedScope && acceptedScopes.some(
679
+ (acceptedScope) => acceptedScope === parsedScope.type
680
+ ) ? parsedScope : null;
681
+ }).filter((scope) => scope !== null);
682
+ }
505
683
 
506
- // ../commons/src/events/Constants.ts
507
- var TENNIS_CLUB_MEMBERSHIP = "tennis-club-membership";
508
- var CHILD_ONBOARDING_EVENT = "child-onboarding";
509
-
510
- // ../commons/src/events/ActionConfig.ts
511
- var z25 = __toESM(require("zod/v4"));
512
-
513
- // ../commons/src/events/TranslationConfig.ts
514
- var z2 = __toESM(require("zod/v4"));
515
- var TranslationConfig = z2.object({
516
- id: z2.string().describe(
517
- "The identifier of the translation referred in translation CSV files"
518
- ),
519
- defaultMessage: z2.string().describe("Default translation message"),
520
- description: z2.string().describe(
521
- "Describe the translation for a translator to be able to identify it."
522
- )
523
- }).meta({
524
- description: "Translation configuration",
525
- id: "TranslationConfig"
526
- });
684
+ // ../commons/src/authentication.ts
685
+ var TokenUserType = z3.enum(["user", "system"]);
686
+ var TokenWithBearer = z3.string().regex(/^Bearer\s/);
527
687
 
528
688
  // ../commons/src/events/ActionType.ts
529
- var z3 = __toESM(require("zod/v4"));
689
+ var z4 = __toESM(require("zod/v4"));
530
690
  var ActionType = {
531
691
  // Pre-declaration actions
532
692
  DELETE: "DELETE",
@@ -568,7 +728,7 @@ var ConfirmableActions = [
568
728
  ActionType.REJECT_CORRECTION,
569
729
  ActionType.CUSTOM
570
730
  ];
571
- var ActionTypes = z3.enum([
731
+ var ActionTypes = z4.enum([
572
732
  "DELETE",
573
733
  "CREATE",
574
734
  "NOTIFY",
@@ -635,12 +795,226 @@ function isMetaAction(actionType) {
635
795
  return META_ACTIONS.includes(actionType);
636
796
  }
637
797
 
798
+ // ../commons/src/events/AuditLog.ts
799
+ var AuditLogEntryBase = z5.object({
800
+ id: z5.string(),
801
+ clientId: z5.string(),
802
+ clientType: TokenUserType,
803
+ createdAt: z5.string()
804
+ });
805
+ var EventCreateEntrySchema = AuditLogEntryBase.extend({
806
+ operation: z5.literal("event.create"),
807
+ requestData: z5.object({
808
+ transactionId: z5.string(),
809
+ type: z5.string(),
810
+ createdAtLocation: z5.string().nullable()
811
+ }),
812
+ responseSummary: z5.object({
813
+ eventId: z5.string(),
814
+ trackingId: z5.string()
815
+ })
816
+ });
817
+ var EventGetEntrySchema = AuditLogEntryBase.extend({
818
+ operation: z5.literal("event.get"),
819
+ requestData: z5.object({ eventId: z5.string() }),
820
+ responseSummary: z5.object({
821
+ eventType: z5.string(),
822
+ trackingId: z5.string()
823
+ })
824
+ });
825
+ var EventSearchEntrySchema = AuditLogEntryBase.extend({
826
+ operation: z5.literal("event.search"),
827
+ clientType: z5.literal("system"),
828
+ requestData: z5.object({
829
+ query: z5.record(z5.string(), z5.unknown()).nullable(),
830
+ limit: z5.number().nullable(),
831
+ offset: z5.number().nullable()
832
+ }),
833
+ responseSummary: z5.object({
834
+ total: z5.number(),
835
+ eventIds: z5.array(z5.string())
836
+ })
837
+ });
838
+ var EventActionEntrySchema = AuditLogEntryBase.extend({
839
+ operation: z5.enum([
840
+ "event.actions.notify.request",
841
+ "event.actions.declare.request",
842
+ "event.actions.register.request",
843
+ "event.actions.reject.request",
844
+ "event.actions.validate.request",
845
+ "event.actions.edit.request",
846
+ "event.actions.assign.request",
847
+ "event.actions.unassign.request",
848
+ "event.actions.read.request",
849
+ "event.actions.archive.request",
850
+ "event.actions.reinstate.request",
851
+ "event.actions.print_certificate.request",
852
+ "event.actions.correction.request.request",
853
+ "event.actions.correction.approve.request",
854
+ "event.actions.correction.reject.request",
855
+ "event.actions.mark_as_duplicate.request",
856
+ "event.actions.mark_as_not_duplicate.request"
857
+ ]),
858
+ requestData: z5.object({
859
+ eventId: z5.string(),
860
+ actionType: z5.string(),
861
+ eventType: z5.string(),
862
+ trackingId: z5.string(),
863
+ transactionId: z5.string()
864
+ })
865
+ });
866
+ var EventCustomActionEntrySchema = AuditLogEntryBase.extend({
867
+ operation: z5.literal("event.actions.custom.request"),
868
+ requestData: z5.object({
869
+ eventId: z5.string(),
870
+ actionType: z5.literal(ActionType.CUSTOM),
871
+ customAction: z5.string(),
872
+ eventType: z5.string(),
873
+ trackingId: z5.string(),
874
+ transactionId: z5.string()
875
+ })
876
+ });
877
+ var IntegrationCreateEntrySchema = AuditLogEntryBase.extend({
878
+ operation: z5.literal("integrations.create"),
879
+ requestData: z5.object({ name: z5.string(), scopes: z5.array(z5.string()) }),
880
+ responseSummary: z5.object({ clientId: z5.string() })
881
+ });
882
+ var IntegrationRefreshTokenEntrySchema = AuditLogEntryBase.extend({
883
+ operation: z5.literal("integrations.refreshToken"),
884
+ requestData: z5.object({ clientId: z5.string() }),
885
+ responseSummary: z5.object({ clientId: z5.string() })
886
+ });
887
+ var IntegrationDeactivateEntrySchema = AuditLogEntryBase.extend({
888
+ operation: z5.literal("integrations.deactivate"),
889
+ requestData: z5.object({ id: z5.string() }),
890
+ responseSummary: z5.object({ id: z5.string(), status: z5.string() })
891
+ });
892
+ var IntegrationActivateEntrySchema = AuditLogEntryBase.extend({
893
+ operation: z5.literal("integrations.activate"),
894
+ requestData: z5.object({ id: z5.string() }),
895
+ responseSummary: z5.object({ id: z5.string(), status: z5.string() })
896
+ });
897
+ var IntegrationDeleteEntrySchema = AuditLogEntryBase.extend({
898
+ operation: z5.literal("integrations.delete"),
899
+ requestData: z5.object({ id: z5.string() }),
900
+ responseSummary: z5.object({ id: z5.string(), name: z5.string() })
901
+ });
902
+ var IntegrationRefreshSecretEntrySchema = AuditLogEntryBase.extend({
903
+ operation: z5.literal("integrations.refreshSecret"),
904
+ requestData: z5.object({ id: z5.string() }),
905
+ responseSummary: z5.object({ clientId: z5.string() })
906
+ });
907
+ var AttachmentUploadEntrySchema = AuditLogEntryBase.extend({
908
+ operation: z5.literal("attachments.upload"),
909
+ requestData: z5.object({
910
+ transactionId: z5.string(),
911
+ path: z5.string().nullable()
912
+ }),
913
+ responseSummary: z5.object({ fileUrl: z5.string() })
914
+ });
915
+ var subjectOnly = z5.object({ subjectId: z5.string() });
916
+ var subjectWithReason = z5.object({
917
+ subjectId: z5.string(),
918
+ reason: z5.string(),
919
+ comment: z5.string().optional()
920
+ });
921
+ var UserCreateEntrySchema = AuditLogEntryBase.extend({
922
+ operation: z5.literal("user.create_user"),
923
+ requestData: z5.object({
924
+ subjectId: z5.string(),
925
+ role: z5.string(),
926
+ primaryOfficeId: z5.string()
927
+ })
928
+ });
929
+ var UserReasonEntrySchema = AuditLogEntryBase.extend({
930
+ operation: z5.enum(["user.deactivate", "user.reactivate"]),
931
+ requestData: subjectWithReason
932
+ });
933
+ var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
934
+ operation: z5.enum([
935
+ "user.edit_user",
936
+ "user.logged_in",
937
+ "user.logged_out",
938
+ "user.password_changed",
939
+ "user.password_reset",
940
+ "user.password_reset_by_admin",
941
+ "user.resend_invite",
942
+ "user.username_reminder",
943
+ "user.username_reminder_by_admin"
944
+ ]),
945
+ requestData: subjectOnly
946
+ });
947
+ var UserEmailChangedEntrySchema = AuditLogEntryBase.extend({
948
+ operation: z5.literal("user.email_address_changed"),
949
+ requestData: subjectOnly,
950
+ responseSummary: z5.object({ email: z5.string() })
951
+ });
952
+ var UserPhoneChangedEntrySchema = AuditLogEntryBase.extend({
953
+ operation: z5.literal("user.phone_number_changed"),
954
+ requestData: subjectOnly,
955
+ responseSummary: z5.object({ phoneNumber: z5.string() })
956
+ });
957
+ var userBaseOmit = {
958
+ id: true,
959
+ clientId: true,
960
+ clientType: true,
961
+ createdAt: true
962
+ };
963
+ var UserAuditRecordInput = z5.discriminatedUnion("operation", [
964
+ UserCreateEntrySchema.omit(userBaseOmit),
965
+ UserReasonEntrySchema.omit(userBaseOmit),
966
+ UserSubjectOnlyEntrySchema.omit(userBaseOmit),
967
+ UserEmailChangedEntrySchema.omit(userBaseOmit),
968
+ UserPhoneChangedEntrySchema.omit(userBaseOmit)
969
+ ]);
970
+ var AuditLogEntrySchema = z5.discriminatedUnion("operation", [
971
+ EventCreateEntrySchema,
972
+ EventGetEntrySchema,
973
+ EventSearchEntrySchema,
974
+ EventActionEntrySchema,
975
+ EventCustomActionEntrySchema,
976
+ IntegrationCreateEntrySchema,
977
+ IntegrationRefreshTokenEntrySchema,
978
+ IntegrationDeactivateEntrySchema,
979
+ IntegrationActivateEntrySchema,
980
+ IntegrationDeleteEntrySchema,
981
+ IntegrationRefreshSecretEntrySchema,
982
+ AttachmentUploadEntrySchema,
983
+ UserCreateEntrySchema,
984
+ UserReasonEntrySchema,
985
+ UserSubjectOnlyEntrySchema,
986
+ UserEmailChangedEntrySchema,
987
+ UserPhoneChangedEntrySchema
988
+ ]);
989
+
990
+ // ../commons/src/events/Constants.ts
991
+ var TENNIS_CLUB_MEMBERSHIP = "tennis-club-membership";
992
+ var CHILD_ONBOARDING_EVENT = "child-onboarding";
993
+
994
+ // ../commons/src/events/ActionConfig.ts
995
+ var z24 = __toESM(require("zod/v4"));
996
+
997
+ // ../commons/src/events/TranslationConfig.ts
998
+ var z6 = __toESM(require("zod/v4"));
999
+ var TranslationConfig = z6.object({
1000
+ id: z6.string().describe(
1001
+ "The identifier of the translation referred in translation CSV files"
1002
+ ),
1003
+ defaultMessage: z6.string().describe("Default translation message"),
1004
+ description: z6.string().describe(
1005
+ "Describe the translation for a translator to be able to identify it."
1006
+ )
1007
+ }).meta({
1008
+ description: "Translation configuration",
1009
+ id: "TranslationConfig"
1010
+ });
1011
+
638
1012
  // ../commons/src/events/FieldConfig.ts
639
1013
  var import_v43 = __toESM(require("zod/v4"));
640
1014
 
641
1015
  // ../commons/src/events/Conditional.ts
642
- var z4 = __toESM(require("zod/v4"));
643
- var Conditional = z4.any().describe("JSONSchema").meta({
1016
+ var z7 = __toESM(require("zod/v4"));
1017
+ var Conditional = z7.any().describe("JSONSchema").meta({
644
1018
  description: "JSON schema conditional configuration",
645
1019
  id: "Conditional"
646
1020
  });
@@ -649,31 +1023,31 @@ var ConditionalType = {
649
1023
  ENABLE: "ENABLE",
650
1024
  DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
651
1025
  };
652
- var ShowConditional = z4.object({
653
- type: z4.literal(ConditionalType.SHOW),
1026
+ var ShowConditional = z7.object({
1027
+ type: z7.literal(ConditionalType.SHOW),
654
1028
  conditional: Conditional
655
1029
  }).describe(
656
1030
  "If 'SHOW' conditional is defined, the component is shown to the user only if the condition is met"
657
1031
  );
658
- var EnableConditional = z4.object({
659
- type: z4.literal(ConditionalType.ENABLE),
1032
+ var EnableConditional = z7.object({
1033
+ type: z7.literal(ConditionalType.ENABLE),
660
1034
  conditional: Conditional
661
1035
  }).describe(
662
1036
  "If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
663
1037
  );
664
- var ActionConditional = z4.discriminatedUnion("type", [
1038
+ var ActionConditional = z7.discriminatedUnion("type", [
665
1039
  // Action can be shown / hidden
666
1040
  ShowConditional,
667
1041
  // Action can be shown to the user in the list but as disabled
668
1042
  EnableConditional
669
1043
  ]);
670
- var DisplayOnReviewConditional = z4.object({
671
- type: z4.literal(ConditionalType.DISPLAY_ON_REVIEW),
1044
+ var DisplayOnReviewConditional = z7.object({
1045
+ type: z7.literal(ConditionalType.DISPLAY_ON_REVIEW),
672
1046
  conditional: Conditional
673
1047
  }).describe(
674
1048
  "If 'DISPLAY_ON_REVIEW' conditional is defined, the component is shown on the review page only if both the 'DISPLAY_ON_REVIEW' and 'SHOW' conditions are met. This should only be used for fields within declaration forms, as they are the only ones with review pages."
675
1049
  );
676
- var FieldConditional = z4.discriminatedUnion("type", [
1050
+ var FieldConditional = z7.discriminatedUnion("type", [
677
1051
  // Field input can be shown / hidden
678
1052
  ShowConditional,
679
1053
  // Field input can be shown to the user but as disabled
@@ -686,7 +1060,7 @@ var FieldConditional = z4.discriminatedUnion("type", [
686
1060
  });
687
1061
 
688
1062
  // ../commons/src/events/FieldType.ts
689
- var z5 = __toESM(require("zod/v4"));
1063
+ var z8 = __toESM(require("zod/v4"));
690
1064
  var FieldType = {
691
1065
  NAME: "NAME",
692
1066
  PHONE: "PHONE",
@@ -726,6 +1100,7 @@ var FieldType = {
726
1100
  SIGNATURE: "SIGNATURE",
727
1101
  DATA: "DATA",
728
1102
  BUTTON: "BUTTON",
1103
+ AUTOCOMPLETE: "AUTOCOMPLETE",
729
1104
  SEARCH: "SEARCH",
730
1105
  ALPHA_PRINT_BUTTON: "ALPHA_PRINT_BUTTON",
731
1106
  HTTP: "HTTP",
@@ -749,7 +1124,7 @@ var FieldType = {
749
1124
  */
750
1125
  _EXPERIMENTAL_CUSTOM: "CUSTOM"
751
1126
  };
752
- var FileFieldType = z5.enum([
1127
+ var FileFieldType = z8.enum([
753
1128
  FieldType.FILE,
754
1129
  FieldType.FILE_WITH_OPTIONS,
755
1130
  FieldType.SIGNATURE
@@ -780,22 +1155,22 @@ var FieldTypesToHideInReview = [
780
1155
  ];
781
1156
 
782
1157
  // ../commons/src/events/FieldValue.ts
783
- var z9 = __toESM(require("zod/v4"));
1158
+ var z12 = __toESM(require("zod/v4"));
784
1159
 
785
1160
  // ../commons/src/documents.ts
786
- var z6 = __toESM(require("zod/v4"));
787
- var FullDocumentUrl = z6.string().brand("FullDocumentUrl").describe(
1161
+ var z9 = __toESM(require("zod/v4"));
1162
+ var FullDocumentUrl = z9.string().brand("FullDocumentUrl").describe(
788
1163
  "A full url with protocol, host, bucket name, starting from the root of the S3 server, https://minio.opencrvs.com/bucket-name/document-id.jpg"
789
1164
  );
790
- var FullDocumentPath = z6.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
1165
+ var FullDocumentPath = z9.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
791
1166
  "A full absolute path with bucket name, starting from the root of the S3 server, /bucket-name/document-id.jpg"
792
1167
  );
793
- var DocumentPath = z6.string().brand("DocumentPath").describe(
1168
+ var DocumentPath = z9.string().brand("DocumentPath").describe(
794
1169
  "A relative path within the S3 bucket, never starting with /. e.g. document-id.jpg or directory/document-id.jpg. The document service constructs the full /bucket/path internally."
795
1170
  );
796
1171
 
797
1172
  // ../commons/src/events/CompositeFieldValue.ts
798
- var z7 = __toESM(require("zod/v4"));
1173
+ var z10 = __toESM(require("zod/v4"));
799
1174
  var GeographicalArea = {
800
1175
  URBAN: "URBAN",
801
1176
  RURAL: "RURAL"
@@ -804,94 +1179,94 @@ var AddressType = {
804
1179
  DOMESTIC: "DOMESTIC",
805
1180
  INTERNATIONAL: "INTERNATIONAL"
806
1181
  };
807
- var FileFieldValue = z7.object({
1182
+ var FileFieldValue = z10.object({
808
1183
  path: DocumentPath,
809
- originalFilename: z7.string(),
810
- type: z7.string()
811
- });
812
- var NameFieldValue = z7.object({
813
- firstname: z7.string(),
814
- surname: z7.string(),
815
- middlename: z7.string().optional()
816
- });
817
- var NameFieldUpdateValue = z7.object({
818
- firstname: z7.string().nullish(),
819
- surname: z7.string().nullish(),
820
- middlename: z7.string().nullish()
821
- }).or(z7.null()).or(z7.undefined());
822
- var StreetLevelDetailsValue = z7.record(z7.string(), z7.string()).optional();
823
- var StreetLevelDetailsUpdateValue = z7.record(z7.string(), z7.string().nullable()).nullish();
824
- var BaseAddressFieldValue = z7.object({
825
- country: z7.string(),
1184
+ originalFilename: z10.string(),
1185
+ type: z10.string()
1186
+ });
1187
+ var NameFieldValue = z10.object({
1188
+ firstname: z10.string(),
1189
+ surname: z10.string(),
1190
+ middlename: z10.string().optional()
1191
+ });
1192
+ var NameFieldUpdateValue = z10.object({
1193
+ firstname: z10.string().nullish(),
1194
+ surname: z10.string().nullish(),
1195
+ middlename: z10.string().nullish()
1196
+ }).or(z10.null()).or(z10.undefined());
1197
+ var StreetLevelDetailsValue = z10.record(z10.string(), z10.string()).optional();
1198
+ var StreetLevelDetailsUpdateValue = z10.record(z10.string(), z10.string().nullable()).nullish();
1199
+ var BaseAddressFieldValue = z10.object({
1200
+ country: z10.string(),
826
1201
  streetLevelDetails: StreetLevelDetailsValue
827
1202
  });
828
- var BaseAddressFieldUpdateValue = z7.object({
829
- country: z7.string().nullish(),
1203
+ var BaseAddressFieldUpdateValue = z10.object({
1204
+ country: z10.string().nullish(),
830
1205
  streetLevelDetails: StreetLevelDetailsUpdateValue
831
1206
  });
832
1207
  var DomesticAddressFieldValue = BaseAddressFieldValue.extend({
833
- addressType: z7.literal(AddressType.DOMESTIC),
834
- administrativeArea: z7.string().uuid()
1208
+ addressType: z10.literal(AddressType.DOMESTIC),
1209
+ administrativeArea: z10.string().uuid()
835
1210
  });
836
1211
  var InternationalAddressFieldValue = BaseAddressFieldValue.extend({
837
- addressType: z7.literal(AddressType.INTERNATIONAL)
1212
+ addressType: z10.literal(AddressType.INTERNATIONAL)
838
1213
  });
839
- var AddressFieldValue = z7.discriminatedUnion("addressType", [
1214
+ var AddressFieldValue = z10.discriminatedUnion("addressType", [
840
1215
  DomesticAddressFieldValue,
841
1216
  InternationalAddressFieldValue
842
1217
  ]);
843
1218
  var DomesticAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend({
844
- addressType: z7.literal(AddressType.DOMESTIC),
845
- administrativeArea: z7.string().uuid().nullish()
1219
+ addressType: z10.literal(AddressType.DOMESTIC),
1220
+ administrativeArea: z10.string().uuid().nullish()
846
1221
  /* Leaf level admin structure */
847
1222
  });
848
1223
  var InternationalAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend(
849
1224
  {
850
- addressType: z7.literal(AddressType.INTERNATIONAL)
1225
+ addressType: z10.literal(AddressType.INTERNATIONAL)
851
1226
  }
852
1227
  );
853
- var AddressFieldUpdateValue = z7.discriminatedUnion("addressType", [
1228
+ var AddressFieldUpdateValue = z10.discriminatedUnion("addressType", [
854
1229
  DomesticAddressUpdateFieldValue,
855
1230
  InternationalAddressUpdateFieldValue
856
1231
  ]).nullish();
857
- var FileFieldValueWithOption = z7.object({
1232
+ var FileFieldValueWithOption = z10.object({
858
1233
  path: DocumentPath,
859
- originalFilename: z7.string(),
860
- type: z7.string(),
861
- option: z7.string()
862
- });
863
- var FileFieldWithOptionValue = z7.array(FileFieldValueWithOption);
864
- var HttpFieldValue = z7.object({
865
- loading: z7.boolean(),
866
- error: z7.object({ statusCode: z7.number(), message: z7.string() }).nullish(),
867
- data: z7.any()
868
- });
869
- var HttpFieldUpdateValue = z7.object({
870
- loading: z7.boolean().nullish(),
871
- error: z7.object({ statusCode: z7.number(), message: z7.string() }).nullish(),
872
- data: z7.any().nullish()
873
- }).or(z7.null()).or(z7.undefined());
874
- var QueryParamReaderFieldValue = z7.object({
875
- data: z7.record(z7.string(), z7.string()),
876
- updatedAt: z7.iso.datetime()
1234
+ originalFilename: z10.string(),
1235
+ type: z10.string(),
1236
+ option: z10.string()
1237
+ });
1238
+ var FileFieldWithOptionValue = z10.array(FileFieldValueWithOption);
1239
+ var HttpFieldValue = z10.object({
1240
+ loading: z10.boolean(),
1241
+ error: z10.object({ statusCode: z10.number(), message: z10.string() }).nullish(),
1242
+ data: z10.any()
1243
+ });
1244
+ var HttpFieldUpdateValue = z10.object({
1245
+ loading: z10.boolean().nullish(),
1246
+ error: z10.object({ statusCode: z10.number(), message: z10.string() }).nullish(),
1247
+ data: z10.any().nullish()
1248
+ }).or(z10.null()).or(z10.undefined());
1249
+ var QueryParamReaderFieldValue = z10.object({
1250
+ data: z10.record(z10.string(), z10.string()),
1251
+ updatedAt: z10.iso.datetime()
877
1252
  }).nullish();
878
- var QueryParamReaderFieldUpdateValue = z7.object({
879
- data: z7.record(z7.string(), z7.string())
1253
+ var QueryParamReaderFieldUpdateValue = z10.object({
1254
+ data: z10.record(z10.string(), z10.string())
880
1255
  });
881
- var ReadDataValue = z7.object({
882
- data: z7.any()
1256
+ var ReadDataValue = z10.object({
1257
+ data: z10.any()
883
1258
  });
884
1259
  var QrReaderFieldValue = ReadDataValue;
885
1260
  var IdReaderFieldValue = ReadDataValue;
886
- var NumberWithUnitFieldValue = z7.object({
887
- numericValue: z7.number(),
888
- unit: z7.string()
1261
+ var NumberWithUnitFieldValue = z10.object({
1262
+ numericValue: z10.number(),
1263
+ unit: z10.string()
889
1264
  });
890
- var NumberWithUnitFieldUpdateValue = z7.object({
891
- numericValue: z7.number().optional(),
892
- unit: z7.string().optional()
1265
+ var NumberWithUnitFieldUpdateValue = z10.object({
1266
+ numericValue: z10.number().optional(),
1267
+ unit: z10.string().optional()
893
1268
  });
894
- var CustomFieldValue = z7.unknown().brand("CustomFieldValue");
1269
+ var CustomFieldValue = z10.unknown().brand("CustomFieldValue");
895
1270
 
896
1271
  // ../commons/src/events/PlainDate.ts
897
1272
  var import_zod = require("zod");
@@ -902,40 +1277,45 @@ function plainDateToLocalDate(date) {
902
1277
  }
903
1278
 
904
1279
  // ../commons/src/events/FieldValue.ts
905
- var TextValue = z9.string();
906
- var HiddenFieldValue = z9.string();
1280
+ var TextValue = z12.string();
1281
+ var HiddenFieldValue = z12.string();
907
1282
  var NonEmptyTextValue = TextValue.min(1);
908
- var DateValue = z9.iso.date().describe("Date in the format YYYY-MM-DD");
909
- var AgeValue = z9.object({
910
- age: z9.number(),
911
- asOfDateRef: z9.string()
1283
+ var DateValue = z12.iso.date().describe("Date in the format YYYY-MM-DD");
1284
+ var AgeValue = z12.object({
1285
+ age: z12.number(),
1286
+ asOfDateRef: z12.string()
912
1287
  });
913
1288
  var AgeUpdateValue = AgeValue.optional().nullable();
914
- var TimeValue = z9.string().regex(/^([01][0-9]|2[0-3]):[0-5][0-9]$/);
915
- var DatetimeValue = z9.iso.datetime();
916
- var SelectDateRangeValue = z9.enum([
1289
+ var AutocompleteValue = z12.object({
1290
+ label: z12.string(),
1291
+ value: z12.string()
1292
+ });
1293
+ var AutocompleteUpdateValue = AutocompleteValue.optional().nullable();
1294
+ var TimeValue = z12.string().regex(/^([01][0-9]|2[0-3]):[0-5][0-9]$/);
1295
+ var DatetimeValue = z12.iso.datetime();
1296
+ var SelectDateRangeValue = z12.enum([
917
1297
  "last7Days",
918
1298
  "last30Days",
919
1299
  "last90Days",
920
1300
  "last365Days"
921
1301
  ]);
922
- var DateRangeFieldValue = z9.object({
1302
+ var DateRangeFieldValue = z12.object({
923
1303
  start: PlainDate,
924
1304
  end: PlainDate
925
1305
  }).or(PlainDate).describe(
926
1306
  "Date range with start and end dates in the format YYYY-MM-DD. Inclusive start, exclusive end."
927
1307
  );
928
- var EmailValue = z9.email();
929
- var CheckboxFieldValue = z9.boolean();
930
- var NumberFieldValue = z9.number();
931
- var ButtonFieldValue = z9.number();
932
- var VerificationStatusValue = z9.enum([
1308
+ var EmailValue = z12.email();
1309
+ var CheckboxFieldValue = z12.boolean();
1310
+ var NumberFieldValue = z12.number();
1311
+ var ButtonFieldValue = z12.number();
1312
+ var VerificationStatusValue = z12.enum([
933
1313
  "verified",
934
1314
  "authenticated",
935
1315
  "failed",
936
1316
  "pending"
937
1317
  ]);
938
- var LeafFieldValues = z9.union([
1318
+ var LeafFieldValues = z12.union([
939
1319
  AddressFieldValue,
940
1320
  TextValue,
941
1321
  PlainDate,
@@ -957,13 +1337,15 @@ var LeafFieldValues = z9.union([
957
1337
  IdReaderFieldValue,
958
1338
  NumberWithUnitFieldValue,
959
1339
  NumberWithUnitFieldUpdateValue,
960
- CustomFieldValue
1340
+ CustomFieldValue,
1341
+ AutocompleteValue,
1342
+ AutocompleteUpdateValue
961
1343
  ]);
962
- var FieldGroupValue = z9.record(z9.string(), LeafFieldValues);
963
- var DataFieldValue = z9.object({
964
- data: z9.record(z9.string(), LeafFieldValues)
1344
+ var FieldGroupValue = z12.record(z12.string(), LeafFieldValues);
1345
+ var DataFieldValue = z12.object({
1346
+ data: z12.record(z12.string(), LeafFieldValues)
965
1347
  }).nullish();
966
- var FieldValue = z9.union([
1348
+ var FieldValue = z12.union([
967
1349
  LeafFieldValues,
968
1350
  DataFieldValue,
969
1351
  FieldGroupValue
@@ -983,657 +1365,114 @@ var PRIORITY_ORDER = [
983
1365
  "FileFieldValue",
984
1366
  "FileFieldWithOptionValue",
985
1367
  "DataFieldValue",
986
- "GroupFieldValue"
987
- ];
988
- function schemaPriority(schema) {
989
- const name = schema.description;
990
- if (!name) {
991
- return 9999;
992
- }
993
- const idx = PRIORITY_ORDER.indexOf(name);
994
- return idx === -1 ? 9999 : idx;
995
- }
996
- function safeUnion(schemas) {
997
- return z9.any().superRefine((val, ctx) => {
998
- const successful = schemas.filter((s) => s.safeParse(val).success);
999
- if (successful.length === 1) {
1000
- return;
1001
- }
1002
- if (successful.length === 0) {
1003
- ctx.addIssue({
1004
- code: "invalid_type",
1005
- expected: "custom",
1006
- message: "Value does not match any schema"
1007
- });
1008
- return;
1009
- }
1010
- successful.sort((a, b) => schemaPriority(a) - schemaPriority(b));
1011
- const best = successful[0];
1012
- if (!best.safeParse(val).success) {
1013
- ctx.addIssue({
1014
- expected: "custom",
1015
- code: "invalid_type",
1016
- message: "Value did not match the best schema"
1017
- });
1018
- }
1019
- }).meta({
1020
- description: "Value that matches exactly one of the possible schema types (TextValue, DateValue, DateRangeFieldValue). The best matching schema is chosen by priority."
1021
- });
1022
- }
1023
- var FieldUpdateValue = safeUnion([
1024
- TextValue.describe("TextValue"),
1025
- PlainDate.describe("PlainDate"),
1026
- TimeValue.describe("TimeValue"),
1027
- AgeUpdateValue.describe("AgeUpdateValue"),
1028
- AddressFieldUpdateValue.describe("AddressFieldUpdateValue"),
1029
- DateRangeFieldValue.describe("DateRangeFieldValue"),
1030
- SelectDateRangeValue.describe("SelectDateRangeValue"),
1031
- CheckboxFieldValue.describe("CheckboxFieldValue"),
1032
- NumberFieldValue.describe("NumberFieldValue"),
1033
- NumberWithUnitFieldUpdateValue.describe("NumberWithUnitFieldUpdateValue"),
1034
- FileFieldValue.describe("FileFieldValue"),
1035
- FileFieldWithOptionValue.describe("FileFieldWithOptionValue"),
1036
- DataFieldValue.describe("DataFieldValue"),
1037
- FieldGroupValue.describe("GroupFieldValue"),
1038
- NameFieldUpdateValue.describe("NameFieldUpdateValue"),
1039
- HttpFieldUpdateValue.describe("HttpFieldUpdateValue"),
1040
- QueryParamReaderFieldUpdateValue.describe("QueryParamReaderFieldUpdateValue"),
1041
- CustomFieldValue.describe("CustomFieldValue"),
1042
- HiddenFieldValue.describe("HiddenFieldValue")
1043
- ]);
1044
-
1045
- // ../commons/src/uuid.ts
1046
- var import_uuid = require("uuid");
1047
- var z10 = __toESM(require("zod/v4"));
1048
- var UUID = z10.uuid().brand("UUID");
1049
- function getUUID() {
1050
- return (0, import_uuid.v4)();
1051
- }
1052
-
1053
- // ../commons/src/events/serializers/user/serializer.ts
1054
- var z11 = __toESM(require("zod/v4"));
1055
- var SerializedUserField = z11.object({
1056
- $userField: z11.enum([
1057
- "id",
1058
- "name",
1059
- "role",
1060
- "fullHonorificName",
1061
- "device",
1062
- "firstname",
1063
- "middlename",
1064
- "surname",
1065
- "signature",
1066
- "avatar",
1067
- "primaryOfficeId",
1068
- "administrativeAreaId"
1069
- ]),
1070
- $location: z11.string().optional()
1071
- });
1072
- function userSerializer(userField) {
1073
- return {
1074
- $userField: userField,
1075
- locationLevel(adminLevelId) {
1076
- return {
1077
- $userField: this.$userField,
1078
- $location: adminLevelId
1079
- };
1080
- },
1081
- toJSON() {
1082
- return {
1083
- $userField: userField
1084
- };
1085
- }
1086
- };
1087
- }
1088
-
1089
- // ../commons/src/events/EventIndex.ts
1090
- var import_v4 = require("zod/v4");
1091
-
1092
- // ../commons/src/events/EventMetadata.ts
1093
- var z17 = __toESM(require("zod/v4"));
1094
-
1095
- // ../commons/src/events/ActionDocument.ts
1096
- var z15 = __toESM(require("zod/v4"));
1097
-
1098
- // ../commons/src/authentication.ts
1099
- var import_jwt_decode = __toESM(require("jwt-decode"));
1100
- var z14 = __toESM(require("zod/v4"));
1101
-
1102
- // ../commons/src/scopes.ts
1103
- var z13 = __toESM(require("zod/v4"));
1104
- var qs = __toESM(require("qs"));
1105
-
1106
- // ../commons/src/scopes.deprecated.do-not-use.ts
1107
- var z12 = __toESM(require("zod/v4"));
1108
- var rawConfigurableScopeRegex = /^([a-zA-Z][a-zA-Z0-9.-]*(?:\.[a-zA-Z0-9.-]+)*)\[((?:\w+=[\w.-]+(?:\|[\w.-]+)*)(?:,[\w]+=[\w.-]+(?:\|[\w.-]+)*)*)\]$/;
1109
- var rawConfigurableScope = z12.string().regex(rawConfigurableScopeRegex);
1110
- var SearchScope = z12.object({
1111
- type: z12.literal("search"),
1112
- options: z12.object({
1113
- event: z12.array(z12.string()).length(1),
1114
- access: z12.array(z12.enum(["my-jurisdiction", "all"])).length(1)
1115
- })
1116
- });
1117
- var CreateUserScope = z12.object({
1118
- type: z12.literal("user.create"),
1119
- options: z12.object({
1120
- role: z12.array(z12.string())
1121
- })
1122
- });
1123
- var EditUserScope = z12.object({
1124
- type: z12.literal("user.edit"),
1125
- options: z12.object({
1126
- role: z12.array(z12.string())
1127
- })
1128
- });
1129
- var WorkqueueScope = z12.object({
1130
- type: z12.literal("workqueue"),
1131
- options: z12.object({
1132
- id: z12.array(z12.string())
1133
- })
1134
- });
1135
- var PrintCertifiedCopiesScope = z12.object({
1136
- type: z12.literal("record.registered.print-certified-copies"),
1137
- options: z12.object({
1138
- event: z12.array(z12.string()).describe("Event type, e.g. birth, death"),
1139
- templates: z12.array(z12.string()).optional().describe(
1140
- "Template IDs for certified copies. If not provided, all templates will be used."
1141
- )
1142
- })
1143
- });
1144
- var LegacyRecordScope = z12.object({
1145
- type: z12.enum([
1146
- "record.create",
1147
- "record.read",
1148
- "record.declare",
1149
- "record.notify",
1150
- "record.declared.edit",
1151
- "record.declared.validate",
1152
- "record.declared.reject",
1153
- "record.declared.archive",
1154
- "record.declared.review-duplicates",
1155
- "record.register",
1156
- "record.registered.request-correction",
1157
- "record.registered.correct",
1158
- "record.unassign-others"
1159
- ]),
1160
- options: z12.object({
1161
- event: z12.array(z12.string()).describe("Event type, e.g. birth, death")
1162
- })
1163
- }).describe(
1164
- "Scopes used to check user's permission to perform actions on a record."
1165
- );
1166
- var ConfigurableRawScopes = z12.discriminatedUnion("type", [
1167
- SearchScope,
1168
- LegacyRecordScope,
1169
- PrintCertifiedCopiesScope,
1170
- CreateUserScope,
1171
- EditUserScope,
1172
- WorkqueueScope
1173
- ]);
1174
-
1175
- // ../commons/src/scopes.ts
1176
- var SCOPES = {
1177
- // TODO v1.8 legacy scopes
1178
- BYPASSRATELIMIT: "bypassratelimit",
1179
- REGISTER: "register",
1180
- DEMO: "demo",
1181
- CONFIG: "config",
1182
- // systems / integrations
1183
- WEBHOOK: "webhook",
1184
- NATIONALID: "nationalId",
1185
- NOTIFICATION_API: "notification-api",
1186
- RECORDSEARCH: "recordsearch",
1187
- RECORD_IMPORT: "record.import",
1188
- RECORD_EXPORT: "record.export",
1189
- RECORD_REINDEX: "record.reindex",
1190
- INTEGRATION_CREATE: "integration.create",
1191
- // declare
1192
- RECORD_DECLARE_BIRTH: "record.declare-birth",
1193
- RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
1194
- RECORD_DECLARE_DEATH: "record.declare-death",
1195
- RECORD_DECLARE_DEATH_MY_JURISDICTION: "record.declare-death:my-jurisdiction",
1196
- RECORD_DECLARE_MARRIAGE: "record.declare-marriage",
1197
- RECORD_DECLARE_MARRIAGE_MY_JURISDICTION: "record.declare-marriage:my-jurisdiction",
1198
- RECORD_SUBMIT_INCOMPLETE: "record.declaration-submit-incomplete",
1199
- // @todo: should this record be removed from events v2?
1200
- RECORD_SUBMIT_FOR_REVIEW: "record.declaration-submit-for-review",
1201
- RECORD_UNASSIGN_OTHERS: "record.unassign-others",
1202
- // validate
1203
- RECORD_SUBMIT_FOR_APPROVAL: "record.declaration-submit-for-approval",
1204
- RECORD_SUBMIT_FOR_UPDATES: "record.declaration-submit-for-updates",
1205
- RECORD_DECLARATION_EDIT: "record.declaration-edit",
1206
- RECORD_REVIEW_DUPLICATES: "record.review-duplicates",
1207
- RECORD_DECLARATION_ARCHIVE: "record.declaration-archive",
1208
- RECORD_DECLARATION_REINSTATE: "record.declaration-reinstate",
1209
- // register
1210
- RECORD_REGISTER: "record.register",
1211
- /**
1212
- * This scope is used to **print and **issue certified copies of a record
1213
- * after it has been registered. Previously Registrars had this permission.
1214
- */
1215
- RECORD_PRINT_ISSUE_CERTIFIED_COPIES: "record.registration-print&issue-certified-copies",
1216
- // correct
1217
- RECORD_REGISTRATION_REQUEST_CORRECTION: "record.registration-request-correction",
1218
- RECORD_REGISTRATION_CORRECT: "record.registration-correct",
1219
- RECORD_CONFIRM_REGISTRATION: "record.confirm-registration",
1220
- RECORD_REJECT_REGISTRATION: "record.reject-registration",
1221
- // search
1222
- SEARCH_BIRTH_MY_JURISDICTION: "search.birth:my-jurisdiction",
1223
- SEARCH_BIRTH: "search.birth",
1224
- SEARCH_DEATH_MY_JURISDICTION: "search.death:my-jurisdiction",
1225
- SEARCH_DEATH: "search.death",
1226
- SEARCH_MARRIAGE_MY_JURISDICTION: "search.marriage:my-jurisdiction",
1227
- SEARCH_MARRIAGE: "search.marriage",
1228
- // audit v1.8
1229
- RECORD_READ: "record.read",
1230
- // profile
1231
- PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature",
1232
- // performance
1233
- PERFORMANCE_READ: "performance.read",
1234
- PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards",
1235
- PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export",
1236
- // organisation
1237
- ORGANISATION_READ_LOCATIONS: "organisation.read-locations:all",
1238
- ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office",
1239
- ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction",
1240
- // user
1241
- USER_READ: "user.read:all",
1242
- USER_READ_MY_OFFICE: "user.read:my-office",
1243
- USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction",
1244
- USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit",
1245
- //v1.8
1246
- USER_CREATE: "user.create:all",
1247
- USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction",
1248
- USER_UPDATE: "user.update:all",
1249
- USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction",
1250
- // config
1251
- CONFIG_UPDATE_ALL: "config.update:all",
1252
- // data seeding
1253
- USER_DATA_SEEDING: "user.data-seeding",
1254
- // attachment
1255
- ATTACHMENT_UPLOAD: "attachment.upload"
1256
- };
1257
- var LegacyScopes = z13.union([
1258
- z13.literal(SCOPES.BYPASSRATELIMIT),
1259
- z13.literal(SCOPES.REGISTER),
1260
- z13.literal(SCOPES.DEMO),
1261
- z13.literal(SCOPES.CONFIG)
1262
- ]);
1263
- var IntegrationScopes = z13.union([
1264
- z13.literal(SCOPES.WEBHOOK),
1265
- z13.literal(SCOPES.NATIONALID),
1266
- z13.literal(SCOPES.NOTIFICATION_API),
1267
- z13.literal(SCOPES.RECORDSEARCH),
1268
- z13.literal(SCOPES.INTEGRATION_CREATE)
1269
- ]);
1270
- var InternalOperationsScopes = z13.union([
1271
- z13.literal(SCOPES.RECORD_REINDEX),
1272
- z13.literal(SCOPES.RECORD_IMPORT)
1273
- ]);
1274
- var PerformanceScopes = z13.union([
1275
- z13.literal(SCOPES.PERFORMANCE_READ),
1276
- z13.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
1277
- z13.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS)
1278
- ]);
1279
- var OrganisationScopes = z13.union([
1280
- z13.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
1281
- z13.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
1282
- z13.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION)
1283
- ]);
1284
- var UserScopes = z13.union([
1285
- z13.literal(SCOPES.USER_READ),
1286
- z13.literal(SCOPES.USER_READ_MY_OFFICE),
1287
- z13.literal(SCOPES.USER_READ_MY_JURISDICTION),
1288
- z13.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
1289
- z13.literal(SCOPES.USER_CREATE),
1290
- z13.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
1291
- z13.literal(SCOPES.USER_UPDATE),
1292
- z13.literal(SCOPES.USER_UPDATE_MY_JURISDICTION)
1293
- ]);
1294
- var ConfigScope = z13.literal(SCOPES.CONFIG_UPDATE_ALL);
1295
- var DataSeedingScope = z13.literal(SCOPES.USER_DATA_SEEDING);
1296
- var AttachmentScope = z13.literal(SCOPES.ATTACHMENT_UPLOAD);
1297
- var LiteralScopes = z13.union([
1298
- LegacyScopes,
1299
- IntegrationScopes,
1300
- z13.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE),
1301
- z13.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
1302
- PerformanceScopes,
1303
- OrganisationScopes,
1304
- UserScopes,
1305
- ConfigScope,
1306
- DataSeedingScope,
1307
- InternalOperationsScopes,
1308
- AttachmentScope
1309
- ]);
1310
- var JurisdictionFilter = z13.enum(["administrativeArea", "location", "all"]).describe(
1311
- "Filters based on user jurisdiction relative to their office location in hierarchy."
1312
- );
1313
- var UserFilter = z13.enum(["user"]).describe("Filters based on the user. Limits to self.");
1314
- var RecordScopeTypeV2 = z13.enum([
1315
- "record.search",
1316
- "record.create",
1317
- "record.read",
1318
- "record.declare",
1319
- "record.notify",
1320
- "record.edit",
1321
- "record.reject",
1322
- "record.archive",
1323
- "record.review-duplicates",
1324
- "record.register",
1325
- "record.print-certified-copies",
1326
- "record.request-correction",
1327
- "record.correct",
1328
- "record.unassign-others",
1329
- "record.custom-action"
1330
- ]);
1331
- var scopeByEvent = z13.preprocess(
1332
- (val) => val === void 0 ? void 0 : [val].flat(),
1333
- z13.array(z13.string()).optional()
1334
- ).describe("Event type, e.g. birth, death");
1335
- var scopeOptionsPlaceEvent = z13.object({
1336
- event: scopeByEvent,
1337
- placeOfEvent: JurisdictionFilter.optional()
1338
- }).describe("Options applicable to all record scopes.");
1339
- var scopeOptionsDeclared = scopeOptionsPlaceEvent.extend({
1340
- declaredIn: JurisdictionFilter.optional(),
1341
- declaredBy: UserFilter.optional()
1342
- }).describe("Options applicable to actions that may take place after DECLARE");
1343
- var ScopeOptionsFull = scopeOptionsDeclared.extend({
1344
- registeredIn: JurisdictionFilter.optional(),
1345
- registeredBy: UserFilter.optional()
1346
- }).describe(
1347
- "Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
1348
- );
1349
- var CustomActionScopeOptions = ScopeOptionsFull.extend({
1350
- customActionTypes: z13.preprocess(
1351
- (val) => val === void 0 ? void 0 : [val].flat(),
1352
- z13.array(z13.string()).optional()
1353
- ).describe("Allowed custom action types")
1354
- });
1355
- var ScopeOptionKey = ScopeOptionsFull.keyof();
1356
- var ResolvedScopeOptionsPlaceEvent = z13.object({
1357
- event: scopeByEvent,
1358
- placeOfEvent: UUID.nullish()
1359
- }).describe(
1360
- "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
1361
- );
1362
- var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
1363
- declaredIn: UUID.nullish(),
1364
- declaredBy: z13.string().optional()
1365
- }).describe(
1366
- "Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
1367
- );
1368
- var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
1369
- registeredIn: UUID.nullish(),
1370
- registeredBy: z13.string().optional()
1371
- }).describe(
1372
- "Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
1373
- );
1374
- var ScopesWithPlaceEventOptions = RecordScopeTypeV2.extract([
1375
- "record.create",
1376
- "record.declare",
1377
- "record.notify"
1378
- ]);
1379
- var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
1380
- "record.edit",
1381
- "record.reject",
1382
- "record.archive",
1383
- "record.review-duplicates",
1384
- "record.register"
1385
- ]);
1386
- var ScopesWithFullOptions = RecordScopeTypeV2.extract([
1387
- "record.search",
1388
- "record.read",
1389
- "record.request-correction",
1390
- "record.correct",
1391
- "record.unassign-others"
1392
- ]);
1393
- var ScopeOptionsPrintCertifiedCopies = ScopeOptionsFull.extend({
1394
- templates: z13.preprocess(
1395
- (val) => val === void 0 ? void 0 : [val].flat(),
1396
- z13.array(z13.string()).optional()
1397
- ).describe(
1398
- "Template IDs for certified copies. Controls which certificate templates are returned to the client via the config service. Certificate printing is a client-side operation \u2014 this option is not validated when the printCertificate action is submitted."
1399
- )
1400
- });
1401
- var RecordScopeV2 = z13.discriminatedUnion("type", [
1402
- z13.object({
1403
- type: ScopesWithPlaceEventOptions,
1404
- options: scopeOptionsPlaceEvent.optional()
1405
- }),
1406
- z13.object({
1407
- type: ScopesWithDeclaredOptions,
1408
- options: scopeOptionsDeclared.optional()
1409
- }),
1410
- z13.object({
1411
- type: ScopesWithFullOptions,
1412
- options: ScopeOptionsFull.optional()
1413
- }),
1414
- z13.object({
1415
- type: z13.literal("record.custom-action"),
1416
- options: CustomActionScopeOptions.optional()
1417
- }),
1418
- z13.object({
1419
- type: z13.literal("record.print-certified-copies"),
1420
- options: ScopeOptionsPrintCertifiedCopies.optional()
1421
- })
1422
- ]).describe(
1423
- "Scopes used to check user's permission to perform actions on a record."
1424
- );
1425
- function scopeUsesDeclaredOptions(scope) {
1426
- return !ScopesWithPlaceEventOptions.options.some((opt) => opt === scope.type);
1427
- }
1428
- function scopeUsesFullOptions(scope) {
1429
- return ScopesWithFullOptions.options.some((opt) => opt === scope.type);
1430
- }
1431
- function scopeUsesPrintCertifiedCopiesOptions(scope) {
1432
- return scope.type === "record.print-certified-copies";
1433
- }
1434
- function isCustomActionScope(scope) {
1435
- return scope.type === "record.custom-action";
1436
- }
1437
- var ResolvedRecordScopeV2 = z13.discriminatedUnion("type", [
1438
- z13.object({
1439
- type: ScopesWithPlaceEventOptions,
1440
- options: ResolvedScopeOptionsPlaceEvent.optional()
1441
- }),
1442
- z13.object({
1443
- type: ScopesWithDeclaredOptions,
1444
- options: ResolvedScopeOptionsDeclared.optional()
1445
- }),
1446
- z13.object({
1447
- type: ScopesWithFullOptions,
1448
- options: ResolvedScopeOptionsFull.optional()
1449
- }),
1450
- z13.object({
1451
- type: z13.literal("record.print-certified-copies"),
1452
- options: ResolvedScopeOptionsFull.extend({
1453
- templates: z13.array(z13.string()).optional()
1454
- }).optional()
1455
- })
1456
- ]).describe("Resolved scope with location/user IDs instead of filters.");
1457
- var flattenScope = (scope) => ({
1458
- type: scope.type,
1459
- ...scope.options
1460
- });
1461
- var unflattenScope = (input) => {
1462
- const { type, ...options } = input;
1463
- return { type, options };
1464
- };
1465
- var encodeScope = (scope) => {
1466
- const flattened = flattenScope(scope);
1467
- return qs.stringify(flattened, {
1468
- arrayFormat: "comma",
1469
- allowDots: true,
1470
- addQueryPrefix: false,
1471
- encode: false
1472
- });
1473
- };
1474
- var decodeScope = (query) => {
1475
- const scope = qs.parse(query, {
1476
- ignoreQueryPrefix: true,
1477
- comma: true,
1478
- allowDots: true
1368
+ "GroupFieldValue"
1369
+ ];
1370
+ function schemaPriority(schema) {
1371
+ const name = schema.description;
1372
+ if (!name) {
1373
+ return 9999;
1374
+ }
1375
+ const idx = PRIORITY_ORDER.indexOf(name);
1376
+ return idx === -1 ? 9999 : idx;
1377
+ }
1378
+ function safeUnion(schemas) {
1379
+ return z12.any().superRefine((val, ctx) => {
1380
+ const successful = schemas.filter((s) => s.safeParse(val).success);
1381
+ if (successful.length === 1) {
1382
+ return;
1383
+ }
1384
+ if (successful.length === 0) {
1385
+ ctx.addIssue({
1386
+ code: "invalid_type",
1387
+ expected: "custom",
1388
+ message: "Value does not match any schema"
1389
+ });
1390
+ return;
1391
+ }
1392
+ successful.sort((a, b) => schemaPriority(a) - schemaPriority(b));
1393
+ const best = successful[0];
1394
+ if (!best.safeParse(val).success) {
1395
+ ctx.addIssue({
1396
+ expected: "custom",
1397
+ code: "invalid_type",
1398
+ message: "Value did not match the best schema"
1399
+ });
1400
+ }
1401
+ }).meta({
1402
+ description: "Value that matches exactly one of the possible schema types (TextValue, DateValue, DateRangeFieldValue). The best matching schema is chosen by priority."
1479
1403
  });
1480
- const unflattenedScope = unflattenScope(scope);
1481
- return RecordScopeV2.safeParse(unflattenedScope)?.data;
1482
- };
1483
- var DEFAULT_SCOPE_OPTIONS = {
1484
- placeOfEvent: JurisdictionFilter.enum.all
1485
- };
1486
- function getAcceptedScopesByType({
1487
- acceptedScopes,
1488
- scopes
1489
- }) {
1490
- return scopes.map((scope) => {
1491
- const parsedScope = decodeScope(scope);
1492
- return parsedScope && acceptedScopes.some(
1493
- (acceptedScope) => acceptedScope === parsedScope.type
1494
- ) ? parsedScope : null;
1495
- }).filter((scope) => scope !== null);
1496
1404
  }
1405
+ var FieldUpdateValue = safeUnion([
1406
+ TextValue.describe("TextValue"),
1407
+ PlainDate.describe("PlainDate"),
1408
+ TimeValue.describe("TimeValue"),
1409
+ AgeUpdateValue.describe("AgeUpdateValue"),
1410
+ AddressFieldUpdateValue.describe("AddressFieldUpdateValue"),
1411
+ DateRangeFieldValue.describe("DateRangeFieldValue"),
1412
+ SelectDateRangeValue.describe("SelectDateRangeValue"),
1413
+ CheckboxFieldValue.describe("CheckboxFieldValue"),
1414
+ NumberFieldValue.describe("NumberFieldValue"),
1415
+ NumberWithUnitFieldUpdateValue.describe("NumberWithUnitFieldUpdateValue"),
1416
+ FileFieldValue.describe("FileFieldValue"),
1417
+ FileFieldWithOptionValue.describe("FileFieldWithOptionValue"),
1418
+ DataFieldValue.describe("DataFieldValue"),
1419
+ FieldGroupValue.describe("GroupFieldValue"),
1420
+ NameFieldUpdateValue.describe("NameFieldUpdateValue"),
1421
+ HttpFieldUpdateValue.describe("HttpFieldUpdateValue"),
1422
+ QueryParamReaderFieldUpdateValue.describe("QueryParamReaderFieldUpdateValue"),
1423
+ CustomFieldValue.describe("CustomFieldValue"),
1424
+ HiddenFieldValue.describe("HiddenFieldValue"),
1425
+ AutocompleteUpdateValue.describe("AutocompleteUpdateValue")
1426
+ ]);
1497
1427
 
1498
- // ../commons/src/authentication.ts
1499
- var DEFAULT_ROLES_DEFINITION = [
1500
- {
1501
- id: "FIELD_AGENT",
1502
- label: {
1503
- defaultMessage: "Field Agent",
1504
- description: "Name for user role Field Agent",
1505
- id: "userRole.fieldAgent"
1506
- },
1507
- scopes: [
1508
- encodeScope({
1509
- type: "record.create",
1510
- options: {
1511
- event: ["birth", "death", "tennis-club-membership"]
1512
- }
1513
- }),
1514
- encodeScope({
1515
- type: "record.declare",
1516
- options: {
1517
- event: ["birth", "death", "tennis-club-membership"]
1518
- }
1519
- })
1520
- ]
1521
- },
1522
- {
1523
- id: "REGISTRATION_AGENT",
1524
- label: {
1525
- defaultMessage: "Registration Agent",
1526
- description: "Name for user role Registration Agent",
1527
- id: "userRole.registrationAgent"
1528
- },
1529
- scopes: [
1530
- encodeScope({
1531
- type: "record.create",
1532
- options: {
1533
- event: ["birth", "death", "tennis-club-membership"]
1534
- }
1535
- }),
1536
- encodeScope({
1537
- type: "record.declare",
1538
- options: {
1539
- event: ["birth", "death", "tennis-club-membership"]
1540
- }
1541
- }),
1542
- SCOPES.PERFORMANCE_READ,
1543
- SCOPES.PERFORMANCE_READ_DASHBOARDS,
1544
- SCOPES.ORGANISATION_READ_LOCATIONS,
1545
- SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE
1546
- ]
1547
- },
1548
- {
1549
- id: "LOCAL_REGISTRAR",
1550
- label: {
1551
- defaultMessage: "Local Registrar",
1552
- description: "Name for user role Local Registrar",
1553
- id: "userRole.localRegistrar"
1554
- },
1555
- scopes: [
1556
- encodeScope({
1557
- type: "record.create",
1558
- options: {
1559
- event: ["birth", "death", "tennis-club-membership"]
1560
- }
1561
- }),
1562
- encodeScope({
1563
- type: "record.declare",
1564
- options: {
1565
- event: ["birth", "death", "tennis-club-membership"]
1566
- }
1567
- }),
1568
- encodeScope({
1569
- type: "record.review-duplicates",
1570
- options: {
1571
- event: ["birth", "death", "tennis-club-membership"]
1572
- }
1573
- }),
1574
- SCOPES.PERFORMANCE_READ,
1575
- SCOPES.PERFORMANCE_READ_DASHBOARDS,
1576
- SCOPES.ORGANISATION_READ_LOCATIONS,
1577
- SCOPES.PROFILE_ELECTRONIC_SIGNATURE,
1578
- SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE
1579
- ]
1580
- },
1581
- {
1582
- id: "LOCAL_SYSTEM_ADMIN",
1583
- label: {
1584
- defaultMessage: "Local System Admin",
1585
- description: "Name for user role Local System Admin",
1586
- id: "userRole.localSystemAdmin"
1587
- },
1588
- scopes: [
1589
- SCOPES.USER_READ_MY_OFFICE,
1590
- SCOPES.USER_CREATE_MY_JURISDICTION,
1591
- SCOPES.USER_UPDATE_MY_JURISDICTION,
1592
- SCOPES.ORGANISATION_READ_LOCATIONS,
1593
- SCOPES.PERFORMANCE_READ,
1594
- SCOPES.PERFORMANCE_READ_DASHBOARDS,
1595
- SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS
1596
- ]
1597
- },
1598
- {
1599
- id: "NATIONAL_SYSTEM_ADMIN",
1600
- label: {
1601
- defaultMessage: "National System Admin",
1602
- description: "Name for user role National System Admin",
1603
- id: "userRole.nationalSystemAdmin"
1604
- },
1605
- scopes: [
1606
- SCOPES.USER_CREATE,
1607
- SCOPES.USER_READ,
1608
- SCOPES.USER_UPDATE,
1609
- SCOPES.ORGANISATION_READ_LOCATIONS,
1610
- SCOPES.PERFORMANCE_READ,
1611
- SCOPES.PERFORMANCE_READ_DASHBOARDS,
1612
- SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS
1613
- ]
1614
- },
1615
- {
1616
- id: "PERFORMANCE_MANAGER",
1617
- label: {
1618
- defaultMessage: "Performance Manager",
1619
- description: "Name for user role Performance Manager",
1620
- id: "userRole.performanceManager"
1428
+ // ../commons/src/events/serializers/user/serializer.ts
1429
+ var z13 = __toESM(require("zod/v4"));
1430
+ var SerializedUserField = z13.object({
1431
+ $userField: z13.enum([
1432
+ "id",
1433
+ "name",
1434
+ "role",
1435
+ "fullHonorificName",
1436
+ "device",
1437
+ "firstname",
1438
+ "middlename",
1439
+ "surname",
1440
+ "signature",
1441
+ "avatar",
1442
+ "primaryOfficeId",
1443
+ "administrativeAreaId"
1444
+ ]),
1445
+ $location: z13.string().optional()
1446
+ });
1447
+ function userSerializer(userField) {
1448
+ return {
1449
+ $userField: userField,
1450
+ locationLevel(adminLevelId) {
1451
+ return {
1452
+ $userField: this.$userField,
1453
+ $location: adminLevelId
1454
+ };
1621
1455
  },
1622
- scopes: [
1623
- SCOPES.PERFORMANCE_READ,
1624
- SCOPES.PERFORMANCE_READ_DASHBOARDS,
1625
- SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS
1626
- ]
1627
- }
1628
- ];
1629
- var TokenUserType = z14.enum(["user", "system"]);
1630
- var TokenWithBearer = z14.string().regex(/^Bearer\s/);
1456
+ toJSON() {
1457
+ return {
1458
+ $userField: userField
1459
+ };
1460
+ }
1461
+ };
1462
+ }
1463
+
1464
+ // ../commons/src/events/EventIndex.ts
1465
+ var import_v4 = require("zod/v4");
1466
+
1467
+ // ../commons/src/events/EventMetadata.ts
1468
+ var z16 = __toESM(require("zod/v4"));
1631
1469
 
1632
1470
  // ../commons/src/events/ActionDocument.ts
1633
- var ActionUpdate = z15.record(z15.string(), FieldUpdateValue).describe(
1471
+ var z14 = __toESM(require("zod/v4"));
1472
+ var ActionUpdate = z14.record(z14.string(), FieldUpdateValue).describe(
1634
1473
  "Record of field-level changes made by an action. Supports partial updates and nullable values."
1635
1474
  );
1636
- var EventState = z15.record(z15.string(), FieldValue).describe(
1475
+ var EventState = z14.record(z14.string(), FieldValue).describe(
1637
1476
  "Aggregate representation of event data after all actions have been applied, with all updates consolidated and null values removed."
1638
1477
  );
1639
1478
  var ActionStatus = {
@@ -1641,15 +1480,15 @@ var ActionStatus = {
1641
1480
  Accepted: "Accepted",
1642
1481
  Rejected: "Rejected"
1643
1482
  };
1644
- var ActionBase = z15.object({
1483
+ var ActionBase = z14.object({
1645
1484
  id: UUID.describe("Unique identifier of the action."),
1646
- transactionId: z15.string().describe("Unique identifier of the transaction."),
1485
+ transactionId: z14.string().describe("Unique identifier of the transaction."),
1647
1486
  createdByUserType: TokenUserType.describe(
1648
1487
  "Indicates whether the action was created by a human-user or by a system-user."
1649
1488
  ),
1650
- createdAt: z15.string().datetime().describe("Timestamp indicating when the action was created."),
1651
- createdBy: z15.string().describe("Identifier of the user who created the action."),
1652
- createdByRole: z15.string().optional().describe("Role of the user who created the action."),
1489
+ createdAt: z14.string().datetime().describe("Timestamp indicating when the action was created."),
1490
+ createdBy: z14.string().describe("Identifier of the user who created the action."),
1491
+ createdByRole: z14.string().optional().describe("Role of the user who created the action."),
1653
1492
  createdBySignature: DocumentPath.nullish().describe(
1654
1493
  "Reference to the signature of the user who created the action."
1655
1494
  ),
@@ -1661,7 +1500,7 @@ var ActionBase = z15.object({
1661
1500
  "Declaration data defined by the ActionConfig. Supports partial updates."
1662
1501
  ),
1663
1502
  annotation: ActionUpdate.optional().nullable().describe("Action-specific metadata used to annotate the event."),
1664
- status: z15.enum([
1503
+ status: z14.enum([
1665
1504
  ActionStatus.Requested,
1666
1505
  ActionStatus.Accepted,
1667
1506
  ActionStatus.Rejected
@@ -1673,132 +1512,132 @@ var ActionBase = z15.object({
1673
1512
  )
1674
1513
  });
1675
1514
  var AssignedAction = ActionBase.extend(
1676
- z15.object({
1677
- type: z15.literal(ActionType.ASSIGN),
1678
- assignedTo: z15.string().describe("Identifier of the user to whom the action is assigned.")
1515
+ z14.object({
1516
+ type: z14.literal(ActionType.ASSIGN),
1517
+ assignedTo: z14.string().describe("Identifier of the user to whom the action is assigned.")
1679
1518
  // TODO move into 'content' property
1680
1519
  }).shape
1681
1520
  );
1682
1521
  var UnassignedAction = ActionBase.extend(
1683
- z15.object({
1684
- type: z15.literal(ActionType.UNASSIGN)
1522
+ z14.object({
1523
+ type: z14.literal(ActionType.UNASSIGN)
1685
1524
  }).shape
1686
1525
  );
1687
1526
  var RegisterAction = ActionBase.extend(
1688
- z15.object({
1689
- type: z15.literal(ActionType.REGISTER),
1690
- registrationNumber: z15.string().optional().describe(
1527
+ z14.object({
1528
+ type: z14.literal(ActionType.REGISTER),
1529
+ registrationNumber: z14.string().optional().describe(
1691
1530
  "Registration number of the event. Always present for accepted registrations."
1692
1531
  )
1693
1532
  // TODO move into 'content' property
1694
1533
  }).shape
1695
1534
  );
1696
1535
  var DeclareAction = ActionBase.extend(
1697
- z15.object({
1698
- type: z15.literal(ActionType.DECLARE)
1536
+ z14.object({
1537
+ type: z14.literal(ActionType.DECLARE)
1699
1538
  }).shape
1700
1539
  );
1701
- var ReasonContent = z15.object({
1702
- reason: z15.string().min(1, { error: "Message cannot be empty" }).describe(
1540
+ var ReasonContent = z14.object({
1541
+ reason: z14.string().min(1, { error: "Message cannot be empty" }).describe(
1703
1542
  "Message describing the reason for rejecting or archiving the event."
1704
1543
  )
1705
1544
  });
1706
1545
  var RejectAction = ActionBase.extend(
1707
- z15.object({
1708
- type: z15.literal(ActionType.REJECT),
1546
+ z14.object({
1547
+ type: z14.literal(ActionType.REJECT),
1709
1548
  content: ReasonContent
1710
1549
  }).shape
1711
1550
  );
1712
- var PotentialDuplicate = z15.object({
1551
+ var PotentialDuplicate = z14.object({
1713
1552
  id: UUID,
1714
- trackingId: z15.string()
1553
+ trackingId: z14.string()
1715
1554
  });
1716
1555
  var DuplicateDetectedAction = ActionBase.extend(
1717
- z15.object({
1718
- type: z15.literal(ActionType.DUPLICATE_DETECTED),
1719
- content: z15.object({
1720
- duplicates: z15.array(PotentialDuplicate)
1556
+ z14.object({
1557
+ type: z14.literal(ActionType.DUPLICATE_DETECTED),
1558
+ content: z14.object({
1559
+ duplicates: z14.array(PotentialDuplicate)
1721
1560
  })
1722
1561
  }).shape
1723
1562
  );
1724
1563
  var MarkNotDuplicateAction = ActionBase.extend(
1725
- z15.object({
1726
- type: z15.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1564
+ z14.object({
1565
+ type: z14.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1727
1566
  }).shape
1728
1567
  );
1729
1568
  var MarkAsDuplicateAction = ActionBase.extend(
1730
- z15.object({
1731
- type: z15.literal(ActionType.MARK_AS_DUPLICATE),
1732
- content: z15.object({
1569
+ z14.object({
1570
+ type: z14.literal(ActionType.MARK_AS_DUPLICATE),
1571
+ content: z14.object({
1733
1572
  duplicateOf: UUID
1734
1573
  }).optional()
1735
1574
  }).shape
1736
1575
  );
1737
1576
  var ArchiveAction = ActionBase.extend(
1738
- z15.object({
1739
- type: z15.literal(ActionType.ARCHIVE),
1577
+ z14.object({
1578
+ type: z14.literal(ActionType.ARCHIVE),
1740
1579
  content: ReasonContent
1741
1580
  }).shape
1742
1581
  );
1743
1582
  var CreatedAction = ActionBase.extend(
1744
- z15.object({
1745
- type: z15.literal(ActionType.CREATE)
1583
+ z14.object({
1584
+ type: z14.literal(ActionType.CREATE)
1746
1585
  }).shape
1747
1586
  );
1748
1587
  var NotifiedAction = ActionBase.extend(
1749
- z15.object({
1750
- type: z15.literal(ActionType.NOTIFY)
1588
+ z14.object({
1589
+ type: z14.literal(ActionType.NOTIFY)
1751
1590
  }).shape
1752
1591
  );
1753
1592
  var EditAction = ActionBase.extend(
1754
- z15.object({
1755
- type: z15.literal(ActionType.EDIT),
1756
- content: z15.object({
1757
- comment: z15.string().describe("Comment for the edit action.").optional()
1593
+ z14.object({
1594
+ type: z14.literal(ActionType.EDIT),
1595
+ content: z14.object({
1596
+ comment: z14.string().describe("Comment for the edit action.").optional()
1758
1597
  })
1759
1598
  }).shape
1760
1599
  );
1761
- var PrintContent = z15.object({
1762
- templateId: z15.string().optional()
1600
+ var PrintContent = z14.object({
1601
+ templateId: z14.string().optional()
1763
1602
  });
1764
1603
  var PrintCertificateAction = ActionBase.extend(
1765
- z15.object({
1766
- type: z15.literal(ActionType.PRINT_CERTIFICATE),
1604
+ z14.object({
1605
+ type: z14.literal(ActionType.PRINT_CERTIFICATE),
1767
1606
  content: PrintContent.optional().nullable()
1768
1607
  }).shape
1769
1608
  );
1770
1609
  var RequestedCorrectionAction = ActionBase.extend(
1771
- z15.object({
1772
- type: z15.literal(ActionType.REQUEST_CORRECTION)
1610
+ z14.object({
1611
+ type: z14.literal(ActionType.REQUEST_CORRECTION)
1773
1612
  }).shape
1774
1613
  );
1775
1614
  var ApprovedCorrectionAction = ActionBase.extend(
1776
- z15.object({
1777
- type: z15.literal(ActionType.APPROVE_CORRECTION),
1778
- requestId: z15.string()
1615
+ z14.object({
1616
+ type: z14.literal(ActionType.APPROVE_CORRECTION),
1617
+ requestId: z14.string()
1779
1618
  // TODO move into 'content' property
1780
1619
  }).shape
1781
1620
  );
1782
1621
  var RejectedCorrectionAction = ActionBase.extend(
1783
- z15.object({
1784
- type: z15.literal(ActionType.REJECT_CORRECTION),
1785
- requestId: z15.string(),
1622
+ z14.object({
1623
+ type: z14.literal(ActionType.REJECT_CORRECTION),
1624
+ requestId: z14.string(),
1786
1625
  // TODO move into 'content' property
1787
1626
  content: ReasonContent
1788
1627
  }).shape
1789
1628
  );
1790
1629
  var ReadAction = ActionBase.extend(
1791
- z15.object({
1792
- type: z15.literal(ActionType.READ)
1630
+ z14.object({
1631
+ type: z14.literal(ActionType.READ)
1793
1632
  }).shape
1794
1633
  );
1795
1634
  var CustomAction = ActionBase.merge(
1796
- z15.object({
1797
- type: z15.literal(ActionType.CUSTOM),
1798
- customActionType: z15.string()
1635
+ z14.object({
1636
+ type: z14.literal(ActionType.CUSTOM),
1637
+ customActionType: z14.string()
1799
1638
  })
1800
1639
  );
1801
- var ActionDocument = z15.discriminatedUnion("type", [
1640
+ var ActionDocument = z14.discriminatedUnion("type", [
1802
1641
  CreatedAction.meta({ id: "CreatedAction" }),
1803
1642
  RejectAction.meta({ id: "RejectAction" }),
1804
1643
  DuplicateDetectedAction.meta({ id: "DuplicateDetectedAction" }),
@@ -1824,15 +1663,15 @@ var AsyncRejectActionDocument = ActionBase.omit({
1824
1663
  declaration: true,
1825
1664
  annotation: true
1826
1665
  }).extend(
1827
- z15.object({
1828
- type: z15.enum(ConfirmableActions),
1829
- status: z15.literal(ActionStatus.Rejected)
1666
+ z14.object({
1667
+ type: z14.enum(ConfirmableActions),
1668
+ status: z14.literal(ActionStatus.Rejected)
1830
1669
  }).shape
1831
1670
  );
1832
- var Action = z15.union([ActionDocument, AsyncRejectActionDocument]);
1671
+ var Action = z14.union([ActionDocument, AsyncRejectActionDocument]);
1833
1672
 
1834
1673
  // ../commons/src/events/Flag.ts
1835
- var z16 = __toESM(require("zod/v4"));
1674
+ var z15 = __toESM(require("zod/v4"));
1836
1675
  var InherentFlags = {
1837
1676
  INCOMPLETE: "incomplete",
1838
1677
  REJECTED: "rejected",
@@ -1846,7 +1685,7 @@ var InherentFlags = {
1846
1685
  */
1847
1686
  EDIT_IN_PROGRESS: "edit-in-progress"
1848
1687
  };
1849
- var ActionFlag = z16.string().regex(
1688
+ var ActionFlag = z15.string().regex(
1850
1689
  new RegExp(
1851
1690
  `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
1852
1691
  ActionStatus
@@ -1854,73 +1693,73 @@ var ActionFlag = z16.string().regex(
1854
1693
  ),
1855
1694
  "Flag must be in the format ActionType:ActionStatus (lowerCase)"
1856
1695
  );
1857
- var CustomFlag = z16.string().refine((val) => !Object.values(InherentFlags).includes(val), {
1696
+ var CustomFlag = z15.string().refine((val) => !Object.values(InherentFlags).includes(val), {
1858
1697
  message: `Custom flag cannot be one of the inherent flags: ${Object.values(
1859
1698
  InherentFlags
1860
1699
  ).join(", ")}`
1861
1700
  }).refine((val) => !ActionFlag.safeParse(val).success, {
1862
1701
  message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
1863
1702
  }).describe("Custom flag identifier defined by the country config.");
1864
- var Flag = ActionFlag.or(z16.enum(InherentFlags)).or(CustomFlag);
1865
- var FlagConfig = z16.object({
1703
+ var Flag = ActionFlag.or(z15.enum(InherentFlags)).or(CustomFlag);
1704
+ var FlagConfig = z15.object({
1866
1705
  id: CustomFlag,
1867
- requiresAction: z16.boolean().describe(
1706
+ requiresAction: z15.boolean().describe(
1868
1707
  "Indicates if this flag expects an action to be performed to be cleared."
1869
1708
  ),
1870
1709
  label: TranslationConfig.describe("Human readable label of the flag.")
1871
1710
  });
1872
- var ActionFlagConfig = z16.object({
1711
+ var ActionFlagConfig = z15.object({
1873
1712
  id: Flag,
1874
- operation: z16.enum(["add", "remove"]).describe("Operation to perform on the flag."),
1713
+ operation: z15.enum(["add", "remove"]).describe("Operation to perform on the flag."),
1875
1714
  conditional: Conditional.optional().describe(
1876
1715
  "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
1877
1716
  )
1878
1717
  });
1879
1718
 
1880
1719
  // ../commons/src/events/EventMetadata.ts
1881
- var EventStatus = z17.enum([
1720
+ var EventStatus = z16.enum([
1882
1721
  "CREATED",
1883
1722
  "NOTIFIED",
1884
1723
  "DECLARED",
1885
1724
  "REGISTERED",
1886
1725
  "ARCHIVED"
1887
1726
  ]);
1888
- var ZodDate = z17.iso.date();
1889
- var ZodDateTime = z17.string().datetime();
1890
- var ActionCreationMetadata = z17.object({
1891
- createdAt: z17.iso.datetime().describe("The timestamp when the action request was created."),
1892
- createdBy: z17.string().describe("ID of the user who created the action request."),
1727
+ var ZodDate = z16.iso.date();
1728
+ var ZodDateTime = z16.string().datetime();
1729
+ var ActionCreationMetadata = z16.object({
1730
+ createdAt: z16.iso.datetime().describe("The timestamp when the action request was created."),
1731
+ createdBy: z16.string().describe("ID of the user who created the action request."),
1893
1732
  // @TODO: createdAtLocation should be non-nullable in the future once all action requests have this field populated.
1894
1733
  createdAtLocation: UUID.nullish().describe(
1895
1734
  "Location of the user who created the action request."
1896
1735
  ),
1897
- createdByUserType: z17.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1898
- acceptedAt: z17.iso.datetime().describe("Timestamp when the action request was accepted."),
1899
- createdByRole: z17.string().optional().describe("Role of the user at the time of action request creation."),
1900
- createdBySignature: z17.string().nullish().describe("Signature of the user who created the action request.")
1736
+ createdByUserType: z16.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1737
+ acceptedAt: z16.iso.datetime().describe("Timestamp when the action request was accepted."),
1738
+ createdByRole: z16.string().optional().describe("Role of the user at the time of action request creation."),
1739
+ createdBySignature: z16.string().nullish().describe("Signature of the user who created the action request.")
1901
1740
  });
1902
1741
  var RegistrationCreationMetadata = ActionCreationMetadata.extend({
1903
- registrationNumber: z17.string().describe(
1742
+ registrationNumber: z16.string().describe(
1904
1743
  "Registration number of the event. Always present for accepted registrations."
1905
1744
  )
1906
1745
  });
1907
- var LegalStatuses = z17.object({
1746
+ var LegalStatuses = z16.object({
1908
1747
  [EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
1909
1748
  [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
1910
1749
  });
1911
- var EventMetadata = z17.object({
1750
+ var EventMetadata = z16.object({
1912
1751
  id: UUID,
1913
- type: z17.string().describe("The type of event, such as birth, death, or marriage."),
1752
+ type: z16.string().describe("The type of event, such as birth, death, or marriage."),
1914
1753
  status: EventStatus,
1915
1754
  legalStatuses: LegalStatuses.describe(
1916
1755
  "Metadata related to the legal registration of the event, such as who registered it and when."
1917
1756
  ),
1918
- createdAt: z17.iso.datetime().describe("The timestamp when the event was first created and saved."),
1757
+ createdAt: z16.iso.datetime().describe("The timestamp when the event was first created and saved."),
1919
1758
  dateOfEvent: ZodDate.nullish(),
1920
1759
  placeOfEvent: UUID.nullish(),
1921
- createdBy: z17.string().describe("ID of the user who created the event."),
1922
- createdByUserType: z17.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1923
- updatedByUserRole: z17.string().nullish().describe("Role of the user who last changed the status."),
1760
+ createdBy: z16.string().describe("ID of the user who created the event."),
1761
+ createdByUserType: z16.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1762
+ updatedByUserRole: z16.string().nullish().describe("Role of the user who last changed the status."),
1924
1763
  // @TODO: createdAtLocation should be non-nullable in the future once all action requests have this field populated.
1925
1764
  createdAtLocation: UUID.nullish().describe(
1926
1765
  "Location of the user who created the event."
@@ -1931,18 +1770,18 @@ var EventMetadata = z17.object({
1931
1770
  updatedAtLocation: UUID.nullish().describe(
1932
1771
  "Location of the user who last changed the status."
1933
1772
  ),
1934
- updatedAt: z17.iso.datetime().describe(
1773
+ updatedAt: z16.iso.datetime().describe(
1935
1774
  "Timestamp of the most recent *accepted* status change. Possibly 3rd party update, if action is validation asynchronously."
1936
1775
  ),
1937
- assignedTo: z17.string().nullish().describe("ID of the user currently assigned to the event."),
1938
- updatedBy: z17.string().nullish().describe("ID of the user who last changed the status."),
1939
- trackingId: z17.string().describe(
1776
+ assignedTo: z16.string().nullish().describe("ID of the user currently assigned to the event."),
1777
+ updatedBy: z16.string().nullish().describe("ID of the user who last changed the status."),
1778
+ trackingId: z16.string().describe(
1940
1779
  "System-generated tracking ID used by informants or registrars to look up the event."
1941
1780
  ),
1942
- potentialDuplicates: z17.array(PotentialDuplicate).describe(
1781
+ potentialDuplicates: z16.array(PotentialDuplicate).describe(
1943
1782
  "List of event IDs and their tracking IDs that this event could be a duplicate of."
1944
1783
  ),
1945
- flags: z17.array(Flag)
1784
+ flags: z16.array(Flag)
1946
1785
  });
1947
1786
  var EventMetadataKeysArray = [
1948
1787
  "id",
@@ -1963,7 +1802,7 @@ var EventMetadataKeysArray = [
1963
1802
  "legalStatuses",
1964
1803
  "flags"
1965
1804
  ];
1966
- var EventMetadataKeys = z17.enum(EventMetadataKeysArray);
1805
+ var EventMetadataKeys = z16.enum(EventMetadataKeysArray);
1967
1806
  var eventMetadataLabelMap = {
1968
1807
  "event.assignedTo": {
1969
1808
  id: "event.assignedTo.label",
@@ -2046,7 +1885,7 @@ var eventMetadataLabelMap = {
2046
1885
  description: "Flags"
2047
1886
  }
2048
1887
  };
2049
- var EventMetadataDateFieldIdInput = z17.enum([
1888
+ var EventMetadataDateFieldIdInput = z16.enum([
2050
1889
  "createdAt",
2051
1890
  "updatedAt",
2052
1891
  "legalStatuses.DECLARED.createdAt",
@@ -2054,7 +1893,7 @@ var EventMetadataDateFieldIdInput = z17.enum([
2054
1893
  "legalStatuses.REGISTERED.createdAt",
2055
1894
  "legalStatuses.REGISTERED.acceptedAt"
2056
1895
  ]);
2057
- var EventMetadataDateFieldId = z17.enum([
1896
+ var EventMetadataDateFieldId = z16.enum([
2058
1897
  "event.createdAt",
2059
1898
  "event.updatedAt",
2060
1899
  "event.legalStatuses.DECLARED.createdAt",
@@ -2162,8 +2001,8 @@ var QueryExpression = import_v4.z.object({
2162
2001
  "legalStatuses.REGISTERED.createdAtLocation": import_v4.z.optional(Within).nullable(),
2163
2002
  "legalStatuses.REGISTERED.createdByRole": import_v4.z.optional(AnyOf),
2164
2003
  "legalStatuses.REGISTERED.registrationNumber": import_v4.z.optional(Exact),
2165
- createdAtLocation: import_v4.z.optional(Within),
2166
- updatedAtLocation: import_v4.z.optional(Within),
2004
+ createdAtLocation: import_v4.z.optional(import_v4.z.union([Within, Exact])),
2005
+ updatedAtLocation: import_v4.z.optional(import_v4.z.union([Within, Exact])),
2167
2006
  assignedTo: import_v4.z.optional(Exact),
2168
2007
  createdByUserType: import_v4.z.optional(ExactUserType),
2169
2008
  updatedByUserRole: import_v4.z.optional(Exact),
@@ -2256,7 +2095,7 @@ function todayDateTimeValueSerializer() {
2256
2095
  // ../commons/src/users/userReferences.ts
2257
2096
  var import_v42 = __toESM(require("zod/v4"));
2258
2097
  var ScopeOptionReference = import_v42.default.object({
2259
- $scope: RecordScopeTypeV2,
2098
+ $scope: ScopeType,
2260
2099
  $option: ScopeOptionKey
2261
2100
  });
2262
2101
  var JurisdictionReference = import_v42.default.object({
@@ -2500,17 +2339,14 @@ var ImageViewField = BaseField.extend({
2500
2339
  }).describe("A read-only image component for form pages");
2501
2340
  var Paragraph = BaseField.extend({
2502
2341
  type: import_v43.default.literal(FieldType.PARAGRAPH),
2503
- defaultValue: NonEmptyTextValue.optional(),
2504
2342
  configuration: ParagraphConfiguration
2505
2343
  }).describe("A read-only HTML <p> paragraph");
2506
2344
  var Heading = BaseField.extend({
2507
2345
  type: import_v43.default.literal(FieldType.HEADING),
2508
- defaultValue: NonEmptyTextValue.optional(),
2509
2346
  configuration: HeadingConfiguration
2510
2347
  }).describe("A read-only heading component for form pages");
2511
2348
  var PageHeader = BaseField.extend({
2512
- type: import_v43.default.literal(FieldType.PAGE_HEADER),
2513
- defaultValue: NonEmptyTextValue.optional()
2349
+ type: import_v43.default.literal(FieldType.PAGE_HEADER)
2514
2350
  }).describe("A read-only header component for form pages");
2515
2351
  var File = BaseField.extend({
2516
2352
  type: import_v43.default.literal(FieldType.FILE),
@@ -2560,7 +2396,6 @@ var RadioGroup = BaseField.extend({
2560
2396
  }).describe("Grouped radio options");
2561
2397
  var BulletList = BaseField.extend({
2562
2398
  type: import_v43.default.literal(FieldType.BULLET_LIST),
2563
- defaultValue: TextValue.optional(),
2564
2399
  items: import_v43.default.array(TranslationConfig).describe("A list of items"),
2565
2400
  configuration: import_v43.default.object({
2566
2401
  styles: import_v43.default.object({
@@ -2666,7 +2501,7 @@ var LocationInput = BaseField.extend({
2666
2501
  configuration: import_v43.default.object({
2667
2502
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
2668
2503
  allowedLocations: AllowedLocations
2669
- })
2504
+ }).optional()
2670
2505
  }).describe("Input field for a location");
2671
2506
  var FileUploadWithOptions = BaseField.extend({
2672
2507
  type: import_v43.default.literal(FieldType.FILE_WITH_OPTIONS),
@@ -2742,16 +2577,32 @@ var DataField = BaseField.extend({
2742
2577
  data: import_v43.default.array(DataEntry)
2743
2578
  })
2744
2579
  }).describe("Data field for displaying read-only data");
2580
+ var ButtonSize = import_v43.default.enum(["small", "medium", "large"]);
2581
+ var ButtonType = import_v43.default.enum([
2582
+ "primary",
2583
+ "secondary",
2584
+ "tertiary",
2585
+ "positive",
2586
+ "negative",
2587
+ "secondaryNegative",
2588
+ "icon",
2589
+ "iconPrimary"
2590
+ ]);
2591
+ var TextColor = import_v43.default.enum(["primary", "copy"]);
2592
+ var TextVariant = import_v43.default.enum(["bold14", "reg14"]);
2593
+ var ButtonConfiguration = import_v43.default.object({
2594
+ icon: import_v43.default.string().optional().describe("Icon for the button. You can find icons from OpenCRVS UI-Kit."),
2595
+ loading: import_v43.default.boolean().optional().describe("Whether the button is in a loading state and shows a spinner"),
2596
+ buttonSize: ButtonSize.optional().describe("Size of the button."),
2597
+ buttonType: ButtonType.optional().describe("Type of the button."),
2598
+ textColor: TextColor.optional().describe("Color of the text."),
2599
+ textVariant: TextVariant.optional().describe("Variant of the text."),
2600
+ text: TranslationConfig.describe("Text to display on the button")
2601
+ });
2745
2602
  var ButtonField = BaseField.extend({
2746
2603
  type: import_v43.default.literal(FieldType.BUTTON),
2747
2604
  defaultValue: ButtonFieldValue.optional(),
2748
- configuration: import_v43.default.object({
2749
- icon: import_v43.default.string().optional().describe(
2750
- "Icon for the button. You can find icons from OpenCRVS UI-Kit."
2751
- ),
2752
- loading: import_v43.default.boolean().optional().describe("Whether the button is in a loading state and shows a spinner"),
2753
- text: TranslationConfig.describe("Text to display on the button")
2754
- })
2605
+ configuration: ButtonConfiguration
2755
2606
  }).describe("Generic button without any built-in functionality");
2756
2607
  var FieldGroup = BaseField.extend({
2757
2608
  type: import_v43.default.literal(FieldType.FIELD_GROUP),
@@ -2783,6 +2634,19 @@ var HttpField = BaseField.extend({
2783
2634
  timeout: import_v43.default.number().default(15e3).describe("Request timeout in milliseconds")
2784
2635
  })
2785
2636
  }).describe("HTTP request function triggered by a button click or other event");
2637
+ var AutocompleteField = BaseField.extend({
2638
+ type: import_v43.default.literal(FieldType.AUTOCOMPLETE),
2639
+ configuration: import_v43.default.object({
2640
+ url: import_v43.default.string().describe("URL to fetch autocomplete suggestions from").optional(),
2641
+ method: import_v43.default.enum(["GET", "POST"]).default("GET").optional(),
2642
+ defaultOptions: import_v43.default.array(
2643
+ import_v43.default.object({
2644
+ label: import_v43.default.string(),
2645
+ value: import_v43.default.string()
2646
+ })
2647
+ ).optional()
2648
+ })
2649
+ }).describe("Autocomplete input field");
2786
2650
  var SearchField = HttpField.extend({
2787
2651
  type: import_v43.default.literal(FieldType.SEARCH),
2788
2652
  configuration: SearchQuery.pick({
@@ -2868,8 +2732,11 @@ var CustomField = BaseField.extend({
2868
2732
  src: import_v43.default.string().describe("Module source path for the custom field component"),
2869
2733
  configuration: import_v43.default.unknown().optional()
2870
2734
  });
2735
+ var FieldStyleVariant = import_v43.default.enum(["default", "highlighted"]);
2871
2736
  var LoaderField = BaseField.extend({
2872
2737
  type: import_v43.default.literal(FieldType.LOADER),
2738
+ variant: FieldStyleVariant.default("default").optional(),
2739
+ hideLabel: import_v43.default.boolean().default(true).optional().describe("Loader field does not show a label by default"),
2873
2740
  configuration: import_v43.default.object({
2874
2741
  text: TranslationConfig.describe("Display text above the loading spinner")
2875
2742
  })
@@ -2926,6 +2793,7 @@ var FieldConfig = import_v43.default.discriminatedUnion("type", [
2926
2793
  ButtonField,
2927
2794
  AlphaPrintButton,
2928
2795
  HttpField,
2796
+ AutocompleteField,
2929
2797
  LinkButtonField,
2930
2798
  VerificationStatus,
2931
2799
  QrReaderField,
@@ -2947,18 +2815,18 @@ var AnyFileField = import_v43.default.discriminatedUnion("type", [
2947
2815
  ]);
2948
2816
 
2949
2817
  // ../commons/src/events/FormConfig.ts
2950
- var z23 = __toESM(require("zod/v4"));
2818
+ var z22 = __toESM(require("zod/v4"));
2951
2819
 
2952
2820
  // ../commons/src/events/PageConfig.ts
2953
- var z22 = __toESM(require("zod/v4"));
2954
- var PageTypes = z22.enum(["FORM", "VERIFICATION"]);
2955
- var PageConfigBase = z22.object({
2956
- id: z22.string().describe("Unique identifier for the page"),
2821
+ var z21 = __toESM(require("zod/v4"));
2822
+ var PageTypes = z21.enum(["FORM", "VERIFICATION"]);
2823
+ var PageConfigBase = z21.object({
2824
+ id: z21.string().describe("Unique identifier for the page"),
2957
2825
  title: TranslationConfig.describe("Header title of the page"),
2958
- requireCompletionToContinue: z22.boolean().default(false).describe(
2826
+ requireCompletionToContinue: z21.boolean().default(false).describe(
2959
2827
  "If true, all required fields must be filled before continuing to the next page"
2960
2828
  ),
2961
- fields: z22.array(FieldConfig).describe("Fields to be rendered on the page"),
2829
+ fields: z21.array(FieldConfig).describe("Fields to be rendered on the page"),
2962
2830
  conditional: Conditional.optional().describe(
2963
2831
  "Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
2964
2832
  )
@@ -2967,13 +2835,13 @@ var PageConfigBase = z22.object({
2967
2835
  id: "FormPageConfig"
2968
2836
  });
2969
2837
  var FormPageConfig = PageConfigBase.extend({
2970
- type: z22.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
2838
+ type: z21.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
2971
2839
  });
2972
- var VerificationActionConfig = z22.object({
2973
- verify: z22.object({ label: TranslationConfig }),
2974
- cancel: z22.object({
2840
+ var VerificationActionConfig = z21.object({
2841
+ verify: z21.object({ label: TranslationConfig }),
2842
+ cancel: z21.object({
2975
2843
  label: TranslationConfig,
2976
- confirmation: z22.object({
2844
+ confirmation: z21.object({
2977
2845
  title: TranslationConfig,
2978
2846
  body: TranslationConfig
2979
2847
  })
@@ -2983,31 +2851,31 @@ var VerificationActionConfig = z22.object({
2983
2851
  id: "VerificationActionConfig"
2984
2852
  });
2985
2853
  var VerificationPageConfig = FormPageConfig.extend({
2986
- type: z22.literal(PageTypes.enum.VERIFICATION),
2854
+ type: z21.literal(PageTypes.enum.VERIFICATION),
2987
2855
  actions: VerificationActionConfig
2988
2856
  });
2989
- var PageConfig = z22.discriminatedUnion("type", [
2857
+ var PageConfig = z21.discriminatedUnion("type", [
2990
2858
  FormPageConfig,
2991
2859
  VerificationPageConfig
2992
2860
  ]);
2993
2861
 
2994
2862
  // ../commons/src/events/FormConfig.ts
2995
- var DeclarationFormConfig = z23.object({
2863
+ var DeclarationFormConfig = z22.object({
2996
2864
  label: TranslationConfig.describe("Human readable description of the form"),
2997
- pages: z23.array(FormPageConfig)
2865
+ pages: z22.array(FormPageConfig)
2998
2866
  }).describe("Configuration of the declaration form.");
2999
- var ActionFormConfig = z23.object({
2867
+ var ActionFormConfig = z22.object({
3000
2868
  label: TranslationConfig.describe("Human readable description of the form"),
3001
- pages: z23.array(PageConfig)
2869
+ pages: z22.array(PageConfig)
3002
2870
  }).describe(
3003
2871
  "Configuration of the form used for system actions beyond declaration, supporting a wider range of page types."
3004
2872
  );
3005
- var FormConfig = z23.union([DeclarationFormConfig, ActionFormConfig]);
2873
+ var FormConfig = z22.union([DeclarationFormConfig, ActionFormConfig]);
3006
2874
 
3007
2875
  // ../commons/src/events/DeduplicationConfig.ts
3008
- var z24 = __toESM(require("zod/v4"));
3009
- var FieldReference2 = z24.string();
3010
- var Matcher = z24.object({
2876
+ var z23 = __toESM(require("zod/v4"));
2877
+ var FieldReference2 = z23.string();
2878
+ var Matcher = z23.object({
3011
2879
  /**
3012
2880
  * Reference to the field used in matching.
3013
2881
  *
@@ -3015,23 +2883,23 @@ var Matcher = z24.object({
3015
2883
  * be used as the origin date to calculate the distance from.
3016
2884
  */
3017
2885
  fieldId: FieldReference2,
3018
- options: z24.object({
3019
- boost: z24.number().optional(),
2886
+ options: z23.object({
2887
+ boost: z23.number().optional(),
3020
2888
  matchAgainst: FieldReference2.optional()
3021
2889
  }).optional().default({
3022
2890
  boost: 1
3023
2891
  })
3024
2892
  });
3025
2893
  var FuzzyMatcher = Matcher.extend({
3026
- type: z24.literal("fuzzy"),
3027
- options: z24.object({
2894
+ type: z23.literal("fuzzy"),
2895
+ options: z23.object({
3028
2896
  /**
3029
2897
  * Names of length 3 or less characters = 0 edits allowed
3030
2898
  * Names of length 4 - 6 characters = 1 edit allowed
3031
2899
  * Names of length >7 characters = 2 edits allowed
3032
2900
  */
3033
- fuzziness: z24.union([z24.string(), z24.number()]).optional().default("AUTO:4,7"),
3034
- boost: z24.number().optional().default(1),
2901
+ fuzziness: z23.union([z23.string(), z23.number()]).optional().default("AUTO:4,7"),
2902
+ boost: z23.number().optional().default(1),
3035
2903
  matchAgainst: FieldReference2.optional()
3036
2904
  }).optional().default({
3037
2905
  fuzziness: "AUTO:4,7",
@@ -3039,48 +2907,48 @@ var FuzzyMatcher = Matcher.extend({
3039
2907
  })
3040
2908
  });
3041
2909
  var StrictMatcher = Matcher.extend({
3042
- type: z24.literal("strict"),
3043
- options: z24.object({
3044
- boost: z24.number().optional().default(1),
2910
+ type: z23.literal("strict"),
2911
+ options: z23.object({
2912
+ boost: z23.number().optional().default(1),
3045
2913
  /**
3046
2914
  * The constant value to be present in the field for both records
3047
2915
  */
3048
- value: z24.string().optional(),
2916
+ value: z23.string().optional(),
3049
2917
  matchAgainst: FieldReference2.optional()
3050
2918
  }).optional().default({
3051
2919
  boost: 1
3052
2920
  })
3053
2921
  });
3054
2922
  var DateRangeMatcher = Matcher.extend({
3055
- type: z24.literal("dateRange"),
3056
- options: z24.object({
2923
+ type: z23.literal("dateRange"),
2924
+ options: z23.object({
3057
2925
  /**
3058
2926
  * The distance pivot in days. Distance from the origin (the value of
3059
2927
  * fieldId) at which relevance scores receive half of the boost value
3060
2928
  */
3061
- pivot: z24.number().optional(),
3062
- days: z24.number(),
3063
- boost: z24.number().optional().default(1),
2929
+ pivot: z23.number().optional(),
2930
+ days: z23.number(),
2931
+ boost: z23.number().optional().default(1),
3064
2932
  matchAgainst: FieldReference2.optional()
3065
2933
  })
3066
2934
  });
3067
- var Not = z24.object({
3068
- type: z24.literal("not"),
2935
+ var Not = z23.object({
2936
+ type: z23.literal("not"),
3069
2937
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
3070
- clause: z24.lazy(() => Clause)
2938
+ clause: z23.lazy(() => Clause)
3071
2939
  });
3072
- var And = z24.object({
3073
- type: z24.literal("and"),
2940
+ var And = z23.object({
2941
+ type: z23.literal("and"),
3074
2942
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
3075
- clauses: z24.lazy(() => Clause.array())
2943
+ clauses: z23.lazy(() => Clause.array())
3076
2944
  });
3077
- var Or = z24.object({
3078
- type: z24.literal("or"),
2945
+ var Or = z23.object({
2946
+ type: z23.literal("or"),
3079
2947
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
3080
- clauses: z24.lazy(() => Clause.array())
2948
+ clauses: z23.lazy(() => Clause.array())
3081
2949
  });
3082
- var Clause = z24.lazy(
3083
- () => z24.discriminatedUnion("type", [
2950
+ var Clause = z23.lazy(
2951
+ () => z23.discriminatedUnion("type", [
3084
2952
  Not,
3085
2953
  And,
3086
2954
  Or,
@@ -3091,22 +2959,22 @@ var Clause = z24.lazy(
3091
2959
  ).meta({
3092
2960
  id: "Clause"
3093
2961
  });
3094
- var DeduplicationConfig = z24.object({
3095
- id: z24.string(),
2962
+ var DeduplicationConfig = z23.object({
2963
+ id: z23.string(),
3096
2964
  label: TranslationConfig,
3097
2965
  query: Clause
3098
2966
  });
3099
2967
 
3100
2968
  // ../commons/src/events/ActionConfig.ts
3101
- var DeclarationReviewConfig = z25.object({
2969
+ var DeclarationReviewConfig = z24.object({
3102
2970
  title: TranslationConfig.describe("Title of the review page"),
3103
- fields: z25.array(FieldConfig).describe("Fields displayed on the review page for annotations.")
2971
+ fields: z24.array(FieldConfig).describe("Fields displayed on the review page for annotations.")
3104
2972
  }).describe(
3105
2973
  "Configuration of the declaration review page for collecting event-related metadata."
3106
2974
  );
3107
- var ActionConfigBase = z25.object({
2975
+ var ActionConfigBase = z24.object({
3108
2976
  label: TranslationConfig.describe("Human readable description of the action"),
3109
- flags: z25.array(ActionFlagConfig).optional().default([]).describe("Flag actions which are executed when the action is performed."),
2977
+ flags: z24.array(ActionFlagConfig).optional().default([]).describe("Flag actions which are executed when the action is performed."),
3110
2978
  supportingCopy: TranslationConfig.optional().describe(
3111
2979
  "Text displayed on the confirmation dialog"
3112
2980
  ),
@@ -3117,28 +2985,28 @@ var ActionConfigBase = z25.object({
3117
2985
  * "The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed."
3118
2986
  * for EventConfig.d.ts.
3119
2987
  */
3120
- icon: z25.string().describe("Icon representing the action").optional(),
3121
- conditionals: z25.array(ActionConditional).optional().describe("Conditionals which can disable or hide actions.")
2988
+ icon: z24.string().describe("Icon representing the action").optional(),
2989
+ conditionals: z24.array(ActionConditional).optional().describe("Conditionals which can disable or hide actions.")
3122
2990
  });
3123
2991
  var DeclarationActionBase = ActionConfigBase.extend({
3124
2992
  deduplication: DeduplicationConfig.optional()
3125
2993
  });
3126
2994
  var ReadActionConfig = ActionConfigBase.extend(
3127
- z25.object({
3128
- type: z25.literal(ActionType.READ),
2995
+ z24.object({
2996
+ type: z24.literal(ActionType.READ),
3129
2997
  review: DeclarationReviewConfig.describe(
3130
2998
  "Configuration of the review page for read-only view."
3131
2999
  ),
3132
- conditionals: z25.never().optional().describe("Read-action can not be disabled or hidden with conditionals.")
3000
+ conditionals: z24.never().optional().describe("Read-action can not be disabled or hidden with conditionals.")
3133
3001
  }).shape
3134
3002
  );
3135
3003
  var DeclareConfig = DeclarationActionBase.extend(
3136
- z25.object({
3137
- type: z25.literal(ActionType.DECLARE),
3004
+ z24.object({
3005
+ type: z24.literal(ActionType.DECLARE),
3138
3006
  review: DeclarationReviewConfig.describe(
3139
3007
  "Configuration of the review page fields."
3140
3008
  ),
3141
- dialogCopy: z25.object({
3009
+ dialogCopy: z24.object({
3142
3010
  notify: TranslationConfig.describe(
3143
3011
  "Confirmation text for the notify action"
3144
3012
  ),
@@ -3152,14 +3020,14 @@ var DeclareConfig = DeclarationActionBase.extend(
3152
3020
  }).shape
3153
3021
  );
3154
3022
  var ArchiveConfig = ActionConfigBase.extend(
3155
- z25.object({
3156
- type: z25.literal(ActionType.ARCHIVE)
3023
+ z24.object({
3024
+ type: z24.literal(ActionType.ARCHIVE)
3157
3025
  }).shape
3158
3026
  );
3159
3027
  var EditActionConfig = ActionConfigBase.extend(
3160
- z25.object({
3161
- type: z25.literal(ActionType.EDIT),
3162
- dialogCopy: z25.object({
3028
+ z24.object({
3029
+ type: z24.literal(ActionType.EDIT),
3030
+ dialogCopy: z24.object({
3163
3031
  notify: TranslationConfig.describe(
3164
3032
  "Confirmation text for the notify with edits action"
3165
3033
  ),
@@ -3173,33 +3041,33 @@ var EditActionConfig = ActionConfigBase.extend(
3173
3041
  }).shape
3174
3042
  );
3175
3043
  var RejectConfig = ActionConfigBase.extend(
3176
- z25.object({
3177
- type: z25.literal(ActionType.REJECT)
3044
+ z24.object({
3045
+ type: z24.literal(ActionType.REJECT)
3178
3046
  }).shape
3179
3047
  );
3180
3048
  var RegisterConfig = DeclarationActionBase.extend(
3181
- z25.object({
3182
- type: z25.literal(ActionType.REGISTER)
3049
+ z24.object({
3050
+ type: z24.literal(ActionType.REGISTER)
3183
3051
  }).shape
3184
3052
  );
3185
3053
  var PrintCertificateActionConfig = ActionConfigBase.extend(
3186
- z25.object({
3187
- type: z25.literal(ActionType.PRINT_CERTIFICATE),
3054
+ z24.object({
3055
+ type: z24.literal(ActionType.PRINT_CERTIFICATE),
3188
3056
  printForm: ActionFormConfig
3189
3057
  }).shape
3190
3058
  );
3191
3059
  var RequestCorrectionConfig = ActionConfigBase.extend(
3192
- z25.object({
3193
- type: z25.literal(ActionType.REQUEST_CORRECTION),
3060
+ z24.object({
3061
+ type: z24.literal(ActionType.REQUEST_CORRECTION),
3194
3062
  correctionForm: ActionFormConfig
3195
3063
  }).shape
3196
3064
  );
3197
3065
  var CustomActionConfig = ActionConfigBase.merge(
3198
- z25.object({
3199
- type: z25.literal(ActionType.CUSTOM),
3200
- customActionType: z25.string().describe("Type identifier of the custom action."),
3066
+ z24.object({
3067
+ type: z24.literal(ActionType.CUSTOM),
3068
+ customActionType: z24.string().describe("Type identifier of the custom action."),
3201
3069
  /** Custom action form configuration supports a simple array of field configs, which should be rendered on the action modal. In the future, we might add support for pages etc. */
3202
- form: z25.array(FieldConfig).describe(
3070
+ form: z24.array(FieldConfig).describe(
3203
3071
  "Form configuration for the custom action. The form configured here will be used on the custom action confirmation modal."
3204
3072
  ),
3205
3073
  auditHistoryLabel: TranslationConfig.describe(
@@ -3207,7 +3075,7 @@ var CustomActionConfig = ActionConfigBase.merge(
3207
3075
  )
3208
3076
  })
3209
3077
  );
3210
- var ActionConfig = z25.discriminatedUnion("type", [
3078
+ var ActionConfig = z24.discriminatedUnion("type", [
3211
3079
  /*
3212
3080
  * OpenAPI references are defined here so our generated OpenAPI spec knows to reuse the models
3213
3081
  * and treat them as "models" instead of duplicating the data structure in each endpoint.
@@ -3229,86 +3097,86 @@ var ActionConfig = z25.discriminatedUnion("type", [
3229
3097
  var actionConfigTypes = new Set(
3230
3098
  ActionConfig.options.map((opt) => opt.shape.type.value)
3231
3099
  );
3232
- var DeclarationActionConfig = z25.discriminatedUnion("type", [
3100
+ var DeclarationActionConfig = z24.discriminatedUnion("type", [
3233
3101
  DeclareConfig,
3234
3102
  RegisterConfig
3235
3103
  ]);
3236
3104
 
3237
3105
  // ../commons/src/events/offline/CertificateConfig.ts
3238
- var z26 = __toESM(require("zod/v4"));
3239
- var FontFamily = z26.object({
3240
- normal: z26.string(),
3241
- bold: z26.string(),
3242
- italics: z26.string(),
3243
- bolditalics: z26.string()
3244
- });
3245
- var CertificateConfig = z26.object({
3246
- id: z26.string(),
3247
- event: z26.string(),
3248
- isV2Template: z26.boolean().optional(),
3106
+ var z25 = __toESM(require("zod/v4"));
3107
+ var FontFamily = z25.object({
3108
+ normal: z25.string(),
3109
+ bold: z25.string(),
3110
+ italics: z25.string(),
3111
+ bolditalics: z25.string()
3112
+ });
3113
+ var CertificateConfig = z25.object({
3114
+ id: z25.string(),
3115
+ event: z25.string(),
3116
+ isV2Template: z25.boolean().optional(),
3249
3117
  label: TranslationConfig,
3250
- isDefault: z26.boolean(),
3251
- fee: z26.object({
3252
- onTime: z26.number(),
3253
- late: z26.number(),
3254
- delayed: z26.number()
3118
+ isDefault: z25.boolean(),
3119
+ fee: z25.object({
3120
+ onTime: z25.number(),
3121
+ late: z25.number(),
3122
+ delayed: z25.number()
3255
3123
  }),
3256
- svgUrl: z26.string(),
3257
- fonts: z26.record(z26.string(), FontFamily).optional(),
3258
- conditionals: z26.array(ShowConditional).optional()
3124
+ svgUrl: z25.string(),
3125
+ fonts: z25.record(z25.string(), FontFamily).optional(),
3126
+ conditionals: z25.array(ShowConditional).optional()
3259
3127
  });
3260
3128
  var CertificateTemplateConfig = CertificateConfig.extend({
3261
- hash: z26.string().optional(),
3262
- svg: z26.string()
3129
+ hash: z25.string().optional(),
3130
+ svg: z25.string()
3263
3131
  });
3264
3132
 
3265
3133
  // ../commons/src/events/offline/LanguageConfig.ts
3266
- var z27 = __toESM(require("zod/v4"));
3267
- var LanguageConfig = z27.object({
3268
- lang: z27.string(),
3134
+ var z26 = __toESM(require("zod/v4"));
3135
+ var LanguageConfig = z26.object({
3136
+ lang: z26.string(),
3269
3137
  /**
3270
3138
  * client.csv contents
3271
3139
  */
3272
- messages: z27.record(z27.string(), z27.string())
3140
+ messages: z26.record(z26.string(), z26.string())
3273
3141
  });
3274
3142
 
3275
3143
  // ../commons/src/events/EventConfig.ts
3276
- var z34 = __toESM(require("zod/v4"));
3144
+ var z33 = __toESM(require("zod/v4"));
3277
3145
 
3278
3146
  // ../commons/src/events/SummaryConfig.ts
3279
- var z28 = __toESM(require("zod/v4"));
3280
- var BaseField2 = z28.object({
3147
+ var z27 = __toESM(require("zod/v4"));
3148
+ var BaseField2 = z27.object({
3281
3149
  emptyValueMessage: TranslationConfig.optional().describe(
3282
3150
  "Default message displayed when the field value is empty."
3283
3151
  ),
3284
- conditionals: z28.array(ShowConditional).default([]).optional()
3152
+ conditionals: z27.array(ShowConditional).default([]).optional()
3285
3153
  });
3286
3154
  var ReferenceField = BaseField2.extend({
3287
- fieldId: z28.string(),
3155
+ fieldId: z27.string(),
3288
3156
  label: TranslationConfig.optional().describe(
3289
3157
  "Overrides the default label from the referenced field when provided."
3290
3158
  )
3291
3159
  }).describe("Field referencing existing event data by field ID.");
3292
3160
  var Field = BaseField2.extend({
3293
- id: z28.string().describe("Identifier of the summary field."),
3161
+ id: z27.string().describe("Identifier of the summary field."),
3294
3162
  value: TranslationConfig.describe(
3295
3163
  'Field value template supporting variables from configuration and EventMetadata (e.g. "{informant.phoneNo} {informant.email}").'
3296
3164
  ),
3297
3165
  label: TranslationConfig
3298
3166
  }).describe("Custom field defined for the summary view.");
3299
- var SummaryConfig = z28.object({
3300
- fields: z28.array(z28.union([Field, ReferenceField])).describe("Fields displayed in the event summary view.")
3167
+ var SummaryConfig = z27.object({
3168
+ fields: z27.array(z27.union([Field, ReferenceField])).describe("Fields displayed in the event summary view.")
3301
3169
  }).describe("Configuration of the event summary section.");
3302
3170
 
3303
3171
  // ../commons/src/events/AdvancedSearchConfig.ts
3304
- var z29 = __toESM(require("zod/v4"));
3305
- var MatchType = z29.enum(["fuzzy", "exact", "range", "within"]);
3306
- var BaseField3 = z29.object({
3307
- config: z29.object({
3172
+ var z28 = __toESM(require("zod/v4"));
3173
+ var MatchType = z28.enum(["fuzzy", "exact", "range", "within"]);
3174
+ var BaseField3 = z28.object({
3175
+ config: z28.object({
3308
3176
  type: MatchType.describe(
3309
3177
  "Determines the search type of field. How to match value."
3310
3178
  ),
3311
- searchFields: z29.array(z29.string()).optional().describe(
3179
+ searchFields: z28.array(z28.string()).optional().describe(
3312
3180
  `
3313
3181
  Defines multiple form fields that should be searched when this field has a value.
3314
3182
  All specified fields will be combined using OR logic.
@@ -3318,7 +3186,7 @@ var BaseField3 = z29.object({
3318
3186
  `
3319
3187
  )
3320
3188
  }),
3321
- type: z29.nativeEnum(FieldType).optional().describe(
3189
+ type: z28.nativeEnum(FieldType).optional().describe(
3322
3190
  `
3323
3191
  Explicitly specify the field type for searchFields.
3324
3192
  This is required when searchFields is defined, to show the correct control in the UI.
@@ -3332,7 +3200,7 @@ var BaseField3 = z29.object({
3332
3200
  This is required when searchFields is defined.
3333
3201
  `
3334
3202
  ),
3335
- options: z29.array(SelectOption).optional(),
3203
+ options: z28.array(SelectOption).optional(),
3336
3204
  searchCriteriaLabelPrefix: TranslationConfig.optional().describe(
3337
3205
  `
3338
3206
  This property determines whether to add a prefix (such as "Child" or "Applicant") before the field label
@@ -3353,7 +3221,7 @@ var BaseField3 = z29.object({
3353
3221
  in the country-config > event.advancedSearch configuration. For example: field("child.dob", { searchCriteriaLabelPrefix: TranslationConfig }).
3354
3222
  `
3355
3223
  ),
3356
- conditionals: z29.array(FieldConditional).optional().describe(
3224
+ conditionals: z28.array(FieldConditional).optional().describe(
3357
3225
  `
3358
3226
  In advanced search, we sometimes need to override the default field visibility conditionals.
3359
3227
 
@@ -3367,20 +3235,20 @@ var BaseField3 = z29.object({
3367
3235
  are always rendered in the advanced search form.
3368
3236
  `
3369
3237
  ),
3370
- validations: z29.array(ValidationConfig).optional().describe(
3238
+ validations: z28.array(ValidationConfig).optional().describe(
3371
3239
  `Option for overriding the field validations specifically for advanced search form.`
3372
3240
  )
3373
3241
  });
3374
- var SearchQueryParams = z29.object({
3375
- eventType: z29.string().optional().describe(
3242
+ var SearchQueryParams = z28.object({
3243
+ eventType: z28.string().optional().describe(
3376
3244
  "Defines type of event so that when redirecting to Advanced Search page, appropriate tab can be selected"
3377
3245
  )
3378
3246
  }).catchall(FieldValue);
3379
3247
  var FieldConfigSchema = BaseField3.extend({
3380
- fieldId: z29.string(),
3381
- fieldType: z29.literal("field")
3248
+ fieldId: z28.string(),
3249
+ fieldType: z28.literal("field")
3382
3250
  });
3383
- var EventFieldIdInput = z29.enum([
3251
+ var EventFieldIdInput = z28.enum([
3384
3252
  "trackingId",
3385
3253
  "status",
3386
3254
  "legalStatuses.REGISTERED.acceptedAt",
@@ -3389,7 +3257,7 @@ var EventFieldIdInput = z29.enum([
3389
3257
  "updatedAt"
3390
3258
  ]);
3391
3259
  var METADATA_FIELD_PREFIX = "event.";
3392
- var EventFieldId = z29.enum([
3260
+ var EventFieldId = z28.enum([
3393
3261
  `${METADATA_FIELD_PREFIX}trackingId`,
3394
3262
  `${METADATA_FIELD_PREFIX}status`,
3395
3263
  `${METADATA_FIELD_PREFIX}legalStatuses.REGISTERED.acceptedAt`,
@@ -3399,29 +3267,29 @@ var EventFieldId = z29.enum([
3399
3267
  ]);
3400
3268
  var EventFieldConfigSchema = BaseField3.extend({
3401
3269
  fieldId: EventFieldId,
3402
- fieldType: z29.literal("event")
3270
+ fieldType: z28.literal("event")
3403
3271
  });
3404
- var AdvancedSearchField = z29.discriminatedUnion("fieldType", [FieldConfigSchema, EventFieldConfigSchema]).superRefine((data, ctx) => {
3272
+ var AdvancedSearchField = z28.discriminatedUnion("fieldType", [FieldConfigSchema, EventFieldConfigSchema]).superRefine((data, ctx) => {
3405
3273
  if (data.config.searchFields && data.config.searchFields.length > 0) {
3406
3274
  if (!data.label) {
3407
3275
  ctx.addIssue({
3408
- code: z29.ZodIssueCode.custom,
3276
+ code: z28.ZodIssueCode.custom,
3409
3277
  message: "label is required when config.searchFields is defined.",
3410
3278
  path: ["label"]
3411
3279
  });
3412
3280
  }
3413
3281
  if (!data.type) {
3414
3282
  ctx.addIssue({
3415
- code: z29.ZodIssueCode.custom,
3283
+ code: z28.ZodIssueCode.custom,
3416
3284
  message: "type is required when config.searchFields is defined.",
3417
3285
  path: ["type"]
3418
3286
  });
3419
3287
  }
3420
3288
  }
3421
3289
  });
3422
- var AdvancedSearchConfig = z29.object({
3290
+ var AdvancedSearchConfig = z28.object({
3423
3291
  title: TranslationConfig.describe("Advanced search tab title"),
3424
- fields: z29.array(AdvancedSearchField).describe("Advanced search fields within the tab.")
3292
+ fields: z28.array(AdvancedSearchField).describe("Advanced search fields within the tab.")
3425
3293
  });
3426
3294
 
3427
3295
  // ../commons/src/events/utils.ts
@@ -3430,17 +3298,17 @@ var import_lodash = require("lodash");
3430
3298
  // ../commons/src/conditionals/validate.ts
3431
3299
  var import__ = __toESM(require("ajv/dist/2019"));
3432
3300
  var import_ajv_formats = __toESM(require("ajv-formats"));
3433
- var z32 = __toESM(require("zod/v4"));
3301
+ var z31 = __toESM(require("zod/v4"));
3434
3302
  var import_date_fns = require("date-fns");
3435
3303
 
3436
3304
  // ../commons/src/events/FieldTypeMapping.ts
3437
- var z31 = __toESM(require("zod/v4"));
3305
+ var z30 = __toESM(require("zod/v4"));
3438
3306
 
3439
3307
  // ../commons/src/events/DynamicFieldValue.ts
3440
- var z30 = __toESM(require("zod/v4"));
3308
+ var z29 = __toESM(require("zod/v4"));
3441
3309
  function getDynamicNameValue(field3) {
3442
3310
  const nameConfiguration = field3.configuration?.name;
3443
- return z30.object({
3311
+ return z29.object({
3444
3312
  firstname: nameConfiguration?.firstname?.required ? NonEmptyTextValue : TextValue,
3445
3313
  surname: nameConfiguration?.surname?.required ? NonEmptyTextValue : TextValue,
3446
3314
  middlename: nameConfiguration?.middlename?.required ? NonEmptyTextValue : TextValue.optional()
@@ -3471,7 +3339,7 @@ function mapFieldTypeToZod(field3, actionType) {
3471
3339
  let schema;
3472
3340
  switch (field3.type) {
3473
3341
  case FieldType.FIELD_GROUP: {
3474
- schema = z31.object(
3342
+ schema = z30.object(
3475
3343
  field3.fields.reduce((acc, subfield) => {
3476
3344
  acc[subfield.id] = mapFieldTypeToZod(subfield, actionType);
3477
3345
  return acc;
@@ -3552,6 +3420,9 @@ function mapFieldTypeToZod(field3, actionType) {
3552
3420
  case FieldType.ALPHA_PRINT_BUTTON:
3553
3421
  schema = TextValue;
3554
3422
  break;
3423
+ case FieldType.AUTOCOMPLETE:
3424
+ schema = AutocompleteValue;
3425
+ break;
3555
3426
  case FieldType.HTTP:
3556
3427
  case FieldType.SEARCH:
3557
3428
  schema = HttpFieldUpdateValue;
@@ -3612,6 +3483,7 @@ function mapFieldTypeToEmptyValue(field3) {
3612
3483
  case FieldType.BUTTON:
3613
3484
  case FieldType.ALPHA_PRINT_BUTTON:
3614
3485
  case FieldType.HTTP:
3486
+ case FieldType.AUTOCOMPLETE:
3615
3487
  case FieldType.SEARCH:
3616
3488
  case FieldType.LINK_BUTTON:
3617
3489
  case FieldType.QUERY_PARAM_READER:
@@ -3751,6 +3623,9 @@ var isPrintButtonFieldType = (field3) => {
3751
3623
  var isHttpFieldType = (field3) => {
3752
3624
  return field3.config.type === FieldType.HTTP;
3753
3625
  };
3626
+ var isAutocompleteFieldType = (field3) => {
3627
+ return field3.config.type === FieldType.AUTOCOMPLETE;
3628
+ };
3754
3629
  var isSearchFieldType = (field3) => {
3755
3630
  return field3.config.type === FieldType.SEARCH;
3756
3631
  };
@@ -3792,9 +3667,9 @@ var ajv = new import__.default({
3792
3667
  strict: false
3793
3668
  // Allow minContains and other newer features
3794
3669
  });
3795
- var DataContext = z32.object({
3796
- rootData: z32.object({
3797
- $leafAdminStructureLocationIds: z32.array(z32.object({ id: UUID }))
3670
+ var DataContext = z31.object({
3671
+ rootData: z31.object({
3672
+ $leafAdminStructureLocationIds: z31.array(z31.object({ id: UUID }))
3798
3673
  })
3799
3674
  });
3800
3675
  function resolveDataPath(rootData, dataPath, instancePath) {
@@ -4243,7 +4118,7 @@ function areCertificateConditionsMet(conditions, values) {
4243
4118
  }
4244
4119
 
4245
4120
  // ../commons/src/utils.ts
4246
- var z33 = __toESM(require("zod/v4"));
4121
+ var z32 = __toESM(require("zod/v4"));
4247
4122
  var _ = __toESM(require("lodash"));
4248
4123
  function getOrThrow(x, message) {
4249
4124
  if (x === void 0 || x === null) {
@@ -4254,11 +4129,11 @@ function getOrThrow(x, message) {
4254
4129
  function joinValues(values, separator = " ") {
4255
4130
  return values.filter((value) => !!value).join(separator).trim();
4256
4131
  }
4257
- var FullNameV1 = z33.array(
4258
- z33.object({
4259
- use: z33.string(),
4260
- family: z33.string(),
4261
- given: z33.array(z33.string())
4132
+ var FullNameV1 = z32.array(
4133
+ z32.object({
4134
+ use: z32.string(),
4135
+ family: z32.string(),
4136
+ given: z32.array(z32.string())
4262
4137
  })
4263
4138
  );
4264
4139
  function omitKeyDeep(obj, keyToRemove) {
@@ -4394,16 +4269,17 @@ function isPageVisible(page, formValues, context) {
4394
4269
  }
4395
4270
  return isConditionMet(page.conditional, formValues, context);
4396
4271
  }
4397
- function omitHiddenFields(fields, formValues, validatorContext, includeHiddenFieldsWithNullValues = false) {
4272
+ function omitHiddenFields(fields, formValues, validatorContext, includeHiddenFieldsWithNullValues = false, declarationContext) {
4398
4273
  const base = (0, import_lodash.cloneDeep)(formValues);
4399
4274
  function fn(prevVisibilityContext) {
4275
+ const visibilityForm = declarationContext ? { ...declarationContext, ...prevVisibilityContext } : prevVisibilityContext;
4400
4276
  const cleaned = (0, import_lodash.omitBy)(base, (value, fieldId) => {
4401
4277
  const fieldConfig = fields.filter((f) => f.id === fieldId);
4402
4278
  if (!fieldConfig.length) {
4403
4279
  return false;
4404
4280
  }
4405
4281
  const isHidden = fieldConfig.every(
4406
- (f) => !isFieldVisible(f, prevVisibilityContext, validatorContext)
4282
+ (f) => !isFieldVisible(f, visibilityForm, validatorContext)
4407
4283
  );
4408
4284
  if (!isHidden) {
4409
4285
  return false;
@@ -4470,8 +4346,10 @@ function omitHiddenAnnotationFields(actionConfig, declaration, annotation, conte
4470
4346
  const annotationFields = getActionAnnotationFields(actionConfig);
4471
4347
  return omitHiddenFields(
4472
4348
  annotationFields,
4473
- { ...declaration, ...annotation },
4474
- context
4349
+ annotation,
4350
+ context,
4351
+ false,
4352
+ declaration
4475
4353
  );
4476
4354
  }
4477
4355
  function deepMerge(currentDocument, actionDocument) {
@@ -4697,7 +4575,16 @@ function aggregateActionDeclarations(event2) {
4697
4575
  if (!requestAction) {
4698
4576
  return declaration;
4699
4577
  }
4700
- return getCompleteActionDeclaration(declaration, event2, requestAction);
4578
+ const declarationWithApprovedCorrection = getCompleteActionDeclaration(
4579
+ declaration,
4580
+ event2,
4581
+ requestAction
4582
+ );
4583
+ return getCompleteActionDeclaration(
4584
+ declarationWithApprovedCorrection,
4585
+ event2,
4586
+ action
4587
+ );
4701
4588
  }
4702
4589
  return getCompleteActionDeclaration(declaration, event2, action);
4703
4590
  }, {});
@@ -5428,11 +5315,11 @@ function validateActionOrder(event2, ctx) {
5428
5315
  }
5429
5316
 
5430
5317
  // ../commons/src/events/EventConfig.ts
5431
- var EventFieldReference = z34.object({ $$event: EventMetadataDateFieldIdInput }).describe(
5318
+ var EventFieldReference = z33.object({ $$event: EventMetadataDateFieldIdInput }).describe(
5432
5319
  "Reference to a field defined in the event metadata, using the field id."
5433
5320
  );
5434
- var _EventConfigBase = z34.object({
5435
- id: z34.string().describe(
5321
+ var _EventConfigBase = z33.object({
5322
+ id: z33.string().describe(
5436
5323
  'Machine-readable identifier of the event (e.g. "birth", "death").'
5437
5324
  ),
5438
5325
  dateOfEvent: FieldReference.or(EventFieldReference).optional().describe(
@@ -5451,20 +5338,23 @@ var _EventConfigBase = z34.object({
5451
5338
  "Summary information displayed in the event overview."
5452
5339
  ),
5453
5340
  label: TranslationConfig.describe("Human-readable label for the event type."),
5454
- actions: z34.array(ActionConfig).describe(
5341
+ actions: z33.array(ActionConfig).describe(
5455
5342
  "Configuration of system-defined actions associated with the event."
5456
5343
  ),
5457
- actionOrder: z34.array(z34.string()).optional().describe(
5344
+ actionOrder: z33.array(z33.string()).optional().describe(
5458
5345
  "Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
5459
5346
  ),
5460
5347
  declaration: DeclarationFormConfig.describe(
5461
5348
  "Configuration of the form used to gather event data."
5462
5349
  ),
5463
- advancedSearch: z34.array(AdvancedSearchConfig).optional().default([]).describe(
5350
+ advancedSearch: z33.array(AdvancedSearchConfig).optional().default([]).describe(
5464
5351
  "Configuration of fields available in the advanced search feature."
5465
5352
  ),
5466
- flags: z34.array(FlagConfig).optional().default([]).describe(
5353
+ flags: z33.array(FlagConfig).optional().default([]).describe(
5467
5354
  "Configuration of flags associated with the actions of this event type."
5355
+ ),
5356
+ analytics: z33.boolean().optional().default(true).describe(
5357
+ "Indicates whether the records of this event type are included in analytics"
5468
5358
  )
5469
5359
  });
5470
5360
  var EventConfig = _EventConfigBase.superRefine((event2, ctx) => {
@@ -5484,7 +5374,7 @@ var definePage = (page) => PageConfig.parse(page);
5484
5374
  var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
5485
5375
 
5486
5376
  // ../commons/src/events/WorkqueueConfig.ts
5487
- var z38 = __toESM(require("zod/v4"));
5377
+ var z37 = __toESM(require("zod/v4"));
5488
5378
 
5489
5379
  // ../commons/src/searchConfigs.ts
5490
5380
  function createSearchConfig(baseField) {
@@ -5685,17 +5575,17 @@ var event = Object.assign(eventFn, {
5685
5575
  });
5686
5576
 
5687
5577
  // ../commons/src/events/WorkqueueColumnConfig.ts
5688
- var z35 = __toESM(require("zod/v4"));
5578
+ var z34 = __toESM(require("zod/v4"));
5689
5579
  var WorkqueueColumnKeysArray = [
5690
5580
  ...EventMetadataKeysArray,
5691
5581
  "title",
5692
5582
  "outbox"
5693
5583
  ];
5694
- var WorkqueueColumnKeys = z35.enum(WorkqueueColumnKeysArray);
5695
- var WorkqueueColumnValue = z35.object({
5584
+ var WorkqueueColumnKeys = z34.enum(WorkqueueColumnKeysArray);
5585
+ var WorkqueueColumnValue = z34.object({
5696
5586
  $event: WorkqueueColumnKeys
5697
5587
  });
5698
- var WorkqueueColumn = z35.object({
5588
+ var WorkqueueColumn = z34.object({
5699
5589
  label: TranslationConfig,
5700
5590
  value: WorkqueueColumnValue
5701
5591
  });
@@ -5706,55 +5596,59 @@ function defineWorkqueuesColumns(workqueueColumns) {
5706
5596
  }
5707
5597
 
5708
5598
  // ../commons/src/events/CountryConfigQueryInput.ts
5709
- var z36 = __toESM(require("zod/v4"));
5710
- var SerializableExact = z36.object({
5711
- type: z36.literal("exact"),
5712
- term: z36.union([z36.string(), SerializedUserField])
5713
- });
5714
- var SerializableWithin = z36.object({
5715
- type: z36.literal("within"),
5716
- location: z36.union([z36.string(), SerializedUserField])
5717
- });
5718
- var SerializedQueryExpression = z36.object({
5719
- eventType: z36.string(),
5720
- status: z36.optional(z36.union([AnyOfStatus, ExactStatus])),
5721
- createdAt: z36.optional(DateCondition),
5722
- updatedAt: z36.optional(DateCondition),
5723
- "legalStatuses.DECLARED.createdAtLocation": z36.optional(SerializableWithin),
5724
- "legalStatuses.DECLARED.createdByRole": z36.optional(AnyOf),
5725
- "legalStatuses.REGISTERED.createdAt": z36.optional(DateCondition),
5726
- "legalStatuses.REGISTERED.createdAtLocation": z36.optional(SerializableWithin),
5727
- "legalStatuses.REGISTERED.createdByRole": z36.optional(AnyOf),
5728
- "legalStatuses.REGISTERED.registrationNumber": z36.optional(Exact),
5729
- createdAtLocation: z36.optional(SerializableWithin),
5730
- updatedAtLocation: z36.optional(SerializableWithin),
5731
- updatedByUserRole: z36.optional(SerializableExact),
5732
- assignedTo: z36.optional(SerializableExact),
5733
- createdBy: z36.optional(SerializableExact),
5599
+ var z35 = __toESM(require("zod/v4"));
5600
+ var SerializableExact = z35.object({
5601
+ type: z35.literal("exact"),
5602
+ term: z35.union([z35.string(), SerializedUserField])
5603
+ });
5604
+ var SerializableWithin = z35.object({
5605
+ type: z35.literal("within"),
5606
+ location: z35.union([z35.string(), SerializedUserField])
5607
+ });
5608
+ var SerializedQueryExpression = z35.object({
5609
+ eventType: z35.string(),
5610
+ status: z35.optional(z35.union([AnyOfStatus, ExactStatus])),
5611
+ createdAt: z35.optional(DateCondition),
5612
+ updatedAt: z35.optional(DateCondition),
5613
+ "legalStatuses.DECLARED.createdAtLocation": z35.optional(SerializableWithin),
5614
+ "legalStatuses.DECLARED.createdByRole": z35.optional(AnyOf),
5615
+ "legalStatuses.REGISTERED.createdAt": z35.optional(DateCondition),
5616
+ "legalStatuses.REGISTERED.createdAtLocation": z35.optional(SerializableWithin),
5617
+ "legalStatuses.REGISTERED.createdByRole": z35.optional(AnyOf),
5618
+ "legalStatuses.REGISTERED.registrationNumber": z35.optional(Exact),
5619
+ createdAtLocation: z35.optional(
5620
+ z35.union([SerializableWithin, SerializableExact])
5621
+ ),
5622
+ updatedAtLocation: z35.optional(
5623
+ z35.union([SerializableWithin, SerializableExact])
5624
+ ),
5625
+ updatedByUserRole: z35.optional(SerializableExact),
5626
+ assignedTo: z35.optional(SerializableExact),
5627
+ createdBy: z35.optional(SerializableExact),
5734
5628
  createdByUserType: ExactUserType,
5735
- updatedBy: z36.optional(SerializableExact),
5736
- trackingId: z36.optional(Exact),
5737
- flags: z36.optional(ContainsFlags),
5629
+ updatedBy: z35.optional(SerializableExact),
5630
+ trackingId: z35.optional(Exact),
5631
+ flags: z35.optional(ContainsFlags),
5738
5632
  data: QueryInput
5739
5633
  }).partial();
5740
- var Or2 = z36.object({
5741
- type: z36.literal("or"),
5742
- clauses: z36.array(SerializedQueryExpression)
5634
+ var Or2 = z35.object({
5635
+ type: z35.literal("or"),
5636
+ clauses: z35.array(SerializedQueryExpression)
5743
5637
  });
5744
- var And2 = z36.object({
5745
- type: z36.literal("and"),
5746
- clauses: z36.array(SerializedQueryExpression)
5638
+ var And2 = z35.object({
5639
+ type: z35.literal("and"),
5640
+ clauses: z35.array(SerializedQueryExpression)
5747
5641
  });
5748
- var CountryConfigQueryType = z36.discriminatedUnion("type", [And2, Or2]);
5749
- var CountryConfigQueryInputType = z36.union([
5642
+ var CountryConfigQueryType = z35.discriminatedUnion("type", [And2, Or2]);
5643
+ var CountryConfigQueryInputType = z35.union([
5750
5644
  SerializedQueryExpression,
5751
5645
  And2,
5752
5646
  Or2
5753
5647
  ]);
5754
5648
 
5755
5649
  // ../commons/src/icons.ts
5756
- var z37 = __toESM(require("zod/v4"));
5757
- var AvailableIcons = z37.enum([
5650
+ var z36 = __toESM(require("zod/v4"));
5651
+ var AvailableIcons = z36.enum([
5758
5652
  "Archived",
5759
5653
  "Assigned",
5760
5654
  "Briefcase",
@@ -5879,16 +5773,16 @@ var mandatoryColumns = defineWorkqueuesColumns([
5879
5773
  value: event.field("updatedAt")
5880
5774
  }
5881
5775
  ]);
5882
- var WorkqueueConfig = z38.object({
5883
- slug: z38.string().describe("Determines the url of the workqueue."),
5776
+ var WorkqueueConfig = z37.object({
5777
+ slug: z37.string().describe("Determines the url of the workqueue."),
5884
5778
  name: TranslationConfig.describe(
5885
5779
  "Title of the workflow (both in navigation and on the page)"
5886
5780
  ),
5887
5781
  query: CountryConfigQueryType,
5888
- action: z38.object({ type: WorkqueueActionType }).optional().describe(
5782
+ action: z37.object({ type: WorkqueueActionType }).optional().describe(
5889
5783
  "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."
5890
5784
  ),
5891
- columns: z38.array(WorkqueueColumn).default(mandatoryColumns),
5785
+ columns: z37.array(WorkqueueColumn).default(mandatoryColumns),
5892
5786
  icon: AvailableIcons,
5893
5787
  emptyMessage: TranslationConfig.optional()
5894
5788
  }).describe("Configuration for workqueue.");
@@ -5896,16 +5790,16 @@ var WorkqueueConfigWithoutQuery = WorkqueueConfig.omit({
5896
5790
  query: true,
5897
5791
  columns: true
5898
5792
  });
5899
- var WorkqueueConfigInput = z38.object({
5900
- slug: z38.string().describe("Determines the url of the workqueue."),
5793
+ var WorkqueueConfigInput = z37.object({
5794
+ slug: z37.string().describe("Determines the url of the workqueue."),
5901
5795
  name: TranslationConfig.describe(
5902
5796
  "Title of the workflow (both in navigation and on the page)"
5903
5797
  ),
5904
5798
  query: CountryConfigQueryInputType,
5905
- action: z38.object({ type: WorkqueueActionType }).optional().describe(
5799
+ action: z37.object({ type: WorkqueueActionType }).optional().describe(
5906
5800
  "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."
5907
5801
  ),
5908
- columns: z38.array(WorkqueueColumn).default(mandatoryColumns),
5802
+ columns: z37.array(WorkqueueColumn).default(mandatoryColumns),
5909
5803
  icon: AvailableIcons,
5910
5804
  emptyMessage: TranslationConfig.optional()
5911
5805
  });
@@ -5914,13 +5808,26 @@ function defineWorkqueue(workqueueInput) {
5914
5808
  const query = "type" in queryInput ? queryInput : { type: "and", clauses: [queryInput] };
5915
5809
  return WorkqueueConfig.parse({ ...workqueueInput, query });
5916
5810
  }
5811
+ function warnOnConfigurationIssues(workqueue) {
5812
+ if (workqueue.actions) {
5813
+ console.warn(
5814
+ `
5815
+ ************** WARNING **************
5816
+ 'actions' property is deprecated, but used on workqueue: '${workqueue.slug}'.
5817
+ Use 'action' property instead!
5818
+ ************** WARNING **************
5819
+ `
5820
+ );
5821
+ }
5822
+ }
5917
5823
  function defineWorkqueues(workqueues) {
5824
+ workqueues.forEach(warnOnConfigurationIssues);
5918
5825
  return workqueues.map((workqueue) => defineWorkqueue(workqueue));
5919
5826
  }
5920
- var WorkqueueCountInput = z38.array(
5921
- z38.object({ slug: z38.string(), query: QueryType })
5827
+ var WorkqueueCountInput = z37.array(
5828
+ z37.object({ slug: z37.string(), query: QueryType })
5922
5829
  );
5923
- var WorkqueueCountOutput = z38.record(z38.string(), z38.number());
5830
+ var WorkqueueCountOutput = z37.record(z37.string(), z37.number());
5924
5831
 
5925
5832
  // ../commons/src/events/workqueueDefaultColumns.ts
5926
5833
  var defaultWorkqueueColumns = [
@@ -5943,18 +5850,18 @@ var defaultWorkqueueColumns = [
5943
5850
  ];
5944
5851
 
5945
5852
  // ../commons/src/events/Draft.ts
5946
- var z40 = __toESM(require("zod/v4"));
5853
+ var z39 = __toESM(require("zod/v4"));
5947
5854
 
5948
5855
  // ../commons/src/events/ActionInput.ts
5949
- var z39 = __toESM(require("zod/v4"));
5950
- var BaseActionInput = z39.object({
5856
+ var z38 = __toESM(require("zod/v4"));
5857
+ var BaseActionInput = z38.object({
5951
5858
  eventId: UUID,
5952
- transactionId: z39.string(),
5859
+ transactionId: z38.string(),
5953
5860
  declaration: ActionUpdate.default({}),
5954
5861
  annotation: ActionUpdate.optional(),
5955
5862
  originalActionId: UUID.optional(),
5956
5863
  // should not be part of base action.
5957
- keepAssignment: z39.boolean().optional(),
5864
+ keepAssignment: z38.boolean().optional(),
5958
5865
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
5959
5866
  // @TODO: createdAtLocation should be limited to actions that system users can perform. For normal users, it should not be part of the base action.
5960
5867
  createdAtLocation: UUID.nullish().describe(
@@ -5962,8 +5869,8 @@ var BaseActionInput = z39.object({
5962
5869
  )
5963
5870
  });
5964
5871
  var CreateActionInput = BaseActionInput.extend(
5965
- z39.object({
5966
- type: z39.literal(ActionType.CREATE).default(ActionType.CREATE),
5872
+ z38.object({
5873
+ type: z38.literal(ActionType.CREATE).default(ActionType.CREATE),
5967
5874
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
5968
5875
  createdAtLocation: UUID.nullish().describe(
5969
5876
  "A valid office location ID. This is required for system users performing actions. The provided location must be a leaf-location, i.e. it must not have any children locations."
@@ -5971,14 +5878,14 @@ var CreateActionInput = BaseActionInput.extend(
5971
5878
  }).shape
5972
5879
  );
5973
5880
  var RegisterActionInput = BaseActionInput.extend(
5974
- z39.strictObject({
5975
- type: z39.literal(ActionType.REGISTER).default(ActionType.REGISTER),
5976
- registrationNumber: z39.string().optional()
5881
+ z38.strictObject({
5882
+ type: z38.literal(ActionType.REGISTER).default(ActionType.REGISTER),
5883
+ registrationNumber: z38.string().optional()
5977
5884
  }).shape
5978
5885
  );
5979
5886
  var NotifyActionInput = BaseActionInput.extend(
5980
- z39.object({
5981
- type: z39.literal(ActionType.NOTIFY).default(ActionType.NOTIFY),
5887
+ z38.object({
5888
+ type: z38.literal(ActionType.NOTIFY).default(ActionType.NOTIFY),
5982
5889
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
5983
5890
  createdAtLocation: UUID.nullish().describe(
5984
5891
  "A valid office location ID. This is required for system users performing actions. The provided location must be a leaf-location, i.e. it must not have any children locations."
@@ -5994,100 +5901,100 @@ var NotifyActionInput = BaseActionInput.extend(
5994
5901
  }
5995
5902
  });
5996
5903
  var DeclareActionInput = BaseActionInput.extend(
5997
- z39.object({
5998
- type: z39.literal(ActionType.DECLARE).default(ActionType.DECLARE)
5904
+ z38.object({
5905
+ type: z38.literal(ActionType.DECLARE).default(ActionType.DECLARE)
5999
5906
  }).shape
6000
5907
  );
6001
5908
  var EditActionInput = BaseActionInput.extend(
6002
- z39.object({
6003
- type: z39.literal(ActionType.EDIT).default(ActionType.EDIT),
6004
- content: z39.object({
6005
- comment: z39.string().describe("Comment for the edit action.").optional()
5909
+ z38.object({
5910
+ type: z38.literal(ActionType.EDIT).default(ActionType.EDIT),
5911
+ content: z38.object({
5912
+ comment: z38.string().describe("Comment for the edit action.").optional()
6006
5913
  })
6007
5914
  }).shape
6008
5915
  );
6009
5916
  var PrintCertificateActionInput = BaseActionInput.extend(
6010
- z39.object({
6011
- type: z39.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE),
5917
+ z38.object({
5918
+ type: z38.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE),
6012
5919
  content: PrintContent.optional()
6013
5920
  }).shape
6014
5921
  );
6015
5922
  var RejectDeclarationActionInput = BaseActionInput.extend(
6016
- z39.object({
6017
- type: z39.literal(ActionType.REJECT).default(ActionType.REJECT),
5923
+ z38.object({
5924
+ type: z38.literal(ActionType.REJECT).default(ActionType.REJECT),
6018
5925
  content: ReasonContent
6019
5926
  }).shape
6020
5927
  );
6021
5928
  var DuplicateDetectedActionInput = BaseActionInput.extend(
6022
- z39.object({
6023
- type: z39.literal(ActionType.DUPLICATE_DETECTED).default(ActionType.DUPLICATE_DETECTED),
6024
- content: z39.object({
6025
- duplicates: z39.array(PotentialDuplicate)
5929
+ z38.object({
5930
+ type: z38.literal(ActionType.DUPLICATE_DETECTED).default(ActionType.DUPLICATE_DETECTED),
5931
+ content: z38.object({
5932
+ duplicates: z38.array(PotentialDuplicate)
6026
5933
  })
6027
5934
  }).shape
6028
5935
  );
6029
5936
  var MarkAsDuplicateActionInput = BaseActionInput.extend(
6030
- z39.object({
6031
- type: z39.literal(ActionType.MARK_AS_DUPLICATE).default(ActionType.MARK_AS_DUPLICATE),
6032
- content: z39.object({
5937
+ z38.object({
5938
+ type: z38.literal(ActionType.MARK_AS_DUPLICATE).default(ActionType.MARK_AS_DUPLICATE),
5939
+ content: z38.object({
6033
5940
  duplicateOf: UUID
6034
5941
  }).optional()
6035
5942
  }).shape
6036
5943
  );
6037
5944
  var MarkNotDuplicateActionInput = BaseActionInput.extend(
6038
- z39.object({
6039
- type: z39.literal(ActionType.MARK_AS_NOT_DUPLICATE).default(ActionType.MARK_AS_NOT_DUPLICATE)
5945
+ z38.object({
5946
+ type: z38.literal(ActionType.MARK_AS_NOT_DUPLICATE).default(ActionType.MARK_AS_NOT_DUPLICATE)
6040
5947
  }).shape
6041
5948
  );
6042
5949
  var ArchiveActionInput = BaseActionInput.extend(
6043
- z39.object({
6044
- type: z39.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
5950
+ z38.object({
5951
+ type: z38.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
6045
5952
  content: ReasonContent
6046
5953
  }).shape
6047
5954
  );
6048
5955
  var AssignActionInput = BaseActionInput.extend(
6049
- z39.object({
6050
- type: z39.literal(ActionType.ASSIGN),
6051
- assignedTo: z39.string()
5956
+ z38.object({
5957
+ type: z38.literal(ActionType.ASSIGN),
5958
+ assignedTo: z38.string()
6052
5959
  }).shape
6053
5960
  );
6054
5961
  var UnassignActionInput = BaseActionInput.extend(
6055
- z39.object({
6056
- type: z39.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
6057
- assignedTo: z39.literal(null).default(null)
5962
+ z38.object({
5963
+ type: z38.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
5964
+ assignedTo: z38.literal(null).default(null)
6058
5965
  }).shape
6059
5966
  );
6060
5967
  var RequestCorrectionActionInput = BaseActionInput.extend(
6061
- z39.object({
6062
- type: z39.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
5968
+ z38.object({
5969
+ type: z38.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
6063
5970
  }).shape
6064
5971
  );
6065
5972
  var RejectCorrectionActionInput = BaseActionInput.extend(
6066
- z39.object({
6067
- requestId: z39.string(),
6068
- type: z39.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION),
5973
+ z38.object({
5974
+ requestId: z38.string(),
5975
+ type: z38.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION),
6069
5976
  content: ReasonContent
6070
5977
  }).shape
6071
5978
  );
6072
5979
  var ApproveCorrectionActionInput = BaseActionInput.extend(
6073
- z39.object({
6074
- requestId: z39.string(),
6075
- type: z39.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
5980
+ z38.object({
5981
+ requestId: z38.string(),
5982
+ type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
6076
5983
  }).shape
6077
5984
  );
6078
5985
  var ReadActionInput = BaseActionInput.extend(
6079
- z39.object({
6080
- type: z39.literal(ActionType.READ).default(ActionType.READ)
5986
+ z38.object({
5987
+ type: z38.literal(ActionType.READ).default(ActionType.READ)
6081
5988
  }).shape
6082
5989
  );
6083
- var DeleteActionInput = z39.object({ eventId: UUID });
5990
+ var DeleteActionInput = z38.object({ eventId: UUID });
6084
5991
  var CustomActionInput = BaseActionInput.extend(
6085
- z39.object({
6086
- type: z39.literal(ActionType.CUSTOM).default(ActionType.CUSTOM),
6087
- customActionType: z39.string().describe("Name of the custom action.")
5992
+ z38.object({
5993
+ type: z38.literal(ActionType.CUSTOM).default(ActionType.CUSTOM),
5994
+ customActionType: z38.string().describe("Name of the custom action.")
6088
5995
  }).shape
6089
5996
  );
6090
- var ActionInput = z39.discriminatedUnion("type", [
5997
+ var ActionInput = z38.discriminatedUnion("type", [
6091
5998
  CreateActionInput.meta({ id: "CreateActionInput" }),
6092
5999
  RegisterActionInput.meta({ id: "RegisterActionInput" }),
6093
6000
  NotifyActionInput.meta({ id: "NotifyActionInput" }),
@@ -6123,11 +6030,11 @@ var ActionInput = z39.discriminatedUnion("type", [
6123
6030
  });
6124
6031
 
6125
6032
  // ../commons/src/events/Draft.ts
6126
- var Draft = z40.object({
6033
+ var Draft = z39.object({
6127
6034
  id: UUID,
6128
6035
  eventId: UUID,
6129
- transactionId: z40.string(),
6130
- createdAt: z40.string().datetime(),
6036
+ transactionId: z39.string(),
6037
+ createdAt: z39.string().datetime(),
6131
6038
  action: ActionBase.extend({
6132
6039
  type: ActionTypes.exclude([ActionTypes.enum.DELETE])
6133
6040
  }).omit({ id: true, createdAtLocation: true })
@@ -6136,7 +6043,7 @@ var Draft = z40.object({
6136
6043
  );
6137
6044
  var DraftInput = BaseActionInput.extend({
6138
6045
  type: ActionTypes.exclude([ActionTypes.enum.DELETE]),
6139
- status: z40.enum([
6046
+ status: z39.enum([
6140
6047
  ActionStatus.Requested,
6141
6048
  ActionStatus.Accepted,
6142
6049
  ActionStatus.Rejected
@@ -6144,27 +6051,27 @@ var DraftInput = BaseActionInput.extend({
6144
6051
  });
6145
6052
 
6146
6053
  // ../commons/src/events/EventInput.ts
6147
- var z41 = __toESM(require("zod/v4"));
6054
+ var z40 = __toESM(require("zod/v4"));
6148
6055
  var import_uuid10 = require("uuid");
6149
- var EventInput = z41.object({
6150
- transactionId: z41.string(),
6151
- type: z41.string(),
6056
+ var EventInput = z40.object({
6057
+ transactionId: z40.string(),
6058
+ type: z40.string(),
6152
6059
  createdAtLocation: UUID.nullish().describe(
6153
6060
  "Location where the event occurred. Required for system users."
6154
6061
  )
6155
6062
  }).meta({ default: { transactionId: (0, import_uuid10.v4)(), type: "birth" } });
6156
6063
 
6157
6064
  // ../commons/src/events/EventDocument.ts
6158
- var z42 = __toESM(require("zod/v4"));
6159
- var EventDocument = z42.object({
6065
+ var z41 = __toESM(require("zod/v4"));
6066
+ var EventDocument = z41.object({
6160
6067
  id: UUID.describe("Unique identifier of the event."),
6161
- type: z42.string().describe("Type of the event (e.g. birth, death, marriage)."),
6162
- createdAt: z42.string().datetime().describe("Timestamp indicating when the event was created."),
6163
- updatedAt: z42.string().datetime().describe(
6068
+ type: z41.string().describe("Type of the event (e.g. birth, death, marriage)."),
6069
+ createdAt: z41.string().datetime().describe("Timestamp indicating when the event was created."),
6070
+ updatedAt: z41.string().datetime().describe(
6164
6071
  "Timestamp of the last update, excluding changes from actions."
6165
6072
  ),
6166
- actions: z42.array(Action).describe("Ordered list of actions associated with the event."),
6167
- trackingId: z42.string().describe(
6073
+ actions: z41.array(Action).describe("Ordered list of actions associated with the event."),
6074
+ trackingId: z41.string().describe(
6168
6075
  "System-generated tracking identifier used to look up the event."
6169
6076
  )
6170
6077
  }).meta({ id: "EventDocument" });
@@ -6215,6 +6122,7 @@ function getDeclarationActionCreationMetadata(actionType, actions) {
6215
6122
  var updateActions = ActionTypes.extract([
6216
6123
  ActionType.CREATE,
6217
6124
  ActionType.NOTIFY,
6125
+ ActionType.EDIT,
6218
6126
  ActionType.DECLARE,
6219
6127
  ActionType.REGISTER,
6220
6128
  ActionType.REJECT,
@@ -6645,9 +6553,10 @@ var IGNORED_EVENT_TYPES = [
6645
6553
  "tennis-club-membership",
6646
6554
  "library-membership",
6647
6555
  "child-onboarding",
6648
- "digital-identity"
6556
+ "digital-identity",
6557
+ "event-with-optional-address"
6649
6558
  ];
6650
- function warnOnConfigurationIssues(config) {
6559
+ function warnOnConfigurationIssues2(config) {
6651
6560
  const eventId = config.id;
6652
6561
  if (IGNORED_EVENT_TYPES.includes(eventId)) {
6653
6562
  return;
@@ -6670,7 +6579,7 @@ function warnOnConfigurationIssues(config) {
6670
6579
  }
6671
6580
  var defineConfig = (config) => {
6672
6581
  const input = EventConfig.parse(config);
6673
- warnOnConfigurationIssues(input);
6582
+ warnOnConfigurationIssues2(input);
6674
6583
  return input;
6675
6584
  };
6676
6585
 
@@ -9062,9 +8971,9 @@ var digitalIdentityEvent = defineConfig({
9062
8971
  });
9063
8972
 
9064
8973
  // ../commons/src/events/test.utils.ts
9065
- var z43 = __toESM(require("zod/v4"));
8974
+ var z42 = __toESM(require("zod/v4"));
9066
8975
  var TEST_SYSTEM_IANA_TIMEZONE = "Asia/Dhaka";
9067
- var TestUserRole = z43.enum([
8976
+ var TestUserRole = z42.enum([
9068
8977
  "FIELD_AGENT",
9069
8978
  "LOCAL_REGISTRAR",
9070
8979
  "LOCAL_SYSTEM_ADMIN",
@@ -9235,6 +9144,7 @@ function mapFieldTypeToMockValue(field3, i, rng, administrativeHierarchy) {
9235
9144
  type: "image/png"
9236
9145
  };
9237
9146
  case FieldType.SEARCH:
9147
+ case FieldType.AUTOCOMPLETE:
9238
9148
  case FieldType.HTTP:
9239
9149
  return {
9240
9150
  error: null,
@@ -9914,26 +9824,26 @@ function isFieldConfigDefaultValue(value) {
9914
9824
  var import_lodash6 = require("lodash");
9915
9825
 
9916
9826
  // ../commons/src/events/locations.ts
9917
- var z44 = __toESM(require("zod/v4"));
9918
- var LocationTypeV1 = z44.enum([
9827
+ var z43 = __toESM(require("zod/v4"));
9828
+ var LocationTypeV1 = z43.enum([
9919
9829
  "ADMIN_STRUCTURE",
9920
9830
  "CRVS_OFFICE",
9921
9831
  "HEALTH_FACILITY"
9922
9832
  ]);
9923
- var AdministrativeArea = z44.object({
9833
+ var AdministrativeArea = z43.object({
9924
9834
  id: UUID,
9925
- name: z44.string(),
9926
- externalId: z44.string().nullish(),
9835
+ name: z43.string(),
9836
+ externalId: z43.string().nullish(),
9927
9837
  parentId: UUID.nullable(),
9928
- validUntil: z44.iso.datetime().nullable()
9838
+ validUntil: z43.iso.datetime().nullable()
9929
9839
  });
9930
- var Location = z44.object({
9840
+ var Location = z43.object({
9931
9841
  id: UUID,
9932
- name: z44.string(),
9933
- externalId: z44.string().nullish(),
9842
+ name: z43.string(),
9843
+ externalId: z43.string().nullish(),
9934
9844
  administrativeAreaId: UUID.nullable(),
9935
- validUntil: z44.iso.datetime().nullable(),
9936
- locationType: z44.string().nullable()
9845
+ validUntil: z43.iso.datetime().nullable(),
9846
+ locationType: z43.string().nullable()
9937
9847
  });
9938
9848
  function matchesJurisdictionFilter(locationIds, filter, user2) {
9939
9849
  if (!locationIds) {
@@ -10033,7 +9943,7 @@ var ACTION_SCOPE_MAP = {
10033
9943
  [ActionType.NOTIFY]: ["record.notify"],
10034
9944
  [ActionType.DECLARE]: ["record.declare", "record.register"],
10035
9945
  [ActionType.EDIT]: ["record.edit"],
10036
- [ActionType.DELETE]: ["record.declare"],
9946
+ [ActionType.DELETE]: ["record.declare", "record.notify"],
10037
9947
  [ActionType.REGISTER]: ["record.register"],
10038
9948
  [ActionType.PRINT_CERTIFICATE]: ["record.print-certified-copies"],
10039
9949
  [ActionType.REQUEST_CORRECTION]: [
@@ -10085,14 +9995,18 @@ function isActionInScope({
10085
9995
  acceptedScopes,
10086
9996
  scopes
10087
9997
  });
10088
- const canAccess = userCanAccessEventWithScopes(event2, matchingScopes, {
10089
- id: currentUser.id,
10090
- primaryOfficeId: currentUser.primaryOfficeId,
10091
- administrativeAreaId: currentUser.administrativeAreaId ?? null,
10092
- role: currentUser.role,
10093
- signature: currentUser.signature,
10094
- type: currentUser.type
10095
- });
9998
+ const canAccess = userCanAccessEventWithScopes(
9999
+ event2,
10000
+ matchingScopes,
10001
+ {
10002
+ id: currentUser.id,
10003
+ primaryOfficeId: currentUser.primaryOfficeId,
10004
+ administrativeAreaId: currentUser.administrativeAreaId ?? null,
10005
+ role: currentUser.role,
10006
+ signature: currentUser.signature,
10007
+ type: currentUser.type
10008
+ }
10009
+ );
10096
10010
  return canAccess;
10097
10011
  }
10098
10012
 
@@ -10109,17 +10023,50 @@ function userDeserializer(serializedUserField, user2) {
10109
10023
  `Deserializer for ${serializedUserField.$userField} is not implemented yet`
10110
10024
  );
10111
10025
  }
10112
- return user2[serializedUserField.$userField] ?? void 0;
10026
+ const value = user2[serializedUserField.$userField];
10027
+ return typeof value === "string" ? value : void 0;
10113
10028
  }
10114
10029
  function isDefined(value) {
10115
10030
  return value !== void 0;
10116
10031
  }
10032
+ function serializeLocationField(expression, user2) {
10033
+ if (expression.type === "exact") {
10034
+ return userDeserializer(expression.term, user2);
10035
+ }
10036
+ if (expression.type === "within") {
10037
+ return userDeserializer(expression.location, user2);
10038
+ }
10039
+ return void 0;
10040
+ }
10041
+ function deserializeExpression(expression, user2) {
10042
+ if (expression.type === "exact") {
10043
+ const term = userDeserializer(expression.term, user2);
10044
+ if (!term) {
10045
+ return void 0;
10046
+ }
10047
+ return {
10048
+ ...expression,
10049
+ term
10050
+ };
10051
+ }
10052
+ if (expression.type === "within") {
10053
+ const location = userDeserializer(expression.location, user2);
10054
+ if (!location) {
10055
+ return void 0;
10056
+ }
10057
+ return {
10058
+ ...expression,
10059
+ location
10060
+ };
10061
+ }
10062
+ return void 0;
10063
+ }
10117
10064
  function deserializeQueryExpression(expression, user2) {
10118
10065
  const assignedTo = expression.assignedTo ? userDeserializer(expression.assignedTo.term, user2) : void 0;
10119
10066
  const createdBy = expression.createdBy ? userDeserializer(expression.createdBy.term, user2) : void 0;
10120
10067
  const updatedBy = expression.updatedBy ? userDeserializer(expression.updatedBy.term, user2) : void 0;
10121
- const createdAtLocation = expression.createdAtLocation ? userDeserializer(expression.createdAtLocation.location, user2) : void 0;
10122
- const updatedAtLocation = expression.updatedAtLocation ? userDeserializer(expression.updatedAtLocation.location, user2) : void 0;
10068
+ const createdAtLocation = expression.createdAtLocation ? serializeLocationField(expression.createdAtLocation, user2) : void 0;
10069
+ const updatedAtLocation = expression.updatedAtLocation ? serializeLocationField(expression.updatedAtLocation, user2) : void 0;
10123
10070
  const updatedByUserRole = expression.updatedByUserRole ? userDeserializer(expression.updatedByUserRole.term, user2) : void 0;
10124
10071
  const declaredLocation = expression["legalStatuses.DECLARED.createdAtLocation"] ? userDeserializer(
10125
10072
  expression["legalStatuses.DECLARED.createdAtLocation"].location,
@@ -10138,8 +10085,8 @@ function deserializeQueryExpression(expression, user2) {
10138
10085
  ...expression.updatedByUserRole,
10139
10086
  term: updatedByUserRole
10140
10087
  } : void 0,
10141
- createdAtLocation: expression.createdAtLocation && isDefined(createdAtLocation) ? { ...expression.createdAtLocation, location: createdAtLocation } : void 0,
10142
- updatedAtLocation: expression.updatedAtLocation && isDefined(updatedAtLocation) ? { ...expression.updatedAtLocation, location: updatedAtLocation } : void 0,
10088
+ createdAtLocation: expression.createdAtLocation && isDefined(createdAtLocation) ? deserializeExpression(expression.createdAtLocation, user2) : void 0,
10089
+ updatedAtLocation: expression.updatedAtLocation && isDefined(updatedAtLocation) ? deserializeExpression(expression.updatedAtLocation, user2) : void 0,
10143
10090
  ["legalStatuses.DECLARED.createdAtLocation"]: expression["legalStatuses.DECLARED.createdAtLocation"] && isDefined(declaredLocation) ? {
10144
10091
  ...expression["legalStatuses.DECLARED.createdAtLocation"],
10145
10092
  location: declaredLocation