@opencrvs/toolkit 2.2.0-rc.045257f → 2.2.0-rc.25c3c81

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 (156) hide show
  1. package/build.sh +15 -2
  2. package/dist/application-config/index.js +16 -5
  3. package/dist/authentication/index.d.ts +1 -1
  4. package/dist/authentication/index.js +4 -8
  5. package/dist/cli.js +2197 -544
  6. package/dist/commons/api/router.d.ts +17 -4
  7. package/dist/commons/application-config/index.d.ts +1 -1
  8. package/dist/commons/conditionals/conditionals.d.ts +4 -4
  9. package/dist/commons/conditionals/validate.d.ts +1 -1
  10. package/dist/commons/events/ActionStatus.d.ts +2 -2
  11. package/dist/commons/events/ActionType.d.ts +2 -0
  12. package/dist/commons/events/AdvancedSearchConfig.d.ts +3 -0
  13. package/dist/commons/events/Draft.d.ts +34 -1
  14. package/dist/commons/events/EventConfig.d.ts +446 -0
  15. package/dist/commons/events/EventDocument.d.ts +2 -0
  16. package/dist/commons/events/EventIndex.d.ts +1 -0
  17. package/dist/commons/events/EventInput.d.ts +1 -0
  18. package/dist/commons/events/EventMetadata.d.ts +1 -0
  19. package/dist/commons/events/FieldTypeMapping.d.ts +19 -19
  20. package/dist/commons/events/PlainDate.d.ts +5 -0
  21. package/dist/commons/events/defineConfig.d.ts +7 -2
  22. package/dist/commons/events/event.d.ts +4 -1
  23. package/dist/commons/events/field.d.ts +5 -0
  24. package/dist/commons/events/locations.d.ts +1 -1
  25. package/dist/commons/events/scopes.d.ts +2 -1
  26. package/dist/commons/events/state/index.d.ts +1 -0
  27. package/dist/commons/events/test.utils.d.ts +59 -6
  28. package/dist/commons/events/utils.d.ts +28 -2
  29. package/dist/commons/users/Role.d.ts +23 -0
  30. package/dist/commons/users/User.d.ts +263 -0
  31. package/dist/commons/users/authentication.d.ts +67 -0
  32. package/dist/commons/users/index.d.ts +5 -0
  33. package/dist/commons/users/roleValidations.d.ts +15 -0
  34. package/dist/commons/users/scopes.d.ts +1402 -0
  35. package/dist/commons/users/userReferences.d.ts +176 -0
  36. package/dist/conditionals/index.js +3 -3
  37. package/dist/configurator/index.d.ts +24 -0
  38. package/dist/configurator/index.d.ts.map +1 -0
  39. package/dist/configurator/index.js +161 -0
  40. package/dist/configurator/layout.d.ts +28 -0
  41. package/dist/configurator/layout.d.ts.map +1 -0
  42. package/dist/configurator/layout.js +78 -0
  43. package/dist/configurator/paths.d.ts +13 -0
  44. package/dist/configurator/paths.d.ts.map +1 -0
  45. package/dist/configurator/paths.js +48 -0
  46. package/dist/configurator/server/environments.d.ts +20 -0
  47. package/dist/configurator/server/environments.d.ts.map +1 -0
  48. package/dist/configurator/server/environments.js +143 -0
  49. package/dist/configurator/server/files.d.ts +11 -0
  50. package/dist/configurator/server/files.d.ts.map +1 -0
  51. package/dist/configurator/server/files.js +67 -0
  52. package/dist/configurator/server/github.d.ts +56 -0
  53. package/dist/configurator/server/github.d.ts.map +1 -0
  54. package/dist/configurator/server/github.js +239 -0
  55. package/dist/configurator/server/plugin.d.ts +39 -0
  56. package/dist/configurator/server/plugin.d.ts.map +1 -0
  57. package/dist/configurator/server/plugin.js +298 -0
  58. package/dist/configurator/server/seal.d.ts +2 -0
  59. package/dist/configurator/server/seal.d.ts.map +1 -0
  60. package/dist/configurator/server/seal.js +36 -0
  61. package/dist/configurator/server/sshKeys.d.ts +5 -0
  62. package/dist/configurator/server/sshKeys.d.ts.map +1 -0
  63. package/dist/configurator/server/sshKeys.js +28 -0
  64. package/dist/configurator/server/start.d.ts +12 -0
  65. package/dist/configurator/server/start.d.ts.map +1 -0
  66. package/dist/configurator/server/start.js +91 -0
  67. package/dist/configurator/testing.d.ts +11 -0
  68. package/dist/configurator/testing.d.ts.map +1 -0
  69. package/dist/configurator/testing.js +74 -0
  70. package/dist/configurator/ui/bindings/bindings.d.ts +35 -0
  71. package/dist/configurator/ui/bindings/bindings.d.ts.map +1 -0
  72. package/dist/configurator/ui/bindings/bindings.js +5 -0
  73. package/dist/configurator/ui/bindings/parsers.d.ts +7 -0
  74. package/dist/configurator/ui/bindings/parsers.d.ts.map +1 -0
  75. package/dist/configurator/ui/bindings/parsers.js +85 -0
  76. package/dist/configurator/ui/form/users.d.ts +11 -0
  77. package/dist/configurator/ui/form/users.d.ts.map +1 -0
  78. package/dist/configurator/ui/form/users.js +33 -0
  79. package/dist/configurator/ui/plan/dependencyHosts.d.ts +2 -0
  80. package/dist/configurator/ui/plan/dependencyHosts.d.ts.map +1 -0
  81. package/dist/configurator/ui/plan/dependencyHosts.js +36 -0
  82. package/dist/configurator/ui/plan/templateValues.d.ts +11 -0
  83. package/dist/configurator/ui/plan/templateValues.d.ts.map +1 -0
  84. package/dist/configurator/ui/plan/templateValues.js +70 -0
  85. package/dist/configurator/workflows.d.ts +53 -0
  86. package/dist/configurator/workflows.d.ts.map +1 -0
  87. package/dist/configurator/workflows.js +161 -0
  88. package/dist/configurator-assets/forms/bindings.yml +263 -0
  89. package/dist/configurator-assets/templates/README.md +18 -0
  90. package/dist/configurator-assets/templates/charts-values/dependencies/values.override.yaml +4 -0
  91. package/dist/configurator-assets/templates/charts-values/dependencies/values.yaml +99 -0
  92. package/dist/configurator-assets/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
  93. package/dist/configurator-assets/templates/charts-values/opencrvs-services/values.yaml +83 -0
  94. package/dist/configurator-assets/templates/charts-values/opentelemetry/values.yaml +102 -0
  95. package/dist/configurator-assets/templates/charts-values/traefik/values.override.yaml +4 -0
  96. package/dist/configurator-assets/templates/charts-values/traefik/values.yaml +130 -0
  97. package/dist/configurator-assets/templates/inventory/inventory.template.yml +98 -0
  98. package/dist/configurator-assets/ui/apple-touch-icon.png +0 -0
  99. package/dist/configurator-assets/ui/assets/index-Bf3eC7uO.js +169 -0
  100. package/dist/configurator-assets/ui/assets/index-CaqYFJUk.css +6 -0
  101. package/dist/configurator-assets/ui/assets/opencrvs-logo-sIjz08HT.svg +1 -0
  102. package/dist/configurator-assets/ui/assets/poppins-400-BwTUGeWf.woff2 +0 -0
  103. package/dist/configurator-assets/ui/assets/poppins-500-CWICHMj6.woff2 +0 -0
  104. package/dist/configurator-assets/ui/assets/poppins-600-DJVo7c07.woff2 +0 -0
  105. package/dist/configurator-assets/ui/assets/poppins-700-g9MkRaG0.woff2 +0 -0
  106. package/dist/configurator-assets/ui/favicon-32x32.png +0 -0
  107. package/dist/configurator-assets/ui/index.html +25 -0
  108. package/dist/environment/custom-types.d.ts +1 -0
  109. package/dist/environment/custom-types.d.ts.map +1 -1
  110. package/dist/environment/derived-variables.d.ts +8 -0
  111. package/dist/environment/derived-variables.d.ts.map +1 -1
  112. package/dist/environment/derived-variables.js +9 -0
  113. package/dist/environment/questions.d.ts +42 -9
  114. package/dist/environment/questions.d.ts.map +1 -1
  115. package/dist/environment/questions.js +70 -47
  116. package/dist/environment/registry.d.ts +15 -0
  117. package/dist/environment/registry.d.ts.map +1 -0
  118. package/dist/environment/registry.js +112 -0
  119. package/dist/environment/setup-environment.d.ts.map +1 -1
  120. package/dist/environment/setup-environment.js +104 -23
  121. package/dist/events/index.js +635 -149
  122. package/dist/migrations/add-notify-config.d.ts +40 -0
  123. package/dist/migrations/add-notify-config.d.ts.map +1 -0
  124. package/dist/migrations/add-notify-config.js +249 -0
  125. package/dist/migrations/index.d.ts.map +1 -1
  126. package/dist/migrations/index.js +602 -143
  127. package/dist/migrations/move-declaration-to-declare-action.d.ts.map +1 -1
  128. package/dist/migrations/move-declaration-to-declare-action.js +27 -144
  129. package/dist/migrations/read-declaration-through-helper.d.ts.map +1 -1
  130. package/dist/migrations/read-declaration-through-helper.js +3 -61
  131. package/dist/migrations/resolve-versioned-event-config.d.ts +56 -0
  132. package/dist/migrations/resolve-versioned-event-config.d.ts.map +1 -0
  133. package/dist/migrations/resolve-versioned-event-config.js +353 -0
  134. package/dist/migrations/utils.d.ts +61 -0
  135. package/dist/migrations/utils.d.ts.map +1 -0
  136. package/dist/migrations/utils.js +218 -0
  137. package/dist/notification/index.js +616 -66
  138. package/dist/roles/index.d.ts +2 -0
  139. package/dist/roles/index.d.ts.map +1 -0
  140. package/dist/roles/index.js +730 -0
  141. package/dist/scopes/index.d.ts +0 -10
  142. package/dist/scopes/index.js +3 -7
  143. package/dist/templates/charts-values/dependencies/values.yaml +4 -1
  144. package/dist/templates/charts-values/opencrvs-services/values.yaml +2 -2
  145. package/dist/verify/endpoints.d.ts +11 -0
  146. package/dist/verify/endpoints.d.ts.map +1 -1
  147. package/dist/verify/endpoints.js +21 -27
  148. package/opencrvs-toolkit-2.2.0-rc.25c3c81.tgz +0 -0
  149. package/package.json +16 -3
  150. package/tsconfig.build.json +11 -1
  151. package/tsconfig.build.tsbuildinfo +1 -1
  152. package/tsconfig.json +15 -6
  153. package/dist/environment/dockerhub.d.ts +0 -15
  154. package/dist/environment/dockerhub.d.ts.map +0 -1
  155. package/dist/environment/dockerhub.js +0 -104
  156. package/opencrvs-toolkit-2.2.0-rc.045257f.tgz +0 -0
@@ -88,6 +88,7 @@ __export(events_exports, {
88
88
  CustomFieldValue: () => CustomFieldValue,
89
89
  CustomFlag: () => CustomFlag,
90
90
  DEFAULT_DATE_OF_EVENT_PROPERTY: () => DEFAULT_DATE_OF_EVENT_PROPERTY,
91
+ DEFAULT_EFFECTIVE_FROM: () => DEFAULT_EFFECTIVE_FROM,
91
92
  DEFAULT_PLACE_OF_EVENT_PROPERTY: () => DEFAULT_PLACE_OF_EVENT_PROPERTY,
92
93
  DOCUMENT_DELETE_SCOPES: () => DOCUMENT_DELETE_SCOPES,
93
94
  DataEntry: () => DataEntry,
@@ -117,7 +118,7 @@ __export(events_exports, {
117
118
  EmailField: () => EmailField,
118
119
  EmailValue: () => EmailValue,
119
120
  EnableConditional: () => EnableConditional,
120
- EventConfig: () => EventConfig,
121
+ EventConfig: () => EventConfig2,
121
122
  EventDocument: () => EventDocument,
122
123
  EventDocumentOnlyLastAction: () => EventDocumentOnlyLastAction,
123
124
  EventFieldConfigSchema: () => EventFieldConfigSchema,
@@ -161,6 +162,7 @@ __export(events_exports, {
161
162
  HiddenFieldValue: () => HiddenFieldValue,
162
163
  HttpFieldUpdateValue: () => HttpFieldUpdateValue,
163
164
  HttpFieldValue: () => HttpFieldValue,
165
+ INITIAL_EVENT_CONFIG_VERSION_ID: () => INITIAL_EVENT_CONFIG_VERSION_ID,
164
166
  IdReaderFieldValue: () => IdReaderFieldValue,
165
167
  ImageMimeType: () => ImageMimeType,
166
168
  InactiveOfficeError: () => InactiveOfficeError,
@@ -208,6 +210,7 @@ __export(events_exports, {
208
210
  RejectCorrectionActionInput: () => RejectCorrectionActionInput,
209
211
  RejectDeclarationActionInput: () => RejectDeclarationActionInput,
210
212
  RejectedCorrectionAction: () => RejectedCorrectionAction,
213
+ RemoteDraft: () => RemoteDraft,
211
214
  RequestCorrectionActionInput: () => RequestCorrectionActionInput,
212
215
  RevokeRegistrationActionInput: () => RevokeRegistrationActionInput,
213
216
  SearchQuery: () => SearchQuery,
@@ -247,6 +250,7 @@ __export(events_exports, {
247
250
  VerificationActionConfig: () => VerificationActionConfig,
248
251
  VerificationPageConfig: () => VerificationPageConfig,
249
252
  VerificationStatusValue: () => VerificationStatusValue,
253
+ VersionedEventConfig: () => VersionedEventConfig2,
250
254
  WithdrawAdministrativeAreaVersionPayload: () => WithdrawAdministrativeAreaVersionPayload,
251
255
  WithdrawLocationVersionPayload: () => WithdrawLocationVersionPayload,
252
256
  Within: () => Within,
@@ -276,6 +280,7 @@ __export(events_exports, {
276
280
  areConditionsMet: () => areConditionsMet,
277
281
  buildClientFunctionContext: () => buildClientFunctionContext,
278
282
  buildFormState: () => buildFormState,
283
+ byEffectiveFrom: () => byEffectiveFrom,
279
284
  canAccessEventWithScope: () => canAccessEventWithScope,
280
285
  canAccessOtherUserWithScopes: () => canAccessOtherUserWithScopes,
281
286
  canAccessUserWithScope: () => canAccessUserWithScope,
@@ -313,6 +318,8 @@ __export(events_exports, {
313
318
  filterActionsByFlags: () => filterActionsByFlags,
314
319
  findActiveDraftForEvent: () => findActiveDraftForEvent,
315
320
  findAllFields: () => findAllFields,
321
+ findConfigVersion: () => findConfigVersion,
322
+ findEventConfigForRecord: () => findEventConfigForRecord,
316
323
  findLastAssignmentAction: () => findLastAssignmentAction,
317
324
  findPendingCorrectionAction: () => findPendingCorrectionAction,
318
325
  findRecordActionPages: () => findRecordActionPages,
@@ -321,6 +328,7 @@ __export(events_exports, {
321
328
  flattenFormState: () => flattenFormState,
322
329
  generateActionDeclarationInput: () => generateActionDeclarationInput,
323
330
  generateActionDocument: () => generateActionDocument,
331
+ generateActionDocuments: () => generateActionDocuments,
324
332
  generateActionDuplicateDeclarationInput: () => generateActionDuplicateDeclarationInput,
325
333
  generateEventConfig: () => generateEventConfig,
326
334
  generateEventDocument: () => generateEventDocument,
@@ -353,17 +361,22 @@ __export(events_exports, {
353
361
  getCompleteActionAnnotation: () => getCompleteActionAnnotation,
354
362
  getCompleteActionContent: () => getCompleteActionContent,
355
363
  getCompleteActionDeclaration: () => getCompleteActionDeclaration,
364
+ getConfigVersion: () => getConfigVersion,
356
365
  getCurrentEventState: () => getCurrentEventState,
357
366
  getCustomActionFields: () => getCustomActionFields,
358
367
  getDeclaration: () => getDeclaration,
359
368
  getDeclarationAfterEachAction: () => getDeclarationAfterEachAction,
360
369
  getDeclarationFieldById: () => getDeclarationFieldById,
361
370
  getDeclarationFields: () => getDeclarationFields,
371
+ getDeclarationFieldsOfAllVersions: () => getDeclarationFieldsOfAllVersions,
362
372
  getDeclarationPages: () => getDeclarationPages,
363
373
  getDeclarationWithPendingAction: () => getDeclarationWithPendingAction,
364
374
  getEventConfigById: () => getEventConfigById,
375
+ getEventConfigForRecord: () => getEventConfigForRecord,
376
+ getEventConfigOfVersion: () => getEventConfigOfVersion,
365
377
  getEventFlags: () => getEventFlags,
366
378
  getEventValidatorContext: () => getEventValidatorContext,
379
+ getEventWithCompleteAcceptedActions: () => getEventWithCompleteAcceptedActions,
367
380
  getFilePathsFromEvent: () => getFilePathsFromEvent,
368
381
  getLeafAdministrativeAreaIds: () => getLeafAdministrativeAreaIds,
369
382
  getLocationHierarchy: () => getLocationHierarchy,
@@ -375,6 +388,7 @@ __export(events_exports, {
375
388
  getRandomDate: () => getRandomDate,
376
389
  getStatusFromActions: () => getStatusFromActions,
377
390
  getValidatorsForField: () => getValidatorsForField,
391
+ getVersionsInEffect: () => getVersionsInEffect,
378
392
  getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
379
393
  hasActiveExternalIdOnOrAfter: () => hasActiveExternalIdOnOrAfter,
380
394
  hasAnyOfScopes: () => hasAnyOfScopes,
@@ -474,6 +488,10 @@ __export(events_exports, {
474
488
  plainDateToLocalDate: () => plainDateToLocalDate,
475
489
  precompileActionSchemas: () => precompileActionSchemas,
476
490
  resolveDateOfEvent: () => resolveDateOfEvent,
491
+ resolveEffectiveVersion: () => resolveEffectiveVersion,
492
+ resolveEventConfig: () => resolveEventConfig,
493
+ resolveEventConfigInTimeZone: () => resolveEventConfigInTimeZone,
494
+ resolveEventConfigOnDate: () => resolveEventConfigOnDate,
477
495
  resolveEventCustomFlags: () => resolveEventCustomFlags,
478
496
  resolvePath: () => resolvePath,
479
497
  resolvePlaceOfEvent: () => resolvePlaceOfEvent,
@@ -486,13 +504,18 @@ __export(events_exports, {
486
504
  timePeriodToDateRange: () => timePeriodToDateRange,
487
505
  toClientAdministrativeArea: () => toClientAdministrativeArea,
488
506
  toClientLocation: () => toClientLocation,
507
+ toEventConfig: () => toEventConfig,
489
508
  toNotificationForm: () => toNotificationForm,
490
509
  toNotificationReview: () => toNotificationReview,
491
510
  toPlainDate: () => toPlainDate,
511
+ toPlainDateInTimeZone: () => toPlainDateInTimeZone,
512
+ toVersionedEventConfig: () => toVersionedEventConfig,
492
513
  todayISO: () => todayISO,
493
514
  user: () => user,
494
515
  userCanAccessEventWithScopes: () => userCanAccessEventWithScopes,
495
516
  validate: () => validate,
517
+ validateEachVersion: () => validateEachVersion,
518
+ validateEventConfig: () => validateEventConfig,
496
519
  validateFieldInput: () => validateFieldInput,
497
520
  validateValue: () => validateValue,
498
521
  window: () => window2,
@@ -507,11 +530,11 @@ var import_compile = require("zod/compile");
507
530
  // ../commons/src/events/AuditLog.ts
508
531
  var z9 = __toESM(require("zod/v4"));
509
532
 
510
- // ../commons/src/authentication.ts
533
+ // ../commons/src/users/authentication.ts
511
534
  var import_jwt_decode = __toESM(require("jwt-decode"));
512
535
  var z8 = __toESM(require("zod/v4"));
513
536
 
514
- // ../commons/src/scopes.ts
537
+ // ../commons/src/users/scopes.ts
515
538
  var z7 = __toESM(require("zod/v4"));
516
539
  var qs = __toESM(require("qs"));
517
540
 
@@ -603,7 +626,9 @@ var ActionTypes = z2.enum([
603
626
  "CUSTOM"
604
627
  ]);
605
628
  var ClientSpecificAction = {
606
- REVIEW_CORRECTION_REQUEST: "REVIEW_CORRECTION_REQUEST"
629
+ REVIEW_CORRECTION_REQUEST: "REVIEW_CORRECTION_REQUEST",
630
+ /** Opens the user's declare or notify draft of the event in its own flow */
631
+ CONTINUE_DRAFT: "CONTINUE_DRAFT"
607
632
  };
608
633
  var declarationActionValues = [
609
634
  ActionTypes.enum.DECLARE,
@@ -798,7 +823,7 @@ var EventStatus = z6.enum([
798
823
  "ARCHIVED"
799
824
  ]);
800
825
 
801
- // ../commons/src/scopes.ts
826
+ // ../commons/src/users/scopes.ts
802
827
  var JurisdictionFilter = z7.enum(["administrativeArea", "location", "all"]).describe(
803
828
  "Filters based on user jurisdiction relative to their office location in hierarchy."
804
829
  );
@@ -1130,7 +1155,7 @@ function getAcceptedScopesByType({
1130
1155
  }).filter((scope) => scope !== null);
1131
1156
  }
1132
1157
 
1133
- // ../commons/src/authentication.ts
1158
+ // ../commons/src/users/authentication.ts
1134
1159
  var TokenUserType = z8.enum(["user", "system"]);
1135
1160
  var TokenWithBearer = z8.string().regex(/^Bearer\s/);
1136
1161
 
@@ -1655,6 +1680,26 @@ var isPlainDate = (date) => PlainDate.validate(date);
1655
1680
  function toPlainDate(dateTime) {
1656
1681
  return dateTime.split("T")[0];
1657
1682
  }
1683
+ var dateFormats = /* @__PURE__ */ new Map();
1684
+ function getDateFormat(timeZone) {
1685
+ let format2 = dateFormats.get(timeZone);
1686
+ if (!format2) {
1687
+ format2 = new Intl.DateTimeFormat("en-US", {
1688
+ timeZone,
1689
+ year: "numeric",
1690
+ month: "2-digit",
1691
+ day: "2-digit"
1692
+ });
1693
+ dateFormats.set(timeZone, format2);
1694
+ }
1695
+ return format2;
1696
+ }
1697
+ function toPlainDateInTimeZone(date, timeZone) {
1698
+ const parts = Object.fromEntries(
1699
+ getDateFormat(timeZone).formatToParts(date).map(({ type, value }) => [type, value])
1700
+ );
1701
+ return `${parts.year}-${parts.month}-${parts.day}`;
1702
+ }
1658
1703
  function plainDateToLocalDate(date) {
1659
1704
  const [year, month, day] = date.split("-").map(Number);
1660
1705
  return new Date(year, month - 1, day);
@@ -2096,6 +2141,9 @@ var LegalStatuses = z17.object({
2096
2141
  var EventMetadata = z17.object({
2097
2142
  id: UUID,
2098
2143
  type: z17.string().describe("The type of event, such as birth, death, or marriage."),
2144
+ configVersionId: z17.string().describe(
2145
+ "Id of the event configuration version the record was created under. Records created before versioning have 'initial'."
2146
+ ),
2099
2147
  status: EventStatus,
2100
2148
  legalStatuses: LegalStatuses.describe(
2101
2149
  "Metadata related to the legal registration of the event, such as who registered it and when."
@@ -3736,7 +3784,7 @@ var ActionConfig = z25.discriminatedUnion("type", [
3736
3784
  }),
3737
3785
  NotifyConfig.meta({
3738
3786
  id: "NotifyActionConfig",
3739
- description: "Configuration for the notify action, including the notification form and its review page. When undefined, it is generated using the DeclareActionConfig."
3787
+ description: "Configuration for the notify action: the notification form and its review page. An event without a NOTIFY action cannot be notified."
3740
3788
  }),
3741
3789
  DeclareConfig.meta({
3742
3790
  id: "DeclareActionConfig",
@@ -4004,7 +4052,7 @@ var ReferenceField = BaseField2.extend({
4004
4052
  var Field = BaseField2.extend({
4005
4053
  id: z29.string().describe("Identifier of the summary field."),
4006
4054
  value: TranslationConfig.describe(
4007
- 'Field value template supports variables from configuration (e.g. "{informant.phoneNo} {informant.email}") and EventMetadata (e.g. "{event.legalStatuses.REGISTERED.acceptedAt, date, ::dd MMMM yyyy}").'
4055
+ 'Field value template supports variables from configuration (e.g. "{informant.phoneNo} {informant.email}") and EventMetadata (e.g. "{event.legalStatuses.REGISTERED.acceptedAt, date, ::dd MMMM yyyy}"). "{event.configVersionLabel}" gives the label of the configuration version that the record was created under.'
4008
4056
  ),
4009
4057
  label: TranslationConfig
4010
4058
  }).describe("Custom field defined for the summary view.");
@@ -4099,7 +4147,10 @@ var SearchQueryParams = z30.object({
4099
4147
  }).catchall(FieldValue);
4100
4148
  var FieldConfigSchema = BaseField3.extend({
4101
4149
  fieldId: z30.string(),
4102
- fieldType: z30.literal("field")
4150
+ fieldType: z30.literal("field"),
4151
+ defaultValue: z30.union([z30.boolean(), z30.string(), z30.number()]).optional().describe(
4152
+ `Value the field opens with in advanced search. Omitted or true uses the declaration form's defaultValue, false opens the field empty, and any other value opens it with that value. Only text, number and date fields take a value; every other field type, and date fields searched as a range, only accept true or false.`
4153
+ )
4103
4154
  });
4104
4155
  var EventFieldIdInput = z30.enum([
4105
4156
  "trackingId",
@@ -4148,6 +4199,41 @@ var AdvancedSearchConfig = z30.object({
4148
4199
  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()`)."
4149
4200
  });
4150
4201
 
4202
+ // ../commons/src/utils.ts
4203
+ var z31 = __toESM(require("zod/v4"));
4204
+ var _ = __toESM(require("lodash"));
4205
+ function getOrThrow(x, message) {
4206
+ if (x === void 0 || x === null) {
4207
+ throw new Error(message);
4208
+ }
4209
+ return x;
4210
+ }
4211
+ function joinValues(values, separator = " ") {
4212
+ return values.filter((value) => !!value).join(separator).trim();
4213
+ }
4214
+ var FullNameV1 = z31.array(
4215
+ z31.object({
4216
+ use: z31.string(),
4217
+ family: z31.string(),
4218
+ given: z31.array(z31.string())
4219
+ })
4220
+ );
4221
+ function omitKeyDeep(obj, keyToRemove) {
4222
+ if (Array.isArray(obj)) {
4223
+ return obj.map((item) => omitKeyDeep(item, keyToRemove));
4224
+ }
4225
+ if (obj === null || typeof obj !== "object") {
4226
+ return obj;
4227
+ }
4228
+ const newObj = {};
4229
+ for (const key of Object.keys(obj)) {
4230
+ if (key !== keyToRemove) {
4231
+ newObj[key] = omitKeyDeep(obj[key], keyToRemove);
4232
+ }
4233
+ }
4234
+ return newObj;
4235
+ }
4236
+
4151
4237
  // ../commons/src/events/utils.ts
4152
4238
  var import_lodash4 = require("lodash");
4153
4239
 
@@ -4158,15 +4244,15 @@ var z34 = __toESM(require("zod/v4"));
4158
4244
  var import_date_fns2 = require("date-fns");
4159
4245
 
4160
4246
  // ../commons/src/events/FieldTypeMapping.ts
4161
- var z32 = __toESM(require("zod/v4"));
4247
+ var z33 = __toESM(require("zod/v4"));
4162
4248
 
4163
4249
  // ../commons/src/events/DynamicFieldValue.ts
4164
- var z31 = __toESM(require("zod/v4"));
4250
+ var z32 = __toESM(require("zod/v4"));
4165
4251
  function getDynamicNameValue(field3) {
4166
4252
  const nameConfiguration = field3.configuration?.name;
4167
4253
  const firstnameRequired = nameConfiguration?.firstname?.required ?? field3.required;
4168
4254
  const surnameRequired = nameConfiguration?.surname?.required ?? field3.required;
4169
- return z31.object({
4255
+ return z32.object({
4170
4256
  firstname: firstnameRequired ? NonEmptyTextValue : TextValue,
4171
4257
  surname: surnameRequired ? NonEmptyTextValue : TextValue,
4172
4258
  middlename: nameConfiguration?.middlename?.required ? NonEmptyTextValue : TextValue.optional()
@@ -4197,7 +4283,7 @@ function mapFieldTypeToZod(field3, actionType) {
4197
4283
  let schema;
4198
4284
  switch (field3.type) {
4199
4285
  case FieldType.FIELD_GROUP: {
4200
- schema = z32.object(
4286
+ schema = z33.object(
4201
4287
  field3.fields.reduce((acc, subfield) => {
4202
4288
  acc[subfield.id] = mapFieldTypeToZod(subfield, actionType);
4203
4289
  return acc;
@@ -4521,41 +4607,6 @@ var isNonInteractiveFieldType = (field3) => {
4521
4607
  // ../commons/src/events/state/index.ts
4522
4608
  var import_lodash3 = require("lodash");
4523
4609
 
4524
- // ../commons/src/utils.ts
4525
- var z33 = __toESM(require("zod/v4"));
4526
- var _ = __toESM(require("lodash"));
4527
- function getOrThrow(x, message) {
4528
- if (x === void 0 || x === null) {
4529
- throw new Error(message);
4530
- }
4531
- return x;
4532
- }
4533
- function joinValues(values, separator = " ") {
4534
- return values.filter((value) => !!value).join(separator).trim();
4535
- }
4536
- var FullNameV1 = z33.array(
4537
- z33.object({
4538
- use: z33.string(),
4539
- family: z33.string(),
4540
- given: z33.array(z33.string())
4541
- })
4542
- );
4543
- function omitKeyDeep(obj, keyToRemove) {
4544
- if (Array.isArray(obj)) {
4545
- return obj.map((item) => omitKeyDeep(item, keyToRemove));
4546
- }
4547
- if (obj === null || typeof obj !== "object") {
4548
- return obj;
4549
- }
4550
- const newObj = {};
4551
- for (const key of Object.keys(obj)) {
4552
- if (key !== keyToRemove) {
4553
- newObj[key] = omitKeyDeep(obj[key], keyToRemove);
4554
- }
4555
- }
4556
- return newObj;
4557
- }
4558
-
4559
4610
  // ../commons/src/events/state/utils.ts
4560
4611
  var import_lodash = require("lodash");
4561
4612
  function getActionRequests(actionType, actions) {
@@ -5642,6 +5693,7 @@ function getCurrentEventState(event2, config) {
5642
5693
  updatedAtLocation: requestActionMetadata.createdAtLocation,
5643
5694
  declaration,
5644
5695
  trackingId: event2.trackingId,
5696
+ configVersionId: event2.configVersionId,
5645
5697
  updatedByUserRole: requestActionMetadata.createdByRole,
5646
5698
  placeOfEvent: resolvePlaceOfEvent(
5647
5699
  { createdAtLocation: creationAction.createdAtLocation },
@@ -5800,7 +5852,9 @@ function buildClientFunctionContext(input) {
5800
5852
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
5801
5853
  $online: isOnline(),
5802
5854
  $user: input.validatorContext?.user,
5803
- $event: input.validatorContext?.event?.document,
5855
+ $event: input.validatorContext?.event?.document ? getEventWithCompleteAcceptedActions(
5856
+ input.validatorContext.event.document
5857
+ ) : void 0,
5804
5858
  $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
5805
5859
  user: input.systemVariables?.user,
5806
5860
  $window: input.systemVariables?.$window,
@@ -6321,14 +6375,25 @@ function getDeclarationPages(configuration) {
6321
6375
  function getDeclarationFields(configuration) {
6322
6376
  return getDeclarationPages(configuration).flatMap(({ fields }) => fields);
6323
6377
  }
6324
- function getConfiguredNotificationForm(configuration) {
6378
+ function getDeclarationFieldsOfAllVersions(config) {
6379
+ const oldestFirst = [...config.versions].sort(byEffectiveFrom);
6380
+ const fieldsById = new Map(
6381
+ oldestFirst.flatMap(
6382
+ (version) => getDeclarationFields(toEventConfig(config, version)).map(
6383
+ (field3) => [field3.id, field3]
6384
+ )
6385
+ )
6386
+ );
6387
+ return [...fieldsById.values()];
6388
+ }
6389
+ function findNotificationForm(configuration) {
6325
6390
  const notifyAction = configuration.actions.find(
6326
6391
  (action) => action.type === ActionType.NOTIFY
6327
6392
  );
6328
6393
  return notifyAction?.type === ActionType.NOTIFY ? notifyAction.notificationForm : void 0;
6329
6394
  }
6330
6395
  function getNotificationForm(configuration) {
6331
- const notificationForm = getConfiguredNotificationForm(configuration);
6396
+ const notificationForm = findNotificationForm(configuration);
6332
6397
  if (!notificationForm) {
6333
6398
  throw new Error(
6334
6399
  `Event '${configuration.id}' has no ${ActionType.NOTIFY} action.`
@@ -6604,9 +6669,7 @@ function isWriteAction(actionType) {
6604
6669
  var findAllFields = (config) => {
6605
6670
  return (0, import_lodash4.flattenDeep)([
6606
6671
  ...getDeclarationFields(config),
6607
- ...getConfiguredNotificationForm(config)?.pages.flatMap(
6608
- ({ fields }) => fields
6609
- ) ?? [],
6672
+ ...findNotificationForm(config)?.pages.flatMap(({ fields }) => fields) ?? [],
6610
6673
  ...getAllAnnotationFields(config)
6611
6674
  ]);
6612
6675
  };
@@ -6629,10 +6692,10 @@ function getMixedPath(obj, path, defaultValue) {
6629
6692
  return (0, import_lodash4.isNil)(result) ? defaultValue : result;
6630
6693
  }
6631
6694
  function getEventConfigById(eventConfigs, id) {
6632
- const eventConfig = eventConfigs.find(
6633
- (eventConfiguration) => eventConfiguration.id === id
6695
+ return getOrThrow(
6696
+ eventConfigs.find((eventConfiguration) => eventConfiguration.id === id),
6697
+ `No configuration found for event type: ${id}`
6634
6698
  );
6635
- return getOrThrow(eventConfig, `Event config for ${id} not found`);
6636
6699
  }
6637
6700
  function timePeriodToDateRange(value) {
6638
6701
  let startDate;
@@ -6742,12 +6805,41 @@ function getCompleteActionDeclaration(declaration, event2, action) {
6742
6805
  }
6743
6806
  return deepMerge(declaration, action.declaration);
6744
6807
  }
6745
- function getAcceptedActions(event2) {
6746
- return event2.actions.filter(isAcceptedAction).map((action) => ({
6808
+ function completeAcceptedAction(event2, action) {
6809
+ return {
6747
6810
  ...action,
6748
6811
  declaration: getCompleteActionDeclaration({}, event2, action),
6749
6812
  annotation: getCompleteActionAnnotation(event2, action)
6750
- }));
6813
+ };
6814
+ }
6815
+ function getAcceptedActions(event2) {
6816
+ return event2.actions.filter(isAcceptedAction).map((action) => completeAcceptedAction(event2, action));
6817
+ }
6818
+ function getEventWithCompleteAcceptedActions(event2) {
6819
+ return {
6820
+ ...event2,
6821
+ actions: event2.actions.map((action) => {
6822
+ if (!isAcceptedAction(action) || !action.originalActionId) {
6823
+ return action;
6824
+ }
6825
+ const requestedAction = event2.actions.find(
6826
+ ({ id }) => id === action.originalActionId
6827
+ );
6828
+ if (requestedAction?.status !== ActionStatus.Requested) {
6829
+ return action;
6830
+ }
6831
+ const content = getCompleteActionContent(event2, action);
6832
+ return {
6833
+ ...completeAcceptedAction(event2, action),
6834
+ // Who requested the action, as getActionUpdateMetadata resolves it.
6835
+ createdBy: requestedAction.createdBy,
6836
+ createdByRole: requestedAction.createdByRole,
6837
+ createdByUserType: requestedAction.createdByUserType,
6838
+ createdAtLocation: requestedAction.createdAtLocation,
6839
+ ...content ? { content } : {}
6840
+ };
6841
+ })
6842
+ };
6751
6843
  }
6752
6844
  var EXCLUDED_ACTIONS = [
6753
6845
  ActionType.REQUEST_CORRECTION,
@@ -6846,6 +6938,20 @@ function dropSecuredDeclarationFields(eventConfig, eventIndex, validatorContext)
6846
6938
  }
6847
6939
 
6848
6940
  // ../commons/src/events/eventConfigValidation.ts
6941
+ var SEARCH_DEFAULT_VALUE_FIELD_TYPES = [
6942
+ FieldType.TEXT,
6943
+ FieldType.TEXTAREA,
6944
+ FieldType.EMAIL,
6945
+ FieldType.PHONE,
6946
+ FieldType.ID,
6947
+ FieldType.SELECT,
6948
+ FieldType.RADIO_GROUP,
6949
+ FieldType.COUNTRY,
6950
+ FieldType.LOCATION,
6951
+ FieldType.ADMINISTRATIVE_AREA,
6952
+ FieldType.NUMBER,
6953
+ FieldType.DATE
6954
+ ];
6849
6955
  function validateAdvancedSearchConfig(event2, ctx) {
6850
6956
  const allFields = findAllFields(event2);
6851
6957
  const fieldIds = allFields.map((field3) => field3.id);
@@ -6877,6 +6983,56 @@ function validateAdvancedSearchConfig(event2, ctx) {
6877
6983
  path: ["advancedSearch"]
6878
6984
  });
6879
6985
  }
6986
+ event2.advancedSearch.forEach((section, sectionIndex) => {
6987
+ section.fields.forEach((searchField, fieldIndex) => {
6988
+ if (searchField.fieldType !== "field" || searchField.defaultValue === void 0) {
6989
+ return;
6990
+ }
6991
+ const path = [
6992
+ "advancedSearch",
6993
+ sectionIndex,
6994
+ "fields",
6995
+ fieldIndex,
6996
+ "defaultValue"
6997
+ ];
6998
+ if (searchField.config.searchFields && searchField.config.searchFields.length > 0) {
6999
+ ctx.addIssue({
7000
+ code: "custom",
7001
+ message: `Advanced search field ${searchField.fieldId} searches across several form fields, so it does not support a defaultValue.`,
7002
+ path
7003
+ });
7004
+ return;
7005
+ }
7006
+ if (typeof searchField.defaultValue === "boolean") {
7007
+ return;
7008
+ }
7009
+ const formField = allFields.find(({ id }) => id === searchField.fieldId);
7010
+ if (!formField) {
7011
+ return;
7012
+ }
7013
+ if (!SEARCH_DEFAULT_VALUE_FIELD_TYPES.some(
7014
+ (type) => type === formField.type
7015
+ )) {
7016
+ ctx.addIssue({
7017
+ code: "custom",
7018
+ message: `Advanced search field ${searchField.fieldId} is a ${formField.type} field, which does not support a defaultValue value, only true or false. Field types that support a defaultValue value: ${SEARCH_DEFAULT_VALUE_FIELD_TYPES.join(", ")}.`,
7019
+ path
7020
+ });
7021
+ } else if (formField.type === FieldType.DATE && searchField.config.type === "range") {
7022
+ ctx.addIssue({
7023
+ code: "custom",
7024
+ message: `Advanced search field ${searchField.fieldId} is searched as a date range, so its defaultValue can only be true or false.`,
7025
+ path
7026
+ });
7027
+ } else if (!mapFieldTypeToZod(formField).safeParse(searchField.defaultValue).success) {
7028
+ ctx.addIssue({
7029
+ code: "custom",
7030
+ message: `Advanced search field ${searchField.fieldId} has defaultValue "${searchField.defaultValue}", which is not a valid ${formField.type} value.`,
7031
+ path
7032
+ });
7033
+ }
7034
+ });
7035
+ });
6880
7036
  }
6881
7037
  function validateDateOfEvent(event2, ctx) {
6882
7038
  if (event2.dateOfEvent && isFieldReference(event2.dateOfEvent)) {
@@ -7049,10 +7205,16 @@ function validateNotificationForm(event2, ctx) {
7049
7205
  var EventFieldReference = z35.object({ $$event: EventMetadataDateFieldIdInput }).describe(
7050
7206
  "Reference to a field defined in the event metadata, using the field id."
7051
7207
  );
7052
- var _EventConfigBase = z35.object({
7208
+ var eventLevelFields = {
7053
7209
  id: z35.string().describe(
7054
7210
  'Machine-readable identifier of the event (e.g. "birth", "death").'
7055
7211
  ),
7212
+ label: TranslationConfig.describe("Human-readable label for the event type."),
7213
+ advancedSearch: z35.array(AdvancedSearchConfig).optional().default([]).describe(
7214
+ "Configuration of fields available in the advanced search feature."
7215
+ )
7216
+ };
7217
+ var versionFields = {
7056
7218
  dateOfEvent: FieldReference.or(EventFieldReference).optional().describe(
7057
7219
  "Reference to the field capturing the date of the event (e.g. date of birth). Defaults to the event creation date if unspecified."
7058
7220
  ),
@@ -7068,18 +7230,12 @@ var _EventConfigBase = z35.object({
7068
7230
  summary: SummaryConfig.describe(
7069
7231
  "Summary information displayed in the event overview."
7070
7232
  ),
7071
- label: TranslationConfig.describe(
7072
- "Human-readable label for the event type."
7073
- ),
7074
7233
  actions: z35.array(ActionConfig).describe(
7075
7234
  "Configuration of core and custom actions associated with the event."
7076
7235
  ),
7077
7236
  actionOrder: z35.array(z35.string()).optional().describe(
7078
7237
  "Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
7079
7238
  ),
7080
- advancedSearch: z35.array(AdvancedSearchConfig).optional().default([]).describe(
7081
- "Configuration of fields available in the advanced search feature."
7082
- ),
7083
7239
  flags: z35.array(FlagConfig).optional().default([]).describe(
7084
7240
  "Configuration of custom flags associated with the actions of this event type."
7085
7241
  ),
@@ -7089,8 +7245,9 @@ var _EventConfigBase = z35.object({
7089
7245
  icon: z35.partialRecord(AvailableIcons, Conditional).optional().describe(
7090
7246
  '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.'
7091
7247
  )
7092
- });
7093
- var EventConfig = _EventConfigBase.superRefine((event2, ctx) => {
7248
+ };
7249
+ var _EventConfigBase = z35.object({ ...eventLevelFields, ...versionFields });
7250
+ function validateEventConfig(event2, ctx) {
7094
7251
  if (!validateExactlyOneDeclareAction(event2, ctx)) {
7095
7252
  return;
7096
7253
  }
@@ -7100,10 +7257,168 @@ var EventConfig = _EventConfigBase.superRefine((event2, ctx) => {
7100
7257
  validatePlaceOfEvent(event2, ctx);
7101
7258
  validateActionFlags(event2, ctx);
7102
7259
  validateActionOrder(event2, ctx);
7103
- }).meta({
7260
+ }
7261
+ var EventConfig2 = _EventConfigBase.superRefine(validateEventConfig).meta({
7104
7262
  id: "EventConfig",
7105
7263
  description: "Configuration defining an event type registered in OpenCRVS (for example birth or death)."
7106
7264
  });
7265
+ var INITIAL_EVENT_CONFIG_VERSION_ID = "initial";
7266
+ var DEFAULT_EFFECTIVE_FROM = "0001-01-01";
7267
+ var _EventConfigVersion = z35.object({
7268
+ id: z35.string().describe(
7269
+ 'Identifier of the version, unique within the event (e.g. "birth-v2").'
7270
+ ),
7271
+ label: TranslationConfig.describe(
7272
+ 'Name of the version, which the UI shows wherever it names the version. For example, "{event.configVersionLabel}" in the event summary.'
7273
+ ),
7274
+ effectiveFrom: z35.iso.date().default(DEFAULT_EFFECTIVE_FROM).describe(
7275
+ `Date (YYYY-MM-DD) from which this version is effective. A version without one is effective from the beginning of time ('${DEFAULT_EFFECTIVE_FROM}').`
7276
+ ),
7277
+ ...versionFields
7278
+ });
7279
+ var resolvedConfigs = /* @__PURE__ */ new WeakMap();
7280
+ function toEventConfig(config, version) {
7281
+ let resolvedVersions = resolvedConfigs.get(config);
7282
+ if (!resolvedVersions) {
7283
+ resolvedVersions = /* @__PURE__ */ new WeakMap();
7284
+ resolvedConfigs.set(config, resolvedVersions);
7285
+ }
7286
+ const cached = resolvedVersions.get(version);
7287
+ if (cached) {
7288
+ return cached;
7289
+ }
7290
+ const {
7291
+ id: _id,
7292
+ label: _label,
7293
+ effectiveFrom: _effectiveFrom,
7294
+ ...fields
7295
+ } = version;
7296
+ const resolved = {
7297
+ ...fields,
7298
+ id: config.id,
7299
+ label: config.label,
7300
+ advancedSearch: config.advancedSearch
7301
+ };
7302
+ resolvedVersions.set(version, resolved);
7303
+ return resolved;
7304
+ }
7305
+ function findConfigVersion(config, versionId) {
7306
+ return config.versions.find(({ id }) => id === versionId);
7307
+ }
7308
+ function getConfigVersion(config, versionId) {
7309
+ return getOrThrow(
7310
+ findConfigVersion(config, versionId),
7311
+ `Event '${config.id}' has no version '${versionId}'`
7312
+ );
7313
+ }
7314
+ function getEventConfigOfVersion(config, versionId) {
7315
+ return toEventConfig(config, getConfigVersion(config, versionId));
7316
+ }
7317
+ function byEffectiveFrom(a, b) {
7318
+ return a.effectiveFrom.localeCompare(b.effectiveFrom);
7319
+ }
7320
+ function getVersionsInEffectOn(config, date) {
7321
+ return config.versions.filter(({ effectiveFrom }) => effectiveFrom <= date).sort(byEffectiveFrom);
7322
+ }
7323
+ function findVersionInEffectOn(config, date) {
7324
+ return getVersionsInEffectOn(config, date).at(-1);
7325
+ }
7326
+ function getVersionsInEffect(config, now2, timeZone) {
7327
+ return getVersionsInEffectOn(config, toPlainDateInTimeZone(now2, timeZone));
7328
+ }
7329
+ function resolveEffectiveVersion(config, now2, timeZone) {
7330
+ return findVersionInEffectOn(config, toPlainDateInTimeZone(now2, timeZone));
7331
+ }
7332
+ function findEventConfigForRecord(config, record8) {
7333
+ const version = findConfigVersion(config, record8.configVersionId);
7334
+ return version && toEventConfig(config, version);
7335
+ }
7336
+ function getEventConfigForRecord(config, record8) {
7337
+ return getEventConfigOfVersion(config, record8.configVersionId);
7338
+ }
7339
+ function resolveEventConfigOnDate(config, date) {
7340
+ return toEventConfig(
7341
+ config,
7342
+ getOrThrow(
7343
+ findVersionInEffectOn(config, date),
7344
+ `Event '${config.id}' has no version in effect on ${date}`
7345
+ )
7346
+ );
7347
+ }
7348
+ function resolveEventConfigInTimeZone(config, timeZone, now2 = /* @__PURE__ */ new Date()) {
7349
+ return resolveEventConfigOnDate(config, toPlainDateInTimeZone(now2, timeZone));
7350
+ }
7351
+ function resolveEventConfig(config) {
7352
+ return resolveEventConfigInTimeZone(config, "UTC");
7353
+ }
7354
+ function validateVersionList(config, ctx) {
7355
+ const ids = /* @__PURE__ */ new Set();
7356
+ const versionIdByEffectiveFrom = /* @__PURE__ */ new Map();
7357
+ config.versions.forEach((version, index) => {
7358
+ if (ids.has(version.id)) {
7359
+ ctx.addIssue({
7360
+ code: "custom",
7361
+ message: `Event '${config.id}' has more than one version with id '${version.id}'. Each version must have a different id.`,
7362
+ path: ["versions", index, "id"]
7363
+ });
7364
+ }
7365
+ ids.add(version.id);
7366
+ const sameEffectiveFromId = versionIdByEffectiveFrom.get(
7367
+ version.effectiveFrom
7368
+ );
7369
+ if (sameEffectiveFromId !== void 0) {
7370
+ const versionIds = `'${sameEffectiveFromId}', '${version.id}'`;
7371
+ ctx.addIssue({
7372
+ code: "custom",
7373
+ message: version.effectiveFrom !== DEFAULT_EFFECTIVE_FROM ? `Event '${config.id}' has more than one version with \`effectiveFrom\` '${version.effectiveFrom}' (${versionIds}). Each version must have a different \`effectiveFrom\`.` : `Event '${config.id}' has more than one version without \`effectiveFrom\` (${versionIds}). At most one version may omit it.`,
7374
+ path: ["versions", index, "effectiveFrom"]
7375
+ });
7376
+ } else {
7377
+ versionIdByEffectiveFrom.set(version.effectiveFrom, version.id);
7378
+ }
7379
+ });
7380
+ }
7381
+ function validateEachVersion(ctx, events, validate2) {
7382
+ const reported = /* @__PURE__ */ new Set();
7383
+ events.forEach((event2, index) => {
7384
+ const addIssue = (issue) => {
7385
+ if (typeof issue === "string") {
7386
+ ctx.addIssue({
7387
+ code: "custom",
7388
+ message: issue,
7389
+ path: ["versions", index]
7390
+ });
7391
+ return;
7392
+ }
7393
+ const [field3] = issue.path ?? [];
7394
+ const isEventLevel = typeof field3 === "string" && field3 in eventLevelFields;
7395
+ const path = isEventLevel ? issue.path ?? [] : ["versions", index, ...issue.path ?? []];
7396
+ const key = JSON.stringify([path, issue.message]);
7397
+ if (reported.has(key)) {
7398
+ return;
7399
+ }
7400
+ reported.add(key);
7401
+ ctx.addIssue({ ...issue, path });
7402
+ };
7403
+ validate2(event2, { value: event2, addIssue });
7404
+ });
7405
+ }
7406
+ var VersionedEventConfig2 = z35.object({
7407
+ ...eventLevelFields,
7408
+ versions: z35.array(_EventConfigVersion).min(1).describe(
7409
+ `Versions of the event configuration, each effective from its \`effectiveFrom\`. An event configured without versions has a single version, with id '${INITIAL_EVENT_CONFIG_VERSION_ID}' and \`effectiveFrom\` '${DEFAULT_EFFECTIVE_FROM}'.`
7410
+ )
7411
+ }).superRefine((config, ctx) => {
7412
+ validateVersionList(config, ctx);
7413
+ validateEachVersion(
7414
+ ctx,
7415
+ config.versions.map((version) => toEventConfig(config, version)),
7416
+ validateEventConfig
7417
+ );
7418
+ }).meta({
7419
+ id: "VersionedEventConfig",
7420
+ description: "Configuration of an event type registered in OpenCRVS (for example birth or death), with every version of it."
7421
+ });
7107
7422
 
7108
7423
  // ../commons/src/events/EventConfigInput.ts
7109
7424
  var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
@@ -7203,7 +7518,10 @@ function eventFn(fieldId) {
7203
7518
  }
7204
7519
  var event = Object.assign(eventFn, {
7205
7520
  /**
7206
- * Checks if the event contains a specific action type.
7521
+ * Checks if the event contains a specific accepted action type.
7522
+ * Only Accepted actions are matched: a confirmable action is stored as a
7523
+ * Requested and an Accepted action, and a pending or rejected request must
7524
+ * not count as the action having happened.
7207
7525
  * Can be used directly as a conditional or chained with additional methods.
7208
7526
  * @param action - The action type to check for.
7209
7527
  */
@@ -7221,9 +7539,12 @@ var event = Object.assign(eventFn, {
7221
7539
  properties: {
7222
7540
  type: {
7223
7541
  const: action
7542
+ },
7543
+ status: {
7544
+ const: ActionStatus.Accepted
7224
7545
  }
7225
7546
  },
7226
- required: ["type"]
7547
+ required: ["type", "status"]
7227
7548
  }
7228
7549
  }
7229
7550
  },
@@ -7234,9 +7555,10 @@ var event = Object.assign(eventFn, {
7234
7555
  });
7235
7556
  const buildActionConstraints = (additionalFields) => {
7236
7557
  const actionProperties = {
7237
- type: { const: action }
7558
+ type: { const: action },
7559
+ status: { const: ActionStatus.Accepted }
7238
7560
  };
7239
- const requiredFields = ["type"];
7561
+ const requiredFields = ["type", "status"];
7240
7562
  if (additionalFields) {
7241
7563
  Object.entries(additionalFields).forEach(([key, value]) => {
7242
7564
  actionProperties[key] = { const: value };
@@ -7717,17 +8039,19 @@ var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
7717
8039
  /*
7718
8040
  * A draft can name a file that no action references. Such a file stays until
7719
8041
  * the record is deleted or the record's next action sweeps its prefix.
7720
- * DECLARE is available only where one of those is still coming: a created
7721
- * record, which can still be deleted, and a record part way through an edit,
7722
- * which is about to be declared or registered.
8042
+ * Drafts are therefore saved only on a created record, which can still be deleted.
8043
+ * The server refuses them on any other record.
7723
8044
  */
7724
- type: z40.literal(ActionTypes.enum.DECLARE),
8045
+ type: z40.enum([ActionTypes.enum.DECLARE, ActionTypes.enum.NOTIFY]),
7725
8046
  status: z40.enum([
7726
8047
  ActionStatus.Requested,
7727
8048
  ActionStatus.Accepted,
7728
8049
  ActionStatus.Rejected
7729
8050
  ])
7730
8051
  });
8052
+ var RemoteDraft = Draft.extend({
8053
+ action: Draft.shape.action.extend({ type: DraftInput.shape.type })
8054
+ });
7731
8055
 
7732
8056
  // ../commons/src/events/EventInput.ts
7733
8057
  var z41 = __toESM(require("zod/v4"));
@@ -7737,6 +8061,9 @@ var EventInput = z41.object({
7737
8061
  type: z41.string(),
7738
8062
  createdAtLocation: UUID.nullish().describe(
7739
8063
  "Location where the event occurred. Required for system users."
8064
+ ),
8065
+ configVersionId: z41.string().optional().describe(
8066
+ "Id of the event configuration version the client created the record under, e.g. while offline. Must be configured and not take effect in the future. Defaults to the version in effect when the server receives the record."
7740
8067
  )
7741
8068
  }).meta({ default: { transactionId: (0, import_uuid11.v4)(), type: "birth" } });
7742
8069
 
@@ -7752,6 +8079,9 @@ var EventDocument = z42.object({
7752
8079
  actions: z42.array(Action).describe("Ordered list of actions associated with the event."),
7753
8080
  trackingId: z42.string().describe(
7754
8081
  "System-generated tracking identifier used to look up the event."
8082
+ ),
8083
+ configVersionId: z42.string().describe(
8084
+ "Id of the event configuration version the record was created under. Every action on the record uses that version. Records created before versioning have 'initial'."
7755
8085
  )
7756
8086
  }).meta({ id: "EventDocument" });
7757
8087
  var EventDocumentOnlyLastAction = EventDocument.extend({
@@ -7771,16 +8101,69 @@ function moveDeclarationToDeclareAction({
7771
8101
  }
7772
8102
  return {
7773
8103
  ...config,
7774
- actions: config.actions.map(
7775
- (action) => action.type === ActionType.DECLARE && declaration ? { ...action, declaration } : action
7776
- )
8104
+ actions: config.actions.map((action) => {
8105
+ if (action.type !== ActionType.DECLARE) {
8106
+ return action;
8107
+ }
8108
+ const declarationOfAction = action.declaration ?? declaration;
8109
+ if (!declarationOfAction) {
8110
+ throw new Error(`Event '${config.id}' does not define \`declaration\`.`);
8111
+ }
8112
+ return { ...action, declaration: declarationOfAction };
8113
+ })
8114
+ };
8115
+ }
8116
+ var VERSIONED_EVENT_FIELDS = [
8117
+ "id",
8118
+ "label",
8119
+ "advancedSearch",
8120
+ "versions"
8121
+ ];
8122
+ function validateNoVersionFieldsAtTopLevel(config, ctx) {
8123
+ Object.keys(config).filter((key) => !VERSIONED_EVENT_FIELDS.includes(key)).forEach((key) => {
8124
+ ctx.addIssue({
8125
+ code: "custom",
8126
+ message: `Event '${config.id}' defines \`versions\`, so \`${key}\` must be defined on each version, not at the top level.`,
8127
+ path: [key]
8128
+ });
8129
+ });
8130
+ }
8131
+ function toVersionedInput(config) {
8132
+ if ("versions" in config) {
8133
+ return config;
8134
+ }
8135
+ const { id, label, advancedSearch, ...version } = moveDeclarationToDeclareAction(config);
8136
+ return {
8137
+ id,
8138
+ label,
8139
+ advancedSearch,
8140
+ versions: [{ ...version, id: INITIAL_EVENT_CONFIG_VERSION_ID, label }]
7777
8141
  };
7778
8142
  }
8143
+ var WESTERNMOST_TIME_ZONE = "Etc/GMT+12";
8144
+ function validateVersionInEffectToday(config, ctx) {
8145
+ const today = toPlainDateInTimeZone(/* @__PURE__ */ new Date(), WESTERNMOST_TIME_ZONE);
8146
+ const isAnyVersionInEffect = config.versions.some(
8147
+ ({ effectiveFrom }) => effectiveFrom <= today
8148
+ );
8149
+ if (!isAnyVersionInEffect) {
8150
+ ctx.addIssue({
8151
+ code: "custom",
8152
+ message: `Event '${config.id}' has no version in effect today (${today}, UTC\u221212, the last time zone to begin the day). At least one version must omit \`effectiveFrom\` or take effect on or before that date.`,
8153
+ path: ["versions"]
8154
+ });
8155
+ }
8156
+ }
7779
8157
  var EventConfigDefinition = z43.custom().superRefine((config, ctx) => {
7780
- if (validateExactlyOneDeclareAction(config, ctx)) {
7781
- validateDeclarationGivenExactlyOnce(config, ctx);
8158
+ if ("versions" in config) {
8159
+ validateNoVersionFieldsAtTopLevel(config, ctx);
8160
+ return;
7782
8161
  }
7783
- }).transform(moveDeclarationToDeclareAction).pipe(EventConfig);
8162
+ const eventCtx = { ...ctx, value: config };
8163
+ if (validateExactlyOneDeclareAction(config, eventCtx)) {
8164
+ validateDeclarationGivenExactlyOnce(config, eventCtx);
8165
+ }
8166
+ }).transform(toVersionedInput).pipe(VersionedEventConfig2).superRefine(validateVersionInEffectToday);
7784
8167
  var defineConfig = (config) => EventConfigDefinition.parse(config);
7785
8168
 
7786
8169
  // ../commons/src/events/toNotificationForm.ts
@@ -9071,7 +9454,7 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
9071
9454
  });
9072
9455
 
9073
9456
  // ../commons/src/fixtures/tennis-club-membership-event.ts
9074
- var tennisClubMembershipEvent = defineConfig({
9457
+ var versionedTennisClubMembershipEvent = defineConfig({
9075
9458
  id: TENNIS_CLUB_MEMBERSHIP,
9076
9459
  declaration: TENNIS_CLUB_DECLARATION_FORM,
9077
9460
  label: {
@@ -9428,9 +9811,12 @@ var tennisClubMembershipEvent = defineConfig({
9428
9811
  }
9429
9812
  ]
9430
9813
  });
9814
+ var tennisClubMembershipEvent = resolveEventConfig(
9815
+ versionedTennisClubMembershipEvent
9816
+ );
9431
9817
 
9432
9818
  // ../commons/src/fixtures/football-club-membership-event.ts
9433
- var footballClubMembershipEvent = defineConfig({
9819
+ var versionedFootballClubMembershipEvent = defineConfig({
9434
9820
  id: "FOOTBALL_CLUB_MEMBERSHIP",
9435
9821
  label: {
9436
9822
  defaultMessage: "Football club membership application",
@@ -9753,6 +10139,9 @@ var footballClubMembershipEvent = defineConfig({
9753
10139
  ],
9754
10140
  declaration: TENNIS_CLUB_DECLARATION_FORM
9755
10141
  });
10142
+ var footballClubMembershipEvent = resolveEventConfig(
10143
+ versionedFootballClubMembershipEvent
10144
+ );
9756
10145
 
9757
10146
  // ../commons/src/fixtures/library-membership-event.ts
9758
10147
  var libraryMembershipForm = defineDeclarationForm({
@@ -9796,7 +10185,7 @@ var libraryMembershipForm = defineDeclarationForm({
9796
10185
  }
9797
10186
  ]
9798
10187
  });
9799
- var libraryMembershipEvent = defineConfig({
10188
+ var versionedLibraryMembershipEvent = defineConfig({
9800
10189
  id: "library-membership",
9801
10190
  label: {
9802
10191
  defaultMessage: "Library membership application",
@@ -9829,6 +10218,9 @@ var libraryMembershipEvent = defineConfig({
9829
10218
  ],
9830
10219
  declaration: libraryMembershipForm
9831
10220
  });
10221
+ var libraryMembershipEvent = resolveEventConfig(
10222
+ versionedLibraryMembershipEvent
10223
+ );
9832
10224
 
9833
10225
  // ../commons/src/fixtures/child-onboarding-event.ts
9834
10226
  function generateTranslationConfig(message) {
@@ -10042,7 +10434,7 @@ var CHILD_ONBOARDING_DECLARATION_FORM = defineDeclarationForm({
10042
10434
  label: generateTranslationConfig("Birth decalration form"),
10043
10435
  pages: [child, mother]
10044
10436
  });
10045
- var ChildOnboardingEvent = defineConfig({
10437
+ var versionedChildOnboardingEvent = defineConfig({
10046
10438
  id: CHILD_ONBOARDING_EVENT,
10047
10439
  title: generateTranslationConfig(
10048
10440
  "{child.name.firstname} {child.name.surname}"
@@ -10070,6 +10462,9 @@ var ChildOnboardingEvent = defineConfig({
10070
10462
  ],
10071
10463
  advancedSearch: []
10072
10464
  });
10465
+ var ChildOnboardingEvent = resolveEventConfig(
10466
+ versionedChildOnboardingEvent
10467
+ );
10073
10468
 
10074
10469
  // ../commons/src/fixtures/digital-identity-issuance-event.ts
10075
10470
  var PRINT_DIGITAL_ID_CERTIFICATE_FORM = defineActionForm({
@@ -10258,7 +10653,7 @@ var digitalIdentityForm = defineDeclarationForm({
10258
10653
  }
10259
10654
  ]
10260
10655
  });
10261
- var digitalIdentityEvent = defineConfig({
10656
+ var versionedDigitalIdentityEvent = defineConfig({
10262
10657
  id: "digital-identity",
10263
10658
  label: {
10264
10659
  defaultMessage: "Digital identity issuance",
@@ -10300,6 +10695,9 @@ var digitalIdentityEvent = defineConfig({
10300
10695
  ],
10301
10696
  declaration: digitalIdentityForm
10302
10697
  });
10698
+ var digitalIdentityEvent = resolveEventConfig(
10699
+ versionedDigitalIdentityEvent
10700
+ );
10303
10701
 
10304
10702
  // ../commons/src/events/test.utils.ts
10305
10703
  var z45 = __toESM(require("zod/v4"));
@@ -11328,7 +11726,8 @@ function eventPayloadGenerator(rng, configuration = tennisClubMembershipEvent) {
11328
11726
  ...input
11329
11727
  }),
11330
11728
  /**
11331
- * Notify allows sending incomplete data. Think it as 'partial declare' for now.
11729
+ * NOTIFY submits the values of the notification form, and the record can stay incomplete.
11730
+ * When `declaration` is not given, string values are left out of the generated declaration to make it incomplete.
11332
11731
  */
11333
11732
  notify: (eventId, input = {}) => {
11334
11733
  let declaration = input.declaration;
@@ -11583,9 +11982,9 @@ function generateActionDocument({
11583
11982
  return { ...actionBase, type: action };
11584
11983
  case ActionType.EDIT:
11585
11984
  return {
11985
+ content: { comment: "Test comment" },
11586
11986
  ...actionBase,
11587
- type: action,
11588
- content: { comment: "Test comment" }
11987
+ type: action
11589
11988
  };
11590
11989
  case ActionType.CUSTOM:
11591
11990
  return {
@@ -11604,9 +12003,9 @@ function generateActionDocument({
11604
12003
  };
11605
12004
  }
11606
12005
  case ActionType.ARCHIVE:
11607
- return { ...actionBase, type: action, content: { reason: "Archive" } };
12006
+ return { content: { reason: "Archive" }, ...actionBase, type: action };
11608
12007
  case ActionType.REJECT:
11609
- return { ...actionBase, type: action, content: { reason: "Reject" } };
12008
+ return { content: { reason: "Reject" }, ...actionBase, type: action };
11610
12009
  case ActionType.PRINT_CERTIFICATE: {
11611
12010
  const printActionDefaults = defaults;
11612
12011
  return {
@@ -11616,13 +12015,13 @@ function generateActionDocument({
11616
12015
  };
11617
12016
  }
11618
12017
  case ActionType.APPROVE_CORRECTION:
11619
- return { ...actionBase, requestId: getUUID(), type: action };
12018
+ return { requestId: getUUID(), ...actionBase, type: action };
11620
12019
  case ActionType.REJECT_CORRECTION:
11621
12020
  return {
11622
- ...actionBase,
11623
12021
  requestId: getUUID(),
11624
- type: action,
11625
- content: { reason: "Correction rejection" }
12022
+ content: { reason: "Correction rejection" },
12023
+ ...actionBase,
12024
+ type: action
11626
12025
  };
11627
12026
  case ActionType.DUPLICATE_DETECTED: {
11628
12027
  const duplicateActionDefaults = defaults;
@@ -11639,6 +12038,65 @@ function generateActionDocument({
11639
12038
  throw new Error(`Unsupported action type: ${action}`);
11640
12039
  }
11641
12040
  }
12041
+ function isConfirmableAction(type) {
12042
+ return ConfirmableActions.some((confirmable) => confirmable === type);
12043
+ }
12044
+ function generateActionDocuments({
12045
+ confirmation,
12046
+ ...args
12047
+ }) {
12048
+ const actionDocument = generateActionDocument(args);
12049
+ if (!isConfirmableAction(actionDocument.type)) {
12050
+ return [actionDocument];
12051
+ }
12052
+ if (args.defaults?.status !== void 0) {
12053
+ throw new Error(
12054
+ `generateActionDocuments: set the status of ${actionDocument.type} with confirmation.status, not defaults.status`
12055
+ );
12056
+ }
12057
+ const status2 = confirmation?.status ?? ActionStatus.Accepted;
12058
+ if (status2 === ActionStatus.Requested) {
12059
+ if (confirmation?.defaults) {
12060
+ throw new Error(
12061
+ "generateActionDocuments: confirmation.defaults have no confirming action to apply to while the request is pending"
12062
+ );
12063
+ }
12064
+ return [{ ...actionDocument, status: ActionStatus.Requested }];
12065
+ }
12066
+ const requestedAction = {
12067
+ ...actionDocument,
12068
+ id: getUUID(),
12069
+ status: ActionStatus.Requested
12070
+ };
12071
+ const confirmingAction = {
12072
+ ...actionDocument,
12073
+ originalActionId: requestedAction.id,
12074
+ createdAt: new Date(
12075
+ new Date(actionDocument.createdAt).getTime() + 1
12076
+ ).toISOString(),
12077
+ ...confirmation?.defaults
12078
+ };
12079
+ if (status2 === ActionStatus.Rejected) {
12080
+ const { declaration, annotation, ...rejectedAction } = confirmingAction;
12081
+ return [
12082
+ requestedAction,
12083
+ {
12084
+ ...rejectedAction,
12085
+ type: actionDocument.type,
12086
+ status: ActionStatus.Rejected
12087
+ }
12088
+ ];
12089
+ }
12090
+ return [
12091
+ requestedAction,
12092
+ {
12093
+ ...confirmingAction,
12094
+ status: ActionStatus.Accepted,
12095
+ declaration: {},
12096
+ annotation: {}
12097
+ }
12098
+ ];
12099
+ }
11642
12100
  function generateRandomDatetime(rng, start, end) {
11643
12101
  const range = end.getTime() - start.getTime();
11644
12102
  const offset = Math.floor(rng() * range);
@@ -11657,9 +12115,20 @@ function generateEventDocument({
11657
12115
  }) {
11658
12116
  return {
11659
12117
  trackingId: generateTrackingId(rng),
12118
+ configVersionId: INITIAL_EVENT_CONFIG_VERSION_ID,
11660
12119
  type: configuration.id,
11661
- actions: actions.map(
11662
- (action, i) => generateActionDocument({
12120
+ actions: actions.flatMap((action, i) => {
12121
+ const createdAt = (0, import_date_fns4.addDays)(
12122
+ new Date(
12123
+ generateRandomDatetime(
12124
+ rng,
12125
+ new Date(2025, 0, 1),
12126
+ new Date(2025, 11, 31)
12127
+ )
12128
+ ),
12129
+ i
12130
+ );
12131
+ return generateActionDocuments({
11663
12132
  configuration,
11664
12133
  action: action.type,
11665
12134
  defaults: {
@@ -11667,20 +12136,11 @@ function generateEventDocument({
11667
12136
  createdAtLocation: action.user?.primaryOfficeId,
11668
12137
  assignedTo: action.user?.assignedTo,
11669
12138
  createdByRole: action.user?.role,
11670
- createdAt: (0, import_date_fns4.addDays)(
11671
- new Date(
11672
- generateRandomDatetime(
11673
- rng,
11674
- new Date(2025, 0, 1),
11675
- new Date(2025, 11, 31)
11676
- )
11677
- ),
11678
- i
11679
- ).toISOString()
12139
+ createdAt: createdAt.toISOString()
11680
12140
  },
11681
12141
  declarationOverrides: action.declarationOverrides
11682
- })
11683
- ),
12142
+ });
12143
+ }),
11684
12144
  // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
11685
12145
  // @TODO: This should be fixed in the future.
11686
12146
  createdAt: new Date(Date.now() - 1e3).toISOString(),
@@ -11707,6 +12167,7 @@ function generateEventDraftDocument({
11707
12167
  transactionId: getUUID(),
11708
12168
  action: {
11709
12169
  ...action,
12170
+ type: actionType,
11710
12171
  declaration: {
11711
12172
  ...action.declaration,
11712
12173
  ...declaration
@@ -11749,6 +12210,7 @@ var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
11749
12210
  return {
11750
12211
  id: overrides.id ?? generateUuid(rng),
11751
12212
  type: overrides.type ?? TENNIS_CLUB_MEMBERSHIP,
12213
+ configVersionId: overrides.configVersionId ?? INITIAL_EVENT_CONFIG_VERSION_ID,
11752
12214
  status: overrides.status ?? pickRandom(rng, EventStatus.options),
11753
12215
  createdAt: overrides.createdAt ?? createdAt,
11754
12216
  createdByUserType: overrides.createdByUserType ?? "user",
@@ -11794,45 +12256,47 @@ var generateEventConfig = ({
11794
12256
  dateOfEventId,
11795
12257
  actions = []
11796
12258
  }) => {
11797
- return defineConfig({
11798
- id,
11799
- label: generateTranslationConfig2(id),
11800
- title: generateTranslationConfig2(`${id} Event`),
11801
- summary: {
11802
- fields: []
11803
- },
11804
- placeOfEvent: placeOfEventId ? { $$field: placeOfEventId } : void 0,
11805
- dateOfEvent: dateOfEventId ? { $$field: dateOfEventId } : void 0,
11806
- declaration: {
11807
- label: generateTranslationConfig2(`${id} Declaration`),
11808
- pages: [
11809
- {
11810
- id: "page1",
11811
- title: generateTranslationConfig2("Page 1"),
11812
- fields
11813
- }
11814
- ]
11815
- },
11816
- actions: [
11817
- {
11818
- type: ActionType.READ,
11819
- label: generateTranslationConfig2("Read"),
11820
- review: {
11821
- title: generateTranslationConfig2("Review Read Action"),
11822
- fields: []
11823
- }
12259
+ return resolveEventConfig(
12260
+ defineConfig({
12261
+ id,
12262
+ label: generateTranslationConfig2(id),
12263
+ title: generateTranslationConfig2(`${id} Event`),
12264
+ summary: {
12265
+ fields: []
11824
12266
  },
11825
- {
11826
- type: ActionType.DECLARE,
11827
- label: generateTranslationConfig2("Declare"),
11828
- review: {
11829
- title: generateTranslationConfig2("Review Declare Action"),
11830
- fields: []
11831
- }
12267
+ placeOfEvent: placeOfEventId ? { $$field: placeOfEventId } : void 0,
12268
+ dateOfEvent: dateOfEventId ? { $$field: dateOfEventId } : void 0,
12269
+ declaration: {
12270
+ label: generateTranslationConfig2(`${id} Declaration`),
12271
+ pages: [
12272
+ {
12273
+ id: "page1",
12274
+ title: generateTranslationConfig2("Page 1"),
12275
+ fields
12276
+ }
12277
+ ]
11832
12278
  },
11833
- ...actions
11834
- ]
11835
- });
12279
+ actions: [
12280
+ {
12281
+ type: ActionType.READ,
12282
+ label: generateTranslationConfig2("Read"),
12283
+ review: {
12284
+ title: generateTranslationConfig2("Review Read Action"),
12285
+ fields: []
12286
+ }
12287
+ },
12288
+ {
12289
+ type: ActionType.DECLARE,
12290
+ label: generateTranslationConfig2("Declare"),
12291
+ review: {
12292
+ title: generateTranslationConfig2("Review Declare Action"),
12293
+ fields: []
12294
+ }
12295
+ },
12296
+ ...actions
12297
+ ]
12298
+ })
12299
+ );
11836
12300
  };
11837
12301
  function withDeclaration(configuration, declaration) {
11838
12302
  return {
@@ -11896,6 +12360,26 @@ function generateTestValidatorContext(userRole2, eventWithConfig) {
11896
12360
  event: getEventValidatorContext(event2, eventConfig)
11897
12361
  };
11898
12362
  }
12363
+ function toVersionedEventConfig({
12364
+ id,
12365
+ label,
12366
+ advancedSearch,
12367
+ ...version
12368
+ }) {
12369
+ return {
12370
+ id,
12371
+ label,
12372
+ advancedSearch,
12373
+ versions: [
12374
+ {
12375
+ ...version,
12376
+ id: INITIAL_EVENT_CONFIG_VERSION_ID,
12377
+ label,
12378
+ effectiveFrom: DEFAULT_EFFECTIVE_FROM
12379
+ }
12380
+ ]
12381
+ };
12382
+ }
11899
12383
 
11900
12384
  // ../commons/src/events/TemplateConfig.ts
11901
12385
  var window2 = () => ({
@@ -11952,6 +12436,8 @@ var ACTION_SCOPE_MAP = {
11952
12436
  "record.correct"
11953
12437
  ],
11954
12438
  [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: ["record.correct"],
12439
+ // Not granted by a scope: the client checks the draft's own action instead
12440
+ [ClientSpecificAction.CONTINUE_DRAFT]: [],
11955
12441
  [ActionType.REJECT_CORRECTION]: ["record.correct"],
11956
12442
  [ActionType.APPROVE_CORRECTION]: ["record.correct"],
11957
12443
  [ActionType.REVOKE_REGISTRATION]: ["record.revoke-registration"],