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

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.
@@ -50,6 +50,8 @@ __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,
@@ -68,6 +70,7 @@ __export(events_exports, {
68
70
  DEFAULT_DATE_OF_EVENT_PROPERTY: () => DEFAULT_DATE_OF_EVENT_PROPERTY,
69
71
  DataEntry: () => DataEntry,
70
72
  DataFieldValue: () => DataFieldValue,
73
+ DateCondition: () => DateCondition,
71
74
  DateRangeFieldValue: () => DateRangeFieldValue,
72
75
  DateValue: () => DateValue,
73
76
  DatetimeValue: () => DatetimeValue,
@@ -93,12 +96,14 @@ __export(events_exports, {
93
96
  EventInput: () => EventInput,
94
97
  EventMetadata: () => EventMetadata,
95
98
  EventMetadataKeys: () => EventMetadataKeys,
96
- EventMetadataParameter: () => EventMetadataParameter,
99
+ EventMetadataKeysArray: () => EventMetadataKeysArray,
97
100
  EventSearchIndex: () => EventSearchIndex,
98
101
  EventState: () => EventState,
99
102
  EventStatus: () => EventStatus,
100
103
  EventStatusEnum: () => EventStatusEnum,
101
104
  EventStatuses: () => EventStatuses,
105
+ Exact: () => Exact,
106
+ ExactStatus: () => ExactStatus,
102
107
  FieldConditional: () => FieldConditional,
103
108
  FieldConfig: () => FieldConfig,
104
109
  FieldConfigSchema: () => FieldConfigSchema,
@@ -111,6 +116,7 @@ __export(events_exports, {
111
116
  Flag: () => Flag,
112
117
  FormConfig: () => FormConfig,
113
118
  FormPageConfig: () => FormPageConfig,
119
+ Fuzzy: () => Fuzzy,
114
120
  GenericAddressUpdateValue: () => GenericAddressUpdateValue,
115
121
  GenericAddressValue: () => GenericAddressValue,
116
122
  GeographicalArea: () => GeographicalArea,
@@ -120,19 +126,23 @@ __export(events_exports, {
120
126
  MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
121
127
  MimeType: () => MimeType,
122
128
  NonEmptyTextValue: () => NonEmptyTextValue,
129
+ Not: () => Not,
123
130
  NotifyActionInput: () => NotifyActionInput,
124
131
  NumberFieldValue: () => NumberFieldValue,
125
132
  PageConfig: () => PageConfig,
126
133
  PageTypes: () => PageTypes,
127
134
  PrintCertificateActionInput: () => PrintCertificateActionInput,
135
+ QueryExpression: () => QueryExpression,
128
136
  QueryInput: () => QueryInput,
129
137
  QueryType: () => QueryType,
138
+ Range: () => Range,
130
139
  ReadActionInput: () => ReadActionInput,
131
140
  RegisterAction: () => RegisterAction,
132
141
  RegisterActionInput: () => RegisterActionInput,
133
142
  RegistrationCreationMetadata: () => RegistrationCreationMetadata,
134
143
  RejectCorrectionActionInput: () => RejectCorrectionActionInput,
135
144
  RejectDeclarationActionInput: () => RejectDeclarationActionInput,
145
+ RejectionReason: () => RejectionReason,
136
146
  RequestCorrectionActionInput: () => RequestCorrectionActionInput,
137
147
  ResolvedUser: () => ResolvedUser,
138
148
  RuralAddressUpdateValue: () => RuralAddressUpdateValue,
@@ -142,15 +152,25 @@ __export(events_exports, {
142
152
  SelectOption: () => SelectOption,
143
153
  ShowConditional: () => ShowConditional,
144
154
  SummaryConfig: () => SummaryConfig,
155
+ TENNIS_CLUB_MEMBERSHIP: () => TENNIS_CLUB_MEMBERSHIP,
145
156
  TextValue: () => TextValue,
146
157
  TranslationConfig: () => TranslationConfig,
147
158
  UnassignActionInput: () => UnassignActionInput,
148
159
  UrbanAddressUpdateValue: () => UrbanAddressUpdateValue,
149
160
  UrbanAddressValue: () => UrbanAddressValue,
161
+ User: () => User,
150
162
  ValidateActionInput: () => ValidateActionInput,
151
163
  VerificationActionConfig: () => VerificationActionConfig,
152
164
  VerificationPageConfig: () => VerificationPageConfig,
165
+ Within: () => Within,
166
+ WorkqueueColumn: () => WorkqueueColumn,
167
+ WorkqueueColumnKeys: () => WorkqueueColumnKeys,
168
+ WorkqueueColumnKeysArray: () => WorkqueueColumnKeysArray,
169
+ WorkqueueColumnValue: () => WorkqueueColumnValue,
153
170
  WorkqueueConfig: () => WorkqueueConfig,
171
+ WorkqueueConfigInput: () => WorkqueueConfigInput,
172
+ WorkqueueCountInput: () => WorkqueueCountInput,
173
+ WorkqueueCountOutput: () => WorkqueueCountOutput,
154
174
  ZodDate: () => ZodDate,
155
175
  alwaysTrue: () => alwaysTrue,
156
176
  and: () => and,
@@ -162,8 +182,10 @@ __export(events_exports, {
162
182
  createEventConditionals: () => createEventConditionals,
163
183
  createFieldConditionals: () => createFieldConditionals,
164
184
  createValidationSchema: () => createValidationSchema,
185
+ dateOfEventColumn: () => dateOfEventColumn,
165
186
  deepDropNulls: () => deepDropNulls,
166
187
  deepMerge: () => deepMerge,
188
+ defaultWorkqueueColumns: () => defaultWorkqueueColumns,
167
189
  defineActionForm: () => defineActionForm,
168
190
  defineConditional: () => defineConditional,
169
191
  defineConfig: () => defineConfig,
@@ -172,6 +194,9 @@ __export(events_exports, {
172
194
  defineFormPage: () => defineFormPage,
173
195
  definePage: () => definePage,
174
196
  defineWorkqueue: () => defineWorkqueue,
197
+ defineWorkqueues: () => defineWorkqueues,
198
+ defineWorkqueuesColumns: () => defineWorkqueuesColumns,
199
+ deserializeQuery: () => deserializeQuery,
175
200
  errorMessages: () => errorMessages,
176
201
  event: () => event,
177
202
  eventMetadataLabelMap: () => eventMetadataLabelMap,
@@ -192,6 +217,7 @@ __export(events_exports, {
192
217
  generateEventDraftDocument: () => generateEventDraftDocument,
193
218
  generateTransactionId: () => generateTransactionId,
194
219
  generateTranslationConfig: () => generateTranslationConfig,
220
+ generateWorkqueues: () => generateWorkqueues,
195
221
  getAcceptedActions: () => getAcceptedActions,
196
222
  getActionAnnotation: () => getActionAnnotation,
197
223
  getActionAnnotationFields: () => getActionAnnotationFields,
@@ -206,6 +232,8 @@ __export(events_exports, {
206
232
  getDeclarationFields: () => getDeclarationFields,
207
233
  getDeclarationPages: () => getDeclarationPages,
208
234
  getMixedPath: () => getMixedPath,
235
+ getRandomDatetime: () => getRandomDatetime,
236
+ getStatusFromActions: () => getStatusFromActions,
209
237
  getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
210
238
  hasAnyOfScopes: () => hasAnyOfScopes,
211
239
  isAddressFieldType: () => isAddressFieldType,
@@ -260,6 +288,9 @@ __export(events_exports, {
260
288
  });
261
289
  module.exports = __toCommonJS(events_exports);
262
290
 
291
+ // ../commons/src/events/Constants.ts
292
+ var TENNIS_CLUB_MEMBERSHIP = "tennis-club-membership";
293
+
263
294
  // ../commons/src/events/ActionConfig.ts
264
295
  var import_zod9 = require("zod");
265
296
 
@@ -909,6 +940,12 @@ var ActionConfigBase = import_zod9.z.object({
909
940
  conditionals: import_zod9.z.array(ActionConditional2).optional().default([]),
910
941
  draft: import_zod9.z.boolean().optional()
911
942
  });
943
+ var ReadActionConfig = ActionConfigBase.merge(
944
+ import_zod9.z.object({
945
+ type: import_zod9.z.literal(ActionType.READ),
946
+ review: DeclarationReviewConfig
947
+ })
948
+ );
912
949
  var DeclareConfig = ActionConfigBase.merge(
913
950
  import_zod9.z.object({
914
951
  type: import_zod9.z.literal(ActionType.DECLARE),
@@ -975,6 +1012,7 @@ var ActionConfig = import_zod9.z.discriminatedUnion("type", [
975
1012
  * OpenAPI references are defined here so our generated OpenAPI spec knows to reuse the models
976
1013
  * and treat them as "models" instead of duplicating the data structure in each endpoint.
977
1014
  */
1015
+ ReadActionConfig.openapi({ ref: "ReadActionConfig" }),
978
1016
  DeclareConfig.openapi({ ref: "DeclareActionConfig" }),
979
1017
  ValidateConfig.openapi({ ref: "ValidateActionConfig" }),
980
1018
  RejectDeclarationConfig.openapi({ ref: "RejectDeclarationActionConfig" }),
@@ -1032,7 +1070,7 @@ var LanguageConfig = import_zod11.z.object({
1032
1070
  });
1033
1071
 
1034
1072
  // ../commons/src/events/EventConfig.ts
1035
- var import_zod17 = require("zod");
1073
+ var import_zod18 = require("zod");
1036
1074
 
1037
1075
  // ../commons/src/events/DeduplicationConfig.ts
1038
1076
  var import_zod12 = require("zod");
@@ -1207,114 +1245,133 @@ var AdvancedSearchConfig = import_zod14.z.object({
1207
1245
  var import_lodash = require("lodash");
1208
1246
 
1209
1247
  // ../commons/src/events/ActionDocument.ts
1210
- var import_zod15 = require("zod");
1248
+ var import_zod16 = require("zod");
1211
1249
  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);
1250
+
1251
+ // ../commons/src/uuid.ts
1252
+ var import_uuid = require("uuid");
1253
+ var import_zod15 = require("zod");
1254
+ var UUID = import_zod15.z.string().uuid().brand("UUID");
1255
+ function getUUID() {
1256
+ return (0, import_uuid.v4)();
1257
+ }
1258
+
1259
+ // ../commons/src/events/CreatedAtLocation.ts
1260
+ var CreatedAtLocation = UUID.nullish();
1261
+
1262
+ // ../commons/src/events/ActionDocument.ts
1263
+ (0, import_zod_openapi7.extendZodWithOpenApi)(import_zod16.z);
1264
+ var ActionUpdate = import_zod16.z.record(import_zod16.z.string(), FieldUpdateValue);
1265
+ var EventState = import_zod16.z.record(import_zod16.z.string(), FieldValue);
1215
1266
  var ActionStatus = {
1216
1267
  Requested: "Requested",
1217
1268
  Accepted: "Accepted",
1218
1269
  Rejected: "Rejected"
1219
1270
  };
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(),
1271
+ var ActionBase = import_zod16.z.object({
1272
+ id: import_zod16.z.string(),
1273
+ transactionId: import_zod16.z.string(),
1274
+ createdAt: import_zod16.z.string().datetime(),
1275
+ createdBy: import_zod16.z.string(),
1276
+ createdByRole: import_zod16.z.string(),
1277
+ createdAtLocation: CreatedAtLocation,
1226
1278
  declaration: ActionUpdate,
1227
- annotation: ActionUpdate.optional(),
1228
- createdAtLocation: import_zod15.z.string(),
1229
- status: import_zod15.z.enum([
1279
+ annotation: ActionUpdate.optional().nullable(),
1280
+ status: import_zod16.z.enum([
1230
1281
  ActionStatus.Requested,
1231
1282
  ActionStatus.Accepted,
1232
1283
  ActionStatus.Rejected
1233
1284
  ]),
1234
1285
  // 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()
1286
+ originalActionId: UUID.optional().nullable()
1236
1287
  });
1237
1288
  var AssignedAction = ActionBase.merge(
1238
- import_zod15.z.object({
1239
- type: import_zod15.z.literal(ActionType.ASSIGN),
1240
- assignedTo: import_zod15.z.string()
1289
+ import_zod16.z.object({
1290
+ type: import_zod16.z.literal(ActionType.ASSIGN),
1291
+ assignedTo: import_zod16.z.string()
1241
1292
  })
1242
1293
  );
1243
1294
  var UnassignedAction = ActionBase.merge(
1244
- import_zod15.z.object({
1245
- type: import_zod15.z.literal(ActionType.UNASSIGN),
1246
- assignedTo: import_zod15.z.literal(null)
1295
+ import_zod16.z.object({
1296
+ type: import_zod16.z.literal(ActionType.UNASSIGN),
1297
+ assignedTo: import_zod16.z.literal(null)
1247
1298
  })
1248
1299
  );
1249
1300
  var RegisterAction = ActionBase.merge(
1250
- import_zod15.z.object({
1251
- type: import_zod15.z.literal(ActionType.REGISTER),
1252
- registrationNumber: import_zod15.z.string().optional()
1301
+ import_zod16.z.object({
1302
+ type: import_zod16.z.literal(ActionType.REGISTER),
1303
+ registrationNumber: import_zod16.z.string().optional()
1253
1304
  })
1254
1305
  );
1255
1306
  var DeclareAction = ActionBase.merge(
1256
- import_zod15.z.object({
1257
- type: import_zod15.z.literal(ActionType.DECLARE)
1307
+ import_zod16.z.object({
1308
+ type: import_zod16.z.literal(ActionType.DECLARE)
1258
1309
  })
1259
1310
  );
1260
1311
  var ValidateAction = ActionBase.merge(
1261
- import_zod15.z.object({
1262
- type: import_zod15.z.literal(ActionType.VALIDATE)
1312
+ import_zod16.z.object({
1313
+ type: import_zod16.z.literal(ActionType.VALIDATE)
1263
1314
  })
1264
1315
  );
1316
+ var RejectionReason = import_zod16.z.object({
1317
+ message: import_zod16.z.string().min(1, { message: "Message cannot be empty" }).describe("Message describing reason for rejection or archiving"),
1318
+ isDuplicate: import_zod16.z.boolean().optional().describe("If a declaration is duplicated")
1319
+ });
1265
1320
  var RejectAction = ActionBase.merge(
1266
- import_zod15.z.object({
1267
- type: import_zod15.z.literal(ActionType.REJECT)
1321
+ import_zod16.z.object({
1322
+ type: import_zod16.z.literal(ActionType.REJECT),
1323
+ reason: RejectionReason
1268
1324
  })
1269
1325
  );
1270
1326
  var MarkAsDuplicateAction = ActionBase.merge(
1271
- import_zod15.z.object({
1272
- type: import_zod15.z.literal(ActionType.MARKED_AS_DUPLICATE)
1327
+ import_zod16.z.object({
1328
+ type: import_zod16.z.literal(ActionType.MARKED_AS_DUPLICATE)
1273
1329
  })
1274
1330
  );
1275
1331
  var ArchiveAction = ActionBase.merge(
1276
- import_zod15.z.object({
1277
- type: import_zod15.z.literal(ActionType.ARCHIVE)
1332
+ import_zod16.z.object({
1333
+ type: import_zod16.z.literal(ActionType.ARCHIVE),
1334
+ reason: RejectionReason
1278
1335
  })
1279
1336
  );
1280
1337
  var CreatedAction = ActionBase.merge(
1281
- import_zod15.z.object({
1282
- type: import_zod15.z.literal(ActionType.CREATE)
1338
+ import_zod16.z.object({
1339
+ type: import_zod16.z.literal(ActionType.CREATE)
1283
1340
  })
1284
1341
  );
1285
1342
  var NotifiedAction = ActionBase.merge(
1286
- import_zod15.z.object({
1287
- type: import_zod15.z.literal(ActionType.NOTIFY)
1343
+ import_zod16.z.object({
1344
+ type: import_zod16.z.literal(ActionType.NOTIFY)
1288
1345
  })
1289
1346
  );
1290
1347
  var PrintCertificateAction = ActionBase.merge(
1291
- import_zod15.z.object({
1292
- type: import_zod15.z.literal(ActionType.PRINT_CERTIFICATE)
1348
+ import_zod16.z.object({
1349
+ type: import_zod16.z.literal(ActionType.PRINT_CERTIFICATE)
1293
1350
  })
1294
1351
  );
1295
1352
  var RequestedCorrectionAction = ActionBase.merge(
1296
- import_zod15.z.object({
1297
- type: import_zod15.z.literal(ActionType.REQUEST_CORRECTION)
1353
+ import_zod16.z.object({
1354
+ type: import_zod16.z.literal(ActionType.REQUEST_CORRECTION)
1298
1355
  })
1299
1356
  );
1300
1357
  var ApprovedCorrectionAction = ActionBase.merge(
1301
- import_zod15.z.object({
1302
- type: import_zod15.z.literal(ActionType.APPROVE_CORRECTION),
1303
- requestId: import_zod15.z.string()
1358
+ import_zod16.z.object({
1359
+ type: import_zod16.z.literal(ActionType.APPROVE_CORRECTION),
1360
+ requestId: import_zod16.z.string()
1304
1361
  })
1305
1362
  );
1306
1363
  var RejectedCorrectionAction = ActionBase.merge(
1307
- import_zod15.z.object({
1308
- type: import_zod15.z.literal(ActionType.REJECT_CORRECTION),
1309
- requestId: import_zod15.z.string()
1364
+ import_zod16.z.object({
1365
+ type: import_zod16.z.literal(ActionType.REJECT_CORRECTION),
1366
+ requestId: import_zod16.z.string()
1310
1367
  })
1311
1368
  );
1312
1369
  var ReadAction = ActionBase.merge(
1313
- import_zod15.z.object({
1314
- type: import_zod15.z.literal(ActionType.READ)
1370
+ import_zod16.z.object({
1371
+ type: import_zod16.z.literal(ActionType.READ)
1315
1372
  })
1316
1373
  );
1317
- var ActionDocument = import_zod15.z.discriminatedUnion("type", [
1374
+ var ActionDocument = import_zod16.z.discriminatedUnion("type", [
1318
1375
  CreatedAction.openapi({ ref: "CreatedAction" }),
1319
1376
  ValidateAction.openapi({ ref: "ValidateAction" }),
1320
1377
  RejectAction.openapi({ ref: "RejectAction" }),
@@ -1337,20 +1394,20 @@ var AsyncRejectActionDocument = ActionBase.omit({
1337
1394
  declaration: true,
1338
1395
  annotation: true
1339
1396
  }).merge(
1340
- import_zod15.z.object({
1341
- type: import_zod15.z.enum(ConfirmableActions),
1342
- status: import_zod15.z.literal(ActionStatus.Rejected)
1397
+ import_zod16.z.object({
1398
+ type: import_zod16.z.enum(ConfirmableActions),
1399
+ status: import_zod16.z.literal(ActionStatus.Rejected)
1343
1400
  })
1344
1401
  );
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()
1402
+ var Action = import_zod16.z.union([ActionDocument, AsyncRejectActionDocument]);
1403
+ var ResolvedUser = import_zod16.z.object({
1404
+ id: import_zod16.z.string(),
1405
+ role: import_zod16.z.string(),
1406
+ name: import_zod16.z.array(
1407
+ import_zod16.z.object({
1408
+ use: import_zod16.z.string(),
1409
+ given: import_zod16.z.array(import_zod16.z.string()),
1410
+ family: import_zod16.z.string()
1354
1411
  })
1355
1412
  )
1356
1413
  });
@@ -1361,7 +1418,7 @@ var import_ajv_formats = __toESM(require("ajv-formats"));
1361
1418
  var import_date_fns = require("date-fns");
1362
1419
 
1363
1420
  // ../commons/src/events/FieldTypeMapping.ts
1364
- var import_zod16 = require("zod");
1421
+ var import_zod17 = require("zod");
1365
1422
  function mapFieldTypeToZod(type, required) {
1366
1423
  let schema;
1367
1424
  switch (type) {
@@ -1416,7 +1473,7 @@ function createValidationSchema(config) {
1416
1473
  for (const field2 of config) {
1417
1474
  shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
1418
1475
  }
1419
- return import_zod16.z.object(shape);
1476
+ return import_zod17.z.object(shape);
1420
1477
  }
1421
1478
  function mapFieldTypeToMockValue(field2, i) {
1422
1479
  switch (field2.type) {
@@ -1762,12 +1819,6 @@ function runFieldValidations({
1762
1819
  };
1763
1820
  }
1764
1821
 
1765
- // ../commons/src/uuid.ts
1766
- var import_uuid = require("uuid");
1767
- function getUUID() {
1768
- return (0, import_uuid.v4)();
1769
- }
1770
-
1771
1822
  // ../commons/src/utils.ts
1772
1823
  function getOrThrow(x, message) {
1773
1824
  if (x === void 0 || x === null) {
@@ -1868,7 +1919,7 @@ function createEmptyDraft(eventId, draftId, actionType) {
1868
1919
  annotation: {},
1869
1920
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1870
1921
  createdBy: "@todo",
1871
- createdAtLocation: "@todo",
1922
+ createdAtLocation: "00000000-0000-0000-0000-000000000000",
1872
1923
  status: ActionStatus.Accepted,
1873
1924
  transactionId: "@todo",
1874
1925
  createdByRole: "@todo"
@@ -1964,22 +2015,22 @@ function getMixedPath(obj, path, defaultValue) {
1964
2015
 
1965
2016
  // ../commons/src/events/EventConfig.ts
1966
2017
  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(
2018
+ (0, import_zod_openapi8.extendZodWithOpenApi)(import_zod18.z);
2019
+ var EventConfig = import_zod18.z.object({
2020
+ id: import_zod18.z.string().describe(
1970
2021
  'A machine-readable identifier for the event, e.g. "birth" or "death"'
1971
2022
  ),
1972
- dateOfEvent: import_zod17.z.object({ fieldId: import_zod17.z.string() }).optional(),
2023
+ dateOfEvent: import_zod18.z.object({ fieldId: import_zod18.z.string() }).optional(),
1973
2024
  title: TranslationConfig,
1974
2025
  fallbackTitle: TranslationConfig.optional().describe(
1975
2026
  "This is a fallback title if actual title resolves to empty string"
1976
2027
  ),
1977
2028
  summary: SummaryConfig,
1978
2029
  label: TranslationConfig,
1979
- actions: import_zod17.z.array(ActionConfig),
2030
+ actions: import_zod18.z.array(ActionConfig),
1980
2031
  declaration: DeclarationFormConfig,
1981
- deduplication: import_zod17.z.array(DeduplicationConfig).optional().default([]),
1982
- advancedSearch: import_zod17.z.array(AdvancedSearchConfig).optional().default([])
2032
+ deduplication: import_zod18.z.array(DeduplicationConfig).optional().default([]),
2033
+ advancedSearch: import_zod18.z.array(AdvancedSearchConfig).optional().default([])
1983
2034
  }).superRefine((event2, ctx) => {
1984
2035
  const allFields = findAllFields(event2);
1985
2036
  const fieldIds = allFields.map((field2) => field2.id);
@@ -2041,241 +2092,24 @@ var definePage = (page) => PageConfig.parse(page);
2041
2092
  var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
2042
2093
 
2043
2094
  // ../commons/src/events/WorkqueueConfig.ts
2044
- var import_zod20 = require("zod");
2095
+ var import_zod25 = require("zod");
2045
2096
 
2046
- // ../commons/src/events/EventIndex.ts
2097
+ // ../commons/src/events/serializers/user/serializer.ts
2047
2098
  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)
2099
+ var SerializedUserField = import_zod19.z.object({
2100
+ $userField: import_zod19.z.enum([
2101
+ "id",
2102
+ "name",
2103
+ "role",
2104
+ "signatureFilename",
2105
+ "primaryOfficeId"
2251
2106
  ])
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
2107
  });
2274
- var And2 = import_zod19.z.object({
2275
- type: import_zod19.z.literal("and"),
2276
- clauses: import_zod19.z.array(QueryExpression)
2277
- });
2278
- var QueryType = import_zod19.z.discriminatedUnion("type", [Or2, And2]);
2108
+ function userSerializer(userField) {
2109
+ return {
2110
+ $userField: userField
2111
+ };
2112
+ }
2279
2113
 
2280
2114
  // ../commons/src/conditionals/conditionals.ts
2281
2115
  function defineConditional(schema) {
@@ -2318,7 +2152,7 @@ function not(condition) {
2318
2152
  function never() {
2319
2153
  return not(alwaysTrue());
2320
2154
  }
2321
- var user = {
2155
+ var user = Object.assign(userSerializer, {
2322
2156
  hasScope: (scope) => defineConditional({
2323
2157
  type: "object",
2324
2158
  properties: {
@@ -2338,7 +2172,7 @@ var user = {
2338
2172
  },
2339
2173
  required: ["$user"]
2340
2174
  })
2341
- };
2175
+ });
2342
2176
  function createEventConditionals() {
2343
2177
  return {
2344
2178
  /**
@@ -2645,144 +2479,668 @@ var event = Object.assign(eventFn, {
2645
2479
  }
2646
2480
  });
2647
2481
 
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)"
2482
+ // ../commons/src/events/WorkqueueColumnConfig.ts
2483
+ var import_zod21 = require("zod");
2484
+
2485
+ // ../commons/src/events/EventMetadata.ts
2486
+ var import_zod20 = require("zod");
2487
+ var EventStatus = {
2488
+ CREATED: "CREATED",
2489
+ NOTIFIED: "NOTIFIED",
2490
+ DECLARED: "DECLARED",
2491
+ VALIDATED: "VALIDATED",
2492
+ REGISTERED: "REGISTERED",
2493
+ CERTIFIED: "CERTIFIED",
2494
+ REJECTED: "REJECTED",
2495
+ ARCHIVED: "ARCHIVED"
2496
+ };
2497
+ var eventStatusValues = [
2498
+ EventStatus.CREATED,
2499
+ EventStatus.NOTIFIED,
2500
+ EventStatus.DECLARED,
2501
+ EventStatus.VALIDATED,
2502
+ EventStatus.REGISTERED,
2503
+ EventStatus.CERTIFIED,
2504
+ EventStatus.REJECTED,
2505
+ EventStatus.ARCHIVED
2506
+ ];
2507
+ var EventStatusEnum = import_zod20.z.enum(eventStatusValues);
2508
+ var CustomFlags = {
2509
+ CERTIFICATE_PRINTED: "certificate-printed"
2510
+ };
2511
+ var Flag = import_zod20.z.string().regex(
2512
+ new RegExp(
2513
+ `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
2514
+ ActionStatus
2515
+ ).join("|").toLowerCase()})$`
2653
2516
  ),
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
- })
2517
+ "Flag must be in the format ActionType:ActionStatus (lowerCase)"
2518
+ ).or(import_zod20.z.nativeEnum(CustomFlags));
2519
+ var eventStatuses = Object.values(EventStatus);
2520
+ var EventStatuses = import_zod20.z.nativeEnum(EventStatus);
2521
+ var ZodDate = import_zod20.z.string().date();
2522
+ var ActionCreationMetadata = import_zod20.z.object({
2523
+ createdAt: import_zod20.z.string().datetime().describe("The timestamp when the action request was created."),
2524
+ createdBy: import_zod20.z.string().describe("ID of the user who created the action request."),
2525
+ createdAtLocation: CreatedAtLocation.describe(
2526
+ "Location of the user who created the action request."
2660
2527
  ),
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()
2528
+ acceptedAt: import_zod20.z.string().datetime().describe("Timestamp when the action request was accepted."),
2529
+ createdByRole: import_zod20.z.string().describe("Role of the user at the time of action request creation.")
2693
2530
  });
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()
2704
- })
2705
- );
2706
- 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())
2710
- })
2711
- );
2712
- var NotifyActionInput = BaseActionInput.merge(
2713
- import_zod21.z.object({
2714
- type: import_zod21.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
2715
- })
2716
- ).openapi({
2717
- default: {
2718
- eventId: "<event-id-here>",
2719
- transactionId: (0, import_uuid3.v4)(),
2720
- declaration: {},
2721
- annotation: {},
2531
+ var RegistrationCreationMetadata = ActionCreationMetadata.extend({
2532
+ registrationNumber: import_zod20.z.string().describe(
2533
+ "Registration number of the event. Always present for accepted registrations."
2534
+ )
2535
+ });
2536
+ var LegalStatuses = import_zod20.z.object({
2537
+ [EventStatus.DECLARED]: ActionCreationMetadata.nullish(),
2538
+ [EventStatus.REGISTERED]: RegistrationCreationMetadata.nullish()
2539
+ });
2540
+ var EventMetadata = import_zod20.z.object({
2541
+ id: UUID,
2542
+ type: import_zod20.z.string().describe("The type of event, such as birth, death, or marriage."),
2543
+ status: EventStatuses,
2544
+ legalStatuses: LegalStatuses.describe(
2545
+ "Metadata related to the legal registration of the event, such as who registered it and when."
2546
+ ),
2547
+ createdAt: import_zod20.z.string().datetime().describe("The timestamp when the event was first created and saved."),
2548
+ dateOfEvent: ZodDate.nullish(),
2549
+ createdBy: import_zod20.z.string().describe("ID of the user who created the event."),
2550
+ updatedByUserRole: import_zod20.z.string().describe("Role of the user who last updated the declaration."),
2551
+ createdAtLocation: CreatedAtLocation.describe(
2552
+ "Location of the user who created the event."
2553
+ ),
2554
+ updatedAtLocation: UUID.nullish().describe(
2555
+ "Location of the user who last updated the declaration."
2556
+ ),
2557
+ updatedAt: import_zod20.z.string().datetime().describe("Timestamp of the most recent declaration update."),
2558
+ assignedTo: import_zod20.z.string().nullish().describe("ID of the user currently assigned to the event."),
2559
+ updatedBy: import_zod20.z.string().nullish().describe("ID of the user who last updated the declaration."),
2560
+ trackingId: import_zod20.z.string().describe(
2561
+ "System-generated tracking ID used by informants or registrars to look up the event."
2562
+ ),
2563
+ flags: import_zod20.z.array(Flag)
2564
+ });
2565
+ var EventMetadataKeysArray = [
2566
+ "id",
2567
+ "type",
2568
+ "status",
2569
+ "createdAt",
2570
+ "dateOfEvent",
2571
+ "createdBy",
2572
+ "updatedByUserRole",
2573
+ "createdAtLocation",
2574
+ "updatedAtLocation",
2575
+ "updatedAt",
2576
+ "assignedTo",
2577
+ "updatedBy",
2578
+ "trackingId",
2579
+ "legalStatuses",
2580
+ "flags"
2581
+ ];
2582
+ var EventMetadataKeys = import_zod20.z.enum(EventMetadataKeysArray);
2583
+ var eventMetadataLabelMap = {
2584
+ "event.assignedTo": {
2585
+ id: "event.assignedTo.label",
2586
+ defaultMessage: "Assigned To",
2587
+ description: "Assigned To"
2588
+ },
2589
+ "event.createdAt": {
2590
+ id: "event.createdAt.label",
2591
+ defaultMessage: "Created",
2592
+ description: "Created At"
2593
+ },
2594
+ "event.dateOfEvent": {
2595
+ id: "event.dateOfEvent.label",
2596
+ defaultMessage: "Date of Event",
2597
+ description: "Date of Event"
2598
+ },
2599
+ "event.createdAtLocation": {
2600
+ id: "event.createdAtLocation.label",
2601
+ defaultMessage: "Location",
2602
+ description: "Created At Location"
2603
+ },
2604
+ "event.updatedAtLocation": {
2605
+ id: "event.updatedAtLocation.label",
2606
+ defaultMessage: "Location",
2607
+ description: "Updated At Location"
2608
+ },
2609
+ "event.createdBy": {
2610
+ id: "event.createdBy.label",
2611
+ defaultMessage: "Created By",
2612
+ description: "Created By"
2613
+ },
2614
+ "event.updatedByUserRole": {
2615
+ id: "event.updatedByUserRole.label",
2616
+ defaultMessage: "Updated By Role",
2617
+ description: "Updated By Role"
2618
+ },
2619
+ "event.id": {
2620
+ id: "event.id.label",
2621
+ defaultMessage: "ID",
2622
+ description: "ID"
2623
+ },
2624
+ "event.updatedAt": {
2625
+ id: "event.modifiedAt.label",
2626
+ defaultMessage: "Updated",
2627
+ description: "Modified At"
2628
+ },
2629
+ "event.status": {
2630
+ id: "event.status.label",
2631
+ defaultMessage: "Status",
2632
+ description: "Status"
2633
+ },
2634
+ "event.type": {
2635
+ id: "event.type.label",
2636
+ defaultMessage: "Type",
2637
+ description: "Type"
2638
+ },
2639
+ "event.updatedBy": {
2640
+ id: "event.updatedBy.label",
2641
+ defaultMessage: "Updated By",
2642
+ description: "Updated By"
2643
+ },
2644
+ "event.trackingId": {
2645
+ id: "event.trackingId.label",
2646
+ defaultMessage: "Tracking ID",
2647
+ description: "Tracking ID"
2648
+ },
2649
+ "event.flags": {
2650
+ id: "event.flags.label",
2651
+ defaultMessage: "Flags",
2652
+ description: "Flags"
2653
+ }
2654
+ };
2655
+
2656
+ // ../commons/src/events/WorkqueueColumnConfig.ts
2657
+ var WorkqueueColumnKeysArray = [
2658
+ ...EventMetadataKeysArray,
2659
+ "title"
2660
+ ];
2661
+ var WorkqueueColumnKeys = import_zod21.z.enum(WorkqueueColumnKeysArray);
2662
+ var WorkqueueColumnValue = import_zod21.z.object({
2663
+ $event: WorkqueueColumnKeys
2664
+ });
2665
+ var WorkqueueColumn = import_zod21.z.object({
2666
+ label: TranslationConfig,
2667
+ value: WorkqueueColumnValue
2668
+ });
2669
+ function defineWorkqueuesColumns(workqueueColumns) {
2670
+ return workqueueColumns.map(
2671
+ (workqueueColumn) => WorkqueueColumn.parse(workqueueColumn)
2672
+ );
2673
+ }
2674
+
2675
+ // ../commons/src/events/CountryConfigQueryInput.ts
2676
+ var import_zod23 = require("zod");
2677
+
2678
+ // ../commons/src/events/EventIndex.ts
2679
+ var import_zod22 = require("zod");
2680
+ var import_zod_openapi9 = require("zod-openapi");
2681
+ (0, import_zod_openapi9.extendZodWithOpenApi)(import_zod22.z);
2682
+ var EventIndex = EventMetadata.extend({
2683
+ declaration: EventState
2684
+ }).openapi({
2685
+ ref: "EventIndex"
2686
+ });
2687
+ var EventSearchIndex = import_zod22.z.record(import_zod22.z.string(), import_zod22.z.any()).and(
2688
+ import_zod22.z.object({
2689
+ type: import_zod22.z.string()
2690
+ // Ensures "type" (event-id) exists and is a string
2691
+ })
2692
+ ).openapi({
2693
+ ref: "EventSearchIndex"
2694
+ });
2695
+ var Fuzzy = import_zod22.z.object({ type: import_zod22.z.literal("fuzzy"), term: import_zod22.z.string() }).openapi({
2696
+ ref: "Fuzzy"
2697
+ });
2698
+ var Exact = import_zod22.z.object({ type: import_zod22.z.literal("exact"), term: import_zod22.z.string() }).openapi({
2699
+ ref: "Exact"
2700
+ });
2701
+ var AnyOf = import_zod22.z.object({
2702
+ type: import_zod22.z.literal("anyOf"),
2703
+ terms: import_zod22.z.array(import_zod22.z.string())
2704
+ }).openapi({
2705
+ ref: "AnyOf"
2706
+ });
2707
+ var ExactStatus = import_zod22.z.object({
2708
+ type: import_zod22.z.literal("exact"),
2709
+ term: EventStatusEnum
2710
+ }).openapi({
2711
+ ref: "ExactStatus"
2712
+ });
2713
+ var AnyOfStatus = import_zod22.z.object({
2714
+ type: import_zod22.z.literal("anyOf"),
2715
+ terms: import_zod22.z.array(EventStatusEnum)
2716
+ }).openapi({
2717
+ ref: "AnyOfStatus"
2718
+ });
2719
+ var Range = import_zod22.z.object({
2720
+ type: import_zod22.z.literal("range"),
2721
+ gte: import_zod22.z.string(),
2722
+ lte: import_zod22.z.string()
2723
+ }).openapi({
2724
+ ref: "Range"
2725
+ });
2726
+ var Not = import_zod22.z.object({ type: import_zod22.z.literal("not"), term: import_zod22.z.string() }).openapi({
2727
+ ref: "Not"
2728
+ });
2729
+ var Within = import_zod22.z.object({ type: import_zod22.z.literal("within"), location: import_zod22.z.string() }).openapi({
2730
+ ref: "Within"
2731
+ });
2732
+ var DateCondition = import_zod22.z.union([Exact, Range]).openapi({
2733
+ ref: "DateCondition"
2734
+ });
2735
+ var QueryInput = import_zod22.z.lazy(
2736
+ () => import_zod22.z.union([
2737
+ import_zod22.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf, Not]),
2738
+ import_zod22.z.record(import_zod22.z.string(), QueryInput)
2739
+ ])
2740
+ ).openapi({
2741
+ ref: "QueryInput"
2742
+ });
2743
+ var QueryExpression = import_zod22.z.object({
2744
+ eventType: import_zod22.z.string(),
2745
+ status: import_zod22.z.optional(import_zod22.z.union([AnyOfStatus, ExactStatus])),
2746
+ createdAt: import_zod22.z.optional(DateCondition),
2747
+ updatedAt: import_zod22.z.optional(DateCondition),
2748
+ "legalStatus.REGISTERED.createdAt": import_zod22.z.optional(DateCondition),
2749
+ "legalStatus.REGISTERED.createdAtLocation": import_zod22.z.optional(
2750
+ import_zod22.z.union([Within, Exact])
2751
+ ),
2752
+ createdAtLocation: import_zod22.z.optional(import_zod22.z.union([Within, Exact])),
2753
+ updatedAtLocation: import_zod22.z.optional(import_zod22.z.union([Within, Exact])),
2754
+ assignedTo: import_zod22.z.optional(Exact),
2755
+ createdBy: import_zod22.z.optional(Exact),
2756
+ updatedBy: import_zod22.z.optional(Exact),
2757
+ trackingId: import_zod22.z.optional(Exact),
2758
+ flags: import_zod22.z.optional(import_zod22.z.array(import_zod22.z.union([AnyOf, Not]))),
2759
+ data: QueryInput
2760
+ }).partial().openapi({
2761
+ ref: "QueryExpression"
2762
+ });
2763
+ var QueryType = import_zod22.z.object({
2764
+ type: import_zod22.z.literal("and").or(import_zod22.z.literal("or")).openapi({ default: "and" }),
2765
+ clauses: import_zod22.z.preprocess(
2766
+ (val) => {
2767
+ if (typeof val === "string") {
2768
+ return [JSON.parse(val)];
2769
+ }
2770
+ if (Array.isArray(val)) {
2771
+ return val.map((v) => typeof v === "string" ? JSON.parse(v) : v);
2772
+ }
2773
+ return val;
2774
+ },
2775
+ import_zod22.z.array(QueryExpression).openapi({
2776
+ default: [
2777
+ {
2778
+ eventType: TENNIS_CLUB_MEMBERSHIP,
2779
+ status: {
2780
+ type: "anyOf",
2781
+ terms: [
2782
+ "CREATED",
2783
+ "NOTIFIED",
2784
+ "DECLARED",
2785
+ "VALIDATED",
2786
+ "REGISTERED",
2787
+ "CERTIFIED",
2788
+ "REJECTED",
2789
+ "ARCHIVED"
2790
+ ]
2791
+ },
2792
+ updatedAt: {
2793
+ type: "range",
2794
+ gte: "2025-05-22",
2795
+ lte: "2025-05-29"
2796
+ },
2797
+ data: {}
2798
+ }
2799
+ ]
2800
+ })
2801
+ )
2802
+ }).openapi({
2803
+ ref: "QueryType"
2804
+ });
2805
+
2806
+ // ../commons/src/events/CountryConfigQueryInput.ts
2807
+ var SerializableExact = import_zod23.z.object({
2808
+ type: import_zod23.z.literal("exact"),
2809
+ term: import_zod23.z.union([import_zod23.z.string(), SerializedUserField])
2810
+ });
2811
+ var SerializableWithin = import_zod23.z.object({
2812
+ type: import_zod23.z.literal("within"),
2813
+ location: import_zod23.z.union([import_zod23.z.string(), SerializedUserField])
2814
+ });
2815
+ var SerializedQueryExpression = import_zod23.z.object({
2816
+ eventType: import_zod23.z.string(),
2817
+ status: import_zod23.z.optional(import_zod23.z.union([AnyOfStatus, ExactStatus])),
2818
+ createdAt: import_zod23.z.optional(DateCondition),
2819
+ updatedAt: import_zod23.z.optional(DateCondition),
2820
+ createdAtLocation: import_zod23.z.optional(
2821
+ import_zod23.z.union([SerializableWithin, SerializableExact])
2822
+ ),
2823
+ updatedAtLocation: import_zod23.z.optional(
2824
+ import_zod23.z.union([SerializableWithin, SerializableExact])
2825
+ ),
2826
+ assignedTo: import_zod23.z.optional(SerializableExact),
2827
+ createdBy: import_zod23.z.optional(SerializableExact),
2828
+ updatedBy: import_zod23.z.optional(SerializableExact),
2829
+ trackingId: import_zod23.z.optional(Exact),
2830
+ flags: import_zod23.z.optional(import_zod23.z.array(import_zod23.z.union([AnyOf, Not]))),
2831
+ data: QueryInput
2832
+ }).partial();
2833
+ var Or2 = import_zod23.z.object({
2834
+ type: import_zod23.z.literal("or"),
2835
+ clauses: import_zod23.z.array(SerializedQueryExpression)
2836
+ });
2837
+ var And2 = import_zod23.z.object({
2838
+ type: import_zod23.z.literal("and"),
2839
+ clauses: import_zod23.z.array(SerializedQueryExpression)
2840
+ });
2841
+ var CountryConfigQueryType = import_zod23.z.discriminatedUnion("type", [And2, Or2]);
2842
+ var CountryConfigQueryInputType = import_zod23.z.union([
2843
+ SerializedQueryExpression,
2844
+ And2,
2845
+ Or2
2846
+ ]);
2847
+
2848
+ // ../commons/src/icons.ts
2849
+ var import_zod24 = require("zod");
2850
+ var AvailableIcons = import_zod24.z.enum([
2851
+ "Archived",
2852
+ "Assigned",
2853
+ "Certified",
2854
+ "Close",
2855
+ "Collapse",
2856
+ "Draft",
2857
+ "DuplicateYellow",
2858
+ "Expand",
2859
+ "ExternalValidate",
2860
+ "FilledCheck",
2861
+ "InReview",
2862
+ "Offline",
2863
+ "Registered",
2864
+ "RequiresUpdates",
2865
+ "Sent",
2866
+ "Validated",
2867
+ "WaitingApproval",
2868
+ "ChartActivity",
2869
+ "Activity",
2870
+ "Archive",
2871
+ "ArchiveTray",
2872
+ "ArrowLeft",
2873
+ "ArrowRight",
2874
+ "Buildings",
2875
+ "Circle",
2876
+ "CaretDown",
2877
+ "CaretLeft",
2878
+ "CaretRight",
2879
+ "ChartBar",
2880
+ "ChartLine",
2881
+ "ChatCircle",
2882
+ "CheckSquare",
2883
+ "Compass",
2884
+ "Check",
2885
+ "Copy",
2886
+ "Database",
2887
+ "DotsThreeVertical",
2888
+ "DownloadSimple",
2889
+ "ArrowCounterClockwise",
2890
+ "MagnifyingGlassMinus",
2891
+ "MagnifyingGlassPlus",
2892
+ "Export",
2893
+ "Eye",
2894
+ "EyeSlash",
2895
+ "Envelope",
2896
+ "File",
2897
+ "FileSearch",
2898
+ "FileMinus",
2899
+ "FilePlus",
2900
+ "FileText",
2901
+ "FileX",
2902
+ "Handshake",
2903
+ "Gear",
2904
+ "GitBranch",
2905
+ "IdentificationCard",
2906
+ "List",
2907
+ "ListBullets",
2908
+ "Lock",
2909
+ "MagnifyingGlass",
2910
+ "MapPin",
2911
+ "Medal",
2912
+ "NotePencil",
2913
+ "Paperclip",
2914
+ "PaperPlaneTilt",
2915
+ "Pen",
2916
+ "Pencil",
2917
+ "PencilSimpleLine",
2918
+ "Phone",
2919
+ "Plus",
2920
+ "Printer",
2921
+ "SignOut",
2922
+ "Star",
2923
+ "Target",
2924
+ "TextT",
2925
+ "Trash",
2926
+ "UploadSimple",
2927
+ "User",
2928
+ "UserPlus",
2929
+ "Users",
2930
+ "WarningCircle",
2931
+ "X",
2932
+ "CircleWavyCheck",
2933
+ "CircleWavyQuestion",
2934
+ "ArchiveBox",
2935
+ "ArrowCircleDown",
2936
+ "FileArrowUp",
2937
+ "FileDotted",
2938
+ "Files",
2939
+ "PencilLine",
2940
+ "PencilCircle",
2941
+ "UserCircle",
2942
+ "Clock",
2943
+ "QrCode",
2944
+ "Webcam",
2945
+ "Sun",
2946
+ "DeviceTabletCamera",
2947
+ "Globe",
2948
+ "Fingerprint",
2949
+ "PushPin",
2950
+ "Timer"
2951
+ ]);
2952
+
2953
+ // ../commons/src/events/WorkqueueConfig.ts
2954
+ var dateOfEventColumn = defineWorkqueuesColumns([
2955
+ {
2956
+ label: {
2957
+ id: "workqueues.dateOfEvent",
2958
+ defaultMessage: "Date of Event",
2959
+ description: "Label for workqueue column: dateOfEvent"
2960
+ },
2961
+ value: event.field("dateOfEvent")
2962
+ },
2963
+ {
2964
+ label: {
2965
+ defaultMessage: "Last updated",
2966
+ description: "This is the label for the workqueue column",
2967
+ id: "workqueue.default.column.modifiedAt"
2968
+ },
2969
+ value: event.field("updatedAt")
2970
+ }
2971
+ ]);
2972
+ var WorkqueueConfig = import_zod25.z.object({
2973
+ slug: import_zod25.z.string().describe("Determines the url of the workqueue."),
2974
+ name: TranslationConfig.describe(
2975
+ "Title of the workflow (both in navigation and on the page)"
2976
+ ),
2977
+ query: CountryConfigQueryType,
2978
+ actions: import_zod25.z.array(
2979
+ import_zod25.z.object({
2980
+ type: import_zod25.z.string(),
2981
+ conditionals: import_zod25.z.array(Conditional).optional()
2982
+ })
2983
+ ),
2984
+ columns: import_zod25.z.array(WorkqueueColumn).default(dateOfEventColumn),
2985
+ icon: AvailableIcons
2986
+ }).describe("Configuration for workqueue.");
2987
+ var WorkqueueConfigInput = import_zod25.z.object({
2988
+ slug: import_zod25.z.string().describe("Determines the url of the workqueue."),
2989
+ name: TranslationConfig.describe(
2990
+ "Title of the workflow (both in navigation and on the page)"
2991
+ ),
2992
+ query: CountryConfigQueryInputType,
2993
+ actions: import_zod25.z.array(
2994
+ import_zod25.z.object({
2995
+ type: import_zod25.z.string(),
2996
+ conditionals: import_zod25.z.array(Conditional).optional()
2997
+ })
2998
+ ),
2999
+ columns: import_zod25.z.array(WorkqueueColumn).default(dateOfEventColumn),
3000
+ icon: AvailableIcons
3001
+ });
3002
+ function defineWorkqueue(workqueueInput) {
3003
+ const queryInput = workqueueInput.query;
3004
+ const query = "type" in queryInput ? queryInput : { type: "and", clauses: [queryInput] };
3005
+ return WorkqueueConfig.parse({ ...workqueueInput, query });
3006
+ }
3007
+ function defineWorkqueues(workqueues) {
3008
+ return workqueues.map((workqueue) => defineWorkqueue(workqueue));
3009
+ }
3010
+ var WorkqueueCountInput = import_zod25.z.array(
3011
+ import_zod25.z.object({ slug: import_zod25.z.string(), query: QueryType })
3012
+ );
3013
+ var WorkqueueCountOutput = import_zod25.z.record(import_zod25.z.string(), import_zod25.z.number());
3014
+
3015
+ // ../commons/src/events/workqueueDefaultColumns.ts
3016
+ var defaultWorkqueueColumns = [
3017
+ {
3018
+ label: {
3019
+ defaultMessage: "Title",
3020
+ description: "This is the label for the workqueue column",
3021
+ id: "workqueue.in-reveiw.column.title"
3022
+ },
3023
+ value: event.field("title")
3024
+ },
3025
+ {
3026
+ label: {
3027
+ defaultMessage: "Event",
3028
+ description: "This is the label for the workqueue column",
3029
+ id: "workqueue.default.column.event"
3030
+ },
3031
+ value: event.field("type")
3032
+ }
3033
+ ];
3034
+
3035
+ // ../commons/src/events/Draft.ts
3036
+ var import_zod27 = require("zod");
3037
+
3038
+ // ../commons/src/events/ActionInput.ts
3039
+ var import_zod26 = require("zod");
3040
+ var import_zod_openapi10 = require("zod-openapi");
3041
+ (0, import_zod_openapi10.extendZodWithOpenApi)(import_zod26.z);
3042
+ var BaseActionInput = import_zod26.z.object({
3043
+ eventId: UUID,
3044
+ transactionId: import_zod26.z.string(),
3045
+ declaration: ActionUpdate.default({}),
3046
+ annotation: ActionUpdate.optional(),
3047
+ originalActionId: UUID.optional(),
3048
+ keepAssignment: import_zod26.z.boolean().optional()
3049
+ });
3050
+ var CreateActionInput = BaseActionInput.merge(
3051
+ import_zod26.z.object({
3052
+ type: import_zod26.z.literal(ActionType.CREATE).default(ActionType.CREATE),
3053
+ createdAtLocation: CreatedAtLocation
3054
+ })
3055
+ );
3056
+ var RegisterActionInput = BaseActionInput.merge(
3057
+ import_zod26.z.object({
3058
+ type: import_zod26.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
3059
+ registrationNumber: import_zod26.z.string().optional()
3060
+ })
3061
+ );
3062
+ var ValidateActionInput = BaseActionInput.merge(
3063
+ import_zod26.z.object({
3064
+ type: import_zod26.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
3065
+ duplicates: import_zod26.z.array(import_zod26.z.string())
3066
+ })
3067
+ );
3068
+ var NotifyActionInput = BaseActionInput.merge(
3069
+ import_zod26.z.object({
3070
+ type: import_zod26.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
3071
+ })
3072
+ ).openapi({
3073
+ default: {
3074
+ eventId: "<event-id-here>",
3075
+ transactionId: getUUID(),
3076
+ declaration: {},
3077
+ annotation: {},
2722
3078
  type: ActionType.NOTIFY
2723
3079
  }
2724
3080
  });
2725
3081
  var DeclareActionInput = BaseActionInput.merge(
2726
- import_zod21.z.object({
2727
- type: import_zod21.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
3082
+ import_zod26.z.object({
3083
+ type: import_zod26.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
2728
3084
  })
2729
3085
  );
2730
3086
  var PrintCertificateActionInput = BaseActionInput.merge(
2731
- import_zod21.z.object({
2732
- type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
3087
+ import_zod26.z.object({
3088
+ type: import_zod26.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
2733
3089
  })
2734
3090
  );
2735
3091
  var RejectDeclarationActionInput = BaseActionInput.merge(
2736
- import_zod21.z.object({
2737
- type: import_zod21.z.literal(ActionType.REJECT).default(ActionType.REJECT)
3092
+ import_zod26.z.object({
3093
+ type: import_zod26.z.literal(ActionType.REJECT).default(ActionType.REJECT),
3094
+ reason: RejectionReason
2738
3095
  })
2739
3096
  );
2740
3097
  var MarkedAsDuplicateActionInput = BaseActionInput.merge(
2741
- import_zod21.z.object({
2742
- type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
3098
+ import_zod26.z.object({
3099
+ type: import_zod26.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
2743
3100
  })
2744
3101
  );
2745
3102
  var ArchiveActionInput = BaseActionInput.merge(
2746
- import_zod21.z.object({
2747
- type: import_zod21.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
3103
+ import_zod26.z.object({
3104
+ type: import_zod26.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
3105
+ reason: RejectionReason
2748
3106
  })
2749
3107
  );
2750
3108
  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()
3109
+ import_zod26.z.object({
3110
+ type: import_zod26.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
3111
+ assignedTo: import_zod26.z.string()
2754
3112
  })
2755
3113
  );
2756
3114
  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)
3115
+ import_zod26.z.object({
3116
+ type: import_zod26.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
3117
+ assignedTo: import_zod26.z.literal(null).default(null)
2760
3118
  })
2761
3119
  );
2762
3120
  var RequestCorrectionActionInput = BaseActionInput.merge(
2763
- import_zod21.z.object({
2764
- type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
3121
+ import_zod26.z.object({
3122
+ type: import_zod26.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
2765
3123
  })
2766
3124
  );
2767
3125
  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)
3126
+ import_zod26.z.object({
3127
+ requestId: import_zod26.z.string(),
3128
+ type: import_zod26.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
2771
3129
  })
2772
3130
  );
2773
3131
  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)
3132
+ import_zod26.z.object({
3133
+ requestId: import_zod26.z.string(),
3134
+ type: import_zod26.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
2777
3135
  })
2778
3136
  );
2779
3137
  var ReadActionInput = BaseActionInput.merge(
2780
- import_zod21.z.object({
2781
- type: import_zod21.z.literal(ActionType.READ).default(ActionType.READ)
3138
+ import_zod26.z.object({
3139
+ type: import_zod26.z.literal(ActionType.READ).default(ActionType.READ)
2782
3140
  })
2783
3141
  );
2784
- var DeleteActionInput = import_zod21.z.object({ eventId: import_zod21.z.string() });
2785
- var ActionInput = import_zod21.z.discriminatedUnion("type", [
3142
+ var DeleteActionInput = import_zod26.z.object({ eventId: UUID });
3143
+ var ActionInput = import_zod26.z.discriminatedUnion("type", [
2786
3144
  CreateActionInput.openapi({ ref: "CreateActionInput" }),
2787
3145
  ValidateActionInput.openapi({ ref: "ValidateActionInput" }),
2788
3146
  RegisterActionInput.openapi({ ref: "RegisterActionInput" }),
@@ -2811,18 +3169,18 @@ var ActionInput = import_zod21.z.discriminatedUnion("type", [
2811
3169
  });
2812
3170
 
2813
3171
  // ../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(),
3172
+ var Draft = import_zod27.z.object({
3173
+ id: UUID,
3174
+ eventId: UUID,
3175
+ transactionId: import_zod27.z.string(),
3176
+ createdAt: import_zod27.z.string().datetime(),
2819
3177
  action: ActionBase.extend({
2820
3178
  type: ActionTypes
2821
3179
  }).omit({ id: true })
2822
3180
  });
2823
3181
  var DraftInput = BaseActionInput.extend({
2824
3182
  type: ActionTypes,
2825
- status: import_zod22.z.enum([
3183
+ status: import_zod27.z.enum([
2826
3184
  ActionStatus.Requested,
2827
3185
  ActionStatus.Accepted,
2828
3186
  ActionStatus.Rejected
@@ -2830,26 +3188,24 @@ var DraftInput = BaseActionInput.extend({
2830
3188
  });
2831
3189
 
2832
3190
  // ../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" } });
3191
+ var import_zod28 = require("zod");
3192
+ var import_uuid8 = require("uuid");
3193
+ var EventInput = import_zod28.z.object({
3194
+ transactionId: import_zod28.z.string(),
3195
+ type: import_zod28.z.string()
3196
+ }).openapi({ default: { transactionId: (0, import_uuid8.v4)(), type: "v2.birth" } });
2840
3197
 
2841
3198
  // ../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()
3199
+ var import_zod29 = require("zod");
3200
+ var import_zod_openapi11 = require("zod-openapi");
3201
+ (0, import_zod_openapi11.extendZodWithOpenApi)(import_zod29.z);
3202
+ var EventDocument = import_zod29.z.object({
3203
+ id: UUID,
3204
+ type: import_zod29.z.string(),
3205
+ createdAt: import_zod29.z.string().datetime(),
3206
+ updatedAt: import_zod29.z.string().datetime(),
3207
+ actions: import_zod29.z.array(Action),
3208
+ trackingId: import_zod29.z.string()
2853
3209
  }).openapi({ ref: "EventDocument" });
2854
3210
 
2855
3211
  // ../commons/src/events/state/utils.ts
@@ -3011,18 +3367,18 @@ function aggregateActionDeclarations(actions) {
3011
3367
  ActionType.REQUEST_CORRECTION,
3012
3368
  ActionType.PRINT_CERTIFICATE
3013
3369
  ];
3014
- return actions.reduce((status, action) => {
3370
+ return actions.reduce((declaration, action) => {
3015
3371
  if (excludedActions.some((excludedAction) => excludedAction === action.type)) {
3016
- return status;
3372
+ return declaration;
3017
3373
  }
3018
3374
  if (action.type === ActionType.APPROVE_CORRECTION) {
3019
3375
  const requestAction = actions.find(({ id }) => id === action.requestId);
3020
3376
  if (!requestAction) {
3021
- return status;
3377
+ return declaration;
3022
3378
  }
3023
- return deepMerge(status, requestAction.declaration);
3379
+ return deepMerge(declaration, requestAction.declaration);
3024
3380
  }
3025
- return deepMerge(status, action.declaration);
3381
+ return deepMerge(declaration, action.declaration);
3026
3382
  }, {});
3027
3383
  }
3028
3384
  function deepDropNulls(obj) {
@@ -3050,7 +3406,7 @@ function getAcceptedActions(event2) {
3050
3406
  );
3051
3407
  }
3052
3408
  var DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
3053
- function getCurrentEventState(event2) {
3409
+ function getCurrentEventState(event2, config) {
3054
3410
  const creationAction = event2.actions.find(
3055
3411
  (action) => action.type === ActionType.CREATE
3056
3412
  );
@@ -3062,9 +3418,17 @@ function getCurrentEventState(event2) {
3062
3418
  event2.actions
3063
3419
  );
3064
3420
  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;
3421
+ let dateOfEvent;
3422
+ if (config.dateOfEvent) {
3423
+ const parsedDate = ZodDate.safeParse(
3424
+ declaration[config.dateOfEvent.fieldId]
3425
+ );
3426
+ if (parsedDate.success) {
3427
+ dateOfEvent = parsedDate.data;
3428
+ }
3429
+ } else {
3430
+ dateOfEvent = event2[DEFAULT_DATE_OF_EVENT_PROPERTY].split("T")[0];
3431
+ }
3068
3432
  return deepDropNulls({
3069
3433
  id: event2.id,
3070
3434
  type: event2.type,
@@ -3085,7 +3449,11 @@ function getCurrentEventState(event2) {
3085
3449
  flags: getFlagsFromActions(event2.actions)
3086
3450
  });
3087
3451
  }
3088
- function getCurrentEventStateWithDrafts(event2, drafts) {
3452
+ function getCurrentEventStateWithDrafts({
3453
+ event: event2,
3454
+ drafts,
3455
+ configuration
3456
+ }) {
3089
3457
  const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
3090
3458
  const activeDrafts = findActiveDrafts(event2, drafts).map((draft) => draft.action).flatMap((action) => {
3091
3459
  if (action.type === ActionType.REQUEST_CORRECTION) {
@@ -3104,7 +3472,7 @@ function getCurrentEventStateWithDrafts(event2, drafts) {
3104
3472
  ...event2,
3105
3473
  actions: actionWithDrafts
3106
3474
  };
3107
- return getCurrentEventState(withDrafts);
3475
+ return getCurrentEventState(withDrafts, configuration);
3108
3476
  }
3109
3477
  function applyDraftsToEventIndex(eventIndex, drafts) {
3110
3478
  const indexedAt = eventIndex.updatedAt;
@@ -3158,8 +3526,24 @@ function generateTransactionId() {
3158
3526
  return getUUID();
3159
3527
  }
3160
3528
 
3529
+ // ../commons/src/events/User.ts
3530
+ var import_zod30 = require("zod");
3531
+ var User = import_zod30.z.object({
3532
+ id: import_zod30.z.string(),
3533
+ name: import_zod30.z.array(
3534
+ import_zod30.z.object({
3535
+ use: import_zod30.z.string(),
3536
+ given: import_zod30.z.array(import_zod30.z.string()),
3537
+ family: import_zod30.z.string()
3538
+ })
3539
+ ),
3540
+ role: import_zod30.z.string(),
3541
+ signatureFilename: import_zod30.z.string().optional()
3542
+ });
3543
+
3161
3544
  // ../commons/src/events/test.utils.ts
3162
3545
  var import_lodash2 = require("lodash");
3546
+ var import_addDays = __toESM(require("date-fns/addDays"));
3163
3547
 
3164
3548
  // ../commons/src/field-config/field-configuration.ts
3165
3549
  function createFieldConfig(fieldId, options) {
@@ -3183,7 +3567,7 @@ function field(fieldId, options = {}) {
3183
3567
  };
3184
3568
  }
3185
3569
 
3186
- // ../commons/src/fixtures/tennis-club-membership-event.ts
3570
+ // ../commons/src/fixtures/forms.ts
3187
3571
  var import_date_fns2 = require("date-fns");
3188
3572
  var PRINT_CERTIFICATE_FORM = defineActionForm({
3189
3573
  label: {
@@ -4174,7 +4558,10 @@ var timePeriodOptions = [
4174
4558
  description: "Label for option of time period select: last 7 days",
4175
4559
  id: "form.section.label.timePeriodLast7Days"
4176
4560
  },
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")}`
4561
+ value: `${(0, import_date_fns2.format)((0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 7), "yyyy-MM-dd")},${(0, import_date_fns2.format)(
4562
+ /* @__PURE__ */ new Date(),
4563
+ "yyyy-MM-dd"
4564
+ )}`
4178
4565
  },
4179
4566
  {
4180
4567
  label: {
@@ -4182,7 +4569,10 @@ var timePeriodOptions = [
4182
4569
  description: "Label for option of time period select: last 30 days",
4183
4570
  id: "form.section.label.timePeriodLast30Days"
4184
4571
  },
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")}`
4572
+ value: `${(0, import_date_fns2.format)((0, import_date_fns2.subMonths)(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd")},${(0, import_date_fns2.format)(
4573
+ /* @__PURE__ */ new Date(),
4574
+ "yyyy-MM-dd"
4575
+ )}`
4186
4576
  },
4187
4577
  {
4188
4578
  label: {
@@ -4190,7 +4580,10 @@ var timePeriodOptions = [
4190
4580
  description: "Label for option of time period select: last 90 days",
4191
4581
  id: "form.section.label.timePeriodLast90Days"
4192
4582
  },
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")}`
4583
+ value: `${(0, import_date_fns2.format)((0, import_date_fns2.subQuarters)(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd")},${(0, import_date_fns2.format)(
4584
+ /* @__PURE__ */ new Date(),
4585
+ "yyyy-MM-dd"
4586
+ )}`
4194
4587
  },
4195
4588
  {
4196
4589
  label: {
@@ -4198,15 +4591,20 @@ var timePeriodOptions = [
4198
4591
  description: "Label for option of time period select: last year",
4199
4592
  id: "form.section.label.timePeriodLastYear"
4200
4593
  },
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")}`
4594
+ value: `${(0, import_date_fns2.format)((0, import_date_fns2.subYears)(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd")},${(0, import_date_fns2.format)(
4595
+ /* @__PURE__ */ new Date(),
4596
+ "yyyy-MM-dd"
4597
+ )}`
4202
4598
  }
4203
4599
  ];
4600
+
4601
+ // ../commons/src/fixtures/tennis-club-membership-event.ts
4204
4602
  var tennisClubMembershipEvent = defineConfig({
4205
- id: "TENNIS_CLUB_MEMBERSHIP",
4603
+ id: TENNIS_CLUB_MEMBERSHIP,
4206
4604
  label: {
4207
4605
  defaultMessage: "Tennis club membership application",
4208
4606
  description: "This is what this event is referred as in the system",
4209
- id: "event.tennis-club-membership.label"
4607
+ id: "v2.event.tennis-club-membership.label"
4210
4608
  },
4211
4609
  title: {
4212
4610
  defaultMessage: "{applicant.firstname} {applicant.surname}",
@@ -4247,6 +4645,15 @@ var tennisClubMembershipEvent = defineConfig({
4247
4645
  ]
4248
4646
  },
4249
4647
  actions: [
4648
+ {
4649
+ type: ActionType.READ,
4650
+ label: {
4651
+ id: "v2.event.tennis-club-membership.action.read.label",
4652
+ defaultMessage: "Read",
4653
+ description: "Title of the read only page"
4654
+ },
4655
+ review: TENNIS_CLUB_DECLARATION_REVIEW
4656
+ },
4250
4657
  {
4251
4658
  type: ActionType.DECLARE,
4252
4659
  label: {
@@ -4587,8 +4994,481 @@ var tennisClubMembershipEvent = defineConfig({
4587
4994
  ],
4588
4995
  declaration: TENNIS_CLUB_DECLARATION_FORM
4589
4996
  });
4590
-
4591
- // ../commons/src/events/test.utils.ts
4997
+ var WorkqueueFixture = defineWorkqueues([
4998
+ {
4999
+ columns: [],
5000
+ slug: "in-progress",
5001
+ name: {
5002
+ id: "workqueues.inProgress.title",
5003
+ defaultMessage: "In progress",
5004
+ description: "Title of in progress workqueue"
5005
+ },
5006
+ query: {
5007
+ type: "and",
5008
+ clauses: [{ eventType: tennisClubMembershipEvent.id }]
5009
+ },
5010
+ actions: [],
5011
+ icon: "Draft"
5012
+ }
5013
+ ]);
5014
+
5015
+ // ../commons/src/fixtures/football-club-membership-event.ts
5016
+ var footballClubMembershipEvent = defineConfig({
5017
+ id: "FOOTBALL_CLUB_MEMBERSHIP",
5018
+ label: {
5019
+ defaultMessage: "Football club membership application",
5020
+ description: "This is what this event is referred as in the system",
5021
+ id: "event.football-club-membership.label"
5022
+ },
5023
+ title: {
5024
+ defaultMessage: "{applicant.firstname} {applicant.surname}",
5025
+ description: "This is the title of the summary",
5026
+ id: "v2.event.football-club-membership.title"
5027
+ },
5028
+ summary: {
5029
+ fields: [
5030
+ {
5031
+ id: "applicant.firstname",
5032
+ label: {
5033
+ defaultMessage: "Applicant's first name",
5034
+ description: "This is the label for the field",
5035
+ id: "event.football-club-membership.summary.field.firstname.label"
5036
+ },
5037
+ value: {
5038
+ defaultMessage: "{applicant.firstname}",
5039
+ description: "This is the value to show in the summary",
5040
+ id: "event.football-club-membership.summary.field.firstname"
5041
+ },
5042
+ emptyValueMessage: {
5043
+ defaultMessage: "First name is not provided",
5044
+ description: "This is the message to show when the field is empty",
5045
+ id: "event.football-club-membership.summary.field.firstname.empty"
5046
+ }
5047
+ },
5048
+ {
5049
+ fieldId: "applicant.surname",
5050
+ label: {
5051
+ defaultMessage: "Applicant's last name",
5052
+ description: "Label for surname",
5053
+ id: "v2.event.football-club-membership.summary.field.surname.label"
5054
+ }
5055
+ },
5056
+ {
5057
+ fieldId: "applicant.email"
5058
+ }
5059
+ ]
5060
+ },
5061
+ actions: [
5062
+ {
5063
+ type: ActionType.READ,
5064
+ label: {
5065
+ id: "v2.event.football-club-membership.action.read.label",
5066
+ defaultMessage: "Read",
5067
+ description: "Title of the read only page"
5068
+ },
5069
+ review: TENNIS_CLUB_DECLARATION_REVIEW
5070
+ },
5071
+ {
5072
+ type: ActionType.DECLARE,
5073
+ label: {
5074
+ defaultMessage: "Send an application",
5075
+ description: "This is shown as the action name anywhere the user can trigger the action from",
5076
+ id: "event.football-club-membership.action.declare.label"
5077
+ },
5078
+ review: TENNIS_CLUB_DECLARATION_REVIEW
5079
+ },
5080
+ {
5081
+ type: ActionType.VALIDATE,
5082
+ label: {
5083
+ defaultMessage: "Validate",
5084
+ description: "This is shown as the action name anywhere the user can trigger the action from",
5085
+ id: "event.football-club-membership.action.validate.label"
5086
+ },
5087
+ review: TENNIS_CLUB_DECLARATION_REVIEW
5088
+ },
5089
+ {
5090
+ type: ActionType.REGISTER,
5091
+ label: {
5092
+ defaultMessage: "Register",
5093
+ description: "This is shown as the action name anywhere the user can trigger the action from",
5094
+ id: "event.football-club-membership.action.register.label"
5095
+ },
5096
+ review: TENNIS_CLUB_DECLARATION_REVIEW
5097
+ },
5098
+ {
5099
+ type: ActionType.REQUEST_CORRECTION,
5100
+ label: {
5101
+ defaultMessage: "Request correction",
5102
+ description: "This is shown as the action name anywhere the user can trigger the action from",
5103
+ id: "event.football-club-membership.action.correction.request.label"
5104
+ },
5105
+ onboardingForm: [
5106
+ {
5107
+ id: "correction-requester",
5108
+ type: PageTypes.enum.FORM,
5109
+ title: {
5110
+ id: "event.football-club-membership.action.requestCorrection.form.section.corrector",
5111
+ defaultMessage: "Correction requester",
5112
+ description: "This is the title of the section"
5113
+ },
5114
+ fields: [
5115
+ {
5116
+ id: "correction.requester.relationshop.intro",
5117
+ type: "PAGE_HEADER",
5118
+ label: {
5119
+ id: "correction.requester.relationshop.intro.label",
5120
+ 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.",
5121
+ description: "The title for the corrector form"
5122
+ }
5123
+ },
5124
+ {
5125
+ id: "correction.requester.relationship",
5126
+ type: "RADIO_GROUP",
5127
+ label: {
5128
+ id: "v2.correction.corrector.title",
5129
+ defaultMessage: "Who is requesting a change to this record?",
5130
+ description: "The title for the corrector form"
5131
+ },
5132
+ defaultValue: "",
5133
+ options: [
5134
+ {
5135
+ value: "INFORMANT",
5136
+ label: {
5137
+ id: "v2.correction.corrector.informant",
5138
+ defaultMessage: "Informant",
5139
+ description: "Label for informant option in certificate correction form"
5140
+ }
5141
+ },
5142
+ {
5143
+ value: "ANOTHER_AGENT",
5144
+ label: {
5145
+ id: "v2.correction.corrector.anotherAgent",
5146
+ defaultMessage: "Another registration agent or field agent",
5147
+ description: "Label for another registration or field agent option in certificate correction form"
5148
+ }
5149
+ },
5150
+ {
5151
+ value: "REGISTRAR",
5152
+ label: {
5153
+ id: "v2.correction.corrector.me",
5154
+ defaultMessage: "Me (Registrar)",
5155
+ description: "Label for registrar option in certificate correction form"
5156
+ }
5157
+ },
5158
+ {
5159
+ value: "OTHER",
5160
+ label: {
5161
+ id: "v2.correction.corrector.others",
5162
+ defaultMessage: "Someone else",
5163
+ description: "Label for someone else option in certificate correction form"
5164
+ }
5165
+ }
5166
+ ]
5167
+ }
5168
+ ]
5169
+ },
5170
+ {
5171
+ id: "identity-check",
5172
+ type: PageTypes.enum.FORM,
5173
+ title: {
5174
+ id: "event.football-club-membership.action.requestCorrection.form.section.verify",
5175
+ defaultMessage: "Verify their identity",
5176
+ description: "This is the title of the section"
5177
+ },
5178
+ fields: [
5179
+ {
5180
+ id: "correction.identity-check.instructions",
5181
+ type: "PAGE_HEADER",
5182
+ label: {
5183
+ id: "correction.corrector.identity.instruction",
5184
+ defaultMessage: "Please verify the identity of the person making this request",
5185
+ description: "The title for the corrector form"
5186
+ }
5187
+ },
5188
+ {
5189
+ id: "correction.identity-check.verified",
5190
+ type: "RADIO_GROUP",
5191
+ label: {
5192
+ id: "correction.corrector.identity.verified.label",
5193
+ defaultMessage: "Identity verified",
5194
+ description: "The title for the corrector form"
5195
+ },
5196
+ defaultValue: "",
5197
+ required: true,
5198
+ options: [
5199
+ {
5200
+ value: "VERIFIED",
5201
+ label: {
5202
+ id: "correction.corrector.identity.verified",
5203
+ defaultMessage: "I have verified their identity",
5204
+ description: "Label for verified option in corrector identity check page"
5205
+ }
5206
+ }
5207
+ ]
5208
+ }
5209
+ ]
5210
+ }
5211
+ ],
5212
+ additionalDetailsForm: [
5213
+ {
5214
+ id: "correction-request.supporting-documents",
5215
+ type: PageTypes.enum.FORM,
5216
+ title: {
5217
+ id: "event.football-club-membership.action.requestCorrection.form.section.verify",
5218
+ defaultMessage: "Upload supporting documents",
5219
+ description: "This is the title of the section"
5220
+ },
5221
+ fields: [
5222
+ {
5223
+ id: "correction.supportingDocs.introduction",
5224
+ type: "PAGE_HEADER",
5225
+ label: {
5226
+ id: "correction.corrector.paragraph.title",
5227
+ 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.",
5228
+ description: "The title for the corrector form"
5229
+ }
5230
+ },
5231
+ {
5232
+ id: "correction.supportingDocs",
5233
+ type: FieldType.FILE,
5234
+ label: {
5235
+ id: "correction.corrector.title",
5236
+ defaultMessage: "Upload supporting documents",
5237
+ description: "The title for the corrector form"
5238
+ }
5239
+ },
5240
+ {
5241
+ id: "correction.request.supportingDocuments",
5242
+ type: "RADIO_GROUP",
5243
+ label: {
5244
+ id: "correction.corrector.title",
5245
+ defaultMessage: "Who is requesting a change to this record?",
5246
+ description: "The title for the corrector form"
5247
+ },
5248
+ defaultValue: "",
5249
+ configuration: {
5250
+ styles: {
5251
+ size: "NORMAL"
5252
+ }
5253
+ },
5254
+ options: [
5255
+ {
5256
+ value: "ATTEST",
5257
+ label: {
5258
+ id: "correction.supportingDocuments.attest.label",
5259
+ defaultMessage: "I attest to seeing supporting documentation and have a copy filed at my office",
5260
+ description: ""
5261
+ }
5262
+ },
5263
+ {
5264
+ value: "NOT_NEEDED",
5265
+ label: {
5266
+ id: "correction.supportingDocuments.notNeeded.label",
5267
+ defaultMessage: "No supporting documents required",
5268
+ description: ""
5269
+ }
5270
+ }
5271
+ ]
5272
+ }
5273
+ ]
5274
+ },
5275
+ {
5276
+ id: "correction-request.additional-details",
5277
+ type: PageTypes.enum.FORM,
5278
+ title: {
5279
+ id: "event.football-club-membership.action.requestCorrection.form.section.corrector",
5280
+ defaultMessage: "Reason for correction",
5281
+ description: "This is the title of the section"
5282
+ },
5283
+ fields: [
5284
+ {
5285
+ id: "correction.request.reason",
5286
+ type: FieldType.TEXT,
5287
+ label: {
5288
+ id: "correction.reason.title",
5289
+ defaultMessage: "Reason for correction?",
5290
+ description: "The title for the corrector form"
5291
+ }
5292
+ }
5293
+ ]
5294
+ }
5295
+ ]
5296
+ },
5297
+ {
5298
+ type: ActionType.APPROVE_CORRECTION,
5299
+ label: {
5300
+ defaultMessage: "Approve correction",
5301
+ description: "This is shown as the action name anywhere the user can trigger the action from",
5302
+ id: "event.football-club-membership.action.correction.approve.label"
5303
+ }
5304
+ },
5305
+ {
5306
+ type: ActionType.PRINT_CERTIFICATE,
5307
+ label: {
5308
+ id: "v2.event.football-club-membership.action.collect-certificate.label",
5309
+ defaultMessage: "Print certificate",
5310
+ description: "This is shown as the action name anywhere the user can trigger the action from"
5311
+ },
5312
+ printForm: PRINT_CERTIFICATE_FORM,
5313
+ conditionals: [
5314
+ {
5315
+ type: "SHOW",
5316
+ conditional: defineConditional({
5317
+ type: "object",
5318
+ properties: {
5319
+ $event: {
5320
+ type: "object",
5321
+ properties: {
5322
+ actions: {
5323
+ type: "array",
5324
+ contains: {
5325
+ type: "object",
5326
+ properties: {
5327
+ type: {
5328
+ const: "REGISTER"
5329
+ },
5330
+ draft: {
5331
+ type: "boolean"
5332
+ }
5333
+ },
5334
+ required: ["type"],
5335
+ not: {
5336
+ properties: {
5337
+ draft: {
5338
+ const: true
5339
+ }
5340
+ }
5341
+ }
5342
+ }
5343
+ }
5344
+ },
5345
+ required: ["actions"]
5346
+ }
5347
+ },
5348
+ required: ["$event"]
5349
+ })
5350
+ }
5351
+ ]
5352
+ },
5353
+ {
5354
+ type: ActionType.ARCHIVE,
5355
+ label: {
5356
+ id: "v2.event.football-club-membership.action.archive.label",
5357
+ defaultMessage: "Archive",
5358
+ description: "This is shown as the action name anywhere the user can trigger the action from"
5359
+ }
5360
+ },
5361
+ {
5362
+ type: ActionType.REJECT,
5363
+ label: {
5364
+ id: "v2.event.football-club-membership.action.reject.label",
5365
+ defaultMessage: "Reject",
5366
+ description: "This is shown as the action name anywhere the user can trigger the action from"
5367
+ }
5368
+ }
5369
+ ],
5370
+ advancedSearch: [
5371
+ {
5372
+ title: {
5373
+ defaultMessage: "Registration details",
5374
+ description: "The title of Registration details accordion",
5375
+ id: "v2.advancedSearch.form.registrationDetails"
5376
+ },
5377
+ fields: [
5378
+ event("legalStatus.REGISTERED.createdAtLocation").exact(),
5379
+ event("legalStatus.REGISTERED.createdAt").range(),
5380
+ event("status", statusOptions).exact(),
5381
+ event("updatedAt", timePeriodOptions).range()
5382
+ ]
5383
+ },
5384
+ {
5385
+ title: {
5386
+ defaultMessage: "Applicant's details",
5387
+ description: "Applicant details search field section title",
5388
+ id: "v2.event.football-club-membership.search.applicants"
5389
+ },
5390
+ fields: [
5391
+ field("applicant.firstname").fuzzy(),
5392
+ field("applicant.surname").fuzzy(),
5393
+ field("applicant.dob").range(),
5394
+ field("applicant.email").exact()
5395
+ ]
5396
+ },
5397
+ {
5398
+ title: {
5399
+ defaultMessage: "Recommender's details",
5400
+ description: "Recommender details search field section title",
5401
+ id: "v2.event.football-club-membership.search.recommender"
5402
+ },
5403
+ fields: [
5404
+ field("recommender.firstname").fuzzy(),
5405
+ field("recommender.surname").fuzzy()
5406
+ ]
5407
+ }
5408
+ ],
5409
+ declaration: TENNIS_CLUB_DECLARATION_FORM
5410
+ });
5411
+
5412
+ // ../commons/src/fixtures/library-membership-event.ts
5413
+ var libraryMembershipForm = defineDeclarationForm({
5414
+ label: {
5415
+ id: "v2.event.library-membership.action.declare.form.label",
5416
+ defaultMessage: "Library membership application",
5417
+ description: "This is what this form is referred as in the system"
5418
+ },
5419
+ pages: [
5420
+ {
5421
+ id: "member",
5422
+ title: {
5423
+ id: "v2.event.library-membership.action.declare.form.section.who.title",
5424
+ defaultMessage: "Who is applying for the membership?",
5425
+ description: "This is the title of the section"
5426
+ },
5427
+ fields: [
5428
+ {
5429
+ id: "member.firstname",
5430
+ type: FieldType.TEXT,
5431
+ required: true,
5432
+ conditionals: [],
5433
+ label: {
5434
+ defaultMessage: "Member's first name",
5435
+ description: "This is the label for the field",
5436
+ id: "v2.event.library-membership.action.declare.form.section.who.field.firstname.label"
5437
+ }
5438
+ },
5439
+ {
5440
+ id: "member.surname",
5441
+ type: FieldType.TEXT,
5442
+ required: true,
5443
+ conditionals: [],
5444
+ label: {
5445
+ defaultMessage: "Member's surname",
5446
+ description: "This is the label for the field",
5447
+ id: "v2.event.library-membership.action.declare.form.section.who.field.surname.label"
5448
+ }
5449
+ }
5450
+ ]
5451
+ }
5452
+ ]
5453
+ });
5454
+ var libraryMembershipEvent = defineConfig({
5455
+ id: "library-membership",
5456
+ label: {
5457
+ defaultMessage: "Library membership application",
5458
+ description: "This is what this event is referred as in the system",
5459
+ id: "event.library-membership.label"
5460
+ },
5461
+ title: {
5462
+ defaultMessage: "{member.firstname} {member.surname}",
5463
+ description: "This is the title of the summary",
5464
+ id: "v2.event.library-membership.title"
5465
+ },
5466
+ summary: { fields: [] },
5467
+ actions: [],
5468
+ declaration: libraryMembershipForm
5469
+ });
5470
+
5471
+ // ../commons/src/events/test.utils.ts
4592
5472
  function fieldConfigsToActionPayload(fields) {
4593
5473
  return fields.reduce(
4594
5474
  (acc, field2, i) => ({
@@ -4635,11 +5515,11 @@ function generateActionAnnotationInput(configuration, action) {
4635
5515
  var eventPayloadGenerator = {
4636
5516
  create: (input = {}) => ({
4637
5517
  transactionId: input.transactionId ?? getUUID(),
4638
- type: input.type ?? "TENNIS_CLUB_MEMBERSHIP"
5518
+ type: input.type ?? TENNIS_CLUB_MEMBERSHIP
4639
5519
  }),
4640
5520
  patch: (id, input = {}) => ({
4641
5521
  transactionId: input.transactionId ?? getUUID(),
4642
- type: input.type ?? "TENNIS_CLUB_MEMBERSHIP",
5522
+ type: input.type ?? TENNIS_CLUB_MEMBERSHIP,
4643
5523
  id
4644
5524
  }),
4645
5525
  draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
@@ -4665,7 +5545,7 @@ var eventPayloadGenerator = {
4665
5545
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4666
5546
  createdBy: "@todo",
4667
5547
  createdByRole: "@todo",
4668
- createdAtLocation: "@todo"
5548
+ createdAtLocation: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c"
4669
5549
  }
4670
5550
  },
4671
5551
  input
@@ -4739,9 +5619,13 @@ var eventPayloadGenerator = {
4739
5619
  transactionId: input.transactionId ?? getUUID(),
4740
5620
  declaration: {},
4741
5621
  // @TODO: Check whether generator is needed?
4742
- annotation: { isDuplicate: isDuplicate ?? false },
5622
+ annotation: {},
4743
5623
  duplicates: [],
4744
- eventId
5624
+ eventId,
5625
+ reason: {
5626
+ message: `${ActionType.ARCHIVE}`,
5627
+ isDuplicate: isDuplicate ?? false
5628
+ }
4745
5629
  }),
4746
5630
  reject: (eventId, input = {}) => ({
4747
5631
  type: ActionType.REJECT,
@@ -4752,7 +5636,8 @@ var eventPayloadGenerator = {
4752
5636
  ActionType.REJECT
4753
5637
  ),
4754
5638
  duplicates: [],
4755
- eventId
5639
+ eventId,
5640
+ reason: { message: `${ActionType.REJECT}` }
4756
5641
  }),
4757
5642
  register: (eventId, input = {}) => ({
4758
5643
  type: ActionType.REGISTER,
@@ -4849,9 +5734,9 @@ function generateActionDocument({
4849
5734
  case ActionType.VALIDATE:
4850
5735
  return { ...actionBase, type: action };
4851
5736
  case ActionType.ARCHIVE:
4852
- return { ...actionBase, type: action };
5737
+ return { ...actionBase, type: action, reason: { message: "Archive" } };
4853
5738
  case ActionType.REJECT:
4854
- return { ...actionBase, type: action };
5739
+ return { ...actionBase, type: action, reason: { message: "Reject" } };
4855
5740
  case ActionType.CREATE:
4856
5741
  return { ...actionBase, type: action };
4857
5742
  case ActionType.NOTIFY:
@@ -4863,7 +5748,11 @@ function generateActionDocument({
4863
5748
  case ActionType.APPROVE_CORRECTION:
4864
5749
  return { ...actionBase, requestId: getUUID(), type: action };
4865
5750
  case ActionType.REJECT_CORRECTION:
4866
- return { ...actionBase, requestId: getUUID(), type: action };
5751
+ return {
5752
+ ...actionBase,
5753
+ requestId: getUUID(),
5754
+ type: action
5755
+ };
4867
5756
  case ActionType.REGISTER:
4868
5757
  return {
4869
5758
  ...actionBase,
@@ -4891,8 +5780,7 @@ function generateEventDocument({
4891
5780
  id: getUUID(),
4892
5781
  // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
4893
5782
  // @TODO: This should be fixed in the future.
4894
- updatedAt: new Date(Date.now() - 1e3).toISOString(),
4895
- dateOfEvent: configuration.dateOfEvent
5783
+ updatedAt: new Date(Date.now() - 1e3).toISOString()
4896
5784
  };
4897
5785
  }
4898
5786
  function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, declaration = {}) {
@@ -4914,21 +5802,16 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, de
4914
5802
  eventId
4915
5803
  };
4916
5804
  }
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];
5805
+ function pickRandom(rng, items) {
5806
+ return items[Math.floor(rng() * items.length)];
4925
5807
  }
4926
- function getTrackingId() {
4927
- const uuid = getUUID().replace(/-/g, "");
4928
- const trackingId = uuid.slice(0, 6).toUpperCase();
4929
- return trackingId;
5808
+ function getRandomDatetime(rng, start, end) {
5809
+ const range = end.getTime() - start.getTime();
5810
+ const offset = Math.floor(rng() * range);
5811
+ const randomDate = new Date(start.getTime() + offset);
5812
+ return randomDate.toISOString();
4930
5813
  }
4931
- function getRandomApplicant() {
5814
+ function generateRandomApplicant(rng) {
4932
5815
  const firstNames = [
4933
5816
  "Danny",
4934
5817
  "John",
@@ -4949,18 +5832,13 @@ function getRandomApplicant() {
4949
5832
  "Garcia",
4950
5833
  "Miller"
4951
5834
  ];
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(
5835
+ const randomFirstName = pickRandom(rng, firstNames);
5836
+ const randomSurname = pickRandom(rng, surnames);
5837
+ const randomDob = getRandomDatetime(
5838
+ rng,
4961
5839
  /* @__PURE__ */ new Date("1990-01-01"),
4962
5840
  /* @__PURE__ */ new Date("2010-12-31")
4963
- );
5841
+ ).split("T")[0];
4964
5842
  return {
4965
5843
  "recommender.none": true,
4966
5844
  "applicant.firstname": randomFirstName,
@@ -4968,28 +5846,75 @@ function getRandomApplicant() {
4968
5846
  "applicant.dob": randomDob
4969
5847
  };
4970
5848
  }
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
- });
5849
+ function createPseudoRandomNumberGenerator(seed) {
5850
+ const MODULUS = 2 ** 32;
5851
+ const MULTIPLIER = 1664525;
5852
+ const INCREMENT = 1013904223;
5853
+ let state = seed >>> 0;
5854
+ return () => {
5855
+ state = (MULTIPLIER * state + INCREMENT) % MODULUS;
5856
+ return state / MODULUS;
5857
+ };
5858
+ }
5859
+ function generateUuid(rng) {
5860
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
5861
+ const r = Math.floor(rng() * 16);
5862
+ const v = c === "x" ? r : r & 3 | 8;
5863
+ return v.toString(16);
5864
+ });
5865
+ }
5866
+ function generateTrackingId(rng) {
5867
+ const uuid = generateUuid(rng).replace(/-/g, "");
5868
+ const trackingId = uuid.slice(0, 6).toUpperCase();
5869
+ return trackingId;
5870
+ }
5871
+ var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
5872
+ const rng = createPseudoRandomNumberGenerator(seed);
5873
+ const createdAt = getRandomDatetime(
5874
+ rng,
5875
+ /* @__PURE__ */ new Date("2024-01-01"),
5876
+ /* @__PURE__ */ new Date("2024-12-31")
5877
+ );
5878
+ return {
5879
+ id: overrides.id ?? generateUuid(rng),
5880
+ type: overrides.type ?? TENNIS_CLUB_MEMBERSHIP,
5881
+ status: overrides.status ?? pickRandom(rng, eventStatuses),
5882
+ createdAt: overrides.createdAt ?? createdAt,
5883
+ createdBy: overrides.createdBy ?? generateUuid(rng),
5884
+ createdAtLocation: overrides.createdAtLocation ?? generateUuid(rng),
5885
+ updatedAtLocation: overrides.updatedAtLocation ?? generateUuid(rng),
5886
+ updatedAt: overrides.updatedAt ?? (0, import_addDays.default)(new Date(createdAt), 1).toISOString(),
5887
+ assignedTo: overrides.assignedTo ?? null,
5888
+ updatedBy: overrides.updatedBy ?? generateUuid(rng),
5889
+ updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
5890
+ flags: [],
5891
+ legalStatuses: overrides.legalStatuses ?? {},
5892
+ declaration: overrides.declaration ?? generateRandomApplicant(rng),
5893
+ trackingId: overrides.trackingId ?? generateTrackingId(rng)
5894
+ };
5895
+ };
4988
5896
  var generateTranslationConfig = (message) => ({
4989
5897
  defaultMessage: message,
4990
5898
  description: "Description for ${message}",
4991
5899
  id: message
4992
5900
  });
5901
+ var generateWorkqueues = (slug = "all-events") => defineWorkqueues([
5902
+ {
5903
+ slug,
5904
+ name: {
5905
+ id: "workqueues.inProgress.title",
5906
+ defaultMessage: slug.charAt(0).toUpperCase() + slug.slice(1).split("-").join(" "),
5907
+ description: "Title of in progress workqueue"
5908
+ },
5909
+ query: {
5910
+ type: "and",
5911
+ clauses: [{ eventType: tennisClubMembershipEvent.id }]
5912
+ },
5913
+ actions: [],
5914
+ icon: "Draft",
5915
+ columns: []
5916
+ }
5917
+ ]);
4993
5918
 
4994
5919
  // ../commons/src/events/TemplateConfig.ts
4995
5920
  function isTemplateVariable(value) {
@@ -5027,7 +5952,7 @@ function isFieldConfigDefaultValue(value) {
5027
5952
  var import_lodash3 = require("lodash");
5028
5953
 
5029
5954
  // ../commons/src/scopes.ts
5030
- var import_zod25 = require("zod");
5955
+ var import_zod31 = require("zod");
5031
5956
  var SCOPES = {
5032
5957
  // TODO v1.8 legacy scopes
5033
5958
  NATLSYSADMIN: "natlsysadmin",
@@ -5140,111 +6065,111 @@ var SCOPES = {
5140
6065
  // data seeding
5141
6066
  USER_DATA_SEEDING: "user.data-seeding"
5142
6067
  };
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)
6068
+ var LiteralScopes = import_zod31.z.union([
6069
+ import_zod31.z.literal(SCOPES.NATLSYSADMIN),
6070
+ import_zod31.z.literal(SCOPES.BYPASSRATELIMIT),
6071
+ import_zod31.z.literal(SCOPES.DECLARE),
6072
+ import_zod31.z.literal(SCOPES.REGISTER),
6073
+ import_zod31.z.literal(SCOPES.VALIDATE),
6074
+ import_zod31.z.literal(SCOPES.DEMO),
6075
+ import_zod31.z.literal(SCOPES.CERTIFY),
6076
+ import_zod31.z.literal(SCOPES.PERFORMANCE),
6077
+ import_zod31.z.literal(SCOPES.SYSADMIN),
6078
+ import_zod31.z.literal(SCOPES.TEAMS),
6079
+ import_zod31.z.literal(SCOPES.CONFIG),
6080
+ import_zod31.z.literal(SCOPES.WEBHOOK),
6081
+ import_zod31.z.literal(SCOPES.NATIONALID),
6082
+ import_zod31.z.literal(SCOPES.NOTIFICATION_API),
6083
+ import_zod31.z.literal(SCOPES.RECORDSEARCH),
6084
+ import_zod31.z.literal(SCOPES.RECORD_IMPORT),
6085
+ import_zod31.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
6086
+ import_zod31.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
6087
+ import_zod31.z.literal(SCOPES.RECORD_DECLARE_DEATH),
6088
+ import_zod31.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
6089
+ import_zod31.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
6090
+ import_zod31.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
6091
+ import_zod31.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
6092
+ import_zod31.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW),
6093
+ import_zod31.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS),
6094
+ import_zod31.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
6095
+ import_zod31.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
6096
+ import_zod31.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
6097
+ import_zod31.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
6098
+ import_zod31.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
6099
+ import_zod31.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE),
6100
+ import_zod31.z.literal(SCOPES.RECORD_REGISTER),
6101
+ import_zod31.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
6102
+ import_zod31.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
6103
+ import_zod31.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
6104
+ import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
6105
+ import_zod31.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
6106
+ import_zod31.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
6107
+ import_zod31.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
6108
+ import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES),
6109
+ import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
6110
+ import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
6111
+ import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
6112
+ import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
6113
+ import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
6114
+ import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
6115
+ import_zod31.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
6116
+ import_zod31.z.literal(SCOPES.RECORD_REJECT_REGISTRATION),
6117
+ import_zod31.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
6118
+ import_zod31.z.literal(SCOPES.SEARCH_BIRTH),
6119
+ import_zod31.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
6120
+ import_zod31.z.literal(SCOPES.SEARCH_DEATH),
6121
+ import_zod31.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
6122
+ import_zod31.z.literal(SCOPES.SEARCH_MARRIAGE),
6123
+ import_zod31.z.literal(SCOPES.RECORD_READ),
6124
+ import_zod31.z.literal(SCOPES.RECORD_READ_AUDIT),
6125
+ import_zod31.z.literal(SCOPES.RECORD_READ_COMMENTS),
6126
+ import_zod31.z.literal(SCOPES.RECORD_CREATE_COMMENTS),
6127
+ import_zod31.z.literal(SCOPES.PROFILE_UPDATE),
6128
+ import_zod31.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE),
6129
+ import_zod31.z.literal(SCOPES.PERFORMANCE_READ),
6130
+ import_zod31.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
6131
+ import_zod31.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS),
6132
+ import_zod31.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
6133
+ import_zod31.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
6134
+ import_zod31.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION),
6135
+ import_zod31.z.literal(SCOPES.USER_READ),
6136
+ import_zod31.z.literal(SCOPES.USER_READ_MY_OFFICE),
6137
+ import_zod31.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
6138
+ import_zod31.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
6139
+ import_zod31.z.literal(SCOPES.USER_CREATE),
6140
+ import_zod31.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
6141
+ import_zod31.z.literal(SCOPES.USER_UPDATE),
6142
+ import_zod31.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION),
6143
+ import_zod31.z.literal(SCOPES.CONFIG_UPDATE_ALL),
6144
+ import_zod31.z.literal(SCOPES.USER_DATA_SEEDING)
5220
6145
  ]);
5221
6146
  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())
6147
+ var rawConfigurableScope = import_zod31.z.string().regex(rawConfigurableScopeRegex);
6148
+ var CreateUserScope = import_zod31.z.object({
6149
+ type: import_zod31.z.literal("user.create"),
6150
+ options: import_zod31.z.object({
6151
+ role: import_zod31.z.array(import_zod31.z.string())
5227
6152
  })
5228
6153
  });
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())
6154
+ var EditUserScope = import_zod31.z.object({
6155
+ type: import_zod31.z.literal("user.edit"),
6156
+ options: import_zod31.z.object({
6157
+ role: import_zod31.z.array(import_zod31.z.string())
5233
6158
  })
5234
6159
  });
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())
6160
+ var WorkqueueScope = import_zod31.z.object({
6161
+ type: import_zod31.z.literal("workqueue"),
6162
+ options: import_zod31.z.object({
6163
+ id: import_zod31.z.array(import_zod31.z.string())
5239
6164
  })
5240
6165
  });
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())
6166
+ var NotifyRecordScope = import_zod31.z.object({
6167
+ type: import_zod31.z.literal("record.notify"),
6168
+ options: import_zod31.z.object({
6169
+ event: import_zod31.z.array(import_zod31.z.string())
5245
6170
  })
5246
6171
  });
5247
- var ConfigurableScopes = import_zod25.z.discriminatedUnion("type", [
6172
+ var ConfigurableScopes = import_zod31.z.discriminatedUnion("type", [
5248
6173
  CreateUserScope,
5249
6174
  EditUserScope,
5250
6175
  WorkqueueScope,
@@ -5348,3 +6273,65 @@ function filterUnallowedActions(actions, userScopes) {
5348
6273
  }
5349
6274
  return [ActionType.READ];
5350
6275
  }
6276
+
6277
+ // ../commons/src/events/serializers/user/deserializer.ts
6278
+ var import_zod32 = require("zod");
6279
+ var UserWithPrimaryOffice = User.extend({
6280
+ primaryOfficeId: import_zod32.z.string()
6281
+ });
6282
+ function userDeserializer(serializedUserField, user2) {
6283
+ if (typeof serializedUserField === "string") {
6284
+ return serializedUserField;
6285
+ }
6286
+ if (serializedUserField.$userField === "name" || serializedUserField.$userField === "signatureFilename") {
6287
+ throw new Error(
6288
+ `Deserializer for ${serializedUserField.$userField} is not implemented yet`
6289
+ );
6290
+ }
6291
+ return user2[serializedUserField.$userField];
6292
+ }
6293
+ function deserializeQueryExpression(expression, user2) {
6294
+ return {
6295
+ ...expression,
6296
+ assignedTo: expression.assignedTo && {
6297
+ ...expression.assignedTo,
6298
+ term: userDeserializer(expression.assignedTo.term, user2)
6299
+ },
6300
+ createdBy: expression.createdBy && {
6301
+ ...expression.createdBy,
6302
+ term: userDeserializer(expression.createdBy.term, user2)
6303
+ },
6304
+ updatedBy: expression.updatedBy && {
6305
+ ...expression.updatedBy,
6306
+ term: userDeserializer(expression.updatedBy.term, user2)
6307
+ },
6308
+ createdAtLocation: expression.createdAtLocation && (expression.createdAtLocation.type === "within" ? {
6309
+ ...expression.createdAtLocation,
6310
+ location: userDeserializer(
6311
+ expression.createdAtLocation.location,
6312
+ user2
6313
+ )
6314
+ } : {
6315
+ ...expression.createdAtLocation,
6316
+ term: userDeserializer(expression.createdAtLocation.term, user2)
6317
+ }),
6318
+ updatedAtLocation: expression.updatedAtLocation && (expression.updatedAtLocation.type === "within" ? {
6319
+ ...expression.updatedAtLocation,
6320
+ location: userDeserializer(
6321
+ expression.updatedAtLocation.location,
6322
+ user2
6323
+ )
6324
+ } : {
6325
+ ...expression.updatedAtLocation,
6326
+ term: userDeserializer(expression.updatedAtLocation.term, user2)
6327
+ })
6328
+ };
6329
+ }
6330
+ function deserializeQuery(query, user2) {
6331
+ return {
6332
+ ...query,
6333
+ clauses: query.clauses.map(
6334
+ (clause) => deserializeQueryExpression(clause, user2)
6335
+ )
6336
+ };
6337
+ }