@opencrvs/toolkit 2.1.0-rc.d7bd264 → 2.1.0-rc.d987aec

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 (107) hide show
  1. package/README.md +3 -12
  2. package/build.sh +9 -1
  3. package/create-countryconfig/index.js +412 -59
  4. package/create-countryconfig/node_modules/.bin/degit +21 -0
  5. package/create-countryconfig/package.json +4 -1
  6. package/dist/application-config/index.js +266 -212
  7. package/dist/authentication/index.d.ts +67 -0
  8. package/dist/authentication/index.d.ts.map +1 -0
  9. package/dist/authentication/index.js +750 -0
  10. package/dist/cli.js +1786 -120
  11. package/dist/commons/api/router.d.ts +691 -76
  12. package/dist/commons/conditionals/conditionals.d.ts +6 -6
  13. package/dist/commons/conditionals/validate.d.ts +15 -5
  14. package/dist/commons/events/ActionConfig.d.ts +0 -21
  15. package/dist/commons/events/ActionDocument.d.ts +4 -4
  16. package/dist/commons/events/ActionInput.d.ts +4 -4
  17. package/dist/commons/events/AdvancedSearchConfig.d.ts +18 -0
  18. package/dist/commons/events/AuditLog.d.ts +147 -0
  19. package/dist/commons/events/CountryConfigQueryInput.d.ts +0 -18
  20. package/dist/commons/events/EventConfig.d.ts +3 -0
  21. package/dist/commons/events/EventDocument.d.ts +470 -2
  22. package/dist/commons/events/EventIndex.d.ts +2 -6
  23. package/dist/commons/events/EventMetadata.d.ts +1 -12
  24. package/dist/commons/events/EventStatus.d.ts +19 -0
  25. package/dist/commons/events/FieldConfig.d.ts +84 -53
  26. package/dist/commons/events/FieldTypeMapping.d.ts +15 -15
  27. package/dist/commons/events/FieldValue.d.ts +2 -2
  28. package/dist/commons/events/Flag.d.ts +0 -6
  29. package/dist/commons/events/PlainDate.d.ts +8 -0
  30. package/dist/commons/events/SummaryConfig.d.ts +249 -0
  31. package/dist/commons/events/WorkqueueConfig.d.ts +5 -17
  32. package/dist/commons/events/event.d.ts +12 -0
  33. package/dist/commons/events/index.d.ts +1 -0
  34. package/dist/commons/events/locationPayloads.d.ts +95 -0
  35. package/dist/commons/events/locations.d.ts +169 -26
  36. package/dist/commons/events/mocks.test.utils.d.ts +30 -0
  37. package/dist/commons/events/test.utils.d.ts +25 -4
  38. package/dist/commons/events/utils.d.ts +13 -2
  39. package/dist/commons/notification/UserNotifications.d.ts +28 -13
  40. package/dist/commons/notification/dispatch.d.ts +10 -0
  41. package/dist/commons/notification/index.d.ts +1 -0
  42. package/dist/conditionals/index.js +81 -59
  43. package/dist/csv.d.ts +25 -0
  44. package/dist/csv.d.ts.map +1 -0
  45. package/dist/csv.js +120 -0
  46. package/dist/environment/index.d.ts +1 -0
  47. package/dist/environment/index.d.ts.map +1 -1
  48. package/dist/environment/index.js +10 -0
  49. package/dist/environment/logger.d.ts +15 -3
  50. package/dist/environment/logger.d.ts.map +1 -1
  51. package/dist/environment/manage-users.js +1 -1
  52. package/dist/environment/paths.d.ts +7 -0
  53. package/dist/environment/paths.d.ts.map +1 -0
  54. package/dist/environment/paths.js +72 -0
  55. package/dist/environment/questions.d.ts.map +1 -1
  56. package/dist/environment/questions.js +20 -14
  57. package/dist/environment/setup-environment.js +28 -7
  58. package/dist/environment/templates.d.ts +0 -1
  59. package/dist/environment/templates.d.ts.map +1 -1
  60. package/dist/environment/templates.js +5 -9
  61. package/dist/environment/update-workflows.d.ts.map +1 -1
  62. package/dist/environment/update-workflows.js +17 -5
  63. package/dist/environment/upgrade.d.ts +2 -0
  64. package/dist/environment/upgrade.d.ts.map +1 -0
  65. package/dist/environment/upgrade.js +82 -0
  66. package/dist/environment/users.js +11 -13
  67. package/dist/events/index.js +2905 -2463
  68. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
  69. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  70. package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
  71. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +3 -0
  72. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -0
  73. package/dist/migrations/v2.1/add-recovery-link-notifications.js +511 -0
  74. package/dist/migrations/v2.1/add-translations.d.ts +9 -0
  75. package/dist/migrations/v2.1/add-translations.d.ts.map +1 -0
  76. package/dist/migrations/v2.1/add-translations.js +213 -0
  77. package/dist/migrations/v2.1/enable-telemetry.d.ts +3 -0
  78. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -0
  79. package/dist/migrations/v2.1/enable-telemetry.js +438 -0
  80. package/dist/migrations/v2.1/index.d.ts.map +1 -1
  81. package/dist/migrations/v2.1/index.js +1058 -0
  82. package/dist/notification/index.js +1317 -1475
  83. package/dist/scopes/index.d.ts +104 -59
  84. package/dist/scopes/index.js +81 -59
  85. package/dist/telemetry/index.d.ts +45 -0
  86. package/dist/telemetry/index.d.ts.map +1 -0
  87. package/dist/telemetry/index.js +39 -0
  88. package/dist/templates/charts-values/dependencies/values.yaml +2 -0
  89. package/dist/templates/charts-values/opencrvs-services/values.yaml +4 -3
  90. package/dist/templates/charts-values/opentelemetry/values.yaml +95 -0
  91. package/dist/templates/charts-values/traefik/values.yaml +23 -9
  92. package/dist/templates/inventory/inventory.template.yml +1 -3
  93. package/dist/translations/check.d.ts +21 -0
  94. package/dist/translations/check.d.ts.map +1 -0
  95. package/dist/translations/check.js +132 -0
  96. package/dist/verify/endpoints.d.ts +2 -0
  97. package/dist/verify/endpoints.d.ts.map +1 -0
  98. package/dist/verify/endpoints.js +345 -0
  99. package/opencrvs-toolkit-2.1.0-rc.d987aec.tgz +0 -0
  100. package/package.json +12 -6
  101. package/tsconfig.build.json +11 -0
  102. package/tsconfig.build.tsbuildinfo +1 -0
  103. package/tsconfig.json +3 -0
  104. package/dist/templates/inventory/production.example.yml +0 -77
  105. package/dist/templates/inventory/qa.example.yml +0 -48
  106. package/opencrvs-toolkit-2.1.0-rc.d7bd264.tgz +0 -0
  107. package/tsconfig.tsbuildinfo +0 -1
@@ -38,23 +38,17 @@ __export(notification_exports, {
38
38
  triggerUserEventNotification: () => triggerUserEventNotification
39
39
  });
40
40
  module.exports = __toCommonJS(notification_exports);
41
- var z45 = __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 = {
@@ -266,8 +257,7 @@ var InherentFlags = {
266
257
  *
267
258
  * We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
268
259
  */
269
- EDIT_IN_PROGRESS: "edit-in-progress",
270
- SEALED: "sealed"
260
+ EDIT_IN_PROGRESS: "edit-in-progress"
271
261
  };
272
262
  var actionFlagPattern;
273
263
  function getActionFlagPattern() {
@@ -317,12 +307,22 @@ var ActionFlagConfig = z5.object({
317
307
  description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
318
308
  });
319
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
+
320
320
  // ../commons/src/scopes.ts
321
- var JurisdictionFilter = z6.enum(["administrativeArea", "location", "all"]).describe(
321
+ var JurisdictionFilter = z7.enum(["administrativeArea", "location", "all"]).describe(
322
322
  "Filters based on user jurisdiction relative to their office location in hierarchy."
323
323
  );
324
- var UserFilter = z6.enum(["user"]).describe("Filters based on the user. Limits to self.");
325
- var RecordScopeTypeV2 = z6.enum([
324
+ var UserFilter = z7.enum(["user"]).describe("Filters based on the user. Limits to self.");
325
+ var RecordScopeTypeV2 = z7.enum([
326
326
  "record.search",
327
327
  "record.create",
328
328
  "record.read",
@@ -340,14 +340,20 @@ var RecordScopeTypeV2 = z6.enum([
340
340
  "record.unassign-others",
341
341
  "record.custom-action"
342
342
  ]);
343
- var PlainScopeType = z6.enum([
343
+ var PlainScopeType = z7.enum([
344
344
  // Misc. system scopes
345
345
  "bypassratelimit",
346
346
  "record.reindex",
347
347
  "user.data-seeding",
348
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",
349
354
  "record.import",
350
355
  "config.update-all",
356
+ "location.edit",
351
357
  "attachment.upload",
352
358
  "profile.electronic-signature",
353
359
  "user.read-only-my-audit",
@@ -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(
373
+ (val) => val === void 0 ? void 0 : [val].flat(),
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(
367
379
  (val) => val === void 0 ? void 0 : [val].flat(),
368
- z6.array(z6.string()).optional()
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."
@@ -440,7 +453,6 @@ var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
440
453
  "record.reject",
441
454
  "record.archive",
442
455
  "record.unarchive",
443
- "record.review-duplicates",
444
456
  "record.register"
445
457
  ]);
446
458
  var ScopesWithFullOptions = RecordScopeTypeV2.extract([
@@ -448,41 +460,42 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
448
460
  "record.read",
449
461
  "record.request-correction",
450
462
  "record.correct",
451
- "record.unassign-others"
463
+ "record.unassign-others",
464
+ "record.review-duplicates"
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,83 +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() })
688
+ });
689
+ var createdVersionFields = {
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()
696
+ };
697
+ var LocationCreateEntrySchema = AuditLogEntryBase.extend({
698
+ operation: z9.literal("locations.create"),
699
+ requestData: z9.object({
700
+ ...createdVersionFields,
701
+ administrativeAreaId: z9.string().nullish(),
702
+ locationType: z9.string().nullish()
703
+ })
704
+ });
705
+ var AdministrativeAreaCreateEntrySchema = AuditLogEntryBase.extend({
706
+ operation: z9.literal("administrativeAreas.create"),
707
+ requestData: z9.object({
708
+ ...createdVersionFields,
709
+ parentId: z9.string().nullish()
710
+ })
711
+ });
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({
730
+ name: ChangedStringField.optional(),
731
+ externalId: ChangedNullableStringField.optional(),
732
+ status: ChangedStringField.optional()
733
+ })
734
+ });
735
+ var LocationUpdateEntrySchema = AuditLogEntryBase.extend({
736
+ operation: z9.literal("locations.update"),
737
+ requestData: updatedVersionRequestData,
738
+ responseSummary: updatedVersionResponseSummary
739
+ });
740
+ var AdministrativeAreaUpdateEntrySchema = AuditLogEntryBase.extend({
741
+ operation: z9.literal("administrativeAreas.update"),
742
+ requestData: updatedVersionRequestData,
743
+ responseSummary: updatedVersionResponseSummary
744
+ });
745
+ var withdrawVersionRequestData = z9.object({
746
+ id: z9.string(),
747
+ versionId: z9.string()
748
+ });
749
+ var withdrawVersionResponseSummary = z9.object({
750
+ effectiveFrom: z9.string(),
751
+ name: z9.string(),
752
+ externalId: z9.string().nullish(),
753
+ status: z9.string()
754
+ });
755
+ var LocationWithdrawEntrySchema = AuditLogEntryBase.extend({
756
+ operation: z9.literal("locations.withdrawVersion"),
757
+ requestData: withdrawVersionRequestData,
758
+ responseSummary: withdrawVersionResponseSummary
759
+ });
760
+ var AdministrativeAreaWithdrawEntrySchema = AuditLogEntryBase.extend({
761
+ operation: z9.literal("administrativeAreas.withdrawVersion"),
762
+ requestData: withdrawVersionRequestData,
763
+ responseSummary: withdrawVersionResponseSummary
675
764
  });
676
765
  var AttachmentUploadEntrySchema = AuditLogEntryBase.extend({
677
- operation: z8.literal("attachments.upload"),
678
- requestData: z8.object({
679
- transactionId: z8.string(),
680
- path: z8.string().nullable()
766
+ operation: z9.literal("attachments.upload"),
767
+ requestData: z9.object({
768
+ transactionId: z9.string(),
769
+ path: z9.string().nullable()
681
770
  }),
682
- responseSummary: z8.object({ fileUrl: z8.string() })
771
+ responseSummary: z9.object({ fileUrl: z9.string() })
683
772
  });
684
- var subjectOnly = z8.object({ subjectId: z8.string() });
685
- var subjectWithReason = z8.object({
686
- subjectId: z8.string(),
687
- reason: z8.string(),
688
- 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()
689
778
  });
690
779
  var UserCreateEntrySchema = AuditLogEntryBase.extend({
691
- operation: z8.literal("user.create_user"),
692
- requestData: z8.object({
693
- subjectId: z8.string(),
694
- role: z8.string(),
695
- 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()
696
785
  })
697
786
  });
698
787
  var UserReasonEntrySchema = AuditLogEntryBase.extend({
699
- operation: z8.enum(["user.deactivate", "user.reactivate"]),
788
+ operation: z9.enum(["user.deactivate", "user.reactivate"]),
700
789
  requestData: subjectWithReason
701
790
  });
702
791
  var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
703
- operation: z8.enum([
792
+ operation: z9.enum([
704
793
  "user.edit_user",
705
794
  "user.logged_in",
706
795
  "user.logged_out",
@@ -714,14 +803,14 @@ var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
714
803
  requestData: subjectOnly
715
804
  });
716
805
  var UserEmailChangedEntrySchema = AuditLogEntryBase.extend({
717
- operation: z8.literal("user.email_address_changed"),
806
+ operation: z9.literal("user.email_address_changed"),
718
807
  requestData: subjectOnly,
719
- responseSummary: z8.object({ email: z8.string() })
808
+ responseSummary: z9.object({ email: z9.string() })
720
809
  });
721
810
  var UserPhoneChangedEntrySchema = AuditLogEntryBase.extend({
722
- operation: z8.literal("user.phone_number_changed"),
811
+ operation: z9.literal("user.phone_number_changed"),
723
812
  requestData: subjectOnly,
724
- responseSummary: z8.object({ phoneNumber: z8.string() })
813
+ responseSummary: z9.object({ phoneNumber: z9.string() })
725
814
  });
726
815
  var userBaseOmit = {
727
816
  id: true,
@@ -729,14 +818,14 @@ var userBaseOmit = {
729
818
  clientType: true,
730
819
  createdAt: true
731
820
  };
732
- var UserAuditRecordInput = z8.discriminatedUnion("operation", [
821
+ var UserAuditRecordInput = z9.discriminatedUnion("operation", [
733
822
  UserCreateEntrySchema.omit(userBaseOmit),
734
823
  UserReasonEntrySchema.omit(userBaseOmit),
735
824
  UserSubjectOnlyEntrySchema.omit(userBaseOmit),
736
825
  UserEmailChangedEntrySchema.omit(userBaseOmit),
737
826
  UserPhoneChangedEntrySchema.omit(userBaseOmit)
738
827
  ]);
739
- var AuditLogEntrySchema = z8.discriminatedUnion("operation", [
828
+ var AuditLogEntrySchema = z9.discriminatedUnion("operation", [
740
829
  EventCreateEntrySchema,
741
830
  EventGetEntrySchema,
742
831
  EventSearchEntrySchema,
@@ -748,6 +837,12 @@ var AuditLogEntrySchema = z8.discriminatedUnion("operation", [
748
837
  IntegrationActivateEntrySchema,
749
838
  IntegrationDeleteEntrySchema,
750
839
  IntegrationRefreshSecretEntrySchema,
840
+ LocationCreateEntrySchema,
841
+ LocationUpdateEntrySchema,
842
+ AdministrativeAreaUpdateEntrySchema,
843
+ LocationWithdrawEntrySchema,
844
+ AdministrativeAreaWithdrawEntrySchema,
845
+ AdministrativeAreaCreateEntrySchema,
751
846
  AttachmentUploadEntrySchema,
752
847
  UserCreateEntrySchema,
753
848
  UserReasonEntrySchema,
@@ -761,13 +856,13 @@ var TENNIS_CLUB_MEMBERSHIP = "tennis-club-membership";
761
856
  var CHILD_ONBOARDING_EVENT = "child-onboarding";
762
857
 
763
858
  // ../commons/src/events/ActionConfig.ts
764
- var z24 = __toESM(require("zod/v4"));
859
+ var z25 = __toESM(require("zod/v4"));
765
860
 
766
861
  // ../commons/src/events/FieldConfig.ts
767
862
  var import_v43 = __toESM(require("zod/v4"));
768
863
 
769
864
  // ../commons/src/events/FieldType.ts
770
- var z9 = __toESM(require("zod/v4"));
865
+ var z10 = __toESM(require("zod/v4"));
771
866
  var FieldType = {
772
867
  NAME: "NAME",
773
868
  PHONE: "PHONE",
@@ -831,7 +926,7 @@ var FieldType = {
831
926
  */
832
927
  _EXPERIMENTAL_CUSTOM: "CUSTOM"
833
928
  };
834
- var FileFieldType = z9.enum([
929
+ var FileFieldType = z10.enum([
835
930
  FieldType.FILE,
836
931
  FieldType.FILE_WITH_OPTIONS,
837
932
  FieldType.SIGNATURE
@@ -867,164 +962,160 @@ var HiddenFieldTypes = [
867
962
  ];
868
963
 
869
964
  // ../commons/src/events/FieldValue.ts
870
- var z13 = __toESM(require("zod/v4"));
965
+ var z14 = __toESM(require("zod/v4"));
871
966
 
872
967
  // ../commons/src/documents.ts
873
- var z10 = __toESM(require("zod/v4"));
874
- var FullDocumentUrl = z10.string().brand("FullDocumentUrl").describe(
968
+ var z11 = __toESM(require("zod/v4"));
969
+ var FullDocumentUrl = z11.string().brand("FullDocumentUrl").describe(
875
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"
876
971
  );
877
- 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(
878
973
  "A full absolute path with bucket name, starting from the root of the S3 server, /bucket-name/document-id.jpg"
879
974
  );
880
- var DocumentPath = z10.string().brand("DocumentPath").describe(
975
+ var DocumentPath = z11.string().brand("DocumentPath").describe(
881
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."
882
977
  );
883
978
 
884
979
  // ../commons/src/events/CompositeFieldValue.ts
885
- var z11 = __toESM(require("zod/v4"));
980
+ var z12 = __toESM(require("zod/v4"));
886
981
  var AddressType = {
887
982
  DOMESTIC: "DOMESTIC",
888
983
  INTERNATIONAL: "INTERNATIONAL"
889
984
  };
890
- var FileFieldValue = z11.object({
985
+ var FileFieldValue = z12.object({
891
986
  path: DocumentPath,
892
- originalFilename: z11.string(),
893
- type: z11.string()
894
- });
895
- var NameFieldValue = z11.object({
896
- firstname: z11.string(),
897
- surname: z11.string(),
898
- middlename: z11.string().optional()
899
- });
900
- var NameFieldUpdateValue = z11.object({
901
- firstname: z11.string().nullish(),
902
- surname: z11.string().nullish(),
903
- middlename: z11.string().nullish()
904
- }).or(z11.null()).or(z11.undefined());
905
- var StreetLevelDetailsValue = z11.record(z11.string(), z11.string()).optional();
906
- var StreetLevelDetailsUpdateValue = z11.record(z11.string(), z11.string().nullable()).nullish();
907
- var BaseAddressFieldValue = z11.object({
908
- 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(),
909
1004
  streetLevelDetails: StreetLevelDetailsValue
910
1005
  });
911
- var BaseAddressFieldUpdateValue = z11.object({
912
- country: z11.string().nullish(),
1006
+ var BaseAddressFieldUpdateValue = z12.object({
1007
+ country: z12.string().nullish(),
913
1008
  streetLevelDetails: StreetLevelDetailsUpdateValue
914
1009
  });
915
1010
  var DomesticAddressFieldValue = BaseAddressFieldValue.extend({
916
- addressType: z11.literal(AddressType.DOMESTIC),
917
- administrativeArea: z11.string().uuid()
1011
+ addressType: z12.literal(AddressType.DOMESTIC),
1012
+ administrativeArea: z12.string().uuid()
918
1013
  });
919
1014
  var InternationalAddressFieldValue = BaseAddressFieldValue.extend({
920
- addressType: z11.literal(AddressType.INTERNATIONAL)
1015
+ addressType: z12.literal(AddressType.INTERNATIONAL)
921
1016
  });
922
- var AddressFieldValue = z11.discriminatedUnion("addressType", [
1017
+ var AddressFieldValue = z12.discriminatedUnion("addressType", [
923
1018
  DomesticAddressFieldValue,
924
1019
  InternationalAddressFieldValue
925
1020
  ]);
926
1021
  var DomesticAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend({
927
- addressType: z11.literal(AddressType.DOMESTIC),
928
- administrativeArea: z11.string().uuid().nullish()
1022
+ addressType: z12.literal(AddressType.DOMESTIC),
1023
+ administrativeArea: z12.string().uuid().nullish()
929
1024
  /* Leaf level admin structure */
930
1025
  });
931
1026
  var InternationalAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend(
932
1027
  {
933
- addressType: z11.literal(AddressType.INTERNATIONAL)
1028
+ addressType: z12.literal(AddressType.INTERNATIONAL)
934
1029
  }
935
1030
  );
936
- var AddressFieldUpdateValue = z11.discriminatedUnion("addressType", [
1031
+ var AddressFieldUpdateValue = z12.discriminatedUnion("addressType", [
937
1032
  DomesticAddressUpdateFieldValue,
938
1033
  InternationalAddressUpdateFieldValue
939
1034
  ]).nullish();
940
- var FileFieldValueWithOption = z11.object({
1035
+ var FileFieldValueWithOption = z12.object({
941
1036
  path: DocumentPath,
942
- originalFilename: z11.string(),
943
- type: z11.string(),
944
- option: z11.string()
945
- });
946
- var FileFieldWithOptionValue = z11.array(FileFieldValueWithOption);
947
- var HttpFieldValue = z11.object({
948
- loading: z11.boolean(),
949
- error: z11.object({ statusCode: z11.number(), message: z11.string() }).nullish(),
950
- data: z11.any()
951
- });
952
- var HttpFieldUpdateValue = z11.object({
953
- loading: z11.boolean().nullish(),
954
- error: z11.object({ statusCode: z11.number(), message: z11.string() }).nullish(),
955
- data: z11.any().nullish()
956
- }).or(z11.null()).or(z11.undefined());
957
- var QueryParamReaderFieldValue = z11.object({
958
- data: z11.record(z11.string(), z11.string()),
959
- 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()
960
1055
  }).nullish();
961
- var QueryParamReaderFieldUpdateValue = z11.object({
962
- data: z11.record(z11.string(), z11.string())
1056
+ var QueryParamReaderFieldUpdateValue = z12.object({
1057
+ data: z12.record(z12.string(), z12.string())
963
1058
  });
964
- var ReadDataValue = z11.object({
965
- data: z11.any()
1059
+ var ReadDataValue = z12.object({
1060
+ data: z12.any()
966
1061
  });
967
1062
  var QrReaderFieldValue = ReadDataValue;
968
1063
  var IdReaderFieldValue = ReadDataValue;
969
- var NumberWithUnitFieldValue = z11.object({
970
- numericValue: z11.number(),
971
- unit: z11.string()
1064
+ var NumberWithUnitFieldValue = z12.object({
1065
+ numericValue: z12.number(),
1066
+ unit: z12.string()
972
1067
  });
973
- var NumberWithUnitFieldUpdateValue = z11.object({
974
- numericValue: z11.number().optional(),
975
- unit: z11.string().optional()
1068
+ var NumberWithUnitFieldUpdateValue = z12.object({
1069
+ numericValue: z12.number().optional(),
1070
+ unit: z12.string().optional()
976
1071
  });
977
- var CustomFieldValue = z11.unknown().brand("CustomFieldValue");
1072
+ var CustomFieldValue = z12.unknown().brand("CustomFieldValue");
978
1073
 
979
1074
  // ../commons/src/events/PlainDate.ts
980
1075
  var import_zod = require("zod");
981
1076
  var PlainDate = import_zod.z.string().date().brand("PlainDate").describe("Date in the format YYYY-MM-DD");
982
- function plainDateToLocalDate(date) {
983
- const [year, month, day] = date.split("-").map(Number);
984
- return new Date(year, month - 1, day);
985
- }
986
1077
 
987
1078
  // ../commons/src/events/FieldValue.ts
988
- var TextValue = z13.string();
989
- var HiddenFieldValue = z13.string();
990
- var NonEmptyTextValue = z13.string().trim().min(1);
991
- var DateValue = z13.iso.date().describe("Date in the format YYYY-MM-DD");
992
- var AgeValue = z13.object({
993
- age: z13.number(),
994
- 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()
995
1086
  });
996
1087
  var AgeUpdateValue = AgeValue.optional().nullable();
997
- var AutocompleteValue = z13.object({
998
- label: z13.string(),
999
- value: z13.string()
1088
+ var AutocompleteValue = z14.object({
1089
+ label: z14.string(),
1090
+ value: z14.string()
1000
1091
  });
1001
1092
  var AutocompleteUpdateValue = AutocompleteValue.optional().nullable();
1002
- var TimeValue = z13.string().regex(/^([01][0-9]|2[0-3]):[0-5][0-9]$/);
1003
- var DatetimeValue = z13.iso.datetime();
1004
- 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([
1005
1096
  "last7Days",
1006
1097
  "last30Days",
1007
1098
  "last90Days",
1008
1099
  "last365Days"
1009
1100
  ]);
1010
- var DateRangeFieldValue = z13.object({
1101
+ var DateRangeFieldValue = z14.object({
1011
1102
  start: PlainDate,
1012
1103
  end: PlainDate
1013
1104
  }).or(PlainDate).describe(
1014
1105
  "Date range with start and end dates in the format YYYY-MM-DD. Inclusive start, exclusive end."
1015
1106
  );
1016
- var EmailValue = z13.email();
1017
- var CheckboxFieldValue = z13.boolean();
1018
- var NumberFieldValue = z13.number();
1107
+ var EmailValue = z14.email();
1108
+ var CheckboxFieldValue = z14.boolean();
1109
+ var NumberFieldValue = z14.number();
1019
1110
  var SignatureFieldValue = FileFieldValue;
1020
- var ButtonFieldValue = z13.number();
1021
- var VerificationStatusValue = z13.enum([
1111
+ var ButtonFieldValue = z14.number();
1112
+ var VerificationStatusValue = z14.enum([
1022
1113
  "verified",
1023
1114
  "authenticated",
1024
1115
  "failed",
1025
1116
  "pending"
1026
1117
  ]);
1027
- var LeafFieldValues = z13.union([
1118
+ var LeafFieldValues = z14.union([
1028
1119
  AddressFieldValue,
1029
1120
  TextValue,
1030
1121
  PlainDate,
@@ -1050,11 +1141,11 @@ var LeafFieldValues = z13.union([
1050
1141
  AutocompleteValue,
1051
1142
  AutocompleteUpdateValue
1052
1143
  ]);
1053
- var FieldGroupValue = z13.record(z13.string(), LeafFieldValues);
1054
- var DataFieldValue = z13.object({
1055
- 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)
1056
1147
  }).nullish();
1057
- var FieldValue = z13.union([
1148
+ var FieldValue = z14.union([
1058
1149
  LeafFieldValues,
1059
1150
  DataFieldValue,
1060
1151
  FieldGroupValue
@@ -1088,7 +1179,7 @@ function safeUnion(schemas) {
1088
1179
  const sortedSchemas = [...schemas].sort(
1089
1180
  (a, b) => schemaPriority(a) - schemaPriority(b)
1090
1181
  );
1091
- return z13.any().superRefine((val, ctx) => {
1182
+ return z14.any().superRefine((val, ctx) => {
1092
1183
  for (const schema of sortedSchemas) {
1093
1184
  if (schema.safeParse(val).success) {
1094
1185
  return;
@@ -1127,9 +1218,9 @@ var FieldUpdateValue = safeUnion([
1127
1218
  ]);
1128
1219
 
1129
1220
  // ../commons/src/events/serializers/user/serializer.ts
1130
- var z14 = __toESM(require("zod/v4"));
1131
- var SerializedUserField = z14.object({
1132
- $userField: z14.enum([
1221
+ var z15 = __toESM(require("zod/v4"));
1222
+ var SerializedUserField = z15.object({
1223
+ $userField: z15.enum([
1133
1224
  "id",
1134
1225
  "name",
1135
1226
  "role",
@@ -1143,7 +1234,7 @@ var SerializedUserField = z14.object({
1143
1234
  "primaryOfficeId",
1144
1235
  "administrativeAreaId"
1145
1236
  ]),
1146
- $location: z14.string().optional()
1237
+ $location: z15.string().optional()
1147
1238
  });
1148
1239
  function userSerializer(userField) {
1149
1240
  return {
@@ -1166,25 +1257,25 @@ function userSerializer(userField) {
1166
1257
  var import_v4 = require("zod/v4");
1167
1258
 
1168
1259
  // ../commons/src/events/EventMetadata.ts
1169
- var z16 = __toESM(require("zod/v4"));
1260
+ var z17 = __toESM(require("zod/v4"));
1170
1261
 
1171
1262
  // ../commons/src/events/ActionDocument.ts
1172
- var z15 = __toESM(require("zod/v4"));
1173
- var ActionUpdate = z15.record(z15.string(), FieldUpdateValue).describe(
1263
+ var z16 = __toESM(require("zod/v4"));
1264
+ var ActionUpdate = z16.record(z16.string(), FieldUpdateValue).describe(
1174
1265
  "Record of field-level changes made by an action. Supports partial updates and nullable values."
1175
1266
  );
1176
- var EventState = z15.record(z15.string(), FieldValue).describe(
1267
+ var EventState = z16.record(z16.string(), FieldValue).describe(
1177
1268
  "Aggregate representation of event data after all actions have been applied, with all updates consolidated and null values removed."
1178
1269
  );
1179
- var ActionBase = z15.object({
1270
+ var ActionBase = z16.object({
1180
1271
  id: UUID.describe("Unique identifier of the action."),
1181
- transactionId: z15.string().describe("Unique identifier of the transaction."),
1272
+ transactionId: z16.string().describe("Unique identifier of the transaction."),
1182
1273
  createdByUserType: TokenUserType.describe(
1183
1274
  "Indicates whether the action was created by a human-user or by a system-user."
1184
1275
  ),
1185
- createdAt: z15.string().datetime().describe("Timestamp indicating when the action was created."),
1186
- createdBy: z15.string().describe("Identifier of the user who created the action."),
1187
- 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."),
1188
1279
  createdBySignature: DocumentPath.nullish().describe(
1189
1280
  "Reference to the signature of the user who created the action."
1190
1281
  ),
@@ -1196,7 +1287,7 @@ var ActionBase = z15.object({
1196
1287
  "Declaration data defined by the ActionConfig. Supports partial updates."
1197
1288
  ),
1198
1289
  annotation: ActionUpdate.optional().nullable().describe("Action-specific metadata used to annotate the event."),
1199
- status: z15.enum([
1290
+ status: z16.enum([
1200
1291
  ActionStatus.Requested,
1201
1292
  ActionStatus.Accepted,
1202
1293
  ActionStatus.Rejected
@@ -1208,139 +1299,143 @@ var ActionBase = z15.object({
1208
1299
  )
1209
1300
  });
1210
1301
  var AssignedAction = ActionBase.extend(
1211
- z15.object({
1212
- type: z15.literal(ActionType.ASSIGN),
1213
- 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.")
1214
1305
  // TODO move into 'content' property
1215
1306
  }).shape
1216
1307
  );
1217
1308
  var UnassignedAction = ActionBase.extend(
1218
- z15.object({
1219
- type: z15.literal(ActionType.UNASSIGN)
1309
+ z16.object({
1310
+ type: z16.literal(ActionType.UNASSIGN)
1220
1311
  }).shape
1221
1312
  );
1222
1313
  var RegisterAction = ActionBase.extend(
1223
- z15.object({
1224
- type: z15.literal(ActionType.REGISTER),
1225
- registrationNumber: z15.string().optional().describe(
1314
+ z16.object({
1315
+ type: z16.literal(ActionType.REGISTER),
1316
+ registrationNumber: z16.string().optional().describe(
1226
1317
  "Registration number of the event. Always present for accepted registrations."
1227
1318
  )
1228
1319
  // TODO move into 'content' property
1229
1320
  }).shape
1230
1321
  );
1231
1322
  var DeclareAction = ActionBase.extend(
1232
- z15.object({
1233
- type: z15.literal(ActionType.DECLARE)
1323
+ z16.object({
1324
+ type: z16.literal(ActionType.DECLARE)
1234
1325
  }).shape
1235
1326
  );
1236
- var ReasonContent = z15.object({
1237
- 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(
1238
1329
  "Message describing the reason for rejecting or archiving the event."
1239
1330
  )
1240
1331
  });
1241
1332
  var RejectAction = ActionBase.extend(
1242
- z15.object({
1243
- type: z15.literal(ActionType.REJECT),
1333
+ z16.object({
1334
+ type: z16.literal(ActionType.REJECT),
1244
1335
  content: ReasonContent
1245
1336
  }).shape
1246
1337
  );
1247
- var PotentialDuplicate = z15.object({
1338
+ var PotentialDuplicate = z16.object({
1248
1339
  id: UUID,
1249
- trackingId: z15.string()
1340
+ trackingId: z16.string()
1250
1341
  });
1251
1342
  var DuplicateDetectedAction = ActionBase.extend(
1252
- z15.object({
1253
- type: z15.literal(ActionType.DUPLICATE_DETECTED),
1254
- content: z15.object({
1255
- duplicates: z15.array(PotentialDuplicate)
1343
+ z16.object({
1344
+ type: z16.literal(ActionType.DUPLICATE_DETECTED),
1345
+ content: z16.object({
1346
+ duplicates: z16.array(PotentialDuplicate)
1256
1347
  })
1257
1348
  }).shape
1258
1349
  );
1259
1350
  var MarkNotDuplicateAction = ActionBase.extend(
1260
- z15.object({
1261
- type: z15.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1351
+ z16.object({
1352
+ type: z16.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1262
1353
  }).shape
1263
1354
  );
1264
1355
  var MarkAsDuplicateAction = ActionBase.extend(
1265
- z15.object({
1266
- type: z15.literal(ActionType.MARK_AS_DUPLICATE),
1267
- content: z15.object({
1356
+ z16.object({
1357
+ type: z16.literal(ActionType.MARK_AS_DUPLICATE),
1358
+ content: z16.object({
1268
1359
  duplicateOf: UUID
1269
1360
  }).optional()
1270
1361
  }).shape
1271
1362
  );
1272
1363
  var ArchiveAction = ActionBase.extend(
1273
- z15.object({
1274
- type: z15.literal(ActionType.ARCHIVE),
1275
- 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()
1276
1371
  }).shape
1277
1372
  );
1278
1373
  var UnarchiveAction = ActionBase.extend(
1279
- z15.object({
1280
- type: z15.literal(ActionType.UNARCHIVE)
1374
+ z16.object({
1375
+ type: z16.literal(ActionType.UNARCHIVE)
1281
1376
  }).shape
1282
1377
  );
1283
1378
  var CreatedAction = ActionBase.extend(
1284
- z15.object({
1285
- type: z15.literal(ActionType.CREATE)
1379
+ z16.object({
1380
+ type: z16.literal(ActionType.CREATE)
1286
1381
  }).shape
1287
1382
  );
1288
1383
  var NotifiedAction = ActionBase.extend(
1289
- z15.object({
1290
- type: z15.literal(ActionType.NOTIFY)
1384
+ z16.object({
1385
+ type: z16.literal(ActionType.NOTIFY)
1291
1386
  }).shape
1292
1387
  );
1293
1388
  var EditAction = ActionBase.extend(
1294
- z15.object({
1295
- type: z15.literal(ActionType.EDIT),
1389
+ z16.object({
1390
+ type: z16.literal(ActionType.EDIT),
1296
1391
  /** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
1297
- content: z15.object({
1298
- 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()
1299
1394
  }).optional()
1300
1395
  }).shape
1301
1396
  );
1302
- var PrintContent = z15.object({
1303
- templateId: z15.string().optional()
1397
+ var PrintContent = z16.object({
1398
+ templateId: z16.string().optional()
1304
1399
  });
1305
1400
  var PrintCertificateAction = ActionBase.extend(
1306
- z15.object({
1307
- type: z15.literal(ActionType.PRINT_CERTIFICATE),
1401
+ z16.object({
1402
+ type: z16.literal(ActionType.PRINT_CERTIFICATE),
1308
1403
  content: PrintContent.optional().nullable()
1309
1404
  }).shape
1310
1405
  );
1311
1406
  var RequestedCorrectionAction = ActionBase.extend(
1312
- z15.object({
1313
- type: z15.literal(ActionType.REQUEST_CORRECTION)
1407
+ z16.object({
1408
+ type: z16.literal(ActionType.REQUEST_CORRECTION)
1314
1409
  }).shape
1315
1410
  );
1316
1411
  var ApprovedCorrectionAction = ActionBase.extend(
1317
- z15.object({
1318
- type: z15.literal(ActionType.APPROVE_CORRECTION),
1319
- requestId: z15.string(),
1412
+ z16.object({
1413
+ type: z16.literal(ActionType.APPROVE_CORRECTION),
1414
+ requestId: z16.string(),
1320
1415
  // TODO move into 'content' property
1321
- content: z15.object({ immediateCorrection: z15.boolean().optional() }).optional()
1416
+ content: z16.object({ immediateCorrection: z16.boolean().optional() }).optional()
1322
1417
  }).shape
1323
1418
  );
1324
1419
  var RejectedCorrectionAction = ActionBase.extend(
1325
- z15.object({
1326
- type: z15.literal(ActionType.REJECT_CORRECTION),
1327
- requestId: z15.string(),
1420
+ z16.object({
1421
+ type: z16.literal(ActionType.REJECT_CORRECTION),
1422
+ requestId: z16.string(),
1328
1423
  // TODO move into 'content' property
1329
1424
  content: ReasonContent
1330
1425
  }).shape
1331
1426
  );
1332
1427
  var ReadAction = ActionBase.extend(
1333
- z15.object({
1334
- type: z15.literal(ActionType.READ)
1428
+ z16.object({
1429
+ type: z16.literal(ActionType.READ)
1335
1430
  }).shape
1336
1431
  );
1337
1432
  var CustomAction = ActionBase.merge(
1338
- z15.object({
1339
- type: z15.literal(ActionType.CUSTOM),
1340
- customActionType: z15.string()
1433
+ z16.object({
1434
+ type: z16.literal(ActionType.CUSTOM),
1435
+ customActionType: z16.string()
1341
1436
  })
1342
1437
  );
1343
- var ActionDocument = z15.discriminatedUnion("type", [
1438
+ var ActionDocument = z16.discriminatedUnion("type", [
1344
1439
  CreatedAction.meta({ id: "CreatedAction" }),
1345
1440
  RejectAction.meta({ id: "RejectAction" }),
1346
1441
  DuplicateDetectedAction.meta({ id: "DuplicateDetectedAction" }),
@@ -1367,57 +1462,50 @@ var AsyncRejectActionDocument = ActionBase.omit({
1367
1462
  declaration: true,
1368
1463
  annotation: true
1369
1464
  }).extend(
1370
- z15.object({
1371
- type: z15.enum(ConfirmableActions),
1372
- status: z15.literal(ActionStatus.Rejected)
1465
+ z16.object({
1466
+ type: z16.enum(ConfirmableActions),
1467
+ status: z16.literal(ActionStatus.Rejected)
1373
1468
  }).shape
1374
1469
  );
1375
- var Action = z15.union([ActionDocument, AsyncRejectActionDocument]);
1470
+ var Action = z16.union([ActionDocument, AsyncRejectActionDocument]);
1376
1471
 
1377
1472
  // ../commons/src/events/EventMetadata.ts
1378
- var EventStatus = z16.enum([
1379
- "CREATED",
1380
- "NOTIFIED",
1381
- "DECLARED",
1382
- "REGISTERED",
1383
- "ARCHIVED"
1384
- ]);
1385
- var ZodDate = z16.iso.date();
1386
- var ZodDateTime = z16.string().datetime();
1387
- var ActionCreationMetadata = z16.object({
1388
- createdAt: z16.iso.datetime().describe("The timestamp when the action request was created."),
1389
- 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."),
1390
1478
  // @TODO: createdAtLocation should be non-nullable in the future once all action requests have this field populated.
1391
1479
  createdAtLocation: UUID.nullish().describe(
1392
1480
  "Location of the user who created the action request."
1393
1481
  ),
1394
- createdByUserType: z16.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1395
- acceptedAt: z16.iso.datetime().describe("Timestamp when the action request was accepted."),
1396
- 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.")
1397
1485
  });
1398
1486
  var RegistrationCreationMetadata = ActionCreationMetadata.extend({
1399
- registrationNumber: z16.string().describe(
1487
+ registrationNumber: z17.string().describe(
1400
1488
  "Registration number of the event. Always present for accepted registrations."
1401
1489
  )
1402
1490
  });
1403
- var LegalStatuses = z16.object({
1491
+ var LegalStatuses = z17.object({
1404
1492
  [EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
1405
1493
  [EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
1406
1494
  [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
1407
1495
  });
1408
- var EventMetadata = z16.object({
1496
+ var EventMetadata = z17.object({
1409
1497
  id: UUID,
1410
- 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."),
1411
1499
  status: EventStatus,
1412
1500
  legalStatuses: LegalStatuses.describe(
1413
1501
  "Metadata related to the legal registration of the event, such as who registered it and when."
1414
1502
  ),
1415
- 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."),
1416
1504
  dateOfEvent: ZodDate.nullish(),
1417
1505
  placeOfEvent: UUID.nullish(),
1418
- createdBy: z16.string().describe("ID of the user who created the event."),
1419
- createdByUserType: z16.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1420
- 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."),
1421
1509
  // @TODO: createdAtLocation should be non-nullable in the future once all action requests have this field populated.
1422
1510
  createdAtLocation: UUID.nullish().describe(
1423
1511
  "Location of the user who created the event."
@@ -1425,18 +1513,18 @@ var EventMetadata = z16.object({
1425
1513
  updatedAtLocation: UUID.nullish().describe(
1426
1514
  "Location of the user who last changed the status."
1427
1515
  ),
1428
- updatedAt: z16.iso.datetime().describe(
1516
+ updatedAt: z17.iso.datetime().describe(
1429
1517
  "Timestamp of the most recent *accepted* status change. Possibly 3rd party update, if action is validation asynchronously."
1430
1518
  ),
1431
- assignedTo: z16.string().nullish().describe("ID of the user currently assigned to the event."),
1432
- updatedBy: z16.string().nullish().describe("ID of the user who last changed the status."),
1433
- 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(
1434
1522
  "System-generated tracking ID used by informants or registrars to look up the event."
1435
1523
  ),
1436
- potentialDuplicates: z16.array(PotentialDuplicate).describe(
1524
+ potentialDuplicates: z17.array(PotentialDuplicate).describe(
1437
1525
  "List of event IDs and their tracking IDs that this event could be a duplicate of."
1438
1526
  ),
1439
- flags: z16.array(Flag)
1527
+ flags: z17.array(Flag)
1440
1528
  });
1441
1529
  var EventMetadataKeysArray = [
1442
1530
  "id",
@@ -1457,8 +1545,8 @@ var EventMetadataKeysArray = [
1457
1545
  "legalStatuses",
1458
1546
  "flags"
1459
1547
  ];
1460
- var EventMetadataKeys = z16.enum(EventMetadataKeysArray);
1461
- var EventMetadataDateFieldIdInput = z16.enum([
1548
+ var EventMetadataKeys = z17.enum(EventMetadataKeysArray);
1549
+ var EventMetadataDateFieldIdInput = z17.enum([
1462
1550
  "createdAt",
1463
1551
  "updatedAt",
1464
1552
  "legalStatuses.NOTIFIED.createdAt",
@@ -1468,7 +1556,7 @@ var EventMetadataDateFieldIdInput = z16.enum([
1468
1556
  "legalStatuses.REGISTERED.createdAt",
1469
1557
  "legalStatuses.REGISTERED.acceptedAt"
1470
1558
  ]);
1471
- var EventMetadataDateFieldId = z16.enum([
1559
+ var EventMetadataDateFieldId = z17.enum([
1472
1560
  "event.createdAt",
1473
1561
  "event.updatedAt",
1474
1562
  "event.legalStatuses.NOTIFIED.createdAt",
@@ -1756,8 +1844,8 @@ var BaseField = import_v43.default.object({
1756
1844
  conditionals: import_v43.default.array(FieldConditional).default([]).optional().describe(
1757
1845
  "Conditions determining when the field is shown or enabled. By default, the field is always shown and enabled."
1758
1846
  ),
1759
- secured: import_v43.default.boolean().default(false).optional().describe(
1760
- "Indicates whether the field is secured. Secured fields are not indexed for search and are only visible when explicitly assigned."
1847
+ secured: import_v43.default.union([import_v43.default.boolean(), Conditional]).default(false).optional().describe(
1848
+ "Indicates whether the field is secured, either always (boolean) or conditionally, evaluated against the event (a JSONSchema conditional, e.g. flag('sealed')). Secured fields are not indexed for search and are only visible when explicitly assigned."
1761
1849
  ),
1762
1850
  placeholder: TranslationConfig.optional(),
1763
1851
  validation: import_v43.default.array(ValidationConfig).default([]).optional().describe("Additional validation rules applied to the field."),
@@ -2155,7 +2243,13 @@ var AdministrativeAreaField = BaseField.extend({
2155
2243
  configuration: import_v43.default.object({
2156
2244
  partOf: FieldReference.optional().describe("Parent location"),
2157
2245
  type: AdministrativeAreas,
2158
- allowedLocations: AllowedLocations
2246
+ allowedLocations: AllowedLocations,
2247
+ activeOnly: import_v43.default.boolean().optional().describe(
2248
+ "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."
2249
+ ),
2250
+ anchorToDateOfEvent: import_v43.default.boolean().optional().describe(
2251
+ "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."
2252
+ )
2159
2253
  }).describe("Administrative area options")
2160
2254
  }).meta({
2161
2255
  description: "Administrative area input field",
@@ -2166,7 +2260,13 @@ var LocationInput = BaseField.extend({
2166
2260
  defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2167
2261
  configuration: import_v43.default.object({
2168
2262
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
2169
- allowedLocations: AllowedLocations
2263
+ allowedLocations: AllowedLocations,
2264
+ activeOnly: import_v43.default.boolean().optional().describe(
2265
+ "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."
2266
+ ),
2267
+ anchorToDateOfEvent: import_v43.default.boolean().optional().describe(
2268
+ "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."
2269
+ )
2170
2270
  }).optional()
2171
2271
  }).meta({
2172
2272
  description: "A field for selecting a location",
@@ -2192,12 +2292,20 @@ var FileUploadWithOptions = BaseField.extend({
2192
2292
  var Facility = BaseField.extend({
2193
2293
  type: import_v43.default.literal(FieldType.FACILITY),
2194
2294
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2195
- configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2295
+ configuration: import_v43.default.object({
2296
+ allowedLocations: AllowedLocations,
2297
+ activeOnly: import_v43.default.boolean().optional(),
2298
+ anchorToDateOfEvent: import_v43.default.boolean().optional()
2299
+ }).optional()
2196
2300
  }).describe("Input field for a facility");
2197
2301
  var Office = BaseField.extend({
2198
2302
  type: import_v43.default.literal(FieldType.OFFICE),
2199
2303
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2200
- configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2304
+ configuration: import_v43.default.object({
2305
+ allowedLocations: AllowedLocations,
2306
+ activeOnly: import_v43.default.boolean().optional(),
2307
+ anchorToDateOfEvent: import_v43.default.boolean().optional()
2308
+ }).optional()
2201
2309
  }).describe("Input field for an office");
2202
2310
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
2203
2311
  administrativeArea: import_v43.default.union([UUID, SerializedUserField]).optional()
@@ -2230,7 +2338,13 @@ var Address = BaseField.extend({
2230
2338
  parent: FieldReference.optional()
2231
2339
  })
2232
2340
  ).optional(),
2233
- allowedLocations: AllowedLocations
2341
+ allowedLocations: AllowedLocations,
2342
+ activeOnly: import_v43.default.boolean().optional().describe(
2343
+ "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."
2344
+ ),
2345
+ anchorToDateOfEvent: import_v43.default.boolean().optional().describe(
2346
+ "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."
2347
+ )
2234
2348
  }).optional(),
2235
2349
  defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
2236
2350
  }).meta({
@@ -2285,10 +2399,19 @@ var ButtonField = BaseField.extend({
2285
2399
  description: "A generic button that can be used to trigger an action",
2286
2400
  id: "ButtonField"
2287
2401
  });
2402
+ var FieldGroupConfiguration = import_v43.default.object({
2403
+ separator: import_v43.default.string().optional().describe(
2404
+ 'Joins the subfield values when the group is rendered as output, e.g. ", ". Defaults to one subfield per line.'
2405
+ ),
2406
+ hideEmptyFields: import_v43.default.boolean().default(false).optional().describe(
2407
+ "Leaves subfields without a value out of the output. Pair it with a separator so the separator does not double up around the gaps."
2408
+ )
2409
+ });
2288
2410
  var FieldGroup = BaseField.extend({
2289
2411
  type: import_v43.default.literal(FieldType.FIELD_GROUP),
2290
2412
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
2291
- fields: import_v43.default.lazy(() => import_v43.default.array(FieldConfig))
2413
+ fields: import_v43.default.lazy(() => import_v43.default.array(FieldConfig)),
2414
+ configuration: FieldGroupConfiguration.optional()
2292
2415
  }).meta({
2293
2416
  description: "A group of fields that are displayed together",
2294
2417
  id: "FieldGroup"
@@ -2531,18 +2654,18 @@ var AnyFileField = import_v43.default.discriminatedUnion("type", [
2531
2654
  ]);
2532
2655
 
2533
2656
  // ../commons/src/events/FormConfig.ts
2534
- var z22 = __toESM(require("zod/v4"));
2657
+ var z23 = __toESM(require("zod/v4"));
2535
2658
 
2536
2659
  // ../commons/src/events/PageConfig.ts
2537
- var z21 = __toESM(require("zod/v4"));
2538
- var PageTypes = z21.enum(["FORM", "VERIFICATION"]);
2539
- var PageConfigBase = z21.object({
2540
- id: z21.string().describe("Unique identifier for the page"),
2660
+ var z22 = __toESM(require("zod/v4"));
2661
+ var PageTypes = z22.enum(["FORM", "VERIFICATION"]);
2662
+ var PageConfigBase = z22.object({
2663
+ id: z22.string().describe("Unique identifier for the page"),
2541
2664
  title: TranslationConfig.describe("Header title of the page"),
2542
- requireCompletionToContinue: z21.boolean().default(false).describe(
2665
+ requireCompletionToContinue: z22.boolean().default(false).describe(
2543
2666
  "If true, all required fields must be filled before continuing to the next page"
2544
2667
  ),
2545
- fields: z21.array(FieldConfig).describe("Fields to be rendered on the page"),
2668
+ fields: z22.array(FieldConfig).describe("Fields to be rendered on the page"),
2546
2669
  conditional: Conditional.optional().describe(
2547
2670
  "Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
2548
2671
  )
@@ -2551,13 +2674,13 @@ var PageConfigBase = z21.object({
2551
2674
  id: "FormPageConfig"
2552
2675
  });
2553
2676
  var FormPageConfig = PageConfigBase.extend({
2554
- type: z21.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
2677
+ type: z22.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
2555
2678
  });
2556
- var VerificationActionConfig = z21.object({
2557
- verify: z21.object({ label: TranslationConfig }),
2558
- cancel: z21.object({
2679
+ var VerificationActionConfig = z22.object({
2680
+ verify: z22.object({ label: TranslationConfig }),
2681
+ cancel: z22.object({
2559
2682
  label: TranslationConfig,
2560
- confirmation: z21.object({
2683
+ confirmation: z22.object({
2561
2684
  title: TranslationConfig,
2562
2685
  body: TranslationConfig
2563
2686
  })
@@ -2567,34 +2690,34 @@ var VerificationActionConfig = z21.object({
2567
2690
  id: "VerificationActionConfig"
2568
2691
  });
2569
2692
  var VerificationPageConfig = FormPageConfig.extend({
2570
- type: z21.literal(PageTypes.enum.VERIFICATION),
2693
+ type: z22.literal(PageTypes.enum.VERIFICATION),
2571
2694
  actions: VerificationActionConfig
2572
2695
  });
2573
- var PageConfig = z21.discriminatedUnion("type", [FormPageConfig, VerificationPageConfig]).meta({
2696
+ var PageConfig = z22.discriminatedUnion("type", [FormPageConfig, VerificationPageConfig]).meta({
2574
2697
  id: "PageConfig",
2575
2698
  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."
2576
2699
  });
2577
2700
 
2578
2701
  // ../commons/src/events/FormConfig.ts
2579
- var DeclarationFormConfig = z22.object({
2702
+ var DeclarationFormConfig = z23.object({
2580
2703
  label: TranslationConfig.describe("Human readable description of the form"),
2581
- pages: z22.array(FormPageConfig)
2704
+ pages: z23.array(FormPageConfig)
2582
2705
  }).meta({
2583
2706
  id: "DeclarationFormConfig",
2584
2707
  description: "Configuration of the declaration form."
2585
2708
  });
2586
- var ActionFormConfig = z22.object({
2709
+ var ActionFormConfig = z23.object({
2587
2710
  label: TranslationConfig.describe("Human readable description of the form"),
2588
- pages: z22.array(PageConfig)
2711
+ pages: z23.array(PageConfig)
2589
2712
  }).describe(
2590
2713
  "Configuration of the form used for system actions beyond declaration, supporting a wider range of page types."
2591
2714
  );
2592
- var FormConfig = z22.union([DeclarationFormConfig, ActionFormConfig]);
2715
+ var FormConfig = z23.union([DeclarationFormConfig, ActionFormConfig]);
2593
2716
 
2594
2717
  // ../commons/src/events/DeduplicationConfig.ts
2595
- var z23 = __toESM(require("zod/v4"));
2596
- var FieldReference2 = z23.string();
2597
- var Matcher = z23.object({
2718
+ var z24 = __toESM(require("zod/v4"));
2719
+ var FieldReference2 = z24.string();
2720
+ var Matcher = z24.object({
2598
2721
  /**
2599
2722
  * Reference to the field used in matching.
2600
2723
  *
@@ -2602,23 +2725,23 @@ var Matcher = z23.object({
2602
2725
  * be used as the origin date to calculate the distance from.
2603
2726
  */
2604
2727
  fieldId: FieldReference2,
2605
- options: z23.object({
2606
- boost: z23.number().optional(),
2728
+ options: z24.object({
2729
+ boost: z24.number().optional(),
2607
2730
  matchAgainst: FieldReference2.optional()
2608
2731
  }).optional().default({
2609
2732
  boost: 1
2610
2733
  })
2611
2734
  });
2612
2735
  var FuzzyMatcher = Matcher.extend({
2613
- type: z23.literal("fuzzy"),
2614
- options: z23.object({
2736
+ type: z24.literal("fuzzy"),
2737
+ options: z24.object({
2615
2738
  /**
2616
2739
  * Names of length 3 or less characters = 0 edits allowed
2617
2740
  * Names of length 4 - 6 characters = 1 edit allowed
2618
2741
  * Names of length >7 characters = 2 edits allowed
2619
2742
  */
2620
- fuzziness: z23.union([z23.string(), z23.number()]).optional().default("AUTO:4,7"),
2621
- boost: z23.number().optional().default(1),
2743
+ fuzziness: z24.union([z24.string(), z24.number()]).optional().default("AUTO:4,7"),
2744
+ boost: z24.number().optional().default(1),
2622
2745
  matchAgainst: FieldReference2.optional()
2623
2746
  }).optional().default({
2624
2747
  fuzziness: "AUTO:4,7",
@@ -2626,48 +2749,48 @@ var FuzzyMatcher = Matcher.extend({
2626
2749
  })
2627
2750
  });
2628
2751
  var StrictMatcher = Matcher.extend({
2629
- type: z23.literal("strict"),
2630
- options: z23.object({
2631
- boost: z23.number().optional().default(1),
2752
+ type: z24.literal("strict"),
2753
+ options: z24.object({
2754
+ boost: z24.number().optional().default(1),
2632
2755
  /**
2633
2756
  * The constant value to be present in the field for both records
2634
2757
  */
2635
- value: z23.string().optional(),
2758
+ value: z24.string().optional(),
2636
2759
  matchAgainst: FieldReference2.optional()
2637
2760
  }).optional().default({
2638
2761
  boost: 1
2639
2762
  })
2640
2763
  });
2641
2764
  var DateRangeMatcher = Matcher.extend({
2642
- type: z23.literal("dateRange"),
2643
- options: z23.object({
2765
+ type: z24.literal("dateRange"),
2766
+ options: z24.object({
2644
2767
  /**
2645
2768
  * The distance pivot in days. Distance from the origin (the value of
2646
2769
  * fieldId) at which relevance scores receive half of the boost value
2647
2770
  */
2648
- pivot: z23.number().optional(),
2649
- days: z23.number(),
2650
- boost: z23.number().optional().default(1),
2771
+ pivot: z24.number().optional(),
2772
+ days: z24.number(),
2773
+ boost: z24.number().optional().default(1),
2651
2774
  matchAgainst: FieldReference2.optional()
2652
2775
  })
2653
2776
  });
2654
- var Not = z23.object({
2655
- type: z23.literal("not"),
2777
+ var Not = z24.object({
2778
+ type: z24.literal("not"),
2656
2779
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
2657
- clause: z23.lazy(() => Clause)
2780
+ clause: z24.lazy(() => Clause)
2658
2781
  });
2659
- var And = z23.object({
2660
- type: z23.literal("and"),
2782
+ var And = z24.object({
2783
+ type: z24.literal("and"),
2661
2784
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
2662
- clauses: z23.lazy(() => Clause.array())
2785
+ clauses: z24.lazy(() => Clause.array())
2663
2786
  });
2664
- var Or = z23.object({
2665
- type: z23.literal("or"),
2787
+ var Or = z24.object({
2788
+ type: z24.literal("or"),
2666
2789
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
2667
- clauses: z23.lazy(() => Clause.array())
2790
+ clauses: z24.lazy(() => Clause.array())
2668
2791
  });
2669
- var Clause = z23.lazy(
2670
- () => z23.discriminatedUnion("type", [
2792
+ var Clause = z24.lazy(
2793
+ () => z24.discriminatedUnion("type", [
2671
2794
  Not,
2672
2795
  And,
2673
2796
  Or,
@@ -2678,8 +2801,8 @@ var Clause = z23.lazy(
2678
2801
  ).meta({
2679
2802
  id: "Clause"
2680
2803
  });
2681
- var DeduplicationConfig = z23.object({
2682
- id: z23.string(),
2804
+ var DeduplicationConfig = z24.object({
2805
+ id: z24.string(),
2683
2806
  label: TranslationConfig,
2684
2807
  query: Clause
2685
2808
  }).meta({
@@ -2688,15 +2811,15 @@ var DeduplicationConfig = z23.object({
2688
2811
  });
2689
2812
 
2690
2813
  // ../commons/src/events/ActionConfig.ts
2691
- var DeclarationReviewConfig = z24.object({
2814
+ var DeclarationReviewConfig = z25.object({
2692
2815
  title: TranslationConfig.describe("Title of the review page"),
2693
- fields: z24.array(FieldConfig).describe("Fields displayed on the review page for annotations.")
2816
+ fields: z25.array(FieldConfig).describe("Fields displayed on the review page for annotations.")
2694
2817
  }).describe(
2695
2818
  "Configuration of the declaration review page for collecting event-related metadata."
2696
2819
  );
2697
- var ActionConfigBase = z24.object({
2820
+ var ActionConfigBase = z25.object({
2698
2821
  label: TranslationConfig.describe("Human readable description of the action"),
2699
- flags: z24.array(ActionFlagConfig).optional().default([]).describe("Flag actions which are executed when the action is performed."),
2822
+ flags: z25.array(ActionFlagConfig).optional().default([]).describe("Flag actions which are executed when the action is performed."),
2700
2823
  supportingCopy: TranslationConfig.optional().describe(
2701
2824
  "Text displayed on the confirmation dialog"
2702
2825
  ),
@@ -2707,84 +2830,84 @@ var ActionConfigBase = z24.object({
2707
2830
  * "The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed."
2708
2831
  * for EventConfig.d.ts.
2709
2832
  */
2710
- icon: z24.string().describe("Icon representing the action").optional(),
2711
- conditionals: z24.array(ActionConditional).optional().describe("Conditionals which can disable or hide actions.")
2833
+ icon: z25.string().describe("Icon representing the action").optional(),
2834
+ conditionals: z25.array(ActionConditional).optional().describe("Conditionals which can disable or hide actions.")
2712
2835
  });
2713
2836
  var DeclarationActionBase = ActionConfigBase.extend({
2714
2837
  deduplication: DeduplicationConfig.optional()
2715
2838
  });
2716
- var actionConfirmationForm = z24.array(FieldConfig).optional().describe(
2839
+ var actionConfirmationForm = z25.array(FieldConfig).optional().describe(
2717
2840
  "Fields rendered on the action confirmation dialog. Submitted values are stored in the action annotation and shown in the audit history."
2718
2841
  );
2719
2842
  var ReadActionConfig = ActionConfigBase.extend(
2720
- z24.object({
2721
- type: z24.literal(ActionType.READ),
2843
+ z25.object({
2844
+ type: z25.literal(ActionType.READ),
2722
2845
  review: DeclarationReviewConfig.describe(
2723
2846
  "Configuration of the review page for read-only view."
2724
2847
  ),
2725
- conditionals: z24.never().optional().describe("Read-action can not be disabled or hidden with conditionals.")
2848
+ conditionals: z25.never().optional().describe("Read-action can not be disabled or hidden with conditionals.")
2726
2849
  }).shape
2727
2850
  );
2728
2851
  var NotifyConfig = ActionConfigBase.extend(
2729
- z24.object({
2730
- type: z24.literal(ActionType.NOTIFY),
2852
+ z25.object({
2853
+ type: z25.literal(ActionType.NOTIFY),
2731
2854
  form: actionConfirmationForm
2732
2855
  }).shape
2733
2856
  );
2734
2857
  var DuplicateDetectedConfig = ActionConfigBase.extend(
2735
- z24.object({
2736
- type: z24.literal(ActionType.DUPLICATE_DETECTED),
2737
- label: z24.never().optional().describe(
2858
+ z25.object({
2859
+ type: z25.literal(ActionType.DUPLICATE_DETECTED),
2860
+ label: z25.never().optional().describe(
2738
2861
  "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no label."
2739
2862
  ),
2740
- supportingCopy: z24.never().optional(),
2741
- icon: z24.never().optional().describe(
2863
+ supportingCopy: z25.never().optional(),
2864
+ icon: z25.never().optional().describe(
2742
2865
  "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no icon."
2743
2866
  ),
2744
- conditionals: z24.never().optional().describe(
2867
+ conditionals: z25.never().optional().describe(
2745
2868
  "DUPLICATE_DETECTED is system-generated and never shown as a button, so it cannot be disabled or hidden with conditionals."
2746
2869
  )
2747
2870
  }).shape
2748
2871
  );
2749
2872
  var MarkAsDuplicateConfig = ActionConfigBase.extend(
2750
- z24.object({
2751
- type: z24.literal(ActionType.MARK_AS_DUPLICATE)
2873
+ z25.object({
2874
+ type: z25.literal(ActionType.MARK_AS_DUPLICATE)
2752
2875
  }).shape
2753
2876
  );
2754
2877
  var MarkAsNotDuplicateConfig = ActionConfigBase.extend(
2755
- z24.object({
2756
- type: z24.literal(ActionType.MARK_AS_NOT_DUPLICATE)
2878
+ z25.object({
2879
+ type: z25.literal(ActionType.MARK_AS_NOT_DUPLICATE)
2757
2880
  }).shape
2758
2881
  );
2759
2882
  var AssignConfig = ActionConfigBase.extend(
2760
- z24.object({
2761
- type: z24.literal(ActionType.ASSIGN),
2762
- flags: z24.never().optional().describe(
2883
+ z25.object({
2884
+ type: z25.literal(ActionType.ASSIGN),
2885
+ flags: z25.never().optional().describe(
2763
2886
  "ASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
2764
2887
  )
2765
2888
  }).shape
2766
2889
  );
2767
2890
  var UnassignConfig = ActionConfigBase.extend(
2768
- z24.object({
2769
- type: z24.literal(ActionType.UNASSIGN),
2770
- flags: z24.never().optional().describe(
2891
+ z25.object({
2892
+ type: z25.literal(ActionType.UNASSIGN),
2893
+ flags: z25.never().optional().describe(
2771
2894
  "UNASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
2772
2895
  )
2773
2896
  }).shape
2774
2897
  );
2775
2898
  var DeleteConfig = ActionConfigBase.extend(
2776
- z24.object({
2777
- type: z24.literal(ActionType.DELETE)
2899
+ z25.object({
2900
+ type: z25.literal(ActionType.DELETE)
2778
2901
  }).shape
2779
2902
  );
2780
2903
  var DeclareConfig = DeclarationActionBase.extend(
2781
- z24.object({
2782
- type: z24.literal(ActionType.DECLARE),
2904
+ z25.object({
2905
+ type: z25.literal(ActionType.DECLARE),
2783
2906
  review: DeclarationReviewConfig.describe(
2784
2907
  "Configuration of the review page fields."
2785
2908
  ),
2786
2909
  form: actionConfirmationForm,
2787
- dialogCopy: z24.object({
2910
+ dialogCopy: z25.object({
2788
2911
  notify: TranslationConfig.describe(
2789
2912
  "Confirmation text for the notify action"
2790
2913
  ),
@@ -2798,20 +2921,20 @@ var DeclareConfig = DeclarationActionBase.extend(
2798
2921
  }).shape
2799
2922
  );
2800
2923
  var ArchiveConfig = ActionConfigBase.extend(
2801
- z24.object({
2802
- type: z24.literal(ActionType.ARCHIVE),
2924
+ z25.object({
2925
+ type: z25.literal(ActionType.ARCHIVE),
2803
2926
  form: actionConfirmationForm
2804
2927
  }).shape
2805
2928
  );
2806
2929
  var UnarchiveConfig = ActionConfigBase.extend(
2807
- z24.object({
2808
- type: z24.literal(ActionType.UNARCHIVE)
2930
+ z25.object({
2931
+ type: z25.literal(ActionType.UNARCHIVE)
2809
2932
  }).shape
2810
2933
  );
2811
2934
  var EditActionConfig = ActionConfigBase.extend(
2812
- z24.object({
2813
- type: z24.literal(ActionType.EDIT),
2814
- dialogCopy: z24.object({
2935
+ z25.object({
2936
+ type: z25.literal(ActionType.EDIT),
2937
+ dialogCopy: z25.object({
2815
2938
  notify: TranslationConfig.describe(
2816
2939
  "Confirmation text for the notify with edits action"
2817
2940
  ),
@@ -2825,45 +2948,45 @@ var EditActionConfig = ActionConfigBase.extend(
2825
2948
  }).shape
2826
2949
  );
2827
2950
  var RejectConfig = ActionConfigBase.extend(
2828
- z24.object({
2829
- type: z24.literal(ActionType.REJECT),
2951
+ z25.object({
2952
+ type: z25.literal(ActionType.REJECT),
2830
2953
  form: actionConfirmationForm
2831
2954
  }).shape
2832
2955
  );
2833
2956
  var RegisterConfig = DeclarationActionBase.extend(
2834
- z24.object({
2835
- type: z24.literal(ActionType.REGISTER),
2957
+ z25.object({
2958
+ type: z25.literal(ActionType.REGISTER),
2836
2959
  form: actionConfirmationForm
2837
2960
  }).shape
2838
2961
  );
2839
2962
  var PrintCertificateActionConfig = ActionConfigBase.extend(
2840
- z24.object({
2841
- type: z24.literal(ActionType.PRINT_CERTIFICATE),
2963
+ z25.object({
2964
+ type: z25.literal(ActionType.PRINT_CERTIFICATE),
2842
2965
  printForm: ActionFormConfig
2843
2966
  }).shape
2844
2967
  );
2845
2968
  var RequestCorrectionConfig = ActionConfigBase.extend(
2846
- z24.object({
2847
- type: z24.literal(ActionType.REQUEST_CORRECTION),
2969
+ z25.object({
2970
+ type: z25.literal(ActionType.REQUEST_CORRECTION),
2848
2971
  correctionForm: ActionFormConfig
2849
2972
  }).shape
2850
2973
  );
2851
2974
  var ApproveCorrectionConfig = ActionConfigBase.extend(
2852
- z24.object({
2853
- type: z24.literal(ActionType.APPROVE_CORRECTION)
2975
+ z25.object({
2976
+ type: z25.literal(ActionType.APPROVE_CORRECTION)
2854
2977
  }).shape
2855
2978
  );
2856
2979
  var RejectCorrectionConfig = ActionConfigBase.extend(
2857
- z24.object({
2858
- type: z24.literal(ActionType.REJECT_CORRECTION)
2980
+ z25.object({
2981
+ type: z25.literal(ActionType.REJECT_CORRECTION)
2859
2982
  }).shape
2860
2983
  );
2861
2984
  var CustomActionConfig = ActionConfigBase.extend(
2862
- z24.object({
2863
- type: z24.literal(ActionType.CUSTOM),
2864
- customActionType: z24.string().describe("Type identifier of the custom action."),
2985
+ z25.object({
2986
+ type: z25.literal(ActionType.CUSTOM),
2987
+ customActionType: z25.string().describe("Type identifier of the custom action."),
2865
2988
  /** 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. */
2866
- form: z24.array(FieldConfig).describe(
2989
+ form: z25.array(FieldConfig).describe(
2867
2990
  "Form configuration for the custom action. The form configured here will be used on the custom action confirmation modal."
2868
2991
  ),
2869
2992
  auditHistoryLabel: TranslationConfig.describe(
@@ -2871,7 +2994,7 @@ var CustomActionConfig = ActionConfigBase.extend(
2871
2994
  )
2872
2995
  }).shape
2873
2996
  );
2874
- var ActionConfig = z24.discriminatedUnion("type", [
2997
+ var ActionConfig = z25.discriminatedUnion("type", [
2875
2998
  /*
2876
2999
  * OpenAPI references are defined here so our generated OpenAPI spec knows to reuse the models
2877
3000
  * and treat them as "models" instead of duplicating the data structure in each endpoint.
@@ -2958,89 +3081,225 @@ var ActionConfig = z24.discriminatedUnion("type", [
2958
3081
  var actionConfigTypes = new Set(
2959
3082
  ActionConfig.options.map((opt) => opt.shape.type.value)
2960
3083
  );
2961
- var DeclarationActionConfig = z24.discriminatedUnion("type", [
3084
+ var DeclarationActionConfig = z25.discriminatedUnion("type", [
2962
3085
  DeclareConfig,
2963
3086
  RegisterConfig
2964
3087
  ]);
2965
3088
 
2966
3089
  // ../commons/src/events/offline/CertificateConfig.ts
2967
- var z25 = __toESM(require("zod/v4"));
2968
- var FontFamily = z25.object({
2969
- normal: z25.string(),
2970
- bold: z25.string(),
2971
- italics: z25.string(),
2972
- bolditalics: z25.string()
2973
- });
2974
- var CertificateConfig = z25.object({
2975
- id: z25.string(),
2976
- event: z25.string(),
2977
- isV2Template: z25.boolean().optional(),
3090
+ var z26 = __toESM(require("zod/v4"));
3091
+ var FontFamily = z26.object({
3092
+ normal: z26.string(),
3093
+ bold: z26.string(),
3094
+ italics: z26.string(),
3095
+ bolditalics: z26.string()
3096
+ });
3097
+ var CertificateConfig = z26.object({
3098
+ id: z26.string(),
3099
+ event: z26.string(),
3100
+ isV2Template: z26.boolean().optional(),
2978
3101
  label: TranslationConfig,
2979
- isDefault: z25.boolean(),
2980
- fee: z25.object({
2981
- onTime: z25.number(),
2982
- late: z25.number(),
2983
- delayed: z25.number()
3102
+ isDefault: z26.boolean(),
3103
+ fee: z26.object({
3104
+ onTime: z26.number(),
3105
+ late: z26.number(),
3106
+ delayed: z26.number()
2984
3107
  }),
2985
- svgUrl: z25.string(),
2986
- fonts: z25.record(z25.string(), FontFamily).optional(),
2987
- conditionals: z25.array(ShowConditional).optional()
3108
+ svgUrl: z26.string(),
3109
+ fonts: z26.record(z26.string(), FontFamily).optional(),
3110
+ conditionals: z26.array(ShowConditional).optional()
2988
3111
  });
2989
3112
  var CertificateTemplateConfig = CertificateConfig.extend({
2990
- hash: z25.string().optional(),
2991
- svg: z25.string()
3113
+ hash: z26.string().optional(),
3114
+ svg: z26.string()
2992
3115
  });
2993
3116
 
2994
3117
  // ../commons/src/events/offline/LanguageConfig.ts
2995
- var z26 = __toESM(require("zod/v4"));
2996
- var LanguageConfig = z26.object({
2997
- lang: z26.string(),
3118
+ var z27 = __toESM(require("zod/v4"));
3119
+ var LanguageConfig = z27.object({
3120
+ lang: z27.string(),
2998
3121
  /**
2999
3122
  * client.csv contents
3000
3123
  */
3001
- messages: z26.record(z26.string(), z26.string())
3124
+ messages: z27.record(z27.string(), z27.string())
3002
3125
  });
3003
3126
 
3004
3127
  // ../commons/src/events/EventConfig.ts
3005
- var z33 = __toESM(require("zod/v4"));
3128
+ var z35 = __toESM(require("zod/v4"));
3006
3129
 
3007
3130
  // ../commons/src/events/SummaryConfig.ts
3008
- var z27 = __toESM(require("zod/v4"));
3009
- var BaseField2 = z27.object({
3131
+ var z29 = __toESM(require("zod/v4"));
3132
+
3133
+ // ../commons/src/icons.ts
3134
+ var z28 = __toESM(require("zod/v4"));
3135
+ var AvailableIcons = z28.enum([
3136
+ "Archived",
3137
+ "Assigned",
3138
+ "Briefcase",
3139
+ "Certified",
3140
+ "Close",
3141
+ "Collapse",
3142
+ "Draft",
3143
+ "DuplicateYellow",
3144
+ "Expand",
3145
+ "ExternalValidate",
3146
+ "FilledCheck",
3147
+ "InReview",
3148
+ "Offline",
3149
+ "Registered",
3150
+ "RequiresUpdates",
3151
+ "Sent",
3152
+ "Validated",
3153
+ "WaitingApproval",
3154
+ "ChartActivity",
3155
+ "Activity",
3156
+ "Archive",
3157
+ "ArchiveTray",
3158
+ "ArrowLeft",
3159
+ "ArrowRight",
3160
+ "Buildings",
3161
+ "Circle",
3162
+ "CaretDown",
3163
+ "CaretLeft",
3164
+ "CaretRight",
3165
+ "ChartBar",
3166
+ "ChartLine",
3167
+ "ChatCircle",
3168
+ "CheckSquare",
3169
+ "Compass",
3170
+ "Check",
3171
+ "Copy",
3172
+ "Database",
3173
+ "DotsThreeVertical",
3174
+ "ArrowCounterClockwise",
3175
+ "MagnifyingGlassMinus",
3176
+ "MagnifyingGlassPlus",
3177
+ "Export",
3178
+ "Eye",
3179
+ "EyeSlash",
3180
+ "Envelope",
3181
+ "File",
3182
+ "FileLock",
3183
+ "FileSearch",
3184
+ "FileMinus",
3185
+ "FilePlus",
3186
+ "FileText",
3187
+ "FileX",
3188
+ "Handshake",
3189
+ "Gear",
3190
+ "GitBranch",
3191
+ "IdentificationCard",
3192
+ "List",
3193
+ "ListBullets",
3194
+ "Lock",
3195
+ "MagnifyingGlass",
3196
+ "MapPin",
3197
+ "Medal",
3198
+ "NotePencil",
3199
+ "Paperclip",
3200
+ "PaperPlaneTilt",
3201
+ "Pen",
3202
+ "PenNib",
3203
+ "Pencil",
3204
+ "PencilSimpleLine",
3205
+ "Phone",
3206
+ "Plus",
3207
+ "Printer",
3208
+ "SignOut",
3209
+ "Stamp",
3210
+ "Star",
3211
+ "Target",
3212
+ "TextT",
3213
+ "Trash",
3214
+ "UploadSimple",
3215
+ "User",
3216
+ "UserPlus",
3217
+ "Users",
3218
+ "WarningCircle",
3219
+ "X",
3220
+ "ChatText",
3221
+ "CircleWavyCheck",
3222
+ "CircleWavyQuestion",
3223
+ "ArchiveBox",
3224
+ "ArrowCircleDown",
3225
+ "FileArrowUp",
3226
+ "FileDotted",
3227
+ "Files",
3228
+ "PencilLine",
3229
+ "PencilCircle",
3230
+ "UserCircle",
3231
+ "Clock",
3232
+ "QrCode",
3233
+ "Webcam",
3234
+ "Sun",
3235
+ "DeviceTabletCamera",
3236
+ "Globe",
3237
+ "Fingerprint",
3238
+ "PushPin",
3239
+ "Timer"
3240
+ ]);
3241
+
3242
+ // ../commons/src/events/SummaryConfig.ts
3243
+ var InfoBox = z29.object({
3244
+ type: z29.enum(["info", "positive", "warning", "negative"]).describe(
3245
+ "Semantic tint of the icon block: info (blue), positive (green), warning (orange), negative (red)."
3246
+ ),
3247
+ background: z29.enum(["tinted", "white"]).default("tinted").optional().describe(
3248
+ "tinted reads as a recessed empty state; white reads as a standalone card."
3249
+ ),
3250
+ icon: AvailableIcons.optional().describe(
3251
+ "Icon displayed inside the icon block. Defaults to FileSearch."
3252
+ ),
3253
+ heading: TranslationConfig.describe(
3254
+ "Primary message. Short, sentence-case."
3255
+ ),
3256
+ description: TranslationConfig.optional().describe(
3257
+ "Secondary copy displayed below the heading, typically a suggested next step."
3258
+ ),
3259
+ conditionals: z29.array(ShowConditional).default([]).optional().describe(
3260
+ "Conditions under which the info box is shown. When omitted, it is always shown."
3261
+ )
3262
+ }).describe(
3263
+ "A compact icon-block + heading + description block displayed above the summary fields in the event overview."
3264
+ );
3265
+ var BaseField2 = z29.object({
3010
3266
  emptyValueMessage: TranslationConfig.optional().describe(
3011
3267
  "Default message displayed when the field value is empty."
3012
3268
  ),
3013
- conditionals: z27.array(ShowConditional).default([]).optional()
3269
+ conditionals: z29.array(ShowConditional).default([]).optional()
3014
3270
  });
3015
3271
  var ReferenceField = BaseField2.extend({
3016
- fieldId: z27.string(),
3272
+ fieldId: z29.string(),
3017
3273
  label: TranslationConfig.optional().describe(
3018
3274
  "Overrides the default label from the referenced field when provided."
3019
3275
  )
3020
3276
  }).describe("Field referencing existing event data by field ID.");
3021
3277
  var Field = BaseField2.extend({
3022
- id: z27.string().describe("Identifier of the summary field."),
3278
+ id: z29.string().describe("Identifier of the summary field."),
3023
3279
  value: TranslationConfig.describe(
3024
3280
  'Field value template supporting variables from configuration and EventMetadata (e.g. "{informant.phoneNo} {informant.email}").'
3025
3281
  ),
3026
3282
  label: TranslationConfig
3027
3283
  }).describe("Custom field defined for the summary view.");
3028
- var SummaryConfig = z27.object({
3029
- fields: z27.array(z27.union([Field, ReferenceField])).describe("Fields displayed in the event summary view.")
3284
+ var SummaryConfig = z29.object({
3285
+ banners: z29.array(InfoBox).default([]).optional().describe(
3286
+ "Info boxes displayed above the summary fields in the event overview."
3287
+ ),
3288
+ fields: z29.array(z29.union([Field, ReferenceField])).describe("Fields displayed in the event summary view.")
3030
3289
  }).meta({
3031
3290
  id: "SummaryConfig",
3032
3291
  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."
3033
3292
  });
3034
3293
 
3035
3294
  // ../commons/src/events/AdvancedSearchConfig.ts
3036
- var z28 = __toESM(require("zod/v4"));
3037
- var MatchType = z28.enum(["fuzzy", "exact", "range", "within"]);
3038
- var BaseField3 = z28.object({
3039
- config: z28.object({
3295
+ var z30 = __toESM(require("zod/v4"));
3296
+ var MatchType = z30.enum(["fuzzy", "exact", "range", "within"]);
3297
+ var BaseField3 = z30.object({
3298
+ config: z30.object({
3040
3299
  type: MatchType.describe(
3041
3300
  "Determines the search type of field. How to match value."
3042
3301
  ),
3043
- searchFields: z28.array(z28.string()).optional().describe(
3302
+ searchFields: z30.array(z30.string()).optional().describe(
3044
3303
  `
3045
3304
  Defines multiple form fields that should be searched when this field has a value.
3046
3305
  All specified fields will be combined using OR logic.
@@ -3050,7 +3309,7 @@ var BaseField3 = z28.object({
3050
3309
  `
3051
3310
  )
3052
3311
  }),
3053
- type: z28.nativeEnum(FieldType).optional().describe(
3312
+ type: z30.nativeEnum(FieldType).optional().describe(
3054
3313
  `
3055
3314
  Explicitly specify the field type for searchFields.
3056
3315
  This is required when searchFields is defined, to show the correct control in the UI.
@@ -3064,7 +3323,7 @@ var BaseField3 = z28.object({
3064
3323
  This is required when searchFields is defined.
3065
3324
  `
3066
3325
  ),
3067
- options: z28.array(SelectOption).optional(),
3326
+ options: z30.array(SelectOption).optional(),
3068
3327
  searchCriteriaLabelPrefix: TranslationConfig.optional().describe(
3069
3328
  `
3070
3329
  This property determines whether to add a prefix (such as "Child" or "Applicant") before the field label
@@ -3085,7 +3344,7 @@ var BaseField3 = z28.object({
3085
3344
  in the country-config > event.advancedSearch configuration. For example: field("child.dob", { searchCriteriaLabelPrefix: TranslationConfig }).
3086
3345
  `
3087
3346
  ),
3088
- conditionals: z28.array(FieldConditional).optional().describe(
3347
+ conditionals: z30.array(FieldConditional).optional().describe(
3089
3348
  `
3090
3349
  In advanced search, we sometimes need to override the default field visibility conditionals.
3091
3350
 
@@ -3099,23 +3358,23 @@ var BaseField3 = z28.object({
3099
3358
  are always rendered in the advanced search form.
3100
3359
  `
3101
3360
  ),
3102
- validations: z28.array(ValidationConfig).optional().describe(
3361
+ validations: z30.array(ValidationConfig).optional().describe(
3103
3362
  `Option for overriding the field validations specifically for advanced search form.`
3104
3363
  ),
3105
3364
  allowedLocations: JurisdictionReference.optional().describe(
3106
3365
  `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.`
3107
3366
  )
3108
3367
  });
3109
- var SearchQueryParams = z28.object({
3110
- eventType: z28.string().optional().describe(
3368
+ var SearchQueryParams = z30.object({
3369
+ eventType: z30.string().optional().describe(
3111
3370
  "Defines type of event so that when redirecting to Advanced Search page, appropriate tab can be selected"
3112
3371
  )
3113
3372
  }).catchall(FieldValue);
3114
3373
  var FieldConfigSchema = BaseField3.extend({
3115
- fieldId: z28.string(),
3116
- fieldType: z28.literal("field")
3374
+ fieldId: z30.string(),
3375
+ fieldType: z30.literal("field")
3117
3376
  });
3118
- var EventFieldIdInput = z28.enum([
3377
+ var EventFieldIdInput = z30.enum([
3119
3378
  "trackingId",
3120
3379
  "status",
3121
3380
  "legalStatuses.REGISTERED.acceptedAt",
@@ -3124,7 +3383,7 @@ var EventFieldIdInput = z28.enum([
3124
3383
  "updatedAt"
3125
3384
  ]);
3126
3385
  var METADATA_FIELD_PREFIX = "event.";
3127
- var EventFieldId = z28.enum([
3386
+ var EventFieldId = z30.enum([
3128
3387
  `${METADATA_FIELD_PREFIX}trackingId`,
3129
3388
  `${METADATA_FIELD_PREFIX}status`,
3130
3389
  `${METADATA_FIELD_PREFIX}legalStatuses.REGISTERED.acceptedAt`,
@@ -3134,29 +3393,29 @@ var EventFieldId = z28.enum([
3134
3393
  ]);
3135
3394
  var EventFieldConfigSchema = BaseField3.extend({
3136
3395
  fieldId: EventFieldId,
3137
- fieldType: z28.literal("event")
3396
+ fieldType: z30.literal("event")
3138
3397
  });
3139
- var AdvancedSearchField = z28.discriminatedUnion("fieldType", [FieldConfigSchema, EventFieldConfigSchema]).superRefine((data, ctx) => {
3398
+ var AdvancedSearchField = z30.discriminatedUnion("fieldType", [FieldConfigSchema, EventFieldConfigSchema]).superRefine((data, ctx) => {
3140
3399
  if (data.config.searchFields && data.config.searchFields.length > 0) {
3141
3400
  if (!data.label) {
3142
3401
  ctx.addIssue({
3143
- code: z28.ZodIssueCode.custom,
3402
+ code: z30.ZodIssueCode.custom,
3144
3403
  message: "label is required when config.searchFields is defined.",
3145
3404
  path: ["label"]
3146
3405
  });
3147
3406
  }
3148
3407
  if (!data.type) {
3149
3408
  ctx.addIssue({
3150
- code: z28.ZodIssueCode.custom,
3409
+ code: z30.ZodIssueCode.custom,
3151
3410
  message: "type is required when config.searchFields is defined.",
3152
3411
  path: ["type"]
3153
3412
  });
3154
3413
  }
3155
3414
  }
3156
3415
  });
3157
- var AdvancedSearchConfig = z28.object({
3416
+ var AdvancedSearchConfig = z30.object({
3158
3417
  title: TranslationConfig.describe("Advanced search tab title"),
3159
- fields: z28.array(AdvancedSearchField).describe("Advanced search fields within the tab.")
3418
+ fields: z30.array(AdvancedSearchField).describe("Advanced search fields within the tab.")
3160
3419
  }).meta({
3161
3420
  id: "AdvancedSearchConfig",
3162
3421
  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()`)."
@@ -3168,35 +3427,26 @@ var import_lodash4 = require("lodash");
3168
3427
  // ../commons/src/conditionals/validate.ts
3169
3428
  var import__ = __toESM(require("ajv/dist/2019"));
3170
3429
  var import_ajv_formats = __toESM(require("ajv-formats"));
3171
- var z32 = __toESM(require("zod/v4"));
3430
+ var z34 = __toESM(require("zod/v4"));
3172
3431
  var import_date_fns2 = require("date-fns");
3173
3432
 
3174
3433
  // ../commons/src/events/FieldTypeMapping.ts
3175
- var z30 = __toESM(require("zod/v4"));
3434
+ var z32 = __toESM(require("zod/v4"));
3176
3435
 
3177
3436
  // ../commons/src/events/DynamicFieldValue.ts
3178
- var z29 = __toESM(require("zod/v4"));
3437
+ var z31 = __toESM(require("zod/v4"));
3179
3438
 
3180
3439
  // ../commons/src/events/state/index.ts
3181
3440
  var import_lodash3 = require("lodash");
3182
3441
 
3183
3442
  // ../commons/src/utils.ts
3184
- var z31 = __toESM(require("zod/v4"));
3443
+ var z33 = __toESM(require("zod/v4"));
3185
3444
  var _ = __toESM(require("lodash"));
3186
- function getOrThrow(x, message) {
3187
- if (x === void 0 || x === null) {
3188
- throw new Error(message);
3189
- }
3190
- return x;
3191
- }
3192
- function joinValues(values, separator = " ") {
3193
- return values.filter((value) => !!value).join(separator).trim();
3194
- }
3195
- var FullNameV1 = z31.array(
3196
- z31.object({
3197
- use: z31.string(),
3198
- family: z31.string(),
3199
- given: z31.array(z31.string())
3445
+ var FullNameV1 = z33.array(
3446
+ z33.object({
3447
+ use: z33.string(),
3448
+ family: z33.string(),
3449
+ given: z33.array(z33.string())
3200
3450
  })
3201
3451
  );
3202
3452
  function omitKeyDeep(obj, keyToRemove) {
@@ -3217,43 +3467,6 @@ function omitKeyDeep(obj, keyToRemove) {
3217
3467
 
3218
3468
  // ../commons/src/events/state/utils.ts
3219
3469
  var import_lodash = require("lodash");
3220
- function getActionRequests(actionType, actions) {
3221
- const filtered = actions.filter((action) => action.type === actionType).reverse();
3222
- const accept = filtered.find(
3223
- (action) => action.status === ActionStatus.Accepted
3224
- );
3225
- const request = filtered.find(
3226
- (action) => action.status === ActionStatus.Requested
3227
- );
3228
- const reject = filtered.find(
3229
- (action) => action.status === ActionStatus.Rejected
3230
- );
3231
- return {
3232
- reject,
3233
- accept,
3234
- request
3235
- };
3236
- }
3237
- function getDeclarationActionCreationMetadata(actionType, actions) {
3238
- const { accept: acceptAction, request: requestAction } = getActionRequests(
3239
- actionType,
3240
- actions
3241
- );
3242
- if (!acceptAction) {
3243
- return null;
3244
- }
3245
- const registrationNumber = acceptAction.type === ActionType.REGISTER ? acceptAction.registrationNumber : null;
3246
- return {
3247
- // When 3rd party API returns 200 OK, we assume that the request was accepted, and persist single 'accepted' action.
3248
- createdAt: requestAction?.createdAt ?? acceptAction.createdAt,
3249
- createdBy: requestAction?.createdBy ?? acceptAction.createdBy,
3250
- createdByUserType: requestAction?.createdByUserType ?? acceptAction.createdByUserType,
3251
- createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
3252
- acceptedAt: acceptAction.createdAt,
3253
- createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
3254
- registrationNumber
3255
- };
3256
- }
3257
3470
  var updateActions = ActionTypes.extract([
3258
3471
  ActionType.CREATE,
3259
3472
  ActionType.NOTIFY,
@@ -3269,88 +3482,10 @@ var updateActions = ActionTypes.extract([
3269
3482
  ActionType.REJECT_CORRECTION,
3270
3483
  ActionType.CUSTOM
3271
3484
  ]);
3272
- function getActionUpdateMetadata(actions) {
3273
- const createAction = getOrThrow(
3274
- actions.find((action) => action.type === ActionType.CREATE),
3275
- `Event has no ${ActionType.CREATE} action`
3276
- );
3277
- const metadataFields = [
3278
- "createdAt",
3279
- "createdBy",
3280
- "createdByUserType",
3281
- "createdAtLocation",
3282
- "createdByRole"
3283
- ];
3284
- return actions.filter(({ type }) => updateActions.safeParse(type).success).reduce(
3285
- (_2, action) => {
3286
- if (action.originalActionId) {
3287
- const originalAction = actions.find(({ id }) => id === action.originalActionId) ?? action;
3288
- return (0, import_lodash.pick)(originalAction, metadataFields);
3289
- }
3290
- return (0, import_lodash.pick)(action, metadataFields);
3291
- },
3292
- (0, import_lodash.pick)(createAction, metadataFields)
3293
- );
3294
- }
3295
- function getLegalStatuses(actions) {
3296
- return {
3297
- [EventStatus.enum.NOTIFIED]: getDeclarationActionCreationMetadata(
3298
- ActionType.NOTIFY,
3299
- actions
3300
- ),
3301
- [EventStatus.enum.DECLARED]: getDeclarationActionCreationMetadata(
3302
- ActionType.DECLARE,
3303
- actions
3304
- ),
3305
- [EventStatus.enum.REGISTERED]: getDeclarationActionCreationMetadata(
3306
- ActionType.REGISTER,
3307
- actions
3308
- )
3309
- };
3310
- }
3311
3485
 
3312
3486
  // ../commons/src/events/state/flags.ts
3313
3487
  var import_lodash2 = require("lodash");
3314
3488
  var import_date_fns = require("date-fns");
3315
- function isFlagConditionMet(conditional, form, action) {
3316
- 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" });
3317
- return validate(conditional, {
3318
- $form: form,
3319
- $now: now2,
3320
- $online: true,
3321
- $user: {
3322
- sub: "",
3323
- exp: "",
3324
- role: action.createdByRole,
3325
- algorithm: "",
3326
- scope: [],
3327
- userType: action.createdByUserType
3328
- }
3329
- });
3330
- }
3331
- function actionConfigRemovesFlag(action, flagId, actionsUpToAndIncluding, event2, eventConfiguration) {
3332
- if (!isActionConfigType(action.type)) {
3333
- return false;
3334
- }
3335
- const actionConfig = getActionConfig({
3336
- eventConfiguration,
3337
- actionType: action.type,
3338
- customActionType: "customActionType" in action ? action.customActionType : void 0
3339
- });
3340
- const removeOperations = (actionConfig?.flags ?? []).filter(
3341
- ({ id, operation }) => id === flagId && operation === "remove"
3342
- );
3343
- if (removeOperations.length === 0) {
3344
- return false;
3345
- }
3346
- const eventUpToThisAction = { ...event2, actions: actionsUpToAndIncluding };
3347
- const declaration = aggregateActionDeclarations(eventUpToThisAction);
3348
- const annotation = aggregateActionAnnotations(eventUpToThisAction);
3349
- const form = { ...declaration, ...annotation };
3350
- return removeOperations.some(
3351
- ({ conditional }) => conditional ? isFlagConditionMet(conditional, form, action) : true
3352
- );
3353
- }
3354
3489
  var INHERENT_FLAG_RULES = [
3355
3490
  {
3356
3491
  flag: InherentFlags.CORRECTION_REQUESTED,
@@ -3387,90 +3522,6 @@ var INHERENT_FLAG_RULES = [
3387
3522
  resetOnAnyOtherAction: true
3388
3523
  }
3389
3524
  ];
3390
- function resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration) {
3391
- return acceptedActions.reduce((present, action, idx) => {
3392
- if (rule.setOn.includes(action.type)) {
3393
- return true;
3394
- }
3395
- if (rule.resetOnAnyOtherAction || (rule.resetOn ?? []).includes(action.type)) {
3396
- return false;
3397
- }
3398
- if (actionConfigRemovesFlag(
3399
- action,
3400
- rule.flag,
3401
- acceptedActions.slice(0, idx + 1),
3402
- event2,
3403
- eventConfiguration
3404
- )) {
3405
- return false;
3406
- }
3407
- return present;
3408
- }, false);
3409
- }
3410
- function resolveEventCustomFlags(event2, eventConfiguration) {
3411
- const actions = getAcceptedActions(event2).filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
3412
- return actions.reduce((acc, action, idx) => {
3413
- let actionConfig;
3414
- if (isActionConfigType(action.type)) {
3415
- actionConfig = getActionConfig({
3416
- eventConfiguration,
3417
- actionType: action.type,
3418
- customActionType: "customActionType" in action ? action.customActionType : void 0
3419
- });
3420
- }
3421
- if (!actionConfig) {
3422
- return acc;
3423
- }
3424
- const eventUpToThisAction = {
3425
- ...event2,
3426
- actions: actions.slice(0, idx + 1)
3427
- };
3428
- const declaration = aggregateActionDeclarations(eventUpToThisAction);
3429
- const annotation = aggregateActionAnnotations(eventUpToThisAction);
3430
- const form = { ...declaration, ...annotation };
3431
- const flagsWithMetConditions = (actionConfig.flags ?? []).filter(
3432
- ({ conditional }) => (
3433
- // If conditional is not provided, the flag is resolved
3434
- conditional ? isFlagConditionMet(conditional, form, action) : true
3435
- )
3436
- );
3437
- const addedFlags = flagsWithMetConditions.filter(({ operation }) => operation === "add").map(({ id }) => id);
3438
- const removedFlags = flagsWithMetConditions.filter(({ operation }) => operation === "remove").map(({ id }) => id);
3439
- const flags = [...acc, ...addedFlags].filter(
3440
- (flagId) => !removedFlags.includes(flagId)
3441
- );
3442
- return (0, import_lodash2.uniq)(flags);
3443
- }, []);
3444
- }
3445
- function getActionStatusFlags(sortedActions) {
3446
- const actionStatus = sortedActions.reduce(
3447
- (actionStatuses, { type, status }) => ({
3448
- ...actionStatuses,
3449
- [type]: status
3450
- }),
3451
- {}
3452
- );
3453
- return Object.entries(actionStatus).filter(([, status]) => status !== ActionStatus.Accepted).map(([type, status]) => {
3454
- const flag = joinValues([type, status], ":").toLowerCase();
3455
- return flag;
3456
- });
3457
- }
3458
- function getInherentFlags(sortedActions, event2, eventConfiguration) {
3459
- const acceptedActions = sortedActions.filter(
3460
- ({ status }) => status === ActionStatus.Accepted
3461
- );
3462
- return INHERENT_FLAG_RULES.filter(
3463
- (rule) => resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration)
3464
- ).map(({ flag }) => flag);
3465
- }
3466
- function getEventFlags(event2, config) {
3467
- const sortedActions = event2.actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
3468
- return [
3469
- ...getActionStatusFlags(sortedActions),
3470
- ...getInherentFlags(sortedActions, event2, config),
3471
- ...resolveEventCustomFlags(event2, config)
3472
- ];
3473
- }
3474
3525
 
3475
3526
  // ../commons/src/conditionals/conditionals.ts
3476
3527
  var objectHash = __toESM(require("object-hash"));
@@ -3678,6 +3729,33 @@ function defineComparison(field3, value, keyword) {
3678
3729
  required: [field3.$$field]
3679
3730
  });
3680
3731
  }
3732
+ function flag(flagvalue) {
3733
+ return defineConditional({
3734
+ type: "object",
3735
+ properties: {
3736
+ $flags: {
3737
+ type: "array",
3738
+ contains: {
3739
+ type: "string",
3740
+ const: flagvalue
3741
+ }
3742
+ }
3743
+ },
3744
+ required: ["$flags"]
3745
+ });
3746
+ }
3747
+ function status(statusValue) {
3748
+ return defineConditional({
3749
+ type: "object",
3750
+ properties: {
3751
+ $status: {
3752
+ type: "string",
3753
+ const: statusValue
3754
+ }
3755
+ },
3756
+ required: ["$status"]
3757
+ });
3758
+ }
3681
3759
  function createFieldConditionals(fieldId) {
3682
3760
  const getDayRange = (field3, days, clause, referenceDate) => ({
3683
3761
  type: "object",
@@ -4079,183 +4157,6 @@ function createFieldConditionals(fieldId) {
4079
4157
  };
4080
4158
  }
4081
4159
 
4082
- // ../commons/src/events/state/index.ts
4083
- function getStatusFromActions(actions) {
4084
- const acceptedActions = actions.filter(
4085
- ({ status }) => status === ActionStatus.Accepted
4086
- );
4087
- const isCurrentlyArchived = acceptedActions.reduce(
4088
- (archived, action) => {
4089
- if (action.type === ActionType.ARCHIVE) {
4090
- return true;
4091
- }
4092
- if (action.type === ActionType.UNARCHIVE) {
4093
- return false;
4094
- }
4095
- return archived;
4096
- },
4097
- false
4098
- );
4099
- if (isCurrentlyArchived) {
4100
- return EventStatus.enum.ARCHIVED;
4101
- }
4102
- return acceptedActions.filter(
4103
- ({ type }) => type !== ActionType.ARCHIVE && type !== ActionType.UNARCHIVE
4104
- ).reduce((status, action) => {
4105
- switch (action.type) {
4106
- case ActionType.CREATE:
4107
- return EventStatus.enum.CREATED;
4108
- case ActionType.DECLARE:
4109
- return EventStatus.enum.DECLARED;
4110
- case ActionType.REGISTER:
4111
- return EventStatus.enum.REGISTERED;
4112
- case ActionType.NOTIFY:
4113
- return EventStatus.enum.NOTIFIED;
4114
- // Already filtered out above; listed here only to satisfy exhaustiveness.
4115
- case ActionType.ARCHIVE:
4116
- case ActionType.UNARCHIVE:
4117
- case ActionType.CUSTOM:
4118
- case ActionType.PRINT_CERTIFICATE:
4119
- case ActionType.ASSIGN:
4120
- case ActionType.UNASSIGN:
4121
- case ActionType.REJECT:
4122
- case ActionType.REQUEST_CORRECTION:
4123
- case ActionType.APPROVE_CORRECTION:
4124
- case ActionType.DUPLICATE_DETECTED:
4125
- case ActionType.MARK_AS_NOT_DUPLICATE:
4126
- case ActionType.MARK_AS_DUPLICATE:
4127
- case ActionType.REJECT_CORRECTION:
4128
- case ActionType.READ:
4129
- case ActionType.EDIT:
4130
- default:
4131
- return status;
4132
- }
4133
- }, EventStatus.enum.CREATED);
4134
- }
4135
- function getAssignedUserFromActions(actions) {
4136
- return actions.reduce((user2, action) => {
4137
- if (action.type === ActionType.ASSIGN) {
4138
- return action.assignedTo;
4139
- }
4140
- if (action.type === ActionType.UNASSIGN) {
4141
- return null;
4142
- }
4143
- return user2;
4144
- }, null);
4145
- }
4146
- function deepDropNulls(obj) {
4147
- if (Array.isArray(obj)) {
4148
- return obj.map(deepDropNulls);
4149
- }
4150
- if (obj !== null && typeof obj === "object") {
4151
- return Object.entries(obj).reduce((acc, [key, value]) => {
4152
- const cleanedValue = deepDropNulls(value);
4153
- if (cleanedValue !== null) {
4154
- ;
4155
- acc[key] = cleanedValue;
4156
- }
4157
- return acc;
4158
- }, {});
4159
- }
4160
- return obj;
4161
- }
4162
- var DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
4163
- function extractDateString(dateTime) {
4164
- return dateTime.split("T")[0];
4165
- }
4166
- function resolveDateOfEvent(eventIndex, declaration, config) {
4167
- if (!config.dateOfEvent) {
4168
- return extractDateString(eventIndex[DEFAULT_DATE_OF_EVENT_PROPERTY]);
4169
- }
4170
- const parsedDate = isFieldReference(config.dateOfEvent) ? ZodDate.safeParse(declaration[config.dateOfEvent.$$field]) : ZodDateTime.safeParse(
4171
- getMixedPath(eventIndex, config.dateOfEvent.$$event)
4172
- );
4173
- return parsedDate.success ? extractDateString(parsedDate.data) : void 0;
4174
- }
4175
- var DEFAULT_PLACE_OF_EVENT_PROPERTY = "createdAtLocation";
4176
- function getParsedUUID(value, oldValue) {
4177
- const parsed = UUID.safeParse(value);
4178
- return parsed.success ? parsed.data : oldValue;
4179
- }
4180
- function resolvePlaceOfEvent(eventMetadata, declaration, config) {
4181
- let placeOfEvent = getParsedUUID(
4182
- eventMetadata[DEFAULT_PLACE_OF_EVENT_PROPERTY]
4183
- );
4184
- if (config.placeOfEvent) {
4185
- const addressFieldValue = AddressFieldValue.safeParse(
4186
- declaration[config.placeOfEvent.$$field]
4187
- );
4188
- if (addressFieldValue.success && addressFieldValue.data.addressType === AddressType.DOMESTIC && addressFieldValue.data.administrativeArea) {
4189
- placeOfEvent = getParsedUUID(
4190
- addressFieldValue.data.administrativeArea,
4191
- placeOfEvent
4192
- );
4193
- } else {
4194
- placeOfEvent = getParsedUUID(
4195
- declaration[config.placeOfEvent.$$field],
4196
- placeOfEvent
4197
- );
4198
- }
4199
- }
4200
- return placeOfEvent;
4201
- }
4202
- function extractPotentialDuplicatesFromActions(actions) {
4203
- return actions.reduce((duplicates, action) => {
4204
- if (action.type === ActionType.DUPLICATE_DETECTED) {
4205
- duplicates = action.content.duplicates;
4206
- }
4207
- if (action.type === ActionType.MARK_AS_NOT_DUPLICATE || action.type === ActionType.MARK_AS_DUPLICATE) {
4208
- duplicates = [];
4209
- }
4210
- return duplicates;
4211
- }, []);
4212
- }
4213
- function getCurrentEventState(event2, config) {
4214
- const sortedActions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
4215
- const creationAction = sortedActions.find(
4216
- (action) => action.type === ActionType.CREATE
4217
- );
4218
- if (!creationAction) {
4219
- throw new Error(`Event ${event2.id} has no creation action`);
4220
- }
4221
- const acceptedActions = getAcceptedActions(event2).sort(
4222
- (a, b) => a.createdAt.localeCompare(b.createdAt)
4223
- );
4224
- const requestActionMetadata = getActionUpdateMetadata(sortedActions);
4225
- const acceptedActionMetadata = getActionUpdateMetadata(acceptedActions);
4226
- const declaration = aggregateActionDeclarations(event2);
4227
- const status = getStatusFromActions(sortedActions);
4228
- const legalStatuses = getLegalStatuses(sortedActions);
4229
- const base = deepDropNulls({
4230
- id: event2.id,
4231
- type: event2.type,
4232
- status,
4233
- legalStatuses,
4234
- createdAt: creationAction.createdAt,
4235
- createdBy: creationAction.createdBy,
4236
- createdByUserType: creationAction.createdByUserType,
4237
- createdAtLocation: creationAction.createdAtLocation,
4238
- updatedAt: acceptedActionMetadata.createdAt,
4239
- assignedTo: getAssignedUserFromActions(acceptedActions),
4240
- updatedBy: requestActionMetadata.createdBy,
4241
- updatedAtLocation: requestActionMetadata.createdAtLocation,
4242
- declaration,
4243
- trackingId: event2.trackingId,
4244
- updatedByUserRole: requestActionMetadata.createdByRole,
4245
- placeOfEvent: resolvePlaceOfEvent(
4246
- { createdAtLocation: creationAction.createdAtLocation },
4247
- declaration,
4248
- config
4249
- ),
4250
- potentialDuplicates: extractPotentialDuplicatesFromActions(sortedActions),
4251
- flags: getEventFlags(event2, config)
4252
- });
4253
- return deepDropNulls({
4254
- ...base,
4255
- dateOfEvent: resolveDateOfEvent(base, declaration, config)
4256
- });
4257
- }
4258
-
4259
4160
  // ../commons/src/conditionals/validate.ts
4260
4161
  var ajv = new import__.default({
4261
4162
  $data: true,
@@ -4263,9 +4164,9 @@ var ajv = new import__.default({
4263
4164
  strict: false
4264
4165
  // Allow minContains and other newer features
4265
4166
  });
4266
- var DataContext = z32.object({
4267
- rootData: z32.object({
4268
- $leafAdminStructureLocationIds: z32.array(z32.object({ id: UUID }))
4167
+ var DataContext = z34.object({
4168
+ rootData: z34.object({
4169
+ $leafAdminStructureLocationIds: z34.array(z34.object({ id: UUID }))
4269
4170
  })
4270
4171
  });
4271
4172
  function resolveDataPath(rootData, dataPath, instancePath) {
@@ -4303,18 +4204,14 @@ function compileClientFunction(code) {
4303
4204
  }
4304
4205
  (0, import_ajv_formats.default)(ajv);
4305
4206
  function buildClientFunctionContext(input) {
4306
- const flags = input.validatorContext?.event && input.validatorContext?.eventConfig ? getCurrentEventState(
4307
- input.validatorContext?.event,
4308
- input.validatorContext?.eventConfig
4309
- )?.flags : [];
4310
4207
  return {
4311
4208
  $form: input.form,
4312
- $flags: flags,
4209
+ $flags: input.validatorContext?.event?.state.flags ?? [],
4313
4210
  $now: todayISO(),
4314
4211
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
4315
4212
  $online: isOnline(),
4316
4213
  $user: input.validatorContext?.user,
4317
- $event: input.validatorContext?.event,
4214
+ $event: input.validatorContext?.event?.document,
4318
4215
  $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
4319
4216
  user: input.systemVariables?.user,
4320
4217
  $window: input.systemVariables?.$window,
@@ -4375,9 +4272,6 @@ ajv.addKeyword({
4375
4272
  return locations.some((location) => location.id === locationIdInput);
4376
4273
  }
4377
4274
  });
4378
- function isAgeValue(value) {
4379
- return typeof value === "object" && value !== null && "age" in value && typeof value.age === "number";
4380
- }
4381
4275
  ajv.addKeyword({
4382
4276
  keyword: "customClientValidator",
4383
4277
  schemaType: "object",
@@ -4395,31 +4289,6 @@ ajv.addKeyword({
4395
4289
  );
4396
4290
  }
4397
4291
  });
4398
- function validate(schema, data) {
4399
- const validator = ajv.getSchema(schema.$id) || ajv.compile(schema);
4400
- if ("$form" in data) {
4401
- const entries = Object.entries(data.$form).map(([key, value]) => {
4402
- if (!isAgeValue(value)) {
4403
- return [key, value];
4404
- }
4405
- const age = value.age;
4406
- const maybeAsOfDate = PlainDate.safeParse(data.$form[value.asOfDateRef]);
4407
- return [
4408
- key,
4409
- {
4410
- age,
4411
- dob: ageToDate(
4412
- age,
4413
- maybeAsOfDate.success ? maybeAsOfDate.data : PlainDate.parse(data.$now)
4414
- )
4415
- }
4416
- ];
4417
- });
4418
- data.$form = Object.fromEntries(entries);
4419
- }
4420
- const result = validator(data);
4421
- return result;
4422
- }
4423
4292
  function isOnline() {
4424
4293
  if (typeof window !== "undefined" && typeof navigator !== "undefined") {
4425
4294
  return navigator.onLine;
@@ -4429,31 +4298,9 @@ function isOnline() {
4429
4298
 
4430
4299
  // ../commons/src/events/utils.ts
4431
4300
  var import_date_fns3 = require("date-fns");
4432
- function ageToDate(age, asOfDate) {
4433
- const date = plainDateToLocalDate(asOfDate);
4434
- return PlainDate.parse((0, import_date_fns3.format)((0, import_date_fns3.subYears)(date, age), "yyyy-MM-dd"));
4435
- }
4436
4301
  function getDeclarationFields(configuration) {
4437
4302
  return configuration.declaration.pages.flatMap(({ fields }) => fields);
4438
4303
  }
4439
- function isActionConfigType(type) {
4440
- return actionConfigTypes.has(type);
4441
- }
4442
- function getActionConfig({
4443
- eventConfiguration,
4444
- actionType,
4445
- customActionType
4446
- }) {
4447
- if (actionType === ActionType.NOTIFY) {
4448
- return eventConfiguration.actions.find((a) => a.type === ActionType.NOTIFY) ?? eventConfiguration.actions.find((a) => a.type === ActionType.DECLARE);
4449
- }
4450
- return eventConfiguration.actions.find((a) => {
4451
- if (a.type === ActionType.CUSTOM && customActionType) {
4452
- return a.customActionType === customActionType;
4453
- }
4454
- return a.type === actionType;
4455
- });
4456
- }
4457
4304
  var getActionAnnotationFields = (actionConfig) => {
4458
4305
  if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
4459
4306
  return actionConfig.correctionForm.pages.flatMap(({ fields }) => fields);
@@ -4468,122 +4315,17 @@ var getActionAnnotationFields = (actionConfig) => {
4468
4315
  function getAllAnnotationFields(config) {
4469
4316
  return (0, import_lodash4.flattenDeep)(config.actions.map(getActionAnnotationFields));
4470
4317
  }
4471
- function deepMerge(currentDocument, actionDocument) {
4472
- const currentDocumentClone = (0, import_lodash4.cloneDeep)(currentDocument);
4473
- return (0, import_lodash4.mergeWith)(
4474
- (0, import_lodash4.cloneDeep)(currentDocumentClone),
4475
- actionDocument,
4476
- (previousValue, incomingValue) => {
4477
- if (incomingValue === void 0) {
4478
- return previousValue;
4479
- }
4480
- if ((0, import_lodash4.isArray)(incomingValue)) {
4481
- return incomingValue;
4482
- }
4483
- if ((0, import_lodash4.isObject)(previousValue) && (0, import_lodash4.isObject)(incomingValue)) {
4484
- return void 0;
4485
- }
4486
- return incomingValue;
4487
- }
4488
- );
4489
- }
4490
4318
  var findAllFields = (config) => {
4491
4319
  return (0, import_lodash4.flattenDeep)([
4492
4320
  ...getDeclarationFields(config),
4493
4321
  ...getAllAnnotationFields(config)
4494
4322
  ]);
4495
4323
  };
4496
- function getMixedPath(obj, path, defaultValue) {
4497
- const parts = path.split(".");
4498
- const resolve = (current, segments) => {
4499
- if (current == null || segments.length === 0) {
4500
- return current;
4501
- }
4502
- for (let i = segments.length; i > 0; i--) {
4503
- const compoundKey = segments.slice(0, i).join(".");
4504
- if ((0, import_lodash4.has)(current, compoundKey)) {
4505
- const next = (0, import_lodash4.get)(current, compoundKey);
4506
- return resolve(next, segments.slice(i));
4507
- }
4508
- }
4509
- return void 0;
4510
- };
4511
- const result = resolve(obj, parts);
4512
- return (0, import_lodash4.isNil)(result) ? defaultValue : result;
4513
- }
4514
- function isAcceptedAction(a) {
4515
- return a.status === ActionStatus.Accepted;
4516
- }
4517
- function getCompleteActionAnnotation(event2, action) {
4518
- if (action.originalActionId) {
4519
- const originalAction = event2.actions.find(
4520
- ({ id }) => id === action.originalActionId
4521
- );
4522
- if (originalAction?.status === ActionStatus.Requested) {
4523
- return deepMerge(originalAction.annotation ?? {}, action.annotation ?? {});
4524
- }
4525
- }
4526
- return action.annotation ?? {};
4527
- }
4528
- function getCompleteActionDeclaration(declaration, event2, action) {
4529
- if (action.originalActionId) {
4530
- const originalAction = event2.actions.find(
4531
- ({ id }) => id === action.originalActionId
4532
- );
4533
- if (originalAction?.status === ActionStatus.Requested) {
4534
- return deepMerge(
4535
- deepMerge(declaration, originalAction.declaration),
4536
- action.declaration
4537
- );
4538
- }
4539
- }
4540
- return deepMerge(declaration, action.declaration);
4541
- }
4542
- function getAcceptedActions(event2) {
4543
- return event2.actions.filter(isAcceptedAction).map((action) => ({
4544
- ...action,
4545
- declaration: getCompleteActionDeclaration({}, event2, action),
4546
- annotation: getCompleteActionAnnotation(event2, action)
4547
- }));
4548
- }
4549
4324
  var EXCLUDED_ACTIONS = [
4550
4325
  ActionType.REQUEST_CORRECTION,
4551
4326
  ActionType.PRINT_CERTIFICATE,
4552
4327
  ActionType.REJECT_CORRECTION
4553
4328
  ];
4554
- function aggregateActionDeclarations(event2) {
4555
- const allAcceptedActions = getAcceptedActions(event2);
4556
- const aggregatedActions = allAcceptedActions.filter((a) => !EXCLUDED_ACTIONS.some((type) => type === a.type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
4557
- return aggregatedActions.reduce((declaration, action) => {
4558
- if (action.type === ActionType.APPROVE_CORRECTION) {
4559
- const requestAction = allAcceptedActions.find(
4560
- ({ id }) => id === action.requestId
4561
- );
4562
- if (!requestAction) {
4563
- return declaration;
4564
- }
4565
- const declarationWithApprovedCorrection = getCompleteActionDeclaration(
4566
- declaration,
4567
- event2,
4568
- requestAction
4569
- );
4570
- return getCompleteActionDeclaration(
4571
- declarationWithApprovedCorrection,
4572
- event2,
4573
- action
4574
- );
4575
- }
4576
- return getCompleteActionDeclaration(declaration, event2, action);
4577
- }, {});
4578
- }
4579
- function aggregateActionAnnotations(event2) {
4580
- return event2.actions.reduce((ann, sortedAction) => {
4581
- if (!("annotation" in sortedAction) || !sortedAction.annotation) {
4582
- return ann;
4583
- }
4584
- return deepMerge(ann, sortedAction.annotation);
4585
- }, {});
4586
- }
4587
4329
 
4588
4330
  // ../commons/src/events/eventConfigValidation.ts
4589
4331
  function validateAdvancedSearchConfig(event2, ctx) {
@@ -4667,9 +4409,9 @@ function validatePlaceOfEvent(event2, ctx) {
4667
4409
  }
4668
4410
  function validateActionFlags(event2, ctx) {
4669
4411
  const isInherentFlag = (value) => Object.values(InherentFlags).includes(value);
4670
- const configuredFlagIds = event2.flags.map((flag) => flag.id);
4412
+ const configuredFlagIds = event2.flags.map((flag2) => flag2.id);
4671
4413
  const actionFlagIds = event2.actions.flatMap(
4672
- (action) => (action.flags ?? []).map((flag) => flag.id)
4414
+ (action) => (action.flags ?? []).map((flag2) => flag2.id)
4673
4415
  );
4674
4416
  for (const actionFlagId of actionFlagIds) {
4675
4417
  const isConfigured = configuredFlagIds.includes(actionFlagId);
@@ -4705,11 +4447,11 @@ function validateActionOrder(event2, ctx) {
4705
4447
  }
4706
4448
 
4707
4449
  // ../commons/src/events/EventConfig.ts
4708
- var EventFieldReference = z33.object({ $$event: EventMetadataDateFieldIdInput }).describe(
4450
+ var EventFieldReference = z35.object({ $$event: EventMetadataDateFieldIdInput }).describe(
4709
4451
  "Reference to a field defined in the event metadata, using the field id."
4710
4452
  );
4711
- var _EventConfigBase = z33.object({
4712
- id: z33.string().describe(
4453
+ var _EventConfigBase = z35.object({
4454
+ id: z35.string().describe(
4713
4455
  'Machine-readable identifier of the event (e.g. "birth", "death").'
4714
4456
  ),
4715
4457
  dateOfEvent: FieldReference.or(EventFieldReference).optional().describe(
@@ -4728,23 +4470,26 @@ var _EventConfigBase = z33.object({
4728
4470
  "Summary information displayed in the event overview."
4729
4471
  ),
4730
4472
  label: TranslationConfig.describe("Human-readable label for the event type."),
4731
- actions: z33.array(ActionConfig).describe(
4473
+ actions: z35.array(ActionConfig).describe(
4732
4474
  "Configuration of core and custom actions associated with the event."
4733
4475
  ),
4734
- actionOrder: z33.array(z33.string()).optional().describe(
4476
+ actionOrder: z35.array(z35.string()).optional().describe(
4735
4477
  "Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
4736
4478
  ),
4737
4479
  declaration: DeclarationFormConfig.describe(
4738
4480
  "Configuration of the form used to gather event data."
4739
4481
  ),
4740
- advancedSearch: z33.array(AdvancedSearchConfig).optional().default([]).describe(
4482
+ advancedSearch: z35.array(AdvancedSearchConfig).optional().default([]).describe(
4741
4483
  "Configuration of fields available in the advanced search feature."
4742
4484
  ),
4743
- flags: z33.array(FlagConfig).optional().default([]).describe(
4485
+ flags: z35.array(FlagConfig).optional().default([]).describe(
4744
4486
  "Configuration of custom flags associated with the actions of this event type."
4745
4487
  ),
4746
- analytics: z33.boolean().optional().default(true).describe(
4488
+ analytics: z35.boolean().optional().default(true).describe(
4747
4489
  "Indicates whether the records of this event type are included in analytics"
4490
+ ),
4491
+ icon: z35.partialRecord(AvailableIcons, Conditional).optional().describe(
4492
+ '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.'
4748
4493
  )
4749
4494
  });
4750
4495
  var EventConfig = _EventConfigBase.superRefine((event2, ctx) => {
@@ -4764,7 +4509,7 @@ var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
4764
4509
  var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
4765
4510
 
4766
4511
  // ../commons/src/events/WorkqueueConfig.ts
4767
- var z37 = __toESM(require("zod/v4"));
4512
+ var z38 = __toESM(require("zod/v4"));
4768
4513
 
4769
4514
  // ../commons/src/searchConfigs.ts
4770
4515
  function createSearchConfig(baseField) {
@@ -4961,21 +4706,31 @@ var event = Object.assign(eventFn, {
4961
4706
  return {
4962
4707
  $event: field3
4963
4708
  };
4964
- }
4709
+ },
4710
+ /**
4711
+ * Checks if the event currently has the given status.
4712
+ * @param eventStatus - The status to check for.
4713
+ */
4714
+ hasStatus: (eventStatus) => status(eventStatus),
4715
+ /**
4716
+ * Checks if the event currently carries the given flag.
4717
+ * @param flagValue - The flag to check for.
4718
+ */
4719
+ hasFlag: (flagValue) => flag(flagValue)
4965
4720
  });
4966
4721
 
4967
4722
  // ../commons/src/events/WorkqueueColumnConfig.ts
4968
- var z34 = __toESM(require("zod/v4"));
4723
+ var z36 = __toESM(require("zod/v4"));
4969
4724
  var WorkqueueColumnKeysArray = [
4970
4725
  ...EventMetadataKeysArray,
4971
4726
  "title",
4972
4727
  "outbox"
4973
4728
  ];
4974
- var WorkqueueColumnKeys = z34.enum(WorkqueueColumnKeysArray);
4975
- var WorkqueueColumnValue = z34.object({
4729
+ var WorkqueueColumnKeys = z36.enum(WorkqueueColumnKeysArray);
4730
+ var WorkqueueColumnValue = z36.object({
4976
4731
  $event: WorkqueueColumnKeys
4977
4732
  });
4978
- var WorkqueueColumn = z34.object({
4733
+ var WorkqueueColumn = z36.object({
4979
4734
  label: TranslationConfig,
4980
4735
  value: WorkqueueColumnValue
4981
4736
  }).meta({
@@ -4989,164 +4744,56 @@ function defineWorkqueuesColumns(workqueueColumns) {
4989
4744
  }
4990
4745
 
4991
4746
  // ../commons/src/events/CountryConfigQueryInput.ts
4992
- var z35 = __toESM(require("zod/v4"));
4993
- var SerializableExact = z35.object({
4994
- type: z35.literal("exact"),
4995
- term: z35.union([z35.string(), SerializedUserField])
4996
- });
4997
- var SerializableWithin = z35.object({
4998
- type: z35.literal("within"),
4999
- location: z35.union([z35.string(), SerializedUserField])
5000
- });
5001
- var SerializedQueryExpression = z35.object({
5002
- eventType: z35.string(),
5003
- status: z35.optional(z35.union([AnyOfStatus, ExactStatus])),
5004
- createdAt: z35.optional(DateCondition),
5005
- updatedAt: z35.optional(DateCondition),
5006
- "legalStatuses.DECLARED.createdAtLocation": z35.optional(SerializableWithin),
5007
- "legalStatuses.DECLARED.createdByRole": z35.optional(AnyOf),
5008
- "legalStatuses.REGISTERED.createdAt": z35.optional(DateCondition),
5009
- "legalStatuses.REGISTERED.createdAtLocation": z35.optional(SerializableWithin),
5010
- "legalStatuses.REGISTERED.createdByRole": z35.optional(AnyOf),
5011
- "legalStatuses.REGISTERED.registrationNumber": z35.optional(Exact),
5012
- createdAtLocation: z35.optional(
5013
- z35.union([SerializableWithin, SerializableExact])
4747
+ var z37 = __toESM(require("zod/v4"));
4748
+ var SerializableExact = z37.object({
4749
+ type: z37.literal("exact"),
4750
+ term: z37.union([z37.string(), SerializedUserField])
4751
+ });
4752
+ var SerializableWithin = z37.object({
4753
+ type: z37.literal("within"),
4754
+ location: z37.union([z37.string(), SerializedUserField])
4755
+ });
4756
+ var SerializedQueryExpression = z37.object({
4757
+ eventType: z37.string(),
4758
+ status: z37.optional(z37.union([AnyOfStatus, ExactStatus])),
4759
+ createdAt: z37.optional(DateCondition),
4760
+ updatedAt: z37.optional(DateCondition),
4761
+ "legalStatuses.DECLARED.createdAtLocation": z37.optional(SerializableWithin),
4762
+ "legalStatuses.DECLARED.createdByRole": z37.optional(AnyOf),
4763
+ "legalStatuses.REGISTERED.createdAt": z37.optional(DateCondition),
4764
+ "legalStatuses.REGISTERED.createdAtLocation": z37.optional(SerializableWithin),
4765
+ "legalStatuses.REGISTERED.createdByRole": z37.optional(AnyOf),
4766
+ "legalStatuses.REGISTERED.registrationNumber": z37.optional(Exact),
4767
+ createdAtLocation: z37.optional(
4768
+ z37.union([SerializableWithin, SerializableExact])
5014
4769
  ),
5015
- updatedAtLocation: z35.optional(
5016
- z35.union([SerializableWithin, SerializableExact])
4770
+ updatedAtLocation: z37.optional(
4771
+ z37.union([SerializableWithin, SerializableExact])
5017
4772
  ),
5018
- updatedByUserRole: z35.optional(SerializableExact),
5019
- assignedTo: z35.optional(SerializableExact),
5020
- createdBy: z35.optional(SerializableExact),
4773
+ updatedByUserRole: z37.optional(SerializableExact),
4774
+ assignedTo: z37.optional(SerializableExact),
4775
+ createdBy: z37.optional(SerializableExact),
5021
4776
  createdByUserType: ExactUserType,
5022
- updatedBy: z35.optional(SerializableExact),
5023
- trackingId: z35.optional(Exact),
5024
- flags: z35.optional(ContainsFlags),
4777
+ updatedBy: z37.optional(SerializableExact),
4778
+ trackingId: z37.optional(Exact),
4779
+ flags: z37.optional(ContainsFlags),
5025
4780
  data: QueryInput
5026
4781
  }).partial();
5027
- var Or2 = z35.object({
5028
- type: z35.literal("or"),
5029
- clauses: z35.array(SerializedQueryExpression)
4782
+ var Or2 = z37.object({
4783
+ type: z37.literal("or"),
4784
+ clauses: z37.array(SerializedQueryExpression)
5030
4785
  });
5031
- var And2 = z35.object({
5032
- type: z35.literal("and"),
5033
- clauses: z35.array(SerializedQueryExpression)
4786
+ var And2 = z37.object({
4787
+ type: z37.literal("and"),
4788
+ clauses: z37.array(SerializedQueryExpression)
5034
4789
  });
5035
- var CountryConfigQueryType = z35.discriminatedUnion("type", [And2, Or2]);
5036
- var CountryConfigQueryInputType = z35.union([
4790
+ var CountryConfigQueryType = z37.discriminatedUnion("type", [And2, Or2]);
4791
+ var CountryConfigQueryInputType = z37.union([
5037
4792
  SerializedQueryExpression,
5038
4793
  And2,
5039
4794
  Or2
5040
4795
  ]);
5041
4796
 
5042
- // ../commons/src/icons.ts
5043
- var z36 = __toESM(require("zod/v4"));
5044
- var AvailableIcons = z36.enum([
5045
- "Archived",
5046
- "Assigned",
5047
- "Briefcase",
5048
- "Certified",
5049
- "Close",
5050
- "Collapse",
5051
- "Draft",
5052
- "DuplicateYellow",
5053
- "Expand",
5054
- "ExternalValidate",
5055
- "FilledCheck",
5056
- "InReview",
5057
- "Offline",
5058
- "Registered",
5059
- "RequiresUpdates",
5060
- "Sent",
5061
- "Validated",
5062
- "WaitingApproval",
5063
- "ChartActivity",
5064
- "Activity",
5065
- "Archive",
5066
- "ArchiveTray",
5067
- "ArrowLeft",
5068
- "ArrowRight",
5069
- "Buildings",
5070
- "Circle",
5071
- "CaretDown",
5072
- "CaretLeft",
5073
- "CaretRight",
5074
- "ChartBar",
5075
- "ChartLine",
5076
- "ChatCircle",
5077
- "CheckSquare",
5078
- "Compass",
5079
- "Check",
5080
- "Copy",
5081
- "Database",
5082
- "DotsThreeVertical",
5083
- "ArrowCounterClockwise",
5084
- "MagnifyingGlassMinus",
5085
- "MagnifyingGlassPlus",
5086
- "Export",
5087
- "Eye",
5088
- "EyeSlash",
5089
- "Envelope",
5090
- "File",
5091
- "FileSearch",
5092
- "FileMinus",
5093
- "FilePlus",
5094
- "FileText",
5095
- "FileX",
5096
- "Handshake",
5097
- "Gear",
5098
- "GitBranch",
5099
- "IdentificationCard",
5100
- "List",
5101
- "ListBullets",
5102
- "Lock",
5103
- "MagnifyingGlass",
5104
- "MapPin",
5105
- "Medal",
5106
- "NotePencil",
5107
- "Paperclip",
5108
- "PaperPlaneTilt",
5109
- "Pen",
5110
- "PenNib",
5111
- "Pencil",
5112
- "PencilSimpleLine",
5113
- "Phone",
5114
- "Plus",
5115
- "Printer",
5116
- "SignOut",
5117
- "Stamp",
5118
- "Star",
5119
- "Target",
5120
- "TextT",
5121
- "Trash",
5122
- "UploadSimple",
5123
- "User",
5124
- "UserPlus",
5125
- "Users",
5126
- "WarningCircle",
5127
- "X",
5128
- "ChatText",
5129
- "CircleWavyCheck",
5130
- "CircleWavyQuestion",
5131
- "ArchiveBox",
5132
- "ArrowCircleDown",
5133
- "FileArrowUp",
5134
- "FileDotted",
5135
- "Files",
5136
- "PencilLine",
5137
- "PencilCircle",
5138
- "UserCircle",
5139
- "Clock",
5140
- "QrCode",
5141
- "Webcam",
5142
- "Sun",
5143
- "DeviceTabletCamera",
5144
- "Globe",
5145
- "Fingerprint",
5146
- "PushPin",
5147
- "Timer"
5148
- ]);
5149
-
5150
4797
  // ../commons/src/events/WorkqueueConfig.ts
5151
4798
  var mandatoryColumns = defineWorkqueuesColumns([
5152
4799
  {
@@ -5166,16 +4813,16 @@ var mandatoryColumns = defineWorkqueuesColumns([
5166
4813
  value: event.field("updatedAt")
5167
4814
  }
5168
4815
  ]);
5169
- var WorkqueueConfig = z37.object({
5170
- slug: z37.string().describe("Determines the url of the workqueue."),
4816
+ var WorkqueueConfig = z38.object({
4817
+ slug: z38.string().describe("Determines the url of the workqueue."),
5171
4818
  name: TranslationConfig.describe(
5172
4819
  "Title of the workflow (both in navigation and on the page)"
5173
4820
  ),
5174
4821
  query: CountryConfigQueryType,
5175
- action: z37.object({ type: WorkqueueActionType }).optional().describe(
4822
+ action: z38.object({ type: WorkqueueActionType }).optional().describe(
5176
4823
  "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."
5177
4824
  ),
5178
- columns: z37.array(WorkqueueColumn).default(mandatoryColumns),
4825
+ columns: z38.array(WorkqueueColumn).default(mandatoryColumns),
5179
4826
  icon: AvailableIcons,
5180
4827
  emptyMessage: TranslationConfig.optional()
5181
4828
  }).describe("Configuration for workqueue.");
@@ -5189,10 +4836,10 @@ var WorkqueueConfigInput = WorkqueueConfig.extend({
5189
4836
  id: "WorkqueueConfig",
5190
4837
  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."
5191
4838
  });
5192
- var WorkqueueCountInput = z37.array(
5193
- z37.object({ slug: z37.string(), query: QueryType })
4839
+ var WorkqueueCountInput = z38.array(
4840
+ z38.object({ slug: z38.string(), query: QueryType })
5194
4841
  );
5195
- var WorkqueueCountOutput = z37.record(z37.string(), z37.number());
4842
+ var WorkqueueCountOutput = z38.record(z38.string(), z38.number());
5196
4843
 
5197
4844
  // ../commons/src/events/workqueueDefaultColumns.ts
5198
4845
  var defaultWorkqueueColumns = [
@@ -5215,21 +4862,21 @@ var defaultWorkqueueColumns = [
5215
4862
  ];
5216
4863
 
5217
4864
  // ../commons/src/events/Draft.ts
5218
- var z39 = __toESM(require("zod/v4"));
4865
+ var z40 = __toESM(require("zod/v4"));
5219
4866
 
5220
4867
  // ../commons/src/events/ActionInput.ts
5221
- var z38 = __toESM(require("zod/v4"));
5222
- var BaseActionInput = z38.object({
4868
+ var z39 = __toESM(require("zod/v4"));
4869
+ var BaseActionInput = z39.object({
5223
4870
  eventId: UUID,
5224
- transactionId: z38.string(),
4871
+ transactionId: z39.string(),
5225
4872
  declaration: ActionUpdate.default({}),
5226
4873
  annotation: ActionUpdate.optional(),
5227
4874
  originalActionId: UUID.optional(),
5228
4875
  // should not be part of base action.
5229
- keepAssignment: z38.boolean().optional(),
5230
- keepAssignmentIfAccepted: z38.boolean().optional(),
5231
- keepAssignmentIfRejected: z38.boolean().optional(),
5232
- waitFor: z38.boolean().default(true).describe(
4876
+ keepAssignment: z39.boolean().optional(),
4877
+ keepAssignmentIfAccepted: z39.boolean().optional(),
4878
+ keepAssignmentIfRejected: z39.boolean().optional(),
4879
+ waitFor: z39.boolean().default(true).describe(
5233
4880
  "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."
5234
4881
  ),
5235
4882
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
@@ -5239,8 +4886,8 @@ var BaseActionInput = z38.object({
5239
4886
  )
5240
4887
  });
5241
4888
  var CreateActionInput = BaseActionInput.extend(
5242
- z38.object({
5243
- type: z38.literal(ActionType.CREATE).default(ActionType.CREATE),
4889
+ z39.object({
4890
+ type: z39.literal(ActionType.CREATE).default(ActionType.CREATE),
5244
4891
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
5245
4892
  createdAtLocation: UUID.nullish().describe(
5246
4893
  "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."
@@ -5248,14 +4895,14 @@ var CreateActionInput = BaseActionInput.extend(
5248
4895
  }).shape
5249
4896
  );
5250
4897
  var RegisterActionInput = BaseActionInput.extend(
5251
- z38.strictObject({
5252
- type: z38.literal(ActionType.REGISTER).default(ActionType.REGISTER),
5253
- registrationNumber: z38.string().optional()
4898
+ z39.strictObject({
4899
+ type: z39.literal(ActionType.REGISTER).default(ActionType.REGISTER),
4900
+ registrationNumber: z39.string().optional()
5254
4901
  }).shape
5255
4902
  );
5256
4903
  var NotifyActionInput = BaseActionInput.extend(
5257
- z38.object({
5258
- type: z38.literal(ActionType.NOTIFY).default(ActionType.NOTIFY),
4904
+ z39.object({
4905
+ type: z39.literal(ActionType.NOTIFY).default(ActionType.NOTIFY),
5259
4906
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
5260
4907
  createdAtLocation: UUID.nullish().describe(
5261
4908
  "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."
@@ -5271,103 +4918,107 @@ var NotifyActionInput = BaseActionInput.extend(
5271
4918
  }
5272
4919
  });
5273
4920
  var DeclareActionInput = BaseActionInput.extend(
5274
- z38.object({
5275
- type: z38.literal(ActionType.DECLARE).default(ActionType.DECLARE)
4921
+ z39.object({
4922
+ type: z39.literal(ActionType.DECLARE).default(ActionType.DECLARE)
5276
4923
  }).shape
5277
4924
  );
5278
4925
  var EditActionInput = BaseActionInput.extend(
5279
- z38.object({
5280
- type: z38.literal(ActionType.EDIT).default(ActionType.EDIT)
4926
+ z39.object({
4927
+ type: z39.literal(ActionType.EDIT).default(ActionType.EDIT)
5281
4928
  }).shape
5282
4929
  );
5283
4930
  var PrintCertificateActionInput = BaseActionInput.extend(
5284
- z38.object({
5285
- type: z38.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE),
4931
+ z39.object({
4932
+ type: z39.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE),
5286
4933
  content: PrintContent.optional()
5287
4934
  }).shape
5288
4935
  );
5289
4936
  var RejectDeclarationActionInput = BaseActionInput.extend(
5290
- z38.object({
5291
- type: z38.literal(ActionType.REJECT).default(ActionType.REJECT),
4937
+ z39.object({
4938
+ type: z39.literal(ActionType.REJECT).default(ActionType.REJECT),
5292
4939
  content: ReasonContent
5293
4940
  }).shape
5294
4941
  );
5295
4942
  var DuplicateDetectedActionInput = BaseActionInput.extend(
5296
- z38.object({
5297
- type: z38.literal(ActionType.DUPLICATE_DETECTED).default(ActionType.DUPLICATE_DETECTED),
5298
- content: z38.object({
5299
- duplicates: z38.array(PotentialDuplicate)
4943
+ z39.object({
4944
+ type: z39.literal(ActionType.DUPLICATE_DETECTED).default(ActionType.DUPLICATE_DETECTED),
4945
+ content: z39.object({
4946
+ duplicates: z39.array(PotentialDuplicate)
5300
4947
  })
5301
4948
  }).shape
5302
4949
  );
5303
4950
  var MarkAsDuplicateActionInput = BaseActionInput.extend(
5304
- z38.object({
5305
- type: z38.literal(ActionType.MARK_AS_DUPLICATE).default(ActionType.MARK_AS_DUPLICATE),
5306
- content: z38.object({
4951
+ z39.object({
4952
+ type: z39.literal(ActionType.MARK_AS_DUPLICATE).default(ActionType.MARK_AS_DUPLICATE),
4953
+ content: z39.object({
5307
4954
  duplicateOf: UUID
5308
4955
  }).optional()
5309
4956
  }).shape
5310
4957
  );
5311
4958
  var MarkNotDuplicateActionInput = BaseActionInput.extend(
5312
- z38.object({
5313
- type: z38.literal(ActionType.MARK_AS_NOT_DUPLICATE).default(ActionType.MARK_AS_NOT_DUPLICATE)
4959
+ z39.object({
4960
+ type: z39.literal(ActionType.MARK_AS_NOT_DUPLICATE).default(ActionType.MARK_AS_NOT_DUPLICATE)
5314
4961
  }).shape
5315
4962
  );
5316
4963
  var ArchiveActionInput = BaseActionInput.extend(
5317
- z38.object({
5318
- type: z38.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
5319
- content: ReasonContent
4964
+ z39.object({
4965
+ type: z39.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
4966
+ /**
4967
+ * Archiving does not collect a reason on its own. Only the
4968
+ * "mark as duplicate" flow archives with a reason attached.
4969
+ */
4970
+ content: ReasonContent.optional()
5320
4971
  }).shape
5321
4972
  );
5322
4973
  var UnarchiveActionInput = BaseActionInput.extend(
5323
- z38.object({
5324
- type: z38.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
4974
+ z39.object({
4975
+ type: z39.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
5325
4976
  }).shape
5326
4977
  );
5327
4978
  var AssignActionInput = BaseActionInput.extend(
5328
- z38.object({
5329
- type: z38.literal(ActionType.ASSIGN),
5330
- assignedTo: z38.string()
4979
+ z39.object({
4980
+ type: z39.literal(ActionType.ASSIGN),
4981
+ assignedTo: z39.string()
5331
4982
  }).shape
5332
4983
  );
5333
4984
  var UnassignActionInput = BaseActionInput.extend(
5334
- z38.object({
5335
- type: z38.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
5336
- assignedTo: z38.literal(null).default(null)
4985
+ z39.object({
4986
+ type: z39.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
4987
+ assignedTo: z39.literal(null).default(null)
5337
4988
  }).shape
5338
4989
  );
5339
4990
  var RequestCorrectionActionInput = BaseActionInput.extend(
5340
- z38.object({
5341
- type: z38.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
4991
+ z39.object({
4992
+ type: z39.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
5342
4993
  }).shape
5343
4994
  );
5344
4995
  var RejectCorrectionActionInput = BaseActionInput.extend(
5345
- z38.object({
5346
- requestId: z38.string(),
5347
- type: z38.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION),
4996
+ z39.object({
4997
+ requestId: z39.string(),
4998
+ type: z39.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION),
5348
4999
  content: ReasonContent
5349
5000
  }).shape
5350
5001
  );
5351
5002
  var ApproveCorrectionActionInput = BaseActionInput.extend(
5352
- z38.object({
5353
- requestId: z38.string(),
5354
- type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION),
5355
- content: z38.object({ immediateCorrection: z38.boolean().optional() }).optional()
5003
+ z39.object({
5004
+ requestId: z39.string(),
5005
+ type: z39.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION),
5006
+ content: z39.object({ immediateCorrection: z39.boolean().optional() }).optional()
5356
5007
  }).shape
5357
5008
  );
5358
5009
  var ReadActionInput = BaseActionInput.extend(
5359
- z38.object({
5360
- type: z38.literal(ActionType.READ).default(ActionType.READ)
5010
+ z39.object({
5011
+ type: z39.literal(ActionType.READ).default(ActionType.READ)
5361
5012
  }).shape
5362
5013
  );
5363
- var DeleteActionInput = z38.object({ eventId: UUID });
5014
+ var DeleteActionInput = z39.object({ eventId: UUID });
5364
5015
  var CustomActionInput = BaseActionInput.extend(
5365
- z38.object({
5366
- type: z38.literal(ActionType.CUSTOM).default(ActionType.CUSTOM),
5367
- customActionType: z38.string().describe("Name of the custom action.")
5016
+ z39.object({
5017
+ type: z39.literal(ActionType.CUSTOM).default(ActionType.CUSTOM),
5018
+ customActionType: z39.string().describe("Name of the custom action.")
5368
5019
  }).shape
5369
5020
  );
5370
- var ActionInput = z38.discriminatedUnion("type", [
5021
+ var ActionInput = z39.discriminatedUnion("type", [
5371
5022
  CreateActionInput.meta({ id: "CreateActionInput" }),
5372
5023
  RegisterActionInput.meta({ id: "RegisterActionInput" }),
5373
5024
  NotifyActionInput.meta({ id: "NotifyActionInput" }),
@@ -5404,11 +5055,11 @@ var ActionInput = z38.discriminatedUnion("type", [
5404
5055
  });
5405
5056
 
5406
5057
  // ../commons/src/events/Draft.ts
5407
- var Draft = z39.object({
5058
+ var Draft = z40.object({
5408
5059
  id: UUID,
5409
5060
  eventId: UUID,
5410
- transactionId: z39.string(),
5411
- createdAt: z39.string().datetime(),
5061
+ transactionId: z40.string(),
5062
+ createdAt: z40.string().datetime(),
5412
5063
  action: ActionBase.extend({
5413
5064
  type: ActionTypes.exclude([ActionTypes.enum.DELETE])
5414
5065
  }).omit({ id: true, createdAtLocation: true })
@@ -5417,7 +5068,7 @@ var Draft = z39.object({
5417
5068
  );
5418
5069
  var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
5419
5070
  type: ActionTypes.exclude([ActionTypes.enum.DELETE]),
5420
- status: z39.enum([
5071
+ status: z40.enum([
5421
5072
  ActionStatus.Requested,
5422
5073
  ActionStatus.Accepted,
5423
5074
  ActionStatus.Rejected
@@ -5425,30 +5076,33 @@ var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
5425
5076
  });
5426
5077
 
5427
5078
  // ../commons/src/events/EventInput.ts
5428
- var z40 = __toESM(require("zod/v4"));
5079
+ var z41 = __toESM(require("zod/v4"));
5429
5080
  var import_uuid11 = require("uuid");
5430
- var EventInput = z40.object({
5431
- transactionId: z40.string(),
5432
- type: z40.string(),
5081
+ var EventInput = z41.object({
5082
+ transactionId: z41.string(),
5083
+ type: z41.string(),
5433
5084
  createdAtLocation: UUID.nullish().describe(
5434
5085
  "Location where the event occurred. Required for system users."
5435
5086
  )
5436
5087
  }).meta({ default: { transactionId: (0, import_uuid11.v4)(), type: "birth" } });
5437
5088
 
5438
5089
  // ../commons/src/events/EventDocument.ts
5439
- var z41 = __toESM(require("zod/v4"));
5440
- var EventDocument = z41.object({
5090
+ var z42 = __toESM(require("zod/v4"));
5091
+ var EventDocument = z42.object({
5441
5092
  id: UUID.describe("Unique identifier of the event."),
5442
- type: z41.string().describe("Type of the event (e.g. birth, death, marriage)."),
5443
- createdAt: z41.string().datetime().describe("Timestamp indicating when the event was created."),
5444
- updatedAt: z41.string().datetime().describe(
5093
+ type: z42.string().describe("Type of the event (e.g. birth, death, marriage)."),
5094
+ createdAt: z42.string().datetime().describe("Timestamp indicating when the event was created."),
5095
+ updatedAt: z42.string().datetime().describe(
5445
5096
  "Timestamp of the last update, excluding changes from actions."
5446
5097
  ),
5447
- actions: z41.array(Action).describe("Ordered list of actions associated with the event."),
5448
- trackingId: z41.string().describe(
5098
+ actions: z42.array(Action).describe("Ordered list of actions associated with the event."),
5099
+ trackingId: z42.string().describe(
5449
5100
  "System-generated tracking identifier used to look up the event."
5450
5101
  )
5451
5102
  }).meta({ id: "EventDocument" });
5103
+ var EventDocumentOnlyLastAction = EventDocument.extend({
5104
+ actions: z42.array(Action).max(1).describe("Only the last action associated with the event.")
5105
+ }).brand("EventDocumentOnlyLastAction");
5452
5106
 
5453
5107
  // ../commons/src/events/defineConfig.ts
5454
5108
  var IGNORED_EVENT_TYPES = [
@@ -7899,21 +7553,7 @@ var digitalIdentityEvent = defineConfig({
7899
7553
  });
7900
7554
 
7901
7555
  // ../commons/src/events/test.utils.ts
7902
- var z42 = __toESM(require("zod/v4"));
7903
- var TestUserRole = z42.enum([
7904
- "FIELD_AGENT",
7905
- "LOCAL_REGISTRAR",
7906
- "LOCAL_SYSTEM_ADMIN",
7907
- "NATIONAL_REGISTRAR",
7908
- "REGISTRATION_AGENT",
7909
- "NATIONAL_SYSTEM_ADMIN",
7910
- "SOCIAL_WORKER",
7911
- "COMMUNITY_LEADER",
7912
- "PROVINCIAL_REGISTRAR"
7913
- ]);
7914
-
7915
- // ../commons/src/events/scopes.ts
7916
- var import_lodash6 = require("lodash");
7556
+ var z44 = __toESM(require("zod/v4"));
7917
7557
 
7918
7558
  // ../commons/src/events/locations.ts
7919
7559
  var z43 = __toESM(require("zod/v4"));
@@ -7947,116 +7587,65 @@ var Location = z43.object({
7947
7587
  status: LocationStatus,
7948
7588
  versions: z43.array(LocationVersion)
7949
7589
  });
7590
+ var ClientAdministrativeArea = AdministrativeArea.omit({
7591
+ name: true,
7592
+ status: true,
7593
+ externalId: true
7594
+ });
7595
+ var ClientLocation = Location.omit({
7596
+ name: true,
7597
+ status: true,
7598
+ externalId: true
7599
+ });
7600
+ function toClientLocation(location) {
7601
+ return {
7602
+ id: location.id,
7603
+ administrativeAreaId: location.administrativeAreaId,
7604
+ locationType: location.locationType,
7605
+ versions: location.versions
7606
+ };
7607
+ }
7608
+ function toClientAdministrativeArea(area) {
7609
+ return {
7610
+ id: area.id,
7611
+ parentId: area.parentId,
7612
+ versions: area.versions
7613
+ };
7614
+ }
7615
+ function validateAscendingDates(versions, ctx) {
7616
+ const ascending = versions.every(
7617
+ (version, index) => index === 0 || versions[index - 1].effectiveFrom < version.effectiveFrom
7618
+ );
7619
+ if (!ascending) {
7620
+ ctx.addIssue("versions must be strictly ascending by effectiveFrom");
7621
+ }
7622
+ }
7623
+ function validateUniqueIds(versions, ctx) {
7624
+ const versionIds = new Set(versions.map((version) => version.versionId));
7625
+ if (versionIds.size !== versions.length) {
7626
+ ctx.addIssue("versions must not repeat a versionId");
7627
+ }
7628
+ }
7629
+ var SeededLocationVersions = z43.array(LocationVersion).min(1).superRefine((versions, ctx) => {
7630
+ validateAscendingDates(versions, ctx);
7631
+ validateUniqueIds(versions, ctx);
7632
+ });
7950
7633
  var SetLocationPayload = z43.object({
7951
7634
  id: UUID,
7952
7635
  name: z43.string(),
7953
7636
  externalId: z43.string().nullish(),
7954
7637
  administrativeAreaId: UUID.nullable(),
7955
- locationType: z43.string().nullable()
7638
+ locationType: z43.string().nullable(),
7639
+ versions: SeededLocationVersions.optional()
7956
7640
  });
7957
7641
  var SetAdministrativeAreaPayload = z43.object({
7958
7642
  id: UUID,
7959
7643
  name: z43.string(),
7960
7644
  externalId: z43.string().nullish(),
7961
- parentId: UUID.nullable()
7645
+ parentId: UUID.nullable(),
7646
+ versions: SeededLocationVersions.optional()
7962
7647
  });
7963
7648
 
7964
- // ../commons/src/events/scopes.ts
7965
- var ACTION_SCOPE_MAP = {
7966
- [ActionType.READ]: ["record.read"],
7967
- [ActionType.CREATE]: ["record.create"],
7968
- [ActionType.NOTIFY]: ["record.notify"],
7969
- [ActionType.DECLARE]: ["record.declare", "record.register"],
7970
- [ActionType.EDIT]: ["record.edit"],
7971
- [ActionType.DELETE]: ["record.declare", "record.notify"],
7972
- [ActionType.REGISTER]: ["record.register"],
7973
- [ActionType.PRINT_CERTIFICATE]: ["record.print-certified-copies"],
7974
- [ActionType.REQUEST_CORRECTION]: [
7975
- "record.request-correction",
7976
- "record.correct"
7977
- ],
7978
- [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: ["record.correct"],
7979
- [ActionType.REJECT_CORRECTION]: ["record.correct"],
7980
- [ActionType.APPROVE_CORRECTION]: ["record.correct"],
7981
- [ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
7982
- [ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
7983
- [ActionType.ARCHIVE]: ["record.archive"],
7984
- [ActionType.UNARCHIVE]: ["record.unarchive"],
7985
- [ActionType.REJECT]: ["record.reject"],
7986
- [ActionType.ASSIGN]: null,
7987
- [ActionType.UNASSIGN]: null,
7988
- [ActionType.DUPLICATE_DETECTED]: [],
7989
- [ActionType.CUSTOM]: []
7990
- };
7991
-
7992
- // ../commons/src/events/state/availableActions.ts
7993
- var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7994
- [EventStatus.enum.CREATED]: [
7995
- ActionType.READ,
7996
- ActionType.DECLARE,
7997
- ActionType.NOTIFY,
7998
- ActionType.DELETE,
7999
- ActionType.CUSTOM
8000
- ],
8001
- [EventStatus.enum.NOTIFIED]: [
8002
- ActionType.READ,
8003
- ActionType.EDIT,
8004
- ActionType.MARK_AS_DUPLICATE,
8005
- ActionType.ARCHIVE,
8006
- ActionType.REJECT,
8007
- ActionType.CUSTOM
8008
- ],
8009
- [EventStatus.enum.DECLARED]: [
8010
- ActionType.READ,
8011
- ActionType.REGISTER,
8012
- ActionType.MARK_AS_DUPLICATE,
8013
- ActionType.ARCHIVE,
8014
- ActionType.REJECT,
8015
- ActionType.CUSTOM,
8016
- ActionType.EDIT
8017
- ],
8018
- [EventStatus.enum.REGISTERED]: [
8019
- ActionType.READ,
8020
- ActionType.PRINT_CERTIFICATE,
8021
- ActionType.REQUEST_CORRECTION,
8022
- ActionType.APPROVE_CORRECTION,
8023
- ActionType.REJECT_CORRECTION,
8024
- ActionType.CUSTOM,
8025
- ClientSpecificAction.REVIEW_CORRECTION_REQUEST
8026
- ],
8027
- [EventStatus.enum.ARCHIVED]: [
8028
- ActionType.READ,
8029
- ActionType.CUSTOM,
8030
- ActionType.UNARCHIVE
8031
- ]
8032
- };
8033
- var ACTION_FILTERS = {
8034
- [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
8035
- [ActionType.REQUEST_CORRECTION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
8036
- [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
8037
- [ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
8038
- [ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
8039
- [ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
8040
- [ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
8041
- [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
8042
- [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag) => flag.endsWith(":requested")),
8043
- [ActionType.ARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
8044
- [ActionType.UNARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
8045
- [ActionType.ASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
8046
- [ActionType.UNASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
8047
- [ActionType.CUSTOM]: (flags) => !flags.some((flag) => flag.endsWith(":requested"))
8048
- };
8049
- var REJECTED_ACTIONS = [
8050
- ActionType.READ,
8051
- ActionType.NOTIFY,
8052
- ActionType.CUSTOM,
8053
- ActionType.EDIT,
8054
- ActionType.ARCHIVE
8055
- ];
8056
-
8057
- // ../commons/src/events/FileUtils.ts
8058
- var import_lodash7 = require("lodash");
8059
-
8060
7649
  // ../commons/src/events/mocks.test.utils.ts
8061
7650
  function withVersionFields(entity) {
8062
7651
  return {
@@ -8389,90 +7978,343 @@ var V2_DEFAULT_MOCK_LOCATIONS_MAP = new Map(
8389
7978
  var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP = new Map(
8390
7979
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [a.id, a])
8391
7980
  );
7981
+ var V2_DEFAULT_MOCK_CLIENT_LOCATIONS_MAP = new Map(
7982
+ V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, toClientLocation(l)])
7983
+ );
7984
+ var V2_DEFAULT_MOCK_CLIENT_ADMINISTRATIVE_AREAS_MAP = new Map(
7985
+ V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [
7986
+ a.id,
7987
+ toClientAdministrativeArea(a)
7988
+ ])
7989
+ );
7990
+
7991
+ // ../commons/src/events/test.utils.ts
7992
+ var TestUserRole = z44.enum([
7993
+ "FIELD_AGENT",
7994
+ "LOCAL_REGISTRAR",
7995
+ "LOCAL_SYSTEM_ADMIN",
7996
+ "NATIONAL_REGISTRAR",
7997
+ "REGISTRATION_AGENT",
7998
+ "NATIONAL_SYSTEM_ADMIN",
7999
+ "SOCIAL_WORKER",
8000
+ "COMMUNITY_LEADER",
8001
+ "PROVINCIAL_REGISTRAR"
8002
+ ]);
8003
+
8004
+ // ../commons/src/events/scopes.ts
8005
+ var import_lodash6 = require("lodash");
8006
+ var ACTION_SCOPE_MAP = {
8007
+ [ActionType.READ]: ["record.read"],
8008
+ [ActionType.CREATE]: ["record.create"],
8009
+ [ActionType.NOTIFY]: ["record.notify"],
8010
+ [ActionType.DECLARE]: ["record.declare", "record.register"],
8011
+ [ActionType.EDIT]: ["record.edit"],
8012
+ [ActionType.DELETE]: ["record.declare", "record.notify"],
8013
+ [ActionType.REGISTER]: ["record.register"],
8014
+ [ActionType.PRINT_CERTIFICATE]: ["record.print-certified-copies"],
8015
+ [ActionType.REQUEST_CORRECTION]: [
8016
+ "record.request-correction",
8017
+ "record.correct"
8018
+ ],
8019
+ [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: ["record.correct"],
8020
+ [ActionType.REJECT_CORRECTION]: ["record.correct"],
8021
+ [ActionType.APPROVE_CORRECTION]: ["record.correct"],
8022
+ [ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
8023
+ [ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
8024
+ [ActionType.ARCHIVE]: ["record.archive"],
8025
+ [ActionType.UNARCHIVE]: ["record.unarchive"],
8026
+ [ActionType.REJECT]: ["record.reject"],
8027
+ [ActionType.ASSIGN]: null,
8028
+ [ActionType.UNASSIGN]: null,
8029
+ [ActionType.DUPLICATE_DETECTED]: [],
8030
+ [ActionType.CUSTOM]: []
8031
+ };
8032
+
8033
+ // ../commons/src/events/state/availableActions.ts
8034
+ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
8035
+ [EventStatus.enum.CREATED]: [
8036
+ ActionType.READ,
8037
+ ActionType.DECLARE,
8038
+ ActionType.NOTIFY,
8039
+ ActionType.DELETE
8040
+ ],
8041
+ [EventStatus.enum.NOTIFIED]: [
8042
+ ActionType.READ,
8043
+ ActionType.EDIT,
8044
+ ActionType.MARK_AS_DUPLICATE,
8045
+ ActionType.ARCHIVE,
8046
+ ActionType.REJECT,
8047
+ ActionType.CUSTOM
8048
+ ],
8049
+ [EventStatus.enum.DECLARED]: [
8050
+ ActionType.READ,
8051
+ ActionType.REGISTER,
8052
+ ActionType.MARK_AS_DUPLICATE,
8053
+ ActionType.ARCHIVE,
8054
+ ActionType.REJECT,
8055
+ ActionType.CUSTOM,
8056
+ ActionType.EDIT
8057
+ ],
8058
+ [EventStatus.enum.REGISTERED]: [
8059
+ ActionType.READ,
8060
+ ActionType.PRINT_CERTIFICATE,
8061
+ ActionType.REQUEST_CORRECTION,
8062
+ ActionType.APPROVE_CORRECTION,
8063
+ ActionType.REJECT_CORRECTION,
8064
+ ActionType.CUSTOM,
8065
+ ClientSpecificAction.REVIEW_CORRECTION_REQUEST
8066
+ ],
8067
+ [EventStatus.enum.ARCHIVED]: [
8068
+ ActionType.READ,
8069
+ ActionType.CUSTOM,
8070
+ ActionType.UNARCHIVE
8071
+ ]
8072
+ };
8073
+ var ACTION_FILTERS = {
8074
+ [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8075
+ [ActionType.REQUEST_CORRECTION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8076
+ [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8077
+ [ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8078
+ [ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8079
+ [ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
8080
+ [ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
8081
+ [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
8082
+ [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8083
+ [ActionType.ARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
8084
+ [ActionType.UNARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
8085
+ [ActionType.ASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
8086
+ [ActionType.UNASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
8087
+ [ActionType.CUSTOM]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested"))
8088
+ };
8089
+ var REJECTED_ACTIONS = [
8090
+ ActionType.READ,
8091
+ ActionType.NOTIFY,
8092
+ ActionType.CUSTOM,
8093
+ ActionType.EDIT,
8094
+ ActionType.ARCHIVE
8095
+ ];
8096
+
8097
+ // ../commons/src/events/FileUtils.ts
8098
+ var import_lodash7 = require("lodash");
8099
+
8100
+ // ../commons/src/events/locationPayloads.ts
8101
+ var z45 = __toESM(require("zod/v4"));
8102
+ var CreateLocationPayload = z45.object({
8103
+ id: UUID.optional(),
8104
+ versionId: UUID.optional(),
8105
+ name: z45.string(),
8106
+ externalId: z45.string().nullish(),
8107
+ administrativeAreaId: UUID.nullable(),
8108
+ locationType: z45.string().nullable(),
8109
+ effectiveFrom: z45.iso.date().optional(),
8110
+ status: LocationStatus.default("active")
8111
+ });
8112
+ var UpdateLocationPayload = z45.strictObject({
8113
+ id: UUID,
8114
+ versionId: UUID.optional(),
8115
+ name: z45.string(),
8116
+ externalId: z45.string().nullish(),
8117
+ status: LocationStatus,
8118
+ effectiveFrom: z45.iso.date().optional(),
8119
+ lastVersionId: UUID
8120
+ });
8121
+ var WithdrawLocationVersionPayload = z45.object({
8122
+ id: UUID,
8123
+ versionId: UUID
8124
+ });
8125
+ var CreateAdministrativeAreaPayload = z45.object({
8126
+ id: UUID.optional(),
8127
+ versionId: UUID.optional(),
8128
+ name: z45.string(),
8129
+ externalId: z45.string().nullish(),
8130
+ parentId: UUID.nullable(),
8131
+ effectiveFrom: z45.iso.date().optional(),
8132
+ status: LocationStatus.default("active")
8133
+ });
8134
+ var UpdateAdministrativeAreaPayload = z45.strictObject({
8135
+ id: UUID,
8136
+ versionId: UUID.optional(),
8137
+ name: z45.string(),
8138
+ externalId: z45.string().nullish(),
8139
+ status: LocationStatus,
8140
+ effectiveFrom: z45.iso.date().optional(),
8141
+ lastVersionId: UUID
8142
+ });
8143
+ var WithdrawAdministrativeAreaVersionPayload = z45.object({
8144
+ id: UUID,
8145
+ versionId: UUID
8146
+ });
8392
8147
 
8393
8148
  // ../commons/src/notification/UserNotifications.ts
8394
- var z44 = __toESM(require("zod/v4"));
8149
+ var z46 = __toESM(require("zod/v4"));
8395
8150
  var TriggerEvent = {
8396
8151
  USER_CREATED: "user-created",
8397
8152
  USER_UPDATED: "user-updated",
8398
8153
  USERNAME_REMINDER: "username-reminder",
8399
8154
  RESET_PASSWORD: "reset-password",
8400
8155
  RESET_PASSWORD_BY_ADMIN: "reset-password-by-admin",
8156
+ PASSWORD_RESET_LINK: "password-reset-link",
8157
+ USERNAME_REMINDER_LINK: "username-reminder-link",
8401
8158
  RESEND_INVITE: "resend-invite",
8402
8159
  TWO_FA: "2fa",
8403
8160
  ALL_USER_NOTIFICATION: "all-user-notification",
8404
8161
  CHANGE_PHONE_NUMBER: "change-phone-number",
8405
8162
  CHANGE_EMAIL_ADDRESS: "change-email-address"
8406
8163
  };
8407
- var Recipient = z44.object({
8164
+ var Recipient = z46.object({
8408
8165
  name: NameFieldValue.optional(),
8409
- mobile: z44.string().optional(),
8410
- email: z44.string().optional(),
8411
- bcc: z44.array(z44.string()).optional()
8166
+ mobile: z46.string().optional(),
8167
+ email: z46.string().optional(),
8168
+ bcc: z46.array(z46.string()).optional()
8412
8169
  });
8413
- var BasePayload = z44.object({
8170
+ var BasePayload = z46.object({
8414
8171
  recipient: Recipient
8415
8172
  });
8416
8173
  var TriggerPayload = {
8417
8174
  [TriggerEvent.USER_CREATED]: BasePayload.extend({
8418
- username: z44.string(),
8419
- temporaryPassword: z44.string()
8175
+ username: z46.string(),
8176
+ temporaryPassword: z46.string()
8420
8177
  }),
8421
8178
  [TriggerEvent.USER_UPDATED]: BasePayload.extend({
8422
- oldUsername: z44.string(),
8423
- newUsername: z44.string()
8179
+ oldUsername: z46.string(),
8180
+ newUsername: z46.string()
8424
8181
  }),
8425
8182
  [TriggerEvent.USERNAME_REMINDER]: BasePayload.extend({
8426
- username: z44.string()
8183
+ username: z46.string()
8427
8184
  }),
8428
8185
  [TriggerEvent.RESET_PASSWORD]: BasePayload.extend({
8429
- code: z44.string()
8186
+ code: z46.string()
8430
8187
  }),
8431
8188
  [TriggerEvent.RESET_PASSWORD_BY_ADMIN]: BasePayload.extend({
8432
- temporaryPassword: z44.string(),
8433
- admin: z44.object({
8434
- id: z44.string(),
8189
+ temporaryPassword: z46.string(),
8190
+ admin: z46.object({
8191
+ id: z46.string(),
8435
8192
  name: NameFieldValue,
8436
- role: z44.string()
8193
+ role: z46.string()
8437
8194
  })
8438
8195
  }),
8196
+ [TriggerEvent.PASSWORD_RESET_LINK]: BasePayload.extend({
8197
+ token: z46.string()
8198
+ }),
8199
+ [TriggerEvent.USERNAME_REMINDER_LINK]: BasePayload.extend({
8200
+ token: z46.string()
8201
+ }),
8439
8202
  [TriggerEvent.RESEND_INVITE]: BasePayload.extend({
8440
- username: z44.string(),
8441
- temporaryPassword: z44.string()
8203
+ username: z46.string(),
8204
+ temporaryPassword: z46.string()
8442
8205
  }),
8443
8206
  [TriggerEvent.TWO_FA]: BasePayload.extend({
8444
- code: z44.string()
8207
+ code: z46.string()
8445
8208
  }),
8446
8209
  [TriggerEvent.ALL_USER_NOTIFICATION]: BasePayload.extend({
8447
- subject: z44.string(),
8448
- body: z44.string()
8210
+ subject: z46.string(),
8211
+ body: z46.string()
8449
8212
  }),
8450
8213
  [TriggerEvent.CHANGE_PHONE_NUMBER]: BasePayload.extend({
8451
- code: z44.string()
8214
+ code: z46.string()
8452
8215
  }),
8453
8216
  [TriggerEvent.CHANGE_EMAIL_ADDRESS]: BasePayload.extend({
8454
- code: z44.string()
8217
+ code: z46.string()
8455
8218
  })
8456
8219
  };
8220
+ function parseUserEventTrigger(event2, body) {
8221
+ const schema = TriggerPayload[event2];
8222
+ return schema.parse(body);
8223
+ }
8224
+
8225
+ // ../commons/src/url.ts
8226
+ function joinUrl(base, path) {
8227
+ const baseWithSlash = base.endsWith("/") ? base : base + "/";
8228
+ return new URL(path, baseWithSlash);
8229
+ }
8230
+
8231
+ // ../commons/src/logger.ts
8232
+ var import_pino = __toESM(require("pino"));
8233
+ function normalizeLogArgs(args) {
8234
+ const [first, ...rest] = args;
8235
+ if (typeof first !== "string" || rest.length === 0) {
8236
+ return args;
8237
+ }
8238
+ const mergingObject = {};
8239
+ const primitives = [];
8240
+ for (const arg of rest) {
8241
+ if (arg instanceof Error) {
8242
+ mergingObject.err = import_pino.default.stdSerializers.err(arg);
8243
+ } else if (arg !== null && typeof arg === "object") {
8244
+ Object.assign(mergingObject, arg);
8245
+ } else {
8246
+ primitives.push(arg);
8247
+ }
8248
+ }
8249
+ const message = primitives.length ? `${first} ${primitives.join(" ")}` : first;
8250
+ return Object.keys(mergingObject).length ? [mergingObject, message] : [message];
8251
+ }
8252
+ function filterHealthCheckLogs(args, method) {
8253
+ const logger2 = this;
8254
+ for (const arg of args) {
8255
+ if (typeof arg === "string" && arg.includes("get /ping 200")) {
8256
+ if (logger2.debug) {
8257
+ return logger2.debug(...args);
8258
+ }
8259
+ }
8260
+ }
8261
+ return method.apply(this, normalizeLogArgs(args));
8262
+ }
8263
+ function buildLoggerOptions() {
8264
+ return {
8265
+ serializers: { err: import_pino.default.stdSerializers.err },
8266
+ hooks: { logMethod: filterHealthCheckLogs }
8267
+ };
8268
+ }
8269
+ var logger = false ? (0, import_pino.default)({
8270
+ level: "info",
8271
+ redact: [
8272
+ "req.headers.authorization",
8273
+ "req.remoteAddress",
8274
+ "req.headers['x-real-ip']"
8275
+ ],
8276
+ ...buildLoggerOptions()
8277
+ }) : (0, import_pino.default)({
8278
+ level: "debug",
8279
+ transport: {
8280
+ target: "pino-pretty",
8281
+ options: {
8282
+ colorize: true,
8283
+ ignore: "pid,hostname"
8284
+ }
8285
+ },
8286
+ ...buildLoggerOptions()
8287
+ });
8288
+ var level = false ? "silent" : process.env.LOG_LEVEL;
8289
+ if (level) {
8290
+ logger.level = level;
8291
+ }
8292
+
8293
+ // ../commons/src/notification/dispatch.ts
8457
8294
  async function triggerUserEventNotification({
8458
8295
  event: event2,
8459
8296
  payload,
8460
8297
  countryConfigUrl,
8461
8298
  authHeader
8462
8299
  }) {
8463
- return await fetch(joinUrl(countryConfigUrl, `triggers/user/${event2}`), {
8464
- method: "POST",
8465
- body: JSON.stringify(payload),
8466
- headers: {
8467
- "Content-Type": "application/json",
8468
- ...authHeader
8300
+ const response = await fetch(
8301
+ joinUrl(countryConfigUrl, `triggers/user/${event2}`),
8302
+ {
8303
+ method: "POST",
8304
+ body: JSON.stringify(payload),
8305
+ headers: {
8306
+ "Content-Type": "application/json",
8307
+ ...authHeader
8308
+ }
8469
8309
  }
8470
- });
8471
- }
8472
- function parseUserEventTrigger(event2, body) {
8473
- const schema = TriggerPayload[event2];
8474
- return schema.parse(body);
8310
+ );
8311
+ if (!response.ok) {
8312
+ logger.error(
8313
+ `triggerUserEventNotification: dispatch failed for event "${event2}" with status ${response.status}`
8314
+ );
8315
+ }
8316
+ return response;
8475
8317
  }
8476
8318
 
8477
8319
  // src/notification/index.ts
8478
- z45.globalRegistry.clear();
8320
+ z47.globalRegistry.clear();