@opencrvs/toolkit 1.8.0-rc.fb4793a → 1.8.0-rc.fb5b9fe

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 (34) hide show
  1. package/dist/commons/api/router.d.ts +2356 -1097
  2. package/dist/commons/conditionals/conditionals.d.ts +7 -6
  3. package/dist/commons/events/ActionConfig.d.ts +15774 -7797
  4. package/dist/commons/events/ActionDocument.d.ts +533 -346
  5. package/dist/commons/events/ActionInput.d.ts +197 -125
  6. package/dist/commons/events/Constants.d.ts +2 -0
  7. package/dist/commons/events/CountryConfigQueryInput.d.ts +2982 -0
  8. package/dist/commons/events/CreatedAtLocation.d.ts +2 -0
  9. package/dist/commons/events/Draft.d.ts +29 -24
  10. package/dist/commons/events/EventConfig.d.ts +13649 -9488
  11. package/dist/commons/events/EventDocument.d.ts +386 -267
  12. package/dist/commons/events/EventIndex.d.ts +209 -605
  13. package/dist/commons/events/EventInput.d.ts +0 -13
  14. package/dist/commons/events/EventMetadata.d.ts +71 -48
  15. package/dist/commons/events/FieldConfig.d.ts +486 -440
  16. package/dist/commons/events/FieldTypeMapping.d.ts +5 -2
  17. package/dist/commons/events/FieldValue.d.ts +2 -0
  18. package/dist/commons/events/FormConfig.d.ts +3346 -3052
  19. package/dist/commons/events/PageConfig.d.ts +750 -680
  20. package/dist/commons/events/User.d.ts +31 -7
  21. package/dist/commons/events/WorkqueueColumnConfig.d.ts +53 -0
  22. package/dist/commons/events/WorkqueueConfig.d.ts +3460 -485
  23. package/dist/commons/events/defineConfig.d.ts +1381 -575
  24. package/dist/commons/events/event.d.ts +2 -2
  25. package/dist/commons/events/field.d.ts +4 -13
  26. package/dist/commons/events/index.d.ts +4 -0
  27. package/dist/commons/events/serializer.d.ts +2 -0
  28. package/dist/commons/events/test.utils.d.ts +28 -6
  29. package/dist/commons/events/transactions.d.ts +1 -1
  30. package/dist/commons/events/utils.d.ts +333 -296
  31. package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
  32. package/dist/conditionals/index.js +28 -8
  33. package/dist/events/index.js +1625 -623
  34. package/package.json +1 -1
@@ -50,11 +50,14 @@ __export(events_exports, {
50
50
  AddressType: () => AddressType,
51
51
  AdministrativeAreas: () => AdministrativeAreas,
52
52
  AdvancedSearchConfig: () => AdvancedSearchConfig,
53
+ AnyOf: () => AnyOf,
54
+ AnyOfStatus: () => AnyOfStatus,
53
55
  ApproveCorrectionActionInput: () => ApproveCorrectionActionInput,
54
56
  ArchiveActionInput: () => ArchiveActionInput,
55
57
  AssignActionInput: () => AssignActionInput,
56
58
  AsyncRejectActionDocument: () => AsyncRejectActionDocument,
57
59
  BaseActionInput: () => BaseActionInput,
60
+ BearerTokenByUserType: () => BearerTokenByUserType,
58
61
  CONFIG_GET_ALLOWED_SCOPES: () => CONFIG_GET_ALLOWED_SCOPES,
59
62
  CONFIG_SEARCH_ALLOWED_SCOPES: () => CONFIG_SEARCH_ALLOWED_SCOPES,
60
63
  CertificateConfig: () => CertificateConfig,
@@ -68,6 +71,7 @@ __export(events_exports, {
68
71
  DEFAULT_DATE_OF_EVENT_PROPERTY: () => DEFAULT_DATE_OF_EVENT_PROPERTY,
69
72
  DataEntry: () => DataEntry,
70
73
  DataFieldValue: () => DataFieldValue,
74
+ DateCondition: () => DateCondition,
71
75
  DateRangeFieldValue: () => DateRangeFieldValue,
72
76
  DateValue: () => DateValue,
73
77
  DatetimeValue: () => DatetimeValue,
@@ -93,15 +97,18 @@ __export(events_exports, {
93
97
  EventInput: () => EventInput,
94
98
  EventMetadata: () => EventMetadata,
95
99
  EventMetadataKeys: () => EventMetadataKeys,
96
- EventMetadataParameter: () => EventMetadataParameter,
100
+ EventMetadataKeysArray: () => EventMetadataKeysArray,
97
101
  EventSearchIndex: () => EventSearchIndex,
98
102
  EventState: () => EventState,
99
103
  EventStatus: () => EventStatus,
100
104
  EventStatusEnum: () => EventStatusEnum,
101
105
  EventStatuses: () => EventStatuses,
106
+ Exact: () => Exact,
107
+ ExactStatus: () => ExactStatus,
102
108
  FieldConditional: () => FieldConditional,
103
109
  FieldConfig: () => FieldConfig,
104
110
  FieldConfigSchema: () => FieldConfigSchema,
111
+ FieldReference: () => FieldReference,
105
112
  FieldType: () => FieldType,
106
113
  FieldUpdateValue: () => FieldUpdateValue,
107
114
  FieldValue: () => FieldValue,
@@ -111,6 +118,7 @@ __export(events_exports, {
111
118
  Flag: () => Flag,
112
119
  FormConfig: () => FormConfig,
113
120
  FormPageConfig: () => FormPageConfig,
121
+ Fuzzy: () => Fuzzy,
114
122
  GenericAddressUpdateValue: () => GenericAddressUpdateValue,
115
123
  GenericAddressValue: () => GenericAddressValue,
116
124
  GeographicalArea: () => GeographicalArea,
@@ -120,19 +128,23 @@ __export(events_exports, {
120
128
  MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
121
129
  MimeType: () => MimeType,
122
130
  NonEmptyTextValue: () => NonEmptyTextValue,
131
+ Not: () => Not,
123
132
  NotifyActionInput: () => NotifyActionInput,
124
133
  NumberFieldValue: () => NumberFieldValue,
125
134
  PageConfig: () => PageConfig,
126
135
  PageTypes: () => PageTypes,
127
136
  PrintCertificateActionInput: () => PrintCertificateActionInput,
137
+ QueryExpression: () => QueryExpression,
128
138
  QueryInput: () => QueryInput,
129
139
  QueryType: () => QueryType,
140
+ Range: () => Range,
130
141
  ReadActionInput: () => ReadActionInput,
131
142
  RegisterAction: () => RegisterAction,
132
143
  RegisterActionInput: () => RegisterActionInput,
133
144
  RegistrationCreationMetadata: () => RegistrationCreationMetadata,
134
145
  RejectCorrectionActionInput: () => RejectCorrectionActionInput,
135
146
  RejectDeclarationActionInput: () => RejectDeclarationActionInput,
147
+ RejectionReason: () => RejectionReason,
136
148
  RequestCorrectionActionInput: () => RequestCorrectionActionInput,
137
149
  ResolvedUser: () => ResolvedUser,
138
150
  RuralAddressUpdateValue: () => RuralAddressUpdateValue,
@@ -141,16 +153,27 @@ __export(events_exports, {
141
153
  SearchQueryParams: () => SearchQueryParams,
142
154
  SelectOption: () => SelectOption,
143
155
  ShowConditional: () => ShowConditional,
156
+ SignatureFieldValue: () => SignatureFieldValue,
144
157
  SummaryConfig: () => SummaryConfig,
158
+ TENNIS_CLUB_MEMBERSHIP: () => TENNIS_CLUB_MEMBERSHIP,
145
159
  TextValue: () => TextValue,
146
160
  TranslationConfig: () => TranslationConfig,
147
161
  UnassignActionInput: () => UnassignActionInput,
148
162
  UrbanAddressUpdateValue: () => UrbanAddressUpdateValue,
149
163
  UrbanAddressValue: () => UrbanAddressValue,
164
+ User: () => User,
150
165
  ValidateActionInput: () => ValidateActionInput,
151
166
  VerificationActionConfig: () => VerificationActionConfig,
152
167
  VerificationPageConfig: () => VerificationPageConfig,
168
+ Within: () => Within,
169
+ WorkqueueColumn: () => WorkqueueColumn,
170
+ WorkqueueColumnKeys: () => WorkqueueColumnKeys,
171
+ WorkqueueColumnKeysArray: () => WorkqueueColumnKeysArray,
172
+ WorkqueueColumnValue: () => WorkqueueColumnValue,
153
173
  WorkqueueConfig: () => WorkqueueConfig,
174
+ WorkqueueConfigInput: () => WorkqueueConfigInput,
175
+ WorkqueueCountInput: () => WorkqueueCountInput,
176
+ WorkqueueCountOutput: () => WorkqueueCountOutput,
154
177
  ZodDate: () => ZodDate,
155
178
  alwaysTrue: () => alwaysTrue,
156
179
  and: () => and,
@@ -161,9 +184,12 @@ __export(events_exports, {
161
184
  createEmptyDraft: () => createEmptyDraft,
162
185
  createEventConditionals: () => createEventConditionals,
163
186
  createFieldConditionals: () => createFieldConditionals,
187
+ createPseudoRandomNumberGenerator: () => createPseudoRandomNumberGenerator,
164
188
  createValidationSchema: () => createValidationSchema,
189
+ dateOfEventColumn: () => dateOfEventColumn,
165
190
  deepDropNulls: () => deepDropNulls,
166
191
  deepMerge: () => deepMerge,
192
+ defaultWorkqueueColumns: () => defaultWorkqueueColumns,
167
193
  defineActionForm: () => defineActionForm,
168
194
  defineConditional: () => defineConditional,
169
195
  defineConfig: () => defineConfig,
@@ -172,6 +198,9 @@ __export(events_exports, {
172
198
  defineFormPage: () => defineFormPage,
173
199
  definePage: () => definePage,
174
200
  defineWorkqueue: () => defineWorkqueue,
201
+ defineWorkqueues: () => defineWorkqueues,
202
+ defineWorkqueuesColumns: () => defineWorkqueuesColumns,
203
+ deserializeQuery: () => deserializeQuery,
175
204
  errorMessages: () => errorMessages,
176
205
  event: () => event,
177
206
  eventMetadataLabelMap: () => eventMetadataLabelMap,
@@ -190,8 +219,10 @@ __export(events_exports, {
190
219
  generateActionDocument: () => generateActionDocument,
191
220
  generateEventDocument: () => generateEventDocument,
192
221
  generateEventDraftDocument: () => generateEventDraftDocument,
222
+ generateRandomSignature: () => generateRandomSignature,
193
223
  generateTransactionId: () => generateTransactionId,
194
224
  generateTranslationConfig: () => generateTranslationConfig,
225
+ generateWorkqueues: () => generateWorkqueues,
195
226
  getAcceptedActions: () => getAcceptedActions,
196
227
  getActionAnnotation: () => getActionAnnotation,
197
228
  getActionAnnotationFields: () => getActionAnnotationFields,
@@ -200,12 +231,15 @@ __export(events_exports, {
200
231
  getActionVerificationPageIds: () => getActionVerificationPageIds,
201
232
  getAnnotationFromDrafts: () => getAnnotationFromDrafts,
202
233
  getAssignedUserFromActions: () => getAssignedUserFromActions,
234
+ getAssignedUserSignatureFromActions: () => getAssignedUserSignatureFromActions,
203
235
  getCurrentEventState: () => getCurrentEventState,
204
236
  getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
205
237
  getDeclaration: () => getDeclaration,
206
238
  getDeclarationFields: () => getDeclarationFields,
207
239
  getDeclarationPages: () => getDeclarationPages,
208
240
  getMixedPath: () => getMixedPath,
241
+ getRandomDatetime: () => getRandomDatetime,
242
+ getStatusFromActions: () => getStatusFromActions,
209
243
  getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
210
244
  hasAnyOfScopes: () => hasAnyOfScopes,
211
245
  isAddressFieldType: () => isAddressFieldType,
@@ -229,6 +263,7 @@ __export(events_exports, {
229
263
  isFileFieldType: () => isFileFieldType,
230
264
  isFileFieldWithOptionType: () => isFileFieldWithOptionType,
231
265
  isLocationFieldType: () => isLocationFieldType,
266
+ isNonInteractiveFieldType: () => isNonInteractiveFieldType,
232
267
  isNumberFieldType: () => isNumberFieldType,
233
268
  isOfficeFieldType: () => isOfficeFieldType,
234
269
  isPageHeaderFieldType: () => isPageHeaderFieldType,
@@ -260,6 +295,9 @@ __export(events_exports, {
260
295
  });
261
296
  module.exports = __toCommonJS(events_exports);
262
297
 
298
+ // ../commons/src/events/Constants.ts
299
+ var TENNIS_CLUB_MEMBERSHIP = "tennis-club-membership";
300
+
263
301
  // ../commons/src/events/ActionConfig.ts
264
302
  var import_zod9 = require("zod");
265
303
 
@@ -462,6 +500,7 @@ var EmailValue = import_zod4.z.string().email();
462
500
  var CheckboxFieldValue = import_zod4.z.boolean();
463
501
  var NumberFieldValue = import_zod4.z.number();
464
502
  var DataFieldValue = import_zod4.z.undefined();
503
+ var SignatureFieldValue = import_zod4.z.string();
465
504
  var FieldValue = import_zod4.z.union([
466
505
  TextValue,
467
506
  DateValue,
@@ -492,19 +531,13 @@ var FieldUpdateValue = import_zod4.z.union([
492
531
  // ../commons/src/events/FieldConfig.ts
493
532
  var import_zod_openapi3 = require("zod-openapi");
494
533
  (0, import_zod_openapi3.extendZodWithOpenApi)(import_zod5.z);
495
- var FieldId = import_zod5.z.string();
496
- var ParentReference = import_zod5.z.object({
497
- _fieldId: FieldId.optional()
498
- }).optional();
534
+ var FieldId = import_zod5.z.string().describe("Unique identifier for the field");
535
+ var FieldReference = import_zod5.z.object({
536
+ $$field: FieldId
537
+ }).describe("Reference to a field by its ID");
538
+ var ParentReference = FieldReference.optional();
499
539
  var BaseField = import_zod5.z.object({
500
540
  id: FieldId,
501
- defaultValue: import_zod5.z.union([
502
- TextValue,
503
- NonEmptyTextValue,
504
- DateValue,
505
- NumberFieldValue,
506
- CheckboxFieldValue
507
- ]).optional(),
508
541
  parent: ParentReference,
509
542
  conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
510
543
  required: import_zod5.z.boolean().default(false).optional(),
@@ -566,6 +599,7 @@ var SignatureField = BaseField.extend({
566
599
  signaturePromptLabel: TranslationConfig.describe(
567
600
  "Title of the signature modal"
568
601
  ),
602
+ defaultValue: SignatureFieldValue.optional(),
569
603
  configuration: import_zod5.z.object({
570
604
  maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
571
605
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
@@ -625,6 +659,7 @@ var PageHeader = BaseField.extend({
625
659
  }).describe("A read-only header component for form pages");
626
660
  var File = BaseField.extend({
627
661
  type: import_zod5.z.literal(FieldType.FILE),
662
+ defaultValue: FileFieldValue.optional(),
628
663
  configuration: import_zod5.z.object({
629
664
  maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
630
665
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
@@ -698,6 +733,7 @@ var Location = BaseField.extend({
698
733
  var FileUploadWithOptions = BaseField.extend({
699
734
  type: import_zod5.z.literal(FieldType.FILE_WITH_OPTIONS),
700
735
  options: import_zod5.z.array(SelectOption).describe("A list of options"),
736
+ defaultValue: FileFieldWithOptionValue.optional(),
701
737
  configuration: import_zod5.z.object({
702
738
  maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
703
739
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
@@ -909,6 +945,12 @@ var ActionConfigBase = import_zod9.z.object({
909
945
  conditionals: import_zod9.z.array(ActionConditional2).optional().default([]),
910
946
  draft: import_zod9.z.boolean().optional()
911
947
  });
948
+ var ReadActionConfig = ActionConfigBase.merge(
949
+ import_zod9.z.object({
950
+ type: import_zod9.z.literal(ActionType.READ),
951
+ review: DeclarationReviewConfig
952
+ })
953
+ );
912
954
  var DeclareConfig = ActionConfigBase.merge(
913
955
  import_zod9.z.object({
914
956
  type: import_zod9.z.literal(ActionType.DECLARE),
@@ -975,6 +1017,7 @@ var ActionConfig = import_zod9.z.discriminatedUnion("type", [
975
1017
  * OpenAPI references are defined here so our generated OpenAPI spec knows to reuse the models
976
1018
  * and treat them as "models" instead of duplicating the data structure in each endpoint.
977
1019
  */
1020
+ ReadActionConfig.openapi({ ref: "ReadActionConfig" }),
978
1021
  DeclareConfig.openapi({ ref: "DeclareActionConfig" }),
979
1022
  ValidateConfig.openapi({ ref: "ValidateActionConfig" }),
980
1023
  RejectDeclarationConfig.openapi({ ref: "RejectDeclarationActionConfig" }),
@@ -1032,13 +1075,13 @@ var LanguageConfig = import_zod11.z.object({
1032
1075
  });
1033
1076
 
1034
1077
  // ../commons/src/events/EventConfig.ts
1035
- var import_zod17 = require("zod");
1078
+ var import_zod18 = require("zod");
1036
1079
 
1037
1080
  // ../commons/src/events/DeduplicationConfig.ts
1038
1081
  var import_zod12 = require("zod");
1039
1082
  var import_zod_openapi6 = require("zod-openapi");
1040
1083
  (0, import_zod_openapi6.extendZodWithOpenApi)(import_zod12.z);
1041
- var FieldReference = import_zod12.z.string();
1084
+ var FieldReference2 = import_zod12.z.string();
1042
1085
  var Matcher = import_zod12.z.object({
1043
1086
  fieldId: import_zod12.z.string(),
1044
1087
  options: import_zod12.z.object({
@@ -1067,7 +1110,7 @@ var DateRangeMatcher = Matcher.extend({
1067
1110
  type: import_zod12.z.literal("dateRange"),
1068
1111
  options: import_zod12.z.object({
1069
1112
  days: import_zod12.z.number(),
1070
- origin: FieldReference,
1113
+ origin: FieldReference2,
1071
1114
  boost: import_zod12.z.number().optional().default(1)
1072
1115
  })
1073
1116
  });
@@ -1075,7 +1118,7 @@ var DateDistanceMatcher = Matcher.extend({
1075
1118
  type: import_zod12.z.literal("dateDistance"),
1076
1119
  options: import_zod12.z.object({
1077
1120
  days: import_zod12.z.number(),
1078
- origin: FieldReference,
1121
+ origin: FieldReference2,
1079
1122
  boost: import_zod12.z.number().optional().default(1)
1080
1123
  })
1081
1124
  });
@@ -1207,114 +1250,134 @@ var AdvancedSearchConfig = import_zod14.z.object({
1207
1250
  var import_lodash = require("lodash");
1208
1251
 
1209
1252
  // ../commons/src/events/ActionDocument.ts
1210
- var import_zod15 = require("zod");
1253
+ var import_zod16 = require("zod");
1211
1254
  var import_zod_openapi7 = require("zod-openapi");
1212
- (0, import_zod_openapi7.extendZodWithOpenApi)(import_zod15.z);
1213
- var ActionUpdate = import_zod15.z.record(import_zod15.z.string(), FieldUpdateValue);
1214
- var EventState = import_zod15.z.record(import_zod15.z.string(), FieldValue);
1255
+
1256
+ // ../commons/src/uuid.ts
1257
+ var import_uuid = require("uuid");
1258
+ var import_zod15 = require("zod");
1259
+ var UUID = import_zod15.z.string().uuid().brand("UUID");
1260
+ function getUUID() {
1261
+ return (0, import_uuid.v4)();
1262
+ }
1263
+
1264
+ // ../commons/src/events/CreatedAtLocation.ts
1265
+ var CreatedAtLocation = UUID.nullish();
1266
+
1267
+ // ../commons/src/events/ActionDocument.ts
1268
+ (0, import_zod_openapi7.extendZodWithOpenApi)(import_zod16.z);
1269
+ var ActionUpdate = import_zod16.z.record(import_zod16.z.string(), FieldUpdateValue);
1270
+ var EventState = import_zod16.z.record(import_zod16.z.string(), FieldValue);
1215
1271
  var ActionStatus = {
1216
1272
  Requested: "Requested",
1217
1273
  Accepted: "Accepted",
1218
1274
  Rejected: "Rejected"
1219
1275
  };
1220
- var ActionBase = import_zod15.z.object({
1221
- id: import_zod15.z.string(),
1222
- transactionId: import_zod15.z.string(),
1223
- createdAt: import_zod15.z.string().datetime(),
1224
- createdBy: import_zod15.z.string(),
1225
- createdByRole: import_zod15.z.string(),
1276
+ var ActionBase = import_zod16.z.object({
1277
+ id: import_zod16.z.string(),
1278
+ transactionId: import_zod16.z.string(),
1279
+ createdAt: import_zod16.z.string().datetime(),
1280
+ createdBy: import_zod16.z.string(),
1281
+ createdByRole: import_zod16.z.string(),
1282
+ createdBySignature: import_zod16.z.string().nullish().describe("Reference to signature of the user who created the action"),
1283
+ createdAtLocation: CreatedAtLocation,
1226
1284
  declaration: ActionUpdate,
1227
- annotation: ActionUpdate.optional(),
1228
- createdAtLocation: import_zod15.z.string(),
1229
- status: import_zod15.z.enum([
1285
+ annotation: ActionUpdate.optional().nullable(),
1286
+ status: import_zod16.z.enum([
1230
1287
  ActionStatus.Requested,
1231
1288
  ActionStatus.Accepted,
1232
1289
  ActionStatus.Rejected
1233
1290
  ]),
1234
1291
  // If the action is an asynchronous confirmation for another action, we will save the original action id here.
1235
- originalActionId: import_zod15.z.string().optional()
1292
+ originalActionId: UUID.optional().nullable()
1236
1293
  });
1237
1294
  var AssignedAction = ActionBase.merge(
1238
- import_zod15.z.object({
1239
- type: import_zod15.z.literal(ActionType.ASSIGN),
1240
- assignedTo: import_zod15.z.string()
1295
+ import_zod16.z.object({
1296
+ type: import_zod16.z.literal(ActionType.ASSIGN),
1297
+ assignedTo: import_zod16.z.string()
1241
1298
  })
1242
1299
  );
1243
1300
  var UnassignedAction = ActionBase.merge(
1244
- import_zod15.z.object({
1245
- type: import_zod15.z.literal(ActionType.UNASSIGN),
1246
- assignedTo: import_zod15.z.literal(null)
1301
+ import_zod16.z.object({
1302
+ type: import_zod16.z.literal(ActionType.UNASSIGN),
1303
+ assignedTo: import_zod16.z.literal(null)
1247
1304
  })
1248
1305
  );
1249
1306
  var RegisterAction = ActionBase.merge(
1250
- import_zod15.z.object({
1251
- type: import_zod15.z.literal(ActionType.REGISTER),
1252
- registrationNumber: import_zod15.z.string().optional()
1307
+ import_zod16.z.object({
1308
+ type: import_zod16.z.literal(ActionType.REGISTER),
1309
+ registrationNumber: import_zod16.z.string().optional()
1253
1310
  })
1254
1311
  );
1255
1312
  var DeclareAction = ActionBase.merge(
1256
- import_zod15.z.object({
1257
- type: import_zod15.z.literal(ActionType.DECLARE)
1313
+ import_zod16.z.object({
1314
+ type: import_zod16.z.literal(ActionType.DECLARE)
1258
1315
  })
1259
1316
  );
1260
1317
  var ValidateAction = ActionBase.merge(
1261
- import_zod15.z.object({
1262
- type: import_zod15.z.literal(ActionType.VALIDATE)
1318
+ import_zod16.z.object({
1319
+ type: import_zod16.z.literal(ActionType.VALIDATE)
1263
1320
  })
1264
1321
  );
1322
+ var RejectionReason = import_zod16.z.object({
1323
+ message: import_zod16.z.string().min(1, { message: "Message cannot be empty" }).describe("Message describing reason for rejection or archiving"),
1324
+ isDuplicate: import_zod16.z.boolean().optional().describe("If a declaration is duplicated")
1325
+ });
1265
1326
  var RejectAction = ActionBase.merge(
1266
- import_zod15.z.object({
1267
- type: import_zod15.z.literal(ActionType.REJECT)
1327
+ import_zod16.z.object({
1328
+ type: import_zod16.z.literal(ActionType.REJECT),
1329
+ reason: RejectionReason
1268
1330
  })
1269
1331
  );
1270
1332
  var MarkAsDuplicateAction = ActionBase.merge(
1271
- import_zod15.z.object({
1272
- type: import_zod15.z.literal(ActionType.MARKED_AS_DUPLICATE)
1333
+ import_zod16.z.object({
1334
+ type: import_zod16.z.literal(ActionType.MARKED_AS_DUPLICATE)
1273
1335
  })
1274
1336
  );
1275
1337
  var ArchiveAction = ActionBase.merge(
1276
- import_zod15.z.object({
1277
- type: import_zod15.z.literal(ActionType.ARCHIVE)
1338
+ import_zod16.z.object({
1339
+ type: import_zod16.z.literal(ActionType.ARCHIVE),
1340
+ reason: RejectionReason
1278
1341
  })
1279
1342
  );
1280
1343
  var CreatedAction = ActionBase.merge(
1281
- import_zod15.z.object({
1282
- type: import_zod15.z.literal(ActionType.CREATE)
1344
+ import_zod16.z.object({
1345
+ type: import_zod16.z.literal(ActionType.CREATE)
1283
1346
  })
1284
1347
  );
1285
1348
  var NotifiedAction = ActionBase.merge(
1286
- import_zod15.z.object({
1287
- type: import_zod15.z.literal(ActionType.NOTIFY)
1349
+ import_zod16.z.object({
1350
+ type: import_zod16.z.literal(ActionType.NOTIFY)
1288
1351
  })
1289
1352
  );
1290
1353
  var PrintCertificateAction = ActionBase.merge(
1291
- import_zod15.z.object({
1292
- type: import_zod15.z.literal(ActionType.PRINT_CERTIFICATE)
1354
+ import_zod16.z.object({
1355
+ type: import_zod16.z.literal(ActionType.PRINT_CERTIFICATE)
1293
1356
  })
1294
1357
  );
1295
1358
  var RequestedCorrectionAction = ActionBase.merge(
1296
- import_zod15.z.object({
1297
- type: import_zod15.z.literal(ActionType.REQUEST_CORRECTION)
1359
+ import_zod16.z.object({
1360
+ type: import_zod16.z.literal(ActionType.REQUEST_CORRECTION)
1298
1361
  })
1299
1362
  );
1300
1363
  var ApprovedCorrectionAction = ActionBase.merge(
1301
- import_zod15.z.object({
1302
- type: import_zod15.z.literal(ActionType.APPROVE_CORRECTION),
1303
- requestId: import_zod15.z.string()
1364
+ import_zod16.z.object({
1365
+ type: import_zod16.z.literal(ActionType.APPROVE_CORRECTION),
1366
+ requestId: import_zod16.z.string()
1304
1367
  })
1305
1368
  );
1306
1369
  var RejectedCorrectionAction = ActionBase.merge(
1307
- import_zod15.z.object({
1308
- type: import_zod15.z.literal(ActionType.REJECT_CORRECTION),
1309
- requestId: import_zod15.z.string()
1370
+ import_zod16.z.object({
1371
+ type: import_zod16.z.literal(ActionType.REJECT_CORRECTION),
1372
+ requestId: import_zod16.z.string()
1310
1373
  })
1311
1374
  );
1312
1375
  var ReadAction = ActionBase.merge(
1313
- import_zod15.z.object({
1314
- type: import_zod15.z.literal(ActionType.READ)
1376
+ import_zod16.z.object({
1377
+ type: import_zod16.z.literal(ActionType.READ)
1315
1378
  })
1316
1379
  );
1317
- var ActionDocument = import_zod15.z.discriminatedUnion("type", [
1380
+ var ActionDocument = import_zod16.z.discriminatedUnion("type", [
1318
1381
  CreatedAction.openapi({ ref: "CreatedAction" }),
1319
1382
  ValidateAction.openapi({ ref: "ValidateAction" }),
1320
1383
  RejectAction.openapi({ ref: "RejectAction" }),
@@ -1337,20 +1400,20 @@ var AsyncRejectActionDocument = ActionBase.omit({
1337
1400
  declaration: true,
1338
1401
  annotation: true
1339
1402
  }).merge(
1340
- import_zod15.z.object({
1341
- type: import_zod15.z.enum(ConfirmableActions),
1342
- status: import_zod15.z.literal(ActionStatus.Rejected)
1403
+ import_zod16.z.object({
1404
+ type: import_zod16.z.enum(ConfirmableActions),
1405
+ status: import_zod16.z.literal(ActionStatus.Rejected)
1343
1406
  })
1344
1407
  );
1345
- var Action = import_zod15.z.union([ActionDocument, AsyncRejectActionDocument]);
1346
- var ResolvedUser = import_zod15.z.object({
1347
- id: import_zod15.z.string(),
1348
- role: import_zod15.z.string(),
1349
- name: import_zod15.z.array(
1350
- import_zod15.z.object({
1351
- use: import_zod15.z.string(),
1352
- given: import_zod15.z.array(import_zod15.z.string()),
1353
- family: import_zod15.z.string()
1408
+ var Action = import_zod16.z.union([ActionDocument, AsyncRejectActionDocument]);
1409
+ var ResolvedUser = import_zod16.z.object({
1410
+ id: import_zod16.z.string(),
1411
+ role: import_zod16.z.string(),
1412
+ name: import_zod16.z.array(
1413
+ import_zod16.z.object({
1414
+ use: import_zod16.z.string(),
1415
+ given: import_zod16.z.array(import_zod16.z.string()),
1416
+ family: import_zod16.z.string()
1354
1417
  })
1355
1418
  )
1356
1419
  });
@@ -1361,7 +1424,7 @@ var import_ajv_formats = __toESM(require("ajv-formats"));
1361
1424
  var import_date_fns = require("date-fns");
1362
1425
 
1363
1426
  // ../commons/src/events/FieldTypeMapping.ts
1364
- var import_zod16 = require("zod");
1427
+ var import_zod17 = require("zod");
1365
1428
  function mapFieldTypeToZod(type, required) {
1366
1429
  let schema;
1367
1430
  switch (type) {
@@ -1387,7 +1450,6 @@ function mapFieldTypeToZod(type, required) {
1387
1450
  case FieldType.ADMINISTRATIVE_AREA:
1388
1451
  case FieldType.FACILITY:
1389
1452
  case FieldType.OFFICE:
1390
- case FieldType.SIGNATURE:
1391
1453
  schema = required ? NonEmptyTextValue : TextValue;
1392
1454
  break;
1393
1455
  case FieldType.NUMBER:
@@ -1396,6 +1458,7 @@ function mapFieldTypeToZod(type, required) {
1396
1458
  case FieldType.CHECKBOX:
1397
1459
  schema = CheckboxFieldValue;
1398
1460
  break;
1461
+ case FieldType.SIGNATURE:
1399
1462
  case FieldType.FILE:
1400
1463
  schema = FileFieldValue;
1401
1464
  break;
@@ -1416,7 +1479,7 @@ function createValidationSchema(config) {
1416
1479
  for (const field2 of config) {
1417
1480
  shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
1418
1481
  }
1419
- return import_zod16.z.object(shape);
1482
+ return import_zod17.z.object(shape);
1420
1483
  }
1421
1484
  function mapFieldTypeToMockValue(field2, i) {
1422
1485
  switch (field2.type) {
@@ -1429,7 +1492,6 @@ function mapFieldTypeToMockValue(field2, i) {
1429
1492
  case FieldType.SELECT:
1430
1493
  case FieldType.COUNTRY:
1431
1494
  case FieldType.RADIO_GROUP:
1432
- case FieldType.SIGNATURE:
1433
1495
  case FieldType.PARAGRAPH:
1434
1496
  case FieldType.ADMINISTRATIVE_AREA:
1435
1497
  case FieldType.FACILITY:
@@ -1458,6 +1520,7 @@ function mapFieldTypeToMockValue(field2, i) {
1458
1520
  return ["2021-01-01", "2021-01-02"];
1459
1521
  case FieldType.CHECKBOX:
1460
1522
  return true;
1523
+ case FieldType.SIGNATURE:
1461
1524
  case FieldType.FILE:
1462
1525
  return {
1463
1526
  filename: "4f095fc4-4312-4de2-aa38-86dcc0f71044.png",
@@ -1481,7 +1544,6 @@ function mapFieldTypeToEmptyValue(field2) {
1481
1544
  case FieldType.SELECT:
1482
1545
  case FieldType.COUNTRY:
1483
1546
  case FieldType.RADIO_GROUP:
1484
- case FieldType.SIGNATURE:
1485
1547
  case FieldType.PARAGRAPH:
1486
1548
  case FieldType.ADMINISTRATIVE_AREA:
1487
1549
  case FieldType.FACILITY:
@@ -1507,6 +1569,7 @@ function mapFieldTypeToEmptyValue(field2) {
1507
1569
  number: null,
1508
1570
  zipCode: null
1509
1571
  };
1572
+ case FieldType.SIGNATURE:
1510
1573
  case FieldType.FILE:
1511
1574
  return {
1512
1575
  filename: "",
@@ -1586,6 +1649,9 @@ var isOfficeFieldType = (field2) => {
1586
1649
  var isDataFieldType = (field2) => {
1587
1650
  return field2.config.type === FieldType.DATA;
1588
1651
  };
1652
+ var isNonInteractiveFieldType = (field2) => {
1653
+ return field2.type === FieldType.DIVIDER || field2.type === FieldType.PAGE_HEADER || field2.type === FieldType.PARAGRAPH || field2.type === FieldType.BULLET_LIST || field2.type === FieldType.DATA;
1654
+ };
1589
1655
 
1590
1656
  // ../commons/src/conditionals/validate.ts
1591
1657
  var ajv = new import_ajv.default({
@@ -1762,12 +1828,6 @@ function runFieldValidations({
1762
1828
  };
1763
1829
  }
1764
1830
 
1765
- // ../commons/src/uuid.ts
1766
- var import_uuid = require("uuid");
1767
- function getUUID() {
1768
- return (0, import_uuid.v4)();
1769
- }
1770
-
1771
1831
  // ../commons/src/utils.ts
1772
1832
  function getOrThrow(x, message) {
1773
1833
  if (x === void 0 || x === null) {
@@ -1868,7 +1928,7 @@ function createEmptyDraft(eventId, draftId, actionType) {
1868
1928
  annotation: {},
1869
1929
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1870
1930
  createdBy: "@todo",
1871
- createdAtLocation: "@todo",
1931
+ createdAtLocation: "00000000-0000-0000-0000-000000000000",
1872
1932
  status: ActionStatus.Accepted,
1873
1933
  transactionId: "@todo",
1874
1934
  createdByRole: "@todo"
@@ -1964,22 +2024,22 @@ function getMixedPath(obj, path, defaultValue) {
1964
2024
 
1965
2025
  // ../commons/src/events/EventConfig.ts
1966
2026
  var import_zod_openapi8 = require("zod-openapi");
1967
- (0, import_zod_openapi8.extendZodWithOpenApi)(import_zod17.z);
1968
- var EventConfig = import_zod17.z.object({
1969
- id: import_zod17.z.string().describe(
2027
+ (0, import_zod_openapi8.extendZodWithOpenApi)(import_zod18.z);
2028
+ var EventConfig = import_zod18.z.object({
2029
+ id: import_zod18.z.string().describe(
1970
2030
  'A machine-readable identifier for the event, e.g. "birth" or "death"'
1971
2031
  ),
1972
- dateOfEvent: import_zod17.z.object({ fieldId: import_zod17.z.string() }).optional(),
2032
+ dateOfEvent: FieldReference.optional(),
1973
2033
  title: TranslationConfig,
1974
2034
  fallbackTitle: TranslationConfig.optional().describe(
1975
2035
  "This is a fallback title if actual title resolves to empty string"
1976
2036
  ),
1977
2037
  summary: SummaryConfig,
1978
2038
  label: TranslationConfig,
1979
- actions: import_zod17.z.array(ActionConfig),
2039
+ actions: import_zod18.z.array(ActionConfig),
1980
2040
  declaration: DeclarationFormConfig,
1981
- deduplication: import_zod17.z.array(DeduplicationConfig).optional().default([]),
1982
- advancedSearch: import_zod17.z.array(AdvancedSearchConfig).optional().default([])
2041
+ deduplication: import_zod18.z.array(DeduplicationConfig).optional().default([]),
2042
+ advancedSearch: import_zod18.z.array(AdvancedSearchConfig).optional().default([])
1983
2043
  }).superRefine((event2, ctx) => {
1984
2044
  const allFields = findAllFields(event2);
1985
2045
  const fieldIds = allFields.map((field2) => field2.id);
@@ -2013,13 +2073,13 @@ var EventConfig = import_zod17.z.object({
2013
2073
  }
2014
2074
  if (event2.dateOfEvent) {
2015
2075
  const eventDateFieldId = getDeclarationFields(event2).find(
2016
- ({ id }) => id === event2.dateOfEvent?.fieldId
2076
+ ({ id }) => id === event2.dateOfEvent?.$$field
2017
2077
  );
2018
2078
  if (!eventDateFieldId) {
2019
2079
  ctx.addIssue({
2020
2080
  code: "custom",
2021
2081
  message: `Date of event field id must match a field id in fields array.
2022
- Invalid date of event field ID for event ${event2.id}: ${event2.dateOfEvent.fieldId}`,
2082
+ Invalid date of event field ID for event ${event2.id}: ${event2.dateOfEvent.$$field}`,
2023
2083
  path: ["dateOfEvent"]
2024
2084
  });
2025
2085
  } else if (eventDateFieldId.type !== FieldType.DATE) {
@@ -2041,241 +2101,24 @@ var definePage = (page) => PageConfig.parse(page);
2041
2101
  var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
2042
2102
 
2043
2103
  // ../commons/src/events/WorkqueueConfig.ts
2044
- var import_zod20 = require("zod");
2104
+ var import_zod25 = require("zod");
2045
2105
 
2046
- // ../commons/src/events/EventIndex.ts
2106
+ // ../commons/src/events/serializers/user/serializer.ts
2047
2107
  var import_zod19 = require("zod");
2048
-
2049
- // ../commons/src/events/EventMetadata.ts
2050
- var import_zod18 = require("zod");
2051
- var EventStatus = {
2052
- CREATED: "CREATED",
2053
- NOTIFIED: "NOTIFIED",
2054
- DECLARED: "DECLARED",
2055
- VALIDATED: "VALIDATED",
2056
- REGISTERED: "REGISTERED",
2057
- CERTIFIED: "CERTIFIED",
2058
- REJECTED: "REJECTED",
2059
- ARCHIVED: "ARCHIVED"
2060
- };
2061
- var eventStatusValues = [
2062
- EventStatus.CREATED,
2063
- EventStatus.NOTIFIED,
2064
- EventStatus.DECLARED,
2065
- EventStatus.VALIDATED,
2066
- EventStatus.REGISTERED,
2067
- EventStatus.CERTIFIED,
2068
- EventStatus.REJECTED,
2069
- EventStatus.ARCHIVED
2070
- ];
2071
- var EventStatusEnum = import_zod18.z.enum(eventStatusValues);
2072
- var CustomFlags = {
2073
- CERTIFICATE_PRINTED: "certificate-printed"
2074
- };
2075
- var Flag = import_zod18.z.string().regex(
2076
- new RegExp(
2077
- `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(ActionStatus).join("|").toLowerCase()})$`
2078
- ),
2079
- "Flag must be in the format ActionType:ActionStatus (lowerCase)"
2080
- ).or(import_zod18.z.nativeEnum(CustomFlags));
2081
- var eventStatuses = Object.values(EventStatus);
2082
- var EventStatuses = import_zod18.z.nativeEnum(EventStatus);
2083
- var ZodDate = import_zod18.z.string().date();
2084
- var ActionCreationMetadata = import_zod18.z.object({
2085
- createdAt: import_zod18.z.string().datetime().describe("The timestamp when the action request was created."),
2086
- createdBy: import_zod18.z.string().describe("ID of the user who created the action request."),
2087
- createdAtLocation: import_zod18.z.string().describe("Location of the user who created the action request."),
2088
- acceptedAt: import_zod18.z.string().datetime().describe("Timestamp when the action request was accepted."),
2089
- createdByRole: import_zod18.z.string().describe("Role of the user at the time of action request creation.")
2090
- });
2091
- var RegistrationCreationMetadata = ActionCreationMetadata.extend({
2092
- registrationNumber: import_zod18.z.string().describe(
2093
- "Registration number of the event. Always present for accepted registrations."
2094
- )
2095
- });
2096
- var LegalStatuses = import_zod18.z.object({
2097
- [EventStatus.DECLARED]: ActionCreationMetadata.nullish(),
2098
- [EventStatus.REGISTERED]: RegistrationCreationMetadata.nullish()
2099
- });
2100
- var EventMetadata = import_zod18.z.object({
2101
- id: import_zod18.z.string(),
2102
- type: import_zod18.z.string().describe("The type of event, such as birth, death, or marriage."),
2103
- status: EventStatuses,
2104
- legalStatuses: LegalStatuses.describe(
2105
- "Metadata related to the legal registration of the event, such as who registered it and when."
2106
- ),
2107
- createdAt: import_zod18.z.string().datetime().describe("The timestamp when the event was first created and saved."),
2108
- dateOfEvent: ZodDate.nullish(),
2109
- createdBy: import_zod18.z.string().describe("ID of the user who created the event."),
2110
- updatedByUserRole: import_zod18.z.string().describe("Role of the user who last updated the declaration."),
2111
- createdAtLocation: import_zod18.z.string().describe("Location of the user who created the event."),
2112
- updatedAtLocation: import_zod18.z.string().nullish().describe("Location of the user who last updated the declaration."),
2113
- updatedAt: import_zod18.z.string().datetime().describe("Timestamp of the most recent declaration update."),
2114
- assignedTo: import_zod18.z.string().nullish().describe("ID of the user currently assigned to the event."),
2115
- updatedBy: import_zod18.z.string().nullish().describe("ID of the user who last updated the declaration."),
2116
- trackingId: import_zod18.z.string().describe(
2117
- "System-generated tracking ID used by informants or registrars to look up the event."
2118
- ),
2119
- flags: import_zod18.z.array(Flag)
2120
- });
2121
- var EventMetadataKeys = import_zod18.z.enum([
2122
- "id",
2123
- "type",
2124
- "status",
2125
- "createdAt",
2126
- "dateOfEvent",
2127
- "createdBy",
2128
- "updatedByUserRole",
2129
- "createdAtLocation",
2130
- "updatedAtLocation",
2131
- "updatedAt",
2132
- "assignedTo",
2133
- "updatedBy",
2134
- "trackingId",
2135
- "legalStatuses",
2136
- "flags"
2137
- ]);
2138
- var EventMetadataParameter = import_zod18.z.object({
2139
- // @TODO: Reconcile with the event metadata definition. How could we derive one from the other?
2140
- $event: EventMetadataKeys
2141
- });
2142
- var eventMetadataLabelMap = {
2143
- "event.assignedTo": {
2144
- id: "event.assignedTo.label",
2145
- defaultMessage: "Assigned To",
2146
- description: "Assigned To"
2147
- },
2148
- "event.createdAt": {
2149
- id: "event.createdAt.label",
2150
- defaultMessage: "Created",
2151
- description: "Created At"
2152
- },
2153
- "event.dateOfEvent": {
2154
- id: "event.dateOfEvent.label",
2155
- defaultMessage: "Date of Event",
2156
- description: "Date of Event"
2157
- },
2158
- "event.createdAtLocation": {
2159
- id: "event.createdAtLocation.label",
2160
- defaultMessage: "Location",
2161
- description: "Created At Location"
2162
- },
2163
- "event.updatedAtLocation": {
2164
- id: "event.updatedAtLocation.label",
2165
- defaultMessage: "Location",
2166
- description: "Updated At Location"
2167
- },
2168
- "event.createdBy": {
2169
- id: "event.createdBy.label",
2170
- defaultMessage: "Created By",
2171
- description: "Created By"
2172
- },
2173
- "event.updatedByUserRole": {
2174
- id: "event.updatedByUserRole.label",
2175
- defaultMessage: "Updated By Role",
2176
- description: "Updated By Role"
2177
- },
2178
- "event.id": {
2179
- id: "event.id.label",
2180
- defaultMessage: "ID",
2181
- description: "ID"
2182
- },
2183
- "event.updatedAt": {
2184
- id: "event.modifiedAt.label",
2185
- defaultMessage: "Updated",
2186
- description: "Modified At"
2187
- },
2188
- "event.status": {
2189
- id: "event.status.label",
2190
- defaultMessage: "Status",
2191
- description: "Status"
2192
- },
2193
- "event.type": {
2194
- id: "event.type.label",
2195
- defaultMessage: "Type",
2196
- description: "Type"
2197
- },
2198
- "event.updatedBy": {
2199
- id: "event.updatedBy.label",
2200
- defaultMessage: "Updated By",
2201
- description: "Updated By"
2202
- },
2203
- "event.trackingId": {
2204
- id: "event.trackingId.label",
2205
- defaultMessage: "Tracking ID",
2206
- description: "Tracking ID"
2207
- },
2208
- "event.flags": {
2209
- id: "event.flags.label",
2210
- defaultMessage: "Flags",
2211
- description: "Flags"
2212
- }
2213
- };
2214
-
2215
- // ../commons/src/events/EventIndex.ts
2216
- var EventIndex = EventMetadata.extend({
2217
- declaration: EventState
2218
- });
2219
- var EventSearchIndex = import_zod19.z.record(import_zod19.z.string(), import_zod19.z.any()).and(
2220
- import_zod19.z.object({
2221
- type: import_zod19.z.string()
2222
- // Ensures "type" (event-id) exists and is a string
2223
- })
2224
- );
2225
- var Fuzzy = import_zod19.z.object({ type: import_zod19.z.literal("fuzzy"), term: import_zod19.z.string() });
2226
- var Exact = import_zod19.z.object({ type: import_zod19.z.literal("exact"), term: import_zod19.z.string() });
2227
- var AnyOf = import_zod19.z.object({
2228
- type: import_zod19.z.literal("anyOf"),
2229
- terms: import_zod19.z.array(import_zod19.z.string())
2230
- });
2231
- var ExactStatus = import_zod19.z.object({
2232
- type: import_zod19.z.literal("exact"),
2233
- term: EventStatusEnum
2234
- });
2235
- var AnyOfStatus = import_zod19.z.object({
2236
- type: import_zod19.z.literal("anyOf"),
2237
- terms: import_zod19.z.array(EventStatusEnum)
2238
- });
2239
- var Range = import_zod19.z.object({
2240
- type: import_zod19.z.literal("range"),
2241
- gte: import_zod19.z.string(),
2242
- lte: import_zod19.z.string()
2243
- });
2244
- var Not = import_zod19.z.object({ type: import_zod19.z.literal("not"), term: import_zod19.z.string() });
2245
- var Within = import_zod19.z.object({ type: import_zod19.z.literal("within"), location: import_zod19.z.string() });
2246
- var DateCondition = import_zod19.z.union([Exact, Range]);
2247
- var QueryInput = import_zod19.z.lazy(
2248
- () => import_zod19.z.union([
2249
- import_zod19.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf, Not]),
2250
- import_zod19.z.record(import_zod19.z.string(), QueryInput)
2108
+ var SerializedUserField = import_zod19.z.object({
2109
+ $userField: import_zod19.z.enum([
2110
+ "id",
2111
+ "name",
2112
+ "role",
2113
+ "signatureFilename",
2114
+ "primaryOfficeId"
2251
2115
  ])
2252
- );
2253
- var QueryExpression = import_zod19.z.object({
2254
- eventType: import_zod19.z.string(),
2255
- status: import_zod19.z.optional(import_zod19.z.union([AnyOfStatus, ExactStatus])),
2256
- createdAt: import_zod19.z.optional(DateCondition),
2257
- updatedAt: import_zod19.z.optional(DateCondition),
2258
- "legalStatus.REGISTERED.createdAt": import_zod19.z.optional(DateCondition),
2259
- "legalStatus.REGISTERED.createdAtLocation": import_zod19.z.optional(
2260
- import_zod19.z.union([Within, Exact])
2261
- ),
2262
- createAtLocation: import_zod19.z.optional(import_zod19.z.union([Within, Exact])),
2263
- updatedAtLocation: import_zod19.z.optional(import_zod19.z.union([Within, Exact])),
2264
- createdBy: import_zod19.z.optional(Exact),
2265
- updatedBy: import_zod19.z.optional(Exact),
2266
- trackingId: import_zod19.z.optional(Exact),
2267
- flags: import_zod19.z.optional(import_zod19.z.array(import_zod19.z.union([AnyOf, Not]))),
2268
- data: QueryInput
2269
- }).partial();
2270
- var Or2 = import_zod19.z.object({
2271
- type: import_zod19.z.literal("or"),
2272
- clauses: import_zod19.z.array(QueryExpression)
2273
- });
2274
- var And2 = import_zod19.z.object({
2275
- type: import_zod19.z.literal("and"),
2276
- clauses: import_zod19.z.array(QueryExpression)
2277
2116
  });
2278
- var QueryType = import_zod19.z.discriminatedUnion("type", [Or2, And2]);
2117
+ function userSerializer(userField) {
2118
+ return {
2119
+ $userField: userField
2120
+ };
2121
+ }
2279
2122
 
2280
2123
  // ../commons/src/conditionals/conditionals.ts
2281
2124
  function defineConditional(schema) {
@@ -2318,7 +2161,7 @@ function not(condition) {
2318
2161
  function never() {
2319
2162
  return not(alwaysTrue());
2320
2163
  }
2321
- var user = {
2164
+ var user = Object.assign(userSerializer, {
2322
2165
  hasScope: (scope) => defineConditional({
2323
2166
  type: "object",
2324
2167
  properties: {
@@ -2338,7 +2181,7 @@ var user = {
2338
2181
  },
2339
2182
  required: ["$user"]
2340
2183
  })
2341
- };
2184
+ });
2342
2185
  function createEventConditionals() {
2343
2186
  return {
2344
2187
  /**
@@ -2389,7 +2232,7 @@ function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
2389
2232
  };
2390
2233
  }
2391
2234
  function isFieldReference(value) {
2392
- return typeof value === "object" && value !== null && "_fieldId" in value;
2235
+ return typeof value === "object" && value !== null && "$$field" in value;
2393
2236
  }
2394
2237
  function createFieldConditionals(fieldId) {
2395
2238
  const getDateRange = (date, clause) => ({
@@ -2404,6 +2247,10 @@ function createFieldConditionals(fieldId) {
2404
2247
  required: [fieldId]
2405
2248
  });
2406
2249
  return {
2250
+ /**
2251
+ * @private Internal property used for field reference tracking.
2252
+ */
2253
+ $$field: fieldId,
2407
2254
  isAfter: () => ({
2408
2255
  days: (days) => ({
2409
2256
  inPast: () => defineFormConditional(
@@ -2415,7 +2262,7 @@ function createFieldConditionals(fieldId) {
2415
2262
  }),
2416
2263
  date: (date) => {
2417
2264
  if (isFieldReference(date)) {
2418
- const comparedFieldId = date._fieldId;
2265
+ const comparedFieldId = date.$$field;
2419
2266
  return defineFormConditional(
2420
2267
  getDateRangeToFieldReference(
2421
2268
  fieldId,
@@ -2439,7 +2286,7 @@ function createFieldConditionals(fieldId) {
2439
2286
  }),
2440
2287
  date: (date) => {
2441
2288
  if (isFieldReference(date)) {
2442
- const comparedFieldId = date._fieldId;
2289
+ const comparedFieldId = date.$$field;
2443
2290
  return defineFormConditional(
2444
2291
  getDateRangeToFieldReference(
2445
2292
  fieldId,
@@ -2454,7 +2301,7 @@ function createFieldConditionals(fieldId) {
2454
2301
  }),
2455
2302
  isEqualTo: (value) => {
2456
2303
  if (isFieldReference(value)) {
2457
- const comparedFieldId = value._fieldId;
2304
+ const comparedFieldId = value.$$field;
2458
2305
  return defineFormConditional({
2459
2306
  type: "object",
2460
2307
  properties: {
@@ -2570,8 +2417,7 @@ function createFieldConditionals(fieldId) {
2570
2417
  }
2571
2418
  },
2572
2419
  required: [fieldId]
2573
- }),
2574
- getId: () => ({ fieldId })
2420
+ })
2575
2421
  };
2576
2422
  }
2577
2423
 
@@ -2645,144 +2491,670 @@ var event = Object.assign(eventFn, {
2645
2491
  }
2646
2492
  });
2647
2493
 
2648
- // ../commons/src/events/WorkqueueConfig.ts
2649
- var WorkqueueConfig = import_zod20.z.object({
2650
- slug: import_zod20.z.string().describe("Determines the url of the workqueue."),
2651
- name: TranslationConfig.describe(
2652
- "Title of the workflow (both in navigation and on the page)"
2494
+ // ../commons/src/events/WorkqueueColumnConfig.ts
2495
+ var import_zod21 = require("zod");
2496
+
2497
+ // ../commons/src/events/EventMetadata.ts
2498
+ var import_zod20 = require("zod");
2499
+ var EventStatus = {
2500
+ CREATED: "CREATED",
2501
+ NOTIFIED: "NOTIFIED",
2502
+ DECLARED: "DECLARED",
2503
+ VALIDATED: "VALIDATED",
2504
+ REGISTERED: "REGISTERED",
2505
+ CERTIFIED: "CERTIFIED",
2506
+ REJECTED: "REJECTED",
2507
+ ARCHIVED: "ARCHIVED"
2508
+ };
2509
+ var eventStatusValues = [
2510
+ EventStatus.CREATED,
2511
+ EventStatus.NOTIFIED,
2512
+ EventStatus.DECLARED,
2513
+ EventStatus.VALIDATED,
2514
+ EventStatus.REGISTERED,
2515
+ EventStatus.CERTIFIED,
2516
+ EventStatus.REJECTED,
2517
+ EventStatus.ARCHIVED
2518
+ ];
2519
+ var EventStatusEnum = import_zod20.z.enum(eventStatusValues);
2520
+ var CustomFlags = {
2521
+ CERTIFICATE_PRINTED: "certificate-printed"
2522
+ };
2523
+ var Flag = import_zod20.z.string().regex(
2524
+ new RegExp(
2525
+ `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
2526
+ ActionStatus
2527
+ ).join("|").toLowerCase()})$`
2653
2528
  ),
2654
- query: QueryType,
2655
- actions: import_zod20.z.array(
2656
- import_zod20.z.object({
2657
- type: import_zod20.z.string(),
2658
- conditionals: import_zod20.z.array(Conditional).optional()
2659
- })
2529
+ "Flag must be in the format ActionType:ActionStatus (lowerCase)"
2530
+ ).or(import_zod20.z.nativeEnum(CustomFlags));
2531
+ var eventStatuses = Object.values(EventStatus);
2532
+ var EventStatuses = import_zod20.z.nativeEnum(EventStatus);
2533
+ var ZodDate = import_zod20.z.string().date();
2534
+ var ActionCreationMetadata = import_zod20.z.object({
2535
+ createdAt: import_zod20.z.string().datetime().describe("The timestamp when the action request was created."),
2536
+ createdBy: import_zod20.z.string().describe("ID of the user who created the action request."),
2537
+ createdAtLocation: CreatedAtLocation.describe(
2538
+ "Location of the user who created the action request."
2660
2539
  ),
2661
- columns: import_zod20.z.array(
2662
- import_zod20.z.object({ label: TranslationConfig, value: EventMetadataParameter })
2663
- ).default([
2664
- {
2665
- label: {
2666
- id: "workqueues.dateOfEvent",
2667
- defaultMessage: "Date of Event",
2668
- description: "Label for workqueue column: dateOfEvent"
2669
- },
2670
- value: event.field("dateOfEvent")
2671
- }
2672
- ])
2673
- }).describe("Configuration for workqueue.");
2674
- function defineWorkqueue(workqueues) {
2675
- return workqueues.map((workqueue) => WorkqueueConfig.parse(workqueue));
2676
- }
2677
-
2678
- // ../commons/src/events/Draft.ts
2679
- var import_zod22 = require("zod");
2680
-
2681
- // ../commons/src/events/ActionInput.ts
2682
- var import_zod21 = require("zod");
2683
- var import_zod_openapi9 = require("zod-openapi");
2684
- var import_uuid3 = require("uuid");
2685
- (0, import_zod_openapi9.extendZodWithOpenApi)(import_zod21.z);
2686
- var BaseActionInput = import_zod21.z.object({
2687
- eventId: import_zod21.z.string(),
2688
- transactionId: import_zod21.z.string(),
2689
- declaration: ActionUpdate.default({}),
2690
- annotation: ActionUpdate.optional(),
2691
- originalActionId: import_zod21.z.string().optional(),
2692
- keepAssignment: import_zod21.z.boolean().optional()
2540
+ acceptedAt: import_zod20.z.string().datetime().describe("Timestamp when the action request was accepted."),
2541
+ createdByRole: import_zod20.z.string().describe("Role of the user at the time of action request creation."),
2542
+ createdBySignature: import_zod20.z.string().nullish().describe("Signature of the user who created the action request.")
2693
2543
  });
2694
- var CreateActionInput = BaseActionInput.merge(
2695
- import_zod21.z.object({
2696
- type: import_zod21.z.literal(ActionType.CREATE).default(ActionType.CREATE),
2697
- createdAtLocation: import_zod21.z.string()
2698
- })
2699
- );
2700
- var RegisterActionInput = BaseActionInput.merge(
2701
- import_zod21.z.object({
2702
- type: import_zod21.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
2703
- registrationNumber: import_zod21.z.string().optional()
2544
+ var RegistrationCreationMetadata = ActionCreationMetadata.extend({
2545
+ registrationNumber: import_zod20.z.string().describe(
2546
+ "Registration number of the event. Always present for accepted registrations."
2547
+ )
2548
+ });
2549
+ var LegalStatuses = import_zod20.z.object({
2550
+ [EventStatus.DECLARED]: ActionCreationMetadata.nullish(),
2551
+ [EventStatus.REGISTERED]: RegistrationCreationMetadata.nullish()
2552
+ });
2553
+ var EventMetadata = import_zod20.z.object({
2554
+ id: UUID,
2555
+ type: import_zod20.z.string().describe("The type of event, such as birth, death, or marriage."),
2556
+ status: EventStatuses,
2557
+ legalStatuses: LegalStatuses.describe(
2558
+ "Metadata related to the legal registration of the event, such as who registered it and when."
2559
+ ),
2560
+ createdAt: import_zod20.z.string().datetime().describe("The timestamp when the event was first created and saved."),
2561
+ dateOfEvent: ZodDate.nullish(),
2562
+ createdBy: import_zod20.z.string().describe("ID of the user who created the event."),
2563
+ updatedByUserRole: import_zod20.z.string().describe("Role of the user who last updated the declaration."),
2564
+ createdAtLocation: CreatedAtLocation.describe(
2565
+ "Location of the user who created the event."
2566
+ ),
2567
+ createdBySignature: import_zod20.z.string().nullish().describe("Signature of the user who created the event."),
2568
+ updatedAtLocation: UUID.nullish().describe(
2569
+ "Location of the user who last updated the declaration."
2570
+ ),
2571
+ updatedAt: import_zod20.z.string().datetime().describe("Timestamp of the most recent declaration update."),
2572
+ assignedTo: import_zod20.z.string().nullish().describe("ID of the user currently assigned to the event."),
2573
+ updatedBy: import_zod20.z.string().nullish().describe("ID of the user who last updated the declaration."),
2574
+ trackingId: import_zod20.z.string().describe(
2575
+ "System-generated tracking ID used by informants or registrars to look up the event."
2576
+ ),
2577
+ flags: import_zod20.z.array(Flag)
2578
+ });
2579
+ var EventMetadataKeysArray = [
2580
+ "id",
2581
+ "type",
2582
+ "status",
2583
+ "createdAt",
2584
+ "dateOfEvent",
2585
+ "createdBy",
2586
+ "updatedByUserRole",
2587
+ "createdAtLocation",
2588
+ "updatedAtLocation",
2589
+ "updatedAt",
2590
+ "assignedTo",
2591
+ "updatedBy",
2592
+ "trackingId",
2593
+ "legalStatuses",
2594
+ "flags"
2595
+ ];
2596
+ var EventMetadataKeys = import_zod20.z.enum(EventMetadataKeysArray);
2597
+ var eventMetadataLabelMap = {
2598
+ "event.assignedTo": {
2599
+ id: "event.assignedTo.label",
2600
+ defaultMessage: "Assigned To",
2601
+ description: "Assigned To"
2602
+ },
2603
+ "event.createdAt": {
2604
+ id: "event.createdAt.label",
2605
+ defaultMessage: "Created",
2606
+ description: "Created At"
2607
+ },
2608
+ "event.dateOfEvent": {
2609
+ id: "event.dateOfEvent.label",
2610
+ defaultMessage: "Date of Event",
2611
+ description: "Date of Event"
2612
+ },
2613
+ "event.createdAtLocation": {
2614
+ id: "event.createdAtLocation.label",
2615
+ defaultMessage: "Location",
2616
+ description: "Created At Location"
2617
+ },
2618
+ "event.updatedAtLocation": {
2619
+ id: "event.updatedAtLocation.label",
2620
+ defaultMessage: "Location",
2621
+ description: "Updated At Location"
2622
+ },
2623
+ "event.createdBy": {
2624
+ id: "event.createdBy.label",
2625
+ defaultMessage: "Created By",
2626
+ description: "Created By"
2627
+ },
2628
+ "event.updatedByUserRole": {
2629
+ id: "event.updatedByUserRole.label",
2630
+ defaultMessage: "Updated By Role",
2631
+ description: "Updated By Role"
2632
+ },
2633
+ "event.id": {
2634
+ id: "event.id.label",
2635
+ defaultMessage: "ID",
2636
+ description: "ID"
2637
+ },
2638
+ "event.updatedAt": {
2639
+ id: "event.modifiedAt.label",
2640
+ defaultMessage: "Updated",
2641
+ description: "Modified At"
2642
+ },
2643
+ "event.status": {
2644
+ id: "event.status.label",
2645
+ defaultMessage: "Status",
2646
+ description: "Status"
2647
+ },
2648
+ "event.type": {
2649
+ id: "event.type.label",
2650
+ defaultMessage: "Type",
2651
+ description: "Type"
2652
+ },
2653
+ "event.updatedBy": {
2654
+ id: "event.updatedBy.label",
2655
+ defaultMessage: "Updated By",
2656
+ description: "Updated By"
2657
+ },
2658
+ "event.trackingId": {
2659
+ id: "event.trackingId.label",
2660
+ defaultMessage: "Tracking ID",
2661
+ description: "Tracking ID"
2662
+ },
2663
+ "event.flags": {
2664
+ id: "event.flags.label",
2665
+ defaultMessage: "Flags",
2666
+ description: "Flags"
2667
+ }
2668
+ };
2669
+
2670
+ // ../commons/src/events/WorkqueueColumnConfig.ts
2671
+ var WorkqueueColumnKeysArray = [
2672
+ ...EventMetadataKeysArray,
2673
+ "title"
2674
+ ];
2675
+ var WorkqueueColumnKeys = import_zod21.z.enum(WorkqueueColumnKeysArray);
2676
+ var WorkqueueColumnValue = import_zod21.z.object({
2677
+ $event: WorkqueueColumnKeys
2678
+ });
2679
+ var WorkqueueColumn = import_zod21.z.object({
2680
+ label: TranslationConfig,
2681
+ value: WorkqueueColumnValue
2682
+ });
2683
+ function defineWorkqueuesColumns(workqueueColumns) {
2684
+ return workqueueColumns.map(
2685
+ (workqueueColumn) => WorkqueueColumn.parse(workqueueColumn)
2686
+ );
2687
+ }
2688
+
2689
+ // ../commons/src/events/CountryConfigQueryInput.ts
2690
+ var import_zod23 = require("zod");
2691
+
2692
+ // ../commons/src/events/EventIndex.ts
2693
+ var import_zod22 = require("zod");
2694
+ var import_zod_openapi9 = require("zod-openapi");
2695
+ (0, import_zod_openapi9.extendZodWithOpenApi)(import_zod22.z);
2696
+ var EventIndex = EventMetadata.extend({
2697
+ declaration: EventState
2698
+ }).openapi({
2699
+ ref: "EventIndex"
2700
+ });
2701
+ var EventSearchIndex = import_zod22.z.record(import_zod22.z.string(), import_zod22.z.any()).and(
2702
+ import_zod22.z.object({
2703
+ type: import_zod22.z.string()
2704
+ // Ensures "type" (event-id) exists and is a string
2705
+ })
2706
+ ).openapi({
2707
+ ref: "EventSearchIndex"
2708
+ });
2709
+ var Fuzzy = import_zod22.z.object({ type: import_zod22.z.literal("fuzzy"), term: import_zod22.z.string() }).openapi({
2710
+ ref: "Fuzzy"
2711
+ });
2712
+ var Exact = import_zod22.z.object({ type: import_zod22.z.literal("exact"), term: import_zod22.z.string() }).openapi({
2713
+ ref: "Exact"
2714
+ });
2715
+ var AnyOf = import_zod22.z.object({
2716
+ type: import_zod22.z.literal("anyOf"),
2717
+ terms: import_zod22.z.array(import_zod22.z.string())
2718
+ }).openapi({
2719
+ ref: "AnyOf"
2720
+ });
2721
+ var ExactStatus = import_zod22.z.object({
2722
+ type: import_zod22.z.literal("exact"),
2723
+ term: EventStatusEnum
2724
+ }).openapi({
2725
+ ref: "ExactStatus"
2726
+ });
2727
+ var AnyOfStatus = import_zod22.z.object({
2728
+ type: import_zod22.z.literal("anyOf"),
2729
+ terms: import_zod22.z.array(EventStatusEnum)
2730
+ }).openapi({
2731
+ ref: "AnyOfStatus"
2732
+ });
2733
+ var Range = import_zod22.z.object({
2734
+ type: import_zod22.z.literal("range"),
2735
+ gte: import_zod22.z.string(),
2736
+ lte: import_zod22.z.string()
2737
+ }).openapi({
2738
+ ref: "Range"
2739
+ });
2740
+ var Not = import_zod22.z.object({ type: import_zod22.z.literal("not"), term: import_zod22.z.string() }).openapi({
2741
+ ref: "Not"
2742
+ });
2743
+ var Within = import_zod22.z.object({ type: import_zod22.z.literal("within"), location: import_zod22.z.string() }).openapi({
2744
+ ref: "Within"
2745
+ });
2746
+ var DateCondition = import_zod22.z.union([Exact, Range]).openapi({
2747
+ ref: "DateCondition"
2748
+ });
2749
+ var QueryInput = import_zod22.z.lazy(
2750
+ () => import_zod22.z.union([
2751
+ import_zod22.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf, Not]),
2752
+ import_zod22.z.record(import_zod22.z.string(), QueryInput)
2753
+ ])
2754
+ ).openapi({
2755
+ ref: "QueryInput"
2756
+ });
2757
+ var QueryExpression = import_zod22.z.object({
2758
+ eventType: import_zod22.z.string(),
2759
+ status: import_zod22.z.optional(import_zod22.z.union([AnyOfStatus, ExactStatus])),
2760
+ createdAt: import_zod22.z.optional(DateCondition),
2761
+ updatedAt: import_zod22.z.optional(DateCondition),
2762
+ "legalStatus.REGISTERED.createdAt": import_zod22.z.optional(DateCondition),
2763
+ "legalStatus.REGISTERED.createdAtLocation": import_zod22.z.optional(
2764
+ import_zod22.z.union([Within, Exact])
2765
+ ),
2766
+ createdAtLocation: import_zod22.z.optional(import_zod22.z.union([Within, Exact])),
2767
+ updatedAtLocation: import_zod22.z.optional(import_zod22.z.union([Within, Exact])),
2768
+ assignedTo: import_zod22.z.optional(Exact),
2769
+ createdBy: import_zod22.z.optional(Exact),
2770
+ updatedBy: import_zod22.z.optional(Exact),
2771
+ trackingId: import_zod22.z.optional(Exact),
2772
+ flags: import_zod22.z.optional(import_zod22.z.array(import_zod22.z.union([AnyOf, Not]))),
2773
+ data: QueryInput
2774
+ }).partial().openapi({
2775
+ ref: "QueryExpression"
2776
+ });
2777
+ var QueryType = import_zod22.z.object({
2778
+ type: import_zod22.z.literal("and").or(import_zod22.z.literal("or")).openapi({ default: "and" }),
2779
+ clauses: import_zod22.z.preprocess(
2780
+ (val) => {
2781
+ if (typeof val === "string") {
2782
+ return [JSON.parse(val)];
2783
+ }
2784
+ if (Array.isArray(val)) {
2785
+ return val.map((v) => typeof v === "string" ? JSON.parse(v) : v);
2786
+ }
2787
+ return val;
2788
+ },
2789
+ import_zod22.z.array(QueryExpression).openapi({
2790
+ default: [
2791
+ {
2792
+ eventType: TENNIS_CLUB_MEMBERSHIP,
2793
+ status: {
2794
+ type: "anyOf",
2795
+ terms: [
2796
+ "CREATED",
2797
+ "NOTIFIED",
2798
+ "DECLARED",
2799
+ "VALIDATED",
2800
+ "REGISTERED",
2801
+ "CERTIFIED",
2802
+ "REJECTED",
2803
+ "ARCHIVED"
2804
+ ]
2805
+ },
2806
+ updatedAt: {
2807
+ type: "range",
2808
+ gte: "2025-05-22",
2809
+ lte: "2025-05-29"
2810
+ },
2811
+ data: {}
2812
+ }
2813
+ ]
2814
+ })
2815
+ )
2816
+ }).openapi({
2817
+ ref: "QueryType"
2818
+ });
2819
+
2820
+ // ../commons/src/events/CountryConfigQueryInput.ts
2821
+ var SerializableExact = import_zod23.z.object({
2822
+ type: import_zod23.z.literal("exact"),
2823
+ term: import_zod23.z.union([import_zod23.z.string(), SerializedUserField])
2824
+ });
2825
+ var SerializableWithin = import_zod23.z.object({
2826
+ type: import_zod23.z.literal("within"),
2827
+ location: import_zod23.z.union([import_zod23.z.string(), SerializedUserField])
2828
+ });
2829
+ var SerializedQueryExpression = import_zod23.z.object({
2830
+ eventType: import_zod23.z.string(),
2831
+ status: import_zod23.z.optional(import_zod23.z.union([AnyOfStatus, ExactStatus])),
2832
+ createdAt: import_zod23.z.optional(DateCondition),
2833
+ updatedAt: import_zod23.z.optional(DateCondition),
2834
+ createdAtLocation: import_zod23.z.optional(
2835
+ import_zod23.z.union([SerializableWithin, SerializableExact])
2836
+ ),
2837
+ updatedAtLocation: import_zod23.z.optional(
2838
+ import_zod23.z.union([SerializableWithin, SerializableExact])
2839
+ ),
2840
+ assignedTo: import_zod23.z.optional(SerializableExact),
2841
+ createdBy: import_zod23.z.optional(SerializableExact),
2842
+ updatedBy: import_zod23.z.optional(SerializableExact),
2843
+ trackingId: import_zod23.z.optional(Exact),
2844
+ flags: import_zod23.z.optional(import_zod23.z.array(import_zod23.z.union([AnyOf, Not]))),
2845
+ data: QueryInput
2846
+ }).partial();
2847
+ var Or2 = import_zod23.z.object({
2848
+ type: import_zod23.z.literal("or"),
2849
+ clauses: import_zod23.z.array(SerializedQueryExpression)
2850
+ });
2851
+ var And2 = import_zod23.z.object({
2852
+ type: import_zod23.z.literal("and"),
2853
+ clauses: import_zod23.z.array(SerializedQueryExpression)
2854
+ });
2855
+ var CountryConfigQueryType = import_zod23.z.discriminatedUnion("type", [And2, Or2]);
2856
+ var CountryConfigQueryInputType = import_zod23.z.union([
2857
+ SerializedQueryExpression,
2858
+ And2,
2859
+ Or2
2860
+ ]);
2861
+
2862
+ // ../commons/src/icons.ts
2863
+ var import_zod24 = require("zod");
2864
+ var AvailableIcons = import_zod24.z.enum([
2865
+ "Archived",
2866
+ "Assigned",
2867
+ "Certified",
2868
+ "Close",
2869
+ "Collapse",
2870
+ "Draft",
2871
+ "DuplicateYellow",
2872
+ "Expand",
2873
+ "ExternalValidate",
2874
+ "FilledCheck",
2875
+ "InReview",
2876
+ "Offline",
2877
+ "Registered",
2878
+ "RequiresUpdates",
2879
+ "Sent",
2880
+ "Validated",
2881
+ "WaitingApproval",
2882
+ "ChartActivity",
2883
+ "Activity",
2884
+ "Archive",
2885
+ "ArchiveTray",
2886
+ "ArrowLeft",
2887
+ "ArrowRight",
2888
+ "Buildings",
2889
+ "Circle",
2890
+ "CaretDown",
2891
+ "CaretLeft",
2892
+ "CaretRight",
2893
+ "ChartBar",
2894
+ "ChartLine",
2895
+ "ChatCircle",
2896
+ "CheckSquare",
2897
+ "Compass",
2898
+ "Check",
2899
+ "Copy",
2900
+ "Database",
2901
+ "DotsThreeVertical",
2902
+ "DownloadSimple",
2903
+ "ArrowCounterClockwise",
2904
+ "MagnifyingGlassMinus",
2905
+ "MagnifyingGlassPlus",
2906
+ "Export",
2907
+ "Eye",
2908
+ "EyeSlash",
2909
+ "Envelope",
2910
+ "File",
2911
+ "FileSearch",
2912
+ "FileMinus",
2913
+ "FilePlus",
2914
+ "FileText",
2915
+ "FileX",
2916
+ "Handshake",
2917
+ "Gear",
2918
+ "GitBranch",
2919
+ "IdentificationCard",
2920
+ "List",
2921
+ "ListBullets",
2922
+ "Lock",
2923
+ "MagnifyingGlass",
2924
+ "MapPin",
2925
+ "Medal",
2926
+ "NotePencil",
2927
+ "Paperclip",
2928
+ "PaperPlaneTilt",
2929
+ "Pen",
2930
+ "Pencil",
2931
+ "PencilSimpleLine",
2932
+ "Phone",
2933
+ "Plus",
2934
+ "Printer",
2935
+ "SignOut",
2936
+ "Star",
2937
+ "Target",
2938
+ "TextT",
2939
+ "Trash",
2940
+ "UploadSimple",
2941
+ "User",
2942
+ "UserPlus",
2943
+ "Users",
2944
+ "WarningCircle",
2945
+ "X",
2946
+ "CircleWavyCheck",
2947
+ "CircleWavyQuestion",
2948
+ "ArchiveBox",
2949
+ "ArrowCircleDown",
2950
+ "FileArrowUp",
2951
+ "FileDotted",
2952
+ "Files",
2953
+ "PencilLine",
2954
+ "PencilCircle",
2955
+ "UserCircle",
2956
+ "Clock",
2957
+ "QrCode",
2958
+ "Webcam",
2959
+ "Sun",
2960
+ "DeviceTabletCamera",
2961
+ "Globe",
2962
+ "Fingerprint",
2963
+ "PushPin",
2964
+ "Timer"
2965
+ ]);
2966
+
2967
+ // ../commons/src/events/WorkqueueConfig.ts
2968
+ var dateOfEventColumn = defineWorkqueuesColumns([
2969
+ {
2970
+ label: {
2971
+ id: "workqueues.dateOfEvent",
2972
+ defaultMessage: "Date of Event",
2973
+ description: "Label for workqueue column: dateOfEvent"
2974
+ },
2975
+ value: event.field("dateOfEvent")
2976
+ },
2977
+ {
2978
+ label: {
2979
+ defaultMessage: "Last updated",
2980
+ description: "This is the label for the workqueue column",
2981
+ id: "workqueue.default.column.modifiedAt"
2982
+ },
2983
+ value: event.field("updatedAt")
2984
+ }
2985
+ ]);
2986
+ var WorkqueueConfig = import_zod25.z.object({
2987
+ slug: import_zod25.z.string().describe("Determines the url of the workqueue."),
2988
+ name: TranslationConfig.describe(
2989
+ "Title of the workflow (both in navigation and on the page)"
2990
+ ),
2991
+ query: CountryConfigQueryType,
2992
+ actions: import_zod25.z.array(
2993
+ import_zod25.z.object({
2994
+ type: import_zod25.z.string(),
2995
+ conditionals: import_zod25.z.array(Conditional).optional()
2996
+ })
2997
+ ),
2998
+ columns: import_zod25.z.array(WorkqueueColumn).default(dateOfEventColumn),
2999
+ icon: AvailableIcons
3000
+ }).describe("Configuration for workqueue.");
3001
+ var WorkqueueConfigInput = import_zod25.z.object({
3002
+ slug: import_zod25.z.string().describe("Determines the url of the workqueue."),
3003
+ name: TranslationConfig.describe(
3004
+ "Title of the workflow (both in navigation and on the page)"
3005
+ ),
3006
+ query: CountryConfigQueryInputType,
3007
+ actions: import_zod25.z.array(
3008
+ import_zod25.z.object({
3009
+ type: import_zod25.z.string(),
3010
+ conditionals: import_zod25.z.array(Conditional).optional()
3011
+ })
3012
+ ),
3013
+ columns: import_zod25.z.array(WorkqueueColumn).default(dateOfEventColumn),
3014
+ icon: AvailableIcons
3015
+ });
3016
+ function defineWorkqueue(workqueueInput) {
3017
+ const queryInput = workqueueInput.query;
3018
+ const query = "type" in queryInput ? queryInput : { type: "and", clauses: [queryInput] };
3019
+ return WorkqueueConfig.parse({ ...workqueueInput, query });
3020
+ }
3021
+ function defineWorkqueues(workqueues) {
3022
+ return workqueues.map((workqueue) => defineWorkqueue(workqueue));
3023
+ }
3024
+ var WorkqueueCountInput = import_zod25.z.array(
3025
+ import_zod25.z.object({ slug: import_zod25.z.string(), query: QueryType })
3026
+ );
3027
+ var WorkqueueCountOutput = import_zod25.z.record(import_zod25.z.string(), import_zod25.z.number());
3028
+
3029
+ // ../commons/src/events/workqueueDefaultColumns.ts
3030
+ var defaultWorkqueueColumns = [
3031
+ {
3032
+ label: {
3033
+ defaultMessage: "Title",
3034
+ description: "This is the label for the workqueue column",
3035
+ id: "workqueue.in-reveiw.column.title"
3036
+ },
3037
+ value: event.field("title")
3038
+ },
3039
+ {
3040
+ label: {
3041
+ defaultMessage: "Event",
3042
+ description: "This is the label for the workqueue column",
3043
+ id: "workqueue.default.column.event"
3044
+ },
3045
+ value: event.field("type")
3046
+ }
3047
+ ];
3048
+
3049
+ // ../commons/src/events/Draft.ts
3050
+ var import_zod27 = require("zod");
3051
+
3052
+ // ../commons/src/events/ActionInput.ts
3053
+ var import_zod26 = require("zod");
3054
+ var import_zod_openapi10 = require("zod-openapi");
3055
+ (0, import_zod_openapi10.extendZodWithOpenApi)(import_zod26.z);
3056
+ var BaseActionInput = import_zod26.z.object({
3057
+ eventId: UUID,
3058
+ transactionId: import_zod26.z.string(),
3059
+ declaration: ActionUpdate.default({}),
3060
+ annotation: ActionUpdate.optional(),
3061
+ originalActionId: UUID.optional(),
3062
+ keepAssignment: import_zod26.z.boolean().optional()
3063
+ });
3064
+ var CreateActionInput = BaseActionInput.merge(
3065
+ import_zod26.z.object({
3066
+ type: import_zod26.z.literal(ActionType.CREATE).default(ActionType.CREATE),
3067
+ createdAtLocation: CreatedAtLocation
3068
+ })
3069
+ );
3070
+ var RegisterActionInput = BaseActionInput.merge(
3071
+ import_zod26.z.object({
3072
+ type: import_zod26.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
3073
+ registrationNumber: import_zod26.z.string().optional()
2704
3074
  })
2705
3075
  );
2706
3076
  var ValidateActionInput = BaseActionInput.merge(
2707
- import_zod21.z.object({
2708
- type: import_zod21.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
2709
- duplicates: import_zod21.z.array(import_zod21.z.string())
3077
+ import_zod26.z.object({
3078
+ type: import_zod26.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
3079
+ duplicates: import_zod26.z.array(import_zod26.z.string())
2710
3080
  })
2711
3081
  );
2712
3082
  var NotifyActionInput = BaseActionInput.merge(
2713
- import_zod21.z.object({
2714
- type: import_zod21.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
3083
+ import_zod26.z.object({
3084
+ type: import_zod26.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
2715
3085
  })
2716
3086
  ).openapi({
2717
3087
  default: {
2718
3088
  eventId: "<event-id-here>",
2719
- transactionId: (0, import_uuid3.v4)(),
3089
+ transactionId: getUUID(),
2720
3090
  declaration: {},
2721
3091
  annotation: {},
2722
3092
  type: ActionType.NOTIFY
2723
3093
  }
2724
3094
  });
2725
3095
  var DeclareActionInput = BaseActionInput.merge(
2726
- import_zod21.z.object({
2727
- type: import_zod21.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
3096
+ import_zod26.z.object({
3097
+ type: import_zod26.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
2728
3098
  })
2729
3099
  );
2730
3100
  var PrintCertificateActionInput = BaseActionInput.merge(
2731
- import_zod21.z.object({
2732
- type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
3101
+ import_zod26.z.object({
3102
+ type: import_zod26.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
2733
3103
  })
2734
3104
  );
2735
3105
  var RejectDeclarationActionInput = BaseActionInput.merge(
2736
- import_zod21.z.object({
2737
- type: import_zod21.z.literal(ActionType.REJECT).default(ActionType.REJECT)
3106
+ import_zod26.z.object({
3107
+ type: import_zod26.z.literal(ActionType.REJECT).default(ActionType.REJECT),
3108
+ reason: RejectionReason
2738
3109
  })
2739
3110
  );
2740
3111
  var MarkedAsDuplicateActionInput = BaseActionInput.merge(
2741
- import_zod21.z.object({
2742
- type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
3112
+ import_zod26.z.object({
3113
+ type: import_zod26.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
2743
3114
  })
2744
3115
  );
2745
3116
  var ArchiveActionInput = BaseActionInput.merge(
2746
- import_zod21.z.object({
2747
- type: import_zod21.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
3117
+ import_zod26.z.object({
3118
+ type: import_zod26.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
3119
+ reason: RejectionReason
2748
3120
  })
2749
3121
  );
2750
3122
  var AssignActionInput = BaseActionInput.merge(
2751
- import_zod21.z.object({
2752
- type: import_zod21.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
2753
- assignedTo: import_zod21.z.string()
3123
+ import_zod26.z.object({
3124
+ type: import_zod26.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
3125
+ assignedTo: import_zod26.z.string()
2754
3126
  })
2755
3127
  );
2756
3128
  var UnassignActionInput = BaseActionInput.merge(
2757
- import_zod21.z.object({
2758
- type: import_zod21.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
2759
- assignedTo: import_zod21.z.literal(null).default(null)
3129
+ import_zod26.z.object({
3130
+ type: import_zod26.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
3131
+ assignedTo: import_zod26.z.literal(null).default(null)
2760
3132
  })
2761
3133
  );
2762
3134
  var RequestCorrectionActionInput = BaseActionInput.merge(
2763
- import_zod21.z.object({
2764
- type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
3135
+ import_zod26.z.object({
3136
+ type: import_zod26.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
2765
3137
  })
2766
3138
  );
2767
3139
  var RejectCorrectionActionInput = BaseActionInput.merge(
2768
- import_zod21.z.object({
2769
- requestId: import_zod21.z.string(),
2770
- type: import_zod21.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
3140
+ import_zod26.z.object({
3141
+ requestId: import_zod26.z.string(),
3142
+ type: import_zod26.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
2771
3143
  })
2772
3144
  );
2773
3145
  var ApproveCorrectionActionInput = BaseActionInput.merge(
2774
- import_zod21.z.object({
2775
- requestId: import_zod21.z.string(),
2776
- type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
3146
+ import_zod26.z.object({
3147
+ requestId: import_zod26.z.string(),
3148
+ type: import_zod26.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
2777
3149
  })
2778
3150
  );
2779
3151
  var ReadActionInput = BaseActionInput.merge(
2780
- import_zod21.z.object({
2781
- type: import_zod21.z.literal(ActionType.READ).default(ActionType.READ)
3152
+ import_zod26.z.object({
3153
+ type: import_zod26.z.literal(ActionType.READ).default(ActionType.READ)
2782
3154
  })
2783
3155
  );
2784
- var DeleteActionInput = import_zod21.z.object({ eventId: import_zod21.z.string() });
2785
- var ActionInput = import_zod21.z.discriminatedUnion("type", [
3156
+ var DeleteActionInput = import_zod26.z.object({ eventId: UUID });
3157
+ var ActionInput = import_zod26.z.discriminatedUnion("type", [
2786
3158
  CreateActionInput.openapi({ ref: "CreateActionInput" }),
2787
3159
  ValidateActionInput.openapi({ ref: "ValidateActionInput" }),
2788
3160
  RegisterActionInput.openapi({ ref: "RegisterActionInput" }),
@@ -2811,18 +3183,18 @@ var ActionInput = import_zod21.z.discriminatedUnion("type", [
2811
3183
  });
2812
3184
 
2813
3185
  // ../commons/src/events/Draft.ts
2814
- var Draft = import_zod22.z.object({
2815
- id: import_zod22.z.string(),
2816
- eventId: import_zod22.z.string(),
2817
- transactionId: import_zod22.z.string(),
2818
- createdAt: import_zod22.z.string().datetime(),
3186
+ var Draft = import_zod27.z.object({
3187
+ id: UUID,
3188
+ eventId: UUID,
3189
+ transactionId: import_zod27.z.string(),
3190
+ createdAt: import_zod27.z.string().datetime(),
2819
3191
  action: ActionBase.extend({
2820
3192
  type: ActionTypes
2821
3193
  }).omit({ id: true })
2822
3194
  });
2823
3195
  var DraftInput = BaseActionInput.extend({
2824
3196
  type: ActionTypes,
2825
- status: import_zod22.z.enum([
3197
+ status: import_zod27.z.enum([
2826
3198
  ActionStatus.Requested,
2827
3199
  ActionStatus.Accepted,
2828
3200
  ActionStatus.Rejected
@@ -2830,26 +3202,24 @@ var DraftInput = BaseActionInput.extend({
2830
3202
  });
2831
3203
 
2832
3204
  // ../commons/src/events/EventInput.ts
2833
- var import_zod23 = require("zod");
2834
- var import_uuid4 = require("uuid");
2835
- var EventInput = import_zod23.z.object({
2836
- transactionId: import_zod23.z.string(),
2837
- type: import_zod23.z.string(),
2838
- dateOfEvent: import_zod23.z.object({ fieldId: import_zod23.z.string() }).optional()
2839
- }).openapi({ default: { transactionId: (0, import_uuid4.v4)(), type: "v2.birth" } });
3205
+ var import_zod28 = require("zod");
3206
+ var import_uuid8 = require("uuid");
3207
+ var EventInput = import_zod28.z.object({
3208
+ transactionId: import_zod28.z.string(),
3209
+ type: import_zod28.z.string()
3210
+ }).openapi({ default: { transactionId: (0, import_uuid8.v4)(), type: "v2.birth" } });
2840
3211
 
2841
3212
  // ../commons/src/events/EventDocument.ts
2842
- var import_zod24 = require("zod");
2843
- var import_zod_openapi10 = require("zod-openapi");
2844
- (0, import_zod_openapi10.extendZodWithOpenApi)(import_zod24.z);
2845
- var EventDocument = import_zod24.z.object({
2846
- id: import_zod24.z.string(),
2847
- type: import_zod24.z.string(),
2848
- dateOfEvent: import_zod24.z.object({ fieldId: import_zod24.z.string() }).optional(),
2849
- createdAt: import_zod24.z.string().datetime(),
2850
- updatedAt: import_zod24.z.string().datetime(),
2851
- actions: import_zod24.z.array(Action),
2852
- trackingId: import_zod24.z.string()
3213
+ var import_zod29 = require("zod");
3214
+ var import_zod_openapi11 = require("zod-openapi");
3215
+ (0, import_zod_openapi11.extendZodWithOpenApi)(import_zod29.z);
3216
+ var EventDocument = import_zod29.z.object({
3217
+ id: UUID,
3218
+ type: import_zod29.z.string(),
3219
+ createdAt: import_zod29.z.string().datetime(),
3220
+ updatedAt: import_zod29.z.string().datetime(),
3221
+ actions: import_zod29.z.array(Action),
3222
+ trackingId: import_zod29.z.string()
2853
3223
  }).openapi({ ref: "EventDocument" });
2854
3224
 
2855
3225
  // ../commons/src/events/state/utils.ts
@@ -2886,6 +3256,7 @@ function getDeclarationActionCreationMetadata(actionType, actions) {
2886
3256
  createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
2887
3257
  acceptedAt: acceptAction.createdAt,
2888
3258
  createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
3259
+ createdBySignature: requestAction?.createdBySignature ?? acceptAction.createdBySignature,
2889
3260
  registrationNumber
2890
3261
  };
2891
3262
  }
@@ -3006,23 +3377,34 @@ function getAssignedUserFromActions(actions) {
3006
3377
  return user2;
3007
3378
  }, null);
3008
3379
  }
3380
+ function getAssignedUserSignatureFromActions(actions) {
3381
+ return actions.reduce((signature, action) => {
3382
+ if (action.type === ActionType.ASSIGN) {
3383
+ return action.createdBySignature || null;
3384
+ }
3385
+ if (action.type === ActionType.UNASSIGN) {
3386
+ return null;
3387
+ }
3388
+ return signature;
3389
+ }, null);
3390
+ }
3009
3391
  function aggregateActionDeclarations(actions) {
3010
3392
  const excludedActions = [
3011
3393
  ActionType.REQUEST_CORRECTION,
3012
3394
  ActionType.PRINT_CERTIFICATE
3013
3395
  ];
3014
- return actions.reduce((status, action) => {
3396
+ return actions.reduce((declaration, action) => {
3015
3397
  if (excludedActions.some((excludedAction) => excludedAction === action.type)) {
3016
- return status;
3398
+ return declaration;
3017
3399
  }
3018
3400
  if (action.type === ActionType.APPROVE_CORRECTION) {
3019
3401
  const requestAction = actions.find(({ id }) => id === action.requestId);
3020
3402
  if (!requestAction) {
3021
- return status;
3403
+ return declaration;
3022
3404
  }
3023
- return deepMerge(status, requestAction.declaration);
3405
+ return deepMerge(declaration, requestAction.declaration);
3024
3406
  }
3025
- return deepMerge(status, action.declaration);
3407
+ return deepMerge(declaration, action.declaration);
3026
3408
  }, {});
3027
3409
  }
3028
3410
  function deepDropNulls(obj) {
@@ -3050,7 +3432,7 @@ function getAcceptedActions(event2) {
3050
3432
  );
3051
3433
  }
3052
3434
  var DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
3053
- function getCurrentEventState(event2) {
3435
+ function getCurrentEventState(event2, config) {
3054
3436
  const creationAction = event2.actions.find(
3055
3437
  (action) => action.type === ActionType.CREATE
3056
3438
  );
@@ -3062,9 +3444,17 @@ function getCurrentEventState(event2) {
3062
3444
  event2.actions
3063
3445
  );
3064
3446
  const declaration = aggregateActionDeclarations(acceptedActions);
3065
- const dateOfEvent = ZodDate.safeParse(
3066
- event2.dateOfEvent?.fieldId ? declaration[event2.dateOfEvent.fieldId] : event2[DEFAULT_DATE_OF_EVENT_PROPERTY]
3067
- ).data ?? null;
3447
+ let dateOfEvent;
3448
+ if (config.dateOfEvent) {
3449
+ const parsedDate = ZodDate.safeParse(
3450
+ declaration[config.dateOfEvent.$$field]
3451
+ );
3452
+ if (parsedDate.success) {
3453
+ dateOfEvent = parsedDate.data;
3454
+ }
3455
+ } else {
3456
+ dateOfEvent = event2[DEFAULT_DATE_OF_EVENT_PROPERTY].split("T")[0];
3457
+ }
3068
3458
  return deepDropNulls({
3069
3459
  id: event2.id,
3070
3460
  type: event2.type,
@@ -3073,19 +3463,24 @@ function getCurrentEventState(event2) {
3073
3463
  createdAt: creationAction.createdAt,
3074
3464
  createdBy: creationAction.createdBy,
3075
3465
  createdAtLocation: creationAction.createdAtLocation,
3466
+ createdBySignature: creationAction.createdBySignature,
3076
3467
  updatedAt: declarationUpdateMetadata.createdAt,
3077
3468
  assignedTo: getAssignedUserFromActions(acceptedActions),
3469
+ assignedToSignature: getAssignedUserSignatureFromActions(acceptedActions),
3078
3470
  updatedBy: declarationUpdateMetadata.createdBy,
3079
3471
  updatedAtLocation: declarationUpdateMetadata.createdAtLocation,
3080
3472
  declaration,
3081
3473
  trackingId: event2.trackingId,
3082
- // @TODO: unify this with rest of the code. It will trip us if updatedBy has different rules than updatedByUserRole
3083
3474
  updatedByUserRole: declarationUpdateMetadata.createdByRole,
3084
3475
  dateOfEvent,
3085
3476
  flags: getFlagsFromActions(event2.actions)
3086
3477
  });
3087
3478
  }
3088
- function getCurrentEventStateWithDrafts(event2, drafts) {
3479
+ function getCurrentEventStateWithDrafts({
3480
+ event: event2,
3481
+ drafts,
3482
+ configuration
3483
+ }) {
3089
3484
  const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
3090
3485
  const activeDrafts = findActiveDrafts(event2, drafts).map((draft) => draft.action).flatMap((action) => {
3091
3486
  if (action.type === ActionType.REQUEST_CORRECTION) {
@@ -3104,7 +3499,7 @@ function getCurrentEventStateWithDrafts(event2, drafts) {
3104
3499
  ...event2,
3105
3500
  actions: actionWithDrafts
3106
3501
  };
3107
- return getCurrentEventState(withDrafts);
3502
+ return getCurrentEventState(withDrafts, configuration);
3108
3503
  }
3109
3504
  function applyDraftsToEventIndex(eventIndex, drafts) {
3110
3505
  const indexedAt = eventIndex.updatedAt;
@@ -3158,8 +3553,24 @@ function generateTransactionId() {
3158
3553
  return getUUID();
3159
3554
  }
3160
3555
 
3556
+ // ../commons/src/events/User.ts
3557
+ var import_zod30 = require("zod");
3558
+ var User = import_zod30.z.object({
3559
+ id: import_zod30.z.string(),
3560
+ name: import_zod30.z.array(
3561
+ import_zod30.z.object({
3562
+ use: import_zod30.z.string(),
3563
+ given: import_zod30.z.array(import_zod30.z.string()),
3564
+ family: import_zod30.z.string()
3565
+ })
3566
+ ),
3567
+ role: import_zod30.z.string(),
3568
+ signatureFilename: import_zod30.z.string().optional()
3569
+ });
3570
+
3161
3571
  // ../commons/src/events/test.utils.ts
3162
3572
  var import_lodash2 = require("lodash");
3573
+ var import_addDays = __toESM(require("date-fns/addDays"));
3163
3574
 
3164
3575
  // ../commons/src/field-config/field-configuration.ts
3165
3576
  function createFieldConfig(fieldId, options) {
@@ -3174,16 +3585,12 @@ function createFieldConfig(fieldId, options) {
3174
3585
  // ../commons/src/events/field.ts
3175
3586
  function field(fieldId, options = {}) {
3176
3587
  return {
3177
- /**
3178
- * @private Internal property used for field reference tracking.
3179
- */
3180
- _fieldId: fieldId,
3181
3588
  ...createFieldConditionals(fieldId),
3182
3589
  ...createFieldConfig(fieldId, options)
3183
3590
  };
3184
3591
  }
3185
3592
 
3186
- // ../commons/src/fixtures/tennis-club-membership-event.ts
3593
+ // ../commons/src/fixtures/forms.ts
3187
3594
  var import_date_fns2 = require("date-fns");
3188
3595
  var PRINT_CERTIFICATE_FORM = defineActionForm({
3189
3596
  label: {
@@ -4174,7 +4581,10 @@ var timePeriodOptions = [
4174
4581
  description: "Label for option of time period select: last 7 days",
4175
4582
  id: "form.section.label.timePeriodLast7Days"
4176
4583
  },
4177
- value: `${(0, import_date_fns2.format)((0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 7), "yyyy-MM-dd")},${(0, import_date_fns2.format)(/* @__PURE__ */ new Date(), "yyyy-MM-dd")}`
4584
+ value: `${(0, import_date_fns2.format)((0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 7), "yyyy-MM-dd")},${(0, import_date_fns2.format)(
4585
+ /* @__PURE__ */ new Date(),
4586
+ "yyyy-MM-dd"
4587
+ )}`
4178
4588
  },
4179
4589
  {
4180
4590
  label: {
@@ -4182,7 +4592,10 @@ var timePeriodOptions = [
4182
4592
  description: "Label for option of time period select: last 30 days",
4183
4593
  id: "form.section.label.timePeriodLast30Days"
4184
4594
  },
4185
- value: `${(0, import_date_fns2.format)((0, import_date_fns2.subMonths)(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd")},${(0, import_date_fns2.format)(/* @__PURE__ */ new Date(), "yyyy-MM-dd")}`
4595
+ value: `${(0, import_date_fns2.format)((0, import_date_fns2.subMonths)(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd")},${(0, import_date_fns2.format)(
4596
+ /* @__PURE__ */ new Date(),
4597
+ "yyyy-MM-dd"
4598
+ )}`
4186
4599
  },
4187
4600
  {
4188
4601
  label: {
@@ -4190,7 +4603,10 @@ var timePeriodOptions = [
4190
4603
  description: "Label for option of time period select: last 90 days",
4191
4604
  id: "form.section.label.timePeriodLast90Days"
4192
4605
  },
4193
- value: `${(0, import_date_fns2.format)((0, import_date_fns2.subQuarters)(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd")},${(0, import_date_fns2.format)(/* @__PURE__ */ new Date(), "yyyy-MM-dd")}`
4606
+ value: `${(0, import_date_fns2.format)((0, import_date_fns2.subQuarters)(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd")},${(0, import_date_fns2.format)(
4607
+ /* @__PURE__ */ new Date(),
4608
+ "yyyy-MM-dd"
4609
+ )}`
4194
4610
  },
4195
4611
  {
4196
4612
  label: {
@@ -4198,15 +4614,20 @@ var timePeriodOptions = [
4198
4614
  description: "Label for option of time period select: last year",
4199
4615
  id: "form.section.label.timePeriodLastYear"
4200
4616
  },
4201
- value: `${(0, import_date_fns2.format)((0, import_date_fns2.subYears)(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd")},${(0, import_date_fns2.format)(/* @__PURE__ */ new Date(), "yyyy-MM-dd")}`
4617
+ value: `${(0, import_date_fns2.format)((0, import_date_fns2.subYears)(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd")},${(0, import_date_fns2.format)(
4618
+ /* @__PURE__ */ new Date(),
4619
+ "yyyy-MM-dd"
4620
+ )}`
4202
4621
  }
4203
4622
  ];
4623
+
4624
+ // ../commons/src/fixtures/tennis-club-membership-event.ts
4204
4625
  var tennisClubMembershipEvent = defineConfig({
4205
- id: "TENNIS_CLUB_MEMBERSHIP",
4626
+ id: TENNIS_CLUB_MEMBERSHIP,
4206
4627
  label: {
4207
4628
  defaultMessage: "Tennis club membership application",
4208
4629
  description: "This is what this event is referred as in the system",
4209
- id: "event.tennis-club-membership.label"
4630
+ id: "v2.event.tennis-club-membership.label"
4210
4631
  },
4211
4632
  title: {
4212
4633
  defaultMessage: "{applicant.firstname} {applicant.surname}",
@@ -4247,6 +4668,15 @@ var tennisClubMembershipEvent = defineConfig({
4247
4668
  ]
4248
4669
  },
4249
4670
  actions: [
4671
+ {
4672
+ type: ActionType.READ,
4673
+ label: {
4674
+ id: "v2.event.tennis-club-membership.action.read.label",
4675
+ defaultMessage: "Read",
4676
+ description: "Title of the read only page"
4677
+ },
4678
+ review: TENNIS_CLUB_DECLARATION_REVIEW
4679
+ },
4250
4680
  {
4251
4681
  type: ActionType.DECLARE,
4252
4682
  label: {
@@ -4588,10 +5018,466 @@ var tennisClubMembershipEvent = defineConfig({
4588
5018
  declaration: TENNIS_CLUB_DECLARATION_FORM
4589
5019
  });
4590
5020
 
4591
- // ../commons/src/events/test.utils.ts
4592
- function fieldConfigsToActionPayload(fields) {
4593
- return fields.reduce(
4594
- (acc, field2, i) => ({
5021
+ // ../commons/src/fixtures/football-club-membership-event.ts
5022
+ var footballClubMembershipEvent = defineConfig({
5023
+ id: "FOOTBALL_CLUB_MEMBERSHIP",
5024
+ label: {
5025
+ defaultMessage: "Football club membership application",
5026
+ description: "This is what this event is referred as in the system",
5027
+ id: "event.football-club-membership.label"
5028
+ },
5029
+ title: {
5030
+ defaultMessage: "{applicant.firstname} {applicant.surname}",
5031
+ description: "This is the title of the summary",
5032
+ id: "v2.event.football-club-membership.title"
5033
+ },
5034
+ summary: {
5035
+ fields: [
5036
+ {
5037
+ id: "applicant.firstname",
5038
+ label: {
5039
+ defaultMessage: "Applicant's first name",
5040
+ description: "This is the label for the field",
5041
+ id: "event.football-club-membership.summary.field.firstname.label"
5042
+ },
5043
+ value: {
5044
+ defaultMessage: "{applicant.firstname}",
5045
+ description: "This is the value to show in the summary",
5046
+ id: "event.football-club-membership.summary.field.firstname"
5047
+ },
5048
+ emptyValueMessage: {
5049
+ defaultMessage: "First name is not provided",
5050
+ description: "This is the message to show when the field is empty",
5051
+ id: "event.football-club-membership.summary.field.firstname.empty"
5052
+ }
5053
+ },
5054
+ {
5055
+ fieldId: "applicant.surname",
5056
+ label: {
5057
+ defaultMessage: "Applicant's last name",
5058
+ description: "Label for surname",
5059
+ id: "v2.event.football-club-membership.summary.field.surname.label"
5060
+ }
5061
+ },
5062
+ {
5063
+ fieldId: "applicant.email"
5064
+ }
5065
+ ]
5066
+ },
5067
+ actions: [
5068
+ {
5069
+ type: ActionType.READ,
5070
+ label: {
5071
+ id: "v2.event.football-club-membership.action.read.label",
5072
+ defaultMessage: "Read",
5073
+ description: "Title of the read only page"
5074
+ },
5075
+ review: TENNIS_CLUB_DECLARATION_REVIEW
5076
+ },
5077
+ {
5078
+ type: ActionType.DECLARE,
5079
+ label: {
5080
+ defaultMessage: "Send an application",
5081
+ description: "This is shown as the action name anywhere the user can trigger the action from",
5082
+ id: "event.football-club-membership.action.declare.label"
5083
+ },
5084
+ review: TENNIS_CLUB_DECLARATION_REVIEW
5085
+ },
5086
+ {
5087
+ type: ActionType.VALIDATE,
5088
+ label: {
5089
+ defaultMessage: "Validate",
5090
+ description: "This is shown as the action name anywhere the user can trigger the action from",
5091
+ id: "event.football-club-membership.action.validate.label"
5092
+ },
5093
+ review: TENNIS_CLUB_DECLARATION_REVIEW
5094
+ },
5095
+ {
5096
+ type: ActionType.REGISTER,
5097
+ label: {
5098
+ defaultMessage: "Register",
5099
+ description: "This is shown as the action name anywhere the user can trigger the action from",
5100
+ id: "event.football-club-membership.action.register.label"
5101
+ },
5102
+ review: TENNIS_CLUB_DECLARATION_REVIEW
5103
+ },
5104
+ {
5105
+ type: ActionType.REQUEST_CORRECTION,
5106
+ label: {
5107
+ defaultMessage: "Request correction",
5108
+ description: "This is shown as the action name anywhere the user can trigger the action from",
5109
+ id: "event.football-club-membership.action.correction.request.label"
5110
+ },
5111
+ onboardingForm: [
5112
+ {
5113
+ id: "correction-requester",
5114
+ type: PageTypes.enum.FORM,
5115
+ title: {
5116
+ id: "event.football-club-membership.action.requestCorrection.form.section.corrector",
5117
+ defaultMessage: "Correction requester",
5118
+ description: "This is the title of the section"
5119
+ },
5120
+ fields: [
5121
+ {
5122
+ id: "correction.requester.relationshop.intro",
5123
+ type: "PAGE_HEADER",
5124
+ label: {
5125
+ id: "correction.requester.relationshop.intro.label",
5126
+ defaultMessage: "Note: In the case that the child is now of legal age (18) then only they should be able to request a change to their birth record.",
5127
+ description: "The title for the corrector form"
5128
+ }
5129
+ },
5130
+ {
5131
+ id: "correction.requester.relationship",
5132
+ type: "RADIO_GROUP",
5133
+ label: {
5134
+ id: "v2.correction.corrector.title",
5135
+ defaultMessage: "Who is requesting a change to this record?",
5136
+ description: "The title for the corrector form"
5137
+ },
5138
+ defaultValue: "",
5139
+ options: [
5140
+ {
5141
+ value: "INFORMANT",
5142
+ label: {
5143
+ id: "v2.correction.corrector.informant",
5144
+ defaultMessage: "Informant",
5145
+ description: "Label for informant option in certificate correction form"
5146
+ }
5147
+ },
5148
+ {
5149
+ value: "ANOTHER_AGENT",
5150
+ label: {
5151
+ id: "v2.correction.corrector.anotherAgent",
5152
+ defaultMessage: "Another registration agent or field agent",
5153
+ description: "Label for another registration or field agent option in certificate correction form"
5154
+ }
5155
+ },
5156
+ {
5157
+ value: "REGISTRAR",
5158
+ label: {
5159
+ id: "v2.correction.corrector.me",
5160
+ defaultMessage: "Me (Registrar)",
5161
+ description: "Label for registrar option in certificate correction form"
5162
+ }
5163
+ },
5164
+ {
5165
+ value: "OTHER",
5166
+ label: {
5167
+ id: "v2.correction.corrector.others",
5168
+ defaultMessage: "Someone else",
5169
+ description: "Label for someone else option in certificate correction form"
5170
+ }
5171
+ }
5172
+ ]
5173
+ }
5174
+ ]
5175
+ },
5176
+ {
5177
+ id: "identity-check",
5178
+ type: PageTypes.enum.FORM,
5179
+ title: {
5180
+ id: "event.football-club-membership.action.requestCorrection.form.section.verify",
5181
+ defaultMessage: "Verify their identity",
5182
+ description: "This is the title of the section"
5183
+ },
5184
+ fields: [
5185
+ {
5186
+ id: "correction.identity-check.instructions",
5187
+ type: "PAGE_HEADER",
5188
+ label: {
5189
+ id: "correction.corrector.identity.instruction",
5190
+ defaultMessage: "Please verify the identity of the person making this request",
5191
+ description: "The title for the corrector form"
5192
+ }
5193
+ },
5194
+ {
5195
+ id: "correction.identity-check.verified",
5196
+ type: "RADIO_GROUP",
5197
+ label: {
5198
+ id: "correction.corrector.identity.verified.label",
5199
+ defaultMessage: "Identity verified",
5200
+ description: "The title for the corrector form"
5201
+ },
5202
+ defaultValue: "",
5203
+ required: true,
5204
+ options: [
5205
+ {
5206
+ value: "VERIFIED",
5207
+ label: {
5208
+ id: "correction.corrector.identity.verified",
5209
+ defaultMessage: "I have verified their identity",
5210
+ description: "Label for verified option in corrector identity check page"
5211
+ }
5212
+ }
5213
+ ]
5214
+ }
5215
+ ]
5216
+ }
5217
+ ],
5218
+ additionalDetailsForm: [
5219
+ {
5220
+ id: "correction-request.supporting-documents",
5221
+ type: PageTypes.enum.FORM,
5222
+ title: {
5223
+ id: "event.football-club-membership.action.requestCorrection.form.section.verify",
5224
+ defaultMessage: "Upload supporting documents",
5225
+ description: "This is the title of the section"
5226
+ },
5227
+ fields: [
5228
+ {
5229
+ id: "correction.supportingDocs.introduction",
5230
+ type: "PAGE_HEADER",
5231
+ label: {
5232
+ id: "correction.corrector.paragraph.title",
5233
+ defaultMessage: "For all record corrections at a minimum an affidavit must be provided. For material errors and omissions eg. in paternity cases, a court order must also be provided.",
5234
+ description: "The title for the corrector form"
5235
+ }
5236
+ },
5237
+ {
5238
+ id: "correction.supportingDocs",
5239
+ type: FieldType.FILE,
5240
+ label: {
5241
+ id: "correction.corrector.title",
5242
+ defaultMessage: "Upload supporting documents",
5243
+ description: "The title for the corrector form"
5244
+ }
5245
+ },
5246
+ {
5247
+ id: "correction.request.supportingDocuments",
5248
+ type: "RADIO_GROUP",
5249
+ label: {
5250
+ id: "correction.corrector.title",
5251
+ defaultMessage: "Who is requesting a change to this record?",
5252
+ description: "The title for the corrector form"
5253
+ },
5254
+ defaultValue: "",
5255
+ configuration: {
5256
+ styles: {
5257
+ size: "NORMAL"
5258
+ }
5259
+ },
5260
+ options: [
5261
+ {
5262
+ value: "ATTEST",
5263
+ label: {
5264
+ id: "correction.supportingDocuments.attest.label",
5265
+ defaultMessage: "I attest to seeing supporting documentation and have a copy filed at my office",
5266
+ description: ""
5267
+ }
5268
+ },
5269
+ {
5270
+ value: "NOT_NEEDED",
5271
+ label: {
5272
+ id: "correction.supportingDocuments.notNeeded.label",
5273
+ defaultMessage: "No supporting documents required",
5274
+ description: ""
5275
+ }
5276
+ }
5277
+ ]
5278
+ }
5279
+ ]
5280
+ },
5281
+ {
5282
+ id: "correction-request.additional-details",
5283
+ type: PageTypes.enum.FORM,
5284
+ title: {
5285
+ id: "event.football-club-membership.action.requestCorrection.form.section.corrector",
5286
+ defaultMessage: "Reason for correction",
5287
+ description: "This is the title of the section"
5288
+ },
5289
+ fields: [
5290
+ {
5291
+ id: "correction.request.reason",
5292
+ type: FieldType.TEXT,
5293
+ label: {
5294
+ id: "correction.reason.title",
5295
+ defaultMessage: "Reason for correction?",
5296
+ description: "The title for the corrector form"
5297
+ }
5298
+ }
5299
+ ]
5300
+ }
5301
+ ]
5302
+ },
5303
+ {
5304
+ type: ActionType.APPROVE_CORRECTION,
5305
+ label: {
5306
+ defaultMessage: "Approve correction",
5307
+ description: "This is shown as the action name anywhere the user can trigger the action from",
5308
+ id: "event.football-club-membership.action.correction.approve.label"
5309
+ }
5310
+ },
5311
+ {
5312
+ type: ActionType.PRINT_CERTIFICATE,
5313
+ label: {
5314
+ id: "v2.event.football-club-membership.action.collect-certificate.label",
5315
+ defaultMessage: "Print certificate",
5316
+ description: "This is shown as the action name anywhere the user can trigger the action from"
5317
+ },
5318
+ printForm: PRINT_CERTIFICATE_FORM,
5319
+ conditionals: [
5320
+ {
5321
+ type: "SHOW",
5322
+ conditional: defineConditional({
5323
+ type: "object",
5324
+ properties: {
5325
+ $event: {
5326
+ type: "object",
5327
+ properties: {
5328
+ actions: {
5329
+ type: "array",
5330
+ contains: {
5331
+ type: "object",
5332
+ properties: {
5333
+ type: {
5334
+ const: "REGISTER"
5335
+ },
5336
+ draft: {
5337
+ type: "boolean"
5338
+ }
5339
+ },
5340
+ required: ["type"],
5341
+ not: {
5342
+ properties: {
5343
+ draft: {
5344
+ const: true
5345
+ }
5346
+ }
5347
+ }
5348
+ }
5349
+ }
5350
+ },
5351
+ required: ["actions"]
5352
+ }
5353
+ },
5354
+ required: ["$event"]
5355
+ })
5356
+ }
5357
+ ]
5358
+ },
5359
+ {
5360
+ type: ActionType.ARCHIVE,
5361
+ label: {
5362
+ id: "v2.event.football-club-membership.action.archive.label",
5363
+ defaultMessage: "Archive",
5364
+ description: "This is shown as the action name anywhere the user can trigger the action from"
5365
+ }
5366
+ },
5367
+ {
5368
+ type: ActionType.REJECT,
5369
+ label: {
5370
+ id: "v2.event.football-club-membership.action.reject.label",
5371
+ defaultMessage: "Reject",
5372
+ description: "This is shown as the action name anywhere the user can trigger the action from"
5373
+ }
5374
+ }
5375
+ ],
5376
+ advancedSearch: [
5377
+ {
5378
+ title: {
5379
+ defaultMessage: "Registration details",
5380
+ description: "The title of Registration details accordion",
5381
+ id: "v2.advancedSearch.form.registrationDetails"
5382
+ },
5383
+ fields: [
5384
+ event("legalStatus.REGISTERED.createdAtLocation").exact(),
5385
+ event("legalStatus.REGISTERED.createdAt").range(),
5386
+ event("status", statusOptions).exact(),
5387
+ event("updatedAt", timePeriodOptions).range()
5388
+ ]
5389
+ },
5390
+ {
5391
+ title: {
5392
+ defaultMessage: "Applicant's details",
5393
+ description: "Applicant details search field section title",
5394
+ id: "v2.event.football-club-membership.search.applicants"
5395
+ },
5396
+ fields: [
5397
+ field("applicant.firstname").fuzzy(),
5398
+ field("applicant.surname").fuzzy(),
5399
+ field("applicant.dob").range(),
5400
+ field("applicant.email").exact()
5401
+ ]
5402
+ },
5403
+ {
5404
+ title: {
5405
+ defaultMessage: "Recommender's details",
5406
+ description: "Recommender details search field section title",
5407
+ id: "v2.event.football-club-membership.search.recommender"
5408
+ },
5409
+ fields: [
5410
+ field("recommender.firstname").fuzzy(),
5411
+ field("recommender.surname").fuzzy()
5412
+ ]
5413
+ }
5414
+ ],
5415
+ declaration: TENNIS_CLUB_DECLARATION_FORM
5416
+ });
5417
+
5418
+ // ../commons/src/fixtures/library-membership-event.ts
5419
+ var libraryMembershipForm = defineDeclarationForm({
5420
+ label: {
5421
+ id: "v2.event.library-membership.action.declare.form.label",
5422
+ defaultMessage: "Library membership application",
5423
+ description: "This is what this form is referred as in the system"
5424
+ },
5425
+ pages: [
5426
+ {
5427
+ id: "member",
5428
+ title: {
5429
+ id: "v2.event.library-membership.action.declare.form.section.who.title",
5430
+ defaultMessage: "Who is applying for the membership?",
5431
+ description: "This is the title of the section"
5432
+ },
5433
+ fields: [
5434
+ {
5435
+ id: "member.firstname",
5436
+ type: FieldType.TEXT,
5437
+ required: true,
5438
+ conditionals: [],
5439
+ label: {
5440
+ defaultMessage: "Member's first name",
5441
+ description: "This is the label for the field",
5442
+ id: "v2.event.library-membership.action.declare.form.section.who.field.firstname.label"
5443
+ }
5444
+ },
5445
+ {
5446
+ id: "member.surname",
5447
+ type: FieldType.TEXT,
5448
+ required: true,
5449
+ conditionals: [],
5450
+ label: {
5451
+ defaultMessage: "Member's surname",
5452
+ description: "This is the label for the field",
5453
+ id: "v2.event.library-membership.action.declare.form.section.who.field.surname.label"
5454
+ }
5455
+ }
5456
+ ]
5457
+ }
5458
+ ]
5459
+ });
5460
+ var libraryMembershipEvent = defineConfig({
5461
+ id: "library-membership",
5462
+ label: {
5463
+ defaultMessage: "Library membership application",
5464
+ description: "This is what this event is referred as in the system",
5465
+ id: "event.library-membership.label"
5466
+ },
5467
+ title: {
5468
+ defaultMessage: "{member.firstname} {member.surname}",
5469
+ description: "This is the title of the summary",
5470
+ id: "v2.event.library-membership.title"
5471
+ },
5472
+ summary: { fields: [] },
5473
+ actions: [],
5474
+ declaration: libraryMembershipForm
5475
+ });
5476
+
5477
+ // ../commons/src/events/test.utils.ts
5478
+ function fieldConfigsToActionPayload(fields) {
5479
+ return fields.reduce(
5480
+ (acc, field2, i) => ({
4595
5481
  ...acc,
4596
5482
  [field2.id]: mapFieldTypeToMockValue(field2, i)
4597
5483
  }),
@@ -4635,11 +5521,11 @@ function generateActionAnnotationInput(configuration, action) {
4635
5521
  var eventPayloadGenerator = {
4636
5522
  create: (input = {}) => ({
4637
5523
  transactionId: input.transactionId ?? getUUID(),
4638
- type: input.type ?? "TENNIS_CLUB_MEMBERSHIP"
5524
+ type: input.type ?? TENNIS_CLUB_MEMBERSHIP
4639
5525
  }),
4640
5526
  patch: (id, input = {}) => ({
4641
5527
  transactionId: input.transactionId ?? getUUID(),
4642
- type: input.type ?? "TENNIS_CLUB_MEMBERSHIP",
5528
+ type: input.type ?? TENNIS_CLUB_MEMBERSHIP,
4643
5529
  id
4644
5530
  }),
4645
5531
  draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
@@ -4665,7 +5551,7 @@ var eventPayloadGenerator = {
4665
5551
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4666
5552
  createdBy: "@todo",
4667
5553
  createdByRole: "@todo",
4668
- createdAtLocation: "@todo"
5554
+ createdAtLocation: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c"
4669
5555
  }
4670
5556
  },
4671
5557
  input
@@ -4739,9 +5625,13 @@ var eventPayloadGenerator = {
4739
5625
  transactionId: input.transactionId ?? getUUID(),
4740
5626
  declaration: {},
4741
5627
  // @TODO: Check whether generator is needed?
4742
- annotation: { isDuplicate: isDuplicate ?? false },
5628
+ annotation: {},
4743
5629
  duplicates: [],
4744
- eventId
5630
+ eventId,
5631
+ reason: {
5632
+ message: `${ActionType.ARCHIVE}`,
5633
+ isDuplicate: isDuplicate ?? false
5634
+ }
4745
5635
  }),
4746
5636
  reject: (eventId, input = {}) => ({
4747
5637
  type: ActionType.REJECT,
@@ -4752,7 +5642,8 @@ var eventPayloadGenerator = {
4752
5642
  ActionType.REJECT
4753
5643
  ),
4754
5644
  duplicates: [],
4755
- eventId
5645
+ eventId,
5646
+ reason: { message: `${ActionType.REJECT}` }
4756
5647
  }),
4757
5648
  register: (eventId, input = {}) => ({
4758
5649
  type: ActionType.REGISTER,
@@ -4849,9 +5740,9 @@ function generateActionDocument({
4849
5740
  case ActionType.VALIDATE:
4850
5741
  return { ...actionBase, type: action };
4851
5742
  case ActionType.ARCHIVE:
4852
- return { ...actionBase, type: action };
5743
+ return { ...actionBase, type: action, reason: { message: "Archive" } };
4853
5744
  case ActionType.REJECT:
4854
- return { ...actionBase, type: action };
5745
+ return { ...actionBase, type: action, reason: { message: "Reject" } };
4855
5746
  case ActionType.CREATE:
4856
5747
  return { ...actionBase, type: action };
4857
5748
  case ActionType.NOTIFY:
@@ -4863,7 +5754,11 @@ function generateActionDocument({
4863
5754
  case ActionType.APPROVE_CORRECTION:
4864
5755
  return { ...actionBase, requestId: getUUID(), type: action };
4865
5756
  case ActionType.REJECT_CORRECTION:
4866
- return { ...actionBase, requestId: getUUID(), type: action };
5757
+ return {
5758
+ ...actionBase,
5759
+ requestId: getUUID(),
5760
+ type: action
5761
+ };
4867
5762
  case ActionType.REGISTER:
4868
5763
  return {
4869
5764
  ...actionBase,
@@ -4891,8 +5786,7 @@ function generateEventDocument({
4891
5786
  id: getUUID(),
4892
5787
  // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
4893
5788
  // @TODO: This should be fixed in the future.
4894
- updatedAt: new Date(Date.now() - 1e3).toISOString(),
4895
- dateOfEvent: configuration.dateOfEvent
5789
+ updatedAt: new Date(Date.now() - 1e3).toISOString()
4896
5790
  };
4897
5791
  }
4898
5792
  function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
@@ -4914,21 +5808,16 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, de
4914
5808
  eventId
4915
5809
  };
4916
5810
  }
4917
- function getEventStatus() {
4918
- const statuses = [
4919
- EventStatus.CREATED,
4920
- EventStatus.REGISTERED,
4921
- EventStatus.DECLARED
4922
- ];
4923
- const randomIndex = Math.floor(Math.random() * 3);
4924
- return statuses[randomIndex];
5811
+ function pickRandom(rng, items) {
5812
+ return items[Math.floor(rng() * items.length)];
4925
5813
  }
4926
- function getTrackingId() {
4927
- const uuid = getUUID().replace(/-/g, "");
4928
- const trackingId = uuid.slice(0, 6).toUpperCase();
4929
- return trackingId;
5814
+ function getRandomDatetime(rng, start, end) {
5815
+ const range = end.getTime() - start.getTime();
5816
+ const offset = Math.floor(rng() * range);
5817
+ const randomDate = new Date(start.getTime() + offset);
5818
+ return randomDate.toISOString();
4930
5819
  }
4931
- function getRandomApplicant() {
5820
+ function generateRandomApplicant(rng) {
4932
5821
  const firstNames = [
4933
5822
  "Danny",
4934
5823
  "John",
@@ -4949,18 +5838,13 @@ function getRandomApplicant() {
4949
5838
  "Garcia",
4950
5839
  "Miller"
4951
5840
  ];
4952
- function getRandomDate(start, end) {
4953
- const randomDate = new Date(
4954
- start.getTime() + Math.random() * (end.getTime() - start.getTime())
4955
- );
4956
- return randomDate.toISOString().split("T")[0];
4957
- }
4958
- const randomFirstName = firstNames[Math.floor(Math.random() * firstNames.length)];
4959
- const randomSurname = surnames[Math.floor(Math.random() * surnames.length)];
4960
- const randomDob = getRandomDate(
5841
+ const randomFirstName = pickRandom(rng, firstNames);
5842
+ const randomSurname = pickRandom(rng, surnames);
5843
+ const randomDob = getRandomDatetime(
5844
+ rng,
4961
5845
  /* @__PURE__ */ new Date("1990-01-01"),
4962
5846
  /* @__PURE__ */ new Date("2010-12-31")
4963
- );
5847
+ ).split("T")[0];
4964
5848
  return {
4965
5849
  "recommender.none": true,
4966
5850
  "applicant.firstname": randomFirstName,
@@ -4968,28 +5852,84 @@ function getRandomApplicant() {
4968
5852
  "applicant.dob": randomDob
4969
5853
  };
4970
5854
  }
4971
- var eventQueryDataGenerator = (overrides = {}) => ({
4972
- id: overrides.id ?? getUUID(),
4973
- type: overrides.type ?? "TENNIS_CLUB_MEMBERSHIP",
4974
- status: overrides.status ?? getEventStatus(),
4975
- createdAt: overrides.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
4976
- createdBy: overrides.createdBy ?? getUUID(),
4977
- createdAtLocation: overrides.createdAtLocation ?? getUUID(),
4978
- updatedAtLocation: overrides.updatedAtLocation ?? getUUID(),
4979
- updatedAt: overrides.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
4980
- assignedTo: overrides.assignedTo ?? null,
4981
- updatedBy: overrides.updatedBy ?? getUUID(),
4982
- updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
4983
- flags: [],
4984
- legalStatuses: overrides.legalStatuses ?? {},
4985
- declaration: overrides.declaration ?? getRandomApplicant(),
4986
- trackingId: overrides.trackingId ?? getTrackingId()
4987
- });
5855
+ function createPseudoRandomNumberGenerator(seed) {
5856
+ const MODULUS = 2 ** 32;
5857
+ const MULTIPLIER = 1664525;
5858
+ const INCREMENT = 1013904223;
5859
+ let state = seed >>> 0;
5860
+ return () => {
5861
+ state = (MULTIPLIER * state + INCREMENT) % MODULUS;
5862
+ return state / MODULUS;
5863
+ };
5864
+ }
5865
+ function generateUuid(rng) {
5866
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
5867
+ const r = Math.floor(rng() * 16);
5868
+ const v = c === "x" ? r : r & 3 | 8;
5869
+ return v.toString(16);
5870
+ });
5871
+ }
5872
+ function generateTrackingId(rng) {
5873
+ const uuid = generateUuid(rng).replace(/-/g, "");
5874
+ const trackingId = uuid.slice(0, 6).toUpperCase();
5875
+ return trackingId;
5876
+ }
5877
+ function generateRandomSignature(rng) {
5878
+ return `/random-bucket/${generateUuid(rng)}.png`;
5879
+ }
5880
+ var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
5881
+ const rng = createPseudoRandomNumberGenerator(seed);
5882
+ const createdAt = getRandomDatetime(
5883
+ rng,
5884
+ /* @__PURE__ */ new Date("2024-01-01"),
5885
+ /* @__PURE__ */ new Date("2024-12-31")
5886
+ );
5887
+ return {
5888
+ id: overrides.id ?? generateUuid(rng),
5889
+ type: overrides.type ?? TENNIS_CLUB_MEMBERSHIP,
5890
+ status: overrides.status ?? pickRandom(rng, eventStatuses),
5891
+ createdAt: overrides.createdAt ?? createdAt,
5892
+ createdBy: overrides.createdBy ?? generateUuid(rng),
5893
+ createdAtLocation: overrides.createdAtLocation ?? generateUuid(rng),
5894
+ updatedAtLocation: overrides.updatedAtLocation ?? generateUuid(rng),
5895
+ createdBySignature: overrides.createdBySignature ?? generateRandomSignature(rng),
5896
+ updatedAt: overrides.updatedAt ?? (0, import_addDays.default)(new Date(createdAt), 1).toISOString(),
5897
+ assignedTo: overrides.assignedTo ?? null,
5898
+ updatedBy: overrides.updatedBy ?? generateUuid(rng),
5899
+ updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
5900
+ flags: [],
5901
+ legalStatuses: overrides.legalStatuses ?? {},
5902
+ declaration: overrides.declaration ?? generateRandomApplicant(rng),
5903
+ trackingId: overrides.trackingId ?? generateTrackingId(rng)
5904
+ };
5905
+ };
4988
5906
  var generateTranslationConfig = (message) => ({
4989
5907
  defaultMessage: message,
4990
5908
  description: "Description for ${message}",
4991
5909
  id: message
4992
5910
  });
5911
+ var BearerTokenByUserType = {
5912
+ fieldAgent: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJyZWNvcmQuZGVjbGFyZS1iaXJ0aCIsInJlY29yZC5kZWNsYXJlLWRlYXRoIiwicmVjb3JkLmRlY2xhcmUtbWFycmlhZ2UiLCJyZWNvcmQuZGVjbGFyYXRpb24tc3VibWl0LWluY29tcGxldGUiLCJyZWNvcmQuZGVjbGFyYXRpb24tc3VibWl0LWZvci1yZXZpZXciLCJzZWFyY2guYmlydGgiLCJzZWFyY2guZGVhdGgiLCJzZWFyY2gubWFycmlhZ2UiLCJkZW1vIl0sInVzZXJUeXBlIjoidXNlciIsImlhdCI6MTc0ODUyNjQ4OCwiZXhwIjoxNzQ5MTMxMjg4LCJhdWQiOlsib3BlbmNydnM6YXV0aC11c2VyIiwib3BlbmNydnM6dXNlci1tZ250LXVzZXIiLCJvcGVuY3J2czpoZWFydGgtdXNlciIsIm9wZW5jcnZzOmdhdGV3YXktdXNlciIsIm9wZW5jcnZzOm5vdGlmaWNhdGlvbi11c2VyIiwib3BlbmNydnM6d29ya2Zsb3ctdXNlciIsIm9wZW5jcnZzOnNlYXJjaC11c2VyIiwib3BlbmNydnM6bWV0cmljcy11c2VyIiwib3BlbmNydnM6Y291bnRyeWNvbmZpZy11c2VyIiwib3BlbmNydnM6d2ViaG9va3MtdXNlciIsIm9wZW5jcnZzOmNvbmZpZy11c2VyIiwib3BlbmNydnM6ZG9jdW1lbnRzLXVzZXIiXSwiaXNzIjoib3BlbmNydnM6YXV0aC1zZXJ2aWNlIiwic3ViIjoiNjc3ZmIwODYzMGYzYWJmYTMzMDcyNzBmIn0.qLif2TmTPpqfbSUWR3TSfWf5syyCtRRJV-fDOZBtN9th-gdT0sUPZp5PB_t2QHHCLes7JLDlSA9CGNIbVvRR8a7EedXTAf0T7pwiE96PgljHSKI9jLMCYb_rhqnl8BwfsxAU3qv8EBYM9rDlcabl5iKnAOM-YLMv63CRMQxZOZ0O3Wl1Xil82dp6PqW_Lom5Qd-Esftt9BWXk5gxmqq-YegT8qU9n3hDXEsOvmIyYQvPDwmUOB-xp74CKJk_o3eBuq4TVCMYxY-tS9qkkn2A7Txhh-bzWMVNrQjQ1Yumvs8gi_F-XYTi89QbZVz8PzJ9kT8w3jshYwmAy7be9M-EQg",
5913
+ registrationAgent: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJyZWNvcmQucmVhZCIsInJlY29yZC5kZWNsYXJlLWJpcnRoIiwicmVjb3JkLmRlY2xhcmUtZGVhdGgiLCJyZWNvcmQuZGVjbGFyZS1tYXJyaWFnZSIsInJlY29yZC5kZWNsYXJhdGlvbi1lZGl0IiwicmVjb3JkLmRlY2xhcmF0aW9uLXN1Ym1pdC1mb3ItYXBwcm92YWwiLCJyZWNvcmQuZGVjbGFyYXRpb24tc3VibWl0LWZvci11cGRhdGVzIiwicmVjb3JkLmRlY2xhcmF0aW9uLWFyY2hpdmUiLCJyZWNvcmQuZGVjbGFyYXRpb24tcmVpbnN0YXRlIiwicmVjb3JkLnJlZ2lzdHJhdGlvbi1yZXF1ZXN0LWNvcnJlY3Rpb24iLCJyZWNvcmQuZGVjbGFyYXRpb24tcHJpbnQtc3VwcG9ydGluZy1kb2N1bWVudHMiLCJyZWNvcmQuZXhwb3J0LXJlY29yZHMiLCJyZWNvcmQucmVnaXN0cmF0aW9uLXByaW50Jmlzc3VlLWNlcnRpZmllZC1jb3BpZXMiLCJwZXJmb3JtYW5jZS5yZWFkIiwicGVyZm9ybWFuY2UucmVhZC1kYXNoYm9hcmRzIiwib3JnYW5pc2F0aW9uLnJlYWQtbG9jYXRpb25zOm15LW9mZmljZSIsInNlYXJjaC5iaXJ0aCIsInNlYXJjaC5kZWF0aCIsInNlYXJjaC5tYXJyaWFnZSIsImRlbW8iXSwidXNlclR5cGUiOiJ1c2VyIiwiaWF0IjoxNzQ4NTI2NDY4LCJleHAiOjE3NDkxMzEyNjgsImF1ZCI6WyJvcGVuY3J2czphdXRoLXVzZXIiLCJvcGVuY3J2czp1c2VyLW1nbnQtdXNlciIsIm9wZW5jcnZzOmhlYXJ0aC11c2VyIiwib3BlbmNydnM6Z2F0ZXdheS11c2VyIiwib3BlbmNydnM6bm90aWZpY2F0aW9uLXVzZXIiLCJvcGVuY3J2czp3b3JrZmxvdy11c2VyIiwib3BlbmNydnM6c2VhcmNoLXVzZXIiLCJvcGVuY3J2czptZXRyaWNzLXVzZXIiLCJvcGVuY3J2czpjb3VudHJ5Y29uZmlnLXVzZXIiLCJvcGVuY3J2czp3ZWJob29rcy11c2VyIiwib3BlbmNydnM6Y29uZmlnLXVzZXIiLCJvcGVuY3J2czpkb2N1bWVudHMtdXNlciJdLCJpc3MiOiJvcGVuY3J2czphdXRoLXNlcnZpY2UiLCJzdWIiOiI2NzdmYjA4NjMwZjNhYmZhMzMwNzI3MTgifQ.C0R3cda9tczdJyadyJzk_wjVx79yiQ4r2BZbrF5VMTol97CwqMk1cPKVv5xZR1fHW5nhYl1X_vsmTYx-p9oSmcAYVud-4Z24TrA3oZ214zCB8RW_RmmFzJSczwe-9Son-96JOpRJTz2F-F_SSmblF0cjndJ-iXCAbOn1hmQ1q45NqaV-oFaFWigvAaRoBFcEvGufQxss_NjRmG12ooENSfWQl0tYM9BmTw4JQo2xerwJcgaJTrtDgRagkuiR7zhVNjcoT64AQiSRp5KmWRhbU4ozlJ2tfy1ccD9jJkbQTf1AZT2pl1diusjstJYFuM9QPFPOyCO0umaxYfgSer_Hmg",
5914
+ localRegistrar: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJyZWNvcmQucmVhZCIsInJlY29yZC5kZWNsYXJlLWJpcnRoIiwicmVjb3JkLmRlY2xhcmUtZGVhdGgiLCJyZWNvcmQuZGVjbGFyZS1tYXJyaWFnZSIsInJlY29yZC5kZWNsYXJhdGlvbi1lZGl0IiwicmVjb3JkLmRlY2xhcmF0aW9uLXN1Ym1pdC1mb3ItdXBkYXRlcyIsInJlY29yZC5yZXZpZXctZHVwbGljYXRlcyIsInJlY29yZC5kZWNsYXJhdGlvbi1hcmNoaXZlIiwicmVjb3JkLmRlY2xhcmF0aW9uLXJlaW5zdGF0ZSIsInJlY29yZC5yZWdpc3RlciIsInJlY29yZC5yZWdpc3RyYXRpb24tY29ycmVjdCIsInJlY29yZC5kZWNsYXJhdGlvbi1wcmludC1zdXBwb3J0aW5nLWRvY3VtZW50cyIsInJlY29yZC5leHBvcnQtcmVjb3JkcyIsInJlY29yZC51bmFzc2lnbi1vdGhlcnMiLCJyZWNvcmQucmVnaXN0cmF0aW9uLXByaW50Jmlzc3VlLWNlcnRpZmllZC1jb3BpZXMiLCJyZWNvcmQuY29uZmlybS1yZWdpc3RyYXRpb24iLCJyZWNvcmQucmVqZWN0LXJlZ2lzdHJhdGlvbiIsInBlcmZvcm1hbmNlLnJlYWQiLCJwZXJmb3JtYW5jZS5yZWFkLWRhc2hib2FyZHMiLCJwcm9maWxlLmVsZWN0cm9uaWMtc2lnbmF0dXJlIiwib3JnYW5pc2F0aW9uLnJlYWQtbG9jYXRpb25zOm15LW9mZmljZSIsInNlYXJjaC5iaXJ0aCIsInNlYXJjaC5kZWF0aCIsInNlYXJjaC5tYXJyaWFnZSIsImRlbW8iXSwidXNlclR5cGUiOiJ1c2VyIiwiaWF0IjoxNzQ4NTI2NDIwLCJleHAiOjE3NDkxMzEyMjAsImF1ZCI6WyJvcGVuY3J2czphdXRoLXVzZXIiLCJvcGVuY3J2czp1c2VyLW1nbnQtdXNlciIsIm9wZW5jcnZzOmhlYXJ0aC11c2VyIiwib3BlbmNydnM6Z2F0ZXdheS11c2VyIiwib3BlbmNydnM6bm90aWZpY2F0aW9uLXVzZXIiLCJvcGVuY3J2czp3b3JrZmxvdy11c2VyIiwib3BlbmNydnM6c2VhcmNoLXVzZXIiLCJvcGVuY3J2czptZXRyaWNzLXVzZXIiLCJvcGVuY3J2czpjb3VudHJ5Y29uZmlnLXVzZXIiLCJvcGVuY3J2czp3ZWJob29rcy11c2VyIiwib3BlbmNydnM6Y29uZmlnLXVzZXIiLCJvcGVuY3J2czpkb2N1bWVudHMtdXNlciJdLCJpc3MiOiJvcGVuY3J2czphdXRoLXNlcnZpY2UiLCJzdWIiOiI2NzdmYjA4NjMwZjNhYmZhMzMwNzI3MjEifQ.Exwojy_1lsoPmp-kQ79SMWI0eQy8Qt7yO_ynGvb_oIVdqSwTxFkkNr9x4UxhBA-o0P6LkMZ2ELKOlSzBr3PRJ8IQnfMQ7Db8oG8HAPsY8sKqra_L6ryV088NW2e2LqAjoOX0dXRIqYMolUhF_OOuZpHW5K8nvog5SLlnJ1gKysQ1EuWBg2dcKbjkkB16v-9NGz4XHye3vcoZlalyha5OOujzbPhkmr9UGiksSIXFNbanBhkQdt-EJlLX9SXvQ4ACJWPKFb_f4gv8p84jdLiryzQux46zHPpTicZHzg0nZtoKKIH1AyFtqWfBFm4y8qWC3ht9TAk93NAXTfkS0wzxKA"
5915
+ };
5916
+ var generateWorkqueues = (slug = "all-events") => defineWorkqueues([
5917
+ {
5918
+ slug,
5919
+ name: {
5920
+ id: "workqueues.inProgress.title",
5921
+ defaultMessage: slug.charAt(0).toUpperCase() + slug.slice(1).split("-").join(" "),
5922
+ description: "Title of in progress workqueue"
5923
+ },
5924
+ query: {
5925
+ type: "and",
5926
+ clauses: [{ eventType: tennisClubMembershipEvent.id }]
5927
+ },
5928
+ actions: [],
5929
+ icon: "Draft",
5930
+ columns: []
5931
+ }
5932
+ ]);
4993
5933
 
4994
5934
  // ../commons/src/events/TemplateConfig.ts
4995
5935
  function isTemplateVariable(value) {
@@ -5027,7 +5967,7 @@ function isFieldConfigDefaultValue(value) {
5027
5967
  var import_lodash3 = require("lodash");
5028
5968
 
5029
5969
  // ../commons/src/scopes.ts
5030
- var import_zod25 = require("zod");
5970
+ var import_zod31 = require("zod");
5031
5971
  var SCOPES = {
5032
5972
  // TODO v1.8 legacy scopes
5033
5973
  NATLSYSADMIN: "natlsysadmin",
@@ -5140,111 +6080,111 @@ var SCOPES = {
5140
6080
  // data seeding
5141
6081
  USER_DATA_SEEDING: "user.data-seeding"
5142
6082
  };
5143
- var LiteralScopes = import_zod25.z.union([
5144
- import_zod25.z.literal(SCOPES.NATLSYSADMIN),
5145
- import_zod25.z.literal(SCOPES.BYPASSRATELIMIT),
5146
- import_zod25.z.literal(SCOPES.DECLARE),
5147
- import_zod25.z.literal(SCOPES.REGISTER),
5148
- import_zod25.z.literal(SCOPES.VALIDATE),
5149
- import_zod25.z.literal(SCOPES.DEMO),
5150
- import_zod25.z.literal(SCOPES.CERTIFY),
5151
- import_zod25.z.literal(SCOPES.PERFORMANCE),
5152
- import_zod25.z.literal(SCOPES.SYSADMIN),
5153
- import_zod25.z.literal(SCOPES.TEAMS),
5154
- import_zod25.z.literal(SCOPES.CONFIG),
5155
- import_zod25.z.literal(SCOPES.WEBHOOK),
5156
- import_zod25.z.literal(SCOPES.NATIONALID),
5157
- import_zod25.z.literal(SCOPES.NOTIFICATION_API),
5158
- import_zod25.z.literal(SCOPES.RECORDSEARCH),
5159
- import_zod25.z.literal(SCOPES.RECORD_IMPORT),
5160
- import_zod25.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
5161
- import_zod25.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
5162
- import_zod25.z.literal(SCOPES.RECORD_DECLARE_DEATH),
5163
- import_zod25.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
5164
- import_zod25.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
5165
- import_zod25.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
5166
- import_zod25.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
5167
- import_zod25.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW),
5168
- import_zod25.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS),
5169
- import_zod25.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
5170
- import_zod25.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
5171
- import_zod25.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
5172
- import_zod25.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
5173
- import_zod25.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
5174
- import_zod25.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE),
5175
- import_zod25.z.literal(SCOPES.RECORD_REGISTER),
5176
- import_zod25.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
5177
- import_zod25.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
5178
- import_zod25.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
5179
- import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
5180
- import_zod25.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
5181
- import_zod25.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
5182
- import_zod25.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
5183
- import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES),
5184
- import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
5185
- import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
5186
- import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
5187
- import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
5188
- import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
5189
- import_zod25.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
5190
- import_zod25.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
5191
- import_zod25.z.literal(SCOPES.RECORD_REJECT_REGISTRATION),
5192
- import_zod25.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
5193
- import_zod25.z.literal(SCOPES.SEARCH_BIRTH),
5194
- import_zod25.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
5195
- import_zod25.z.literal(SCOPES.SEARCH_DEATH),
5196
- import_zod25.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
5197
- import_zod25.z.literal(SCOPES.SEARCH_MARRIAGE),
5198
- import_zod25.z.literal(SCOPES.RECORD_READ),
5199
- import_zod25.z.literal(SCOPES.RECORD_READ_AUDIT),
5200
- import_zod25.z.literal(SCOPES.RECORD_READ_COMMENTS),
5201
- import_zod25.z.literal(SCOPES.RECORD_CREATE_COMMENTS),
5202
- import_zod25.z.literal(SCOPES.PROFILE_UPDATE),
5203
- import_zod25.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE),
5204
- import_zod25.z.literal(SCOPES.PERFORMANCE_READ),
5205
- import_zod25.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
5206
- import_zod25.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS),
5207
- import_zod25.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
5208
- import_zod25.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
5209
- import_zod25.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION),
5210
- import_zod25.z.literal(SCOPES.USER_READ),
5211
- import_zod25.z.literal(SCOPES.USER_READ_MY_OFFICE),
5212
- import_zod25.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
5213
- import_zod25.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
5214
- import_zod25.z.literal(SCOPES.USER_CREATE),
5215
- import_zod25.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
5216
- import_zod25.z.literal(SCOPES.USER_UPDATE),
5217
- import_zod25.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION),
5218
- import_zod25.z.literal(SCOPES.CONFIG_UPDATE_ALL),
5219
- import_zod25.z.literal(SCOPES.USER_DATA_SEEDING)
6083
+ var LiteralScopes = import_zod31.z.union([
6084
+ import_zod31.z.literal(SCOPES.NATLSYSADMIN),
6085
+ import_zod31.z.literal(SCOPES.BYPASSRATELIMIT),
6086
+ import_zod31.z.literal(SCOPES.DECLARE),
6087
+ import_zod31.z.literal(SCOPES.REGISTER),
6088
+ import_zod31.z.literal(SCOPES.VALIDATE),
6089
+ import_zod31.z.literal(SCOPES.DEMO),
6090
+ import_zod31.z.literal(SCOPES.CERTIFY),
6091
+ import_zod31.z.literal(SCOPES.PERFORMANCE),
6092
+ import_zod31.z.literal(SCOPES.SYSADMIN),
6093
+ import_zod31.z.literal(SCOPES.TEAMS),
6094
+ import_zod31.z.literal(SCOPES.CONFIG),
6095
+ import_zod31.z.literal(SCOPES.WEBHOOK),
6096
+ import_zod31.z.literal(SCOPES.NATIONALID),
6097
+ import_zod31.z.literal(SCOPES.NOTIFICATION_API),
6098
+ import_zod31.z.literal(SCOPES.RECORDSEARCH),
6099
+ import_zod31.z.literal(SCOPES.RECORD_IMPORT),
6100
+ import_zod31.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
6101
+ import_zod31.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
6102
+ import_zod31.z.literal(SCOPES.RECORD_DECLARE_DEATH),
6103
+ import_zod31.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
6104
+ import_zod31.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
6105
+ import_zod31.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
6106
+ import_zod31.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
6107
+ import_zod31.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW),
6108
+ import_zod31.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS),
6109
+ import_zod31.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
6110
+ import_zod31.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
6111
+ import_zod31.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
6112
+ import_zod31.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
6113
+ import_zod31.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
6114
+ import_zod31.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE),
6115
+ import_zod31.z.literal(SCOPES.RECORD_REGISTER),
6116
+ import_zod31.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
6117
+ import_zod31.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
6118
+ import_zod31.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
6119
+ import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
6120
+ import_zod31.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
6121
+ import_zod31.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
6122
+ import_zod31.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
6123
+ import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES),
6124
+ import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
6125
+ import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
6126
+ import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
6127
+ import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
6128
+ import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
6129
+ import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
6130
+ import_zod31.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
6131
+ import_zod31.z.literal(SCOPES.RECORD_REJECT_REGISTRATION),
6132
+ import_zod31.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
6133
+ import_zod31.z.literal(SCOPES.SEARCH_BIRTH),
6134
+ import_zod31.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
6135
+ import_zod31.z.literal(SCOPES.SEARCH_DEATH),
6136
+ import_zod31.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
6137
+ import_zod31.z.literal(SCOPES.SEARCH_MARRIAGE),
6138
+ import_zod31.z.literal(SCOPES.RECORD_READ),
6139
+ import_zod31.z.literal(SCOPES.RECORD_READ_AUDIT),
6140
+ import_zod31.z.literal(SCOPES.RECORD_READ_COMMENTS),
6141
+ import_zod31.z.literal(SCOPES.RECORD_CREATE_COMMENTS),
6142
+ import_zod31.z.literal(SCOPES.PROFILE_UPDATE),
6143
+ import_zod31.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE),
6144
+ import_zod31.z.literal(SCOPES.PERFORMANCE_READ),
6145
+ import_zod31.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
6146
+ import_zod31.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS),
6147
+ import_zod31.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
6148
+ import_zod31.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
6149
+ import_zod31.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION),
6150
+ import_zod31.z.literal(SCOPES.USER_READ),
6151
+ import_zod31.z.literal(SCOPES.USER_READ_MY_OFFICE),
6152
+ import_zod31.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
6153
+ import_zod31.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
6154
+ import_zod31.z.literal(SCOPES.USER_CREATE),
6155
+ import_zod31.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
6156
+ import_zod31.z.literal(SCOPES.USER_UPDATE),
6157
+ import_zod31.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION),
6158
+ import_zod31.z.literal(SCOPES.CONFIG_UPDATE_ALL),
6159
+ import_zod31.z.literal(SCOPES.USER_DATA_SEEDING)
5220
6160
  ]);
5221
6161
  var rawConfigurableScopeRegex = /^([a-zA-Z\.]+)\[((?:\w+=[\w.-]+(?:\|[\w.-]+)*)(?:,[\w]+=[\w.-]+(?:\|[\w.-]+)*)*)\]$/;
5222
- var rawConfigurableScope = import_zod25.z.string().regex(rawConfigurableScopeRegex);
5223
- var CreateUserScope = import_zod25.z.object({
5224
- type: import_zod25.z.literal("user.create"),
5225
- options: import_zod25.z.object({
5226
- role: import_zod25.z.array(import_zod25.z.string())
6162
+ var rawConfigurableScope = import_zod31.z.string().regex(rawConfigurableScopeRegex);
6163
+ var CreateUserScope = import_zod31.z.object({
6164
+ type: import_zod31.z.literal("user.create"),
6165
+ options: import_zod31.z.object({
6166
+ role: import_zod31.z.array(import_zod31.z.string())
5227
6167
  })
5228
6168
  });
5229
- var EditUserScope = import_zod25.z.object({
5230
- type: import_zod25.z.literal("user.edit"),
5231
- options: import_zod25.z.object({
5232
- role: import_zod25.z.array(import_zod25.z.string())
6169
+ var EditUserScope = import_zod31.z.object({
6170
+ type: import_zod31.z.literal("user.edit"),
6171
+ options: import_zod31.z.object({
6172
+ role: import_zod31.z.array(import_zod31.z.string())
5233
6173
  })
5234
6174
  });
5235
- var WorkqueueScope = import_zod25.z.object({
5236
- type: import_zod25.z.literal("workqueue"),
5237
- options: import_zod25.z.object({
5238
- id: import_zod25.z.array(import_zod25.z.string())
6175
+ var WorkqueueScope = import_zod31.z.object({
6176
+ type: import_zod31.z.literal("workqueue"),
6177
+ options: import_zod31.z.object({
6178
+ id: import_zod31.z.array(import_zod31.z.string())
5239
6179
  })
5240
6180
  });
5241
- var NotifyRecordScope = import_zod25.z.object({
5242
- type: import_zod25.z.literal("record.notify"),
5243
- options: import_zod25.z.object({
5244
- event: import_zod25.z.array(import_zod25.z.string())
6181
+ var NotifyRecordScope = import_zod31.z.object({
6182
+ type: import_zod31.z.literal("record.notify"),
6183
+ options: import_zod31.z.object({
6184
+ event: import_zod31.z.array(import_zod31.z.string())
5245
6185
  })
5246
6186
  });
5247
- var ConfigurableScopes = import_zod25.z.discriminatedUnion("type", [
6187
+ var ConfigurableScopes = import_zod31.z.discriminatedUnion("type", [
5248
6188
  CreateUserScope,
5249
6189
  EditUserScope,
5250
6190
  WorkqueueScope,
@@ -5348,3 +6288,65 @@ function filterUnallowedActions(actions, userScopes) {
5348
6288
  }
5349
6289
  return [ActionType.READ];
5350
6290
  }
6291
+
6292
+ // ../commons/src/events/serializers/user/deserializer.ts
6293
+ var import_zod32 = require("zod");
6294
+ var UserWithPrimaryOffice = User.extend({
6295
+ primaryOfficeId: import_zod32.z.string()
6296
+ });
6297
+ function userDeserializer(serializedUserField, user2) {
6298
+ if (typeof serializedUserField === "string") {
6299
+ return serializedUserField;
6300
+ }
6301
+ if (serializedUserField.$userField === "name" || serializedUserField.$userField === "signatureFilename") {
6302
+ throw new Error(
6303
+ `Deserializer for ${serializedUserField.$userField} is not implemented yet`
6304
+ );
6305
+ }
6306
+ return user2[serializedUserField.$userField];
6307
+ }
6308
+ function deserializeQueryExpression(expression, user2) {
6309
+ return {
6310
+ ...expression,
6311
+ assignedTo: expression.assignedTo && {
6312
+ ...expression.assignedTo,
6313
+ term: userDeserializer(expression.assignedTo.term, user2)
6314
+ },
6315
+ createdBy: expression.createdBy && {
6316
+ ...expression.createdBy,
6317
+ term: userDeserializer(expression.createdBy.term, user2)
6318
+ },
6319
+ updatedBy: expression.updatedBy && {
6320
+ ...expression.updatedBy,
6321
+ term: userDeserializer(expression.updatedBy.term, user2)
6322
+ },
6323
+ createdAtLocation: expression.createdAtLocation && (expression.createdAtLocation.type === "within" ? {
6324
+ ...expression.createdAtLocation,
6325
+ location: userDeserializer(
6326
+ expression.createdAtLocation.location,
6327
+ user2
6328
+ )
6329
+ } : {
6330
+ ...expression.createdAtLocation,
6331
+ term: userDeserializer(expression.createdAtLocation.term, user2)
6332
+ }),
6333
+ updatedAtLocation: expression.updatedAtLocation && (expression.updatedAtLocation.type === "within" ? {
6334
+ ...expression.updatedAtLocation,
6335
+ location: userDeserializer(
6336
+ expression.updatedAtLocation.location,
6337
+ user2
6338
+ )
6339
+ } : {
6340
+ ...expression.updatedAtLocation,
6341
+ term: userDeserializer(expression.updatedAtLocation.term, user2)
6342
+ })
6343
+ };
6344
+ }
6345
+ function deserializeQuery(query, user2) {
6346
+ return {
6347
+ ...query,
6348
+ clauses: query.clauses.map(
6349
+ (clause) => deserializeQueryExpression(clause, user2)
6350
+ )
6351
+ };
6352
+ }