@opencrvs/toolkit 2.1.0-rc.5135dc7 → 2.1.0-rc.517ffcd

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 (52) hide show
  1. package/build.sh +3 -0
  2. package/create-countryconfig/index.js +114 -66
  3. package/create-countryconfig/node_modules/.bin/degit +21 -0
  4. package/create-countryconfig/package.json +4 -1
  5. package/dist/application-config/index.js +242 -207
  6. package/dist/cli.js +556 -81
  7. package/dist/commons/api/router.d.ts +407 -50
  8. package/dist/commons/conditionals/conditionals.d.ts +6 -6
  9. package/dist/commons/conditionals/validate.d.ts +6 -2
  10. package/dist/commons/events/ActionDocument.d.ts +4 -4
  11. package/dist/commons/events/ActionInput.d.ts +4 -4
  12. package/dist/commons/events/AdvancedSearchConfig.d.ts +12 -0
  13. package/dist/commons/events/EventDocument.d.ts +470 -2
  14. package/dist/commons/events/EventMetadata.d.ts +1 -11
  15. package/dist/commons/events/EventStatus.d.ts +19 -0
  16. package/dist/commons/events/FieldConfig.d.ts +18 -0
  17. package/dist/commons/events/FieldTypeMapping.d.ts +15 -15
  18. package/dist/commons/events/locations.d.ts +59 -10
  19. package/dist/commons/events/test.utils.d.ts +8 -4
  20. package/dist/commons/events/utils.d.ts +2 -2
  21. package/dist/commons/notification/UserNotifications.d.ts +28 -13
  22. package/dist/commons/notification/dispatch.d.ts +15 -0
  23. package/dist/commons/notification/index.d.ts +1 -0
  24. package/dist/conditionals/index.js +77 -55
  25. package/dist/environment/questions.d.ts.map +1 -1
  26. package/dist/environment/questions.js +20 -14
  27. package/dist/environment/setup-environment.js +1 -1
  28. package/dist/events/index.js +839 -775
  29. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
  30. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  31. package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
  32. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +3 -0
  33. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -0
  34. package/dist/migrations/v2.1/add-recovery-link-notifications.js +530 -0
  35. package/dist/migrations/v2.1/index.d.ts.map +1 -1
  36. package/dist/migrations/v2.1/index.js +469 -0
  37. package/dist/notification/index.js +911 -1359
  38. package/dist/scopes/index.d.ts +71 -1
  39. package/dist/scopes/index.js +77 -55
  40. package/dist/telemetry/index.d.ts +48 -0
  41. package/dist/telemetry/index.d.ts.map +1 -0
  42. package/dist/telemetry/index.js +42 -0
  43. package/dist/templates/charts-values/opencrvs-services/values.yaml +1 -1
  44. package/dist/templates/charts-values/opentelemetry/values.yaml +22 -0
  45. package/dist/templates/charts-values/traefik/values.yaml +23 -9
  46. package/dist/templates/inventory/inventory.template.yml +1 -3
  47. package/opencrvs-toolkit-2.1.0-rc.517ffcd.tgz +0 -0
  48. package/package.json +2 -1
  49. package/tsconfig.tsbuildinfo +1 -1
  50. package/dist/templates/inventory/production.example.yml +0 -77
  51. package/dist/templates/inventory/qa.example.yml +0 -48
  52. package/opencrvs-toolkit-2.1.0-rc.5135dc7.tgz +0 -0
@@ -38,23 +38,17 @@ __export(notification_exports, {
38
38
  triggerUserEventNotification: () => triggerUserEventNotification
39
39
  });
40
40
  module.exports = __toCommonJS(notification_exports);
41
- var z46 = __toESM(require("zod/v4"));
42
-
43
- // ../commons/src/url.ts
44
- function joinUrl(base, path) {
45
- const baseWithSlash = base.endsWith("/") ? base : base + "/";
46
- return new URL(path, baseWithSlash);
47
- }
41
+ var z47 = __toESM(require("zod/v4"));
48
42
 
49
43
  // ../commons/src/events/AuditLog.ts
50
- var z8 = __toESM(require("zod/v4"));
44
+ var z9 = __toESM(require("zod/v4"));
51
45
 
52
46
  // ../commons/src/authentication.ts
53
47
  var import_jwt_decode = __toESM(require("jwt-decode"));
54
- var z7 = __toESM(require("zod/v4"));
48
+ var z8 = __toESM(require("zod/v4"));
55
49
 
56
50
  // ../commons/src/scopes.ts
57
- var z6 = __toESM(require("zod/v4"));
51
+ var z7 = __toESM(require("zod/v4"));
58
52
  var qs = __toESM(require("qs"));
59
53
 
60
54
  // ../commons/src/uuid.ts
@@ -175,9 +169,6 @@ var META_ACTIONS = [
175
169
  ActionType.UNASSIGN,
176
170
  ActionType.READ
177
171
  ];
178
- function isMetaAction(actionType) {
179
- return META_ACTIONS.includes(actionType);
180
- }
181
172
 
182
173
  // ../commons/src/events/ActionStatus.ts
183
174
  var ActionStatus = {
@@ -316,12 +307,22 @@ var ActionFlagConfig = z5.object({
316
307
  description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
317
308
  });
318
309
 
310
+ // ../commons/src/events/EventStatus.ts
311
+ var z6 = __toESM(require("zod/v4"));
312
+ var EventStatus = z6.enum([
313
+ "CREATED",
314
+ "NOTIFIED",
315
+ "DECLARED",
316
+ "REGISTERED",
317
+ "ARCHIVED"
318
+ ]);
319
+
319
320
  // ../commons/src/scopes.ts
320
- var JurisdictionFilter = z6.enum(["administrativeArea", "location", "all"]).describe(
321
+ var JurisdictionFilter = z7.enum(["administrativeArea", "location", "all"]).describe(
321
322
  "Filters based on user jurisdiction relative to their office location in hierarchy."
322
323
  );
323
- var UserFilter = z6.enum(["user"]).describe("Filters based on the user. Limits to self.");
324
- var RecordScopeTypeV2 = z6.enum([
324
+ var UserFilter = z7.enum(["user"]).describe("Filters based on the user. Limits to self.");
325
+ var RecordScopeTypeV2 = z7.enum([
325
326
  "record.search",
326
327
  "record.create",
327
328
  "record.read",
@@ -339,12 +340,17 @@ var RecordScopeTypeV2 = z6.enum([
339
340
  "record.unassign-others",
340
341
  "record.custom-action"
341
342
  ]);
342
- var PlainScopeType = z6.enum([
343
+ var PlainScopeType = z7.enum([
343
344
  // Misc. system scopes
344
345
  "bypassratelimit",
345
346
  "record.reindex",
346
347
  "user.data-seeding",
347
348
  "integration.create",
349
+ // Reading an integration's audit log. Deliberately separate from
350
+ // 'integration.create' so read-only oversight can be granted on its own, and
351
+ // deliberately option-less: system clients have no office and no
352
+ // administrative area, so jurisdiction options would have nothing to bind to.
353
+ "integration.audit.read",
348
354
  "record.import",
349
355
  "config.update-all",
350
356
  "location.edit",
@@ -359,15 +365,21 @@ var PlainScopeType = z6.enum([
359
365
  "record.confirm-registration",
360
366
  "record.reject-registration"
361
367
  ]);
362
- var scopeByEvent = z6.preprocess(
368
+ var scopeByEvent = z7.preprocess(
363
369
  (val) => val === void 0 ? void 0 : [val].flat(),
364
- z6.array(z6.string()).optional()
370
+ z7.array(z7.string()).optional()
365
371
  ).describe("Event type, e.g. birth, death");
366
- var userRole = z6.preprocess(
372
+ var scopeByStatus = z7.preprocess(
367
373
  (val) => val === void 0 ? void 0 : [val].flat(),
368
- z6.array(z6.string()).optional()
374
+ z7.array(EventStatus).optional()
375
+ ).describe(
376
+ "Restricts the scope to records currently in one of these statuses."
377
+ );
378
+ var userRole = z7.preprocess(
379
+ (val) => val === void 0 ? void 0 : [val].flat(),
380
+ z7.array(z7.string()).optional()
369
381
  ).describe("User role, e.g. admin, field agent");
370
- var scopeOptionsPlaceEvent = z6.object({
382
+ var scopeOptionsPlaceEvent = z7.object({
371
383
  event: scopeByEvent,
372
384
  placeOfEvent: JurisdictionFilter.optional()
373
385
  }).describe("Options applicable to all record scopes.");
@@ -375,7 +387,8 @@ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
375
387
  notifiedIn: JurisdictionFilter.optional(),
376
388
  notifiedBy: UserFilter.optional(),
377
389
  declaredIn: JurisdictionFilter.optional(),
378
- declaredBy: UserFilter.optional()
390
+ declaredBy: UserFilter.optional(),
391
+ status: scopeByStatus
379
392
  }).describe("Options applicable to actions that may take place after DECLARE");
380
393
  var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
381
394
  registeredIn: JurisdictionFilter.optional(),
@@ -385,31 +398,31 @@ var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
385
398
  "Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
386
399
  );
387
400
  var CustomActionScopeOptions = AllRecordScopeOptions.extend({
388
- customActionTypes: z6.preprocess(
401
+ customActionTypes: z7.preprocess(
389
402
  (val) => val === void 0 ? void 0 : [val].flat(),
390
- z6.array(z6.string()).optional()
403
+ z7.array(z7.string()).optional()
391
404
  ).describe("Allowed custom action types")
392
405
  });
393
- var AccessLevelOptions = z6.object({
406
+ var AccessLevelOptions = z7.object({
394
407
  accessLevel: JurisdictionFilter.optional()
395
408
  });
396
409
  var AllUserScopeOptions = AccessLevelOptions.extend({
397
410
  role: userRole.optional()
398
411
  });
399
- var WorkqueueOrDashboardOptions = z6.object({
400
- ids: z6.preprocess(
412
+ var WorkqueueOrDashboardOptions = z7.object({
413
+ ids: z7.preprocess(
401
414
  (val) => val === void 0 ? void 0 : [val].flat(),
402
- z6.array(z6.string())
415
+ z7.array(z7.string())
403
416
  ).describe("Must contain a list of workqueue or dashboard ids.")
404
417
  });
405
- var AllScopeOptions = z6.object({
418
+ var AllScopeOptions = z7.object({
406
419
  ...AllRecordScopeOptions.shape,
407
420
  ...AccessLevelOptions.shape,
408
421
  ...AllUserScopeOptions.shape,
409
422
  ...WorkqueueOrDashboardOptions.shape
410
423
  });
411
424
  var ScopeOptionKey = AllScopeOptions.keyof();
412
- var ResolvedScopeOptionsPlaceEvent = z6.object({
425
+ var ResolvedScopeOptionsPlaceEvent = z7.object({
413
426
  event: scopeByEvent,
414
427
  placeOfEvent: UUID.nullish()
415
428
  }).describe(
@@ -417,15 +430,15 @@ var ResolvedScopeOptionsPlaceEvent = z6.object({
417
430
  );
418
431
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
419
432
  notifiedIn: UUID.nullish(),
420
- notifiedBy: z6.string().optional(),
433
+ notifiedBy: z7.string().optional(),
421
434
  declaredIn: UUID.nullish(),
422
- declaredBy: z6.string().optional()
435
+ declaredBy: z7.string().optional()
423
436
  }).describe(
424
437
  "Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
425
438
  );
426
439
  var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
427
440
  registeredIn: UUID.nullish(),
428
- registeredBy: z6.string().optional(),
441
+ registeredBy: z7.string().optional(),
429
442
  flags: ContainsFlags.optional()
430
443
  }).describe(
431
444
  "Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
@@ -451,38 +464,38 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
451
464
  "record.unassign-others"
452
465
  ]);
453
466
  var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
454
- templates: z6.preprocess(
467
+ templates: z7.preprocess(
455
468
  (val) => val === void 0 ? void 0 : [val].flat(),
456
- z6.array(z6.string()).optional()
469
+ z7.array(z7.string()).optional()
457
470
  ).describe(
458
471
  "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."
459
472
  )
460
473
  });
461
- var RecordScopeV2 = z6.discriminatedUnion("type", [
462
- z6.object({
474
+ var RecordScopeV2 = z7.discriminatedUnion("type", [
475
+ z7.object({
463
476
  type: ScopesWithPlaceEventOptions,
464
477
  options: scopeOptionsPlaceEvent.optional()
465
478
  }),
466
- z6.object({
479
+ z7.object({
467
480
  type: ScopesWithDeclaredOptions,
468
481
  options: scopeOptionsDeclaredOrNotified.optional()
469
482
  }),
470
- z6.object({
483
+ z7.object({
471
484
  type: ScopesWithFullOptions,
472
485
  options: AllRecordScopeOptions.optional()
473
486
  }),
474
- z6.object({
475
- type: z6.literal("record.custom-action"),
487
+ z7.object({
488
+ type: z7.literal("record.custom-action"),
476
489
  options: CustomActionScopeOptions.optional()
477
490
  }),
478
- z6.object({
479
- type: z6.literal("record.print-certified-copies"),
491
+ z7.object({
492
+ type: z7.literal("record.print-certified-copies"),
480
493
  options: ScopeOptionsPrintCertifiedCopies.optional()
481
494
  })
482
495
  ]).describe(
483
496
  "Scopes used to check user's permission to perform actions on a record."
484
497
  );
485
- var SystemScopeType = z6.enum([
498
+ var SystemScopeType = z7.enum([
486
499
  "organisation.read-locations",
487
500
  "user.read",
488
501
  "user.create",
@@ -496,61 +509,61 @@ var UserScopeType = SystemScopeType.extract([
496
509
  "user.search"
497
510
  ]);
498
511
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
499
- var UserScopeV2 = z6.discriminatedUnion("type", [
500
- z6.object({
512
+ var UserScopeV2 = z7.discriminatedUnion("type", [
513
+ z7.object({
501
514
  type: ScopesWithRoleOption,
502
515
  options: AllUserScopeOptions.optional()
503
516
  }),
504
- z6.object({
517
+ z7.object({
505
518
  type: UserScopeType.extract(["user.read", "user.search"]),
506
519
  options: AccessLevelOptions.optional()
507
520
  })
508
521
  ]);
509
- var ResolvedRecordScopeV2 = z6.discriminatedUnion("type", [
510
- z6.object({
522
+ var ResolvedRecordScopeV2 = z7.discriminatedUnion("type", [
523
+ z7.object({
511
524
  type: ScopesWithPlaceEventOptions,
512
525
  options: ResolvedScopeOptionsPlaceEvent.optional()
513
526
  }),
514
- z6.object({
527
+ z7.object({
515
528
  type: ScopesWithDeclaredOptions,
516
529
  options: ResolvedScopeOptionsDeclared.optional()
517
530
  }),
518
- z6.object({
531
+ z7.object({
519
532
  type: ScopesWithFullOptions,
520
533
  options: ResolvedScopeOptionsFull.optional()
521
534
  }),
522
- z6.object({
523
- type: z6.literal("record.print-certified-copies"),
535
+ z7.object({
536
+ type: z7.literal("record.print-certified-copies"),
524
537
  options: ResolvedScopeOptionsFull.extend({
525
- templates: z6.array(z6.string()).optional()
538
+ templates: z7.array(z7.string()).optional()
526
539
  }).optional()
527
540
  })
528
541
  ]).describe("Resolved scope with location/user IDs instead of filters.");
529
- var Scope = z6.discriminatedUnion("type", [
530
- z6.object({ type: PlainScopeType }),
542
+ var Scope = z7.discriminatedUnion("type", [
543
+ z7.object({ type: PlainScopeType }),
531
544
  ...RecordScopeV2.options,
532
545
  ...UserScopeV2.options,
533
- z6.object({
534
- type: z6.literal("organisation.read-locations"),
546
+ z7.object({
547
+ type: z7.literal("organisation.read-locations"),
535
548
  options: AccessLevelOptions.optional()
536
549
  }),
537
- z6.object({
538
- type: z6.literal("workqueue"),
550
+ z7.object({
551
+ type: z7.literal("workqueue"),
539
552
  options: WorkqueueOrDashboardOptions
540
553
  }),
541
- z6.object({
542
- type: z6.literal("dashboard.view"),
554
+ z7.object({
555
+ type: z7.literal("dashboard.view"),
543
556
  options: WorkqueueOrDashboardOptions
544
557
  })
545
558
  ]);
546
- var ScopeType = z6.enum([
559
+ var ScopeType = z7.enum([
547
560
  ...SystemScopeType.options,
548
561
  ...RecordScopeTypeV2.options,
549
562
  ...PlainScopeType.options,
550
563
  "workqueue",
551
564
  "dashboard.view"
552
565
  ]);
553
- var EncodedScope = z6.string().brand("EncodedScope");
566
+ var EncodedScope = z7.string().brand("EncodedScope");
554
567
  var DEFAULT_SCOPE_OPTIONS = {
555
568
  placeOfEvent: JurisdictionFilter.enum.all,
556
569
  accessLevel: JurisdictionFilter.enum.all,
@@ -560,51 +573,51 @@ var DEFAULT_SCOPE_OPTIONS = {
560
573
  };
561
574
 
562
575
  // ../commons/src/authentication.ts
563
- var TokenUserType = z7.enum(["user", "system"]);
564
- var TokenWithBearer = z7.string().regex(/^Bearer\s/);
576
+ var TokenUserType = z8.enum(["user", "system"]);
577
+ var TokenWithBearer = z8.string().regex(/^Bearer\s/);
565
578
 
566
579
  // ../commons/src/events/AuditLog.ts
567
- var AuditLogEntryBase = z8.object({
568
- id: z8.string(),
569
- clientId: z8.string(),
580
+ var AuditLogEntryBase = z9.object({
581
+ id: z9.string(),
582
+ clientId: z9.string(),
570
583
  clientType: TokenUserType,
571
- createdAt: z8.string()
584
+ createdAt: z9.string()
572
585
  });
573
586
  var EventCreateEntrySchema = AuditLogEntryBase.extend({
574
- operation: z8.literal("event.create"),
575
- requestData: z8.object({
576
- transactionId: z8.string(),
577
- type: z8.string(),
578
- createdAtLocation: z8.string().nullable()
587
+ operation: z9.literal("event.create"),
588
+ requestData: z9.object({
589
+ transactionId: z9.string(),
590
+ type: z9.string(),
591
+ createdAtLocation: z9.string().nullable()
579
592
  }),
580
- responseSummary: z8.object({
581
- eventId: z8.string(),
582
- trackingId: z8.string()
593
+ responseSummary: z9.object({
594
+ eventId: z9.string(),
595
+ trackingId: z9.string()
583
596
  })
584
597
  });
585
598
  var EventGetEntrySchema = AuditLogEntryBase.extend({
586
- operation: z8.literal("event.get"),
587
- requestData: z8.object({ eventId: z8.string() }),
588
- responseSummary: z8.object({
589
- eventType: z8.string(),
590
- trackingId: z8.string()
599
+ operation: z9.literal("event.get"),
600
+ requestData: z9.object({ eventId: z9.string() }),
601
+ responseSummary: z9.object({
602
+ eventType: z9.string(),
603
+ trackingId: z9.string()
591
604
  })
592
605
  });
593
606
  var EventSearchEntrySchema = AuditLogEntryBase.extend({
594
- operation: z8.literal("event.search"),
595
- clientType: z8.literal("system"),
596
- requestData: z8.object({
597
- query: z8.record(z8.string(), z8.unknown()).nullable(),
598
- limit: z8.number().nullable(),
599
- offset: z8.number().nullable()
607
+ operation: z9.literal("event.search"),
608
+ clientType: z9.literal("system"),
609
+ requestData: z9.object({
610
+ query: z9.record(z9.string(), z9.unknown()).nullable(),
611
+ limit: z9.number().nullable(),
612
+ offset: z9.number().nullable()
600
613
  }),
601
- responseSummary: z8.object({
602
- total: z8.number(),
603
- eventIds: z8.array(z8.string())
614
+ responseSummary: z9.object({
615
+ total: z9.number(),
616
+ eventIds: z9.array(z9.string())
604
617
  })
605
618
  });
606
619
  var EventActionEntrySchema = AuditLogEntryBase.extend({
607
- operation: z8.enum([
620
+ operation: z9.enum([
608
621
  "event.actions.notify.request",
609
622
  "event.actions.declare.request",
610
623
  "event.actions.register.request",
@@ -624,159 +637,159 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
624
637
  "event.actions.mark_as_duplicate.request",
625
638
  "event.actions.mark_as_not_duplicate.request"
626
639
  ]),
627
- requestData: z8.object({
628
- eventId: z8.string(),
629
- actionType: z8.string(),
630
- eventType: z8.string(),
631
- trackingId: z8.string(),
632
- transactionId: z8.string()
640
+ requestData: z9.object({
641
+ eventId: z9.string(),
642
+ actionType: z9.string(),
643
+ eventType: z9.string(),
644
+ trackingId: z9.string(),
645
+ transactionId: z9.string()
633
646
  })
634
647
  });
635
648
  var EventCustomActionEntrySchema = AuditLogEntryBase.extend({
636
- operation: z8.literal("event.actions.custom.request"),
637
- requestData: z8.object({
638
- eventId: z8.string(),
639
- actionType: z8.literal(ActionType.CUSTOM),
640
- customAction: z8.string(),
641
- eventType: z8.string(),
642
- trackingId: z8.string(),
643
- transactionId: z8.string()
649
+ operation: z9.literal("event.actions.custom.request"),
650
+ requestData: z9.object({
651
+ eventId: z9.string(),
652
+ actionType: z9.literal(ActionType.CUSTOM),
653
+ customAction: z9.string(),
654
+ eventType: z9.string(),
655
+ trackingId: z9.string(),
656
+ transactionId: z9.string()
644
657
  })
645
658
  });
646
659
  var IntegrationCreateEntrySchema = AuditLogEntryBase.extend({
647
- operation: z8.literal("integrations.create"),
648
- requestData: z8.object({ name: z8.string(), scopes: z8.array(z8.string()) }),
649
- responseSummary: z8.object({ clientId: z8.string() })
660
+ operation: z9.literal("integrations.create"),
661
+ requestData: z9.object({ name: z9.string(), scopes: z9.array(z9.string()) }),
662
+ responseSummary: z9.object({ clientId: z9.string() })
650
663
  });
651
664
  var IntegrationRefreshTokenEntrySchema = AuditLogEntryBase.extend({
652
- operation: z8.literal("integrations.refreshToken"),
653
- requestData: z8.object({ clientId: z8.string() }),
654
- responseSummary: z8.object({ clientId: z8.string() })
665
+ operation: z9.literal("integrations.refreshToken"),
666
+ requestData: z9.object({ clientId: z9.string() }),
667
+ responseSummary: z9.object({ clientId: z9.string() })
655
668
  });
656
669
  var IntegrationDeactivateEntrySchema = AuditLogEntryBase.extend({
657
- operation: z8.literal("integrations.deactivate"),
658
- requestData: z8.object({ id: z8.string() }),
659
- responseSummary: z8.object({ id: z8.string(), status: z8.string() })
670
+ operation: z9.literal("integrations.deactivate"),
671
+ requestData: z9.object({ id: z9.string() }),
672
+ responseSummary: z9.object({ id: z9.string(), status: z9.string() })
660
673
  });
661
674
  var IntegrationActivateEntrySchema = AuditLogEntryBase.extend({
662
- operation: z8.literal("integrations.activate"),
663
- requestData: z8.object({ id: z8.string() }),
664
- responseSummary: z8.object({ id: z8.string(), status: z8.string() })
675
+ operation: z9.literal("integrations.activate"),
676
+ requestData: z9.object({ id: z9.string() }),
677
+ responseSummary: z9.object({ id: z9.string(), status: z9.string() })
665
678
  });
666
679
  var IntegrationDeleteEntrySchema = AuditLogEntryBase.extend({
667
- operation: z8.literal("integrations.delete"),
668
- requestData: z8.object({ id: z8.string() }),
669
- responseSummary: z8.object({ id: z8.string(), name: z8.string() })
680
+ operation: z9.literal("integrations.delete"),
681
+ requestData: z9.object({ id: z9.string() }),
682
+ responseSummary: z9.object({ id: z9.string(), name: z9.string() })
670
683
  });
671
684
  var IntegrationRefreshSecretEntrySchema = AuditLogEntryBase.extend({
672
- operation: z8.literal("integrations.refreshSecret"),
673
- requestData: z8.object({ id: z8.string() }),
674
- responseSummary: z8.object({ clientId: z8.string() })
685
+ operation: z9.literal("integrations.refreshSecret"),
686
+ requestData: z9.object({ id: z9.string() }),
687
+ responseSummary: z9.object({ clientId: z9.string() })
675
688
  });
676
689
  var createdVersionFields = {
677
- id: z8.string(),
678
- versionId: z8.string(),
679
- name: z8.string(),
680
- externalId: z8.string().nullish(),
681
- effectiveFrom: z8.string(),
682
- status: z8.string()
690
+ id: z9.string(),
691
+ versionId: z9.string(),
692
+ name: z9.string(),
693
+ externalId: z9.string().nullish(),
694
+ effectiveFrom: z9.string(),
695
+ status: z9.string()
683
696
  };
684
697
  var LocationCreateEntrySchema = AuditLogEntryBase.extend({
685
- operation: z8.literal("locations.create"),
686
- requestData: z8.object({
698
+ operation: z9.literal("locations.create"),
699
+ requestData: z9.object({
687
700
  ...createdVersionFields,
688
- administrativeAreaId: z8.string().nullish(),
689
- locationType: z8.string().nullish()
701
+ administrativeAreaId: z9.string().nullish(),
702
+ locationType: z9.string().nullish()
690
703
  })
691
704
  });
692
705
  var AdministrativeAreaCreateEntrySchema = AuditLogEntryBase.extend({
693
- operation: z8.literal("administrativeAreas.create"),
694
- requestData: z8.object({
706
+ operation: z9.literal("administrativeAreas.create"),
707
+ requestData: z9.object({
695
708
  ...createdVersionFields,
696
- parentId: z8.string().nullish()
709
+ parentId: z9.string().nullish()
697
710
  })
698
711
  });
699
- var ChangedStringField = z8.object({ from: z8.string(), to: z8.string() });
700
- var ChangedNullableStringField = z8.object({
701
- from: z8.string().nullable(),
702
- to: z8.string().nullable()
703
- });
704
- var updatedVersionRequestData = z8.object({
705
- id: z8.string(),
706
- versionId: z8.string(),
707
- name: z8.string(),
708
- externalId: z8.string().nullish(),
709
- status: z8.string(),
710
- effectiveFrom: z8.string(),
711
- lastVersionId: z8.string()
712
- });
713
- var updatedVersionResponseSummary = z8.object({
714
- previousVersionId: z8.string(),
715
- versionId: z8.string(),
716
- changed: z8.object({
712
+ var ChangedStringField = z9.object({ from: z9.string(), to: z9.string() });
713
+ var ChangedNullableStringField = z9.object({
714
+ from: z9.string().nullable(),
715
+ to: z9.string().nullable()
716
+ });
717
+ var updatedVersionRequestData = z9.object({
718
+ id: z9.string(),
719
+ versionId: z9.string(),
720
+ name: z9.string(),
721
+ externalId: z9.string().nullish(),
722
+ status: z9.string(),
723
+ effectiveFrom: z9.string(),
724
+ lastVersionId: z9.string()
725
+ });
726
+ var updatedVersionResponseSummary = z9.object({
727
+ previousVersionId: z9.string(),
728
+ versionId: z9.string(),
729
+ changed: z9.object({
717
730
  name: ChangedStringField.optional(),
718
731
  externalId: ChangedNullableStringField.optional(),
719
732
  status: ChangedStringField.optional()
720
733
  })
721
734
  });
722
735
  var LocationUpdateEntrySchema = AuditLogEntryBase.extend({
723
- operation: z8.literal("locations.update"),
736
+ operation: z9.literal("locations.update"),
724
737
  requestData: updatedVersionRequestData,
725
738
  responseSummary: updatedVersionResponseSummary
726
739
  });
727
740
  var AdministrativeAreaUpdateEntrySchema = AuditLogEntryBase.extend({
728
- operation: z8.literal("administrativeAreas.update"),
741
+ operation: z9.literal("administrativeAreas.update"),
729
742
  requestData: updatedVersionRequestData,
730
743
  responseSummary: updatedVersionResponseSummary
731
744
  });
732
- var withdrawVersionRequestData = z8.object({
733
- id: z8.string(),
734
- versionId: z8.string()
745
+ var withdrawVersionRequestData = z9.object({
746
+ id: z9.string(),
747
+ versionId: z9.string()
735
748
  });
736
- var withdrawVersionResponseSummary = z8.object({
737
- effectiveFrom: z8.string(),
738
- name: z8.string(),
739
- externalId: z8.string().nullish(),
740
- status: z8.string()
749
+ var withdrawVersionResponseSummary = z9.object({
750
+ effectiveFrom: z9.string(),
751
+ name: z9.string(),
752
+ externalId: z9.string().nullish(),
753
+ status: z9.string()
741
754
  });
742
755
  var LocationWithdrawEntrySchema = AuditLogEntryBase.extend({
743
- operation: z8.literal("locations.withdrawVersion"),
756
+ operation: z9.literal("locations.withdrawVersion"),
744
757
  requestData: withdrawVersionRequestData,
745
758
  responseSummary: withdrawVersionResponseSummary
746
759
  });
747
760
  var AdministrativeAreaWithdrawEntrySchema = AuditLogEntryBase.extend({
748
- operation: z8.literal("administrativeAreas.withdrawVersion"),
761
+ operation: z9.literal("administrativeAreas.withdrawVersion"),
749
762
  requestData: withdrawVersionRequestData,
750
763
  responseSummary: withdrawVersionResponseSummary
751
764
  });
752
765
  var AttachmentUploadEntrySchema = AuditLogEntryBase.extend({
753
- operation: z8.literal("attachments.upload"),
754
- requestData: z8.object({
755
- transactionId: z8.string(),
756
- path: z8.string().nullable()
766
+ operation: z9.literal("attachments.upload"),
767
+ requestData: z9.object({
768
+ transactionId: z9.string(),
769
+ path: z9.string().nullable()
757
770
  }),
758
- responseSummary: z8.object({ fileUrl: z8.string() })
771
+ responseSummary: z9.object({ fileUrl: z9.string() })
759
772
  });
760
- var subjectOnly = z8.object({ subjectId: z8.string() });
761
- var subjectWithReason = z8.object({
762
- subjectId: z8.string(),
763
- reason: z8.string(),
764
- comment: z8.string().optional()
773
+ var subjectOnly = z9.object({ subjectId: z9.string() });
774
+ var subjectWithReason = z9.object({
775
+ subjectId: z9.string(),
776
+ reason: z9.string(),
777
+ comment: z9.string().optional()
765
778
  });
766
779
  var UserCreateEntrySchema = AuditLogEntryBase.extend({
767
- operation: z8.literal("user.create_user"),
768
- requestData: z8.object({
769
- subjectId: z8.string(),
770
- role: z8.string(),
771
- primaryOfficeId: z8.string()
780
+ operation: z9.literal("user.create_user"),
781
+ requestData: z9.object({
782
+ subjectId: z9.string(),
783
+ role: z9.string(),
784
+ primaryOfficeId: z9.string()
772
785
  })
773
786
  });
774
787
  var UserReasonEntrySchema = AuditLogEntryBase.extend({
775
- operation: z8.enum(["user.deactivate", "user.reactivate"]),
788
+ operation: z9.enum(["user.deactivate", "user.reactivate"]),
776
789
  requestData: subjectWithReason
777
790
  });
778
791
  var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
779
- operation: z8.enum([
792
+ operation: z9.enum([
780
793
  "user.edit_user",
781
794
  "user.logged_in",
782
795
  "user.logged_out",
@@ -790,14 +803,14 @@ var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
790
803
  requestData: subjectOnly
791
804
  });
792
805
  var UserEmailChangedEntrySchema = AuditLogEntryBase.extend({
793
- operation: z8.literal("user.email_address_changed"),
806
+ operation: z9.literal("user.email_address_changed"),
794
807
  requestData: subjectOnly,
795
- responseSummary: z8.object({ email: z8.string() })
808
+ responseSummary: z9.object({ email: z9.string() })
796
809
  });
797
810
  var UserPhoneChangedEntrySchema = AuditLogEntryBase.extend({
798
- operation: z8.literal("user.phone_number_changed"),
811
+ operation: z9.literal("user.phone_number_changed"),
799
812
  requestData: subjectOnly,
800
- responseSummary: z8.object({ phoneNumber: z8.string() })
813
+ responseSummary: z9.object({ phoneNumber: z9.string() })
801
814
  });
802
815
  var userBaseOmit = {
803
816
  id: true,
@@ -805,14 +818,14 @@ var userBaseOmit = {
805
818
  clientType: true,
806
819
  createdAt: true
807
820
  };
808
- var UserAuditRecordInput = z8.discriminatedUnion("operation", [
821
+ var UserAuditRecordInput = z9.discriminatedUnion("operation", [
809
822
  UserCreateEntrySchema.omit(userBaseOmit),
810
823
  UserReasonEntrySchema.omit(userBaseOmit),
811
824
  UserSubjectOnlyEntrySchema.omit(userBaseOmit),
812
825
  UserEmailChangedEntrySchema.omit(userBaseOmit),
813
826
  UserPhoneChangedEntrySchema.omit(userBaseOmit)
814
827
  ]);
815
- var AuditLogEntrySchema = z8.discriminatedUnion("operation", [
828
+ var AuditLogEntrySchema = z9.discriminatedUnion("operation", [
816
829
  EventCreateEntrySchema,
817
830
  EventGetEntrySchema,
818
831
  EventSearchEntrySchema,
@@ -843,13 +856,13 @@ var TENNIS_CLUB_MEMBERSHIP = "tennis-club-membership";
843
856
  var CHILD_ONBOARDING_EVENT = "child-onboarding";
844
857
 
845
858
  // ../commons/src/events/ActionConfig.ts
846
- var z24 = __toESM(require("zod/v4"));
859
+ var z25 = __toESM(require("zod/v4"));
847
860
 
848
861
  // ../commons/src/events/FieldConfig.ts
849
862
  var import_v43 = __toESM(require("zod/v4"));
850
863
 
851
864
  // ../commons/src/events/FieldType.ts
852
- var z9 = __toESM(require("zod/v4"));
865
+ var z10 = __toESM(require("zod/v4"));
853
866
  var FieldType = {
854
867
  NAME: "NAME",
855
868
  PHONE: "PHONE",
@@ -913,7 +926,7 @@ var FieldType = {
913
926
  */
914
927
  _EXPERIMENTAL_CUSTOM: "CUSTOM"
915
928
  };
916
- var FileFieldType = z9.enum([
929
+ var FileFieldType = z10.enum([
917
930
  FieldType.FILE,
918
931
  FieldType.FILE_WITH_OPTIONS,
919
932
  FieldType.SIGNATURE
@@ -949,164 +962,160 @@ var HiddenFieldTypes = [
949
962
  ];
950
963
 
951
964
  // ../commons/src/events/FieldValue.ts
952
- var z13 = __toESM(require("zod/v4"));
965
+ var z14 = __toESM(require("zod/v4"));
953
966
 
954
967
  // ../commons/src/documents.ts
955
- var z10 = __toESM(require("zod/v4"));
956
- var FullDocumentUrl = z10.string().brand("FullDocumentUrl").describe(
968
+ var z11 = __toESM(require("zod/v4"));
969
+ var FullDocumentUrl = z11.string().brand("FullDocumentUrl").describe(
957
970
  "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"
958
971
  );
959
- var FullDocumentPath = z10.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
972
+ var FullDocumentPath = z11.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
960
973
  "A full absolute path with bucket name, starting from the root of the S3 server, /bucket-name/document-id.jpg"
961
974
  );
962
- var DocumentPath = z10.string().brand("DocumentPath").describe(
975
+ var DocumentPath = z11.string().brand("DocumentPath").describe(
963
976
  "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."
964
977
  );
965
978
 
966
979
  // ../commons/src/events/CompositeFieldValue.ts
967
- var z11 = __toESM(require("zod/v4"));
980
+ var z12 = __toESM(require("zod/v4"));
968
981
  var AddressType = {
969
982
  DOMESTIC: "DOMESTIC",
970
983
  INTERNATIONAL: "INTERNATIONAL"
971
984
  };
972
- var FileFieldValue = z11.object({
985
+ var FileFieldValue = z12.object({
973
986
  path: DocumentPath,
974
- originalFilename: z11.string(),
975
- type: z11.string()
976
- });
977
- var NameFieldValue = z11.object({
978
- firstname: z11.string(),
979
- surname: z11.string(),
980
- middlename: z11.string().optional()
981
- });
982
- var NameFieldUpdateValue = z11.object({
983
- firstname: z11.string().nullish(),
984
- surname: z11.string().nullish(),
985
- middlename: z11.string().nullish()
986
- }).or(z11.null()).or(z11.undefined());
987
- var StreetLevelDetailsValue = z11.record(z11.string(), z11.string()).optional();
988
- var StreetLevelDetailsUpdateValue = z11.record(z11.string(), z11.string().nullable()).nullish();
989
- var BaseAddressFieldValue = z11.object({
990
- country: z11.string(),
987
+ originalFilename: z12.string(),
988
+ type: z12.string()
989
+ });
990
+ var NameFieldValue = z12.object({
991
+ firstname: z12.string(),
992
+ surname: z12.string(),
993
+ middlename: z12.string().optional()
994
+ });
995
+ var NameFieldUpdateValue = z12.object({
996
+ firstname: z12.string().nullish(),
997
+ surname: z12.string().nullish(),
998
+ middlename: z12.string().nullish()
999
+ }).or(z12.null()).or(z12.undefined());
1000
+ var StreetLevelDetailsValue = z12.record(z12.string(), z12.string()).optional();
1001
+ var StreetLevelDetailsUpdateValue = z12.record(z12.string(), z12.string().nullable()).nullish();
1002
+ var BaseAddressFieldValue = z12.object({
1003
+ country: z12.string(),
991
1004
  streetLevelDetails: StreetLevelDetailsValue
992
1005
  });
993
- var BaseAddressFieldUpdateValue = z11.object({
994
- country: z11.string().nullish(),
1006
+ var BaseAddressFieldUpdateValue = z12.object({
1007
+ country: z12.string().nullish(),
995
1008
  streetLevelDetails: StreetLevelDetailsUpdateValue
996
1009
  });
997
1010
  var DomesticAddressFieldValue = BaseAddressFieldValue.extend({
998
- addressType: z11.literal(AddressType.DOMESTIC),
999
- administrativeArea: z11.string().uuid()
1011
+ addressType: z12.literal(AddressType.DOMESTIC),
1012
+ administrativeArea: z12.string().uuid()
1000
1013
  });
1001
1014
  var InternationalAddressFieldValue = BaseAddressFieldValue.extend({
1002
- addressType: z11.literal(AddressType.INTERNATIONAL)
1015
+ addressType: z12.literal(AddressType.INTERNATIONAL)
1003
1016
  });
1004
- var AddressFieldValue = z11.discriminatedUnion("addressType", [
1017
+ var AddressFieldValue = z12.discriminatedUnion("addressType", [
1005
1018
  DomesticAddressFieldValue,
1006
1019
  InternationalAddressFieldValue
1007
1020
  ]);
1008
1021
  var DomesticAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend({
1009
- addressType: z11.literal(AddressType.DOMESTIC),
1010
- administrativeArea: z11.string().uuid().nullish()
1022
+ addressType: z12.literal(AddressType.DOMESTIC),
1023
+ administrativeArea: z12.string().uuid().nullish()
1011
1024
  /* Leaf level admin structure */
1012
1025
  });
1013
1026
  var InternationalAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend(
1014
1027
  {
1015
- addressType: z11.literal(AddressType.INTERNATIONAL)
1028
+ addressType: z12.literal(AddressType.INTERNATIONAL)
1016
1029
  }
1017
1030
  );
1018
- var AddressFieldUpdateValue = z11.discriminatedUnion("addressType", [
1031
+ var AddressFieldUpdateValue = z12.discriminatedUnion("addressType", [
1019
1032
  DomesticAddressUpdateFieldValue,
1020
1033
  InternationalAddressUpdateFieldValue
1021
1034
  ]).nullish();
1022
- var FileFieldValueWithOption = z11.object({
1035
+ var FileFieldValueWithOption = z12.object({
1023
1036
  path: DocumentPath,
1024
- originalFilename: z11.string(),
1025
- type: z11.string(),
1026
- option: z11.string()
1027
- });
1028
- var FileFieldWithOptionValue = z11.array(FileFieldValueWithOption);
1029
- var HttpFieldValue = z11.object({
1030
- loading: z11.boolean(),
1031
- error: z11.object({ statusCode: z11.number(), message: z11.string() }).nullish(),
1032
- data: z11.any()
1033
- });
1034
- var HttpFieldUpdateValue = z11.object({
1035
- loading: z11.boolean().nullish(),
1036
- error: z11.object({ statusCode: z11.number(), message: z11.string() }).nullish(),
1037
- data: z11.any().nullish()
1038
- }).or(z11.null()).or(z11.undefined());
1039
- var QueryParamReaderFieldValue = z11.object({
1040
- data: z11.record(z11.string(), z11.string()),
1041
- updatedAt: z11.iso.datetime()
1037
+ originalFilename: z12.string(),
1038
+ type: z12.string(),
1039
+ option: z12.string()
1040
+ });
1041
+ var FileFieldWithOptionValue = z12.array(FileFieldValueWithOption);
1042
+ var HttpFieldValue = z12.object({
1043
+ loading: z12.boolean(),
1044
+ error: z12.object({ statusCode: z12.number(), message: z12.string() }).nullish(),
1045
+ data: z12.any()
1046
+ });
1047
+ var HttpFieldUpdateValue = z12.object({
1048
+ loading: z12.boolean().nullish(),
1049
+ error: z12.object({ statusCode: z12.number(), message: z12.string() }).nullish(),
1050
+ data: z12.any().nullish()
1051
+ }).or(z12.null()).or(z12.undefined());
1052
+ var QueryParamReaderFieldValue = z12.object({
1053
+ data: z12.record(z12.string(), z12.string()),
1054
+ updatedAt: z12.iso.datetime()
1042
1055
  }).nullish();
1043
- var QueryParamReaderFieldUpdateValue = z11.object({
1044
- data: z11.record(z11.string(), z11.string())
1056
+ var QueryParamReaderFieldUpdateValue = z12.object({
1057
+ data: z12.record(z12.string(), z12.string())
1045
1058
  });
1046
- var ReadDataValue = z11.object({
1047
- data: z11.any()
1059
+ var ReadDataValue = z12.object({
1060
+ data: z12.any()
1048
1061
  });
1049
1062
  var QrReaderFieldValue = ReadDataValue;
1050
1063
  var IdReaderFieldValue = ReadDataValue;
1051
- var NumberWithUnitFieldValue = z11.object({
1052
- numericValue: z11.number(),
1053
- unit: z11.string()
1064
+ var NumberWithUnitFieldValue = z12.object({
1065
+ numericValue: z12.number(),
1066
+ unit: z12.string()
1054
1067
  });
1055
- var NumberWithUnitFieldUpdateValue = z11.object({
1056
- numericValue: z11.number().optional(),
1057
- unit: z11.string().optional()
1068
+ var NumberWithUnitFieldUpdateValue = z12.object({
1069
+ numericValue: z12.number().optional(),
1070
+ unit: z12.string().optional()
1058
1071
  });
1059
- var CustomFieldValue = z11.unknown().brand("CustomFieldValue");
1072
+ var CustomFieldValue = z12.unknown().brand("CustomFieldValue");
1060
1073
 
1061
1074
  // ../commons/src/events/PlainDate.ts
1062
1075
  var import_zod = require("zod");
1063
1076
  var PlainDate = import_zod.z.string().date().brand("PlainDate").describe("Date in the format YYYY-MM-DD");
1064
- function plainDateToLocalDate(date) {
1065
- const [year, month, day] = date.split("-").map(Number);
1066
- return new Date(year, month - 1, day);
1067
- }
1068
1077
 
1069
1078
  // ../commons/src/events/FieldValue.ts
1070
- var TextValue = z13.string();
1071
- var HiddenFieldValue = z13.string();
1072
- var NonEmptyTextValue = z13.string().trim().min(1);
1073
- var DateValue = z13.iso.date().describe("Date in the format YYYY-MM-DD");
1074
- var AgeValue = z13.object({
1075
- age: z13.number(),
1076
- asOfDateRef: z13.string()
1079
+ var TextValue = z14.string();
1080
+ var HiddenFieldValue = z14.string();
1081
+ var NonEmptyTextValue = z14.string().trim().min(1);
1082
+ var DateValue = z14.iso.date().describe("Date in the format YYYY-MM-DD");
1083
+ var AgeValue = z14.object({
1084
+ age: z14.number(),
1085
+ asOfDateRef: z14.string()
1077
1086
  });
1078
1087
  var AgeUpdateValue = AgeValue.optional().nullable();
1079
- var AutocompleteValue = z13.object({
1080
- label: z13.string(),
1081
- value: z13.string()
1088
+ var AutocompleteValue = z14.object({
1089
+ label: z14.string(),
1090
+ value: z14.string()
1082
1091
  });
1083
1092
  var AutocompleteUpdateValue = AutocompleteValue.optional().nullable();
1084
- var TimeValue = z13.string().regex(/^([01][0-9]|2[0-3]):[0-5][0-9]$/);
1085
- var DatetimeValue = z13.iso.datetime();
1086
- var SelectDateRangeValue = z13.enum([
1093
+ var TimeValue = z14.string().regex(/^([01][0-9]|2[0-3]):[0-5][0-9]$/);
1094
+ var DatetimeValue = z14.iso.datetime();
1095
+ var SelectDateRangeValue = z14.enum([
1087
1096
  "last7Days",
1088
1097
  "last30Days",
1089
1098
  "last90Days",
1090
1099
  "last365Days"
1091
1100
  ]);
1092
- var DateRangeFieldValue = z13.object({
1101
+ var DateRangeFieldValue = z14.object({
1093
1102
  start: PlainDate,
1094
1103
  end: PlainDate
1095
1104
  }).or(PlainDate).describe(
1096
1105
  "Date range with start and end dates in the format YYYY-MM-DD. Inclusive start, exclusive end."
1097
1106
  );
1098
- var EmailValue = z13.email();
1099
- var CheckboxFieldValue = z13.boolean();
1100
- var NumberFieldValue = z13.number();
1107
+ var EmailValue = z14.email();
1108
+ var CheckboxFieldValue = z14.boolean();
1109
+ var NumberFieldValue = z14.number();
1101
1110
  var SignatureFieldValue = FileFieldValue;
1102
- var ButtonFieldValue = z13.number();
1103
- var VerificationStatusValue = z13.enum([
1111
+ var ButtonFieldValue = z14.number();
1112
+ var VerificationStatusValue = z14.enum([
1104
1113
  "verified",
1105
1114
  "authenticated",
1106
1115
  "failed",
1107
1116
  "pending"
1108
1117
  ]);
1109
- var LeafFieldValues = z13.union([
1118
+ var LeafFieldValues = z14.union([
1110
1119
  AddressFieldValue,
1111
1120
  TextValue,
1112
1121
  PlainDate,
@@ -1132,11 +1141,11 @@ var LeafFieldValues = z13.union([
1132
1141
  AutocompleteValue,
1133
1142
  AutocompleteUpdateValue
1134
1143
  ]);
1135
- var FieldGroupValue = z13.record(z13.string(), LeafFieldValues);
1136
- var DataFieldValue = z13.object({
1137
- data: z13.record(z13.string(), LeafFieldValues)
1144
+ var FieldGroupValue = z14.record(z14.string(), LeafFieldValues);
1145
+ var DataFieldValue = z14.object({
1146
+ data: z14.record(z14.string(), LeafFieldValues)
1138
1147
  }).nullish();
1139
- var FieldValue = z13.union([
1148
+ var FieldValue = z14.union([
1140
1149
  LeafFieldValues,
1141
1150
  DataFieldValue,
1142
1151
  FieldGroupValue
@@ -1170,7 +1179,7 @@ function safeUnion(schemas) {
1170
1179
  const sortedSchemas = [...schemas].sort(
1171
1180
  (a, b) => schemaPriority(a) - schemaPriority(b)
1172
1181
  );
1173
- return z13.any().superRefine((val, ctx) => {
1182
+ return z14.any().superRefine((val, ctx) => {
1174
1183
  for (const schema of sortedSchemas) {
1175
1184
  if (schema.safeParse(val).success) {
1176
1185
  return;
@@ -1209,9 +1218,9 @@ var FieldUpdateValue = safeUnion([
1209
1218
  ]);
1210
1219
 
1211
1220
  // ../commons/src/events/serializers/user/serializer.ts
1212
- var z14 = __toESM(require("zod/v4"));
1213
- var SerializedUserField = z14.object({
1214
- $userField: z14.enum([
1221
+ var z15 = __toESM(require("zod/v4"));
1222
+ var SerializedUserField = z15.object({
1223
+ $userField: z15.enum([
1215
1224
  "id",
1216
1225
  "name",
1217
1226
  "role",
@@ -1225,7 +1234,7 @@ var SerializedUserField = z14.object({
1225
1234
  "primaryOfficeId",
1226
1235
  "administrativeAreaId"
1227
1236
  ]),
1228
- $location: z14.string().optional()
1237
+ $location: z15.string().optional()
1229
1238
  });
1230
1239
  function userSerializer(userField) {
1231
1240
  return {
@@ -1248,25 +1257,25 @@ function userSerializer(userField) {
1248
1257
  var import_v4 = require("zod/v4");
1249
1258
 
1250
1259
  // ../commons/src/events/EventMetadata.ts
1251
- var z16 = __toESM(require("zod/v4"));
1260
+ var z17 = __toESM(require("zod/v4"));
1252
1261
 
1253
1262
  // ../commons/src/events/ActionDocument.ts
1254
- var z15 = __toESM(require("zod/v4"));
1255
- var ActionUpdate = z15.record(z15.string(), FieldUpdateValue).describe(
1263
+ var z16 = __toESM(require("zod/v4"));
1264
+ var ActionUpdate = z16.record(z16.string(), FieldUpdateValue).describe(
1256
1265
  "Record of field-level changes made by an action. Supports partial updates and nullable values."
1257
1266
  );
1258
- var EventState = z15.record(z15.string(), FieldValue).describe(
1267
+ var EventState = z16.record(z16.string(), FieldValue).describe(
1259
1268
  "Aggregate representation of event data after all actions have been applied, with all updates consolidated and null values removed."
1260
1269
  );
1261
- var ActionBase = z15.object({
1270
+ var ActionBase = z16.object({
1262
1271
  id: UUID.describe("Unique identifier of the action."),
1263
- transactionId: z15.string().describe("Unique identifier of the transaction."),
1272
+ transactionId: z16.string().describe("Unique identifier of the transaction."),
1264
1273
  createdByUserType: TokenUserType.describe(
1265
1274
  "Indicates whether the action was created by a human-user or by a system-user."
1266
1275
  ),
1267
- createdAt: z15.string().datetime().describe("Timestamp indicating when the action was created."),
1268
- createdBy: z15.string().describe("Identifier of the user who created the action."),
1269
- createdByRole: z15.string().optional().describe("Role of the user who created the action."),
1276
+ createdAt: z16.string().datetime().describe("Timestamp indicating when the action was created."),
1277
+ createdBy: z16.string().describe("Identifier of the user who created the action."),
1278
+ createdByRole: z16.string().optional().describe("Role of the user who created the action."),
1270
1279
  createdBySignature: DocumentPath.nullish().describe(
1271
1280
  "Reference to the signature of the user who created the action."
1272
1281
  ),
@@ -1278,7 +1287,7 @@ var ActionBase = z15.object({
1278
1287
  "Declaration data defined by the ActionConfig. Supports partial updates."
1279
1288
  ),
1280
1289
  annotation: ActionUpdate.optional().nullable().describe("Action-specific metadata used to annotate the event."),
1281
- status: z15.enum([
1290
+ status: z16.enum([
1282
1291
  ActionStatus.Requested,
1283
1292
  ActionStatus.Accepted,
1284
1293
  ActionStatus.Rejected
@@ -1290,139 +1299,143 @@ var ActionBase = z15.object({
1290
1299
  )
1291
1300
  });
1292
1301
  var AssignedAction = ActionBase.extend(
1293
- z15.object({
1294
- type: z15.literal(ActionType.ASSIGN),
1295
- assignedTo: z15.string().describe("Identifier of the user to whom the action is assigned.")
1302
+ z16.object({
1303
+ type: z16.literal(ActionType.ASSIGN),
1304
+ assignedTo: z16.string().describe("Identifier of the user to whom the action is assigned.")
1296
1305
  // TODO move into 'content' property
1297
1306
  }).shape
1298
1307
  );
1299
1308
  var UnassignedAction = ActionBase.extend(
1300
- z15.object({
1301
- type: z15.literal(ActionType.UNASSIGN)
1309
+ z16.object({
1310
+ type: z16.literal(ActionType.UNASSIGN)
1302
1311
  }).shape
1303
1312
  );
1304
1313
  var RegisterAction = ActionBase.extend(
1305
- z15.object({
1306
- type: z15.literal(ActionType.REGISTER),
1307
- registrationNumber: z15.string().optional().describe(
1314
+ z16.object({
1315
+ type: z16.literal(ActionType.REGISTER),
1316
+ registrationNumber: z16.string().optional().describe(
1308
1317
  "Registration number of the event. Always present for accepted registrations."
1309
1318
  )
1310
1319
  // TODO move into 'content' property
1311
1320
  }).shape
1312
1321
  );
1313
1322
  var DeclareAction = ActionBase.extend(
1314
- z15.object({
1315
- type: z15.literal(ActionType.DECLARE)
1323
+ z16.object({
1324
+ type: z16.literal(ActionType.DECLARE)
1316
1325
  }).shape
1317
1326
  );
1318
- var ReasonContent = z15.object({
1319
- reason: z15.string().min(1, { error: "Message cannot be empty" }).describe(
1327
+ var ReasonContent = z16.object({
1328
+ reason: z16.string().min(1, { error: "Message cannot be empty" }).describe(
1320
1329
  "Message describing the reason for rejecting or archiving the event."
1321
1330
  )
1322
1331
  });
1323
1332
  var RejectAction = ActionBase.extend(
1324
- z15.object({
1325
- type: z15.literal(ActionType.REJECT),
1333
+ z16.object({
1334
+ type: z16.literal(ActionType.REJECT),
1326
1335
  content: ReasonContent
1327
1336
  }).shape
1328
1337
  );
1329
- var PotentialDuplicate = z15.object({
1338
+ var PotentialDuplicate = z16.object({
1330
1339
  id: UUID,
1331
- trackingId: z15.string()
1340
+ trackingId: z16.string()
1332
1341
  });
1333
1342
  var DuplicateDetectedAction = ActionBase.extend(
1334
- z15.object({
1335
- type: z15.literal(ActionType.DUPLICATE_DETECTED),
1336
- content: z15.object({
1337
- duplicates: z15.array(PotentialDuplicate)
1343
+ z16.object({
1344
+ type: z16.literal(ActionType.DUPLICATE_DETECTED),
1345
+ content: z16.object({
1346
+ duplicates: z16.array(PotentialDuplicate)
1338
1347
  })
1339
1348
  }).shape
1340
1349
  );
1341
1350
  var MarkNotDuplicateAction = ActionBase.extend(
1342
- z15.object({
1343
- type: z15.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1351
+ z16.object({
1352
+ type: z16.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1344
1353
  }).shape
1345
1354
  );
1346
1355
  var MarkAsDuplicateAction = ActionBase.extend(
1347
- z15.object({
1348
- type: z15.literal(ActionType.MARK_AS_DUPLICATE),
1349
- content: z15.object({
1356
+ z16.object({
1357
+ type: z16.literal(ActionType.MARK_AS_DUPLICATE),
1358
+ content: z16.object({
1350
1359
  duplicateOf: UUID
1351
1360
  }).optional()
1352
1361
  }).shape
1353
1362
  );
1354
1363
  var ArchiveAction = ActionBase.extend(
1355
- z15.object({
1356
- type: z15.literal(ActionType.ARCHIVE),
1357
- content: ReasonContent
1364
+ z16.object({
1365
+ type: z16.literal(ActionType.ARCHIVE),
1366
+ /**
1367
+ * Archiving does not collect a reason on its own. Only the
1368
+ * "mark as duplicate" flow archives with a reason attached.
1369
+ */
1370
+ content: ReasonContent.optional()
1358
1371
  }).shape
1359
1372
  );
1360
1373
  var UnarchiveAction = ActionBase.extend(
1361
- z15.object({
1362
- type: z15.literal(ActionType.UNARCHIVE)
1374
+ z16.object({
1375
+ type: z16.literal(ActionType.UNARCHIVE)
1363
1376
  }).shape
1364
1377
  );
1365
1378
  var CreatedAction = ActionBase.extend(
1366
- z15.object({
1367
- type: z15.literal(ActionType.CREATE)
1379
+ z16.object({
1380
+ type: z16.literal(ActionType.CREATE)
1368
1381
  }).shape
1369
1382
  );
1370
1383
  var NotifiedAction = ActionBase.extend(
1371
- z15.object({
1372
- type: z15.literal(ActionType.NOTIFY)
1384
+ z16.object({
1385
+ type: z16.literal(ActionType.NOTIFY)
1373
1386
  }).shape
1374
1387
  );
1375
1388
  var EditAction = ActionBase.extend(
1376
- z15.object({
1377
- type: z15.literal(ActionType.EDIT),
1389
+ z16.object({
1390
+ type: z16.literal(ActionType.EDIT),
1378
1391
  /** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
1379
- content: z15.object({
1380
- comment: z15.string().describe("Comment for the edit action.").optional()
1392
+ content: z16.object({
1393
+ comment: z16.string().describe("Comment for the edit action.").optional()
1381
1394
  }).optional()
1382
1395
  }).shape
1383
1396
  );
1384
- var PrintContent = z15.object({
1385
- templateId: z15.string().optional()
1397
+ var PrintContent = z16.object({
1398
+ templateId: z16.string().optional()
1386
1399
  });
1387
1400
  var PrintCertificateAction = ActionBase.extend(
1388
- z15.object({
1389
- type: z15.literal(ActionType.PRINT_CERTIFICATE),
1401
+ z16.object({
1402
+ type: z16.literal(ActionType.PRINT_CERTIFICATE),
1390
1403
  content: PrintContent.optional().nullable()
1391
1404
  }).shape
1392
1405
  );
1393
1406
  var RequestedCorrectionAction = ActionBase.extend(
1394
- z15.object({
1395
- type: z15.literal(ActionType.REQUEST_CORRECTION)
1407
+ z16.object({
1408
+ type: z16.literal(ActionType.REQUEST_CORRECTION)
1396
1409
  }).shape
1397
1410
  );
1398
1411
  var ApprovedCorrectionAction = ActionBase.extend(
1399
- z15.object({
1400
- type: z15.literal(ActionType.APPROVE_CORRECTION),
1401
- requestId: z15.string(),
1412
+ z16.object({
1413
+ type: z16.literal(ActionType.APPROVE_CORRECTION),
1414
+ requestId: z16.string(),
1402
1415
  // TODO move into 'content' property
1403
- content: z15.object({ immediateCorrection: z15.boolean().optional() }).optional()
1416
+ content: z16.object({ immediateCorrection: z16.boolean().optional() }).optional()
1404
1417
  }).shape
1405
1418
  );
1406
1419
  var RejectedCorrectionAction = ActionBase.extend(
1407
- z15.object({
1408
- type: z15.literal(ActionType.REJECT_CORRECTION),
1409
- requestId: z15.string(),
1420
+ z16.object({
1421
+ type: z16.literal(ActionType.REJECT_CORRECTION),
1422
+ requestId: z16.string(),
1410
1423
  // TODO move into 'content' property
1411
1424
  content: ReasonContent
1412
1425
  }).shape
1413
1426
  );
1414
1427
  var ReadAction = ActionBase.extend(
1415
- z15.object({
1416
- type: z15.literal(ActionType.READ)
1428
+ z16.object({
1429
+ type: z16.literal(ActionType.READ)
1417
1430
  }).shape
1418
1431
  );
1419
1432
  var CustomAction = ActionBase.merge(
1420
- z15.object({
1421
- type: z15.literal(ActionType.CUSTOM),
1422
- customActionType: z15.string()
1433
+ z16.object({
1434
+ type: z16.literal(ActionType.CUSTOM),
1435
+ customActionType: z16.string()
1423
1436
  })
1424
1437
  );
1425
- var ActionDocument = z15.discriminatedUnion("type", [
1438
+ var ActionDocument = z16.discriminatedUnion("type", [
1426
1439
  CreatedAction.meta({ id: "CreatedAction" }),
1427
1440
  RejectAction.meta({ id: "RejectAction" }),
1428
1441
  DuplicateDetectedAction.meta({ id: "DuplicateDetectedAction" }),
@@ -1449,57 +1462,50 @@ var AsyncRejectActionDocument = ActionBase.omit({
1449
1462
  declaration: true,
1450
1463
  annotation: true
1451
1464
  }).extend(
1452
- z15.object({
1453
- type: z15.enum(ConfirmableActions),
1454
- status: z15.literal(ActionStatus.Rejected)
1465
+ z16.object({
1466
+ type: z16.enum(ConfirmableActions),
1467
+ status: z16.literal(ActionStatus.Rejected)
1455
1468
  }).shape
1456
1469
  );
1457
- var Action = z15.union([ActionDocument, AsyncRejectActionDocument]);
1470
+ var Action = z16.union([ActionDocument, AsyncRejectActionDocument]);
1458
1471
 
1459
1472
  // ../commons/src/events/EventMetadata.ts
1460
- var EventStatus = z16.enum([
1461
- "CREATED",
1462
- "NOTIFIED",
1463
- "DECLARED",
1464
- "REGISTERED",
1465
- "ARCHIVED"
1466
- ]);
1467
- var ZodDate = z16.iso.date();
1468
- var ZodDateTime = z16.string().datetime();
1469
- var ActionCreationMetadata = z16.object({
1470
- createdAt: z16.iso.datetime().describe("The timestamp when the action request was created."),
1471
- createdBy: z16.string().describe("ID of the user who created the action request."),
1473
+ var ZodDate = z17.iso.date();
1474
+ var ZodDateTime = z17.string().datetime();
1475
+ var ActionCreationMetadata = z17.object({
1476
+ createdAt: z17.iso.datetime().describe("The timestamp when the action request was created."),
1477
+ createdBy: z17.string().describe("ID of the user who created the action request."),
1472
1478
  // @TODO: createdAtLocation should be non-nullable in the future once all action requests have this field populated.
1473
1479
  createdAtLocation: UUID.nullish().describe(
1474
1480
  "Location of the user who created the action request."
1475
1481
  ),
1476
- createdByUserType: z16.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1477
- acceptedAt: z16.iso.datetime().describe("Timestamp when the action request was accepted."),
1478
- createdByRole: z16.string().optional().describe("Role of the user at the time of action request creation.")
1482
+ createdByUserType: z17.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1483
+ acceptedAt: z17.iso.datetime().describe("Timestamp when the action request was accepted."),
1484
+ createdByRole: z17.string().optional().describe("Role of the user at the time of action request creation.")
1479
1485
  });
1480
1486
  var RegistrationCreationMetadata = ActionCreationMetadata.extend({
1481
- registrationNumber: z16.string().describe(
1487
+ registrationNumber: z17.string().describe(
1482
1488
  "Registration number of the event. Always present for accepted registrations."
1483
1489
  )
1484
1490
  });
1485
- var LegalStatuses = z16.object({
1491
+ var LegalStatuses = z17.object({
1486
1492
  [EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
1487
1493
  [EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
1488
1494
  [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
1489
1495
  });
1490
- var EventMetadata = z16.object({
1496
+ var EventMetadata = z17.object({
1491
1497
  id: UUID,
1492
- type: z16.string().describe("The type of event, such as birth, death, or marriage."),
1498
+ type: z17.string().describe("The type of event, such as birth, death, or marriage."),
1493
1499
  status: EventStatus,
1494
1500
  legalStatuses: LegalStatuses.describe(
1495
1501
  "Metadata related to the legal registration of the event, such as who registered it and when."
1496
1502
  ),
1497
- createdAt: z16.iso.datetime().describe("The timestamp when the event was first created and saved."),
1503
+ createdAt: z17.iso.datetime().describe("The timestamp when the event was first created and saved."),
1498
1504
  dateOfEvent: ZodDate.nullish(),
1499
1505
  placeOfEvent: UUID.nullish(),
1500
- createdBy: z16.string().describe("ID of the user who created the event."),
1501
- createdByUserType: z16.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1502
- updatedByUserRole: z16.string().nullish().describe("Role of the user who last changed the status."),
1506
+ createdBy: z17.string().describe("ID of the user who created the event."),
1507
+ createdByUserType: z17.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1508
+ updatedByUserRole: z17.string().nullish().describe("Role of the user who last changed the status."),
1503
1509
  // @TODO: createdAtLocation should be non-nullable in the future once all action requests have this field populated.
1504
1510
  createdAtLocation: UUID.nullish().describe(
1505
1511
  "Location of the user who created the event."
@@ -1507,18 +1513,18 @@ var EventMetadata = z16.object({
1507
1513
  updatedAtLocation: UUID.nullish().describe(
1508
1514
  "Location of the user who last changed the status."
1509
1515
  ),
1510
- updatedAt: z16.iso.datetime().describe(
1516
+ updatedAt: z17.iso.datetime().describe(
1511
1517
  "Timestamp of the most recent *accepted* status change. Possibly 3rd party update, if action is validation asynchronously."
1512
1518
  ),
1513
- assignedTo: z16.string().nullish().describe("ID of the user currently assigned to the event."),
1514
- updatedBy: z16.string().nullish().describe("ID of the user who last changed the status."),
1515
- trackingId: z16.string().describe(
1519
+ assignedTo: z17.string().nullish().describe("ID of the user currently assigned to the event."),
1520
+ updatedBy: z17.string().nullish().describe("ID of the user who last changed the status."),
1521
+ trackingId: z17.string().describe(
1516
1522
  "System-generated tracking ID used by informants or registrars to look up the event."
1517
1523
  ),
1518
- potentialDuplicates: z16.array(PotentialDuplicate).describe(
1524
+ potentialDuplicates: z17.array(PotentialDuplicate).describe(
1519
1525
  "List of event IDs and their tracking IDs that this event could be a duplicate of."
1520
1526
  ),
1521
- flags: z16.array(Flag)
1527
+ flags: z17.array(Flag)
1522
1528
  });
1523
1529
  var EventMetadataKeysArray = [
1524
1530
  "id",
@@ -1539,8 +1545,8 @@ var EventMetadataKeysArray = [
1539
1545
  "legalStatuses",
1540
1546
  "flags"
1541
1547
  ];
1542
- var EventMetadataKeys = z16.enum(EventMetadataKeysArray);
1543
- var EventMetadataDateFieldIdInput = z16.enum([
1548
+ var EventMetadataKeys = z17.enum(EventMetadataKeysArray);
1549
+ var EventMetadataDateFieldIdInput = z17.enum([
1544
1550
  "createdAt",
1545
1551
  "updatedAt",
1546
1552
  "legalStatuses.NOTIFIED.createdAt",
@@ -1550,7 +1556,7 @@ var EventMetadataDateFieldIdInput = z16.enum([
1550
1556
  "legalStatuses.REGISTERED.createdAt",
1551
1557
  "legalStatuses.REGISTERED.acceptedAt"
1552
1558
  ]);
1553
- var EventMetadataDateFieldId = z16.enum([
1559
+ var EventMetadataDateFieldId = z17.enum([
1554
1560
  "event.createdAt",
1555
1561
  "event.updatedAt",
1556
1562
  "event.legalStatuses.NOTIFIED.createdAt",
@@ -2239,10 +2245,13 @@ var AdministrativeAreaField = BaseField.extend({
2239
2245
  type: AdministrativeAreas,
2240
2246
  allowedLocations: AllowedLocations,
2241
2247
  listHistoricalNames: import_v43.default.boolean().optional().describe(
2242
- "Advanced search: list every historical name a location has had as a separate, selectable option."
2248
+ "List every historical name a location has had as a separate, selectable option."
2243
2249
  ),
2244
2250
  activeOnly: import_v43.default.boolean().optional().describe(
2245
- "Advanced search: offer only currently-active locations; inactivated ones are excluded."
2251
+ "Offer only locations that are active at the resolved anchor date (today, or the date of event when anchorToDateOfEvent is set); inactive or not-yet-effective versions are excluded."
2252
+ ),
2253
+ anchorToDateOfEvent: import_v43.default.boolean().optional().describe(
2254
+ "Resolve selectable/displayed versions against the event's date of event (falling back to the record's creation date when empty) instead of today. Does not by itself exclude inactive versions; combine with activeOnly for that."
2246
2255
  )
2247
2256
  }).describe("Administrative area options")
2248
2257
  }).meta({
@@ -2256,7 +2265,13 @@ var LocationInput = BaseField.extend({
2256
2265
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
2257
2266
  allowedLocations: AllowedLocations,
2258
2267
  listHistoricalNames: import_v43.default.boolean().optional().describe(
2259
- "Advanced search: list every historical name a location has had as a separate, selectable option."
2268
+ "List every historical name a location has had as a separate, selectable option."
2269
+ ),
2270
+ activeOnly: import_v43.default.boolean().optional().describe(
2271
+ "Offer only locations that are active at the resolved anchor date (today, or the date of event when anchorToDateOfEvent is set); inactive or not-yet-effective versions are excluded."
2272
+ ),
2273
+ anchorToDateOfEvent: import_v43.default.boolean().optional().describe(
2274
+ "Resolve selectable/displayed versions against the event's date of event (falling back to the record's creation date when empty) instead of today. Does not by itself exclude inactive versions; combine with activeOnly for that."
2260
2275
  )
2261
2276
  }).optional()
2262
2277
  }).meta({
@@ -2285,7 +2300,9 @@ var Facility = BaseField.extend({
2285
2300
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2286
2301
  configuration: import_v43.default.object({
2287
2302
  allowedLocations: AllowedLocations,
2288
- listHistoricalNames: import_v43.default.boolean().optional()
2303
+ listHistoricalNames: import_v43.default.boolean().optional(),
2304
+ activeOnly: import_v43.default.boolean().optional(),
2305
+ anchorToDateOfEvent: import_v43.default.boolean().optional()
2289
2306
  }).optional()
2290
2307
  }).describe("Input field for a facility");
2291
2308
  var Office = BaseField.extend({
@@ -2293,7 +2310,9 @@ var Office = BaseField.extend({
2293
2310
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2294
2311
  configuration: import_v43.default.object({
2295
2312
  allowedLocations: AllowedLocations,
2296
- listHistoricalNames: import_v43.default.boolean().optional()
2313
+ listHistoricalNames: import_v43.default.boolean().optional(),
2314
+ activeOnly: import_v43.default.boolean().optional(),
2315
+ anchorToDateOfEvent: import_v43.default.boolean().optional()
2297
2316
  }).optional()
2298
2317
  }).describe("Input field for an office");
2299
2318
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
@@ -2329,10 +2348,13 @@ var Address = BaseField.extend({
2329
2348
  ).optional(),
2330
2349
  allowedLocations: AllowedLocations,
2331
2350
  listHistoricalNames: import_v43.default.boolean().optional().describe(
2332
- "Advanced search: list every historical name a location has had as a separate, selectable option. Propagated to the embedded admin-area selectors."
2351
+ "List every historical name a location has had as a separate, selectable option. Propagated to the embedded admin-area selectors."
2333
2352
  ),
2334
2353
  activeOnly: import_v43.default.boolean().optional().describe(
2335
- "Advanced search: offer only currently-active admin areas; inactivated ones are excluded. Propagated to the embedded admin-area selectors."
2354
+ "Offer only admin areas that are active at the resolved anchor date (today, or the date of event when anchorToDateOfEvent is set); inactive or not-yet-effective versions are excluded. Propagated to the embedded admin-area selectors."
2355
+ ),
2356
+ anchorToDateOfEvent: import_v43.default.boolean().optional().describe(
2357
+ "Resolve selectable/displayed versions against the event's date of event (falling back to the record's creation date when empty) instead of today. Does not by itself exclude inactive versions; combine with activeOnly for that. Propagated to the embedded admin-area selectors."
2336
2358
  )
2337
2359
  }).optional(),
2338
2360
  defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
@@ -2634,18 +2656,18 @@ var AnyFileField = import_v43.default.discriminatedUnion("type", [
2634
2656
  ]);
2635
2657
 
2636
2658
  // ../commons/src/events/FormConfig.ts
2637
- var z22 = __toESM(require("zod/v4"));
2659
+ var z23 = __toESM(require("zod/v4"));
2638
2660
 
2639
2661
  // ../commons/src/events/PageConfig.ts
2640
- var z21 = __toESM(require("zod/v4"));
2641
- var PageTypes = z21.enum(["FORM", "VERIFICATION"]);
2642
- var PageConfigBase = z21.object({
2643
- id: z21.string().describe("Unique identifier for the page"),
2662
+ var z22 = __toESM(require("zod/v4"));
2663
+ var PageTypes = z22.enum(["FORM", "VERIFICATION"]);
2664
+ var PageConfigBase = z22.object({
2665
+ id: z22.string().describe("Unique identifier for the page"),
2644
2666
  title: TranslationConfig.describe("Header title of the page"),
2645
- requireCompletionToContinue: z21.boolean().default(false).describe(
2667
+ requireCompletionToContinue: z22.boolean().default(false).describe(
2646
2668
  "If true, all required fields must be filled before continuing to the next page"
2647
2669
  ),
2648
- fields: z21.array(FieldConfig).describe("Fields to be rendered on the page"),
2670
+ fields: z22.array(FieldConfig).describe("Fields to be rendered on the page"),
2649
2671
  conditional: Conditional.optional().describe(
2650
2672
  "Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
2651
2673
  )
@@ -2654,13 +2676,13 @@ var PageConfigBase = z21.object({
2654
2676
  id: "FormPageConfig"
2655
2677
  });
2656
2678
  var FormPageConfig = PageConfigBase.extend({
2657
- type: z21.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
2679
+ type: z22.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
2658
2680
  });
2659
- var VerificationActionConfig = z21.object({
2660
- verify: z21.object({ label: TranslationConfig }),
2661
- cancel: z21.object({
2681
+ var VerificationActionConfig = z22.object({
2682
+ verify: z22.object({ label: TranslationConfig }),
2683
+ cancel: z22.object({
2662
2684
  label: TranslationConfig,
2663
- confirmation: z21.object({
2685
+ confirmation: z22.object({
2664
2686
  title: TranslationConfig,
2665
2687
  body: TranslationConfig
2666
2688
  })
@@ -2670,34 +2692,34 @@ var VerificationActionConfig = z21.object({
2670
2692
  id: "VerificationActionConfig"
2671
2693
  });
2672
2694
  var VerificationPageConfig = FormPageConfig.extend({
2673
- type: z21.literal(PageTypes.enum.VERIFICATION),
2695
+ type: z22.literal(PageTypes.enum.VERIFICATION),
2674
2696
  actions: VerificationActionConfig
2675
2697
  });
2676
- var PageConfig = z21.discriminatedUnion("type", [FormPageConfig, VerificationPageConfig]).meta({
2698
+ var PageConfig = z22.discriminatedUnion("type", [FormPageConfig, VerificationPageConfig]).meta({
2677
2699
  id: "PageConfig",
2678
2700
  description: "Configuration for a single page in a form. Either a form page with fields and a continue button, or a verification page with verify/cancel options."
2679
2701
  });
2680
2702
 
2681
2703
  // ../commons/src/events/FormConfig.ts
2682
- var DeclarationFormConfig = z22.object({
2704
+ var DeclarationFormConfig = z23.object({
2683
2705
  label: TranslationConfig.describe("Human readable description of the form"),
2684
- pages: z22.array(FormPageConfig)
2706
+ pages: z23.array(FormPageConfig)
2685
2707
  }).meta({
2686
2708
  id: "DeclarationFormConfig",
2687
2709
  description: "Configuration of the declaration form."
2688
2710
  });
2689
- var ActionFormConfig = z22.object({
2711
+ var ActionFormConfig = z23.object({
2690
2712
  label: TranslationConfig.describe("Human readable description of the form"),
2691
- pages: z22.array(PageConfig)
2713
+ pages: z23.array(PageConfig)
2692
2714
  }).describe(
2693
2715
  "Configuration of the form used for system actions beyond declaration, supporting a wider range of page types."
2694
2716
  );
2695
- var FormConfig = z22.union([DeclarationFormConfig, ActionFormConfig]);
2717
+ var FormConfig = z23.union([DeclarationFormConfig, ActionFormConfig]);
2696
2718
 
2697
2719
  // ../commons/src/events/DeduplicationConfig.ts
2698
- var z23 = __toESM(require("zod/v4"));
2699
- var FieldReference2 = z23.string();
2700
- var Matcher = z23.object({
2720
+ var z24 = __toESM(require("zod/v4"));
2721
+ var FieldReference2 = z24.string();
2722
+ var Matcher = z24.object({
2701
2723
  /**
2702
2724
  * Reference to the field used in matching.
2703
2725
  *
@@ -2705,23 +2727,23 @@ var Matcher = z23.object({
2705
2727
  * be used as the origin date to calculate the distance from.
2706
2728
  */
2707
2729
  fieldId: FieldReference2,
2708
- options: z23.object({
2709
- boost: z23.number().optional(),
2730
+ options: z24.object({
2731
+ boost: z24.number().optional(),
2710
2732
  matchAgainst: FieldReference2.optional()
2711
2733
  }).optional().default({
2712
2734
  boost: 1
2713
2735
  })
2714
2736
  });
2715
2737
  var FuzzyMatcher = Matcher.extend({
2716
- type: z23.literal("fuzzy"),
2717
- options: z23.object({
2738
+ type: z24.literal("fuzzy"),
2739
+ options: z24.object({
2718
2740
  /**
2719
2741
  * Names of length 3 or less characters = 0 edits allowed
2720
2742
  * Names of length 4 - 6 characters = 1 edit allowed
2721
2743
  * Names of length >7 characters = 2 edits allowed
2722
2744
  */
2723
- fuzziness: z23.union([z23.string(), z23.number()]).optional().default("AUTO:4,7"),
2724
- boost: z23.number().optional().default(1),
2745
+ fuzziness: z24.union([z24.string(), z24.number()]).optional().default("AUTO:4,7"),
2746
+ boost: z24.number().optional().default(1),
2725
2747
  matchAgainst: FieldReference2.optional()
2726
2748
  }).optional().default({
2727
2749
  fuzziness: "AUTO:4,7",
@@ -2729,48 +2751,48 @@ var FuzzyMatcher = Matcher.extend({
2729
2751
  })
2730
2752
  });
2731
2753
  var StrictMatcher = Matcher.extend({
2732
- type: z23.literal("strict"),
2733
- options: z23.object({
2734
- boost: z23.number().optional().default(1),
2754
+ type: z24.literal("strict"),
2755
+ options: z24.object({
2756
+ boost: z24.number().optional().default(1),
2735
2757
  /**
2736
2758
  * The constant value to be present in the field for both records
2737
2759
  */
2738
- value: z23.string().optional(),
2760
+ value: z24.string().optional(),
2739
2761
  matchAgainst: FieldReference2.optional()
2740
2762
  }).optional().default({
2741
2763
  boost: 1
2742
2764
  })
2743
2765
  });
2744
2766
  var DateRangeMatcher = Matcher.extend({
2745
- type: z23.literal("dateRange"),
2746
- options: z23.object({
2767
+ type: z24.literal("dateRange"),
2768
+ options: z24.object({
2747
2769
  /**
2748
2770
  * The distance pivot in days. Distance from the origin (the value of
2749
2771
  * fieldId) at which relevance scores receive half of the boost value
2750
2772
  */
2751
- pivot: z23.number().optional(),
2752
- days: z23.number(),
2753
- boost: z23.number().optional().default(1),
2773
+ pivot: z24.number().optional(),
2774
+ days: z24.number(),
2775
+ boost: z24.number().optional().default(1),
2754
2776
  matchAgainst: FieldReference2.optional()
2755
2777
  })
2756
2778
  });
2757
- var Not = z23.object({
2758
- type: z23.literal("not"),
2779
+ var Not = z24.object({
2780
+ type: z24.literal("not"),
2759
2781
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
2760
- clause: z23.lazy(() => Clause)
2782
+ clause: z24.lazy(() => Clause)
2761
2783
  });
2762
- var And = z23.object({
2763
- type: z23.literal("and"),
2784
+ var And = z24.object({
2785
+ type: z24.literal("and"),
2764
2786
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
2765
- clauses: z23.lazy(() => Clause.array())
2787
+ clauses: z24.lazy(() => Clause.array())
2766
2788
  });
2767
- var Or = z23.object({
2768
- type: z23.literal("or"),
2789
+ var Or = z24.object({
2790
+ type: z24.literal("or"),
2769
2791
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
2770
- clauses: z23.lazy(() => Clause.array())
2792
+ clauses: z24.lazy(() => Clause.array())
2771
2793
  });
2772
- var Clause = z23.lazy(
2773
- () => z23.discriminatedUnion("type", [
2794
+ var Clause = z24.lazy(
2795
+ () => z24.discriminatedUnion("type", [
2774
2796
  Not,
2775
2797
  And,
2776
2798
  Or,
@@ -2781,8 +2803,8 @@ var Clause = z23.lazy(
2781
2803
  ).meta({
2782
2804
  id: "Clause"
2783
2805
  });
2784
- var DeduplicationConfig = z23.object({
2785
- id: z23.string(),
2806
+ var DeduplicationConfig = z24.object({
2807
+ id: z24.string(),
2786
2808
  label: TranslationConfig,
2787
2809
  query: Clause
2788
2810
  }).meta({
@@ -2791,15 +2813,15 @@ var DeduplicationConfig = z23.object({
2791
2813
  });
2792
2814
 
2793
2815
  // ../commons/src/events/ActionConfig.ts
2794
- var DeclarationReviewConfig = z24.object({
2816
+ var DeclarationReviewConfig = z25.object({
2795
2817
  title: TranslationConfig.describe("Title of the review page"),
2796
- fields: z24.array(FieldConfig).describe("Fields displayed on the review page for annotations.")
2818
+ fields: z25.array(FieldConfig).describe("Fields displayed on the review page for annotations.")
2797
2819
  }).describe(
2798
2820
  "Configuration of the declaration review page for collecting event-related metadata."
2799
2821
  );
2800
- var ActionConfigBase = z24.object({
2822
+ var ActionConfigBase = z25.object({
2801
2823
  label: TranslationConfig.describe("Human readable description of the action"),
2802
- flags: z24.array(ActionFlagConfig).optional().default([]).describe("Flag actions which are executed when the action is performed."),
2824
+ flags: z25.array(ActionFlagConfig).optional().default([]).describe("Flag actions which are executed when the action is performed."),
2803
2825
  supportingCopy: TranslationConfig.optional().describe(
2804
2826
  "Text displayed on the confirmation dialog"
2805
2827
  ),
@@ -2810,84 +2832,84 @@ var ActionConfigBase = z24.object({
2810
2832
  * "The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed."
2811
2833
  * for EventConfig.d.ts.
2812
2834
  */
2813
- icon: z24.string().describe("Icon representing the action").optional(),
2814
- conditionals: z24.array(ActionConditional).optional().describe("Conditionals which can disable or hide actions.")
2835
+ icon: z25.string().describe("Icon representing the action").optional(),
2836
+ conditionals: z25.array(ActionConditional).optional().describe("Conditionals which can disable or hide actions.")
2815
2837
  });
2816
2838
  var DeclarationActionBase = ActionConfigBase.extend({
2817
2839
  deduplication: DeduplicationConfig.optional()
2818
2840
  });
2819
- var actionConfirmationForm = z24.array(FieldConfig).optional().describe(
2841
+ var actionConfirmationForm = z25.array(FieldConfig).optional().describe(
2820
2842
  "Fields rendered on the action confirmation dialog. Submitted values are stored in the action annotation and shown in the audit history."
2821
2843
  );
2822
2844
  var ReadActionConfig = ActionConfigBase.extend(
2823
- z24.object({
2824
- type: z24.literal(ActionType.READ),
2845
+ z25.object({
2846
+ type: z25.literal(ActionType.READ),
2825
2847
  review: DeclarationReviewConfig.describe(
2826
2848
  "Configuration of the review page for read-only view."
2827
2849
  ),
2828
- conditionals: z24.never().optional().describe("Read-action can not be disabled or hidden with conditionals.")
2850
+ conditionals: z25.never().optional().describe("Read-action can not be disabled or hidden with conditionals.")
2829
2851
  }).shape
2830
2852
  );
2831
2853
  var NotifyConfig = ActionConfigBase.extend(
2832
- z24.object({
2833
- type: z24.literal(ActionType.NOTIFY),
2854
+ z25.object({
2855
+ type: z25.literal(ActionType.NOTIFY),
2834
2856
  form: actionConfirmationForm
2835
2857
  }).shape
2836
2858
  );
2837
2859
  var DuplicateDetectedConfig = ActionConfigBase.extend(
2838
- z24.object({
2839
- type: z24.literal(ActionType.DUPLICATE_DETECTED),
2840
- label: z24.never().optional().describe(
2860
+ z25.object({
2861
+ type: z25.literal(ActionType.DUPLICATE_DETECTED),
2862
+ label: z25.never().optional().describe(
2841
2863
  "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no label."
2842
2864
  ),
2843
- supportingCopy: z24.never().optional(),
2844
- icon: z24.never().optional().describe(
2865
+ supportingCopy: z25.never().optional(),
2866
+ icon: z25.never().optional().describe(
2845
2867
  "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no icon."
2846
2868
  ),
2847
- conditionals: z24.never().optional().describe(
2869
+ conditionals: z25.never().optional().describe(
2848
2870
  "DUPLICATE_DETECTED is system-generated and never shown as a button, so it cannot be disabled or hidden with conditionals."
2849
2871
  )
2850
2872
  }).shape
2851
2873
  );
2852
2874
  var MarkAsDuplicateConfig = ActionConfigBase.extend(
2853
- z24.object({
2854
- type: z24.literal(ActionType.MARK_AS_DUPLICATE)
2875
+ z25.object({
2876
+ type: z25.literal(ActionType.MARK_AS_DUPLICATE)
2855
2877
  }).shape
2856
2878
  );
2857
2879
  var MarkAsNotDuplicateConfig = ActionConfigBase.extend(
2858
- z24.object({
2859
- type: z24.literal(ActionType.MARK_AS_NOT_DUPLICATE)
2880
+ z25.object({
2881
+ type: z25.literal(ActionType.MARK_AS_NOT_DUPLICATE)
2860
2882
  }).shape
2861
2883
  );
2862
2884
  var AssignConfig = ActionConfigBase.extend(
2863
- z24.object({
2864
- type: z24.literal(ActionType.ASSIGN),
2865
- flags: z24.never().optional().describe(
2885
+ z25.object({
2886
+ type: z25.literal(ActionType.ASSIGN),
2887
+ flags: z25.never().optional().describe(
2866
2888
  "ASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
2867
2889
  )
2868
2890
  }).shape
2869
2891
  );
2870
2892
  var UnassignConfig = ActionConfigBase.extend(
2871
- z24.object({
2872
- type: z24.literal(ActionType.UNASSIGN),
2873
- flags: z24.never().optional().describe(
2893
+ z25.object({
2894
+ type: z25.literal(ActionType.UNASSIGN),
2895
+ flags: z25.never().optional().describe(
2874
2896
  "UNASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
2875
2897
  )
2876
2898
  }).shape
2877
2899
  );
2878
2900
  var DeleteConfig = ActionConfigBase.extend(
2879
- z24.object({
2880
- type: z24.literal(ActionType.DELETE)
2901
+ z25.object({
2902
+ type: z25.literal(ActionType.DELETE)
2881
2903
  }).shape
2882
2904
  );
2883
2905
  var DeclareConfig = DeclarationActionBase.extend(
2884
- z24.object({
2885
- type: z24.literal(ActionType.DECLARE),
2906
+ z25.object({
2907
+ type: z25.literal(ActionType.DECLARE),
2886
2908
  review: DeclarationReviewConfig.describe(
2887
2909
  "Configuration of the review page fields."
2888
2910
  ),
2889
2911
  form: actionConfirmationForm,
2890
- dialogCopy: z24.object({
2912
+ dialogCopy: z25.object({
2891
2913
  notify: TranslationConfig.describe(
2892
2914
  "Confirmation text for the notify action"
2893
2915
  ),
@@ -2901,20 +2923,20 @@ var DeclareConfig = DeclarationActionBase.extend(
2901
2923
  }).shape
2902
2924
  );
2903
2925
  var ArchiveConfig = ActionConfigBase.extend(
2904
- z24.object({
2905
- type: z24.literal(ActionType.ARCHIVE),
2926
+ z25.object({
2927
+ type: z25.literal(ActionType.ARCHIVE),
2906
2928
  form: actionConfirmationForm
2907
2929
  }).shape
2908
2930
  );
2909
2931
  var UnarchiveConfig = ActionConfigBase.extend(
2910
- z24.object({
2911
- type: z24.literal(ActionType.UNARCHIVE)
2932
+ z25.object({
2933
+ type: z25.literal(ActionType.UNARCHIVE)
2912
2934
  }).shape
2913
2935
  );
2914
2936
  var EditActionConfig = ActionConfigBase.extend(
2915
- z24.object({
2916
- type: z24.literal(ActionType.EDIT),
2917
- dialogCopy: z24.object({
2937
+ z25.object({
2938
+ type: z25.literal(ActionType.EDIT),
2939
+ dialogCopy: z25.object({
2918
2940
  notify: TranslationConfig.describe(
2919
2941
  "Confirmation text for the notify with edits action"
2920
2942
  ),
@@ -2928,45 +2950,45 @@ var EditActionConfig = ActionConfigBase.extend(
2928
2950
  }).shape
2929
2951
  );
2930
2952
  var RejectConfig = ActionConfigBase.extend(
2931
- z24.object({
2932
- type: z24.literal(ActionType.REJECT),
2953
+ z25.object({
2954
+ type: z25.literal(ActionType.REJECT),
2933
2955
  form: actionConfirmationForm
2934
2956
  }).shape
2935
2957
  );
2936
2958
  var RegisterConfig = DeclarationActionBase.extend(
2937
- z24.object({
2938
- type: z24.literal(ActionType.REGISTER),
2959
+ z25.object({
2960
+ type: z25.literal(ActionType.REGISTER),
2939
2961
  form: actionConfirmationForm
2940
2962
  }).shape
2941
2963
  );
2942
2964
  var PrintCertificateActionConfig = ActionConfigBase.extend(
2943
- z24.object({
2944
- type: z24.literal(ActionType.PRINT_CERTIFICATE),
2965
+ z25.object({
2966
+ type: z25.literal(ActionType.PRINT_CERTIFICATE),
2945
2967
  printForm: ActionFormConfig
2946
2968
  }).shape
2947
2969
  );
2948
2970
  var RequestCorrectionConfig = ActionConfigBase.extend(
2949
- z24.object({
2950
- type: z24.literal(ActionType.REQUEST_CORRECTION),
2971
+ z25.object({
2972
+ type: z25.literal(ActionType.REQUEST_CORRECTION),
2951
2973
  correctionForm: ActionFormConfig
2952
2974
  }).shape
2953
2975
  );
2954
2976
  var ApproveCorrectionConfig = ActionConfigBase.extend(
2955
- z24.object({
2956
- type: z24.literal(ActionType.APPROVE_CORRECTION)
2977
+ z25.object({
2978
+ type: z25.literal(ActionType.APPROVE_CORRECTION)
2957
2979
  }).shape
2958
2980
  );
2959
2981
  var RejectCorrectionConfig = ActionConfigBase.extend(
2960
- z24.object({
2961
- type: z24.literal(ActionType.REJECT_CORRECTION)
2982
+ z25.object({
2983
+ type: z25.literal(ActionType.REJECT_CORRECTION)
2962
2984
  }).shape
2963
2985
  );
2964
2986
  var CustomActionConfig = ActionConfigBase.extend(
2965
- z24.object({
2966
- type: z24.literal(ActionType.CUSTOM),
2967
- customActionType: z24.string().describe("Type identifier of the custom action."),
2987
+ z25.object({
2988
+ type: z25.literal(ActionType.CUSTOM),
2989
+ customActionType: z25.string().describe("Type identifier of the custom action."),
2968
2990
  /** 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. */
2969
- form: z24.array(FieldConfig).describe(
2991
+ form: z25.array(FieldConfig).describe(
2970
2992
  "Form configuration for the custom action. The form configured here will be used on the custom action confirmation modal."
2971
2993
  ),
2972
2994
  auditHistoryLabel: TranslationConfig.describe(
@@ -2974,7 +2996,7 @@ var CustomActionConfig = ActionConfigBase.extend(
2974
2996
  )
2975
2997
  }).shape
2976
2998
  );
2977
- var ActionConfig = z24.discriminatedUnion("type", [
2999
+ var ActionConfig = z25.discriminatedUnion("type", [
2978
3000
  /*
2979
3001
  * OpenAPI references are defined here so our generated OpenAPI spec knows to reuse the models
2980
3002
  * and treat them as "models" instead of duplicating the data structure in each endpoint.
@@ -3061,58 +3083,58 @@ var ActionConfig = z24.discriminatedUnion("type", [
3061
3083
  var actionConfigTypes = new Set(
3062
3084
  ActionConfig.options.map((opt) => opt.shape.type.value)
3063
3085
  );
3064
- var DeclarationActionConfig = z24.discriminatedUnion("type", [
3086
+ var DeclarationActionConfig = z25.discriminatedUnion("type", [
3065
3087
  DeclareConfig,
3066
3088
  RegisterConfig
3067
3089
  ]);
3068
3090
 
3069
3091
  // ../commons/src/events/offline/CertificateConfig.ts
3070
- var z25 = __toESM(require("zod/v4"));
3071
- var FontFamily = z25.object({
3072
- normal: z25.string(),
3073
- bold: z25.string(),
3074
- italics: z25.string(),
3075
- bolditalics: z25.string()
3076
- });
3077
- var CertificateConfig = z25.object({
3078
- id: z25.string(),
3079
- event: z25.string(),
3080
- isV2Template: z25.boolean().optional(),
3092
+ var z26 = __toESM(require("zod/v4"));
3093
+ var FontFamily = z26.object({
3094
+ normal: z26.string(),
3095
+ bold: z26.string(),
3096
+ italics: z26.string(),
3097
+ bolditalics: z26.string()
3098
+ });
3099
+ var CertificateConfig = z26.object({
3100
+ id: z26.string(),
3101
+ event: z26.string(),
3102
+ isV2Template: z26.boolean().optional(),
3081
3103
  label: TranslationConfig,
3082
- isDefault: z25.boolean(),
3083
- fee: z25.object({
3084
- onTime: z25.number(),
3085
- late: z25.number(),
3086
- delayed: z25.number()
3104
+ isDefault: z26.boolean(),
3105
+ fee: z26.object({
3106
+ onTime: z26.number(),
3107
+ late: z26.number(),
3108
+ delayed: z26.number()
3087
3109
  }),
3088
- svgUrl: z25.string(),
3089
- fonts: z25.record(z25.string(), FontFamily).optional(),
3090
- conditionals: z25.array(ShowConditional).optional()
3110
+ svgUrl: z26.string(),
3111
+ fonts: z26.record(z26.string(), FontFamily).optional(),
3112
+ conditionals: z26.array(ShowConditional).optional()
3091
3113
  });
3092
3114
  var CertificateTemplateConfig = CertificateConfig.extend({
3093
- hash: z25.string().optional(),
3094
- svg: z25.string()
3115
+ hash: z26.string().optional(),
3116
+ svg: z26.string()
3095
3117
  });
3096
3118
 
3097
3119
  // ../commons/src/events/offline/LanguageConfig.ts
3098
- var z26 = __toESM(require("zod/v4"));
3099
- var LanguageConfig = z26.object({
3100
- lang: z26.string(),
3120
+ var z27 = __toESM(require("zod/v4"));
3121
+ var LanguageConfig = z27.object({
3122
+ lang: z27.string(),
3101
3123
  /**
3102
3124
  * client.csv contents
3103
3125
  */
3104
- messages: z26.record(z26.string(), z26.string())
3126
+ messages: z27.record(z27.string(), z27.string())
3105
3127
  });
3106
3128
 
3107
3129
  // ../commons/src/events/EventConfig.ts
3108
- var z34 = __toESM(require("zod/v4"));
3130
+ var z35 = __toESM(require("zod/v4"));
3109
3131
 
3110
3132
  // ../commons/src/events/SummaryConfig.ts
3111
- var z28 = __toESM(require("zod/v4"));
3133
+ var z29 = __toESM(require("zod/v4"));
3112
3134
 
3113
3135
  // ../commons/src/icons.ts
3114
- var z27 = __toESM(require("zod/v4"));
3115
- var AvailableIcons = z27.enum([
3136
+ var z28 = __toESM(require("zod/v4"));
3137
+ var AvailableIcons = z28.enum([
3116
3138
  "Archived",
3117
3139
  "Assigned",
3118
3140
  "Briefcase",
@@ -3220,11 +3242,11 @@ var AvailableIcons = z27.enum([
3220
3242
  ]);
3221
3243
 
3222
3244
  // ../commons/src/events/SummaryConfig.ts
3223
- var InfoBox = z28.object({
3224
- type: z28.enum(["info", "positive", "warning", "negative"]).describe(
3245
+ var InfoBox = z29.object({
3246
+ type: z29.enum(["info", "positive", "warning", "negative"]).describe(
3225
3247
  "Semantic tint of the icon block: info (blue), positive (green), warning (orange), negative (red)."
3226
3248
  ),
3227
- background: z28.enum(["tinted", "white"]).default("tinted").optional().describe(
3249
+ background: z29.enum(["tinted", "white"]).default("tinted").optional().describe(
3228
3250
  "tinted reads as a recessed empty state; white reads as a standalone card."
3229
3251
  ),
3230
3252
  icon: AvailableIcons.optional().describe(
@@ -3236,50 +3258,50 @@ var InfoBox = z28.object({
3236
3258
  description: TranslationConfig.optional().describe(
3237
3259
  "Secondary copy displayed below the heading, typically a suggested next step."
3238
3260
  ),
3239
- conditionals: z28.array(ShowConditional).default([]).optional().describe(
3261
+ conditionals: z29.array(ShowConditional).default([]).optional().describe(
3240
3262
  "Conditions under which the info box is shown. When omitted, it is always shown."
3241
3263
  )
3242
3264
  }).describe(
3243
3265
  "A compact icon-block + heading + description block displayed above the summary fields in the event overview."
3244
3266
  );
3245
- var BaseField2 = z28.object({
3267
+ var BaseField2 = z29.object({
3246
3268
  emptyValueMessage: TranslationConfig.optional().describe(
3247
3269
  "Default message displayed when the field value is empty."
3248
3270
  ),
3249
- conditionals: z28.array(ShowConditional).default([]).optional()
3271
+ conditionals: z29.array(ShowConditional).default([]).optional()
3250
3272
  });
3251
3273
  var ReferenceField = BaseField2.extend({
3252
- fieldId: z28.string(),
3274
+ fieldId: z29.string(),
3253
3275
  label: TranslationConfig.optional().describe(
3254
3276
  "Overrides the default label from the referenced field when provided."
3255
3277
  )
3256
3278
  }).describe("Field referencing existing event data by field ID.");
3257
3279
  var Field = BaseField2.extend({
3258
- id: z28.string().describe("Identifier of the summary field."),
3280
+ id: z29.string().describe("Identifier of the summary field."),
3259
3281
  value: TranslationConfig.describe(
3260
3282
  'Field value template supporting variables from configuration and EventMetadata (e.g. "{informant.phoneNo} {informant.email}").'
3261
3283
  ),
3262
3284
  label: TranslationConfig
3263
3285
  }).describe("Custom field defined for the summary view.");
3264
- var SummaryConfig = z28.object({
3265
- banners: z28.array(InfoBox).default([]).optional().describe(
3286
+ var SummaryConfig = z29.object({
3287
+ banners: z29.array(InfoBox).default([]).optional().describe(
3266
3288
  "Info boxes displayed above the summary fields in the event overview."
3267
3289
  ),
3268
- fields: z28.array(z28.union([Field, ReferenceField])).describe("Fields displayed in the event summary view.")
3290
+ fields: z29.array(z29.union([Field, ReferenceField])).describe("Fields displayed in the event summary view.")
3269
3291
  }).meta({
3270
3292
  id: "SummaryConfig",
3271
3293
  description: "Configuration of the event overview page. Defines which declaration fields appear in the record summary, optionally with custom labels, empty-value messages, and templated values."
3272
3294
  });
3273
3295
 
3274
3296
  // ../commons/src/events/AdvancedSearchConfig.ts
3275
- var z29 = __toESM(require("zod/v4"));
3276
- var MatchType = z29.enum(["fuzzy", "exact", "range", "within"]);
3277
- var BaseField3 = z29.object({
3278
- config: z29.object({
3297
+ var z30 = __toESM(require("zod/v4"));
3298
+ var MatchType = z30.enum(["fuzzy", "exact", "range", "within"]);
3299
+ var BaseField3 = z30.object({
3300
+ config: z30.object({
3279
3301
  type: MatchType.describe(
3280
3302
  "Determines the search type of field. How to match value."
3281
3303
  ),
3282
- searchFields: z29.array(z29.string()).optional().describe(
3304
+ searchFields: z30.array(z30.string()).optional().describe(
3283
3305
  `
3284
3306
  Defines multiple form fields that should be searched when this field has a value.
3285
3307
  All specified fields will be combined using OR logic.
@@ -3289,7 +3311,7 @@ var BaseField3 = z29.object({
3289
3311
  `
3290
3312
  )
3291
3313
  }),
3292
- type: z29.nativeEnum(FieldType).optional().describe(
3314
+ type: z30.nativeEnum(FieldType).optional().describe(
3293
3315
  `
3294
3316
  Explicitly specify the field type for searchFields.
3295
3317
  This is required when searchFields is defined, to show the correct control in the UI.
@@ -3303,7 +3325,7 @@ var BaseField3 = z29.object({
3303
3325
  This is required when searchFields is defined.
3304
3326
  `
3305
3327
  ),
3306
- options: z29.array(SelectOption).optional(),
3328
+ options: z30.array(SelectOption).optional(),
3307
3329
  searchCriteriaLabelPrefix: TranslationConfig.optional().describe(
3308
3330
  `
3309
3331
  This property determines whether to add a prefix (such as "Child" or "Applicant") before the field label
@@ -3324,7 +3346,7 @@ var BaseField3 = z29.object({
3324
3346
  in the country-config > event.advancedSearch configuration. For example: field("child.dob", { searchCriteriaLabelPrefix: TranslationConfig }).
3325
3347
  `
3326
3348
  ),
3327
- conditionals: z29.array(FieldConditional).optional().describe(
3349
+ conditionals: z30.array(FieldConditional).optional().describe(
3328
3350
  `
3329
3351
  In advanced search, we sometimes need to override the default field visibility conditionals.
3330
3352
 
@@ -3338,23 +3360,23 @@ var BaseField3 = z29.object({
3338
3360
  are always rendered in the advanced search form.
3339
3361
  `
3340
3362
  ),
3341
- validations: z29.array(ValidationConfig).optional().describe(
3363
+ validations: z30.array(ValidationConfig).optional().describe(
3342
3364
  `Option for overriding the field validations specifically for advanced search form.`
3343
3365
  ),
3344
3366
  allowedLocations: JurisdictionReference.optional().describe(
3345
3367
  `Override the allowedLocations for a location field in advanced search. Use this when the declaration form's allowedLocations references a scope (e.g. record.create) that search-only users don't have \u2014 specify record.search scope instead.`
3346
3368
  )
3347
3369
  });
3348
- var SearchQueryParams = z29.object({
3349
- eventType: z29.string().optional().describe(
3370
+ var SearchQueryParams = z30.object({
3371
+ eventType: z30.string().optional().describe(
3350
3372
  "Defines type of event so that when redirecting to Advanced Search page, appropriate tab can be selected"
3351
3373
  )
3352
3374
  }).catchall(FieldValue);
3353
3375
  var FieldConfigSchema = BaseField3.extend({
3354
- fieldId: z29.string(),
3355
- fieldType: z29.literal("field")
3376
+ fieldId: z30.string(),
3377
+ fieldType: z30.literal("field")
3356
3378
  });
3357
- var EventFieldIdInput = z29.enum([
3379
+ var EventFieldIdInput = z30.enum([
3358
3380
  "trackingId",
3359
3381
  "status",
3360
3382
  "legalStatuses.REGISTERED.acceptedAt",
@@ -3363,7 +3385,7 @@ var EventFieldIdInput = z29.enum([
3363
3385
  "updatedAt"
3364
3386
  ]);
3365
3387
  var METADATA_FIELD_PREFIX = "event.";
3366
- var EventFieldId = z29.enum([
3388
+ var EventFieldId = z30.enum([
3367
3389
  `${METADATA_FIELD_PREFIX}trackingId`,
3368
3390
  `${METADATA_FIELD_PREFIX}status`,
3369
3391
  `${METADATA_FIELD_PREFIX}legalStatuses.REGISTERED.acceptedAt`,
@@ -3373,29 +3395,29 @@ var EventFieldId = z29.enum([
3373
3395
  ]);
3374
3396
  var EventFieldConfigSchema = BaseField3.extend({
3375
3397
  fieldId: EventFieldId,
3376
- fieldType: z29.literal("event")
3398
+ fieldType: z30.literal("event")
3377
3399
  });
3378
- var AdvancedSearchField = z29.discriminatedUnion("fieldType", [FieldConfigSchema, EventFieldConfigSchema]).superRefine((data, ctx) => {
3400
+ var AdvancedSearchField = z30.discriminatedUnion("fieldType", [FieldConfigSchema, EventFieldConfigSchema]).superRefine((data, ctx) => {
3379
3401
  if (data.config.searchFields && data.config.searchFields.length > 0) {
3380
3402
  if (!data.label) {
3381
3403
  ctx.addIssue({
3382
- code: z29.ZodIssueCode.custom,
3404
+ code: z30.ZodIssueCode.custom,
3383
3405
  message: "label is required when config.searchFields is defined.",
3384
3406
  path: ["label"]
3385
3407
  });
3386
3408
  }
3387
3409
  if (!data.type) {
3388
3410
  ctx.addIssue({
3389
- code: z29.ZodIssueCode.custom,
3411
+ code: z30.ZodIssueCode.custom,
3390
3412
  message: "type is required when config.searchFields is defined.",
3391
3413
  path: ["type"]
3392
3414
  });
3393
3415
  }
3394
3416
  }
3395
3417
  });
3396
- var AdvancedSearchConfig = z29.object({
3418
+ var AdvancedSearchConfig = z30.object({
3397
3419
  title: TranslationConfig.describe("Advanced search tab title"),
3398
- fields: z29.array(AdvancedSearchField).describe("Advanced search fields within the tab.")
3420
+ fields: z30.array(AdvancedSearchField).describe("Advanced search fields within the tab.")
3399
3421
  }).meta({
3400
3422
  id: "AdvancedSearchConfig",
3401
3423
  description: "Configuration of one advanced search tab. Each tab has a title and a list of searchable fields \u2014 either declaration fields (via `field()`) or event metadata (via `event()`)."
@@ -3407,35 +3429,26 @@ var import_lodash4 = require("lodash");
3407
3429
  // ../commons/src/conditionals/validate.ts
3408
3430
  var import__ = __toESM(require("ajv/dist/2019"));
3409
3431
  var import_ajv_formats = __toESM(require("ajv-formats"));
3410
- var z33 = __toESM(require("zod/v4"));
3432
+ var z34 = __toESM(require("zod/v4"));
3411
3433
  var import_date_fns2 = require("date-fns");
3412
3434
 
3413
3435
  // ../commons/src/events/FieldTypeMapping.ts
3414
- var z31 = __toESM(require("zod/v4"));
3436
+ var z32 = __toESM(require("zod/v4"));
3415
3437
 
3416
3438
  // ../commons/src/events/DynamicFieldValue.ts
3417
- var z30 = __toESM(require("zod/v4"));
3439
+ var z31 = __toESM(require("zod/v4"));
3418
3440
 
3419
3441
  // ../commons/src/events/state/index.ts
3420
3442
  var import_lodash3 = require("lodash");
3421
3443
 
3422
3444
  // ../commons/src/utils.ts
3423
- var z32 = __toESM(require("zod/v4"));
3445
+ var z33 = __toESM(require("zod/v4"));
3424
3446
  var _ = __toESM(require("lodash"));
3425
- function getOrThrow(x, message) {
3426
- if (x === void 0 || x === null) {
3427
- throw new Error(message);
3428
- }
3429
- return x;
3430
- }
3431
- function joinValues(values, separator = " ") {
3432
- return values.filter((value) => !!value).join(separator).trim();
3433
- }
3434
- var FullNameV1 = z32.array(
3435
- z32.object({
3436
- use: z32.string(),
3437
- family: z32.string(),
3438
- given: z32.array(z32.string())
3447
+ var FullNameV1 = z33.array(
3448
+ z33.object({
3449
+ use: z33.string(),
3450
+ family: z33.string(),
3451
+ given: z33.array(z33.string())
3439
3452
  })
3440
3453
  );
3441
3454
  function omitKeyDeep(obj, keyToRemove) {
@@ -3456,43 +3469,6 @@ function omitKeyDeep(obj, keyToRemove) {
3456
3469
 
3457
3470
  // ../commons/src/events/state/utils.ts
3458
3471
  var import_lodash = require("lodash");
3459
- function getActionRequests(actionType, actions) {
3460
- const filtered = actions.filter((action) => action.type === actionType).reverse();
3461
- const accept = filtered.find(
3462
- (action) => action.status === ActionStatus.Accepted
3463
- );
3464
- const request = filtered.find(
3465
- (action) => action.status === ActionStatus.Requested
3466
- );
3467
- const reject = filtered.find(
3468
- (action) => action.status === ActionStatus.Rejected
3469
- );
3470
- return {
3471
- reject,
3472
- accept,
3473
- request
3474
- };
3475
- }
3476
- function getDeclarationActionCreationMetadata(actionType, actions) {
3477
- const { accept: acceptAction, request: requestAction } = getActionRequests(
3478
- actionType,
3479
- actions
3480
- );
3481
- if (!acceptAction) {
3482
- return null;
3483
- }
3484
- const registrationNumber = acceptAction.type === ActionType.REGISTER ? acceptAction.registrationNumber : null;
3485
- return {
3486
- // When 3rd party API returns 200 OK, we assume that the request was accepted, and persist single 'accepted' action.
3487
- createdAt: requestAction?.createdAt ?? acceptAction.createdAt,
3488
- createdBy: requestAction?.createdBy ?? acceptAction.createdBy,
3489
- createdByUserType: requestAction?.createdByUserType ?? acceptAction.createdByUserType,
3490
- createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
3491
- acceptedAt: acceptAction.createdAt,
3492
- createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
3493
- registrationNumber
3494
- };
3495
- }
3496
3472
  var updateActions = ActionTypes.extract([
3497
3473
  ActionType.CREATE,
3498
3474
  ActionType.NOTIFY,
@@ -3508,88 +3484,10 @@ var updateActions = ActionTypes.extract([
3508
3484
  ActionType.REJECT_CORRECTION,
3509
3485
  ActionType.CUSTOM
3510
3486
  ]);
3511
- function getActionUpdateMetadata(actions) {
3512
- const createAction = getOrThrow(
3513
- actions.find((action) => action.type === ActionType.CREATE),
3514
- `Event has no ${ActionType.CREATE} action`
3515
- );
3516
- const metadataFields = [
3517
- "createdAt",
3518
- "createdBy",
3519
- "createdByUserType",
3520
- "createdAtLocation",
3521
- "createdByRole"
3522
- ];
3523
- return actions.filter(({ type }) => updateActions.safeParse(type).success).reduce(
3524
- (_2, action) => {
3525
- if (action.originalActionId) {
3526
- const originalAction = actions.find(({ id }) => id === action.originalActionId) ?? action;
3527
- return (0, import_lodash.pick)(originalAction, metadataFields);
3528
- }
3529
- return (0, import_lodash.pick)(action, metadataFields);
3530
- },
3531
- (0, import_lodash.pick)(createAction, metadataFields)
3532
- );
3533
- }
3534
- function getLegalStatuses(actions) {
3535
- return {
3536
- [EventStatus.enum.NOTIFIED]: getDeclarationActionCreationMetadata(
3537
- ActionType.NOTIFY,
3538
- actions
3539
- ),
3540
- [EventStatus.enum.DECLARED]: getDeclarationActionCreationMetadata(
3541
- ActionType.DECLARE,
3542
- actions
3543
- ),
3544
- [EventStatus.enum.REGISTERED]: getDeclarationActionCreationMetadata(
3545
- ActionType.REGISTER,
3546
- actions
3547
- )
3548
- };
3549
- }
3550
3487
 
3551
3488
  // ../commons/src/events/state/flags.ts
3552
3489
  var import_lodash2 = require("lodash");
3553
3490
  var import_date_fns = require("date-fns");
3554
- function isFlagConditionMet(conditional, form, action) {
3555
- const now2 = (0, import_date_fns.isValid)((0, import_date_fns.parseISO)(action.createdAt)) ? (0, import_date_fns.formatISO)((0, import_date_fns.parseISO)(action.createdAt), { representation: "date" }) : (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
3556
- return validate(conditional, {
3557
- $form: form,
3558
- $now: now2,
3559
- $online: true,
3560
- $user: {
3561
- sub: "",
3562
- exp: "",
3563
- role: action.createdByRole,
3564
- algorithm: "",
3565
- scope: [],
3566
- userType: action.createdByUserType
3567
- }
3568
- });
3569
- }
3570
- function actionConfigRemovesFlag(action, flagId, actionsUpToAndIncluding, event2, eventConfiguration) {
3571
- if (!isActionConfigType(action.type)) {
3572
- return false;
3573
- }
3574
- const actionConfig = getActionConfig({
3575
- eventConfiguration,
3576
- actionType: action.type,
3577
- customActionType: "customActionType" in action ? action.customActionType : void 0
3578
- });
3579
- const removeOperations = (actionConfig?.flags ?? []).filter(
3580
- ({ id, operation }) => id === flagId && operation === "remove"
3581
- );
3582
- if (removeOperations.length === 0) {
3583
- return false;
3584
- }
3585
- const eventUpToThisAction = { ...event2, actions: actionsUpToAndIncluding };
3586
- const declaration = aggregateActionDeclarations(eventUpToThisAction);
3587
- const annotation = aggregateActionAnnotations(eventUpToThisAction);
3588
- const form = { ...declaration, ...annotation };
3589
- return removeOperations.some(
3590
- ({ conditional }) => conditional ? isFlagConditionMet(conditional, form, action) : true
3591
- );
3592
- }
3593
3491
  var INHERENT_FLAG_RULES = [
3594
3492
  {
3595
3493
  flag: InherentFlags.CORRECTION_REQUESTED,
@@ -3626,90 +3524,6 @@ var INHERENT_FLAG_RULES = [
3626
3524
  resetOnAnyOtherAction: true
3627
3525
  }
3628
3526
  ];
3629
- function resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration) {
3630
- return acceptedActions.reduce((present, action, idx) => {
3631
- if (rule.setOn.includes(action.type)) {
3632
- return true;
3633
- }
3634
- if (rule.resetOnAnyOtherAction || (rule.resetOn ?? []).includes(action.type)) {
3635
- return false;
3636
- }
3637
- if (actionConfigRemovesFlag(
3638
- action,
3639
- rule.flag,
3640
- acceptedActions.slice(0, idx + 1),
3641
- event2,
3642
- eventConfiguration
3643
- )) {
3644
- return false;
3645
- }
3646
- return present;
3647
- }, false);
3648
- }
3649
- function resolveEventCustomFlags(event2, eventConfiguration) {
3650
- const actions = getAcceptedActions(event2).filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
3651
- return actions.reduce((acc, action, idx) => {
3652
- let actionConfig;
3653
- if (isActionConfigType(action.type)) {
3654
- actionConfig = getActionConfig({
3655
- eventConfiguration,
3656
- actionType: action.type,
3657
- customActionType: "customActionType" in action ? action.customActionType : void 0
3658
- });
3659
- }
3660
- if (!actionConfig) {
3661
- return acc;
3662
- }
3663
- const eventUpToThisAction = {
3664
- ...event2,
3665
- actions: actions.slice(0, idx + 1)
3666
- };
3667
- const declaration = aggregateActionDeclarations(eventUpToThisAction);
3668
- const annotation = aggregateActionAnnotations(eventUpToThisAction);
3669
- const form = { ...declaration, ...annotation };
3670
- const flagsWithMetConditions = (actionConfig.flags ?? []).filter(
3671
- ({ conditional }) => (
3672
- // If conditional is not provided, the flag is resolved
3673
- conditional ? isFlagConditionMet(conditional, form, action) : true
3674
- )
3675
- );
3676
- const addedFlags = flagsWithMetConditions.filter(({ operation }) => operation === "add").map(({ id }) => id);
3677
- const removedFlags = flagsWithMetConditions.filter(({ operation }) => operation === "remove").map(({ id }) => id);
3678
- const flags = [...acc, ...addedFlags].filter(
3679
- (flagId) => !removedFlags.includes(flagId)
3680
- );
3681
- return (0, import_lodash2.uniq)(flags);
3682
- }, []);
3683
- }
3684
- function getActionStatusFlags(sortedActions) {
3685
- const actionStatus = sortedActions.reduce(
3686
- (actionStatuses, { type, status: status2 }) => ({
3687
- ...actionStatuses,
3688
- [type]: status2
3689
- }),
3690
- {}
3691
- );
3692
- return Object.entries(actionStatus).filter(([, status2]) => status2 !== ActionStatus.Accepted).map(([type, status2]) => {
3693
- const flag2 = joinValues([type, status2], ":").toLowerCase();
3694
- return flag2;
3695
- });
3696
- }
3697
- function getInherentFlags(sortedActions, event2, eventConfiguration) {
3698
- const acceptedActions = sortedActions.filter(
3699
- ({ status: status2 }) => status2 === ActionStatus.Accepted
3700
- );
3701
- return INHERENT_FLAG_RULES.filter(
3702
- (rule) => resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration)
3703
- ).map(({ flag: flag2 }) => flag2);
3704
- }
3705
- function getEventFlags(event2, config) {
3706
- const sortedActions = event2.actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
3707
- return [
3708
- ...getActionStatusFlags(sortedActions),
3709
- ...getInherentFlags(sortedActions, event2, config),
3710
- ...resolveEventCustomFlags(event2, config)
3711
- ];
3712
- }
3713
3527
 
3714
3528
  // ../commons/src/conditionals/conditionals.ts
3715
3529
  var objectHash = __toESM(require("object-hash"));
@@ -4345,183 +4159,6 @@ function createFieldConditionals(fieldId) {
4345
4159
  };
4346
4160
  }
4347
4161
 
4348
- // ../commons/src/events/state/index.ts
4349
- function getStatusFromActions(actions) {
4350
- const acceptedActions = actions.filter(
4351
- ({ status: status2 }) => status2 === ActionStatus.Accepted
4352
- );
4353
- const isCurrentlyArchived = acceptedActions.reduce(
4354
- (archived, action) => {
4355
- if (action.type === ActionType.ARCHIVE) {
4356
- return true;
4357
- }
4358
- if (action.type === ActionType.UNARCHIVE) {
4359
- return false;
4360
- }
4361
- return archived;
4362
- },
4363
- false
4364
- );
4365
- if (isCurrentlyArchived) {
4366
- return EventStatus.enum.ARCHIVED;
4367
- }
4368
- return acceptedActions.filter(
4369
- ({ type }) => type !== ActionType.ARCHIVE && type !== ActionType.UNARCHIVE
4370
- ).reduce((status2, action) => {
4371
- switch (action.type) {
4372
- case ActionType.CREATE:
4373
- return EventStatus.enum.CREATED;
4374
- case ActionType.DECLARE:
4375
- return EventStatus.enum.DECLARED;
4376
- case ActionType.REGISTER:
4377
- return EventStatus.enum.REGISTERED;
4378
- case ActionType.NOTIFY:
4379
- return EventStatus.enum.NOTIFIED;
4380
- // Already filtered out above; listed here only to satisfy exhaustiveness.
4381
- case ActionType.ARCHIVE:
4382
- case ActionType.UNARCHIVE:
4383
- case ActionType.CUSTOM:
4384
- case ActionType.PRINT_CERTIFICATE:
4385
- case ActionType.ASSIGN:
4386
- case ActionType.UNASSIGN:
4387
- case ActionType.REJECT:
4388
- case ActionType.REQUEST_CORRECTION:
4389
- case ActionType.APPROVE_CORRECTION:
4390
- case ActionType.DUPLICATE_DETECTED:
4391
- case ActionType.MARK_AS_NOT_DUPLICATE:
4392
- case ActionType.MARK_AS_DUPLICATE:
4393
- case ActionType.REJECT_CORRECTION:
4394
- case ActionType.READ:
4395
- case ActionType.EDIT:
4396
- default:
4397
- return status2;
4398
- }
4399
- }, EventStatus.enum.CREATED);
4400
- }
4401
- function getAssignedUserFromActions(actions) {
4402
- return actions.reduce((user2, action) => {
4403
- if (action.type === ActionType.ASSIGN) {
4404
- return action.assignedTo;
4405
- }
4406
- if (action.type === ActionType.UNASSIGN) {
4407
- return null;
4408
- }
4409
- return user2;
4410
- }, null);
4411
- }
4412
- function deepDropNulls(obj) {
4413
- if (Array.isArray(obj)) {
4414
- return obj.map(deepDropNulls);
4415
- }
4416
- if (obj !== null && typeof obj === "object") {
4417
- return Object.entries(obj).reduce((acc, [key, value]) => {
4418
- const cleanedValue = deepDropNulls(value);
4419
- if (cleanedValue !== null) {
4420
- ;
4421
- acc[key] = cleanedValue;
4422
- }
4423
- return acc;
4424
- }, {});
4425
- }
4426
- return obj;
4427
- }
4428
- var DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
4429
- function extractDateString(dateTime) {
4430
- return dateTime.split("T")[0];
4431
- }
4432
- function resolveDateOfEvent(eventIndex, declaration, config) {
4433
- if (!config.dateOfEvent) {
4434
- return extractDateString(eventIndex[DEFAULT_DATE_OF_EVENT_PROPERTY]);
4435
- }
4436
- const parsedDate = isFieldReference(config.dateOfEvent) ? ZodDate.safeParse(declaration[config.dateOfEvent.$$field]) : ZodDateTime.safeParse(
4437
- getMixedPath(eventIndex, config.dateOfEvent.$$event)
4438
- );
4439
- return parsedDate.success ? extractDateString(parsedDate.data) : void 0;
4440
- }
4441
- var DEFAULT_PLACE_OF_EVENT_PROPERTY = "createdAtLocation";
4442
- function getParsedUUID(value, oldValue) {
4443
- const parsed = UUID.safeParse(value);
4444
- return parsed.success ? parsed.data : oldValue;
4445
- }
4446
- function resolvePlaceOfEvent(eventMetadata, declaration, config) {
4447
- let placeOfEvent = getParsedUUID(
4448
- eventMetadata[DEFAULT_PLACE_OF_EVENT_PROPERTY]
4449
- );
4450
- if (config.placeOfEvent) {
4451
- const addressFieldValue = AddressFieldValue.safeParse(
4452
- declaration[config.placeOfEvent.$$field]
4453
- );
4454
- if (addressFieldValue.success && addressFieldValue.data.addressType === AddressType.DOMESTIC && addressFieldValue.data.administrativeArea) {
4455
- placeOfEvent = getParsedUUID(
4456
- addressFieldValue.data.administrativeArea,
4457
- placeOfEvent
4458
- );
4459
- } else {
4460
- placeOfEvent = getParsedUUID(
4461
- declaration[config.placeOfEvent.$$field],
4462
- placeOfEvent
4463
- );
4464
- }
4465
- }
4466
- return placeOfEvent;
4467
- }
4468
- function extractPotentialDuplicatesFromActions(actions) {
4469
- return actions.reduce((duplicates, action) => {
4470
- if (action.type === ActionType.DUPLICATE_DETECTED) {
4471
- duplicates = action.content.duplicates;
4472
- }
4473
- if (action.type === ActionType.MARK_AS_NOT_DUPLICATE || action.type === ActionType.MARK_AS_DUPLICATE) {
4474
- duplicates = [];
4475
- }
4476
- return duplicates;
4477
- }, []);
4478
- }
4479
- function getCurrentEventState(event2, config) {
4480
- const sortedActions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
4481
- const creationAction = sortedActions.find(
4482
- (action) => action.type === ActionType.CREATE
4483
- );
4484
- if (!creationAction) {
4485
- throw new Error(`Event ${event2.id} has no creation action`);
4486
- }
4487
- const acceptedActions = getAcceptedActions(event2).sort(
4488
- (a, b) => a.createdAt.localeCompare(b.createdAt)
4489
- );
4490
- const requestActionMetadata = getActionUpdateMetadata(sortedActions);
4491
- const acceptedActionMetadata = getActionUpdateMetadata(acceptedActions);
4492
- const declaration = aggregateActionDeclarations(event2);
4493
- const status2 = getStatusFromActions(sortedActions);
4494
- const legalStatuses = getLegalStatuses(sortedActions);
4495
- const base = deepDropNulls({
4496
- id: event2.id,
4497
- type: event2.type,
4498
- status: status2,
4499
- legalStatuses,
4500
- createdAt: creationAction.createdAt,
4501
- createdBy: creationAction.createdBy,
4502
- createdByUserType: creationAction.createdByUserType,
4503
- createdAtLocation: creationAction.createdAtLocation,
4504
- updatedAt: acceptedActionMetadata.createdAt,
4505
- assignedTo: getAssignedUserFromActions(acceptedActions),
4506
- updatedBy: requestActionMetadata.createdBy,
4507
- updatedAtLocation: requestActionMetadata.createdAtLocation,
4508
- declaration,
4509
- trackingId: event2.trackingId,
4510
- updatedByUserRole: requestActionMetadata.createdByRole,
4511
- placeOfEvent: resolvePlaceOfEvent(
4512
- { createdAtLocation: creationAction.createdAtLocation },
4513
- declaration,
4514
- config
4515
- ),
4516
- potentialDuplicates: extractPotentialDuplicatesFromActions(sortedActions),
4517
- flags: getEventFlags(event2, config)
4518
- });
4519
- return deepDropNulls({
4520
- ...base,
4521
- dateOfEvent: resolveDateOfEvent(base, declaration, config)
4522
- });
4523
- }
4524
-
4525
4162
  // ../commons/src/conditionals/validate.ts
4526
4163
  var ajv = new import__.default({
4527
4164
  $data: true,
@@ -4529,9 +4166,9 @@ var ajv = new import__.default({
4529
4166
  strict: false
4530
4167
  // Allow minContains and other newer features
4531
4168
  });
4532
- var DataContext = z33.object({
4533
- rootData: z33.object({
4534
- $leafAdminStructureLocationIds: z33.array(z33.object({ id: UUID }))
4169
+ var DataContext = z34.object({
4170
+ rootData: z34.object({
4171
+ $leafAdminStructureLocationIds: z34.array(z34.object({ id: UUID }))
4535
4172
  })
4536
4173
  });
4537
4174
  function resolveDataPath(rootData, dataPath, instancePath) {
@@ -4568,33 +4205,15 @@ function compileClientFunction(code) {
4568
4205
  return fn;
4569
4206
  }
4570
4207
  (0, import_ajv_formats.default)(ajv);
4571
- var inMemoryEventStateCache = /* @__PURE__ */ new WeakMap();
4572
- function getInMemoryEventState(event2, config) {
4573
- let stateByConfig = inMemoryEventStateCache.get(event2);
4574
- if (!stateByConfig) {
4575
- stateByConfig = /* @__PURE__ */ new WeakMap();
4576
- inMemoryEventStateCache.set(event2, stateByConfig);
4577
- }
4578
- let state = stateByConfig.get(config);
4579
- if (!state) {
4580
- state = getCurrentEventState(event2, config);
4581
- stateByConfig.set(config, state);
4582
- }
4583
- return state;
4584
- }
4585
4208
  function buildClientFunctionContext(input) {
4586
- const flags = input.validatorContext?.event && input.validatorContext?.eventConfig ? getInMemoryEventState(
4587
- input.validatorContext?.event,
4588
- input.validatorContext?.eventConfig
4589
- )?.flags : [];
4590
4209
  return {
4591
4210
  $form: input.form,
4592
- $flags: flags,
4211
+ $flags: input.validatorContext?.event?.state.flags ?? [],
4593
4212
  $now: todayISO(),
4594
4213
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
4595
4214
  $online: isOnline(),
4596
4215
  $user: input.validatorContext?.user,
4597
- $event: input.validatorContext?.event,
4216
+ $event: input.validatorContext?.event?.document,
4598
4217
  $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
4599
4218
  user: input.systemVariables?.user,
4600
4219
  $window: input.systemVariables?.$window,
@@ -4655,9 +4274,6 @@ ajv.addKeyword({
4655
4274
  return locations.some((location) => location.id === locationIdInput);
4656
4275
  }
4657
4276
  });
4658
- function isAgeValue(value) {
4659
- return typeof value === "object" && value !== null && "age" in value && typeof value.age === "number";
4660
- }
4661
4277
  ajv.addKeyword({
4662
4278
  keyword: "customClientValidator",
4663
4279
  schemaType: "object",
@@ -4675,31 +4291,6 @@ ajv.addKeyword({
4675
4291
  );
4676
4292
  }
4677
4293
  });
4678
- function validate(schema, data) {
4679
- const validator = ajv.getSchema(schema.$id) || ajv.compile(schema);
4680
- if ("$form" in data) {
4681
- const entries = Object.entries(data.$form).map(([key, value]) => {
4682
- if (!isAgeValue(value)) {
4683
- return [key, value];
4684
- }
4685
- const age = value.age;
4686
- const maybeAsOfDate = PlainDate.safeParse(data.$form[value.asOfDateRef]);
4687
- return [
4688
- key,
4689
- {
4690
- age,
4691
- dob: ageToDate(
4692
- age,
4693
- maybeAsOfDate.success ? maybeAsOfDate.data : PlainDate.parse(data.$now)
4694
- )
4695
- }
4696
- ];
4697
- });
4698
- data.$form = Object.fromEntries(entries);
4699
- }
4700
- const result = validator(data);
4701
- return result;
4702
- }
4703
4294
  function isOnline() {
4704
4295
  if (typeof window !== "undefined" && typeof navigator !== "undefined") {
4705
4296
  return navigator.onLine;
@@ -4709,31 +4300,9 @@ function isOnline() {
4709
4300
 
4710
4301
  // ../commons/src/events/utils.ts
4711
4302
  var import_date_fns3 = require("date-fns");
4712
- function ageToDate(age, asOfDate) {
4713
- const date = plainDateToLocalDate(asOfDate);
4714
- return PlainDate.parse((0, import_date_fns3.format)((0, import_date_fns3.subYears)(date, age), "yyyy-MM-dd"));
4715
- }
4716
4303
  function getDeclarationFields(configuration) {
4717
4304
  return configuration.declaration.pages.flatMap(({ fields }) => fields);
4718
4305
  }
4719
- function isActionConfigType(type) {
4720
- return actionConfigTypes.has(type);
4721
- }
4722
- function getActionConfig({
4723
- eventConfiguration,
4724
- actionType,
4725
- customActionType
4726
- }) {
4727
- if (actionType === ActionType.NOTIFY) {
4728
- return eventConfiguration.actions.find((a) => a.type === ActionType.NOTIFY) ?? eventConfiguration.actions.find((a) => a.type === ActionType.DECLARE);
4729
- }
4730
- return eventConfiguration.actions.find((a) => {
4731
- if (a.type === ActionType.CUSTOM && customActionType) {
4732
- return a.customActionType === customActionType;
4733
- }
4734
- return a.type === actionType;
4735
- });
4736
- }
4737
4306
  var getActionAnnotationFields = (actionConfig) => {
4738
4307
  if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
4739
4308
  return actionConfig.correctionForm.pages.flatMap(({ fields }) => fields);
@@ -4748,122 +4317,17 @@ var getActionAnnotationFields = (actionConfig) => {
4748
4317
  function getAllAnnotationFields(config) {
4749
4318
  return (0, import_lodash4.flattenDeep)(config.actions.map(getActionAnnotationFields));
4750
4319
  }
4751
- function deepMerge(currentDocument, actionDocument) {
4752
- const currentDocumentClone = (0, import_lodash4.cloneDeep)(currentDocument);
4753
- return (0, import_lodash4.mergeWith)(
4754
- (0, import_lodash4.cloneDeep)(currentDocumentClone),
4755
- actionDocument,
4756
- (previousValue, incomingValue) => {
4757
- if (incomingValue === void 0) {
4758
- return previousValue;
4759
- }
4760
- if ((0, import_lodash4.isArray)(incomingValue)) {
4761
- return incomingValue;
4762
- }
4763
- if ((0, import_lodash4.isObject)(previousValue) && (0, import_lodash4.isObject)(incomingValue)) {
4764
- return void 0;
4765
- }
4766
- return incomingValue;
4767
- }
4768
- );
4769
- }
4770
4320
  var findAllFields = (config) => {
4771
4321
  return (0, import_lodash4.flattenDeep)([
4772
4322
  ...getDeclarationFields(config),
4773
4323
  ...getAllAnnotationFields(config)
4774
4324
  ]);
4775
4325
  };
4776
- function getMixedPath(obj, path, defaultValue) {
4777
- const parts = path.split(".");
4778
- const resolve = (current, segments) => {
4779
- if (current == null || segments.length === 0) {
4780
- return current;
4781
- }
4782
- for (let i = segments.length; i > 0; i--) {
4783
- const compoundKey = segments.slice(0, i).join(".");
4784
- if ((0, import_lodash4.has)(current, compoundKey)) {
4785
- const next = (0, import_lodash4.get)(current, compoundKey);
4786
- return resolve(next, segments.slice(i));
4787
- }
4788
- }
4789
- return void 0;
4790
- };
4791
- const result = resolve(obj, parts);
4792
- return (0, import_lodash4.isNil)(result) ? defaultValue : result;
4793
- }
4794
- function isAcceptedAction(a) {
4795
- return a.status === ActionStatus.Accepted;
4796
- }
4797
- function getCompleteActionAnnotation(event2, action) {
4798
- if (action.originalActionId) {
4799
- const originalAction = event2.actions.find(
4800
- ({ id }) => id === action.originalActionId
4801
- );
4802
- if (originalAction?.status === ActionStatus.Requested) {
4803
- return deepMerge(originalAction.annotation ?? {}, action.annotation ?? {});
4804
- }
4805
- }
4806
- return action.annotation ?? {};
4807
- }
4808
- function getCompleteActionDeclaration(declaration, event2, action) {
4809
- if (action.originalActionId) {
4810
- const originalAction = event2.actions.find(
4811
- ({ id }) => id === action.originalActionId
4812
- );
4813
- if (originalAction?.status === ActionStatus.Requested) {
4814
- return deepMerge(
4815
- deepMerge(declaration, originalAction.declaration),
4816
- action.declaration
4817
- );
4818
- }
4819
- }
4820
- return deepMerge(declaration, action.declaration);
4821
- }
4822
- function getAcceptedActions(event2) {
4823
- return event2.actions.filter(isAcceptedAction).map((action) => ({
4824
- ...action,
4825
- declaration: getCompleteActionDeclaration({}, event2, action),
4826
- annotation: getCompleteActionAnnotation(event2, action)
4827
- }));
4828
- }
4829
4326
  var EXCLUDED_ACTIONS = [
4830
4327
  ActionType.REQUEST_CORRECTION,
4831
4328
  ActionType.PRINT_CERTIFICATE,
4832
4329
  ActionType.REJECT_CORRECTION
4833
4330
  ];
4834
- function aggregateActionDeclarations(event2) {
4835
- const allAcceptedActions = getAcceptedActions(event2);
4836
- const aggregatedActions = allAcceptedActions.filter((a) => !EXCLUDED_ACTIONS.some((type) => type === a.type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
4837
- return aggregatedActions.reduce((declaration, action) => {
4838
- if (action.type === ActionType.APPROVE_CORRECTION) {
4839
- const requestAction = allAcceptedActions.find(
4840
- ({ id }) => id === action.requestId
4841
- );
4842
- if (!requestAction) {
4843
- return declaration;
4844
- }
4845
- const declarationWithApprovedCorrection = getCompleteActionDeclaration(
4846
- declaration,
4847
- event2,
4848
- requestAction
4849
- );
4850
- return getCompleteActionDeclaration(
4851
- declarationWithApprovedCorrection,
4852
- event2,
4853
- action
4854
- );
4855
- }
4856
- return getCompleteActionDeclaration(declaration, event2, action);
4857
- }, {});
4858
- }
4859
- function aggregateActionAnnotations(event2) {
4860
- return event2.actions.reduce((ann, sortedAction) => {
4861
- if (!("annotation" in sortedAction) || !sortedAction.annotation) {
4862
- return ann;
4863
- }
4864
- return deepMerge(ann, sortedAction.annotation);
4865
- }, {});
4866
- }
4867
4331
 
4868
4332
  // ../commons/src/events/eventConfigValidation.ts
4869
4333
  function validateAdvancedSearchConfig(event2, ctx) {
@@ -4985,11 +4449,11 @@ function validateActionOrder(event2, ctx) {
4985
4449
  }
4986
4450
 
4987
4451
  // ../commons/src/events/EventConfig.ts
4988
- var EventFieldReference = z34.object({ $$event: EventMetadataDateFieldIdInput }).describe(
4452
+ var EventFieldReference = z35.object({ $$event: EventMetadataDateFieldIdInput }).describe(
4989
4453
  "Reference to a field defined in the event metadata, using the field id."
4990
4454
  );
4991
- var _EventConfigBase = z34.object({
4992
- id: z34.string().describe(
4455
+ var _EventConfigBase = z35.object({
4456
+ id: z35.string().describe(
4993
4457
  'Machine-readable identifier of the event (e.g. "birth", "death").'
4994
4458
  ),
4995
4459
  dateOfEvent: FieldReference.or(EventFieldReference).optional().describe(
@@ -5008,25 +4472,25 @@ var _EventConfigBase = z34.object({
5008
4472
  "Summary information displayed in the event overview."
5009
4473
  ),
5010
4474
  label: TranslationConfig.describe("Human-readable label for the event type."),
5011
- actions: z34.array(ActionConfig).describe(
4475
+ actions: z35.array(ActionConfig).describe(
5012
4476
  "Configuration of core and custom actions associated with the event."
5013
4477
  ),
5014
- actionOrder: z34.array(z34.string()).optional().describe(
4478
+ actionOrder: z35.array(z35.string()).optional().describe(
5015
4479
  "Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
5016
4480
  ),
5017
4481
  declaration: DeclarationFormConfig.describe(
5018
4482
  "Configuration of the form used to gather event data."
5019
4483
  ),
5020
- advancedSearch: z34.array(AdvancedSearchConfig).optional().default([]).describe(
4484
+ advancedSearch: z35.array(AdvancedSearchConfig).optional().default([]).describe(
5021
4485
  "Configuration of fields available in the advanced search feature."
5022
4486
  ),
5023
- flags: z34.array(FlagConfig).optional().default([]).describe(
4487
+ flags: z35.array(FlagConfig).optional().default([]).describe(
5024
4488
  "Configuration of custom flags associated with the actions of this event type."
5025
4489
  ),
5026
- analytics: z34.boolean().optional().default(true).describe(
4490
+ analytics: z35.boolean().optional().default(true).describe(
5027
4491
  "Indicates whether the records of this event type are included in analytics"
5028
4492
  ),
5029
- icon: z34.partialRecord(AvailableIcons, Conditional).optional().describe(
4493
+ icon: z35.partialRecord(AvailableIcons, Conditional).optional().describe(
5030
4494
  'Maps an icon name to a conditional. The icon of the first entry (in definition order) whose conditional matches the event is used when rendering it (e.g. in the "iconWithName"/"iconWithNameEvent" workqueue columns). Falls back to the default status-based icon when unset or when no conditional matches.'
5031
4495
  )
5032
4496
  });
@@ -5047,7 +4511,7 @@ var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
5047
4511
  var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
5048
4512
 
5049
4513
  // ../commons/src/events/WorkqueueConfig.ts
5050
- var z37 = __toESM(require("zod/v4"));
4514
+ var z38 = __toESM(require("zod/v4"));
5051
4515
 
5052
4516
  // ../commons/src/searchConfigs.ts
5053
4517
  function createSearchConfig(baseField) {
@@ -5258,17 +4722,17 @@ var event = Object.assign(eventFn, {
5258
4722
  });
5259
4723
 
5260
4724
  // ../commons/src/events/WorkqueueColumnConfig.ts
5261
- var z35 = __toESM(require("zod/v4"));
4725
+ var z36 = __toESM(require("zod/v4"));
5262
4726
  var WorkqueueColumnKeysArray = [
5263
4727
  ...EventMetadataKeysArray,
5264
4728
  "title",
5265
4729
  "outbox"
5266
4730
  ];
5267
- var WorkqueueColumnKeys = z35.enum(WorkqueueColumnKeysArray);
5268
- var WorkqueueColumnValue = z35.object({
4731
+ var WorkqueueColumnKeys = z36.enum(WorkqueueColumnKeysArray);
4732
+ var WorkqueueColumnValue = z36.object({
5269
4733
  $event: WorkqueueColumnKeys
5270
4734
  });
5271
- var WorkqueueColumn = z35.object({
4735
+ var WorkqueueColumn = z36.object({
5272
4736
  label: TranslationConfig,
5273
4737
  value: WorkqueueColumnValue
5274
4738
  }).meta({
@@ -5282,51 +4746,51 @@ function defineWorkqueuesColumns(workqueueColumns) {
5282
4746
  }
5283
4747
 
5284
4748
  // ../commons/src/events/CountryConfigQueryInput.ts
5285
- var z36 = __toESM(require("zod/v4"));
5286
- var SerializableExact = z36.object({
5287
- type: z36.literal("exact"),
5288
- term: z36.union([z36.string(), SerializedUserField])
5289
- });
5290
- var SerializableWithin = z36.object({
5291
- type: z36.literal("within"),
5292
- location: z36.union([z36.string(), SerializedUserField])
5293
- });
5294
- var SerializedQueryExpression = z36.object({
5295
- eventType: z36.string(),
5296
- status: z36.optional(z36.union([AnyOfStatus, ExactStatus])),
5297
- createdAt: z36.optional(DateCondition),
5298
- updatedAt: z36.optional(DateCondition),
5299
- "legalStatuses.DECLARED.createdAtLocation": z36.optional(SerializableWithin),
5300
- "legalStatuses.DECLARED.createdByRole": z36.optional(AnyOf),
5301
- "legalStatuses.REGISTERED.createdAt": z36.optional(DateCondition),
5302
- "legalStatuses.REGISTERED.createdAtLocation": z36.optional(SerializableWithin),
5303
- "legalStatuses.REGISTERED.createdByRole": z36.optional(AnyOf),
5304
- "legalStatuses.REGISTERED.registrationNumber": z36.optional(Exact),
5305
- createdAtLocation: z36.optional(
5306
- z36.union([SerializableWithin, SerializableExact])
4749
+ var z37 = __toESM(require("zod/v4"));
4750
+ var SerializableExact = z37.object({
4751
+ type: z37.literal("exact"),
4752
+ term: z37.union([z37.string(), SerializedUserField])
4753
+ });
4754
+ var SerializableWithin = z37.object({
4755
+ type: z37.literal("within"),
4756
+ location: z37.union([z37.string(), SerializedUserField])
4757
+ });
4758
+ var SerializedQueryExpression = z37.object({
4759
+ eventType: z37.string(),
4760
+ status: z37.optional(z37.union([AnyOfStatus, ExactStatus])),
4761
+ createdAt: z37.optional(DateCondition),
4762
+ updatedAt: z37.optional(DateCondition),
4763
+ "legalStatuses.DECLARED.createdAtLocation": z37.optional(SerializableWithin),
4764
+ "legalStatuses.DECLARED.createdByRole": z37.optional(AnyOf),
4765
+ "legalStatuses.REGISTERED.createdAt": z37.optional(DateCondition),
4766
+ "legalStatuses.REGISTERED.createdAtLocation": z37.optional(SerializableWithin),
4767
+ "legalStatuses.REGISTERED.createdByRole": z37.optional(AnyOf),
4768
+ "legalStatuses.REGISTERED.registrationNumber": z37.optional(Exact),
4769
+ createdAtLocation: z37.optional(
4770
+ z37.union([SerializableWithin, SerializableExact])
5307
4771
  ),
5308
- updatedAtLocation: z36.optional(
5309
- z36.union([SerializableWithin, SerializableExact])
4772
+ updatedAtLocation: z37.optional(
4773
+ z37.union([SerializableWithin, SerializableExact])
5310
4774
  ),
5311
- updatedByUserRole: z36.optional(SerializableExact),
5312
- assignedTo: z36.optional(SerializableExact),
5313
- createdBy: z36.optional(SerializableExact),
4775
+ updatedByUserRole: z37.optional(SerializableExact),
4776
+ assignedTo: z37.optional(SerializableExact),
4777
+ createdBy: z37.optional(SerializableExact),
5314
4778
  createdByUserType: ExactUserType,
5315
- updatedBy: z36.optional(SerializableExact),
5316
- trackingId: z36.optional(Exact),
5317
- flags: z36.optional(ContainsFlags),
4779
+ updatedBy: z37.optional(SerializableExact),
4780
+ trackingId: z37.optional(Exact),
4781
+ flags: z37.optional(ContainsFlags),
5318
4782
  data: QueryInput
5319
4783
  }).partial();
5320
- var Or2 = z36.object({
5321
- type: z36.literal("or"),
5322
- clauses: z36.array(SerializedQueryExpression)
4784
+ var Or2 = z37.object({
4785
+ type: z37.literal("or"),
4786
+ clauses: z37.array(SerializedQueryExpression)
5323
4787
  });
5324
- var And2 = z36.object({
5325
- type: z36.literal("and"),
5326
- clauses: z36.array(SerializedQueryExpression)
4788
+ var And2 = z37.object({
4789
+ type: z37.literal("and"),
4790
+ clauses: z37.array(SerializedQueryExpression)
5327
4791
  });
5328
- var CountryConfigQueryType = z36.discriminatedUnion("type", [And2, Or2]);
5329
- var CountryConfigQueryInputType = z36.union([
4792
+ var CountryConfigQueryType = z37.discriminatedUnion("type", [And2, Or2]);
4793
+ var CountryConfigQueryInputType = z37.union([
5330
4794
  SerializedQueryExpression,
5331
4795
  And2,
5332
4796
  Or2
@@ -5351,16 +4815,16 @@ var mandatoryColumns = defineWorkqueuesColumns([
5351
4815
  value: event.field("updatedAt")
5352
4816
  }
5353
4817
  ]);
5354
- var WorkqueueConfig = z37.object({
5355
- slug: z37.string().describe("Determines the url of the workqueue."),
4818
+ var WorkqueueConfig = z38.object({
4819
+ slug: z38.string().describe("Determines the url of the workqueue."),
5356
4820
  name: TranslationConfig.describe(
5357
4821
  "Title of the workflow (both in navigation and on the page)"
5358
4822
  ),
5359
4823
  query: CountryConfigQueryType,
5360
- action: z37.object({ type: WorkqueueActionType }).optional().describe(
4824
+ action: z38.object({ type: WorkqueueActionType }).optional().describe(
5361
4825
  "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."
5362
4826
  ),
5363
- columns: z37.array(WorkqueueColumn).default(mandatoryColumns),
4827
+ columns: z38.array(WorkqueueColumn).default(mandatoryColumns),
5364
4828
  icon: AvailableIcons,
5365
4829
  emptyMessage: TranslationConfig.optional()
5366
4830
  }).describe("Configuration for workqueue.");
@@ -5374,10 +4838,10 @@ var WorkqueueConfigInput = WorkqueueConfig.extend({
5374
4838
  id: "WorkqueueConfig",
5375
4839
  description: "Configuration for a single workqueue. Defines the filter applied to the event index, the quick-action button, the columns shown on each row, and the message rendered when the queue is empty."
5376
4840
  });
5377
- var WorkqueueCountInput = z37.array(
5378
- z37.object({ slug: z37.string(), query: QueryType })
4841
+ var WorkqueueCountInput = z38.array(
4842
+ z38.object({ slug: z38.string(), query: QueryType })
5379
4843
  );
5380
- var WorkqueueCountOutput = z37.record(z37.string(), z37.number());
4844
+ var WorkqueueCountOutput = z38.record(z38.string(), z38.number());
5381
4845
 
5382
4846
  // ../commons/src/events/workqueueDefaultColumns.ts
5383
4847
  var defaultWorkqueueColumns = [
@@ -5400,21 +4864,21 @@ var defaultWorkqueueColumns = [
5400
4864
  ];
5401
4865
 
5402
4866
  // ../commons/src/events/Draft.ts
5403
- var z39 = __toESM(require("zod/v4"));
4867
+ var z40 = __toESM(require("zod/v4"));
5404
4868
 
5405
4869
  // ../commons/src/events/ActionInput.ts
5406
- var z38 = __toESM(require("zod/v4"));
5407
- var BaseActionInput = z38.object({
4870
+ var z39 = __toESM(require("zod/v4"));
4871
+ var BaseActionInput = z39.object({
5408
4872
  eventId: UUID,
5409
- transactionId: z38.string(),
4873
+ transactionId: z39.string(),
5410
4874
  declaration: ActionUpdate.default({}),
5411
4875
  annotation: ActionUpdate.optional(),
5412
4876
  originalActionId: UUID.optional(),
5413
4877
  // should not be part of base action.
5414
- keepAssignment: z38.boolean().optional(),
5415
- keepAssignmentIfAccepted: z38.boolean().optional(),
5416
- keepAssignmentIfRejected: z38.boolean().optional(),
5417
- waitFor: z38.boolean().default(true).describe(
4878
+ keepAssignment: z39.boolean().optional(),
4879
+ keepAssignmentIfAccepted: z39.boolean().optional(),
4880
+ keepAssignmentIfRejected: z39.boolean().optional(),
4881
+ waitFor: z39.boolean().default(true).describe(
5418
4882
  "Whether action waits for the indexing before returning. Defaults to true. Setting this to to false completes faster but might lead to stale data in the client if the client tries to read the event immediately after performing the action. Use with care."
5419
4883
  ),
5420
4884
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
@@ -5424,8 +4888,8 @@ var BaseActionInput = z38.object({
5424
4888
  )
5425
4889
  });
5426
4890
  var CreateActionInput = BaseActionInput.extend(
5427
- z38.object({
5428
- type: z38.literal(ActionType.CREATE).default(ActionType.CREATE),
4891
+ z39.object({
4892
+ type: z39.literal(ActionType.CREATE).default(ActionType.CREATE),
5429
4893
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
5430
4894
  createdAtLocation: UUID.nullish().describe(
5431
4895
  "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."
@@ -5433,14 +4897,14 @@ var CreateActionInput = BaseActionInput.extend(
5433
4897
  }).shape
5434
4898
  );
5435
4899
  var RegisterActionInput = BaseActionInput.extend(
5436
- z38.strictObject({
5437
- type: z38.literal(ActionType.REGISTER).default(ActionType.REGISTER),
5438
- registrationNumber: z38.string().optional()
4900
+ z39.strictObject({
4901
+ type: z39.literal(ActionType.REGISTER).default(ActionType.REGISTER),
4902
+ registrationNumber: z39.string().optional()
5439
4903
  }).shape
5440
4904
  );
5441
4905
  var NotifyActionInput = BaseActionInput.extend(
5442
- z38.object({
5443
- type: z38.literal(ActionType.NOTIFY).default(ActionType.NOTIFY),
4906
+ z39.object({
4907
+ type: z39.literal(ActionType.NOTIFY).default(ActionType.NOTIFY),
5444
4908
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
5445
4909
  createdAtLocation: UUID.nullish().describe(
5446
4910
  "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."
@@ -5456,103 +4920,107 @@ var NotifyActionInput = BaseActionInput.extend(
5456
4920
  }
5457
4921
  });
5458
4922
  var DeclareActionInput = BaseActionInput.extend(
5459
- z38.object({
5460
- type: z38.literal(ActionType.DECLARE).default(ActionType.DECLARE)
4923
+ z39.object({
4924
+ type: z39.literal(ActionType.DECLARE).default(ActionType.DECLARE)
5461
4925
  }).shape
5462
4926
  );
5463
4927
  var EditActionInput = BaseActionInput.extend(
5464
- z38.object({
5465
- type: z38.literal(ActionType.EDIT).default(ActionType.EDIT)
4928
+ z39.object({
4929
+ type: z39.literal(ActionType.EDIT).default(ActionType.EDIT)
5466
4930
  }).shape
5467
4931
  );
5468
4932
  var PrintCertificateActionInput = BaseActionInput.extend(
5469
- z38.object({
5470
- type: z38.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE),
4933
+ z39.object({
4934
+ type: z39.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE),
5471
4935
  content: PrintContent.optional()
5472
4936
  }).shape
5473
4937
  );
5474
4938
  var RejectDeclarationActionInput = BaseActionInput.extend(
5475
- z38.object({
5476
- type: z38.literal(ActionType.REJECT).default(ActionType.REJECT),
4939
+ z39.object({
4940
+ type: z39.literal(ActionType.REJECT).default(ActionType.REJECT),
5477
4941
  content: ReasonContent
5478
4942
  }).shape
5479
4943
  );
5480
4944
  var DuplicateDetectedActionInput = BaseActionInput.extend(
5481
- z38.object({
5482
- type: z38.literal(ActionType.DUPLICATE_DETECTED).default(ActionType.DUPLICATE_DETECTED),
5483
- content: z38.object({
5484
- duplicates: z38.array(PotentialDuplicate)
4945
+ z39.object({
4946
+ type: z39.literal(ActionType.DUPLICATE_DETECTED).default(ActionType.DUPLICATE_DETECTED),
4947
+ content: z39.object({
4948
+ duplicates: z39.array(PotentialDuplicate)
5485
4949
  })
5486
4950
  }).shape
5487
4951
  );
5488
4952
  var MarkAsDuplicateActionInput = BaseActionInput.extend(
5489
- z38.object({
5490
- type: z38.literal(ActionType.MARK_AS_DUPLICATE).default(ActionType.MARK_AS_DUPLICATE),
5491
- content: z38.object({
4953
+ z39.object({
4954
+ type: z39.literal(ActionType.MARK_AS_DUPLICATE).default(ActionType.MARK_AS_DUPLICATE),
4955
+ content: z39.object({
5492
4956
  duplicateOf: UUID
5493
4957
  }).optional()
5494
4958
  }).shape
5495
4959
  );
5496
4960
  var MarkNotDuplicateActionInput = BaseActionInput.extend(
5497
- z38.object({
5498
- type: z38.literal(ActionType.MARK_AS_NOT_DUPLICATE).default(ActionType.MARK_AS_NOT_DUPLICATE)
4961
+ z39.object({
4962
+ type: z39.literal(ActionType.MARK_AS_NOT_DUPLICATE).default(ActionType.MARK_AS_NOT_DUPLICATE)
5499
4963
  }).shape
5500
4964
  );
5501
4965
  var ArchiveActionInput = BaseActionInput.extend(
5502
- z38.object({
5503
- type: z38.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
5504
- content: ReasonContent
4966
+ z39.object({
4967
+ type: z39.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
4968
+ /**
4969
+ * Archiving does not collect a reason on its own. Only the
4970
+ * "mark as duplicate" flow archives with a reason attached.
4971
+ */
4972
+ content: ReasonContent.optional()
5505
4973
  }).shape
5506
4974
  );
5507
4975
  var UnarchiveActionInput = BaseActionInput.extend(
5508
- z38.object({
5509
- type: z38.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
4976
+ z39.object({
4977
+ type: z39.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
5510
4978
  }).shape
5511
4979
  );
5512
4980
  var AssignActionInput = BaseActionInput.extend(
5513
- z38.object({
5514
- type: z38.literal(ActionType.ASSIGN),
5515
- assignedTo: z38.string()
4981
+ z39.object({
4982
+ type: z39.literal(ActionType.ASSIGN),
4983
+ assignedTo: z39.string()
5516
4984
  }).shape
5517
4985
  );
5518
4986
  var UnassignActionInput = BaseActionInput.extend(
5519
- z38.object({
5520
- type: z38.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
5521
- assignedTo: z38.literal(null).default(null)
4987
+ z39.object({
4988
+ type: z39.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
4989
+ assignedTo: z39.literal(null).default(null)
5522
4990
  }).shape
5523
4991
  );
5524
4992
  var RequestCorrectionActionInput = BaseActionInput.extend(
5525
- z38.object({
5526
- type: z38.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
4993
+ z39.object({
4994
+ type: z39.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
5527
4995
  }).shape
5528
4996
  );
5529
4997
  var RejectCorrectionActionInput = BaseActionInput.extend(
5530
- z38.object({
5531
- requestId: z38.string(),
5532
- type: z38.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION),
4998
+ z39.object({
4999
+ requestId: z39.string(),
5000
+ type: z39.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION),
5533
5001
  content: ReasonContent
5534
5002
  }).shape
5535
5003
  );
5536
5004
  var ApproveCorrectionActionInput = BaseActionInput.extend(
5537
- z38.object({
5538
- requestId: z38.string(),
5539
- type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION),
5540
- content: z38.object({ immediateCorrection: z38.boolean().optional() }).optional()
5005
+ z39.object({
5006
+ requestId: z39.string(),
5007
+ type: z39.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION),
5008
+ content: z39.object({ immediateCorrection: z39.boolean().optional() }).optional()
5541
5009
  }).shape
5542
5010
  );
5543
5011
  var ReadActionInput = BaseActionInput.extend(
5544
- z38.object({
5545
- type: z38.literal(ActionType.READ).default(ActionType.READ)
5012
+ z39.object({
5013
+ type: z39.literal(ActionType.READ).default(ActionType.READ)
5546
5014
  }).shape
5547
5015
  );
5548
- var DeleteActionInput = z38.object({ eventId: UUID });
5016
+ var DeleteActionInput = z39.object({ eventId: UUID });
5549
5017
  var CustomActionInput = BaseActionInput.extend(
5550
- z38.object({
5551
- type: z38.literal(ActionType.CUSTOM).default(ActionType.CUSTOM),
5552
- customActionType: z38.string().describe("Name of the custom action.")
5018
+ z39.object({
5019
+ type: z39.literal(ActionType.CUSTOM).default(ActionType.CUSTOM),
5020
+ customActionType: z39.string().describe("Name of the custom action.")
5553
5021
  }).shape
5554
5022
  );
5555
- var ActionInput = z38.discriminatedUnion("type", [
5023
+ var ActionInput = z39.discriminatedUnion("type", [
5556
5024
  CreateActionInput.meta({ id: "CreateActionInput" }),
5557
5025
  RegisterActionInput.meta({ id: "RegisterActionInput" }),
5558
5026
  NotifyActionInput.meta({ id: "NotifyActionInput" }),
@@ -5589,11 +5057,11 @@ var ActionInput = z38.discriminatedUnion("type", [
5589
5057
  });
5590
5058
 
5591
5059
  // ../commons/src/events/Draft.ts
5592
- var Draft = z39.object({
5060
+ var Draft = z40.object({
5593
5061
  id: UUID,
5594
5062
  eventId: UUID,
5595
- transactionId: z39.string(),
5596
- createdAt: z39.string().datetime(),
5063
+ transactionId: z40.string(),
5064
+ createdAt: z40.string().datetime(),
5597
5065
  action: ActionBase.extend({
5598
5066
  type: ActionTypes.exclude([ActionTypes.enum.DELETE])
5599
5067
  }).omit({ id: true, createdAtLocation: true })
@@ -5602,7 +5070,7 @@ var Draft = z39.object({
5602
5070
  );
5603
5071
  var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
5604
5072
  type: ActionTypes.exclude([ActionTypes.enum.DELETE]),
5605
- status: z39.enum([
5073
+ status: z40.enum([
5606
5074
  ActionStatus.Requested,
5607
5075
  ActionStatus.Accepted,
5608
5076
  ActionStatus.Rejected
@@ -5610,30 +5078,33 @@ var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
5610
5078
  });
5611
5079
 
5612
5080
  // ../commons/src/events/EventInput.ts
5613
- var z40 = __toESM(require("zod/v4"));
5081
+ var z41 = __toESM(require("zod/v4"));
5614
5082
  var import_uuid11 = require("uuid");
5615
- var EventInput = z40.object({
5616
- transactionId: z40.string(),
5617
- type: z40.string(),
5083
+ var EventInput = z41.object({
5084
+ transactionId: z41.string(),
5085
+ type: z41.string(),
5618
5086
  createdAtLocation: UUID.nullish().describe(
5619
5087
  "Location where the event occurred. Required for system users."
5620
5088
  )
5621
5089
  }).meta({ default: { transactionId: (0, import_uuid11.v4)(), type: "birth" } });
5622
5090
 
5623
5091
  // ../commons/src/events/EventDocument.ts
5624
- var z41 = __toESM(require("zod/v4"));
5625
- var EventDocument = z41.object({
5092
+ var z42 = __toESM(require("zod/v4"));
5093
+ var EventDocument = z42.object({
5626
5094
  id: UUID.describe("Unique identifier of the event."),
5627
- type: z41.string().describe("Type of the event (e.g. birth, death, marriage)."),
5628
- createdAt: z41.string().datetime().describe("Timestamp indicating when the event was created."),
5629
- updatedAt: z41.string().datetime().describe(
5095
+ type: z42.string().describe("Type of the event (e.g. birth, death, marriage)."),
5096
+ createdAt: z42.string().datetime().describe("Timestamp indicating when the event was created."),
5097
+ updatedAt: z42.string().datetime().describe(
5630
5098
  "Timestamp of the last update, excluding changes from actions."
5631
5099
  ),
5632
- actions: z41.array(Action).describe("Ordered list of actions associated with the event."),
5633
- trackingId: z41.string().describe(
5100
+ actions: z42.array(Action).describe("Ordered list of actions associated with the event."),
5101
+ trackingId: z42.string().describe(
5634
5102
  "System-generated tracking identifier used to look up the event."
5635
5103
  )
5636
5104
  }).meta({ id: "EventDocument" });
5105
+ var EventDocumentOnlyLastAction = EventDocument.extend({
5106
+ actions: z42.array(Action).max(1).describe("Only the last action associated with the event.")
5107
+ }).brand("EventDocumentOnlyLastAction");
5637
5108
 
5638
5109
  // ../commons/src/events/defineConfig.ts
5639
5110
  var IGNORED_EVENT_TYPES = [
@@ -8084,8 +7555,8 @@ var digitalIdentityEvent = defineConfig({
8084
7555
  });
8085
7556
 
8086
7557
  // ../commons/src/events/test.utils.ts
8087
- var z42 = __toESM(require("zod/v4"));
8088
- var TestUserRole = z42.enum([
7558
+ var z43 = __toESM(require("zod/v4"));
7559
+ var TestUserRole = z43.enum([
8089
7560
  "FIELD_AGENT",
8090
7561
  "LOCAL_REGISTRAR",
8091
7562
  "LOCAL_SYSTEM_ADMIN",
@@ -8101,36 +7572,36 @@ var TestUserRole = z42.enum([
8101
7572
  var import_lodash6 = require("lodash");
8102
7573
 
8103
7574
  // ../commons/src/events/locations.ts
8104
- var z43 = __toESM(require("zod/v4"));
8105
- var LocationTypeV1 = z43.enum([
7575
+ var z44 = __toESM(require("zod/v4"));
7576
+ var LocationTypeV1 = z44.enum([
8106
7577
  "ADMIN_STRUCTURE",
8107
7578
  "CRVS_OFFICE",
8108
7579
  "HEALTH_FACILITY"
8109
7580
  ]);
8110
- var LocationStatus = z43.enum(["active", "inactive"]);
8111
- var LocationVersion = z43.object({
7581
+ var LocationStatus = z44.enum(["active", "inactive"]);
7582
+ var LocationVersion = z44.object({
8112
7583
  versionId: UUID,
8113
- effectiveFrom: z43.iso.date(),
8114
- name: z43.string(),
8115
- externalId: z43.string().nullish(),
7584
+ effectiveFrom: z44.iso.date(),
7585
+ name: z44.string(),
7586
+ externalId: z44.string().nullish(),
8116
7587
  status: LocationStatus
8117
7588
  });
8118
- var AdministrativeArea = z43.object({
7589
+ var AdministrativeArea = z44.object({
8119
7590
  id: UUID,
8120
- name: z43.string(),
8121
- externalId: z43.string().nullish(),
7591
+ name: z44.string(),
7592
+ externalId: z44.string().nullish(),
8122
7593
  parentId: UUID.nullable(),
8123
7594
  status: LocationStatus,
8124
- versions: z43.array(LocationVersion)
7595
+ versions: z44.array(LocationVersion)
8125
7596
  });
8126
- var Location = z43.object({
7597
+ var Location = z44.object({
8127
7598
  id: UUID,
8128
- name: z43.string(),
8129
- externalId: z43.string().nullish(),
7599
+ name: z44.string(),
7600
+ externalId: z44.string().nullish(),
8130
7601
  administrativeAreaId: UUID.nullable(),
8131
- locationType: z43.string().nullable(),
7602
+ locationType: z44.string().nullable(),
8132
7603
  status: LocationStatus,
8133
- versions: z43.array(LocationVersion)
7604
+ versions: z44.array(LocationVersion)
8134
7605
  });
8135
7606
  var ClientAdministrativeArea = AdministrativeArea.omit({
8136
7607
  name: true,
@@ -8157,18 +7628,38 @@ function toClientAdministrativeArea(area) {
8157
7628
  versions: area.versions
8158
7629
  };
8159
7630
  }
8160
- var SetLocationPayload = z43.object({
7631
+ function validateAscendingDates(versions, ctx) {
7632
+ const ascending = versions.every(
7633
+ (version, index) => index === 0 || versions[index - 1].effectiveFrom < version.effectiveFrom
7634
+ );
7635
+ if (!ascending) {
7636
+ ctx.addIssue("versions must be strictly ascending by effectiveFrom");
7637
+ }
7638
+ }
7639
+ function validateUniqueIds(versions, ctx) {
7640
+ const versionIds = new Set(versions.map((version) => version.versionId));
7641
+ if (versionIds.size !== versions.length) {
7642
+ ctx.addIssue("versions must not repeat a versionId");
7643
+ }
7644
+ }
7645
+ var SeededLocationVersions = z44.array(LocationVersion).min(1).superRefine((versions, ctx) => {
7646
+ validateAscendingDates(versions, ctx);
7647
+ validateUniqueIds(versions, ctx);
7648
+ });
7649
+ var SetLocationPayload = z44.object({
8161
7650
  id: UUID,
8162
- name: z43.string(),
8163
- externalId: z43.string().nullish(),
7651
+ name: z44.string(),
7652
+ externalId: z44.string().nullish(),
8164
7653
  administrativeAreaId: UUID.nullable(),
8165
- locationType: z43.string().nullable()
7654
+ locationType: z44.string().nullable(),
7655
+ versions: SeededLocationVersions.optional()
8166
7656
  });
8167
- var SetAdministrativeAreaPayload = z43.object({
7657
+ var SetAdministrativeAreaPayload = z44.object({
8168
7658
  id: UUID,
8169
- name: z43.string(),
8170
- externalId: z43.string().nullish(),
8171
- parentId: UUID.nullable()
7659
+ name: z44.string(),
7660
+ externalId: z44.string().nullish(),
7661
+ parentId: UUID.nullable(),
7662
+ versions: SeededLocationVersions.optional()
8172
7663
  });
8173
7664
 
8174
7665
  // ../commons/src/events/scopes.ts
@@ -8205,8 +7696,7 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
8205
7696
  ActionType.READ,
8206
7697
  ActionType.DECLARE,
8207
7698
  ActionType.NOTIFY,
8208
- ActionType.DELETE,
8209
- ActionType.CUSTOM
7699
+ ActionType.DELETE
8210
7700
  ],
8211
7701
  [EventStatus.enum.NOTIFIED]: [
8212
7702
  ActionType.READ,
@@ -8610,136 +8100,198 @@ var V2_DEFAULT_MOCK_CLIENT_ADMINISTRATIVE_AREAS_MAP = new Map(
8610
8100
  );
8611
8101
 
8612
8102
  // ../commons/src/events/locationPayloads.ts
8613
- var z44 = __toESM(require("zod/v4"));
8614
- var CreateLocationPayload = z44.object({
8103
+ var z45 = __toESM(require("zod/v4"));
8104
+ var CreateLocationPayload = z45.object({
8615
8105
  id: UUID.optional(),
8616
8106
  versionId: UUID.optional(),
8617
- name: z44.string(),
8618
- externalId: z44.string().nullish(),
8107
+ name: z45.string(),
8108
+ externalId: z45.string().nullish(),
8619
8109
  administrativeAreaId: UUID.nullable(),
8620
- locationType: z44.string().nullable(),
8621
- effectiveFrom: z44.iso.date().optional(),
8110
+ locationType: z45.string().nullable(),
8111
+ effectiveFrom: z45.iso.date().optional(),
8622
8112
  status: LocationStatus.default("active")
8623
8113
  });
8624
- var UpdateLocationPayload = z44.strictObject({
8114
+ var UpdateLocationPayload = z45.strictObject({
8625
8115
  id: UUID,
8626
8116
  versionId: UUID.optional(),
8627
- name: z44.string(),
8628
- externalId: z44.string().nullish(),
8117
+ name: z45.string(),
8118
+ externalId: z45.string().nullish(),
8629
8119
  status: LocationStatus,
8630
- effectiveFrom: z44.iso.date().optional(),
8120
+ effectiveFrom: z45.iso.date().optional(),
8631
8121
  lastVersionId: UUID
8632
8122
  });
8633
- var WithdrawLocationVersionPayload = z44.object({
8123
+ var WithdrawLocationVersionPayload = z45.object({
8634
8124
  id: UUID,
8635
8125
  versionId: UUID
8636
8126
  });
8637
- var CreateAdministrativeAreaPayload = z44.object({
8127
+ var CreateAdministrativeAreaPayload = z45.object({
8638
8128
  id: UUID.optional(),
8639
8129
  versionId: UUID.optional(),
8640
- name: z44.string(),
8641
- externalId: z44.string().nullish(),
8130
+ name: z45.string(),
8131
+ externalId: z45.string().nullish(),
8642
8132
  parentId: UUID.nullable(),
8643
- effectiveFrom: z44.iso.date().optional(),
8133
+ effectiveFrom: z45.iso.date().optional(),
8644
8134
  status: LocationStatus.default("active")
8645
8135
  });
8646
- var UpdateAdministrativeAreaPayload = z44.strictObject({
8136
+ var UpdateAdministrativeAreaPayload = z45.strictObject({
8647
8137
  id: UUID,
8648
8138
  versionId: UUID.optional(),
8649
- name: z44.string(),
8650
- externalId: z44.string().nullish(),
8139
+ name: z45.string(),
8140
+ externalId: z45.string().nullish(),
8651
8141
  status: LocationStatus,
8652
- effectiveFrom: z44.iso.date().optional(),
8142
+ effectiveFrom: z45.iso.date().optional(),
8653
8143
  lastVersionId: UUID
8654
8144
  });
8655
- var WithdrawAdministrativeAreaVersionPayload = z44.object({
8145
+ var WithdrawAdministrativeAreaVersionPayload = z45.object({
8656
8146
  id: UUID,
8657
8147
  versionId: UUID
8658
8148
  });
8659
8149
 
8660
8150
  // ../commons/src/notification/UserNotifications.ts
8661
- var z45 = __toESM(require("zod/v4"));
8151
+ var z46 = __toESM(require("zod/v4"));
8662
8152
  var TriggerEvent = {
8663
8153
  USER_CREATED: "user-created",
8664
8154
  USER_UPDATED: "user-updated",
8665
8155
  USERNAME_REMINDER: "username-reminder",
8666
8156
  RESET_PASSWORD: "reset-password",
8667
8157
  RESET_PASSWORD_BY_ADMIN: "reset-password-by-admin",
8158
+ PASSWORD_RESET_LINK: "password-reset-link",
8159
+ USERNAME_REMINDER_LINK: "username-reminder-link",
8668
8160
  RESEND_INVITE: "resend-invite",
8669
8161
  TWO_FA: "2fa",
8670
8162
  ALL_USER_NOTIFICATION: "all-user-notification",
8671
8163
  CHANGE_PHONE_NUMBER: "change-phone-number",
8672
8164
  CHANGE_EMAIL_ADDRESS: "change-email-address"
8673
8165
  };
8674
- var Recipient = z45.object({
8166
+ var Recipient = z46.object({
8675
8167
  name: NameFieldValue.optional(),
8676
- mobile: z45.string().optional(),
8677
- email: z45.string().optional(),
8678
- bcc: z45.array(z45.string()).optional()
8168
+ mobile: z46.string().optional(),
8169
+ email: z46.string().optional(),
8170
+ bcc: z46.array(z46.string()).optional()
8679
8171
  });
8680
- var BasePayload = z45.object({
8172
+ var BasePayload = z46.object({
8681
8173
  recipient: Recipient
8682
8174
  });
8683
8175
  var TriggerPayload = {
8684
8176
  [TriggerEvent.USER_CREATED]: BasePayload.extend({
8685
- username: z45.string(),
8686
- temporaryPassword: z45.string()
8177
+ username: z46.string(),
8178
+ temporaryPassword: z46.string()
8687
8179
  }),
8688
8180
  [TriggerEvent.USER_UPDATED]: BasePayload.extend({
8689
- oldUsername: z45.string(),
8690
- newUsername: z45.string()
8181
+ oldUsername: z46.string(),
8182
+ newUsername: z46.string()
8691
8183
  }),
8692
8184
  [TriggerEvent.USERNAME_REMINDER]: BasePayload.extend({
8693
- username: z45.string()
8185
+ username: z46.string()
8694
8186
  }),
8695
8187
  [TriggerEvent.RESET_PASSWORD]: BasePayload.extend({
8696
- code: z45.string()
8188
+ code: z46.string()
8697
8189
  }),
8698
8190
  [TriggerEvent.RESET_PASSWORD_BY_ADMIN]: BasePayload.extend({
8699
- temporaryPassword: z45.string(),
8700
- admin: z45.object({
8701
- id: z45.string(),
8191
+ temporaryPassword: z46.string(),
8192
+ admin: z46.object({
8193
+ id: z46.string(),
8702
8194
  name: NameFieldValue,
8703
- role: z45.string()
8195
+ role: z46.string()
8704
8196
  })
8705
8197
  }),
8198
+ [TriggerEvent.PASSWORD_RESET_LINK]: BasePayload.extend({
8199
+ token: z46.string()
8200
+ }),
8201
+ [TriggerEvent.USERNAME_REMINDER_LINK]: BasePayload.extend({
8202
+ token: z46.string()
8203
+ }),
8706
8204
  [TriggerEvent.RESEND_INVITE]: BasePayload.extend({
8707
- username: z45.string(),
8708
- temporaryPassword: z45.string()
8205
+ username: z46.string(),
8206
+ temporaryPassword: z46.string()
8709
8207
  }),
8710
8208
  [TriggerEvent.TWO_FA]: BasePayload.extend({
8711
- code: z45.string()
8209
+ code: z46.string()
8712
8210
  }),
8713
8211
  [TriggerEvent.ALL_USER_NOTIFICATION]: BasePayload.extend({
8714
- subject: z45.string(),
8715
- body: z45.string()
8212
+ subject: z46.string(),
8213
+ body: z46.string()
8716
8214
  }),
8717
8215
  [TriggerEvent.CHANGE_PHONE_NUMBER]: BasePayload.extend({
8718
- code: z45.string()
8216
+ code: z46.string()
8719
8217
  }),
8720
8218
  [TriggerEvent.CHANGE_EMAIL_ADDRESS]: BasePayload.extend({
8721
- code: z45.string()
8219
+ code: z46.string()
8722
8220
  })
8723
8221
  };
8222
+ function parseUserEventTrigger(event2, body) {
8223
+ const schema = TriggerPayload[event2];
8224
+ return schema.parse(body);
8225
+ }
8226
+
8227
+ // ../commons/src/url.ts
8228
+ function joinUrl(base, path) {
8229
+ const baseWithSlash = base.endsWith("/") ? base : base + "/";
8230
+ return new URL(path, baseWithSlash);
8231
+ }
8232
+
8233
+ // ../commons/src/logger.ts
8234
+ var import_pino = __toESM(require("pino"));
8235
+ function filterHealthCheckLogs(args, method) {
8236
+ const logger2 = this;
8237
+ for (const arg of args) {
8238
+ if (typeof arg === "string" && arg.includes("get /ping 200")) {
8239
+ if (logger2.debug) {
8240
+ return logger2.debug(...args);
8241
+ }
8242
+ }
8243
+ }
8244
+ return method.apply(this, args);
8245
+ }
8246
+ var logger = false ? (0, import_pino.default)({
8247
+ level: "info",
8248
+ redact: [
8249
+ "req.headers.authorization",
8250
+ "req.remoteAddress",
8251
+ "req.headers['x-real-ip']"
8252
+ ],
8253
+ hooks: { logMethod: filterHealthCheckLogs }
8254
+ }) : (0, import_pino.default)({
8255
+ level: "debug",
8256
+ transport: {
8257
+ target: "pino-pretty",
8258
+ options: {
8259
+ colorize: true,
8260
+ ignore: "pid,hostname"
8261
+ }
8262
+ },
8263
+ hooks: { logMethod: filterHealthCheckLogs }
8264
+ });
8265
+ var level = false ? "silent" : process.env.LOG_LEVEL;
8266
+ if (level) {
8267
+ logger.level = level;
8268
+ }
8269
+
8270
+ // ../commons/src/notification/dispatch.ts
8724
8271
  async function triggerUserEventNotification({
8725
8272
  event: event2,
8726
8273
  payload,
8727
8274
  countryConfigUrl,
8728
8275
  authHeader
8729
8276
  }) {
8730
- return await fetch(joinUrl(countryConfigUrl, `triggers/user/${event2}`), {
8731
- method: "POST",
8732
- body: JSON.stringify(payload),
8733
- headers: {
8734
- "Content-Type": "application/json",
8735
- ...authHeader
8277
+ const response = await fetch(
8278
+ joinUrl(countryConfigUrl, `triggers/user/${event2}`),
8279
+ {
8280
+ method: "POST",
8281
+ body: JSON.stringify(payload),
8282
+ headers: {
8283
+ "Content-Type": "application/json",
8284
+ ...authHeader
8285
+ }
8736
8286
  }
8737
- });
8738
- }
8739
- function parseUserEventTrigger(event2, body) {
8740
- const schema = TriggerPayload[event2];
8741
- return schema.parse(body);
8287
+ );
8288
+ if (!response.ok) {
8289
+ logger.error(
8290
+ `triggerUserEventNotification: dispatch failed for event "${event2}" with status ${response.status}`
8291
+ );
8292
+ }
8293
+ return response;
8742
8294
  }
8743
8295
 
8744
8296
  // src/notification/index.ts
8745
- z46.globalRegistry.clear();
8297
+ z47.globalRegistry.clear();