@opencrvs/toolkit 1.8.0-rc.fc4c805 → 1.8.0-rc.fcd89ec

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.
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/events/index.ts
31
31
  var events_exports = {};
32
32
  __export(events_exports, {
33
+ ACTION_ALLOWED_CONFIGURABLE_SCOPES: () => ACTION_ALLOWED_CONFIGURABLE_SCOPES,
33
34
  ACTION_ALLOWED_SCOPES: () => ACTION_ALLOWED_SCOPES,
34
35
  Action: () => Action,
35
36
  ActionBase: () => ActionBase,
@@ -96,6 +97,7 @@ __export(events_exports, {
96
97
  EventSearchIndex: () => EventSearchIndex,
97
98
  EventState: () => EventState,
98
99
  EventStatus: () => EventStatus,
100
+ EventStatusEnum: () => EventStatusEnum,
99
101
  EventStatuses: () => EventStatuses,
100
102
  FieldConditional: () => FieldConditional,
101
103
  FieldConfig: () => FieldConfig,
@@ -123,6 +125,7 @@ __export(events_exports, {
123
125
  PageConfig: () => PageConfig,
124
126
  PageTypes: () => PageTypes,
125
127
  PrintCertificateActionInput: () => PrintCertificateActionInput,
128
+ QueryExpression: () => QueryExpression,
126
129
  QueryInput: () => QueryInput,
127
130
  QueryType: () => QueryType,
128
131
  ReadActionInput: () => ReadActionInput,
@@ -136,6 +139,7 @@ __export(events_exports, {
136
139
  RuralAddressUpdateValue: () => RuralAddressUpdateValue,
137
140
  RuralAddressValue: () => RuralAddressValue,
138
141
  SearchField: () => SearchField,
142
+ SearchQueryParams: () => SearchQueryParams,
139
143
  SelectOption: () => SelectOption,
140
144
  ShowConditional: () => ShowConditional,
141
145
  SummaryConfig: () => SummaryConfig,
@@ -203,6 +207,7 @@ __export(events_exports, {
203
207
  getDeclarationFields: () => getDeclarationFields,
204
208
  getDeclarationPages: () => getDeclarationPages,
205
209
  getMixedPath: () => getMixedPath,
210
+ getRandomDatetime: () => getRandomDatetime,
206
211
  getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
207
212
  hasAnyOfScopes: () => hasAnyOfScopes,
208
213
  isAddressFieldType: () => isAddressFieldType,
@@ -262,9 +267,12 @@ var import_zod9 = require("zod");
262
267
 
263
268
  // ../commons/src/events/Conditional.ts
264
269
  var import_zod = require("zod");
265
- var Conditional = import_zod.z.custom(
266
- (val) => typeof val === "object" && val !== null
267
- );
270
+ var import_zod_openapi = require("zod-openapi");
271
+ (0, import_zod_openapi.extendZodWithOpenApi)(import_zod.z);
272
+ var Conditional = import_zod.z.custom((val) => typeof val === "object" && val !== null).openapi({
273
+ description: "JSON schema conditional configuration",
274
+ ref: "Conditional"
275
+ });
268
276
  var ConditionalType = {
269
277
  SHOW: "SHOW",
270
278
  ENABLE: "ENABLE",
@@ -301,7 +309,10 @@ var FieldConditional = import_zod.z.discriminatedUnion("type", [
301
309
  EnableConditional,
302
310
  // Field output can be shown / hidden on the review page
303
311
  DisplayOnReviewConditional
304
- ]);
312
+ ]).openapi({
313
+ description: "Field conditional configuration",
314
+ ref: "FieldConditional"
315
+ });
305
316
 
306
317
  // ../commons/src/events/PageConfig.ts
307
318
  var import_zod6 = require("zod");
@@ -311,6 +322,8 @@ var import_zod5 = require("zod");
311
322
 
312
323
  // ../commons/src/events/TranslationConfig.ts
313
324
  var import_zod2 = require("zod");
325
+ var import_zod_openapi2 = require("zod-openapi");
326
+ (0, import_zod_openapi2.extendZodWithOpenApi)(import_zod2.z);
314
327
  var TranslationConfig = import_zod2.z.object({
315
328
  id: import_zod2.z.string().describe(
316
329
  "The identifier of the translation referred in translation CSV files"
@@ -319,6 +332,9 @@ var TranslationConfig = import_zod2.z.object({
319
332
  description: import_zod2.z.string().describe(
320
333
  "Describe the translation for a translator to be able to identify it."
321
334
  )
335
+ }).openapi({
336
+ description: "Translation configuration",
337
+ ref: "TranslationConfig"
322
338
  });
323
339
 
324
340
  // ../commons/src/events/FieldType.ts
@@ -476,6 +492,8 @@ var FieldUpdateValue = import_zod4.z.union([
476
492
  ]);
477
493
 
478
494
  // ../commons/src/events/FieldConfig.ts
495
+ var import_zod_openapi3 = require("zod-openapi");
496
+ (0, import_zod_openapi3.extendZodWithOpenApi)(import_zod5.z);
479
497
  var FieldId = import_zod5.z.string();
480
498
  var ParentReference = import_zod5.z.object({
481
499
  _fieldId: FieldId.optional()
@@ -500,6 +518,7 @@ var BaseField = import_zod5.z.object({
500
518
  })
501
519
  ).default([]).optional(),
502
520
  label: TranslationConfig,
521
+ helperText: TranslationConfig.optional(),
503
522
  hideLabel: import_zod5.z.boolean().default(false).optional()
504
523
  });
505
524
  var Divider = BaseField.extend({
@@ -740,9 +759,14 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
740
759
  EmailField,
741
760
  FileUploadWithOptions,
742
761
  DataField
743
- ]);
762
+ ]).openapi({
763
+ description: "Form field configuration",
764
+ ref: "FieldConfig"
765
+ });
744
766
 
745
767
  // ../commons/src/events/PageConfig.ts
768
+ var import_zod_openapi4 = require("zod-openapi");
769
+ (0, import_zod_openapi4.extendZodWithOpenApi)(import_zod6.z);
746
770
  var PageTypes = import_zod6.z.enum(["FORM", "VERIFICATION"]);
747
771
  var PageConfigBase = import_zod6.z.object({
748
772
  id: import_zod6.z.string().describe("Unique identifier for the page"),
@@ -751,6 +775,9 @@ var PageConfigBase = import_zod6.z.object({
751
775
  conditional: Conditional.optional().describe(
752
776
  "Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
753
777
  )
778
+ }).openapi({
779
+ description: "Form page configuration",
780
+ ref: "FormPageConfig"
754
781
  });
755
782
  var FormPageConfig = PageConfigBase.extend({
756
783
  type: import_zod6.z.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
@@ -764,7 +791,10 @@ var VerificationActionConfig = import_zod6.z.object({
764
791
  body: TranslationConfig
765
792
  })
766
793
  })
767
- }).describe("Actions available on the verification page");
794
+ }).describe("Actions available on the verification page").openapi({
795
+ description: "Verification action configuration",
796
+ ref: "VerificationActionConfig"
797
+ });
768
798
  var VerificationPageConfig = FormPageConfig.extend({
769
799
  type: import_zod6.z.literal(PageTypes.enum.VERIFICATION),
770
800
  actions: VerificationActionConfig
@@ -864,8 +894,8 @@ var ActionFormConfig = import_zod8.z.object({
864
894
  var FormConfig = import_zod8.z.union([DeclarationFormConfig, ActionFormConfig]);
865
895
 
866
896
  // ../commons/src/events/ActionConfig.ts
867
- var import_zod_openapi = require("zod-openapi");
868
- (0, import_zod_openapi.extendZodWithOpenApi)(import_zod9.z);
897
+ var import_zod_openapi5 = require("zod-openapi");
898
+ (0, import_zod_openapi5.extendZodWithOpenApi)(import_zod9.z);
869
899
  var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
870
900
  /** If conditional is defined, the action is shown to the user only if the condition is met */
871
901
  ShowConditional,
@@ -1004,12 +1034,12 @@ var LanguageConfig = import_zod11.z.object({
1004
1034
  });
1005
1035
 
1006
1036
  // ../commons/src/events/EventConfig.ts
1007
- var import_zod17 = require("zod");
1037
+ var import_zod18 = require("zod");
1008
1038
 
1009
1039
  // ../commons/src/events/DeduplicationConfig.ts
1010
1040
  var import_zod12 = require("zod");
1011
- var import_zod_openapi2 = require("zod-openapi");
1012
- (0, import_zod_openapi2.extendZodWithOpenApi)(import_zod12.z);
1041
+ var import_zod_openapi6 = require("zod-openapi");
1042
+ (0, import_zod_openapi6.extendZodWithOpenApi)(import_zod12.z);
1013
1043
  var FieldReference = import_zod12.z.string();
1014
1044
  var Matcher = import_zod12.z.object({
1015
1045
  fieldId: import_zod12.z.string(),
@@ -1110,13 +1140,58 @@ var BaseField3 = import_zod14.z.object({
1110
1140
  config: import_zod14.z.object({
1111
1141
  type: MatchType.describe("Determines the type of field")
1112
1142
  }),
1113
- options: import_zod14.z.array(SelectOption).optional()
1143
+ options: import_zod14.z.array(SelectOption).optional(),
1144
+ searchCriteriaLabelPrefix: TranslationConfig.optional().describe(
1145
+ `
1146
+ This property determines whether to add a prefix (such as "Child" or "Applicant") before the field label
1147
+ when rendering search parameter labels \u2014 for example, in the search results page to indicate which fields were used in the search.
1148
+
1149
+ For example, a field config like { id: "child.firstname", label: { defaultMessage: "First Name(s)" } } would render as "First Name(s)" by default.
1150
+
1151
+ A field config like { id: "mother.firstname", label: { defaultMessage: "First Name(s)" } } would also render as "First Name(s)" by default.
1152
+
1153
+ So, if both child.firstname and mother.firstname are used in a search, the resulting search criteria labels would be "First Name(s)", "First Name(s)",
1154
+ which is ambiguous.
1155
+
1156
+ Now, if we treat the field ID prefix as a label (e.g., "applicant.firstname" \u2192 "Applicant"), and the field label is already
1157
+ descriptive \u2014 like { id: "applicant.firstname", label: { defaultMessage: "Applicant's First Name" } } \u2014 then the resulting
1158
+ label would be "Applicant Applicant's First Name", which is redundant and awkward.
1159
+
1160
+ By setting searchCriteriaLabelPrefix to a translation config object, we can explicitly define the desired prefix
1161
+ in the country-config > event.advancedSearch configuration. For example: field("child.dob", { searchCriteriaLabelPrefix: TranslationConfig }).
1162
+ `
1163
+ ),
1164
+ conditionals: import_zod14.z.array(FieldConditional).default([]).optional().describe(
1165
+ `
1166
+ In advanced search, we sometimes need to override the default field visibility conditionals.
1167
+
1168
+ For example, Informant fields in the declaration form may have conditional logic
1169
+ that hides them based on other field values. Since the advanced search form reuses
1170
+ the declaration form config, those same conditionals would apply by default.
1171
+
1172
+ However, in advanced search we often want to make all Informant fields searchable,
1173
+ regardless of their original visibility logic. To do this, we explicitly set their
1174
+ 'conditionals' to an empty array ('[]') in the search config. This ensures they
1175
+ are always rendered in the advanced search form.
1176
+ `
1177
+ )
1114
1178
  });
1179
+ var SearchQueryParams = import_zod14.z.object({
1180
+ eventType: import_zod14.z.string().optional().describe(
1181
+ "Defines type of event so that when redirecting to Advanced Search page, appropriate tab can be selected"
1182
+ )
1183
+ }).catchall(FieldValue);
1115
1184
  var FieldConfigSchema = BaseField3.extend({
1116
1185
  fieldId: import_zod14.z.string(),
1117
1186
  fieldType: import_zod14.z.literal("field")
1118
1187
  });
1119
- var EventFieldId = import_zod14.z.enum(["trackingId", "status"]);
1188
+ var EventFieldId = import_zod14.z.enum([
1189
+ "trackingId",
1190
+ "status",
1191
+ "legalStatus.REGISTERED.createdAt",
1192
+ "legalStatus.REGISTERED.createdAtLocation",
1193
+ "updatedAt"
1194
+ ]);
1120
1195
  var EventFieldConfigSchema = BaseField3.extend({
1121
1196
  fieldId: EventFieldId,
1122
1197
  fieldType: import_zod14.z.literal("event")
@@ -1134,114 +1209,120 @@ var AdvancedSearchConfig = import_zod14.z.object({
1134
1209
  var import_lodash = require("lodash");
1135
1210
 
1136
1211
  // ../commons/src/events/ActionDocument.ts
1212
+ var import_zod16 = require("zod");
1213
+ var import_zod_openapi7 = require("zod-openapi");
1214
+
1215
+ // ../commons/src/events/CreatedAtLocation.ts
1137
1216
  var import_zod15 = require("zod");
1138
- var import_zod_openapi3 = require("zod-openapi");
1139
- (0, import_zod_openapi3.extendZodWithOpenApi)(import_zod15.z);
1140
- var ActionUpdate = import_zod15.z.record(import_zod15.z.string(), FieldUpdateValue);
1141
- var EventState = import_zod15.z.record(import_zod15.z.string(), FieldValue);
1217
+ var CreatedAtLocation = import_zod15.z.string().nullish();
1218
+
1219
+ // ../commons/src/events/ActionDocument.ts
1220
+ (0, import_zod_openapi7.extendZodWithOpenApi)(import_zod16.z);
1221
+ var ActionUpdate = import_zod16.z.record(import_zod16.z.string(), FieldUpdateValue);
1222
+ var EventState = import_zod16.z.record(import_zod16.z.string(), FieldValue);
1142
1223
  var ActionStatus = {
1143
1224
  Requested: "Requested",
1144
1225
  Accepted: "Accepted",
1145
1226
  Rejected: "Rejected"
1146
1227
  };
1147
- var ActionBase = import_zod15.z.object({
1148
- id: import_zod15.z.string(),
1149
- transactionId: import_zod15.z.string(),
1150
- createdAt: import_zod15.z.string().datetime(),
1151
- createdBy: import_zod15.z.string(),
1152
- createdByRole: import_zod15.z.string(),
1228
+ var ActionBase = import_zod16.z.object({
1229
+ id: import_zod16.z.string(),
1230
+ transactionId: import_zod16.z.string(),
1231
+ createdAt: import_zod16.z.string().datetime(),
1232
+ createdBy: import_zod16.z.string(),
1233
+ createdByRole: import_zod16.z.string(),
1234
+ createdAtLocation: CreatedAtLocation,
1153
1235
  declaration: ActionUpdate,
1154
1236
  annotation: ActionUpdate.optional(),
1155
- createdAtLocation: import_zod15.z.string(),
1156
- status: import_zod15.z.enum([
1237
+ status: import_zod16.z.enum([
1157
1238
  ActionStatus.Requested,
1158
1239
  ActionStatus.Accepted,
1159
1240
  ActionStatus.Rejected
1160
1241
  ]),
1161
1242
  // If the action is an asynchronous confirmation for another action, we will save the original action id here.
1162
- originalActionId: import_zod15.z.string().optional()
1243
+ originalActionId: import_zod16.z.string().optional()
1163
1244
  });
1164
1245
  var AssignedAction = ActionBase.merge(
1165
- import_zod15.z.object({
1166
- type: import_zod15.z.literal(ActionType.ASSIGN),
1167
- assignedTo: import_zod15.z.string()
1246
+ import_zod16.z.object({
1247
+ type: import_zod16.z.literal(ActionType.ASSIGN),
1248
+ assignedTo: import_zod16.z.string()
1168
1249
  })
1169
1250
  );
1170
1251
  var UnassignedAction = ActionBase.merge(
1171
- import_zod15.z.object({
1172
- type: import_zod15.z.literal(ActionType.UNASSIGN),
1173
- assignedTo: import_zod15.z.literal(null)
1252
+ import_zod16.z.object({
1253
+ type: import_zod16.z.literal(ActionType.UNASSIGN),
1254
+ assignedTo: import_zod16.z.literal(null)
1174
1255
  })
1175
1256
  );
1176
1257
  var RegisterAction = ActionBase.merge(
1177
- import_zod15.z.object({
1178
- type: import_zod15.z.literal(ActionType.REGISTER),
1179
- registrationNumber: import_zod15.z.string().optional()
1258
+ import_zod16.z.object({
1259
+ type: import_zod16.z.literal(ActionType.REGISTER),
1260
+ registrationNumber: import_zod16.z.string().optional()
1180
1261
  })
1181
1262
  );
1182
1263
  var DeclareAction = ActionBase.merge(
1183
- import_zod15.z.object({
1184
- type: import_zod15.z.literal(ActionType.DECLARE)
1264
+ import_zod16.z.object({
1265
+ type: import_zod16.z.literal(ActionType.DECLARE)
1185
1266
  })
1186
1267
  );
1187
1268
  var ValidateAction = ActionBase.merge(
1188
- import_zod15.z.object({
1189
- type: import_zod15.z.literal(ActionType.VALIDATE)
1269
+ import_zod16.z.object({
1270
+ type: import_zod16.z.literal(ActionType.VALIDATE)
1190
1271
  })
1191
1272
  );
1192
1273
  var RejectAction = ActionBase.merge(
1193
- import_zod15.z.object({
1194
- type: import_zod15.z.literal(ActionType.REJECT)
1274
+ import_zod16.z.object({
1275
+ type: import_zod16.z.literal(ActionType.REJECT)
1195
1276
  })
1196
1277
  );
1197
1278
  var MarkAsDuplicateAction = ActionBase.merge(
1198
- import_zod15.z.object({
1199
- type: import_zod15.z.literal(ActionType.MARKED_AS_DUPLICATE)
1279
+ import_zod16.z.object({
1280
+ type: import_zod16.z.literal(ActionType.MARKED_AS_DUPLICATE)
1200
1281
  })
1201
1282
  );
1202
1283
  var ArchiveAction = ActionBase.merge(
1203
- import_zod15.z.object({
1204
- type: import_zod15.z.literal(ActionType.ARCHIVE)
1284
+ import_zod16.z.object({
1285
+ type: import_zod16.z.literal(ActionType.ARCHIVE)
1205
1286
  })
1206
1287
  );
1207
1288
  var CreatedAction = ActionBase.merge(
1208
- import_zod15.z.object({
1209
- type: import_zod15.z.literal(ActionType.CREATE)
1289
+ import_zod16.z.object({
1290
+ type: import_zod16.z.literal(ActionType.CREATE)
1210
1291
  })
1211
1292
  );
1212
1293
  var NotifiedAction = ActionBase.merge(
1213
- import_zod15.z.object({
1214
- type: import_zod15.z.literal(ActionType.NOTIFY)
1294
+ import_zod16.z.object({
1295
+ type: import_zod16.z.literal(ActionType.NOTIFY)
1215
1296
  })
1216
1297
  );
1217
1298
  var PrintCertificateAction = ActionBase.merge(
1218
- import_zod15.z.object({
1219
- type: import_zod15.z.literal(ActionType.PRINT_CERTIFICATE)
1299
+ import_zod16.z.object({
1300
+ type: import_zod16.z.literal(ActionType.PRINT_CERTIFICATE)
1220
1301
  })
1221
1302
  );
1222
1303
  var RequestedCorrectionAction = ActionBase.merge(
1223
- import_zod15.z.object({
1224
- type: import_zod15.z.literal(ActionType.REQUEST_CORRECTION)
1304
+ import_zod16.z.object({
1305
+ type: import_zod16.z.literal(ActionType.REQUEST_CORRECTION)
1225
1306
  })
1226
1307
  );
1227
1308
  var ApprovedCorrectionAction = ActionBase.merge(
1228
- import_zod15.z.object({
1229
- type: import_zod15.z.literal(ActionType.APPROVE_CORRECTION),
1230
- requestId: import_zod15.z.string()
1309
+ import_zod16.z.object({
1310
+ type: import_zod16.z.literal(ActionType.APPROVE_CORRECTION),
1311
+ requestId: import_zod16.z.string()
1231
1312
  })
1232
1313
  );
1233
1314
  var RejectedCorrectionAction = ActionBase.merge(
1234
- import_zod15.z.object({
1235
- type: import_zod15.z.literal(ActionType.REJECT_CORRECTION),
1236
- requestId: import_zod15.z.string()
1315
+ import_zod16.z.object({
1316
+ type: import_zod16.z.literal(ActionType.REJECT_CORRECTION),
1317
+ requestId: import_zod16.z.string()
1237
1318
  })
1238
1319
  );
1239
1320
  var ReadAction = ActionBase.merge(
1240
- import_zod15.z.object({
1241
- type: import_zod15.z.literal(ActionType.READ)
1321
+ import_zod16.z.object({
1322
+ type: import_zod16.z.literal(ActionType.READ)
1242
1323
  })
1243
1324
  );
1244
- var ActionDocument = import_zod15.z.discriminatedUnion("type", [
1325
+ var ActionDocument = import_zod16.z.discriminatedUnion("type", [
1245
1326
  CreatedAction.openapi({ ref: "CreatedAction" }),
1246
1327
  ValidateAction.openapi({ ref: "ValidateAction" }),
1247
1328
  RejectAction.openapi({ ref: "RejectAction" }),
@@ -1264,20 +1345,20 @@ var AsyncRejectActionDocument = ActionBase.omit({
1264
1345
  declaration: true,
1265
1346
  annotation: true
1266
1347
  }).merge(
1267
- import_zod15.z.object({
1268
- type: import_zod15.z.enum(ConfirmableActions),
1269
- status: import_zod15.z.literal(ActionStatus.Rejected)
1348
+ import_zod16.z.object({
1349
+ type: import_zod16.z.enum(ConfirmableActions),
1350
+ status: import_zod16.z.literal(ActionStatus.Rejected)
1270
1351
  })
1271
1352
  );
1272
- var Action = import_zod15.z.union([ActionDocument, AsyncRejectActionDocument]);
1273
- var ResolvedUser = import_zod15.z.object({
1274
- id: import_zod15.z.string(),
1275
- role: import_zod15.z.string(),
1276
- name: import_zod15.z.array(
1277
- import_zod15.z.object({
1278
- use: import_zod15.z.string(),
1279
- given: import_zod15.z.array(import_zod15.z.string()),
1280
- family: import_zod15.z.string()
1353
+ var Action = import_zod16.z.union([ActionDocument, AsyncRejectActionDocument]);
1354
+ var ResolvedUser = import_zod16.z.object({
1355
+ id: import_zod16.z.string(),
1356
+ role: import_zod16.z.string(),
1357
+ name: import_zod16.z.array(
1358
+ import_zod16.z.object({
1359
+ use: import_zod16.z.string(),
1360
+ given: import_zod16.z.array(import_zod16.z.string()),
1361
+ family: import_zod16.z.string()
1281
1362
  })
1282
1363
  )
1283
1364
  });
@@ -1288,7 +1369,7 @@ var import_ajv_formats = __toESM(require("ajv-formats"));
1288
1369
  var import_date_fns = require("date-fns");
1289
1370
 
1290
1371
  // ../commons/src/events/FieldTypeMapping.ts
1291
- var import_zod16 = require("zod");
1372
+ var import_zod17 = require("zod");
1292
1373
  function mapFieldTypeToZod(type, required) {
1293
1374
  let schema;
1294
1375
  switch (type) {
@@ -1343,7 +1424,7 @@ function createValidationSchema(config) {
1343
1424
  for (const field2 of config) {
1344
1425
  shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
1345
1426
  }
1346
- return import_zod16.z.object(shape);
1427
+ return import_zod17.z.object(shape);
1347
1428
  }
1348
1429
  function mapFieldTypeToMockValue(field2, i) {
1349
1430
  switch (field2.type) {
@@ -1890,23 +1971,23 @@ function getMixedPath(obj, path, defaultValue) {
1890
1971
  }
1891
1972
 
1892
1973
  // ../commons/src/events/EventConfig.ts
1893
- var import_zod_openapi4 = require("zod-openapi");
1894
- (0, import_zod_openapi4.extendZodWithOpenApi)(import_zod17.z);
1895
- var EventConfig = import_zod17.z.object({
1896
- id: import_zod17.z.string().describe(
1974
+ var import_zod_openapi8 = require("zod-openapi");
1975
+ (0, import_zod_openapi8.extendZodWithOpenApi)(import_zod18.z);
1976
+ var EventConfig = import_zod18.z.object({
1977
+ id: import_zod18.z.string().describe(
1897
1978
  'A machine-readable identifier for the event, e.g. "birth" or "death"'
1898
1979
  ),
1899
- dateOfEvent: import_zod17.z.object({ fieldId: import_zod17.z.string() }).optional(),
1980
+ dateOfEvent: import_zod18.z.object({ fieldId: import_zod18.z.string() }).optional(),
1900
1981
  title: TranslationConfig,
1901
1982
  fallbackTitle: TranslationConfig.optional().describe(
1902
1983
  "This is a fallback title if actual title resolves to empty string"
1903
1984
  ),
1904
1985
  summary: SummaryConfig,
1905
1986
  label: TranslationConfig,
1906
- actions: import_zod17.z.array(ActionConfig),
1987
+ actions: import_zod18.z.array(ActionConfig),
1907
1988
  declaration: DeclarationFormConfig,
1908
- deduplication: import_zod17.z.array(DeduplicationConfig).optional().default([]),
1909
- advancedSearch: import_zod17.z.array(AdvancedSearchConfig).optional().default([])
1989
+ deduplication: import_zod18.z.array(DeduplicationConfig).optional().default([]),
1990
+ advancedSearch: import_zod18.z.array(AdvancedSearchConfig).optional().default([])
1910
1991
  }).superRefine((event2, ctx) => {
1911
1992
  const allFields = findAllFields(event2);
1912
1993
  const fieldIds = allFields.map((field2) => field2.id);
@@ -1968,13 +2049,13 @@ var definePage = (page) => PageConfig.parse(page);
1968
2049
  var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
1969
2050
 
1970
2051
  // ../commons/src/events/WorkqueueConfig.ts
1971
- var import_zod20 = require("zod");
2052
+ var import_zod21 = require("zod");
1972
2053
 
1973
2054
  // ../commons/src/events/EventIndex.ts
1974
- var import_zod19 = require("zod");
2055
+ var import_zod20 = require("zod");
1975
2056
 
1976
2057
  // ../commons/src/events/EventMetadata.ts
1977
- var import_zod18 = require("zod");
2058
+ var import_zod19 = require("zod");
1978
2059
  var EventStatus = {
1979
2060
  CREATED: "CREATED",
1980
2061
  NOTIFIED: "NOTIFIED",
@@ -1985,56 +2066,71 @@ var EventStatus = {
1985
2066
  REJECTED: "REJECTED",
1986
2067
  ARCHIVED: "ARCHIVED"
1987
2068
  };
2069
+ var eventStatusValues = [
2070
+ EventStatus.CREATED,
2071
+ EventStatus.NOTIFIED,
2072
+ EventStatus.DECLARED,
2073
+ EventStatus.VALIDATED,
2074
+ EventStatus.REGISTERED,
2075
+ EventStatus.CERTIFIED,
2076
+ EventStatus.REJECTED,
2077
+ EventStatus.ARCHIVED
2078
+ ];
2079
+ var EventStatusEnum = import_zod19.z.enum(eventStatusValues);
1988
2080
  var CustomFlags = {
1989
2081
  CERTIFICATE_PRINTED: "certificate-printed"
1990
2082
  };
1991
- var Flag = import_zod18.z.string().regex(
2083
+ var Flag = import_zod19.z.string().regex(
1992
2084
  new RegExp(
1993
2085
  `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(ActionStatus).join("|").toLowerCase()})$`
1994
2086
  ),
1995
2087
  "Flag must be in the format ActionType:ActionStatus (lowerCase)"
1996
- ).or(import_zod18.z.nativeEnum(CustomFlags));
2088
+ ).or(import_zod19.z.nativeEnum(CustomFlags));
1997
2089
  var eventStatuses = Object.values(EventStatus);
1998
- var EventStatuses = import_zod18.z.nativeEnum(EventStatus);
1999
- var ZodDate = import_zod18.z.string().date();
2000
- var ActionCreationMetadata = import_zod18.z.object({
2001
- createdAt: import_zod18.z.string().datetime().describe("The timestamp when the action request was created."),
2002
- createdBy: import_zod18.z.string().describe("ID of the user who created the action request."),
2003
- createdAtLocation: import_zod18.z.string().describe("Location of the user who created the action request."),
2004
- acceptedAt: import_zod18.z.string().datetime().describe("Timestamp when the action request was accepted."),
2005
- createdByRole: import_zod18.z.string().describe("Role of the user at the time of action request creation.")
2090
+ var EventStatuses = import_zod19.z.nativeEnum(EventStatus);
2091
+ var ZodDate = import_zod19.z.string().date();
2092
+ var ActionCreationMetadata = import_zod19.z.object({
2093
+ createdAt: import_zod19.z.string().datetime().describe("The timestamp when the action request was created."),
2094
+ createdBy: import_zod19.z.string().describe("ID of the user who created the action request."),
2095
+ createdAtLocation: CreatedAtLocation.describe(
2096
+ "Location of the user who created the action request."
2097
+ ),
2098
+ acceptedAt: import_zod19.z.string().datetime().describe("Timestamp when the action request was accepted."),
2099
+ createdByRole: import_zod19.z.string().describe("Role of the user at the time of action request creation.")
2006
2100
  });
2007
2101
  var RegistrationCreationMetadata = ActionCreationMetadata.extend({
2008
- registrationNumber: import_zod18.z.string().describe(
2102
+ registrationNumber: import_zod19.z.string().describe(
2009
2103
  "Registration number of the event. Always present for accepted registrations."
2010
2104
  )
2011
2105
  });
2012
- var LegalStatuses = import_zod18.z.object({
2106
+ var LegalStatuses = import_zod19.z.object({
2013
2107
  [EventStatus.DECLARED]: ActionCreationMetadata.nullish(),
2014
2108
  [EventStatus.REGISTERED]: RegistrationCreationMetadata.nullish()
2015
2109
  });
2016
- var EventMetadata = import_zod18.z.object({
2017
- id: import_zod18.z.string(),
2018
- type: import_zod18.z.string().describe("The type of event, such as birth, death, or marriage."),
2110
+ var EventMetadata = import_zod19.z.object({
2111
+ id: import_zod19.z.string(),
2112
+ type: import_zod19.z.string().describe("The type of event, such as birth, death, or marriage."),
2019
2113
  status: EventStatuses,
2020
2114
  legalStatuses: LegalStatuses.describe(
2021
2115
  "Metadata related to the legal registration of the event, such as who registered it and when."
2022
2116
  ),
2023
- createdAt: import_zod18.z.string().datetime().describe("The timestamp when the event was first created and saved."),
2117
+ createdAt: import_zod19.z.string().datetime().describe("The timestamp when the event was first created and saved."),
2024
2118
  dateOfEvent: ZodDate.nullish(),
2025
- createdBy: import_zod18.z.string().describe("ID of the user who created the event."),
2026
- updatedByUserRole: import_zod18.z.string().describe("Role of the user who last updated the declaration."),
2027
- createdAtLocation: import_zod18.z.string().describe("Location of the user who created the event."),
2028
- updatedAtLocation: import_zod18.z.string().nullish().describe("Location of the user who last updated the declaration."),
2029
- updatedAt: import_zod18.z.string().datetime().describe("Timestamp of the most recent declaration update."),
2030
- assignedTo: import_zod18.z.string().nullish().describe("ID of the user currently assigned to the event."),
2031
- updatedBy: import_zod18.z.string().nullish().describe("ID of the user who last updated the declaration."),
2032
- trackingId: import_zod18.z.string().describe(
2119
+ createdBy: import_zod19.z.string().describe("ID of the user who created the event."),
2120
+ updatedByUserRole: import_zod19.z.string().describe("Role of the user who last updated the declaration."),
2121
+ createdAtLocation: CreatedAtLocation.describe(
2122
+ "Location of the user who created the event."
2123
+ ),
2124
+ updatedAtLocation: import_zod19.z.string().nullish().describe("Location of the user who last updated the declaration."),
2125
+ updatedAt: import_zod19.z.string().datetime().describe("Timestamp of the most recent declaration update."),
2126
+ assignedTo: import_zod19.z.string().nullish().describe("ID of the user currently assigned to the event."),
2127
+ updatedBy: import_zod19.z.string().nullish().describe("ID of the user who last updated the declaration."),
2128
+ trackingId: import_zod19.z.string().describe(
2033
2129
  "System-generated tracking ID used by informants or registrars to look up the event."
2034
2130
  ),
2035
- flags: import_zod18.z.array(Flag)
2131
+ flags: import_zod19.z.array(Flag)
2036
2132
  });
2037
- var EventMetadataKeys = import_zod18.z.enum([
2133
+ var EventMetadataKeys = import_zod19.z.enum([
2038
2134
  "id",
2039
2135
  "type",
2040
2136
  "status",
@@ -2051,7 +2147,7 @@ var EventMetadataKeys = import_zod18.z.enum([
2051
2147
  "legalStatuses",
2052
2148
  "flags"
2053
2149
  ]);
2054
- var EventMetadataParameter = import_zod18.z.object({
2150
+ var EventMetadataParameter = import_zod19.z.object({
2055
2151
  // @TODO: Reconcile with the event metadata definition. How could we derive one from the other?
2056
2152
  $event: EventMetadataKeys
2057
2153
  });
@@ -2129,54 +2225,130 @@ var eventMetadataLabelMap = {
2129
2225
  };
2130
2226
 
2131
2227
  // ../commons/src/events/EventIndex.ts
2228
+ var import_zod_openapi9 = require("zod-openapi");
2229
+ (0, import_zod_openapi9.extendZodWithOpenApi)(import_zod20.z);
2132
2230
  var EventIndex = EventMetadata.extend({
2133
2231
  declaration: EventState
2232
+ }).openapi({
2233
+ ref: "EventIndex"
2134
2234
  });
2135
- var EventSearchIndex = import_zod19.z.record(import_zod19.z.string(), import_zod19.z.any()).and(
2136
- import_zod19.z.object({
2137
- type: import_zod19.z.string()
2235
+ var EventSearchIndex = import_zod20.z.record(import_zod20.z.string(), import_zod20.z.any()).and(
2236
+ import_zod20.z.object({
2237
+ type: import_zod20.z.string()
2138
2238
  // Ensures "type" (event-id) exists and is a string
2139
2239
  })
2140
- );
2141
- var Fuzzy = import_zod19.z.object({ type: import_zod19.z.literal("fuzzy"), term: import_zod19.z.string() });
2142
- var Exact = import_zod19.z.object({ type: import_zod19.z.literal("exact"), term: import_zod19.z.string() });
2143
- var AnyOf = import_zod19.z.object({
2144
- type: import_zod19.z.literal("anyOf"),
2145
- terms: import_zod19.z.array(import_zod19.z.string())
2240
+ ).openapi({
2241
+ ref: "EventSearchIndex"
2146
2242
  });
2147
- var Range = import_zod19.z.object({
2148
- type: import_zod19.z.literal("range"),
2149
- gte: import_zod19.z.string(),
2150
- lte: import_zod19.z.string()
2243
+ var Fuzzy = import_zod20.z.object({ type: import_zod20.z.literal("fuzzy"), term: import_zod20.z.string() }).openapi({
2244
+ ref: "Fuzzy"
2151
2245
  });
2152
- var Not = import_zod19.z.object({ type: import_zod19.z.literal("not"), term: import_zod19.z.string() });
2153
- var Within = import_zod19.z.object({ type: import_zod19.z.literal("within"), location: import_zod19.z.string() });
2154
- var DateCondition = import_zod19.z.union([Exact, Range]);
2155
- var QueryInput = import_zod19.z.lazy(
2156
- () => import_zod19.z.union([
2157
- import_zod19.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf, Not]),
2158
- import_zod19.z.record(import_zod19.z.string(), QueryInput)
2246
+ var Exact = import_zod20.z.object({ type: import_zod20.z.literal("exact"), term: import_zod20.z.string() }).openapi({
2247
+ ref: "Exact"
2248
+ });
2249
+ var AnyOf = import_zod20.z.object({
2250
+ type: import_zod20.z.literal("anyOf"),
2251
+ terms: import_zod20.z.array(import_zod20.z.string())
2252
+ }).openapi({
2253
+ ref: "AnyOf"
2254
+ });
2255
+ var ExactStatus = import_zod20.z.object({
2256
+ type: import_zod20.z.literal("exact"),
2257
+ term: EventStatusEnum
2258
+ }).openapi({
2259
+ ref: "ExactStatus"
2260
+ });
2261
+ var AnyOfStatus = import_zod20.z.object({
2262
+ type: import_zod20.z.literal("anyOf"),
2263
+ terms: import_zod20.z.array(EventStatusEnum)
2264
+ }).openapi({
2265
+ ref: "AnyOfStatus"
2266
+ });
2267
+ var Range = import_zod20.z.object({
2268
+ type: import_zod20.z.literal("range"),
2269
+ gte: import_zod20.z.string(),
2270
+ lte: import_zod20.z.string()
2271
+ }).openapi({
2272
+ ref: "Range"
2273
+ });
2274
+ var Not = import_zod20.z.object({ type: import_zod20.z.literal("not"), term: import_zod20.z.string() }).openapi({
2275
+ ref: "Not"
2276
+ });
2277
+ var Within = import_zod20.z.object({ type: import_zod20.z.literal("within"), location: import_zod20.z.string() }).openapi({
2278
+ ref: "Within"
2279
+ });
2280
+ var DateCondition = import_zod20.z.union([Exact, Range]).openapi({
2281
+ ref: "DateCondition"
2282
+ });
2283
+ var QueryInput = import_zod20.z.lazy(
2284
+ () => import_zod20.z.union([
2285
+ import_zod20.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf, Not]),
2286
+ import_zod20.z.record(import_zod20.z.string(), QueryInput)
2159
2287
  ])
2160
- );
2161
- var QueryExpression = import_zod19.z.object({
2162
- type: import_zod19.z.literal("and"),
2163
- eventType: import_zod19.z.string(),
2164
- status: import_zod19.z.optional(import_zod19.z.union([AnyOf, Exact])),
2165
- createdAt: import_zod19.z.optional(DateCondition),
2166
- updatedAt: import_zod19.z.optional(DateCondition),
2167
- createAtLocation: import_zod19.z.optional(import_zod19.z.union([Within, Exact])),
2168
- updatedAtLocation: import_zod19.z.optional(import_zod19.z.union([Within, Exact])),
2169
- createdBy: import_zod19.z.optional(Exact),
2170
- updatedBy: import_zod19.z.optional(Exact),
2171
- trackingId: import_zod19.z.optional(Exact),
2172
- flags: import_zod19.z.optional(import_zod19.z.array(import_zod19.z.union([AnyOf, Not]))),
2288
+ ).openapi({
2289
+ ref: "QueryInput"
2290
+ });
2291
+ var QueryExpression = import_zod20.z.object({
2292
+ eventType: import_zod20.z.string(),
2293
+ status: import_zod20.z.optional(import_zod20.z.union([AnyOfStatus, ExactStatus])),
2294
+ createdAt: import_zod20.z.optional(DateCondition),
2295
+ updatedAt: import_zod20.z.optional(DateCondition),
2296
+ "legalStatus.REGISTERED.createdAt": import_zod20.z.optional(DateCondition),
2297
+ "legalStatus.REGISTERED.createdAtLocation": import_zod20.z.optional(
2298
+ import_zod20.z.union([Within, Exact])
2299
+ ),
2300
+ createAtLocation: import_zod20.z.optional(import_zod20.z.union([Within, Exact])),
2301
+ updatedAtLocation: import_zod20.z.optional(import_zod20.z.union([Within, Exact])),
2302
+ createdBy: import_zod20.z.optional(Exact),
2303
+ updatedBy: import_zod20.z.optional(Exact),
2304
+ trackingId: import_zod20.z.optional(Exact),
2305
+ flags: import_zod20.z.optional(import_zod20.z.array(import_zod20.z.union([AnyOf, Not]))),
2173
2306
  data: QueryInput
2174
- }).partial();
2175
- var Or2 = import_zod19.z.object({
2176
- type: import_zod19.z.literal("or"),
2177
- clauses: import_zod19.z.array(QueryExpression)
2307
+ }).partial().openapi({
2308
+ ref: "QueryExpression"
2309
+ });
2310
+ var QueryType = import_zod20.z.object({
2311
+ type: import_zod20.z.literal("and").or(import_zod20.z.literal("or")).openapi({ default: "and" }),
2312
+ clauses: import_zod20.z.preprocess(
2313
+ (val) => {
2314
+ if (typeof val === "string") {
2315
+ return [JSON.parse(val)];
2316
+ }
2317
+ if (Array.isArray(val)) {
2318
+ return val.map((v) => typeof v === "string" ? JSON.parse(v) : v);
2319
+ }
2320
+ return val;
2321
+ },
2322
+ import_zod20.z.array(QueryExpression).openapi({
2323
+ default: [
2324
+ {
2325
+ eventType: "tennis-club-membership",
2326
+ status: {
2327
+ type: "anyOf",
2328
+ terms: [
2329
+ "CREATED",
2330
+ "NOTIFIED",
2331
+ "DECLARED",
2332
+ "VALIDATED",
2333
+ "REGISTERED",
2334
+ "CERTIFIED",
2335
+ "REJECTED",
2336
+ "ARCHIVED"
2337
+ ]
2338
+ },
2339
+ updatedAt: {
2340
+ type: "range",
2341
+ gte: "2025-05-22",
2342
+ lte: "2025-05-29"
2343
+ },
2344
+ data: {}
2345
+ }
2346
+ ]
2347
+ })
2348
+ )
2349
+ }).openapi({
2350
+ ref: "QueryType"
2178
2351
  });
2179
- var QueryType = import_zod19.z.discriminatedUnion("type", [QueryExpression, Or2]);
2180
2352
 
2181
2353
  // ../commons/src/conditionals/conditionals.ts
2182
2354
  function defineConditional(schema) {
@@ -2476,14 +2648,61 @@ function createFieldConditionals(fieldId) {
2476
2648
  };
2477
2649
  }
2478
2650
 
2651
+ // ../commons/src/searchConfigs.ts
2652
+ function createSearchConfig(baseField) {
2653
+ return {
2654
+ /**
2655
+ * Creates a range configuration for the specified field.
2656
+ *
2657
+ * @returns An object containing the field ID and a configuration object with a type of 'range'.
2658
+ *
2659
+ * @example event('legalStatus.REGISTERED.createdAt').range()
2660
+ * // {
2661
+ * // ...
2662
+ * // config: { type: 'range' }
2663
+ * // }
2664
+ */
2665
+ range: () => ({
2666
+ ...baseField,
2667
+ config: { type: "range" }
2668
+ }),
2669
+ /**
2670
+ * Creates a configuration for exact matching of the specified field.
2671
+ * @returns An object containing the field ID and a configuration object with a type of 'exact'.
2672
+ * @example field('dob').exact()
2673
+ * // {
2674
+ * // ...
2675
+ * // config: { type: 'exact' }
2676
+ * // }
2677
+ */
2678
+ exact: () => ({
2679
+ ...baseField,
2680
+ config: { type: "exact" }
2681
+ }),
2682
+ /**
2683
+ * Creates a configuration for fuzzy matching of the specified field.
2684
+ * @returns An object containing the field ID and a configuration object with a type of 'exact'.
2685
+ * @example field('name').fuzzy()
2686
+ * // {
2687
+ * // ...
2688
+ * // config: { type: 'fuzzy' }
2689
+ * // }
2690
+ */
2691
+ fuzzy: () => ({
2692
+ ...baseField,
2693
+ config: { type: "fuzzy" }
2694
+ })
2695
+ };
2696
+ }
2697
+
2479
2698
  // ../commons/src/event-config/event-configuration.ts
2480
2699
  function createEventFieldConfig(fieldId, options) {
2481
- return {
2700
+ const baseField = {
2482
2701
  fieldId,
2483
2702
  options,
2484
- config: { type: "exact" },
2485
2703
  fieldType: "event"
2486
2704
  };
2705
+ return createSearchConfig(baseField);
2487
2706
  }
2488
2707
 
2489
2708
  // ../commons/src/events/event.ts
@@ -2500,20 +2719,20 @@ var event = Object.assign(eventFn, {
2500
2719
  });
2501
2720
 
2502
2721
  // ../commons/src/events/WorkqueueConfig.ts
2503
- var WorkqueueConfig = import_zod20.z.object({
2504
- slug: import_zod20.z.string().describe("Determines the url of the workqueue."),
2722
+ var WorkqueueConfig = import_zod21.z.object({
2723
+ slug: import_zod21.z.string().describe("Determines the url of the workqueue."),
2505
2724
  name: TranslationConfig.describe(
2506
2725
  "Title of the workflow (both in navigation and on the page)"
2507
2726
  ),
2508
2727
  query: QueryType,
2509
- actions: import_zod20.z.array(
2510
- import_zod20.z.object({
2511
- type: import_zod20.z.string(),
2512
- conditionals: import_zod20.z.array(Conditional).optional()
2728
+ actions: import_zod21.z.array(
2729
+ import_zod21.z.object({
2730
+ type: import_zod21.z.string(),
2731
+ conditionals: import_zod21.z.array(Conditional).optional()
2513
2732
  })
2514
2733
  ),
2515
- columns: import_zod20.z.array(
2516
- import_zod20.z.object({ label: TranslationConfig, value: EventMetadataParameter })
2734
+ columns: import_zod21.z.array(
2735
+ import_zod21.z.object({ label: TranslationConfig, value: EventMetadataParameter })
2517
2736
  ).default([
2518
2737
  {
2519
2738
  label: {
@@ -2530,104 +2749,113 @@ function defineWorkqueue(workqueues) {
2530
2749
  }
2531
2750
 
2532
2751
  // ../commons/src/events/Draft.ts
2533
- var import_zod22 = require("zod");
2752
+ var import_zod23 = require("zod");
2534
2753
 
2535
2754
  // ../commons/src/events/ActionInput.ts
2536
- var import_zod21 = require("zod");
2537
- var import_zod_openapi5 = require("zod-openapi");
2538
- (0, import_zod_openapi5.extendZodWithOpenApi)(import_zod21.z);
2539
- var BaseActionInput = import_zod21.z.object({
2540
- eventId: import_zod21.z.string(),
2541
- transactionId: import_zod21.z.string(),
2755
+ var import_zod22 = require("zod");
2756
+ var import_zod_openapi10 = require("zod-openapi");
2757
+ var import_uuid3 = require("uuid");
2758
+ (0, import_zod_openapi10.extendZodWithOpenApi)(import_zod22.z);
2759
+ var BaseActionInput = import_zod22.z.object({
2760
+ eventId: import_zod22.z.string(),
2761
+ transactionId: import_zod22.z.string(),
2542
2762
  declaration: ActionUpdate.default({}),
2543
2763
  annotation: ActionUpdate.optional(),
2544
- originalActionId: import_zod21.z.string().optional(),
2545
- keepAssignment: import_zod21.z.boolean().optional()
2764
+ originalActionId: import_zod22.z.string().optional(),
2765
+ keepAssignment: import_zod22.z.boolean().optional()
2546
2766
  });
2547
2767
  var CreateActionInput = BaseActionInput.merge(
2548
- import_zod21.z.object({
2549
- type: import_zod21.z.literal(ActionType.CREATE).default(ActionType.CREATE),
2550
- createdAtLocation: import_zod21.z.string()
2768
+ import_zod22.z.object({
2769
+ type: import_zod22.z.literal(ActionType.CREATE).default(ActionType.CREATE),
2770
+ createdAtLocation: CreatedAtLocation
2551
2771
  })
2552
2772
  );
2553
2773
  var RegisterActionInput = BaseActionInput.merge(
2554
- import_zod21.z.object({
2555
- type: import_zod21.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
2556
- registrationNumber: import_zod21.z.string().optional()
2774
+ import_zod22.z.object({
2775
+ type: import_zod22.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
2776
+ registrationNumber: import_zod22.z.string().optional()
2557
2777
  })
2558
2778
  );
2559
2779
  var ValidateActionInput = BaseActionInput.merge(
2560
- import_zod21.z.object({
2561
- type: import_zod21.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
2562
- duplicates: import_zod21.z.array(import_zod21.z.string())
2780
+ import_zod22.z.object({
2781
+ type: import_zod22.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
2782
+ duplicates: import_zod22.z.array(import_zod22.z.string())
2563
2783
  })
2564
2784
  );
2565
2785
  var NotifyActionInput = BaseActionInput.merge(
2566
- import_zod21.z.object({
2567
- type: import_zod21.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
2786
+ import_zod22.z.object({
2787
+ type: import_zod22.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
2568
2788
  })
2569
- );
2789
+ ).openapi({
2790
+ default: {
2791
+ eventId: "<event-id-here>",
2792
+ transactionId: (0, import_uuid3.v4)(),
2793
+ declaration: {},
2794
+ annotation: {},
2795
+ type: ActionType.NOTIFY
2796
+ }
2797
+ });
2570
2798
  var DeclareActionInput = BaseActionInput.merge(
2571
- import_zod21.z.object({
2572
- type: import_zod21.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
2799
+ import_zod22.z.object({
2800
+ type: import_zod22.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
2573
2801
  })
2574
2802
  );
2575
2803
  var PrintCertificateActionInput = BaseActionInput.merge(
2576
- import_zod21.z.object({
2577
- type: import_zod21.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
2804
+ import_zod22.z.object({
2805
+ type: import_zod22.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
2578
2806
  })
2579
2807
  );
2580
2808
  var RejectDeclarationActionInput = BaseActionInput.merge(
2581
- import_zod21.z.object({
2582
- type: import_zod21.z.literal(ActionType.REJECT).default(ActionType.REJECT)
2809
+ import_zod22.z.object({
2810
+ type: import_zod22.z.literal(ActionType.REJECT).default(ActionType.REJECT)
2583
2811
  })
2584
2812
  );
2585
2813
  var MarkedAsDuplicateActionInput = BaseActionInput.merge(
2586
- import_zod21.z.object({
2587
- type: import_zod21.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
2814
+ import_zod22.z.object({
2815
+ type: import_zod22.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
2588
2816
  })
2589
2817
  );
2590
2818
  var ArchiveActionInput = BaseActionInput.merge(
2591
- import_zod21.z.object({
2592
- type: import_zod21.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
2819
+ import_zod22.z.object({
2820
+ type: import_zod22.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE)
2593
2821
  })
2594
2822
  );
2595
2823
  var AssignActionInput = BaseActionInput.merge(
2596
- import_zod21.z.object({
2597
- type: import_zod21.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
2598
- assignedTo: import_zod21.z.string()
2824
+ import_zod22.z.object({
2825
+ type: import_zod22.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
2826
+ assignedTo: import_zod22.z.string()
2599
2827
  })
2600
2828
  );
2601
2829
  var UnassignActionInput = BaseActionInput.merge(
2602
- import_zod21.z.object({
2603
- type: import_zod21.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
2604
- assignedTo: import_zod21.z.literal(null).default(null)
2830
+ import_zod22.z.object({
2831
+ type: import_zod22.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
2832
+ assignedTo: import_zod22.z.literal(null).default(null)
2605
2833
  })
2606
2834
  );
2607
2835
  var RequestCorrectionActionInput = BaseActionInput.merge(
2608
- import_zod21.z.object({
2609
- type: import_zod21.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
2836
+ import_zod22.z.object({
2837
+ type: import_zod22.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
2610
2838
  })
2611
2839
  );
2612
2840
  var RejectCorrectionActionInput = BaseActionInput.merge(
2613
- import_zod21.z.object({
2614
- requestId: import_zod21.z.string(),
2615
- type: import_zod21.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
2841
+ import_zod22.z.object({
2842
+ requestId: import_zod22.z.string(),
2843
+ type: import_zod22.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
2616
2844
  })
2617
2845
  );
2618
2846
  var ApproveCorrectionActionInput = BaseActionInput.merge(
2619
- import_zod21.z.object({
2620
- requestId: import_zod21.z.string(),
2621
- type: import_zod21.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
2847
+ import_zod22.z.object({
2848
+ requestId: import_zod22.z.string(),
2849
+ type: import_zod22.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
2622
2850
  })
2623
2851
  );
2624
2852
  var ReadActionInput = BaseActionInput.merge(
2625
- import_zod21.z.object({
2626
- type: import_zod21.z.literal(ActionType.READ).default(ActionType.READ)
2853
+ import_zod22.z.object({
2854
+ type: import_zod22.z.literal(ActionType.READ).default(ActionType.READ)
2627
2855
  })
2628
2856
  );
2629
- var DeleteActionInput = import_zod21.z.object({ eventId: import_zod21.z.string() });
2630
- var ActionInput = import_zod21.z.discriminatedUnion("type", [
2857
+ var DeleteActionInput = import_zod22.z.object({ eventId: import_zod22.z.string() });
2858
+ var ActionInput = import_zod22.z.discriminatedUnion("type", [
2631
2859
  CreateActionInput.openapi({ ref: "CreateActionInput" }),
2632
2860
  ValidateActionInput.openapi({ ref: "ValidateActionInput" }),
2633
2861
  RegisterActionInput.openapi({ ref: "RegisterActionInput" }),
@@ -2656,18 +2884,18 @@ var ActionInput = import_zod21.z.discriminatedUnion("type", [
2656
2884
  });
2657
2885
 
2658
2886
  // ../commons/src/events/Draft.ts
2659
- var Draft = import_zod22.z.object({
2660
- id: import_zod22.z.string(),
2661
- eventId: import_zod22.z.string(),
2662
- transactionId: import_zod22.z.string(),
2663
- createdAt: import_zod22.z.string().datetime(),
2887
+ var Draft = import_zod23.z.object({
2888
+ id: import_zod23.z.string(),
2889
+ eventId: import_zod23.z.string(),
2890
+ transactionId: import_zod23.z.string(),
2891
+ createdAt: import_zod23.z.string().datetime(),
2664
2892
  action: ActionBase.extend({
2665
2893
  type: ActionTypes
2666
2894
  }).omit({ id: true })
2667
2895
  });
2668
2896
  var DraftInput = BaseActionInput.extend({
2669
2897
  type: ActionTypes,
2670
- status: import_zod22.z.enum([
2898
+ status: import_zod23.z.enum([
2671
2899
  ActionStatus.Requested,
2672
2900
  ActionStatus.Accepted,
2673
2901
  ActionStatus.Rejected
@@ -2675,25 +2903,26 @@ var DraftInput = BaseActionInput.extend({
2675
2903
  });
2676
2904
 
2677
2905
  // ../commons/src/events/EventInput.ts
2678
- var import_zod23 = require("zod");
2679
- var EventInput = import_zod23.z.object({
2680
- transactionId: import_zod23.z.string(),
2681
- type: import_zod23.z.string(),
2682
- dateOfEvent: import_zod23.z.object({ fieldId: import_zod23.z.string() }).optional()
2683
- });
2684
-
2685
- // ../commons/src/events/EventDocument.ts
2686
2906
  var import_zod24 = require("zod");
2687
- var import_zod_openapi6 = require("zod-openapi");
2688
- (0, import_zod_openapi6.extendZodWithOpenApi)(import_zod24.z);
2689
- var EventDocument = import_zod24.z.object({
2690
- id: import_zod24.z.string(),
2907
+ var import_uuid4 = require("uuid");
2908
+ var EventInput = import_zod24.z.object({
2909
+ transactionId: import_zod24.z.string(),
2691
2910
  type: import_zod24.z.string(),
2692
- dateOfEvent: import_zod24.z.object({ fieldId: import_zod24.z.string() }).optional(),
2693
- createdAt: import_zod24.z.string().datetime(),
2694
- updatedAt: import_zod24.z.string().datetime(),
2695
- actions: import_zod24.z.array(Action),
2696
- trackingId: import_zod24.z.string()
2911
+ dateOfEvent: import_zod24.z.object({ fieldId: import_zod24.z.string() }).optional()
2912
+ }).openapi({ default: { transactionId: (0, import_uuid4.v4)(), type: "v2.birth" } });
2913
+
2914
+ // ../commons/src/events/EventDocument.ts
2915
+ var import_zod25 = require("zod");
2916
+ var import_zod_openapi11 = require("zod-openapi");
2917
+ (0, import_zod_openapi11.extendZodWithOpenApi)(import_zod25.z);
2918
+ var EventDocument = import_zod25.z.object({
2919
+ id: import_zod25.z.string(),
2920
+ type: import_zod25.z.string(),
2921
+ dateOfEvent: import_zod25.z.object({ fieldId: import_zod25.z.string() }).optional(),
2922
+ createdAt: import_zod25.z.string().datetime(),
2923
+ updatedAt: import_zod25.z.string().datetime(),
2924
+ actions: import_zod25.z.array(Action),
2925
+ trackingId: import_zod25.z.string()
2697
2926
  }).openapi({ ref: "EventDocument" });
2698
2927
 
2699
2928
  // ../commons/src/events/state/utils.ts
@@ -3004,71 +3233,32 @@ function generateTransactionId() {
3004
3233
 
3005
3234
  // ../commons/src/events/test.utils.ts
3006
3235
  var import_lodash2 = require("lodash");
3236
+ var import_addDays = __toESM(require("date-fns/addDays"));
3007
3237
 
3008
3238
  // ../commons/src/field-config/field-configuration.ts
3009
- function createFieldConfigs(fieldId) {
3239
+ function createFieldConfig(fieldId, options) {
3010
3240
  const baseField = {
3011
3241
  fieldId,
3012
- fieldType: "field"
3013
- };
3014
- return {
3015
- /**
3016
- * Creates a range configuration for the specified field.
3017
- *
3018
- * @returns An object containing the field ID and a configuration object with a type of 'range'.
3019
- *
3020
- * @example field('age').range()
3021
- * // {
3022
- * // fieldId: 'age',
3023
- * // config: { type: 'range' }
3024
- * // }
3025
- */
3026
- range: () => ({
3027
- ...baseField,
3028
- config: { type: "range" }
3029
- }),
3030
- /**
3031
- * Creates a configuration for exact matching of the specified field.
3032
- * @returns An object containing the field ID and a configuration object with a type of 'exact'.
3033
- * @example field('dob').exact()
3034
- * // {
3035
- * // fieldId: 'dob',
3036
- * // config: { type: 'exact' }
3037
- * // }
3038
- */
3039
- exact: () => ({
3040
- ...baseField,
3041
- config: { type: "exact" }
3042
- }),
3043
- /**
3044
- * Creates a configuration for fuzzy matching of the specified field.
3045
- * @returns An object containing the field ID and a configuration object with a type of 'exact'.
3046
- * @example field('name').fuzzy()
3047
- * // {
3048
- * // fieldId: 'name',
3049
- * // config: { type: 'fuzzy' }
3050
- * // }
3051
- */
3052
- fuzzy: () => ({
3053
- ...baseField,
3054
- config: { type: "fuzzy" }
3055
- })
3242
+ fieldType: "field",
3243
+ ...options
3056
3244
  };
3245
+ return createSearchConfig(baseField);
3057
3246
  }
3058
3247
 
3059
3248
  // ../commons/src/events/field.ts
3060
- function field(fieldId) {
3249
+ function field(fieldId, options = {}) {
3061
3250
  return {
3062
3251
  /**
3063
3252
  * @private Internal property used for field reference tracking.
3064
3253
  */
3065
3254
  _fieldId: fieldId,
3066
3255
  ...createFieldConditionals(fieldId),
3067
- ...createFieldConfigs(fieldId)
3256
+ ...createFieldConfig(fieldId, options)
3068
3257
  };
3069
3258
  }
3070
3259
 
3071
3260
  // ../commons/src/fixtures/tennis-club-membership-event.ts
3261
+ var import_date_fns2 = require("date-fns");
3072
3262
  var PRINT_CERTIFICATE_FORM = defineActionForm({
3073
3263
  label: {
3074
3264
  id: "v2.event.tennis-club-membership.action.certificate.form.label",
@@ -3977,6 +4167,114 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
3977
4167
  }
3978
4168
  ]
3979
4169
  });
4170
+ var statusOptions = [
4171
+ {
4172
+ value: "ALL",
4173
+ label: {
4174
+ defaultMessage: "Any status",
4175
+ description: "Option for form field: status of record",
4176
+ id: "v2.advancedSearch.form.recordStatusAny"
4177
+ }
4178
+ },
4179
+ {
4180
+ value: EventStatus.CREATED,
4181
+ label: {
4182
+ defaultMessage: "Draft",
4183
+ description: "Option for form field: status of record",
4184
+ id: "v2.advancedSearch.form.recordStatusCreated"
4185
+ }
4186
+ },
4187
+ {
4188
+ value: EventStatus.NOTIFIED,
4189
+ label: {
4190
+ defaultMessage: "Notified",
4191
+ description: "Option for form field: status of record",
4192
+ id: "v2.advancedSearch.form.recordStatusNotified"
4193
+ }
4194
+ },
4195
+ {
4196
+ value: EventStatus.DECLARED,
4197
+ label: {
4198
+ defaultMessage: "Declared",
4199
+ description: "Option for form field: status of record",
4200
+ id: "v2.advancedSearch.form.recordStatusDeclared"
4201
+ }
4202
+ },
4203
+ {
4204
+ value: EventStatus.VALIDATED,
4205
+ label: {
4206
+ defaultMessage: "Validated",
4207
+ description: "Option for form field: status of record",
4208
+ id: "v2.advancedSearch.form.recordStatusValidated"
4209
+ }
4210
+ },
4211
+ {
4212
+ value: EventStatus.REGISTERED,
4213
+ label: {
4214
+ defaultMessage: "Registered",
4215
+ description: "Option for form field: status of record",
4216
+ id: "v2.advancedSearch.form.recordStatusRegistered"
4217
+ }
4218
+ },
4219
+ {
4220
+ value: EventStatus.CERTIFIED,
4221
+ label: {
4222
+ defaultMessage: "Certified",
4223
+ description: "Option for form field: status of record",
4224
+ id: "v2.advancedSearch.form.recordStatusCertified"
4225
+ }
4226
+ },
4227
+ {
4228
+ value: EventStatus.REJECTED,
4229
+ label: {
4230
+ defaultMessage: "Rejected",
4231
+ description: "Option for form field: status of record",
4232
+ id: "v2.advancedSearch.form.recordStatusRejected"
4233
+ }
4234
+ },
4235
+ {
4236
+ value: EventStatus.ARCHIVED,
4237
+ label: {
4238
+ defaultMessage: "Archived",
4239
+ description: "Option for form field: status of record",
4240
+ id: "v2.advancedSearch.form.recordStatusArchived"
4241
+ }
4242
+ }
4243
+ ];
4244
+ var timePeriodOptions = [
4245
+ {
4246
+ label: {
4247
+ defaultMessage: "Last 7 days",
4248
+ description: "Label for option of time period select: last 7 days",
4249
+ id: "form.section.label.timePeriodLast7Days"
4250
+ },
4251
+ 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")}`
4252
+ },
4253
+ {
4254
+ label: {
4255
+ defaultMessage: "Last 30 days",
4256
+ description: "Label for option of time period select: last 30 days",
4257
+ id: "form.section.label.timePeriodLast30Days"
4258
+ },
4259
+ 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")}`
4260
+ },
4261
+ {
4262
+ label: {
4263
+ defaultMessage: "Last 90 days",
4264
+ description: "Label for option of time period select: last 90 days",
4265
+ id: "form.section.label.timePeriodLast90Days"
4266
+ },
4267
+ 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")}`
4268
+ },
4269
+ {
4270
+ label: {
4271
+ defaultMessage: "Last year",
4272
+ description: "Label for option of time period select: last year",
4273
+ id: "form.section.label.timePeriodLastYear"
4274
+ },
4275
+ 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")}`
4276
+ }
4277
+ ];
3980
4278
  var tennisClubMembershipEvent = defineConfig({
3981
4279
  id: "TENNIS_CLUB_MEMBERSHIP",
3982
4280
  label: {
@@ -4010,22 +4308,15 @@ var tennisClubMembershipEvent = defineConfig({
4010
4308
  }
4011
4309
  },
4012
4310
  {
4013
- id: "applicant.surname",
4311
+ fieldId: "applicant.surname",
4014
4312
  label: {
4015
4313
  defaultMessage: "Applicant's last name",
4016
- description: "This is the label for the field",
4017
- id: "event.tennis-club-membership.summary.field.surname.label"
4018
- },
4019
- value: {
4020
- defaultMessage: "{applicant.surname}",
4021
- description: "This is the value to show in the summary",
4022
- id: "event.tennis-club-membership.summary.field.surname"
4023
- },
4024
- emptyValueMessage: {
4025
- defaultMessage: "Last name is not provided",
4026
- description: "This is the message to show when the field is empty",
4027
- id: "event.tennis-club-membership.summary.field.surname.empty"
4314
+ description: "Label for surname",
4315
+ id: "v2.event.tennis-club-membership.summary.field.surname.label"
4028
4316
  }
4317
+ },
4318
+ {
4319
+ fieldId: "applicant.email"
4029
4320
  }
4030
4321
  ]
4031
4322
  },
@@ -4332,11 +4623,40 @@ var tennisClubMembershipEvent = defineConfig({
4332
4623
  advancedSearch: [
4333
4624
  {
4334
4625
  title: {
4335
- defaultMessage: "Tennis club registration search",
4336
- description: "This is what this event is referred as in the system",
4337
- id: "v2.event.tennis-club-membership.search"
4626
+ defaultMessage: "Registration details",
4627
+ description: "The title of Registration details accordion",
4628
+ id: "v2.advancedSearch.form.registrationDetails"
4338
4629
  },
4339
- fields: [field("applicant.dob").exact()]
4630
+ fields: [
4631
+ event("legalStatus.REGISTERED.createdAtLocation").exact(),
4632
+ event("legalStatus.REGISTERED.createdAt").range(),
4633
+ event("status", statusOptions).exact(),
4634
+ event("updatedAt", timePeriodOptions).range()
4635
+ ]
4636
+ },
4637
+ {
4638
+ title: {
4639
+ defaultMessage: "Applicant's details",
4640
+ description: "Applicant details search field section title",
4641
+ id: "v2.event.tennis-club-membership.search.applicants"
4642
+ },
4643
+ fields: [
4644
+ field("applicant.firstname").fuzzy(),
4645
+ field("applicant.surname").fuzzy(),
4646
+ field("applicant.dob").range(),
4647
+ field("applicant.email").exact()
4648
+ ]
4649
+ },
4650
+ {
4651
+ title: {
4652
+ defaultMessage: "Recommender's details",
4653
+ description: "Recommender details search field section title",
4654
+ id: "v2.event.tennis-club-membership.search.recommender"
4655
+ },
4656
+ fields: [
4657
+ field("recommender.firstname").fuzzy(),
4658
+ field("recommender.surname").fuzzy()
4659
+ ]
4340
4660
  }
4341
4661
  ],
4342
4662
  declaration: TENNIS_CLUB_DECLARATION_FORM
@@ -4668,21 +4988,16 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, de
4668
4988
  eventId
4669
4989
  };
4670
4990
  }
4671
- function getEventStatus() {
4672
- const statuses = [
4673
- EventStatus.CREATED,
4674
- EventStatus.REGISTERED,
4675
- EventStatus.DECLARED
4676
- ];
4677
- const randomIndex = Math.floor(Math.random() * 3);
4678
- return statuses[randomIndex];
4991
+ function pickRandom(rng, items) {
4992
+ return items[Math.floor(rng() * items.length)];
4679
4993
  }
4680
- function getTrackingId() {
4681
- const uuid = getUUID().replace(/-/g, "");
4682
- const trackingId = uuid.slice(0, 6).toUpperCase();
4683
- return trackingId;
4994
+ function getRandomDatetime(rng, start, end) {
4995
+ const range = end.getTime() - start.getTime();
4996
+ const offset = Math.floor(rng() * range);
4997
+ const randomDate = new Date(start.getTime() + offset);
4998
+ return randomDate.toISOString();
4684
4999
  }
4685
- function getRandomApplicant() {
5000
+ function generateRandomApplicant(rng) {
4686
5001
  const firstNames = [
4687
5002
  "Danny",
4688
5003
  "John",
@@ -4703,18 +5018,13 @@ function getRandomApplicant() {
4703
5018
  "Garcia",
4704
5019
  "Miller"
4705
5020
  ];
4706
- function getRandomDate(start, end) {
4707
- const randomDate = new Date(
4708
- start.getTime() + Math.random() * (end.getTime() - start.getTime())
4709
- );
4710
- return randomDate.toISOString().split("T")[0];
4711
- }
4712
- const randomFirstName = firstNames[Math.floor(Math.random() * firstNames.length)];
4713
- const randomSurname = surnames[Math.floor(Math.random() * surnames.length)];
4714
- const randomDob = getRandomDate(
5021
+ const randomFirstName = pickRandom(rng, firstNames);
5022
+ const randomSurname = pickRandom(rng, surnames);
5023
+ const randomDob = getRandomDatetime(
5024
+ rng,
4715
5025
  /* @__PURE__ */ new Date("1990-01-01"),
4716
5026
  /* @__PURE__ */ new Date("2010-12-31")
4717
- );
5027
+ ).split("T")[0];
4718
5028
  return {
4719
5029
  "recommender.none": true,
4720
5030
  "applicant.firstname": randomFirstName,
@@ -4722,23 +5032,53 @@ function getRandomApplicant() {
4722
5032
  "applicant.dob": randomDob
4723
5033
  };
4724
5034
  }
4725
- var eventQueryDataGenerator = (overrides = {}) => ({
4726
- id: overrides.id ?? getUUID(),
4727
- type: overrides.type ?? "TENNIS_CLUB_MEMBERSHIP",
4728
- status: overrides.status ?? getEventStatus(),
4729
- createdAt: overrides.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
4730
- createdBy: overrides.createdBy ?? getUUID(),
4731
- createdAtLocation: overrides.createdAtLocation ?? getUUID(),
4732
- updatedAtLocation: overrides.updatedAtLocation ?? getUUID(),
4733
- updatedAt: overrides.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
4734
- assignedTo: overrides.assignedTo ?? null,
4735
- updatedBy: overrides.updatedBy ?? getUUID(),
4736
- updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
4737
- flags: [],
4738
- legalStatuses: overrides.legalStatuses ?? {},
4739
- declaration: overrides.declaration ?? getRandomApplicant(),
4740
- trackingId: overrides.trackingId ?? getTrackingId()
4741
- });
5035
+ function createPseudoRandomNumberGenerator(seed) {
5036
+ const MODULUS = 2 ** 32;
5037
+ const MULTIPLIER = 1664525;
5038
+ const INCREMENT = 1013904223;
5039
+ let state = seed >>> 0;
5040
+ return () => {
5041
+ state = (MULTIPLIER * state + INCREMENT) % MODULUS;
5042
+ return state / MODULUS;
5043
+ };
5044
+ }
5045
+ function generateUuid(rng) {
5046
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
5047
+ const r = Math.floor(rng() * 16);
5048
+ const v = c === "x" ? r : r & 3 | 8;
5049
+ return v.toString(16);
5050
+ });
5051
+ }
5052
+ function generateTrackingId(rng) {
5053
+ const uuid = generateUuid(rng).replace(/-/g, "");
5054
+ const trackingId = uuid.slice(0, 6).toUpperCase();
5055
+ return trackingId;
5056
+ }
5057
+ var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
5058
+ const rng = createPseudoRandomNumberGenerator(seed);
5059
+ const createdAt = getRandomDatetime(
5060
+ rng,
5061
+ /* @__PURE__ */ new Date("2024-01-01"),
5062
+ /* @__PURE__ */ new Date("2024-12-31")
5063
+ );
5064
+ return {
5065
+ id: overrides.id ?? generateUuid(rng),
5066
+ type: overrides.type ?? "TENNIS_CLUB_MEMBERSHIP",
5067
+ status: overrides.status ?? pickRandom(rng, eventStatuses),
5068
+ createdAt: overrides.createdAt ?? createdAt,
5069
+ createdBy: overrides.createdBy ?? generateUuid(rng),
5070
+ createdAtLocation: overrides.createdAtLocation ?? generateUuid(rng),
5071
+ updatedAtLocation: overrides.updatedAtLocation ?? generateUuid(rng),
5072
+ updatedAt: overrides.updatedAt ?? (0, import_addDays.default)(new Date(createdAt), 1).toISOString(),
5073
+ assignedTo: overrides.assignedTo ?? null,
5074
+ updatedBy: overrides.updatedBy ?? generateUuid(rng),
5075
+ updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
5076
+ flags: [],
5077
+ legalStatuses: overrides.legalStatuses ?? {},
5078
+ declaration: overrides.declaration ?? generateRandomApplicant(rng),
5079
+ trackingId: overrides.trackingId ?? generateTrackingId(rng)
5080
+ };
5081
+ };
4742
5082
  var generateTranslationConfig = (message) => ({
4743
5083
  defaultMessage: message,
4744
5084
  description: "Description for ${message}",
@@ -4781,6 +5121,7 @@ function isFieldConfigDefaultValue(value) {
4781
5121
  var import_lodash3 = require("lodash");
4782
5122
 
4783
5123
  // ../commons/src/scopes.ts
5124
+ var import_zod26 = require("zod");
4784
5125
  var SCOPES = {
4785
5126
  // TODO v1.8 legacy scopes
4786
5127
  NATLSYSADMIN: "natlsysadmin",
@@ -4804,6 +5145,8 @@ var SCOPES = {
4804
5145
  */
4805
5146
  RECORD_DECLARE: "record.declare-birth",
4806
5147
  // declare
5148
+ RECORD_IMPORT: "record.import",
5149
+ // declare
4807
5150
  RECORD_DECLARE_BIRTH: "record.declare-birth",
4808
5151
  RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
4809
5152
  RECORD_DECLARE_DEATH: "record.declare-death",
@@ -4891,12 +5234,119 @@ var SCOPES = {
4891
5234
  // data seeding
4892
5235
  USER_DATA_SEEDING: "user.data-seeding"
4893
5236
  };
5237
+ var LiteralScopes = import_zod26.z.union([
5238
+ import_zod26.z.literal(SCOPES.NATLSYSADMIN),
5239
+ import_zod26.z.literal(SCOPES.BYPASSRATELIMIT),
5240
+ import_zod26.z.literal(SCOPES.DECLARE),
5241
+ import_zod26.z.literal(SCOPES.REGISTER),
5242
+ import_zod26.z.literal(SCOPES.VALIDATE),
5243
+ import_zod26.z.literal(SCOPES.DEMO),
5244
+ import_zod26.z.literal(SCOPES.CERTIFY),
5245
+ import_zod26.z.literal(SCOPES.PERFORMANCE),
5246
+ import_zod26.z.literal(SCOPES.SYSADMIN),
5247
+ import_zod26.z.literal(SCOPES.TEAMS),
5248
+ import_zod26.z.literal(SCOPES.CONFIG),
5249
+ import_zod26.z.literal(SCOPES.WEBHOOK),
5250
+ import_zod26.z.literal(SCOPES.NATIONALID),
5251
+ import_zod26.z.literal(SCOPES.NOTIFICATION_API),
5252
+ import_zod26.z.literal(SCOPES.RECORDSEARCH),
5253
+ import_zod26.z.literal(SCOPES.RECORD_IMPORT),
5254
+ import_zod26.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
5255
+ import_zod26.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
5256
+ import_zod26.z.literal(SCOPES.RECORD_DECLARE_DEATH),
5257
+ import_zod26.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
5258
+ import_zod26.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
5259
+ import_zod26.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
5260
+ import_zod26.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
5261
+ import_zod26.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW),
5262
+ import_zod26.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS),
5263
+ import_zod26.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
5264
+ import_zod26.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
5265
+ import_zod26.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
5266
+ import_zod26.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
5267
+ import_zod26.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
5268
+ import_zod26.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE),
5269
+ import_zod26.z.literal(SCOPES.RECORD_REGISTER),
5270
+ import_zod26.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
5271
+ import_zod26.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
5272
+ import_zod26.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
5273
+ import_zod26.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
5274
+ import_zod26.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
5275
+ import_zod26.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
5276
+ import_zod26.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
5277
+ import_zod26.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES),
5278
+ import_zod26.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
5279
+ import_zod26.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
5280
+ import_zod26.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
5281
+ import_zod26.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
5282
+ import_zod26.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
5283
+ import_zod26.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
5284
+ import_zod26.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
5285
+ import_zod26.z.literal(SCOPES.RECORD_REJECT_REGISTRATION),
5286
+ import_zod26.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
5287
+ import_zod26.z.literal(SCOPES.SEARCH_BIRTH),
5288
+ import_zod26.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
5289
+ import_zod26.z.literal(SCOPES.SEARCH_DEATH),
5290
+ import_zod26.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
5291
+ import_zod26.z.literal(SCOPES.SEARCH_MARRIAGE),
5292
+ import_zod26.z.literal(SCOPES.RECORD_READ),
5293
+ import_zod26.z.literal(SCOPES.RECORD_READ_AUDIT),
5294
+ import_zod26.z.literal(SCOPES.RECORD_READ_COMMENTS),
5295
+ import_zod26.z.literal(SCOPES.RECORD_CREATE_COMMENTS),
5296
+ import_zod26.z.literal(SCOPES.PROFILE_UPDATE),
5297
+ import_zod26.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE),
5298
+ import_zod26.z.literal(SCOPES.PERFORMANCE_READ),
5299
+ import_zod26.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
5300
+ import_zod26.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS),
5301
+ import_zod26.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
5302
+ import_zod26.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
5303
+ import_zod26.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION),
5304
+ import_zod26.z.literal(SCOPES.USER_READ),
5305
+ import_zod26.z.literal(SCOPES.USER_READ_MY_OFFICE),
5306
+ import_zod26.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
5307
+ import_zod26.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
5308
+ import_zod26.z.literal(SCOPES.USER_CREATE),
5309
+ import_zod26.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
5310
+ import_zod26.z.literal(SCOPES.USER_UPDATE),
5311
+ import_zod26.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION),
5312
+ import_zod26.z.literal(SCOPES.CONFIG_UPDATE_ALL),
5313
+ import_zod26.z.literal(SCOPES.USER_DATA_SEEDING)
5314
+ ]);
5315
+ var rawConfigurableScopeRegex = /^([a-zA-Z\.]+)\[((?:\w+=[\w.-]+(?:\|[\w.-]+)*)(?:,[\w]+=[\w.-]+(?:\|[\w.-]+)*)*)\]$/;
5316
+ var rawConfigurableScope = import_zod26.z.string().regex(rawConfigurableScopeRegex);
5317
+ var CreateUserScope = import_zod26.z.object({
5318
+ type: import_zod26.z.literal("user.create"),
5319
+ options: import_zod26.z.object({
5320
+ role: import_zod26.z.array(import_zod26.z.string())
5321
+ })
5322
+ });
5323
+ var EditUserScope = import_zod26.z.object({
5324
+ type: import_zod26.z.literal("user.edit"),
5325
+ options: import_zod26.z.object({
5326
+ role: import_zod26.z.array(import_zod26.z.string())
5327
+ })
5328
+ });
5329
+ var WorkqueueScope = import_zod26.z.object({
5330
+ type: import_zod26.z.literal("workqueue"),
5331
+ options: import_zod26.z.object({
5332
+ id: import_zod26.z.array(import_zod26.z.string())
5333
+ })
5334
+ });
5335
+ var NotifyRecordScope = import_zod26.z.object({
5336
+ type: import_zod26.z.literal("record.notify"),
5337
+ options: import_zod26.z.object({
5338
+ event: import_zod26.z.array(import_zod26.z.string())
5339
+ })
5340
+ });
5341
+ var ConfigurableScopes = import_zod26.z.discriminatedUnion("type", [
5342
+ CreateUserScope,
5343
+ EditUserScope,
5344
+ WorkqueueScope,
5345
+ NotifyRecordScope
5346
+ ]);
4894
5347
  var scopes = Object.values(SCOPES);
4895
5348
 
4896
5349
  // ../commons/src/events/scopes.ts
4897
- function hasAnyOfScopes(a, b) {
4898
- return (0, import_lodash3.intersection)(a, b).length > 0;
4899
- }
4900
5350
  var CONFIG_GET_ALLOWED_SCOPES = [
4901
5351
  SCOPES.RECORD_DECLARE,
4902
5352
  SCOPES.RECORD_READ,
@@ -4954,6 +5404,28 @@ var ACTION_ALLOWED_SCOPES = {
4954
5404
  [ActionType.UNASSIGN]: null,
4955
5405
  [ActionType.DETECT_DUPLICATE]: []
4956
5406
  };
5407
+ var ACTION_ALLOWED_CONFIGURABLE_SCOPES = {
5408
+ [ActionType.READ]: [],
5409
+ [ActionType.CREATE]: ["record.notify"],
5410
+ [ActionType.NOTIFY]: ["record.notify"],
5411
+ [ActionType.DECLARE]: [],
5412
+ [ActionType.DELETE]: [],
5413
+ [ActionType.VALIDATE]: [],
5414
+ [ActionType.REGISTER]: [],
5415
+ [ActionType.PRINT_CERTIFICATE]: [],
5416
+ [ActionType.REQUEST_CORRECTION]: [],
5417
+ [ActionType.REJECT_CORRECTION]: [],
5418
+ [ActionType.APPROVE_CORRECTION]: [],
5419
+ [ActionType.MARKED_AS_DUPLICATE]: [],
5420
+ [ActionType.ARCHIVE]: [],
5421
+ [ActionType.REJECT]: [],
5422
+ [ActionType.ASSIGN]: [],
5423
+ [ActionType.UNASSIGN]: [],
5424
+ [ActionType.DETECT_DUPLICATE]: []
5425
+ };
5426
+ function hasAnyOfScopes(a, b) {
5427
+ return (0, import_lodash3.intersection)(a, b).length > 0;
5428
+ }
4957
5429
  function filterUnallowedActions(actions, userScopes) {
4958
5430
  const allowedActions = actions.filter((action) => {
4959
5431
  const requiredScopes = ACTION_ALLOWED_SCOPES[action];