@opencrvs/toolkit 1.8.0-rc.fd8a78f → 1.8.0-rc.fde35f6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/commons/api/router.d.ts +3117 -11206
  2. package/dist/commons/conditionals/conditionals.d.ts +0 -12
  3. package/dist/commons/events/ActionConfig.d.ts +12032 -3972
  4. package/dist/commons/events/ActionDocument.d.ts +3029 -1886
  5. package/dist/commons/events/ActionInput.d.ts +2406 -1506
  6. package/dist/commons/events/AdvancedSearchConfig.d.ts +304 -51
  7. package/dist/commons/events/CompositeFieldValue.d.ts +15 -15
  8. package/dist/commons/events/CountryConfigQueryInput.d.ts +1891 -741
  9. package/dist/commons/events/CreatedAtLocation.d.ts +1 -2
  10. package/dist/commons/events/Draft.d.ts +213 -136
  11. package/dist/commons/events/EventConfig.d.ts +4770 -755
  12. package/dist/commons/events/EventDocument.d.ts +1942 -1219
  13. package/dist/commons/events/EventIndex.d.ts +897 -263
  14. package/dist/commons/events/EventMetadata.d.ts +73 -31
  15. package/dist/commons/events/FieldConfig.d.ts +607 -30
  16. package/dist/commons/events/FieldType.d.ts +2 -1
  17. package/dist/commons/events/FieldTypeMapping.d.ts +73 -41
  18. package/dist/commons/events/FieldValue.d.ts +57 -28
  19. package/dist/commons/events/FormConfig.d.ts +4685 -1295
  20. package/dist/commons/events/PageConfig.d.ts +868 -38
  21. package/dist/commons/events/User.d.ts +6 -3
  22. package/dist/commons/events/WorkqueueColumnConfig.d.ts +11 -11
  23. package/dist/commons/events/WorkqueueConfig.d.ts +4490 -1177
  24. package/dist/commons/events/defineConfig.d.ts +759 -34
  25. package/dist/commons/events/event.d.ts +15 -10
  26. package/dist/commons/events/field.d.ts +17 -0
  27. package/dist/commons/events/scopes.d.ts +1 -2
  28. package/dist/commons/events/test.utils.d.ts +83 -36
  29. package/dist/commons/events/transactions.d.ts +1 -1
  30. package/dist/commons/events/utils.d.ts +2926 -88
  31. package/dist/conditionals/index.js +22 -51
  32. package/dist/events/index.js +1550 -1048
  33. package/dist/scopes/index.d.ts +96 -7
  34. package/dist/scopes/index.js +105 -26
  35. package/package.json +3 -3
@@ -32,6 +32,7 @@ var events_exports = {};
32
32
  __export(events_exports, {
33
33
  ACTION_ALLOWED_CONFIGURABLE_SCOPES: () => ACTION_ALLOWED_CONFIGURABLE_SCOPES,
34
34
  ACTION_ALLOWED_SCOPES: () => ACTION_ALLOWED_SCOPES,
35
+ AVAILABLE_ACTIONS_BY_EVENT_STATUS: () => AVAILABLE_ACTIONS_BY_EVENT_STATUS,
35
36
  Action: () => Action,
36
37
  ActionBase: () => ActionBase,
37
38
  ActionConditional: () => ActionConditional,
@@ -68,11 +69,12 @@ __export(events_exports, {
68
69
  Conditional: () => Conditional,
69
70
  ConditionalType: () => ConditionalType,
70
71
  ConfirmableActions: () => ConfirmableActions,
71
- CustomFlags: () => CustomFlags,
72
+ ContainsFlags: () => ContainsFlags,
72
73
  DEFAULT_DATE_OF_EVENT_PROPERTY: () => DEFAULT_DATE_OF_EVENT_PROPERTY,
73
74
  DataEntry: () => DataEntry,
74
75
  DataFieldValue: () => DataFieldValue,
75
76
  DateCondition: () => DateCondition,
77
+ DateRangeField: () => DateRangeField,
76
78
  DateRangeFieldValue: () => DateRangeFieldValue,
77
79
  DateValue: () => DateValue,
78
80
  DatetimeValue: () => DatetimeValue,
@@ -103,7 +105,9 @@ __export(events_exports, {
103
105
  EventState: () => EventState,
104
106
  EventStatus: () => EventStatus,
105
107
  Exact: () => Exact,
108
+ ExactDate: () => ExactDate,
106
109
  ExactStatus: () => ExactStatus,
110
+ ExactUserType: () => ExactUserType,
107
111
  FieldConditional: () => FieldConditional,
108
112
  FieldConfig: () => FieldConfig,
109
113
  FieldConfigSchema: () => FieldConfigSchema,
@@ -122,6 +126,7 @@ __export(events_exports, {
122
126
  GenericAddressValue: () => GenericAddressValue,
123
127
  GeographicalArea: () => GeographicalArea,
124
128
  ImageMimeType: () => ImageMimeType,
129
+ InherentFlags: () => InherentFlags,
125
130
  LanguageConfig: () => LanguageConfig,
126
131
  LegalStatuses: () => LegalStatuses,
127
132
  MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
@@ -129,7 +134,6 @@ __export(events_exports, {
129
134
  NameFieldUpdateValue: () => NameFieldUpdateValue,
130
135
  NameFieldValue: () => NameFieldValue,
131
136
  NonEmptyTextValue: () => NonEmptyTextValue,
132
- Not: () => Not,
133
137
  NotifyActionInput: () => NotifyActionInput,
134
138
  NumberFieldValue: () => NumberFieldValue,
135
139
  PageConfig: () => PageConfig,
@@ -152,11 +156,17 @@ __export(events_exports, {
152
156
  RuralAddressValue: () => RuralAddressValue,
153
157
  SearchField: () => SearchField,
154
158
  SearchQueryParams: () => SearchQueryParams,
159
+ SearchScopeAccessLevels: () => SearchScopeAccessLevels,
160
+ SelectDateRangeField: () => SelectDateRangeField,
161
+ SelectDateRangeOption: () => SelectDateRangeOption,
162
+ SelectDateRangeValue: () => SelectDateRangeValue,
155
163
  SelectOption: () => SelectOption,
156
164
  ShowConditional: () => ShowConditional,
157
165
  SignatureFieldValue: () => SignatureFieldValue,
158
166
  SummaryConfig: () => SummaryConfig,
159
167
  TENNIS_CLUB_MEMBERSHIP: () => TENNIS_CLUB_MEMBERSHIP,
168
+ TEST_SYSTEM_IANA_TIMEZONE: () => TEST_SYSTEM_IANA_TIMEZONE,
169
+ TestUserRole: () => TestUserRole,
160
170
  TextValue: () => TextValue,
161
171
  TranslationConfig: () => TranslationConfig,
162
172
  UnassignActionInput: () => UnassignActionInput,
@@ -164,8 +174,10 @@ __export(events_exports, {
164
174
  UrbanAddressValue: () => UrbanAddressValue,
165
175
  User: () => User,
166
176
  ValidateActionInput: () => ValidateActionInput,
177
+ ValidationConfig: () => ValidationConfig,
167
178
  VerificationActionConfig: () => VerificationActionConfig,
168
179
  VerificationPageConfig: () => VerificationPageConfig,
180
+ WRITE_ACTION_SCOPES: () => WRITE_ACTION_SCOPES,
169
181
  Within: () => Within,
170
182
  WorkqueueActionsWithDefault: () => WorkqueueActionsWithDefault,
171
183
  WorkqueueColumn: () => WorkqueueColumn,
@@ -174,17 +186,18 @@ __export(events_exports, {
174
186
  WorkqueueColumnValue: () => WorkqueueColumnValue,
175
187
  WorkqueueConfig: () => WorkqueueConfig,
176
188
  WorkqueueConfigInput: () => WorkqueueConfigInput,
189
+ WorkqueueConfigWithoutQuery: () => WorkqueueConfigWithoutQuery,
177
190
  WorkqueueCountInput: () => WorkqueueCountInput,
178
191
  WorkqueueCountOutput: () => WorkqueueCountOutput,
179
192
  ZodDate: () => ZodDate,
180
193
  alwaysTrue: () => alwaysTrue,
181
194
  and: () => and,
182
195
  annotationActions: () => annotationActions,
196
+ applyDeclarationToEventIndex: () => applyDeclarationToEventIndex,
183
197
  applyDraftsToEventIndex: () => applyDraftsToEventIndex,
184
198
  areConditionsMet: () => areConditionsMet,
185
199
  compositeFieldTypes: () => compositeFieldTypes,
186
200
  createEmptyDraft: () => createEmptyDraft,
187
- createEventConditionals: () => createEventConditionals,
188
201
  createFieldConditionals: () => createFieldConditionals,
189
202
  createPrng: () => createPrng,
190
203
  createValidationSchema: () => createValidationSchema,
@@ -209,7 +222,6 @@ __export(events_exports, {
209
222
  eventQueryDataGenerator: () => eventQueryDataGenerator,
210
223
  field: () => field,
211
224
  fieldTypes: () => fieldTypes,
212
- filterUnallowedActions: () => filterUnallowedActions,
213
225
  findActiveDrafts: () => findActiveDrafts,
214
226
  findAllFields: () => findAllFields,
215
227
  findLastAssignmentAction: () => findLastAssignmentAction,
@@ -221,8 +233,10 @@ __export(events_exports, {
221
233
  generateEventDraftDocument: () => generateEventDraftDocument,
222
234
  generateRandomName: () => generateRandomName,
223
235
  generateRandomSignature: () => generateRandomSignature,
236
+ generateRegistrationNumber: () => generateRegistrationNumber,
224
237
  generateTransactionId: () => generateTransactionId,
225
238
  generateTranslationConfig: () => generateTranslationConfig,
239
+ generateUuid: () => generateUuid,
226
240
  generateWorkqueues: () => generateWorkqueues,
227
241
  getAcceptedActions: () => getAcceptedActions,
228
242
  getActionAnnotation: () => getActionAnnotation,
@@ -234,7 +248,6 @@ __export(events_exports, {
234
248
  getAnnotationFromDrafts: () => getAnnotationFromDrafts,
235
249
  getAssignedUserFromActions: () => getAssignedUserFromActions,
236
250
  getAssignedUserSignatureFromActions: () => getAssignedUserSignatureFromActions,
237
- getAvailableActionsByStatus: () => getAvailableActionsByStatus,
238
251
  getCurrentEventState: () => getCurrentEventState,
239
252
  getCurrentEventStateWithDrafts: () => getCurrentEventStateWithDrafts,
240
253
  getDeclaration: () => getDeclaration,
@@ -243,6 +256,7 @@ __export(events_exports, {
243
256
  getDeclarationPages: () => getDeclarationPages,
244
257
  getEventConfigById: () => getEventConfigById,
245
258
  getMixedPath: () => getMixedPath,
259
+ getPrintCertificatePages: () => getPrintCertificatePages,
246
260
  getRandomDate: () => getRandomDate,
247
261
  getRandomDatetime: () => getRandomDatetime,
248
262
  getStatusFromActions: () => getStatusFromActions,
@@ -281,6 +295,7 @@ __export(events_exports, {
281
295
  isParagraphFieldType: () => isParagraphFieldType,
282
296
  isPhoneFieldType: () => isPhoneFieldType,
283
297
  isRadioGroupFieldType: () => isRadioGroupFieldType,
298
+ isSelectDateRangeFieldType: () => isSelectDateRangeFieldType,
284
299
  isSelectFieldType: () => isSelectFieldType,
285
300
  isSignatureFieldType: () => isSignatureFieldType,
286
301
  isTemplateVariable: () => isTemplateVariable,
@@ -299,7 +314,9 @@ __export(events_exports, {
299
314
  omitHiddenFields: () => omitHiddenFields,
300
315
  omitHiddenPaginatedFields: () => omitHiddenPaginatedFields,
301
316
  or: () => or,
317
+ resolveDateOfEvent: () => resolveDateOfEvent,
302
318
  runFieldValidations: () => runFieldValidations,
319
+ timePeriodToDateRange: () => timePeriodToDateRange,
303
320
  user: () => user,
304
321
  validate: () => validate,
305
322
  validateFieldInput: () => validateFieldInput,
@@ -313,7 +330,7 @@ var TENNIS_CLUB_MEMBERSHIP = "tennis-club-membership";
313
330
  var BIRTH_EVENT = "v2-birth";
314
331
 
315
332
  // ../commons/src/events/ActionConfig.ts
316
- var import_zod9 = require("zod");
333
+ var import_zod10 = require("zod");
317
334
 
318
335
  // ../commons/src/events/Conditional.ts
319
336
  var import_zod = require("zod");
@@ -365,10 +382,10 @@ var FieldConditional = import_zod.z.discriminatedUnion("type", [
365
382
  });
366
383
 
367
384
  // ../commons/src/events/PageConfig.ts
368
- var import_zod6 = require("zod");
385
+ var import_zod7 = require("zod");
369
386
 
370
387
  // ../commons/src/events/FieldConfig.ts
371
- var import_zod5 = require("zod");
388
+ var import_zod6 = require("zod");
372
389
 
373
390
  // ../commons/src/events/TranslationConfig.ts
374
391
  var import_zod2 = require("zod");
@@ -399,6 +416,9 @@ var FieldType = {
399
416
  EMAIL: "EMAIL",
400
417
  DATE: "DATE",
401
418
  DATE_RANGE: "DATE_RANGE",
419
+ // // Internal use, only for search functionality
420
+ SELECT_DATE_RANGE: "SELECT_DATE_RANGE",
421
+ // Internal use, only for search functionality
402
422
  PARAGRAPH: "PARAGRAPH",
403
423
  PAGE_HEADER: "PAGE_HEADER",
404
424
  RADIO_GROUP: "RADIO_GROUP",
@@ -425,10 +445,24 @@ var compositeFieldTypes = [
425
445
  ];
426
446
 
427
447
  // ../commons/src/events/FieldValue.ts
428
- var import_zod4 = require("zod");
448
+ var import_zod5 = require("zod");
429
449
 
430
- // ../commons/src/events/CompositeFieldValue.ts
450
+ // ../commons/src/documents.ts
431
451
  var import_zod3 = require("zod");
452
+ var import_zod_openapi3 = require("zod-openapi");
453
+ (0, import_zod_openapi3.extendZodWithOpenApi)(import_zod3.z);
454
+ var FullDocumentURL = import_zod3.z.string().brand("FullDocumentURL").describe(
455
+ "A full url with protocol, host, bucket name, starting from the root of the S3 server, https://minio/bucket-name/document-id.jpg"
456
+ );
457
+ var FullDocumentPath = import_zod3.z.string().transform((val) => val.startsWith("/") ? val : `/${val}`).openapi({ effectType: "input", type: "string" }).describe(
458
+ "A full absolute path with bucket name, starting from the root of the S3 server, /bucket-name/document-id.jpg"
459
+ );
460
+ var DocumentPath = import_zod3.z.string().brand("DocumentPath").describe(
461
+ "A full identifier starting from the root of the S3 bucket, e.g. /document-id.jpg or /directory/document-id.jpg but never /bucket-name/document-id.jpg"
462
+ );
463
+
464
+ // ../commons/src/events/CompositeFieldValue.ts
465
+ var import_zod4 = require("zod");
432
466
  var GeographicalArea = {
433
467
  URBAN: "URBAN",
434
468
  RURAL: "RURAL"
@@ -437,101 +471,113 @@ var AddressType = {
437
471
  DOMESTIC: "DOMESTIC",
438
472
  INTERNATIONAL: "INTERNATIONAL"
439
473
  };
440
- var FileFieldValue = import_zod3.z.object({
441
- filename: import_zod3.z.string(),
442
- originalFilename: import_zod3.z.string(),
443
- type: import_zod3.z.string()
474
+ var FileFieldValue = import_zod4.z.object({
475
+ path: FullDocumentPath,
476
+ originalFilename: import_zod4.z.string(),
477
+ type: import_zod4.z.string()
444
478
  });
445
- var AdminStructure = import_zod3.z.object({
446
- country: import_zod3.z.string(),
447
- addressType: import_zod3.z.literal(AddressType.DOMESTIC),
448
- province: import_zod3.z.string(),
449
- district: import_zod3.z.string()
479
+ var AdminStructure = import_zod4.z.object({
480
+ country: import_zod4.z.string(),
481
+ addressType: import_zod4.z.literal(AddressType.DOMESTIC),
482
+ province: import_zod4.z.string(),
483
+ district: import_zod4.z.string()
450
484
  });
451
485
  var UrbanAddressValue = AdminStructure.extend({
452
- urbanOrRural: import_zod3.z.literal(GeographicalArea.URBAN),
453
- town: import_zod3.z.string().optional(),
454
- residentialArea: import_zod3.z.string().optional(),
455
- street: import_zod3.z.string().optional(),
456
- number: import_zod3.z.string().optional(),
457
- zipCode: import_zod3.z.string().optional()
486
+ urbanOrRural: import_zod4.z.literal(GeographicalArea.URBAN),
487
+ town: import_zod4.z.string().optional(),
488
+ residentialArea: import_zod4.z.string().optional(),
489
+ street: import_zod4.z.string().optional(),
490
+ number: import_zod4.z.string().optional(),
491
+ zipCode: import_zod4.z.string().optional()
458
492
  });
459
493
  var RuralAddressValue = AdminStructure.extend({
460
- urbanOrRural: import_zod3.z.literal(GeographicalArea.RURAL),
461
- village: import_zod3.z.string().optional()
494
+ urbanOrRural: import_zod4.z.literal(GeographicalArea.RURAL),
495
+ village: import_zod4.z.string().optional()
462
496
  });
463
497
  var UrbanAddressUpdateValue = AdminStructure.extend({
464
- urbanOrRural: import_zod3.z.literal(GeographicalArea.URBAN),
465
- town: import_zod3.z.string().nullish(),
466
- residentialArea: import_zod3.z.string().nullish(),
467
- street: import_zod3.z.string().nullish(),
468
- number: import_zod3.z.string().nullish(),
469
- zipCode: import_zod3.z.string().nullish()
498
+ urbanOrRural: import_zod4.z.literal(GeographicalArea.URBAN),
499
+ town: import_zod4.z.string().nullish(),
500
+ residentialArea: import_zod4.z.string().nullish(),
501
+ street: import_zod4.z.string().nullish(),
502
+ number: import_zod4.z.string().nullish(),
503
+ zipCode: import_zod4.z.string().nullish()
470
504
  });
471
- var NameFieldValue = import_zod3.z.object({
472
- firstname: import_zod3.z.string(),
473
- surname: import_zod3.z.string(),
474
- middlename: import_zod3.z.string().optional()
505
+ var NameFieldValue = import_zod4.z.object({
506
+ firstname: import_zod4.z.string(),
507
+ surname: import_zod4.z.string(),
508
+ middlename: import_zod4.z.string().optional()
475
509
  });
476
- var NameFieldUpdateValue = import_zod3.z.object({
477
- firstname: import_zod3.z.string(),
478
- surname: import_zod3.z.string(),
479
- middlename: import_zod3.z.string().nullish()
480
- }).or(import_zod3.z.null()).or(import_zod3.z.undefined());
510
+ var NameFieldUpdateValue = import_zod4.z.object({
511
+ firstname: import_zod4.z.string().nullish(),
512
+ surname: import_zod4.z.string().nullish(),
513
+ middlename: import_zod4.z.string().nullish()
514
+ }).or(import_zod4.z.null()).or(import_zod4.z.undefined());
481
515
  var RuralAddressUpdateValue = AdminStructure.extend({
482
- urbanOrRural: import_zod3.z.literal(GeographicalArea.RURAL),
483
- village: import_zod3.z.string().nullish()
516
+ urbanOrRural: import_zod4.z.literal(GeographicalArea.RURAL),
517
+ village: import_zod4.z.string().nullish()
484
518
  });
485
- var GenericAddressValue = import_zod3.z.object({
486
- country: import_zod3.z.string(),
487
- addressType: import_zod3.z.literal(AddressType.INTERNATIONAL),
488
- state: import_zod3.z.string(),
489
- district2: import_zod3.z.string(),
490
- cityOrTown: import_zod3.z.string().optional(),
491
- addressLine1: import_zod3.z.string().optional(),
492
- addressLine2: import_zod3.z.string().optional(),
493
- addressLine3: import_zod3.z.string().optional(),
494
- postcodeOrZip: import_zod3.z.string().optional()
519
+ var GenericAddressValue = import_zod4.z.object({
520
+ country: import_zod4.z.string(),
521
+ addressType: import_zod4.z.literal(AddressType.INTERNATIONAL),
522
+ state: import_zod4.z.string(),
523
+ district2: import_zod4.z.string(),
524
+ cityOrTown: import_zod4.z.string().optional(),
525
+ addressLine1: import_zod4.z.string().optional(),
526
+ addressLine2: import_zod4.z.string().optional(),
527
+ addressLine3: import_zod4.z.string().optional(),
528
+ postcodeOrZip: import_zod4.z.string().optional()
495
529
  });
496
- var AddressFieldValue = import_zod3.z.discriminatedUnion("urbanOrRural", [UrbanAddressValue, RuralAddressValue]).or(GenericAddressValue);
497
- var GenericAddressUpdateValue = import_zod3.z.object({
498
- country: import_zod3.z.string(),
499
- addressType: import_zod3.z.literal(AddressType.INTERNATIONAL),
500
- state: import_zod3.z.string(),
501
- district2: import_zod3.z.string(),
502
- cityOrTown: import_zod3.z.string().nullish(),
503
- addressLine1: import_zod3.z.string().nullish(),
504
- addressLine2: import_zod3.z.string().nullish(),
505
- addressLine3: import_zod3.z.string().nullish(),
506
- postcodeOrZip: import_zod3.z.string().nullish()
530
+ var AddressFieldValue = import_zod4.z.discriminatedUnion("urbanOrRural", [UrbanAddressValue, RuralAddressValue]).or(GenericAddressValue);
531
+ var GenericAddressUpdateValue = import_zod4.z.object({
532
+ country: import_zod4.z.string(),
533
+ addressType: import_zod4.z.literal(AddressType.INTERNATIONAL),
534
+ state: import_zod4.z.string(),
535
+ district2: import_zod4.z.string(),
536
+ cityOrTown: import_zod4.z.string().nullish(),
537
+ addressLine1: import_zod4.z.string().nullish(),
538
+ addressLine2: import_zod4.z.string().nullish(),
539
+ addressLine3: import_zod4.z.string().nullish(),
540
+ postcodeOrZip: import_zod4.z.string().nullish()
507
541
  });
508
- var AddressFieldUpdateValue = import_zod3.z.discriminatedUnion("urbanOrRural", [
542
+ var AddressFieldUpdateValue = import_zod4.z.discriminatedUnion("urbanOrRural", [
509
543
  UrbanAddressUpdateValue,
510
544
  RuralAddressUpdateValue
511
545
  ]).or(GenericAddressUpdateValue);
512
- var FileFieldValueWithOption = import_zod3.z.object({
513
- filename: import_zod3.z.string(),
514
- originalFilename: import_zod3.z.string(),
515
- type: import_zod3.z.string(),
516
- option: import_zod3.z.string()
546
+ var FileFieldValueWithOption = import_zod4.z.object({
547
+ path: FullDocumentPath,
548
+ originalFilename: import_zod4.z.string(),
549
+ type: import_zod4.z.string(),
550
+ option: import_zod4.z.string()
517
551
  });
518
- var FileFieldWithOptionValue = import_zod3.z.array(FileFieldValueWithOption);
552
+ var FileFieldWithOptionValue = import_zod4.z.array(FileFieldValueWithOption);
519
553
 
520
554
  // ../commons/src/events/FieldValue.ts
521
- var TextValue = import_zod4.z.string();
555
+ var TextValue = import_zod5.z.string();
522
556
  var NonEmptyTextValue = TextValue.min(1);
523
- var DateValue = import_zod4.z.string().date().describe("Date in the format YYYY-MM-DD");
524
- var DatetimeValue = import_zod4.z.string().datetime();
525
- var DateRangeFieldValue = DateValue.or(import_zod4.z.tuple([DateValue, DateValue]));
526
- var EmailValue = import_zod4.z.string().email();
527
- var CheckboxFieldValue = import_zod4.z.boolean();
528
- var NumberFieldValue = import_zod4.z.number();
529
- var DataFieldValue = import_zod4.z.undefined();
530
- var SignatureFieldValue = import_zod4.z.string();
531
- var FieldValue = import_zod4.z.union([
557
+ var DateValue = import_zod5.z.string().date().describe("Date in the format YYYY-MM-DD");
558
+ var DatetimeValue = import_zod5.z.string().datetime();
559
+ var SelectDateRangeValue = import_zod5.z.enum([
560
+ "last7Days",
561
+ "last30Days",
562
+ "last90Days",
563
+ "last365Days"
564
+ ]);
565
+ var DateRangeFieldValue = import_zod5.z.object({
566
+ start: DateValue,
567
+ end: DateValue
568
+ }).or(DateValue).describe(
569
+ "Date range with start and end dates in the format YYYY-MM-DD. Inclusive start, exclusive end."
570
+ );
571
+ var EmailValue = import_zod5.z.string().email();
572
+ var CheckboxFieldValue = import_zod5.z.boolean();
573
+ var NumberFieldValue = import_zod5.z.number();
574
+ var DataFieldValue = import_zod5.z.undefined();
575
+ var SignatureFieldValue = import_zod5.z.string();
576
+ var FieldValue = import_zod5.z.union([
532
577
  TextValue,
533
578
  DateValue,
534
579
  DateRangeFieldValue,
580
+ SelectDateRangeValue,
535
581
  CheckboxFieldValue,
536
582
  NumberFieldValue,
537
583
  FileFieldValue,
@@ -543,10 +589,11 @@ var FieldValue = import_zod4.z.union([
543
589
  NameFieldValue,
544
590
  NameFieldUpdateValue
545
591
  ]);
546
- var FieldUpdateValue = import_zod4.z.union([
592
+ var FieldUpdateValue = import_zod5.z.union([
547
593
  TextValue,
548
594
  DateValue,
549
595
  DateRangeFieldValue,
596
+ SelectDateRangeValue,
550
597
  CheckboxFieldValue,
551
598
  NumberFieldValue,
552
599
  FileFieldValue,
@@ -559,64 +606,64 @@ var FieldUpdateValue = import_zod4.z.union([
559
606
  ]);
560
607
 
561
608
  // ../commons/src/events/FieldConfig.ts
562
- var import_zod_openapi3 = require("zod-openapi");
563
- (0, import_zod_openapi3.extendZodWithOpenApi)(import_zod5.z);
564
- var FieldId = import_zod5.z.string().describe("Unique identifier for the field");
565
- var FieldReference = import_zod5.z.object({
609
+ var import_zod_openapi4 = require("zod-openapi");
610
+ (0, import_zod_openapi4.extendZodWithOpenApi)(import_zod6.z);
611
+ var FieldId = import_zod6.z.string().describe("Unique identifier for the field");
612
+ var FieldReference = import_zod6.z.object({
566
613
  $$field: FieldId
567
614
  }).describe("Reference to a field by its ID");
568
615
  var ParentReference = FieldReference.optional();
569
- var BaseField = import_zod5.z.object({
616
+ var ValidationConfig = import_zod6.z.object({
617
+ validator: Conditional,
618
+ message: TranslationConfig
619
+ });
620
+ var BaseField = import_zod6.z.object({
570
621
  id: FieldId,
571
622
  parent: ParentReference,
572
- conditionals: import_zod5.z.array(FieldConditional).default([]).optional(),
573
- required: import_zod5.z.boolean().default(false).optional(),
623
+ conditionals: import_zod6.z.array(FieldConditional).default([]).optional(),
624
+ required: import_zod6.z.boolean().default(false).optional(),
625
+ secured: import_zod6.z.boolean().default(false).optional(),
574
626
  placeholder: TranslationConfig.optional(),
575
- validation: import_zod5.z.array(
576
- import_zod5.z.object({
577
- validator: Conditional,
578
- message: TranslationConfig
579
- })
580
- ).default([]).optional(),
627
+ validation: import_zod6.z.array(ValidationConfig).default([]).optional(),
581
628
  label: TranslationConfig,
582
629
  helperText: TranslationConfig.optional(),
583
- hideLabel: import_zod5.z.boolean().default(false).optional()
630
+ hideLabel: import_zod6.z.boolean().default(false).optional()
584
631
  });
585
632
  var Divider = BaseField.extend({
586
- type: import_zod5.z.literal(FieldType.DIVIDER)
633
+ type: import_zod6.z.literal(FieldType.DIVIDER)
587
634
  });
588
635
  var TextField = BaseField.extend({
589
- type: import_zod5.z.literal(FieldType.TEXT),
636
+ type: import_zod6.z.literal(FieldType.TEXT),
590
637
  defaultValue: NonEmptyTextValue.optional(),
591
- configuration: import_zod5.z.object({
592
- maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
593
- type: import_zod5.z.enum(["text", "password"]).optional(),
638
+ configuration: import_zod6.z.object({
639
+ maxLength: import_zod6.z.number().optional().describe("Maximum length of the text"),
640
+ type: import_zod6.z.enum(["text", "password"]).optional(),
594
641
  prefix: TranslationConfig.optional(),
595
642
  postfix: TranslationConfig.optional()
596
643
  }).default({ type: "text" }).optional()
597
644
  }).describe("Text input");
598
645
  var NumberField = BaseField.extend({
599
- type: import_zod5.z.literal(FieldType.NUMBER),
646
+ type: import_zod6.z.literal(FieldType.NUMBER),
600
647
  defaultValue: NumberFieldValue.optional(),
601
- configuration: import_zod5.z.object({
602
- min: import_zod5.z.number().optional().describe("Minimum value"),
603
- max: import_zod5.z.number().optional().describe("Maximum value"),
648
+ configuration: import_zod6.z.object({
649
+ min: import_zod6.z.number().optional().describe("Minimum value"),
650
+ max: import_zod6.z.number().optional().describe("Maximum value"),
604
651
  prefix: TranslationConfig.optional(),
605
652
  postfix: TranslationConfig.optional()
606
653
  }).optional()
607
654
  }).describe("Number input");
608
655
  var TextAreaField = BaseField.extend({
609
- type: import_zod5.z.literal(FieldType.TEXTAREA),
656
+ type: import_zod6.z.literal(FieldType.TEXTAREA),
610
657
  defaultValue: NonEmptyTextValue.optional(),
611
- configuration: import_zod5.z.object({
612
- maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
613
- rows: import_zod5.z.number().optional().describe("Number of visible text lines"),
614
- cols: import_zod5.z.number().optional().describe("Number of visible columns"),
658
+ configuration: import_zod6.z.object({
659
+ maxLength: import_zod6.z.number().optional().describe("Maximum length of the text"),
660
+ rows: import_zod6.z.number().optional().describe("Number of visible text lines"),
661
+ cols: import_zod6.z.number().optional().describe("Number of visible columns"),
615
662
  prefix: TranslationConfig.optional(),
616
663
  postfix: TranslationConfig.optional()
617
664
  }).default({ rows: 4 }).optional()
618
665
  }).describe("Multiline text input");
619
- var ImageMimeType = import_zod5.z.enum([
666
+ var ImageMimeType = import_zod6.z.enum([
620
667
  "image/png",
621
668
  "image/jpg",
622
669
  "image/jpeg",
@@ -625,46 +672,44 @@ var ImageMimeType = import_zod5.z.enum([
625
672
  var MimeType = ImageMimeType;
626
673
  var DEFAULT_MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;
627
674
  var SignatureField = BaseField.extend({
628
- type: import_zod5.z.literal(FieldType.SIGNATURE),
675
+ type: import_zod6.z.literal(FieldType.SIGNATURE),
629
676
  signaturePromptLabel: TranslationConfig.describe(
630
677
  "Title of the signature modal"
631
678
  ),
632
679
  defaultValue: SignatureFieldValue.optional(),
633
- configuration: import_zod5.z.object({
634
- maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
680
+ configuration: import_zod6.z.object({
681
+ maxFileSize: import_zod6.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
635
682
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
636
683
  }).default({
637
684
  maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
638
685
  })
639
686
  }).describe("Signature input field");
640
687
  var EmailField = BaseField.extend({
641
- type: import_zod5.z.literal(FieldType.EMAIL),
642
- configuration: import_zod5.z.object({
643
- maxLength: import_zod5.z.number().optional().describe("Maximum length of the text")
688
+ type: import_zod6.z.literal(FieldType.EMAIL),
689
+ configuration: import_zod6.z.object({
690
+ maxLength: import_zod6.z.number().optional().describe("Maximum length of the text")
644
691
  }).default({ maxLength: 10 }).optional(),
645
692
  defaultValue: NonEmptyTextValue.optional()
646
693
  });
647
694
  var DateField = BaseField.extend({
648
- type: import_zod5.z.literal(FieldType.DATE),
695
+ type: import_zod6.z.literal(FieldType.DATE),
649
696
  defaultValue: DateValue.optional(),
650
- configuration: import_zod5.z.object({
697
+ configuration: import_zod6.z.object({
651
698
  notice: TranslationConfig.describe(
652
699
  "Text to display above the date input"
653
700
  ).optional()
654
701
  }).optional()
655
- }).describe("A single date input (dd-mm-YYYY)");
702
+ }).describe("A single date input (yyyy-MM-dd)");
656
703
  var DateRangeField = BaseField.extend({
657
- type: import_zod5.z.literal(FieldType.DATE_RANGE),
704
+ type: import_zod6.z.literal(FieldType.DATE_RANGE),
658
705
  defaultValue: DateRangeFieldValue.optional(),
659
- configuration: import_zod5.z.object({
706
+ configuration: import_zod6.z.object({
660
707
  notice: TranslationConfig.describe(
661
708
  "Text to display above the date input"
662
709
  ).optional()
663
710
  }).optional()
664
- }).describe(
665
- "A date range input ({ rangeStart: dd-mm-YYYY, rangeEnd: dd-mm-YYYY })"
666
- );
667
- var HtmlFontVariant = import_zod5.z.enum([
711
+ }).describe("A date range input ({ start: yyyy-MM-dd, end: yyyy-MM-dd })");
712
+ var HtmlFontVariant = import_zod6.z.enum([
668
713
  "reg12",
669
714
  "reg14",
670
715
  "reg16",
@@ -675,26 +720,26 @@ var HtmlFontVariant = import_zod5.z.enum([
675
720
  "h1"
676
721
  ]);
677
722
  var Paragraph = BaseField.extend({
678
- type: import_zod5.z.literal(FieldType.PARAGRAPH),
723
+ type: import_zod6.z.literal(FieldType.PARAGRAPH),
679
724
  defaultValue: NonEmptyTextValue.optional(),
680
- configuration: import_zod5.z.object({
681
- styles: import_zod5.z.object({
725
+ configuration: import_zod6.z.object({
726
+ styles: import_zod6.z.object({
682
727
  fontVariant: HtmlFontVariant.optional()
683
728
  }).optional()
684
729
  }).default({})
685
730
  }).describe("A read-only HTML <p> paragraph");
686
731
  var PageHeader = BaseField.extend({
687
- type: import_zod5.z.literal(FieldType.PAGE_HEADER),
732
+ type: import_zod6.z.literal(FieldType.PAGE_HEADER),
688
733
  defaultValue: NonEmptyTextValue.optional()
689
734
  }).describe("A read-only header component for form pages");
690
735
  var File = BaseField.extend({
691
- type: import_zod5.z.literal(FieldType.FILE),
736
+ type: import_zod6.z.literal(FieldType.FILE),
692
737
  defaultValue: FileFieldValue.optional(),
693
- configuration: import_zod5.z.object({
694
- maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
738
+ configuration: import_zod6.z.object({
739
+ maxFileSize: import_zod6.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
695
740
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
696
- style: import_zod5.z.object({
697
- width: import_zod5.z.enum(["full", "auto"]).optional().describe(
741
+ style: import_zod6.z.object({
742
+ width: import_zod6.z.enum(["full", "auto"]).optional().describe(
698
743
  "Whether the file upload button should take the full width of the container or not"
699
744
  )
700
745
  }).optional(),
@@ -703,129 +748,144 @@ var File = BaseField.extend({
703
748
  maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
704
749
  })
705
750
  }).describe("File upload");
706
- var SelectOption = import_zod5.z.object({
707
- value: import_zod5.z.string().describe("The value of the option"),
751
+ var SelectOption = import_zod6.z.object({
752
+ value: import_zod6.z.string().describe("The value of the option"),
708
753
  label: TranslationConfig.describe("The label of the option")
709
754
  });
710
755
  var RadioGroup = BaseField.extend({
711
- type: import_zod5.z.literal(FieldType.RADIO_GROUP),
756
+ type: import_zod6.z.literal(FieldType.RADIO_GROUP),
712
757
  defaultValue: TextValue.optional(),
713
- options: import_zod5.z.array(SelectOption).describe("A list of options"),
714
- configuration: import_zod5.z.object({
715
- styles: import_zod5.z.object({
716
- size: import_zod5.z.enum(["NORMAL", "LARGE"]).optional()
758
+ options: import_zod6.z.array(SelectOption).describe("A list of options"),
759
+ configuration: import_zod6.z.object({
760
+ styles: import_zod6.z.object({
761
+ size: import_zod6.z.enum(["NORMAL", "LARGE"]).optional()
717
762
  }).optional()
718
763
  }).optional()
719
764
  }).describe("Grouped radio options");
720
765
  var BulletList = BaseField.extend({
721
- type: import_zod5.z.literal(FieldType.BULLET_LIST),
766
+ type: import_zod6.z.literal(FieldType.BULLET_LIST),
722
767
  defaultValue: TextValue.optional(),
723
- items: import_zod5.z.array(TranslationConfig).describe("A list of items"),
724
- configuration: import_zod5.z.object({
725
- styles: import_zod5.z.object({
768
+ items: import_zod6.z.array(TranslationConfig).describe("A list of items"),
769
+ configuration: import_zod6.z.object({
770
+ styles: import_zod6.z.object({
726
771
  fontVariant: HtmlFontVariant.optional()
727
772
  }).optional()
728
773
  }).default({})
729
774
  }).describe("A list of bullet points");
730
775
  var Select = BaseField.extend({
731
- type: import_zod5.z.literal(FieldType.SELECT),
776
+ type: import_zod6.z.literal(FieldType.SELECT),
732
777
  defaultValue: TextValue.optional(),
733
- options: import_zod5.z.array(SelectOption).describe("A list of options")
778
+ options: import_zod6.z.array(SelectOption).describe("A list of options")
734
779
  }).describe("Select input");
780
+ var SelectDateRangeOption = import_zod6.z.object({
781
+ value: SelectDateRangeValue.describe("The value of the option"),
782
+ label: TranslationConfig.describe("The label of the option")
783
+ });
784
+ var SelectDateRangeField = BaseField.extend({
785
+ type: import_zod6.z.literal(FieldType.SELECT_DATE_RANGE),
786
+ defaultValue: SelectDateRangeValue.optional(),
787
+ options: import_zod6.z.array(SelectDateRangeOption).describe("A list of options")
788
+ }).describe("Select input with date range options");
735
789
  var NameField = BaseField.extend({
736
- type: import_zod5.z.literal(FieldType.NAME),
737
- defaultValue: import_zod5.z.object({
790
+ type: import_zod6.z.literal(FieldType.NAME),
791
+ defaultValue: import_zod6.z.object({
738
792
  firstname: NonEmptyTextValue,
739
793
  surname: NonEmptyTextValue
740
794
  }).optional(),
741
- configuration: import_zod5.z.object({
742
- maxLength: import_zod5.z.number().optional().describe("Maximum length of the text"),
795
+ configuration: import_zod6.z.object({
796
+ maxLength: import_zod6.z.number().optional().describe("Maximum length of the text"),
743
797
  prefix: TranslationConfig.optional(),
744
- postfix: TranslationConfig.optional()
798
+ postfix: TranslationConfig.optional(),
799
+ includeMiddlename: import_zod6.z.boolean().default(false).optional().describe("To make middle name visible in Name form field"),
800
+ searchMode: import_zod6.z.boolean().optional()
745
801
  }).optional()
746
802
  }).describe("Name input field");
747
803
  var PhoneField = BaseField.extend({
748
804
  defaultValue: NonEmptyTextValue.optional(),
749
- type: import_zod5.z.literal(FieldType.PHONE)
805
+ type: import_zod6.z.literal(FieldType.PHONE)
750
806
  }).describe("Phone input field");
751
807
  var IdField = BaseField.extend({
752
808
  defaultValue: NonEmptyTextValue.optional(),
753
- type: import_zod5.z.literal(FieldType.ID)
809
+ type: import_zod6.z.literal(FieldType.ID)
754
810
  }).describe("ID input field");
755
811
  var Checkbox = BaseField.extend({
756
- type: import_zod5.z.literal(FieldType.CHECKBOX),
812
+ type: import_zod6.z.literal(FieldType.CHECKBOX),
757
813
  defaultValue: CheckboxFieldValue.optional()
758
814
  }).describe("Boolean checkbox field");
759
815
  var Country = BaseField.extend({
760
- type: import_zod5.z.literal(FieldType.COUNTRY),
816
+ type: import_zod6.z.literal(FieldType.COUNTRY),
761
817
  defaultValue: NonEmptyTextValue.optional()
762
818
  }).describe("Country select field");
763
- var AdministrativeAreas = import_zod5.z.enum([
819
+ var AdministrativeAreas = import_zod6.z.enum([
764
820
  "ADMIN_STRUCTURE",
765
821
  "HEALTH_FACILITY",
766
822
  "CRVS_OFFICE"
767
823
  ]);
768
- var AdministrativeAreaConfiguration = import_zod5.z.object({
769
- partOf: import_zod5.z.object({
770
- $declaration: import_zod5.z.string()
824
+ var AdministrativeAreaConfiguration = import_zod6.z.object({
825
+ partOf: import_zod6.z.object({
826
+ $declaration: import_zod6.z.string()
771
827
  }).optional().describe("Parent location"),
772
828
  type: AdministrativeAreas
773
829
  }).describe("Administrative area options");
774
830
  var AdministrativeArea = BaseField.extend({
775
- type: import_zod5.z.literal(FieldType.ADMINISTRATIVE_AREA),
831
+ type: import_zod6.z.literal(FieldType.ADMINISTRATIVE_AREA),
776
832
  defaultValue: NonEmptyTextValue.optional(),
777
833
  configuration: AdministrativeAreaConfiguration
778
834
  }).describe("Administrative area input field e.g. facility, office");
779
835
  var Location = BaseField.extend({
780
- type: import_zod5.z.literal(FieldType.LOCATION),
836
+ type: import_zod6.z.literal(FieldType.LOCATION),
781
837
  defaultValue: NonEmptyTextValue.optional()
782
838
  }).describe("Input field for a location");
783
839
  var FileUploadWithOptions = BaseField.extend({
784
- type: import_zod5.z.literal(FieldType.FILE_WITH_OPTIONS),
785
- options: import_zod5.z.array(SelectOption).describe("A list of options"),
840
+ type: import_zod6.z.literal(FieldType.FILE_WITH_OPTIONS),
841
+ options: import_zod6.z.array(SelectOption).describe("A list of options"),
786
842
  defaultValue: FileFieldWithOptionValue.optional(),
787
- configuration: import_zod5.z.object({
788
- maxFileSize: import_zod5.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
843
+ configuration: import_zod6.z.object({
844
+ maxFileSize: import_zod6.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
789
845
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
790
846
  }).default({
791
847
  maxFileSize: DEFAULT_MAX_FILE_SIZE_BYTES
792
848
  })
793
849
  });
794
850
  var Facility = BaseField.extend({
795
- type: import_zod5.z.literal(FieldType.FACILITY),
851
+ type: import_zod6.z.literal(FieldType.FACILITY),
796
852
  defaultValue: NonEmptyTextValue.optional()
797
853
  }).describe("Input field for a facility");
798
854
  var Office = BaseField.extend({
799
- type: import_zod5.z.literal(FieldType.OFFICE),
855
+ type: import_zod6.z.literal(FieldType.OFFICE),
800
856
  defaultValue: NonEmptyTextValue.optional()
801
857
  }).describe("Input field for an office");
802
858
  var Address = BaseField.extend({
803
- type: import_zod5.z.literal(FieldType.ADDRESS),
804
- defaultValue: AddressFieldValue.optional()
859
+ type: import_zod6.z.literal(FieldType.ADDRESS),
860
+ defaultValue: AddressFieldValue.optional(),
861
+ configuration: import_zod6.z.object({
862
+ searchMode: import_zod6.z.boolean().optional()
863
+ }).optional()
805
864
  }).describe("Address input field \u2013 a combination of location and text fields");
806
- var DataEntry = import_zod5.z.union([
807
- import_zod5.z.object({
865
+ var DataEntry = import_zod6.z.union([
866
+ import_zod6.z.object({
808
867
  label: TranslationConfig,
809
- value: TranslationConfig.or(import_zod5.z.string())
868
+ value: TranslationConfig.or(import_zod6.z.string())
810
869
  }),
811
- import_zod5.z.object({
812
- fieldId: import_zod5.z.string()
870
+ import_zod6.z.object({
871
+ fieldId: import_zod6.z.string()
813
872
  })
814
873
  ]);
815
874
  var DataField = BaseField.extend({
816
- type: import_zod5.z.literal(FieldType.DATA),
817
- configuration: import_zod5.z.object({
875
+ type: import_zod6.z.literal(FieldType.DATA),
876
+ configuration: import_zod6.z.object({
818
877
  subtitle: TranslationConfig.optional(),
819
- data: import_zod5.z.array(DataEntry)
878
+ data: import_zod6.z.array(DataEntry)
820
879
  })
821
880
  }).describe("Data field for displaying read-only data");
822
- var FieldConfig = import_zod5.z.discriminatedUnion("type", [
881
+ var FieldConfig = import_zod6.z.discriminatedUnion("type", [
823
882
  Address,
824
883
  TextField,
825
884
  NumberField,
826
885
  TextAreaField,
827
886
  DateField,
828
887
  DateRangeField,
888
+ SelectDateRangeField,
829
889
  Paragraph,
830
890
  RadioGroup,
831
891
  BulletList,
@@ -852,13 +912,13 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
852
912
  });
853
913
 
854
914
  // ../commons/src/events/PageConfig.ts
855
- var import_zod_openapi4 = require("zod-openapi");
856
- (0, import_zod_openapi4.extendZodWithOpenApi)(import_zod6.z);
857
- var PageTypes = import_zod6.z.enum(["FORM", "VERIFICATION"]);
858
- var PageConfigBase = import_zod6.z.object({
859
- id: import_zod6.z.string().describe("Unique identifier for the page"),
915
+ var import_zod_openapi5 = require("zod-openapi");
916
+ (0, import_zod_openapi5.extendZodWithOpenApi)(import_zod7.z);
917
+ var PageTypes = import_zod7.z.enum(["FORM", "VERIFICATION"]);
918
+ var PageConfigBase = import_zod7.z.object({
919
+ id: import_zod7.z.string().describe("Unique identifier for the page"),
860
920
  title: TranslationConfig.describe("Header title of the page"),
861
- fields: import_zod6.z.array(FieldConfig).describe("Fields to be rendered on the page"),
921
+ fields: import_zod7.z.array(FieldConfig).describe("Fields to be rendered on the page"),
862
922
  conditional: Conditional.optional().describe(
863
923
  "Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
864
924
  )
@@ -867,13 +927,13 @@ var PageConfigBase = import_zod6.z.object({
867
927
  ref: "FormPageConfig"
868
928
  });
869
929
  var FormPageConfig = PageConfigBase.extend({
870
- type: import_zod6.z.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
930
+ type: import_zod7.z.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
871
931
  });
872
- var VerificationActionConfig = import_zod6.z.object({
873
- verify: import_zod6.z.object({ label: TranslationConfig }),
874
- cancel: import_zod6.z.object({
932
+ var VerificationActionConfig = import_zod7.z.object({
933
+ verify: import_zod7.z.object({ label: TranslationConfig }),
934
+ cancel: import_zod7.z.object({
875
935
  label: TranslationConfig,
876
- confirmation: import_zod6.z.object({
936
+ confirmation: import_zod7.z.object({
877
937
  title: TranslationConfig,
878
938
  body: TranslationConfig
879
939
  })
@@ -883,16 +943,16 @@ var VerificationActionConfig = import_zod6.z.object({
883
943
  ref: "VerificationActionConfig"
884
944
  });
885
945
  var VerificationPageConfig = FormPageConfig.extend({
886
- type: import_zod6.z.literal(PageTypes.enum.VERIFICATION),
946
+ type: import_zod7.z.literal(PageTypes.enum.VERIFICATION),
887
947
  actions: VerificationActionConfig
888
948
  });
889
- var PageConfig = import_zod6.z.discriminatedUnion("type", [
949
+ var PageConfig = import_zod7.z.discriminatedUnion("type", [
890
950
  FormPageConfig,
891
951
  VerificationPageConfig
892
952
  ]);
893
953
 
894
954
  // ../commons/src/events/ActionType.ts
895
- var import_zod7 = require("zod");
955
+ var import_zod8 = require("zod");
896
956
  var ActionType = {
897
957
  // Pre-declaration actions
898
958
  DELETE: "DELETE",
@@ -928,7 +988,7 @@ var ConfirmableActions = [
928
988
  ActionType.ARCHIVE,
929
989
  ActionType.PRINT_CERTIFICATE
930
990
  ];
931
- var ActionTypes = import_zod7.z.enum([
991
+ var ActionTypes = import_zod8.z.enum([
932
992
  "DELETE",
933
993
  "CREATE",
934
994
  "NOTIFY",
@@ -988,103 +1048,103 @@ function isMetaAction(actionType) {
988
1048
  }
989
1049
 
990
1050
  // ../commons/src/events/FormConfig.ts
991
- var import_zod8 = require("zod");
992
- var DeclarationFormConfig = import_zod8.z.object({
1051
+ var import_zod9 = require("zod");
1052
+ var DeclarationFormConfig = import_zod9.z.object({
993
1053
  label: TranslationConfig.describe("Human readable description of the form"),
994
- pages: import_zod8.z.array(FormPageConfig)
1054
+ pages: import_zod9.z.array(FormPageConfig)
995
1055
  }).describe("Configuration for a declaration form");
996
- var ActionFormConfig = import_zod8.z.object({
1056
+ var ActionFormConfig = import_zod9.z.object({
997
1057
  label: TranslationConfig.describe("Human readable description of the form"),
998
- pages: import_zod8.z.array(PageConfig)
1058
+ pages: import_zod9.z.array(PageConfig)
999
1059
  });
1000
- var FormConfig = import_zod8.z.union([DeclarationFormConfig, ActionFormConfig]);
1060
+ var FormConfig = import_zod9.z.union([DeclarationFormConfig, ActionFormConfig]);
1001
1061
 
1002
1062
  // ../commons/src/events/ActionConfig.ts
1003
- var import_zod_openapi5 = require("zod-openapi");
1004
- (0, import_zod_openapi5.extendZodWithOpenApi)(import_zod9.z);
1005
- var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
1063
+ var import_zod_openapi6 = require("zod-openapi");
1064
+ (0, import_zod_openapi6.extendZodWithOpenApi)(import_zod10.z);
1065
+ var ActionConditional2 = import_zod10.z.discriminatedUnion("type", [
1006
1066
  /** If conditional is defined, the action is shown to the user only if the condition is met */
1007
1067
  ShowConditional,
1008
1068
  /** If conditional is defined, the action is enabled only if the condition is met */
1009
1069
  EnableConditional
1010
1070
  ]);
1011
- var DeclarationReviewConfig = import_zod9.z.object({
1071
+ var DeclarationReviewConfig = import_zod10.z.object({
1012
1072
  title: TranslationConfig.describe("Title of the review page"),
1013
- fields: import_zod9.z.array(FieldConfig).describe("Fields to be rendered on the review page for annotations.")
1073
+ fields: import_zod10.z.array(FieldConfig).describe("Fields to be rendered on the review page for annotations.")
1014
1074
  }).describe("Configuration for **declaration** review page.");
1015
- var ActionConfigBase = import_zod9.z.object({
1075
+ var ActionConfigBase = import_zod10.z.object({
1016
1076
  label: TranslationConfig,
1017
- conditionals: import_zod9.z.array(ActionConditional2).optional().default([]),
1018
- draft: import_zod9.z.boolean().optional()
1077
+ conditionals: import_zod10.z.array(ActionConditional2).optional().default([]),
1078
+ draft: import_zod10.z.boolean().optional()
1019
1079
  });
1020
1080
  var ReadActionConfig = ActionConfigBase.merge(
1021
- import_zod9.z.object({
1022
- type: import_zod9.z.literal(ActionType.READ),
1081
+ import_zod10.z.object({
1082
+ type: import_zod10.z.literal(ActionType.READ),
1023
1083
  review: DeclarationReviewConfig
1024
1084
  })
1025
1085
  );
1026
1086
  var DeclareConfig = ActionConfigBase.merge(
1027
- import_zod9.z.object({
1028
- type: import_zod9.z.literal(ActionType.DECLARE),
1087
+ import_zod10.z.object({
1088
+ type: import_zod10.z.literal(ActionType.DECLARE),
1029
1089
  review: DeclarationReviewConfig
1030
1090
  })
1031
1091
  );
1032
1092
  var ValidateConfig = ActionConfigBase.merge(
1033
- import_zod9.z.object({
1034
- type: import_zod9.z.literal(ActionType.VALIDATE),
1093
+ import_zod10.z.object({
1094
+ type: import_zod10.z.literal(ActionType.VALIDATE),
1035
1095
  review: DeclarationReviewConfig
1036
1096
  })
1037
1097
  );
1038
1098
  var RegisterConfig = ActionConfigBase.merge(
1039
- import_zod9.z.object({
1040
- type: import_zod9.z.literal(ActionType.REGISTER),
1099
+ import_zod10.z.object({
1100
+ type: import_zod10.z.literal(ActionType.REGISTER),
1041
1101
  review: DeclarationReviewConfig
1042
1102
  })
1043
1103
  );
1044
1104
  var RejectDeclarationConfig = ActionConfigBase.merge(
1045
- import_zod9.z.object({
1046
- type: import_zod9.z.literal(ActionType.REJECT)
1105
+ import_zod10.z.object({
1106
+ type: import_zod10.z.literal(ActionType.REJECT)
1047
1107
  })
1048
1108
  );
1049
1109
  var MarkedAsDuplicateConfig = ActionConfigBase.merge(
1050
- import_zod9.z.object({
1051
- type: import_zod9.z.literal(ActionType.MARKED_AS_DUPLICATE)
1110
+ import_zod10.z.object({
1111
+ type: import_zod10.z.literal(ActionType.MARKED_AS_DUPLICATE)
1052
1112
  })
1053
1113
  );
1054
1114
  var ArchiveConfig = ActionConfigBase.merge(
1055
- import_zod9.z.object({
1056
- type: import_zod9.z.literal(ActionType.ARCHIVE)
1115
+ import_zod10.z.object({
1116
+ type: import_zod10.z.literal(ActionType.ARCHIVE)
1057
1117
  })
1058
1118
  );
1059
1119
  var DeleteConfig = ActionConfigBase.merge(
1060
- import_zod9.z.object({
1061
- type: import_zod9.z.literal(ActionType.DELETE)
1120
+ import_zod10.z.object({
1121
+ type: import_zod10.z.literal(ActionType.DELETE)
1062
1122
  })
1063
1123
  );
1064
1124
  var PrintCertificateActionConfig = ActionConfigBase.merge(
1065
- import_zod9.z.object({
1066
- type: import_zod9.z.literal(ActionType.PRINT_CERTIFICATE),
1125
+ import_zod10.z.object({
1126
+ type: import_zod10.z.literal(ActionType.PRINT_CERTIFICATE),
1067
1127
  printForm: ActionFormConfig
1068
1128
  })
1069
1129
  );
1070
1130
  var RequestCorrectionConfig = ActionConfigBase.merge(
1071
- import_zod9.z.object({
1072
- type: import_zod9.z.literal(ActionType.REQUEST_CORRECTION),
1073
- onboardingForm: import_zod9.z.array(PageConfig),
1074
- additionalDetailsForm: import_zod9.z.array(PageConfig)
1131
+ import_zod10.z.object({
1132
+ type: import_zod10.z.literal(ActionType.REQUEST_CORRECTION),
1133
+ onboardingForm: import_zod10.z.array(PageConfig),
1134
+ additionalDetailsForm: import_zod10.z.array(PageConfig)
1075
1135
  })
1076
1136
  );
1077
1137
  var RejectCorrectionConfig = ActionConfigBase.merge(
1078
- import_zod9.z.object({
1079
- type: import_zod9.z.literal(ActionType.REJECT_CORRECTION)
1138
+ import_zod10.z.object({
1139
+ type: import_zod10.z.literal(ActionType.REJECT_CORRECTION)
1080
1140
  })
1081
1141
  );
1082
1142
  var ApproveCorrectionConfig = ActionConfigBase.merge(
1083
- import_zod9.z.object({
1084
- type: import_zod9.z.literal(ActionType.APPROVE_CORRECTION)
1143
+ import_zod10.z.object({
1144
+ type: import_zod10.z.literal(ActionType.APPROVE_CORRECTION)
1085
1145
  })
1086
1146
  );
1087
- var ActionConfig = import_zod9.z.discriminatedUnion("type", [
1147
+ var ActionConfig = import_zod10.z.discriminatedUnion("type", [
1088
1148
  /*
1089
1149
  * OpenAPI references are defined here so our generated OpenAPI spec knows to reuse the models
1090
1150
  * and treat them as "models" instead of duplicating the data structure in each endpoint.
@@ -1104,108 +1164,108 @@ var ActionConfig = import_zod9.z.discriminatedUnion("type", [
1104
1164
  RejectCorrectionConfig.openapi({ ref: "RejectCorrectionActionConfig" }),
1105
1165
  ApproveCorrectionConfig.openapi({ ref: "ApproveCorrectionActionConfig" })
1106
1166
  ]).openapi({ ref: "ActionConfig" });
1107
- var DeclarationActionConfig = import_zod9.z.discriminatedUnion("type", [
1167
+ var DeclarationActionConfig = import_zod10.z.discriminatedUnion("type", [
1108
1168
  DeclareConfig,
1109
1169
  ValidateConfig,
1110
1170
  RegisterConfig
1111
1171
  ]);
1112
1172
 
1113
1173
  // ../commons/src/events/offline/CertificateConfig.ts
1114
- var import_zod10 = require("zod");
1115
- var FontFamily = import_zod10.z.object({
1116
- normal: import_zod10.z.string(),
1117
- bold: import_zod10.z.string(),
1118
- italics: import_zod10.z.string(),
1119
- bolditalics: import_zod10.z.string()
1174
+ var import_zod11 = require("zod");
1175
+ var FontFamily = import_zod11.z.object({
1176
+ normal: import_zod11.z.string(),
1177
+ bold: import_zod11.z.string(),
1178
+ italics: import_zod11.z.string(),
1179
+ bolditalics: import_zod11.z.string()
1120
1180
  });
1121
- var CertificateConfig = import_zod10.z.object({
1122
- id: import_zod10.z.string(),
1123
- event: import_zod10.z.string(),
1181
+ var CertificateConfig = import_zod11.z.object({
1182
+ id: import_zod11.z.string(),
1183
+ event: import_zod11.z.string(),
1124
1184
  label: TranslationConfig,
1125
- isDefault: import_zod10.z.boolean(),
1126
- fee: import_zod10.z.object({
1127
- onTime: import_zod10.z.number(),
1128
- late: import_zod10.z.number(),
1129
- delayed: import_zod10.z.number()
1185
+ isDefault: import_zod11.z.boolean(),
1186
+ fee: import_zod11.z.object({
1187
+ onTime: import_zod11.z.number(),
1188
+ late: import_zod11.z.number(),
1189
+ delayed: import_zod11.z.number()
1130
1190
  }),
1131
- svgUrl: import_zod10.z.string(),
1132
- fonts: import_zod10.z.record(FontFamily).optional()
1191
+ svgUrl: import_zod11.z.string(),
1192
+ fonts: import_zod11.z.record(FontFamily).optional()
1133
1193
  });
1134
1194
  var CertificateTemplateConfig = CertificateConfig.extend({
1135
- hash: import_zod10.z.string().optional(),
1136
- svg: import_zod10.z.string()
1195
+ hash: import_zod11.z.string().optional(),
1196
+ svg: import_zod11.z.string()
1137
1197
  });
1138
1198
 
1139
1199
  // ../commons/src/events/offline/LanguageConfig.ts
1140
- var import_zod11 = require("zod");
1141
- var LanguageConfig = import_zod11.z.object({
1142
- lang: import_zod11.z.string(),
1200
+ var import_zod12 = require("zod");
1201
+ var LanguageConfig = import_zod12.z.object({
1202
+ lang: import_zod12.z.string(),
1143
1203
  /**
1144
1204
  * client.csv contents
1145
1205
  */
1146
- messages: import_zod11.z.record(import_zod11.z.string())
1206
+ messages: import_zod12.z.record(import_zod12.z.string())
1147
1207
  });
1148
1208
 
1149
1209
  // ../commons/src/events/EventConfig.ts
1150
- var import_zod18 = require("zod");
1210
+ var import_zod21 = require("zod");
1151
1211
 
1152
1212
  // ../commons/src/events/DeduplicationConfig.ts
1153
- var import_zod12 = require("zod");
1154
- var import_zod_openapi6 = require("zod-openapi");
1155
- (0, import_zod_openapi6.extendZodWithOpenApi)(import_zod12.z);
1156
- var FieldReference2 = import_zod12.z.string();
1157
- var Matcher = import_zod12.z.object({
1158
- fieldId: import_zod12.z.string(),
1159
- options: import_zod12.z.object({
1160
- boost: import_zod12.z.number().optional()
1213
+ var import_zod13 = require("zod");
1214
+ var import_zod_openapi7 = require("zod-openapi");
1215
+ (0, import_zod_openapi7.extendZodWithOpenApi)(import_zod13.z);
1216
+ var FieldReference2 = import_zod13.z.string();
1217
+ var Matcher = import_zod13.z.object({
1218
+ fieldId: import_zod13.z.string(),
1219
+ options: import_zod13.z.object({
1220
+ boost: import_zod13.z.number().optional()
1161
1221
  }).optional().default({})
1162
1222
  });
1163
1223
  var FuzzyMatcher = Matcher.extend({
1164
- type: import_zod12.z.literal("fuzzy"),
1165
- options: import_zod12.z.object({
1224
+ type: import_zod13.z.literal("fuzzy"),
1225
+ options: import_zod13.z.object({
1166
1226
  /**
1167
1227
  * Names of length 3 or less characters = 0 edits allowed
1168
1228
  * Names of length 4 - 6 characters = 1 edit allowed
1169
1229
  * Names of length >7 characters = 2 edits allowed
1170
1230
  */
1171
- fuzziness: import_zod12.z.union([import_zod12.z.string(), import_zod12.z.number()]).optional().default("AUTO:4,7"),
1172
- boost: import_zod12.z.number().optional().default(1)
1231
+ fuzziness: import_zod13.z.union([import_zod13.z.string(), import_zod13.z.number()]).optional().default("AUTO:4,7"),
1232
+ boost: import_zod13.z.number().optional().default(1)
1173
1233
  }).optional().default({})
1174
1234
  });
1175
1235
  var StrictMatcher = Matcher.extend({
1176
- type: import_zod12.z.literal("strict"),
1177
- options: import_zod12.z.object({
1178
- boost: import_zod12.z.number().optional().default(1)
1236
+ type: import_zod13.z.literal("strict"),
1237
+ options: import_zod13.z.object({
1238
+ boost: import_zod13.z.number().optional().default(1)
1179
1239
  }).optional().default({})
1180
1240
  });
1181
1241
  var DateRangeMatcher = Matcher.extend({
1182
- type: import_zod12.z.literal("dateRange"),
1183
- options: import_zod12.z.object({
1184
- days: import_zod12.z.number(),
1242
+ type: import_zod13.z.literal("dateRange"),
1243
+ options: import_zod13.z.object({
1244
+ days: import_zod13.z.number(),
1185
1245
  origin: FieldReference2,
1186
- boost: import_zod12.z.number().optional().default(1)
1246
+ boost: import_zod13.z.number().optional().default(1)
1187
1247
  })
1188
1248
  });
1189
1249
  var DateDistanceMatcher = Matcher.extend({
1190
- type: import_zod12.z.literal("dateDistance"),
1191
- options: import_zod12.z.object({
1192
- days: import_zod12.z.number(),
1250
+ type: import_zod13.z.literal("dateDistance"),
1251
+ options: import_zod13.z.object({
1252
+ days: import_zod13.z.number(),
1193
1253
  origin: FieldReference2,
1194
- boost: import_zod12.z.number().optional().default(1)
1254
+ boost: import_zod13.z.number().optional().default(1)
1195
1255
  })
1196
1256
  });
1197
- var And = import_zod12.z.object({
1198
- type: import_zod12.z.literal("and"),
1257
+ var And = import_zod13.z.object({
1258
+ type: import_zod13.z.literal("and"),
1199
1259
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
1200
- clauses: import_zod12.z.lazy(() => Clause.array())
1260
+ clauses: import_zod13.z.lazy(() => Clause.array())
1201
1261
  });
1202
- var Or = import_zod12.z.object({
1203
- type: import_zod12.z.literal("or"),
1262
+ var Or = import_zod13.z.object({
1263
+ type: import_zod13.z.literal("or"),
1204
1264
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
1205
- clauses: import_zod12.z.lazy(() => Clause.array())
1265
+ clauses: import_zod13.z.lazy(() => Clause.array())
1206
1266
  });
1207
- var Clause = import_zod12.z.lazy(
1208
- () => import_zod12.z.discriminatedUnion("type", [
1267
+ var Clause = import_zod13.z.lazy(
1268
+ () => import_zod13.z.discriminatedUnion("type", [
1209
1269
  And,
1210
1270
  Or,
1211
1271
  FuzzyMatcher,
@@ -1216,43 +1276,43 @@ var Clause = import_zod12.z.lazy(
1216
1276
  ).openapi({
1217
1277
  ref: "Clause"
1218
1278
  });
1219
- var DeduplicationConfig = import_zod12.z.object({
1220
- id: import_zod12.z.string(),
1279
+ var DeduplicationConfig = import_zod13.z.object({
1280
+ id: import_zod13.z.string(),
1221
1281
  label: TranslationConfig,
1222
1282
  query: Clause
1223
1283
  });
1224
1284
 
1225
1285
  // ../commons/src/events/SummaryConfig.ts
1226
- var import_zod13 = require("zod");
1227
- var BaseField2 = import_zod13.z.object({
1286
+ var import_zod14 = require("zod");
1287
+ var BaseField2 = import_zod14.z.object({
1228
1288
  emptyValueMessage: TranslationConfig.optional(),
1229
- conditionals: import_zod13.z.array(ShowConditional).default([]).optional()
1289
+ conditionals: import_zod14.z.array(ShowConditional).default([]).optional()
1230
1290
  });
1231
1291
  var ReferenceField = BaseField2.extend({
1232
- fieldId: import_zod13.z.string(),
1292
+ fieldId: import_zod14.z.string(),
1233
1293
  label: TranslationConfig.optional().describe(
1234
1294
  "By default, the configured field's label is used. This can be overridden by providing a custom label."
1235
1295
  )
1236
1296
  }).describe("Field directly referencing event data with field id");
1237
1297
  var Field = BaseField2.extend({
1238
- id: import_zod13.z.string().describe("Id of summary field"),
1298
+ id: import_zod14.z.string().describe("Id of summary field"),
1239
1299
  value: TranslationConfig.describe(
1240
1300
  "Summary field value. Can utilise values defined in configuration and EventMetadata"
1241
1301
  ),
1242
1302
  label: TranslationConfig
1243
1303
  }).describe("Custom configured field");
1244
- var SummaryConfig = import_zod13.z.object({
1245
- fields: import_zod13.z.array(import_zod13.z.union([Field, ReferenceField])).describe("Fields rendered in summary view.")
1304
+ var SummaryConfig = import_zod14.z.object({
1305
+ fields: import_zod14.z.array(import_zod14.z.union([Field, ReferenceField])).describe("Fields rendered in summary view.")
1246
1306
  }).describe("Configuration for summary in event.");
1247
1307
 
1248
1308
  // ../commons/src/events/AdvancedSearchConfig.ts
1249
- var import_zod14 = require("zod");
1250
- var MatchType = import_zod14.z.enum(["fuzzy", "exact", "range"]);
1251
- var BaseField3 = import_zod14.z.object({
1252
- config: import_zod14.z.object({
1309
+ var import_zod15 = require("zod");
1310
+ var MatchType = import_zod15.z.enum(["fuzzy", "exact", "range"]);
1311
+ var BaseField3 = import_zod15.z.object({
1312
+ config: import_zod15.z.object({
1253
1313
  type: MatchType.describe("Determines the type of field")
1254
1314
  }),
1255
- options: import_zod14.z.array(SelectOption).optional(),
1315
+ options: import_zod15.z.array(SelectOption).optional(),
1256
1316
  searchCriteriaLabelPrefix: TranslationConfig.optional().describe(
1257
1317
  `
1258
1318
  This property determines whether to add a prefix (such as "Child" or "Applicant") before the field label
@@ -1273,7 +1333,7 @@ var BaseField3 = import_zod14.z.object({
1273
1333
  in the country-config > event.advancedSearch configuration. For example: field("child.dob", { searchCriteriaLabelPrefix: TranslationConfig }).
1274
1334
  `
1275
1335
  ),
1276
- conditionals: import_zod14.z.array(FieldConditional).default([]).optional().describe(
1336
+ conditionals: import_zod15.z.array(FieldConditional).default([]).optional().describe(
1277
1337
  `
1278
1338
  In advanced search, we sometimes need to override the default field visibility conditionals.
1279
1339
 
@@ -1286,162 +1346,616 @@ var BaseField3 = import_zod14.z.object({
1286
1346
  'conditionals' to an empty array ('[]') in the search config. This ensures they
1287
1347
  are always rendered in the advanced search form.
1288
1348
  `
1349
+ ),
1350
+ validations: import_zod15.z.array(ValidationConfig).default([]).optional().describe(
1351
+ `In advanced search, we sometimes need to override the default field validations.`
1289
1352
  )
1290
1353
  });
1291
- var SearchQueryParams = import_zod14.z.object({
1292
- eventType: import_zod14.z.string().optional().describe(
1354
+ var SearchQueryParams = import_zod15.z.object({
1355
+ eventType: import_zod15.z.string().optional().describe(
1293
1356
  "Defines type of event so that when redirecting to Advanced Search page, appropriate tab can be selected"
1294
1357
  )
1295
1358
  }).catchall(FieldValue);
1296
1359
  var FieldConfigSchema = BaseField3.extend({
1297
- fieldId: import_zod14.z.string(),
1298
- fieldType: import_zod14.z.literal("field")
1360
+ fieldId: import_zod15.z.string(),
1361
+ fieldType: import_zod15.z.literal("field"),
1362
+ alternateFieldIds: import_zod15.z.array(import_zod15.z.string()).optional().describe(
1363
+ `Sometimes there might be need to search a value against multiple field of same FormField type. For example
1364
+ search Country, Province, District against child.address.private and child.address.other. In such case, we
1365
+ add a one field as fieldId, and accomodate others in alternateFieldIds`
1366
+ ),
1367
+ excludeInSearchQuery: import_zod15.z.boolean().default(false).optional().describe(`Sometimes there will be search fields which are used to
1368
+ conditionally display another search field, but its not needed in search query. For example, child.placeOfBirth
1369
+ is select field, which has 3 options, FACILITY, PRIVATE_HOME, OTHER. Upon selecting any of the option, pops up another field
1370
+ related to the selected option, whose value is required in the search query. But child.placeOfBirth itself is not needed in the query.
1371
+ In such case, populate this field (excludeInSearchQuery) with boolean true`)
1299
1372
  });
1300
- var EventFieldId = import_zod14.z.enum([
1373
+ var EventFieldId = import_zod15.z.enum([
1301
1374
  "trackingId",
1302
1375
  "status",
1303
- "legalStatus.REGISTERED.createdAt",
1304
- "legalStatus.REGISTERED.createdAtLocation",
1376
+ "legalStatuses.REGISTERED.acceptedAt",
1377
+ "legalStatuses.REGISTERED.createdAtLocation",
1305
1378
  "updatedAt"
1306
1379
  ]);
1307
1380
  var EventFieldConfigSchema = BaseField3.extend({
1308
1381
  fieldId: EventFieldId,
1309
- fieldType: import_zod14.z.literal("event")
1382
+ fieldType: import_zod15.z.literal("event")
1310
1383
  });
1311
- var SearchField = import_zod14.z.discriminatedUnion("fieldType", [
1384
+ var SearchField = import_zod15.z.discriminatedUnion("fieldType", [
1312
1385
  FieldConfigSchema,
1313
1386
  EventFieldConfigSchema
1314
1387
  ]);
1315
- var AdvancedSearchConfig = import_zod14.z.object({
1388
+ var AdvancedSearchConfig = import_zod15.z.object({
1316
1389
  title: TranslationConfig.describe("Advanced search tab title"),
1317
- fields: import_zod14.z.array(SearchField).describe("Advanced search fields.")
1390
+ fields: import_zod15.z.array(SearchField).describe("Advanced search fields.")
1318
1391
  });
1319
1392
 
1320
1393
  // ../commons/src/events/utils.ts
1321
1394
  var import_lodash = require("lodash");
1322
1395
 
1323
1396
  // ../commons/src/events/ActionDocument.ts
1397
+ var import_zod19 = require("zod");
1398
+ var import_zod_openapi8 = require("zod-openapi");
1399
+
1400
+ // ../commons/src/uuid.ts
1401
+ var import_uuid = require("uuid");
1324
1402
  var import_zod16 = require("zod");
1325
- var import_zod_openapi7 = require("zod-openapi");
1403
+ var UUID = import_zod16.z.string().uuid().brand("UUID");
1404
+ function getUUID() {
1405
+ return (0, import_uuid.v4)();
1406
+ }
1326
1407
 
1327
1408
  // ../commons/src/events/CreatedAtLocation.ts
1328
- var import_zod15 = require("zod");
1329
- var CreatedAtLocation = import_zod15.z.string().nullish();
1409
+ var CreatedAtLocation = UUID.nullish();
1410
+
1411
+ // ../commons/src/authentication.ts
1412
+ var import_jwt_decode = __toESM(require("jwt-decode"));
1413
+ var import_zod18 = require("zod");
1414
+
1415
+ // ../commons/src/scopes.ts
1416
+ var import_zod17 = require("zod");
1417
+ var SCOPES = {
1418
+ // TODO v1.8 legacy scopes
1419
+ NATLSYSADMIN: "natlsysadmin",
1420
+ BYPASSRATELIMIT: "bypassratelimit",
1421
+ DECLARE: "declare",
1422
+ REGISTER: "register",
1423
+ VALIDATE: "validate",
1424
+ DEMO: "demo",
1425
+ CERTIFY: "certify",
1426
+ PERFORMANCE: "performance",
1427
+ SYSADMIN: "sysadmin",
1428
+ TEAMS: "teams",
1429
+ CONFIG: "config",
1430
+ // systems / integrations
1431
+ WEBHOOK: "webhook",
1432
+ NATIONALID: "nationalId",
1433
+ NOTIFICATION_API: "notification-api",
1434
+ RECORDSEARCH: "recordsearch",
1435
+ /**
1436
+ * @TODO This is a temporary scope to be used for V2 Events custom events declaration
1437
+ */
1438
+ RECORD_DECLARE: "record.declare-birth",
1439
+ // declare
1440
+ RECORD_IMPORT: "record.import",
1441
+ // declare
1442
+ RECORD_DECLARE_BIRTH: "record.declare-birth",
1443
+ RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
1444
+ RECORD_DECLARE_DEATH: "record.declare-death",
1445
+ RECORD_DECLARE_DEATH_MY_JURISDICTION: "record.declare-death:my-jurisdiction",
1446
+ RECORD_DECLARE_MARRIAGE: "record.declare-marriage",
1447
+ RECORD_DECLARE_MARRIAGE_MY_JURISDICTION: "record.declare-marriage:my-jurisdiction",
1448
+ RECORD_SUBMIT_INCOMPLETE: "record.declaration-submit-incomplete",
1449
+ RECORD_SUBMIT_FOR_REVIEW: "record.declaration-submit-for-review",
1450
+ RECORD_UNASSIGN_OTHERS: "record.unassign-others",
1451
+ // validate
1452
+ RECORD_SUBMIT_FOR_APPROVAL: "record.declaration-submit-for-approval",
1453
+ RECORD_SUBMIT_FOR_UPDATES: "record.declaration-submit-for-updates",
1454
+ RECORD_DECLARATION_EDIT: "record.declaration-edit",
1455
+ RECORD_REVIEW_DUPLICATES: "record.review-duplicates",
1456
+ RECORD_DECLARATION_ARCHIVE: "record.declaration-archive",
1457
+ RECORD_DECLARATION_REINSTATE: "record.declaration-reinstate",
1458
+ // register
1459
+ RECORD_REGISTER: "record.register",
1460
+ // certify
1461
+ RECORD_EXPORT_RECORDS: "record.export-records",
1462
+ RECORD_DECLARATION_PRINT: "record.declaration-print",
1463
+ RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS: "record.declaration-print-supporting-documents",
1464
+ RECORD_REGISTRATION_PRINT: "record.registration-print",
1465
+ // v1.8
1466
+ /**
1467
+ * This scope is used to **print and **issue certified copies of a record
1468
+ * after it has been registered. Previously Registrars had this permission.
1469
+ */
1470
+ RECORD_PRINT_ISSUE_CERTIFIED_COPIES: "record.registration-print&issue-certified-copies",
1471
+ RECORD_PRINT_CERTIFIED_COPIES: "record.registration-print-certified-copies",
1472
+ // v1.8
1473
+ RECORD_BULK_PRINT_CERTIFIED_COPIES: "record.registration-bulk-print-certified-copies",
1474
+ // v1.8
1475
+ RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES: "record.registration-verify-certified-copies",
1476
+ // v1.8
1477
+ // correct
1478
+ RECORD_REGISTRATION_REQUEST_CORRECTION: "record.registration-request-correction",
1479
+ RECORD_REGISTRATION_CORRECT: "record.registration-correct",
1480
+ RECORD_REGISTRATION_REQUEST_REVOCATION: "record.registration-request-revocation",
1481
+ // v1.8
1482
+ RECORD_REGISTRATION_REVOKE: "record.registration-revoke",
1483
+ // v1.8
1484
+ RECORD_REGISTRATION_REQUEST_REINSTATEMENT: "record.registration-request-reinstatement",
1485
+ // v1.8
1486
+ RECORD_REGISTRATION_REINSTATE: "record.registration-reinstate",
1487
+ // v1.8
1488
+ RECORD_CONFIRM_REGISTRATION: "record.confirm-registration",
1489
+ RECORD_REJECT_REGISTRATION: "record.reject-registration",
1490
+ // search
1491
+ SEARCH_BIRTH_MY_JURISDICTION: "search.birth:my-jurisdiction",
1492
+ SEARCH_BIRTH: "search.birth",
1493
+ SEARCH_DEATH_MY_JURISDICTION: "search.death:my-jurisdiction",
1494
+ SEARCH_DEATH: "search.death",
1495
+ SEARCH_MARRIAGE_MY_JURISDICTION: "search.marriage:my-jurisdiction",
1496
+ SEARCH_MARRIAGE: "search.marriage",
1497
+ // audit v1.8
1498
+ RECORD_READ: "record.read",
1499
+ RECORD_READ_AUDIT: "record.read-audit",
1500
+ RECORD_READ_COMMENTS: "record.read-comments",
1501
+ RECORD_CREATE_COMMENTS: "record.create-comments",
1502
+ // profile
1503
+ PROFILE_UPDATE: "profile.update",
1504
+ //v1.8
1505
+ PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature",
1506
+ // performance
1507
+ PERFORMANCE_READ: "performance.read",
1508
+ PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards",
1509
+ PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export",
1510
+ // organisation
1511
+ ORGANISATION_READ_LOCATIONS: "organisation.read-locations:all",
1512
+ ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office",
1513
+ ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction",
1514
+ // user
1515
+ USER_READ: "user.read:all",
1516
+ USER_READ_MY_OFFICE: "user.read:my-office",
1517
+ USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction",
1518
+ USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit",
1519
+ //v1.8
1520
+ USER_CREATE: "user.create:all",
1521
+ USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction",
1522
+ USER_UPDATE: "user.update:all",
1523
+ USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction",
1524
+ // config
1525
+ CONFIG_UPDATE_ALL: "config.update:all",
1526
+ // data seeding
1527
+ USER_DATA_SEEDING: "user.data-seeding"
1528
+ };
1529
+ var LegacyScopes = import_zod17.z.union([
1530
+ import_zod17.z.literal(SCOPES.NATLSYSADMIN),
1531
+ import_zod17.z.literal(SCOPES.BYPASSRATELIMIT),
1532
+ import_zod17.z.literal(SCOPES.DECLARE),
1533
+ import_zod17.z.literal(SCOPES.REGISTER),
1534
+ import_zod17.z.literal(SCOPES.VALIDATE),
1535
+ import_zod17.z.literal(SCOPES.DEMO),
1536
+ import_zod17.z.literal(SCOPES.CERTIFY),
1537
+ import_zod17.z.literal(SCOPES.PERFORMANCE),
1538
+ import_zod17.z.literal(SCOPES.SYSADMIN),
1539
+ import_zod17.z.literal(SCOPES.TEAMS),
1540
+ import_zod17.z.literal(SCOPES.CONFIG)
1541
+ ]);
1542
+ var IntegrationScopes = import_zod17.z.union([
1543
+ import_zod17.z.literal(SCOPES.WEBHOOK),
1544
+ import_zod17.z.literal(SCOPES.NATIONALID),
1545
+ import_zod17.z.literal(SCOPES.NOTIFICATION_API),
1546
+ import_zod17.z.literal(SCOPES.RECORDSEARCH)
1547
+ ]);
1548
+ var DeclareScopes = import_zod17.z.union([
1549
+ import_zod17.z.literal(SCOPES.RECORD_DECLARE),
1550
+ import_zod17.z.literal(SCOPES.RECORD_IMPORT),
1551
+ import_zod17.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
1552
+ import_zod17.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
1553
+ import_zod17.z.literal(SCOPES.RECORD_DECLARE_DEATH),
1554
+ import_zod17.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
1555
+ import_zod17.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
1556
+ import_zod17.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
1557
+ import_zod17.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
1558
+ import_zod17.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW)
1559
+ ]);
1560
+ var UnassignScope = import_zod17.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS);
1561
+ var ValidateScopes = import_zod17.z.union([
1562
+ import_zod17.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
1563
+ import_zod17.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
1564
+ import_zod17.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
1565
+ import_zod17.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
1566
+ import_zod17.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
1567
+ import_zod17.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE)
1568
+ ]);
1569
+ var RegisterScope = import_zod17.z.literal(SCOPES.RECORD_REGISTER);
1570
+ var CertifyScopes = import_zod17.z.union([
1571
+ import_zod17.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
1572
+ import_zod17.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
1573
+ import_zod17.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
1574
+ import_zod17.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
1575
+ import_zod17.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
1576
+ import_zod17.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
1577
+ import_zod17.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
1578
+ import_zod17.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES)
1579
+ ]);
1580
+ var CorrectionScopes = import_zod17.z.union([
1581
+ import_zod17.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
1582
+ import_zod17.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
1583
+ import_zod17.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
1584
+ import_zod17.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
1585
+ import_zod17.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
1586
+ import_zod17.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
1587
+ import_zod17.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
1588
+ import_zod17.z.literal(SCOPES.RECORD_REJECT_REGISTRATION)
1589
+ ]);
1590
+ var SearchScopes = import_zod17.z.union([
1591
+ import_zod17.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
1592
+ import_zod17.z.literal(SCOPES.SEARCH_BIRTH),
1593
+ import_zod17.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
1594
+ import_zod17.z.literal(SCOPES.SEARCH_DEATH),
1595
+ import_zod17.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
1596
+ import_zod17.z.literal(SCOPES.SEARCH_MARRIAGE)
1597
+ ]);
1598
+ var AuditScopes = import_zod17.z.union([
1599
+ import_zod17.z.literal(SCOPES.RECORD_READ),
1600
+ import_zod17.z.literal(SCOPES.RECORD_READ_AUDIT),
1601
+ import_zod17.z.literal(SCOPES.RECORD_READ_COMMENTS),
1602
+ import_zod17.z.literal(SCOPES.RECORD_CREATE_COMMENTS)
1603
+ ]);
1604
+ var ProfileScopes = import_zod17.z.union([
1605
+ import_zod17.z.literal(SCOPES.PROFILE_UPDATE),
1606
+ import_zod17.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE)
1607
+ ]);
1608
+ var PerformanceScopes = import_zod17.z.union([
1609
+ import_zod17.z.literal(SCOPES.PERFORMANCE_READ),
1610
+ import_zod17.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
1611
+ import_zod17.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS)
1612
+ ]);
1613
+ var OrganisationScopes = import_zod17.z.union([
1614
+ import_zod17.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
1615
+ import_zod17.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
1616
+ import_zod17.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION)
1617
+ ]);
1618
+ var UserScopes = import_zod17.z.union([
1619
+ import_zod17.z.literal(SCOPES.USER_READ),
1620
+ import_zod17.z.literal(SCOPES.USER_READ_MY_OFFICE),
1621
+ import_zod17.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
1622
+ import_zod17.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
1623
+ import_zod17.z.literal(SCOPES.USER_CREATE),
1624
+ import_zod17.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
1625
+ import_zod17.z.literal(SCOPES.USER_UPDATE),
1626
+ import_zod17.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION)
1627
+ ]);
1628
+ var ConfigScope = import_zod17.z.literal(SCOPES.CONFIG_UPDATE_ALL);
1629
+ var DataSeedingScope = import_zod17.z.literal(SCOPES.USER_DATA_SEEDING);
1630
+ var LiteralScopes = import_zod17.z.union([
1631
+ LegacyScopes,
1632
+ IntegrationScopes,
1633
+ UnassignScope,
1634
+ DeclareScopes,
1635
+ ValidateScopes,
1636
+ RegisterScope,
1637
+ CertifyScopes,
1638
+ CorrectionScopes,
1639
+ SearchScopes,
1640
+ AuditScopes,
1641
+ ProfileScopes,
1642
+ PerformanceScopes,
1643
+ OrganisationScopes,
1644
+ UserScopes,
1645
+ ConfigScope,
1646
+ DataSeedingScope
1647
+ ]);
1648
+ var rawConfigurableScopeRegex = /^([a-zA-Z\.]+)\[((?:\w+=[\w.-]+(?:\|[\w.-]+)*)(?:,[\w]+=[\w.-]+(?:\|[\w.-]+)*)*)\]$/;
1649
+ var rawConfigurableScope = import_zod17.z.string().regex(rawConfigurableScopeRegex);
1650
+ var CreateUserScope = import_zod17.z.object({
1651
+ type: import_zod17.z.literal("user.create"),
1652
+ options: import_zod17.z.object({
1653
+ role: import_zod17.z.array(import_zod17.z.string())
1654
+ })
1655
+ });
1656
+ var EditUserScope = import_zod17.z.object({
1657
+ type: import_zod17.z.literal("user.edit"),
1658
+ options: import_zod17.z.object({
1659
+ role: import_zod17.z.array(import_zod17.z.string())
1660
+ })
1661
+ });
1662
+ var WorkqueueScope = import_zod17.z.object({
1663
+ type: import_zod17.z.literal("workqueue"),
1664
+ options: import_zod17.z.object({
1665
+ id: import_zod17.z.array(import_zod17.z.string())
1666
+ })
1667
+ });
1668
+ var NotifyRecordScope = import_zod17.z.object({
1669
+ type: import_zod17.z.literal("record.notify"),
1670
+ options: import_zod17.z.object({
1671
+ event: import_zod17.z.array(import_zod17.z.string())
1672
+ })
1673
+ });
1674
+ var SearchScope = import_zod17.z.object({
1675
+ type: import_zod17.z.literal("search"),
1676
+ options: import_zod17.z.object({
1677
+ event: import_zod17.z.array(import_zod17.z.string()).length(1),
1678
+ access: import_zod17.z.array(import_zod17.z.enum(["my-jurisdiction", "all"])).length(1)
1679
+ })
1680
+ });
1681
+ var ConfigurableRawScopes = import_zod17.z.discriminatedUnion("type", [
1682
+ SearchScope,
1683
+ CreateUserScope,
1684
+ EditUserScope,
1685
+ WorkqueueScope,
1686
+ NotifyRecordScope
1687
+ ]);
1688
+ var scopes = Object.values(SCOPES);
1689
+ var ActionScopes = import_zod17.z.union([
1690
+ DeclareScopes,
1691
+ ValidateScopes,
1692
+ RegisterScope,
1693
+ CertifyScopes,
1694
+ CorrectionScopes
1695
+ ]);
1696
+
1697
+ // ../commons/src/authentication.ts
1698
+ var DEFAULT_ROLES_DEFINITION = [
1699
+ {
1700
+ id: "FIELD_AGENT",
1701
+ label: {
1702
+ defaultMessage: "Field Agent",
1703
+ description: "Name for user role Field Agent",
1704
+ id: "userRole.fieldAgent"
1705
+ },
1706
+ scopes: [
1707
+ // new scopes
1708
+ SCOPES.RECORD_DECLARE_BIRTH,
1709
+ SCOPES.RECORD_DECLARE_DEATH,
1710
+ SCOPES.RECORD_DECLARE_MARRIAGE,
1711
+ SCOPES.RECORD_SUBMIT_INCOMPLETE,
1712
+ SCOPES.RECORD_SUBMIT_FOR_REVIEW,
1713
+ SCOPES.SEARCH_BIRTH,
1714
+ SCOPES.SEARCH_DEATH,
1715
+ SCOPES.SEARCH_MARRIAGE
1716
+ ]
1717
+ },
1718
+ {
1719
+ id: "REGISTRATION_AGENT",
1720
+ label: {
1721
+ defaultMessage: "Registration Agent",
1722
+ description: "Name for user role Registration Agent",
1723
+ id: "userRole.registrationAgent"
1724
+ },
1725
+ scopes: [
1726
+ SCOPES.PERFORMANCE,
1727
+ SCOPES.CERTIFY,
1728
+ SCOPES.RECORD_DECLARE_BIRTH,
1729
+ SCOPES.RECORD_DECLARE_DEATH,
1730
+ SCOPES.RECORD_DECLARE_MARRIAGE,
1731
+ SCOPES.RECORD_SUBMIT_FOR_APPROVAL,
1732
+ SCOPES.RECORD_SUBMIT_FOR_UPDATES,
1733
+ SCOPES.RECORD_DECLARATION_ARCHIVE,
1734
+ SCOPES.RECORD_DECLARATION_REINSTATE,
1735
+ SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION,
1736
+ SCOPES.RECORD_REGISTRATION_PRINT,
1737
+ SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS,
1738
+ SCOPES.RECORD_EXPORT_RECORDS,
1739
+ SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES,
1740
+ SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES,
1741
+ SCOPES.RECORD_CREATE_COMMENTS,
1742
+ SCOPES.PERFORMANCE_READ,
1743
+ SCOPES.PERFORMANCE_READ_DASHBOARDS,
1744
+ SCOPES.ORGANISATION_READ_LOCATIONS,
1745
+ SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE,
1746
+ SCOPES.SEARCH_BIRTH,
1747
+ SCOPES.SEARCH_DEATH,
1748
+ SCOPES.SEARCH_MARRIAGE
1749
+ ]
1750
+ },
1751
+ {
1752
+ id: "LOCAL_REGISTRAR",
1753
+ label: {
1754
+ defaultMessage: "Local Registrar",
1755
+ description: "Name for user role Local Registrar",
1756
+ id: "userRole.localRegistrar"
1757
+ },
1758
+ scopes: [
1759
+ SCOPES.PERFORMANCE,
1760
+ SCOPES.CERTIFY,
1761
+ SCOPES.RECORD_DECLARE_BIRTH,
1762
+ SCOPES.RECORD_DECLARE_DEATH,
1763
+ SCOPES.RECORD_DECLARE_MARRIAGE,
1764
+ SCOPES.RECORD_SUBMIT_FOR_UPDATES,
1765
+ SCOPES.RECORD_REVIEW_DUPLICATES,
1766
+ SCOPES.RECORD_DECLARATION_ARCHIVE,
1767
+ SCOPES.RECORD_DECLARATION_REINSTATE,
1768
+ SCOPES.RECORD_REGISTER,
1769
+ SCOPES.RECORD_REGISTRATION_CORRECT,
1770
+ SCOPES.RECORD_REGISTRATION_PRINT,
1771
+ SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS,
1772
+ SCOPES.RECORD_EXPORT_RECORDS,
1773
+ SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES,
1774
+ SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES,
1775
+ SCOPES.RECORD_CREATE_COMMENTS,
1776
+ SCOPES.PERFORMANCE_READ,
1777
+ SCOPES.PERFORMANCE_READ_DASHBOARDS,
1778
+ SCOPES.ORGANISATION_READ_LOCATIONS,
1779
+ SCOPES.PROFILE_ELECTRONIC_SIGNATURE,
1780
+ SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE,
1781
+ SCOPES.SEARCH_BIRTH,
1782
+ SCOPES.SEARCH_DEATH,
1783
+ SCOPES.SEARCH_MARRIAGE
1784
+ ]
1785
+ },
1786
+ {
1787
+ id: "LOCAL_SYSTEM_ADMIN",
1788
+ label: {
1789
+ defaultMessage: "Local System Admin",
1790
+ description: "Name for user role Local System Admin",
1791
+ id: "userRole.localSystemAdmin"
1792
+ },
1793
+ scopes: [
1794
+ SCOPES.SYSADMIN,
1795
+ SCOPES.USER_READ_MY_OFFICE,
1796
+ SCOPES.USER_CREATE_MY_JURISDICTION,
1797
+ SCOPES.USER_UPDATE_MY_JURISDICTION,
1798
+ SCOPES.ORGANISATION_READ_LOCATIONS,
1799
+ SCOPES.PERFORMANCE_READ,
1800
+ SCOPES.PERFORMANCE_READ_DASHBOARDS,
1801
+ SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS
1802
+ // 'organisation.read-users' ?
1803
+ ]
1804
+ },
1805
+ {
1806
+ id: "NATIONAL_SYSTEM_ADMIN",
1807
+ label: {
1808
+ defaultMessage: "National System Admin",
1809
+ description: "Name for user role National System Admin",
1810
+ id: "userRole.nationalSystemAdmin"
1811
+ },
1812
+ scopes: [
1813
+ SCOPES.SYSADMIN,
1814
+ SCOPES.NATLSYSADMIN,
1815
+ SCOPES.USER_CREATE,
1816
+ SCOPES.USER_READ,
1817
+ SCOPES.USER_UPDATE,
1818
+ SCOPES.ORGANISATION_READ_LOCATIONS,
1819
+ SCOPES.PERFORMANCE_READ,
1820
+ SCOPES.PERFORMANCE_READ_DASHBOARDS,
1821
+ SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS
1822
+ // 'organisation.read-users' ?
1823
+ ]
1824
+ },
1825
+ {
1826
+ id: "PERFORMANCE_MANAGER",
1827
+ label: {
1828
+ defaultMessage: "Performance Manager",
1829
+ description: "Name for user role Performance Manager",
1830
+ id: "userRole.performanceManager"
1831
+ },
1832
+ scopes: [
1833
+ SCOPES.PERFORMANCE,
1834
+ SCOPES.PERFORMANCE_READ,
1835
+ SCOPES.PERFORMANCE_READ_DASHBOARDS,
1836
+ SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS
1837
+ ]
1838
+ }
1839
+ ];
1840
+ var TokenUserType = import_zod18.z.enum(["user", "system"]);
1841
+ var TokenWithBearer = import_zod18.z.string().regex(/^Bearer\s/);
1330
1842
 
1331
1843
  // ../commons/src/events/ActionDocument.ts
1332
- (0, import_zod_openapi7.extendZodWithOpenApi)(import_zod16.z);
1333
- var ActionUpdate = import_zod16.z.record(import_zod16.z.string(), FieldUpdateValue);
1334
- var EventState = import_zod16.z.record(import_zod16.z.string(), FieldValue);
1844
+ (0, import_zod_openapi8.extendZodWithOpenApi)(import_zod19.z);
1845
+ var ActionUpdate = import_zod19.z.record(import_zod19.z.string(), FieldUpdateValue);
1846
+ var EventState = import_zod19.z.record(import_zod19.z.string(), FieldValue);
1335
1847
  var ActionStatus = {
1336
1848
  Requested: "Requested",
1337
1849
  Accepted: "Accepted",
1338
1850
  Rejected: "Rejected"
1339
1851
  };
1340
- var ActionBase = import_zod16.z.object({
1341
- id: import_zod16.z.string(),
1342
- transactionId: import_zod16.z.string(),
1343
- createdAt: import_zod16.z.string().datetime(),
1344
- createdBy: import_zod16.z.string(),
1345
- createdByRole: import_zod16.z.string(),
1346
- createdBySignature: import_zod16.z.string().nullish().describe("Reference to signature of the user who created the action"),
1852
+ var ActionBase = import_zod19.z.object({
1853
+ id: UUID,
1854
+ transactionId: import_zod19.z.string(),
1855
+ createdByUserType: TokenUserType,
1856
+ createdAt: import_zod19.z.string().datetime(),
1857
+ createdBy: import_zod19.z.string(),
1858
+ createdByRole: import_zod19.z.string(),
1859
+ createdBySignature: import_zod19.z.string().nullish().describe("Reference to signature of the user who created the action"),
1347
1860
  createdAtLocation: CreatedAtLocation,
1348
1861
  declaration: ActionUpdate,
1349
- annotation: ActionUpdate.optional(),
1350
- status: import_zod16.z.enum([
1862
+ annotation: ActionUpdate.optional().nullable(),
1863
+ status: import_zod19.z.enum([
1351
1864
  ActionStatus.Requested,
1352
1865
  ActionStatus.Accepted,
1353
1866
  ActionStatus.Rejected
1354
1867
  ]),
1355
1868
  // If the action is an asynchronous confirmation for another action, we will save the original action id here.
1356
- originalActionId: import_zod16.z.string().optional()
1869
+ originalActionId: UUID.optional().nullable().describe(
1870
+ "Reference to the original action that was asynchronously rejected or accepted by 3rd party integration."
1871
+ )
1357
1872
  });
1358
1873
  var AssignedAction = ActionBase.merge(
1359
- import_zod16.z.object({
1360
- type: import_zod16.z.literal(ActionType.ASSIGN),
1361
- assignedTo: import_zod16.z.string()
1874
+ import_zod19.z.object({
1875
+ type: import_zod19.z.literal(ActionType.ASSIGN),
1876
+ assignedTo: import_zod19.z.string()
1362
1877
  })
1363
1878
  );
1364
1879
  var UnassignedAction = ActionBase.merge(
1365
- import_zod16.z.object({
1366
- type: import_zod16.z.literal(ActionType.UNASSIGN),
1367
- assignedTo: import_zod16.z.literal(null)
1880
+ import_zod19.z.object({
1881
+ type: import_zod19.z.literal(ActionType.UNASSIGN)
1368
1882
  })
1369
1883
  );
1370
1884
  var RegisterAction = ActionBase.merge(
1371
- import_zod16.z.object({
1372
- type: import_zod16.z.literal(ActionType.REGISTER),
1373
- registrationNumber: import_zod16.z.string().optional()
1885
+ import_zod19.z.object({
1886
+ type: import_zod19.z.literal(ActionType.REGISTER),
1887
+ registrationNumber: import_zod19.z.string().optional()
1374
1888
  })
1375
1889
  );
1376
1890
  var DeclareAction = ActionBase.merge(
1377
- import_zod16.z.object({
1378
- type: import_zod16.z.literal(ActionType.DECLARE)
1891
+ import_zod19.z.object({
1892
+ type: import_zod19.z.literal(ActionType.DECLARE)
1379
1893
  })
1380
1894
  );
1381
1895
  var ValidateAction = ActionBase.merge(
1382
- import_zod16.z.object({
1383
- type: import_zod16.z.literal(ActionType.VALIDATE)
1896
+ import_zod19.z.object({
1897
+ type: import_zod19.z.literal(ActionType.VALIDATE)
1384
1898
  })
1385
1899
  );
1386
- var RejectionReason = import_zod16.z.object({
1387
- message: import_zod16.z.string().min(1, { message: "Message cannot be empty" }).describe("Message describing reason for rejection or archiving"),
1388
- isDuplicate: import_zod16.z.boolean().optional().describe("If a declaration is duplicated")
1900
+ var RejectionReason = import_zod19.z.object({
1901
+ message: import_zod19.z.string().min(1, { message: "Message cannot be empty" }).describe("Message describing reason for rejection or archiving"),
1902
+ isDuplicate: import_zod19.z.boolean().optional().describe("If a declaration is duplicated")
1389
1903
  });
1390
1904
  var RejectAction = ActionBase.merge(
1391
- import_zod16.z.object({
1392
- type: import_zod16.z.literal(ActionType.REJECT),
1905
+ import_zod19.z.object({
1906
+ type: import_zod19.z.literal(ActionType.REJECT),
1393
1907
  reason: RejectionReason
1394
1908
  })
1395
1909
  );
1396
1910
  var MarkAsDuplicateAction = ActionBase.merge(
1397
- import_zod16.z.object({
1398
- type: import_zod16.z.literal(ActionType.MARKED_AS_DUPLICATE)
1911
+ import_zod19.z.object({
1912
+ type: import_zod19.z.literal(ActionType.MARKED_AS_DUPLICATE)
1399
1913
  })
1400
1914
  );
1401
1915
  var ArchiveAction = ActionBase.merge(
1402
- import_zod16.z.object({
1403
- type: import_zod16.z.literal(ActionType.ARCHIVE),
1916
+ import_zod19.z.object({
1917
+ type: import_zod19.z.literal(ActionType.ARCHIVE),
1404
1918
  reason: RejectionReason
1405
1919
  })
1406
1920
  );
1407
1921
  var CreatedAction = ActionBase.merge(
1408
- import_zod16.z.object({
1409
- type: import_zod16.z.literal(ActionType.CREATE)
1922
+ import_zod19.z.object({
1923
+ type: import_zod19.z.literal(ActionType.CREATE)
1410
1924
  })
1411
1925
  );
1412
1926
  var NotifiedAction = ActionBase.merge(
1413
- import_zod16.z.object({
1414
- type: import_zod16.z.literal(ActionType.NOTIFY)
1927
+ import_zod19.z.object({
1928
+ type: import_zod19.z.literal(ActionType.NOTIFY)
1415
1929
  })
1416
1930
  );
1417
1931
  var PrintCertificateAction = ActionBase.merge(
1418
- import_zod16.z.object({
1419
- type: import_zod16.z.literal(ActionType.PRINT_CERTIFICATE)
1932
+ import_zod19.z.object({
1933
+ type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE)
1420
1934
  })
1421
1935
  );
1422
1936
  var RequestedCorrectionAction = ActionBase.merge(
1423
- import_zod16.z.object({
1424
- type: import_zod16.z.literal(ActionType.REQUEST_CORRECTION)
1937
+ import_zod19.z.object({
1938
+ type: import_zod19.z.literal(ActionType.REQUEST_CORRECTION)
1425
1939
  })
1426
1940
  );
1427
1941
  var ApprovedCorrectionAction = ActionBase.merge(
1428
- import_zod16.z.object({
1429
- type: import_zod16.z.literal(ActionType.APPROVE_CORRECTION),
1430
- requestId: import_zod16.z.string()
1942
+ import_zod19.z.object({
1943
+ type: import_zod19.z.literal(ActionType.APPROVE_CORRECTION),
1944
+ requestId: import_zod19.z.string()
1431
1945
  })
1432
1946
  );
1433
1947
  var RejectedCorrectionAction = ActionBase.merge(
1434
- import_zod16.z.object({
1435
- type: import_zod16.z.literal(ActionType.REJECT_CORRECTION),
1436
- requestId: import_zod16.z.string()
1948
+ import_zod19.z.object({
1949
+ type: import_zod19.z.literal(ActionType.REJECT_CORRECTION),
1950
+ requestId: import_zod19.z.string()
1437
1951
  })
1438
1952
  );
1439
1953
  var ReadAction = ActionBase.merge(
1440
- import_zod16.z.object({
1441
- type: import_zod16.z.literal(ActionType.READ)
1954
+ import_zod19.z.object({
1955
+ type: import_zod19.z.literal(ActionType.READ)
1442
1956
  })
1443
1957
  );
1444
- var ActionDocument = import_zod16.z.discriminatedUnion("type", [
1958
+ var ActionDocument = import_zod19.z.discriminatedUnion("type", [
1445
1959
  CreatedAction.openapi({ ref: "CreatedAction" }),
1446
1960
  ValidateAction.openapi({ ref: "ValidateAction" }),
1447
1961
  RejectAction.openapi({ ref: "RejectAction" }),
@@ -1464,20 +1978,20 @@ var AsyncRejectActionDocument = ActionBase.omit({
1464
1978
  declaration: true,
1465
1979
  annotation: true
1466
1980
  }).merge(
1467
- import_zod16.z.object({
1468
- type: import_zod16.z.enum(ConfirmableActions),
1469
- status: import_zod16.z.literal(ActionStatus.Rejected)
1981
+ import_zod19.z.object({
1982
+ type: import_zod19.z.enum(ConfirmableActions),
1983
+ status: import_zod19.z.literal(ActionStatus.Rejected)
1470
1984
  })
1471
1985
  );
1472
- var Action = import_zod16.z.union([ActionDocument, AsyncRejectActionDocument]);
1473
- var ResolvedUser = import_zod16.z.object({
1474
- id: import_zod16.z.string(),
1475
- role: import_zod16.z.string(),
1476
- name: import_zod16.z.array(
1477
- import_zod16.z.object({
1478
- use: import_zod16.z.string(),
1479
- given: import_zod16.z.array(import_zod16.z.string()),
1480
- family: import_zod16.z.string()
1986
+ var Action = import_zod19.z.union([ActionDocument, AsyncRejectActionDocument]);
1987
+ var ResolvedUser = import_zod19.z.object({
1988
+ id: import_zod19.z.string(),
1989
+ role: import_zod19.z.string(),
1990
+ name: import_zod19.z.array(
1991
+ import_zod19.z.object({
1992
+ use: import_zod19.z.string(),
1993
+ given: import_zod19.z.array(import_zod19.z.string()),
1994
+ family: import_zod19.z.string()
1481
1995
  })
1482
1996
  )
1483
1997
  });
@@ -1488,7 +2002,7 @@ var import_ajv_formats = __toESM(require("ajv-formats"));
1488
2002
  var import_date_fns = require("date-fns");
1489
2003
 
1490
2004
  // ../commons/src/events/FieldTypeMapping.ts
1491
- var import_zod17 = require("zod");
2005
+ var import_zod20 = require("zod");
1492
2006
  function mapFieldTypeToZod(type, required) {
1493
2007
  let schema;
1494
2008
  switch (type) {
@@ -1501,6 +2015,9 @@ function mapFieldTypeToZod(type, required) {
1501
2015
  case FieldType.DATE_RANGE:
1502
2016
  schema = DateRangeFieldValue;
1503
2017
  break;
2018
+ case FieldType.SELECT_DATE_RANGE:
2019
+ schema = SelectDateRangeValue;
2020
+ break;
1504
2021
  case FieldType.TEXT:
1505
2022
  case FieldType.TEXTAREA:
1506
2023
  case FieldType.DIVIDER:
@@ -1548,7 +2065,7 @@ function createValidationSchema(config) {
1548
2065
  for (const field2 of config) {
1549
2066
  shape[field2.id] = mapFieldTypeToZod(field2.type, field2.required);
1550
2067
  }
1551
- return import_zod17.z.object(shape);
2068
+ return import_zod20.z.object(shape);
1552
2069
  }
1553
2070
  function mapFieldTypeToEmptyValue(field2) {
1554
2071
  switch (field2.type) {
@@ -1570,6 +2087,7 @@ function mapFieldTypeToEmptyValue(field2) {
1570
2087
  case FieldType.DATE:
1571
2088
  case FieldType.CHECKBOX:
1572
2089
  case FieldType.DATE_RANGE:
2090
+ case FieldType.SELECT_DATE_RANGE:
1573
2091
  case FieldType.DATA:
1574
2092
  case FieldType.NAME:
1575
2093
  case FieldType.PHONE:
@@ -1592,7 +2110,7 @@ function mapFieldTypeToEmptyValue(field2) {
1592
2110
  case FieldType.SIGNATURE:
1593
2111
  case FieldType.FILE:
1594
2112
  return {
1595
- filename: "",
2113
+ path: "",
1596
2114
  originalFilename: "",
1597
2115
  type: ""
1598
2116
  };
@@ -1609,6 +2127,9 @@ var isDateFieldType = (field2) => {
1609
2127
  var isDateRangeFieldType = (field2) => {
1610
2128
  return field2.config.type === FieldType.DATE_RANGE;
1611
2129
  };
2130
+ var isSelectDateRangeFieldType = (field2) => {
2131
+ return field2.config.type === FieldType.SELECT_DATE_RANGE;
2132
+ };
1612
2133
  var isPageHeaderFieldType = (field2) => {
1613
2134
  return field2.config.type === FieldType.PAGE_HEADER;
1614
2135
  };
@@ -1688,6 +2209,29 @@ var ajv = new import_ajv.default({
1688
2209
  allowUnionTypes: true
1689
2210
  });
1690
2211
  (0, import_ajv_formats.default)(ajv);
2212
+ ajv.addKeyword({
2213
+ keyword: "daysFromNow",
2214
+ type: "string",
2215
+ schemaType: "object",
2216
+ $data: true,
2217
+ errors: true,
2218
+ validate(schema, data, _, dataContext) {
2219
+ if (!(dataContext && dataContext.rootData && typeof dataContext.rootData === "object" && "$now" in dataContext.rootData && typeof dataContext.rootData.$now === "string")) {
2220
+ throw new Error("Validation context must contain $now");
2221
+ }
2222
+ const { days, clause } = schema;
2223
+ if (typeof data !== "string") {
2224
+ return false;
2225
+ }
2226
+ const date = new Date(data);
2227
+ if (isNaN(date.getTime())) {
2228
+ return false;
2229
+ }
2230
+ const now = new Date(dataContext.rootData.$now);
2231
+ const offsetDate = new Date(now.getTime() + days * 24 * 60 * 60 * 1e3);
2232
+ return clause === "after" ? (0, import_date_fns.isAfter)(date, offsetDate) : (0, import_date_fns.isBefore)(date, offsetDate);
2233
+ }
2234
+ });
1691
2235
  function validate(schema, data) {
1692
2236
  return ajv.validate(schema, data);
1693
2237
  }
@@ -1753,7 +2297,7 @@ var errorMessages = {
1753
2297
  id: "v2.error.invalidEmail"
1754
2298
  },
1755
2299
  requiredField: {
1756
- defaultMessage: "Required for registration",
2300
+ defaultMessage: "Required",
1757
2301
  description: "Error message when required field is missing",
1758
2302
  id: "v2.error.required"
1759
2303
  },
@@ -1901,12 +2445,6 @@ function getValidatorsForField(fieldId, validations) {
1901
2445
  }).filter((x) => x !== null);
1902
2446
  }
1903
2447
 
1904
- // ../commons/src/uuid.ts
1905
- var import_uuid = require("uuid");
1906
- function getUUID() {
1907
- return (0, import_uuid.v4)();
1908
- }
1909
-
1910
2448
  // ../commons/src/utils.ts
1911
2449
  function getOrThrow(x, message) {
1912
2450
  if (x === void 0 || x === null) {
@@ -1914,8 +2452,12 @@ function getOrThrow(x, message) {
1914
2452
  }
1915
2453
  return x;
1916
2454
  }
2455
+ function joinValues(values, separator = " ") {
2456
+ return values.filter((value) => !!value).join(separator).trim();
2457
+ }
1917
2458
 
1918
2459
  // ../commons/src/events/utils.ts
2460
+ var import_date_fns2 = require("date-fns");
1919
2461
  function isDeclarationActionConfig(action) {
1920
2462
  return DeclarationActions.safeParse(action.type).success;
1921
2463
  }
@@ -1928,6 +2470,15 @@ function getDeclarationPages(configuration) {
1928
2470
  function getDeclaration(configuration) {
1929
2471
  return configuration.declaration;
1930
2472
  }
2473
+ function getPrintCertificatePages(configuration) {
2474
+ const action = configuration.actions.find(
2475
+ (a) => a.type === ActionType.PRINT_CERTIFICATE
2476
+ );
2477
+ return getOrThrow(
2478
+ action?.printForm.pages,
2479
+ `${ActionType.PRINT_CERTIFICATE} action does not have print form set.`
2480
+ );
2481
+ }
1931
2482
  var getActionAnnotationFields = (actionConfig) => {
1932
2483
  if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
1933
2484
  return [
@@ -2013,8 +2564,9 @@ function createEmptyDraft(eventId, draftId, actionType) {
2013
2564
  declaration: {},
2014
2565
  annotation: {},
2015
2566
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2567
+ createdByUserType: TokenUserType.Enum.user,
2016
2568
  createdBy: "@todo",
2017
- createdAtLocation: "@todo",
2569
+ createdAtLocation: "00000000-0000-0000-0000-000000000000",
2018
2570
  status: ActionStatus.Accepted,
2019
2571
  transactionId: "@todo",
2020
2572
  createdByRole: "@todo"
@@ -2114,12 +2666,33 @@ function getEventConfigById(eventConfigs, id) {
2114
2666
  );
2115
2667
  return getOrThrow(eventConfig, `Event config for ${id} not found`);
2116
2668
  }
2669
+ function timePeriodToDateRange(value) {
2670
+ let startDate;
2671
+ switch (value) {
2672
+ case "last7Days":
2673
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 6);
2674
+ break;
2675
+ case "last30Days":
2676
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 29);
2677
+ break;
2678
+ case "last90Days":
2679
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 89);
2680
+ break;
2681
+ case "last365Days":
2682
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 364);
2683
+ break;
2684
+ }
2685
+ return {
2686
+ startDate: startDate.toISOString(),
2687
+ endDate: (/* @__PURE__ */ new Date()).toISOString()
2688
+ };
2689
+ }
2117
2690
 
2118
2691
  // ../commons/src/events/EventConfig.ts
2119
- var import_zod_openapi8 = require("zod-openapi");
2120
- (0, import_zod_openapi8.extendZodWithOpenApi)(import_zod18.z);
2121
- var EventConfig = import_zod18.z.object({
2122
- id: import_zod18.z.string().describe(
2692
+ var import_zod_openapi9 = require("zod-openapi");
2693
+ (0, import_zod_openapi9.extendZodWithOpenApi)(import_zod21.z);
2694
+ var EventConfig = import_zod21.z.object({
2695
+ id: import_zod21.z.string().describe(
2123
2696
  'A machine-readable identifier for the event, e.g. "birth" or "death"'
2124
2697
  ),
2125
2698
  dateOfEvent: FieldReference.optional(),
@@ -2129,10 +2702,10 @@ var EventConfig = import_zod18.z.object({
2129
2702
  ),
2130
2703
  summary: SummaryConfig,
2131
2704
  label: TranslationConfig,
2132
- actions: import_zod18.z.array(ActionConfig),
2705
+ actions: import_zod21.z.array(ActionConfig),
2133
2706
  declaration: DeclarationFormConfig,
2134
- deduplication: import_zod18.z.array(DeduplicationConfig).optional().default([]),
2135
- advancedSearch: import_zod18.z.array(AdvancedSearchConfig).optional().default([])
2707
+ deduplication: import_zod21.z.array(DeduplicationConfig).optional().default([]),
2708
+ advancedSearch: import_zod21.z.array(AdvancedSearchConfig).optional().default([])
2136
2709
  }).superRefine((event2, ctx) => {
2137
2710
  const allFields = findAllFields(event2);
2138
2711
  const fieldIds = allFields.map((field2) => field2.id);
@@ -2164,6 +2737,28 @@ var EventConfig = import_zod18.z.object({
2164
2737
  path: ["advancedSearch"]
2165
2738
  });
2166
2739
  }
2740
+ event2.advancedSearch.forEach((section, sectionIndex) => {
2741
+ section.fields.forEach((field2, fieldIndex) => {
2742
+ if ("alternateFieldIds" in field2 && Array.isArray(field2.alternateFieldIds)) {
2743
+ const invalidAltIds = field2.alternateFieldIds.filter(
2744
+ (id) => !fieldIds.includes(id)
2745
+ );
2746
+ if (invalidAltIds.length > 0) {
2747
+ ctx.addIssue({
2748
+ code: "custom",
2749
+ message: `Invalid alternateFieldIds: ${invalidAltIds.join(", ")}`,
2750
+ path: [
2751
+ "advancedSearch",
2752
+ sectionIndex,
2753
+ "fields",
2754
+ fieldIndex,
2755
+ "alternateFieldIds"
2756
+ ]
2757
+ });
2758
+ }
2759
+ }
2760
+ });
2761
+ });
2167
2762
  if (event2.dateOfEvent) {
2168
2763
  const eventDateFieldId = getDeclarationFields(event2).find(
2169
2764
  ({ id }) => id === event2.dateOfEvent?.$$field
@@ -2194,16 +2789,17 @@ var definePage = (page) => PageConfig.parse(page);
2194
2789
  var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
2195
2790
 
2196
2791
  // ../commons/src/events/WorkqueueConfig.ts
2197
- var import_zod25 = require("zod");
2792
+ var import_zod28 = require("zod");
2198
2793
 
2199
2794
  // ../commons/src/events/serializers/user/serializer.ts
2200
- var import_zod19 = require("zod");
2201
- var SerializedUserField = import_zod19.z.object({
2202
- $userField: import_zod19.z.enum([
2795
+ var import_zod22 = require("zod");
2796
+ var SerializedUserField = import_zod22.z.object({
2797
+ $userField: import_zod22.z.enum([
2203
2798
  "id",
2204
2799
  "name",
2205
2800
  "role",
2206
- "signatureFilename",
2801
+ "signature",
2802
+ "avatar",
2207
2803
  "primaryOfficeId"
2208
2804
  ])
2209
2805
  });
@@ -2275,41 +2871,6 @@ var user = Object.assign(userSerializer, {
2275
2871
  required: ["$user"]
2276
2872
  })
2277
2873
  });
2278
- function createEventConditionals() {
2279
- return {
2280
- /**
2281
- * Checks if the event contains a specific action type.
2282
- * @param action - The action type to check for.
2283
- */
2284
- hasAction: (action) => defineConditional({
2285
- type: "object",
2286
- properties: {
2287
- $event: {
2288
- type: "object",
2289
- properties: {
2290
- actions: {
2291
- type: "array",
2292
- contains: {
2293
- type: "object",
2294
- properties: {
2295
- type: {
2296
- const: action
2297
- }
2298
- },
2299
- required: ["type"]
2300
- }
2301
- }
2302
- },
2303
- required: ["actions"]
2304
- }
2305
- },
2306
- required: ["$event"]
2307
- })
2308
- };
2309
- }
2310
- function getDateFromNow(days) {
2311
- return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
2312
- }
2313
2874
  function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
2314
2875
  return {
2315
2876
  type: "object",
@@ -2328,6 +2889,20 @@ function isFieldReference(value) {
2328
2889
  return typeof value === "object" && value !== null && "$$field" in value;
2329
2890
  }
2330
2891
  function createFieldConditionals(fieldId) {
2892
+ const getDayRange = (days, clause) => ({
2893
+ type: "object",
2894
+ properties: {
2895
+ [fieldId]: {
2896
+ type: "string",
2897
+ format: "date",
2898
+ daysFromNow: {
2899
+ days,
2900
+ clause
2901
+ }
2902
+ }
2903
+ },
2904
+ required: [fieldId]
2905
+ });
2331
2906
  const getDateRange = (date, clause) => ({
2332
2907
  type: "object",
2333
2908
  properties: {
@@ -2346,12 +2921,8 @@ function createFieldConditionals(fieldId) {
2346
2921
  $$field: fieldId,
2347
2922
  isAfter: () => ({
2348
2923
  days: (days) => ({
2349
- inPast: () => defineFormConditional(
2350
- getDateRange(getDateFromNow(days), "formatMinimum")
2351
- ),
2352
- inFuture: () => defineFormConditional(
2353
- getDateRange(getDateFromNow(-days), "formatMinimum")
2354
- )
2924
+ inPast: () => defineFormConditional(getDayRange(-days, "after")),
2925
+ inFuture: () => defineFormConditional(getDayRange(days, "after"))
2355
2926
  }),
2356
2927
  date: (date) => {
2357
2928
  if (isFieldReference(date)) {
@@ -2366,16 +2937,12 @@ function createFieldConditionals(fieldId) {
2366
2937
  }
2367
2938
  return defineFormConditional(getDateRange(date, "formatMinimum"));
2368
2939
  },
2369
- now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMinimum"))
2940
+ now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMinimum"))
2370
2941
  }),
2371
2942
  isBefore: () => ({
2372
2943
  days: (days) => ({
2373
- inPast: () => defineFormConditional(
2374
- getDateRange(getDateFromNow(days), "formatMaximum")
2375
- ),
2376
- inFuture: () => defineFormConditional(
2377
- getDateRange(getDateFromNow(-days), "formatMaximum")
2378
- )
2944
+ inPast: () => defineFormConditional(getDayRange(days, "before")),
2945
+ inFuture: () => defineFormConditional(getDayRange(-days, "before"))
2379
2946
  }),
2380
2947
  date: (date) => {
2381
2948
  if (isFieldReference(date)) {
@@ -2390,7 +2957,7 @@ function createFieldConditionals(fieldId) {
2390
2957
  }
2391
2958
  return defineFormConditional(getDateRange(date, "formatMaximum"));
2392
2959
  },
2393
- now: () => defineFormConditional(getDateRange(getDateFromNow(0), "formatMaximum"))
2960
+ now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMaximum"))
2394
2961
  }),
2395
2962
  isEqualTo: (value) => {
2396
2963
  if (isFieldReference(value)) {
@@ -2539,7 +3106,7 @@ function createSearchConfig(baseField) {
2539
3106
  *
2540
3107
  * @returns An object containing the field ID and a configuration object with a type of 'range'.
2541
3108
  *
2542
- * @example event('legalStatus.REGISTERED.createdAt').range()
3109
+ * @example event('legalStatuses.REGISTERED.acceptedAt').range()
2543
3110
  * // {
2544
3111
  * // ...
2545
3112
  * // config: { type: 'range' }
@@ -2579,21 +3146,48 @@ function createSearchConfig(baseField) {
2579
3146
  }
2580
3147
 
2581
3148
  // ../commons/src/event-config/event-configuration.ts
2582
- function createEventFieldConfig(fieldId, options) {
3149
+ function createEventFieldConfig(fieldId, options = []) {
2583
3150
  const baseField = {
2584
3151
  fieldId,
2585
- options,
2586
- fieldType: "event"
3152
+ fieldType: "event",
3153
+ options
2587
3154
  };
2588
3155
  return createSearchConfig(baseField);
2589
3156
  }
2590
3157
 
2591
3158
  // ../commons/src/events/event.ts
2592
- function eventFn(fieldId, options) {
3159
+ function eventFn(fieldId, options = []) {
2593
3160
  return createEventFieldConfig(fieldId, options);
2594
3161
  }
2595
3162
  var event = Object.assign(eventFn, {
2596
- ...createEventConditionals(),
3163
+ /**
3164
+ * Checks if the event contains a specific action type.
3165
+ * @param action - The action type to check for.
3166
+ */
3167
+ hasAction: (action) => defineConditional({
3168
+ type: "object",
3169
+ properties: {
3170
+ $event: {
3171
+ type: "object",
3172
+ properties: {
3173
+ actions: {
3174
+ type: "array",
3175
+ contains: {
3176
+ type: "object",
3177
+ properties: {
3178
+ type: {
3179
+ const: action
3180
+ }
3181
+ },
3182
+ required: ["type"]
3183
+ }
3184
+ }
3185
+ },
3186
+ required: ["actions"]
3187
+ }
3188
+ },
3189
+ required: ["$event"]
3190
+ }),
2597
3191
  field(field2) {
2598
3192
  return {
2599
3193
  $event: field2
@@ -2602,11 +3196,11 @@ var event = Object.assign(eventFn, {
2602
3196
  });
2603
3197
 
2604
3198
  // ../commons/src/events/WorkqueueColumnConfig.ts
2605
- var import_zod21 = require("zod");
3199
+ var import_zod24 = require("zod");
2606
3200
 
2607
3201
  // ../commons/src/events/EventMetadata.ts
2608
- var import_zod20 = require("zod");
2609
- var EventStatus = import_zod20.z.enum([
3202
+ var import_zod23 = require("zod");
3203
+ var EventStatus = import_zod23.z.enum([
2610
3204
  "CREATED",
2611
3205
  "NOTIFIED",
2612
3206
  "DECLARED",
@@ -2616,60 +3210,69 @@ var EventStatus = import_zod20.z.enum([
2616
3210
  "REJECTED",
2617
3211
  "ARCHIVED"
2618
3212
  ]);
2619
- var CustomFlags = {
2620
- CERTIFICATE_PRINTED: "certificate-printed"
3213
+ var InherentFlags = {
3214
+ PRINTED: "printed",
3215
+ INCOMPLETE: "incomplete",
3216
+ REJECTED: "rejected",
3217
+ CORRECTION_REQUESTED: "correction-requested"
2621
3218
  };
2622
- var Flag = import_zod20.z.string().regex(
3219
+ var Flag = import_zod23.z.string().regex(
2623
3220
  new RegExp(
2624
3221
  `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
2625
3222
  ActionStatus
2626
3223
  ).join("|").toLowerCase()})$`
2627
3224
  ),
2628
3225
  "Flag must be in the format ActionType:ActionStatus (lowerCase)"
2629
- ).or(import_zod20.z.nativeEnum(CustomFlags));
2630
- var ZodDate = import_zod20.z.string().date();
2631
- var ActionCreationMetadata = import_zod20.z.object({
2632
- createdAt: import_zod20.z.string().datetime().describe("The timestamp when the action request was created."),
2633
- createdBy: import_zod20.z.string().describe("ID of the user who created the action request."),
3226
+ ).or(import_zod23.z.nativeEnum(InherentFlags));
3227
+ var ZodDate = import_zod23.z.string().date();
3228
+ var ActionCreationMetadata = import_zod23.z.object({
3229
+ createdAt: import_zod23.z.string().datetime().describe("The timestamp when the action request was created."),
3230
+ createdBy: import_zod23.z.string().describe("ID of the user who created the action request."),
2634
3231
  createdAtLocation: CreatedAtLocation.describe(
2635
3232
  "Location of the user who created the action request."
2636
3233
  ),
2637
- acceptedAt: import_zod20.z.string().datetime().describe("Timestamp when the action request was accepted."),
2638
- createdByRole: import_zod20.z.string().describe("Role of the user at the time of action request creation."),
2639
- createdBySignature: import_zod20.z.string().nullish().describe("Signature of the user who created the action request.")
3234
+ createdByUserType: import_zod23.z.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
3235
+ acceptedAt: import_zod23.z.string().datetime().describe("Timestamp when the action request was accepted."),
3236
+ createdByRole: import_zod23.z.string().describe("Role of the user at the time of action request creation."),
3237
+ createdBySignature: import_zod23.z.string().nullish().describe("Signature of the user who created the action request.")
2640
3238
  });
2641
3239
  var RegistrationCreationMetadata = ActionCreationMetadata.extend({
2642
- registrationNumber: import_zod20.z.string().describe(
3240
+ registrationNumber: import_zod23.z.string().describe(
2643
3241
  "Registration number of the event. Always present for accepted registrations."
2644
3242
  )
2645
3243
  });
2646
- var LegalStatuses = import_zod20.z.object({
3244
+ var LegalStatuses = import_zod23.z.object({
2647
3245
  [EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
2648
3246
  [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
2649
3247
  });
2650
- var EventMetadata = import_zod20.z.object({
2651
- id: import_zod20.z.string(),
2652
- type: import_zod20.z.string().describe("The type of event, such as birth, death, or marriage."),
3248
+ var EventMetadata = import_zod23.z.object({
3249
+ id: UUID,
3250
+ type: import_zod23.z.string().describe("The type of event, such as birth, death, or marriage."),
2653
3251
  status: EventStatus,
2654
3252
  legalStatuses: LegalStatuses.describe(
2655
3253
  "Metadata related to the legal registration of the event, such as who registered it and when."
2656
3254
  ),
2657
- createdAt: import_zod20.z.string().datetime().describe("The timestamp when the event was first created and saved."),
3255
+ createdAt: import_zod23.z.string().datetime().describe("The timestamp when the event was first created and saved."),
2658
3256
  dateOfEvent: ZodDate.nullish(),
2659
- createdBy: import_zod20.z.string().describe("ID of the user who created the event."),
2660
- updatedByUserRole: import_zod20.z.string().describe("Role of the user who last updated the declaration."),
3257
+ createdBy: import_zod23.z.string().describe("ID of the user who created the event."),
3258
+ createdByUserType: import_zod23.z.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
3259
+ updatedByUserRole: import_zod23.z.string().describe("Role of the user who last changed the status."),
2661
3260
  createdAtLocation: CreatedAtLocation.describe(
2662
3261
  "Location of the user who created the event."
2663
3262
  ),
2664
- createdBySignature: import_zod20.z.string().nullish().describe("Signature of the user who created the event."),
2665
- updatedAtLocation: import_zod20.z.string().nullish().describe("Location of the user who last updated the declaration."),
2666
- updatedAt: import_zod20.z.string().datetime().describe("Timestamp of the most recent declaration update."),
2667
- assignedTo: import_zod20.z.string().nullish().describe("ID of the user currently assigned to the event."),
2668
- updatedBy: import_zod20.z.string().nullish().describe("ID of the user who last updated the declaration."),
2669
- trackingId: import_zod20.z.string().describe(
3263
+ createdBySignature: import_zod23.z.string().nullish().describe("Signature of the user who created the event."),
3264
+ updatedAtLocation: UUID.nullish().describe(
3265
+ "Location of the user who last changed the status."
3266
+ ),
3267
+ updatedAt: import_zod23.z.string().datetime().describe(
3268
+ "Timestamp of the most recent *accepted* status change. Possibly 3rd party update, if action is validation asynchronously."
3269
+ ),
3270
+ assignedTo: import_zod23.z.string().nullish().describe("ID of the user currently assigned to the event."),
3271
+ updatedBy: import_zod23.z.string().nullish().describe("ID of the user who last changed the status."),
3272
+ trackingId: import_zod23.z.string().describe(
2670
3273
  "System-generated tracking ID used by informants or registrars to look up the event."
2671
3274
  ),
2672
- flags: import_zod20.z.array(Flag)
3275
+ flags: import_zod23.z.array(Flag)
2673
3276
  });
2674
3277
  var EventMetadataKeysArray = [
2675
3278
  "id",
@@ -2678,6 +3281,7 @@ var EventMetadataKeysArray = [
2678
3281
  "createdAt",
2679
3282
  "dateOfEvent",
2680
3283
  "createdBy",
3284
+ "createdByUserType",
2681
3285
  "updatedByUserRole",
2682
3286
  "createdAtLocation",
2683
3287
  "updatedAtLocation",
@@ -2688,7 +3292,7 @@ var EventMetadataKeysArray = [
2688
3292
  "legalStatuses",
2689
3293
  "flags"
2690
3294
  ];
2691
- var EventMetadataKeys = import_zod20.z.enum(EventMetadataKeysArray);
3295
+ var EventMetadataKeys = import_zod23.z.enum(EventMetadataKeysArray);
2692
3296
  var eventMetadataLabelMap = {
2693
3297
  "event.assignedTo": {
2694
3298
  id: "event.assignedTo.label",
@@ -2700,6 +3304,11 @@ var eventMetadataLabelMap = {
2700
3304
  defaultMessage: "Created",
2701
3305
  description: "Created At"
2702
3306
  },
3307
+ "event.createdByUserType": {
3308
+ id: "event.createdByUserType.label",
3309
+ defaultMessage: "createdByUserType",
3310
+ description: "createdByUserType:user or system"
3311
+ },
2703
3312
  "event.dateOfEvent": {
2704
3313
  id: "event.dateOfEvent.label",
2705
3314
  defaultMessage: "Date of Event",
@@ -2765,13 +3374,14 @@ var eventMetadataLabelMap = {
2765
3374
  // ../commons/src/events/WorkqueueColumnConfig.ts
2766
3375
  var WorkqueueColumnKeysArray = [
2767
3376
  ...EventMetadataKeysArray,
2768
- "title"
3377
+ "title",
3378
+ "outbox"
2769
3379
  ];
2770
- var WorkqueueColumnKeys = import_zod21.z.enum(WorkqueueColumnKeysArray);
2771
- var WorkqueueColumnValue = import_zod21.z.object({
3380
+ var WorkqueueColumnKeys = import_zod24.z.enum(WorkqueueColumnKeysArray);
3381
+ var WorkqueueColumnValue = import_zod24.z.object({
2772
3382
  $event: WorkqueueColumnKeys
2773
3383
  });
2774
- var WorkqueueColumn = import_zod21.z.object({
3384
+ var WorkqueueColumn = import_zod24.z.object({
2775
3385
  label: TranslationConfig,
2776
3386
  value: WorkqueueColumnValue
2777
3387
  });
@@ -2782,97 +3392,127 @@ function defineWorkqueuesColumns(workqueueColumns) {
2782
3392
  }
2783
3393
 
2784
3394
  // ../commons/src/events/CountryConfigQueryInput.ts
2785
- var import_zod23 = require("zod");
3395
+ var import_zod26 = require("zod");
2786
3396
 
2787
3397
  // ../commons/src/events/EventIndex.ts
2788
- var import_zod22 = require("zod");
2789
- var import_zod_openapi9 = require("zod-openapi");
2790
- (0, import_zod_openapi9.extendZodWithOpenApi)(import_zod22.z);
3398
+ var import_zod25 = require("zod");
3399
+ var import_zod_openapi10 = require("zod-openapi");
3400
+ (0, import_zod_openapi10.extendZodWithOpenApi)(import_zod25.z);
2791
3401
  var EventIndex = EventMetadata.extend({
2792
3402
  declaration: EventState
2793
3403
  }).openapi({
2794
3404
  ref: "EventIndex"
2795
3405
  });
2796
- var EventSearchIndex = import_zod22.z.record(import_zod22.z.string(), import_zod22.z.any()).and(
2797
- import_zod22.z.object({
2798
- type: import_zod22.z.string()
3406
+ var EventSearchIndex = import_zod25.z.record(import_zod25.z.string(), import_zod25.z.any()).and(
3407
+ import_zod25.z.object({
3408
+ type: import_zod25.z.string()
2799
3409
  // Ensures "type" (event-id) exists and is a string
2800
3410
  })
2801
3411
  ).openapi({
2802
3412
  ref: "EventSearchIndex"
2803
3413
  });
2804
- var Fuzzy = import_zod22.z.object({ type: import_zod22.z.literal("fuzzy"), term: import_zod22.z.string() }).openapi({
3414
+ var Fuzzy = import_zod25.z.object({ type: import_zod25.z.literal("fuzzy"), term: import_zod25.z.string() }).openapi({
2805
3415
  ref: "Fuzzy"
2806
3416
  });
2807
- var Exact = import_zod22.z.object({ type: import_zod22.z.literal("exact"), term: import_zod22.z.string() }).openapi({
3417
+ var Exact = import_zod25.z.object({ type: import_zod25.z.literal("exact"), term: import_zod25.z.string() }).openapi({
2808
3418
  ref: "Exact"
2809
3419
  });
2810
- var AnyOf = import_zod22.z.object({
2811
- type: import_zod22.z.literal("anyOf"),
2812
- terms: import_zod22.z.array(import_zod22.z.string())
2813
- }).openapi({
2814
- ref: "AnyOf"
2815
- });
2816
- var ExactStatus = import_zod22.z.object({
2817
- type: import_zod22.z.literal("exact"),
3420
+ var ExactStatus = import_zod25.z.object({
3421
+ type: import_zod25.z.literal("exact"),
2818
3422
  term: EventStatus
2819
3423
  }).openapi({
2820
3424
  ref: "ExactStatus"
2821
3425
  });
2822
- var AnyOfStatus = import_zod22.z.object({
2823
- type: import_zod22.z.literal("anyOf"),
2824
- terms: import_zod22.z.array(EventStatus)
3426
+ var ExactUserType = import_zod25.z.object({
3427
+ type: import_zod25.z.literal("exact"),
3428
+ term: TokenUserType
3429
+ }).openapi({
3430
+ ref: "ExactUserType"
3431
+ });
3432
+ var AnyOf = import_zod25.z.object({
3433
+ type: import_zod25.z.literal("anyOf"),
3434
+ terms: import_zod25.z.array(import_zod25.z.string())
3435
+ }).openapi({
3436
+ ref: "AnyOf"
3437
+ });
3438
+ var AnyOfStatus = import_zod25.z.object({
3439
+ type: import_zod25.z.literal("anyOf"),
3440
+ terms: import_zod25.z.array(EventStatus)
2825
3441
  }).openapi({
2826
3442
  ref: "AnyOfStatus"
2827
3443
  });
2828
- var Range = import_zod22.z.object({
2829
- type: import_zod22.z.literal("range"),
2830
- gte: import_zod22.z.string(),
2831
- lte: import_zod22.z.string()
3444
+ var Range = import_zod25.z.object({
3445
+ type: import_zod25.z.literal("range"),
3446
+ gte: import_zod25.z.string(),
3447
+ lte: import_zod25.z.string()
2832
3448
  }).openapi({
2833
3449
  ref: "Range"
2834
3450
  });
2835
- var Not = import_zod22.z.object({ type: import_zod22.z.literal("not"), term: import_zod22.z.string() }).openapi({
2836
- ref: "Not"
3451
+ var ContainsFlags = import_zod25.z.object({
3452
+ anyOf: import_zod25.z.array(Flag).optional(),
3453
+ noneOf: import_zod25.z.array(Flag).optional()
3454
+ }).openapi({
3455
+ ref: "ContainsFlags"
2837
3456
  });
2838
- var Within = import_zod22.z.object({ type: import_zod22.z.literal("within"), location: import_zod22.z.string() }).openapi({
3457
+ var Within = import_zod25.z.object({ type: import_zod25.z.literal("within"), location: import_zod25.z.string() }).openapi({
2839
3458
  ref: "Within"
2840
3459
  });
2841
- var DateCondition = import_zod22.z.union([Exact, Range]).openapi({
3460
+ var RangeDate = import_zod25.z.object({
3461
+ type: import_zod25.z.literal("range"),
3462
+ gte: import_zod25.z.string().date().or(import_zod25.z.string().datetime()),
3463
+ lte: import_zod25.z.string().date().or(import_zod25.z.string().datetime())
3464
+ }).openapi({ ref: "RangeDate" });
3465
+ var ExactDate = Exact.extend({
3466
+ term: import_zod25.z.string().date().or(import_zod25.z.string().datetime())
3467
+ }).openapi({
3468
+ ref: "ExactDate"
3469
+ });
3470
+ var TimePeriod = import_zod25.z.object({
3471
+ type: import_zod25.z.literal("timePeriod"),
3472
+ term: SelectDateRangeValue
3473
+ }).openapi({
3474
+ ref: "TimePeriod"
3475
+ });
3476
+ var DateCondition = import_zod25.z.union([ExactDate, RangeDate, TimePeriod]).openapi({
2842
3477
  ref: "DateCondition"
2843
3478
  });
2844
- var QueryInput = import_zod22.z.lazy(
2845
- () => import_zod22.z.union([
2846
- import_zod22.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf, Not]),
2847
- import_zod22.z.record(import_zod22.z.string(), QueryInput)
3479
+ var QueryInput = import_zod25.z.lazy(
3480
+ () => import_zod25.z.union([
3481
+ import_zod25.z.discriminatedUnion("type", [Fuzzy, Exact, Range, Within, AnyOf]),
3482
+ import_zod25.z.record(import_zod25.z.string(), QueryInput)
2848
3483
  ])
2849
3484
  ).openapi({
2850
3485
  ref: "QueryInput"
2851
3486
  });
2852
- var QueryExpression = import_zod22.z.object({
2853
- eventType: import_zod22.z.string(),
2854
- status: import_zod22.z.optional(import_zod22.z.union([AnyOfStatus, ExactStatus])),
2855
- createdAt: import_zod22.z.optional(DateCondition),
2856
- updatedAt: import_zod22.z.optional(DateCondition),
2857
- "legalStatus.REGISTERED.createdAt": import_zod22.z.optional(DateCondition),
2858
- "legalStatus.REGISTERED.createdAtLocation": import_zod22.z.optional(
2859
- import_zod22.z.union([Within, Exact])
3487
+ var QueryExpression = import_zod25.z.object({
3488
+ id: import_zod25.z.optional(import_zod25.z.string()),
3489
+ eventType: import_zod25.z.string(),
3490
+ status: import_zod25.z.optional(import_zod25.z.union([AnyOfStatus, ExactStatus])),
3491
+ createdAt: import_zod25.z.optional(DateCondition),
3492
+ updatedAt: import_zod25.z.optional(DateCondition),
3493
+ "legalStatuses.REGISTERED.acceptedAt": import_zod25.z.optional(DateCondition),
3494
+ "legalStatuses.REGISTERED.createdAtLocation": import_zod25.z.optional(
3495
+ import_zod25.z.union([Within, Exact])
2860
3496
  ),
2861
- "legalStatus.REGISTERED.registrationNumber": import_zod22.z.optional(Exact),
2862
- createdAtLocation: import_zod22.z.optional(import_zod22.z.union([Within, Exact])),
2863
- updatedAtLocation: import_zod22.z.optional(import_zod22.z.union([Within, Exact])),
2864
- assignedTo: import_zod22.z.optional(Exact),
2865
- createdBy: import_zod22.z.optional(Exact),
2866
- updatedBy: import_zod22.z.optional(Exact),
2867
- trackingId: import_zod22.z.optional(Exact),
2868
- flags: import_zod22.z.optional(import_zod22.z.array(import_zod22.z.union([AnyOf, Not]))),
3497
+ "legalStatuses.REGISTERED.registrationNumber": import_zod25.z.optional(Exact),
3498
+ createdAtLocation: import_zod25.z.optional(import_zod25.z.union([Within, Exact])),
3499
+ updatedAtLocation: import_zod25.z.optional(import_zod25.z.union([Within, Exact])),
3500
+ assignedTo: import_zod25.z.optional(Exact),
3501
+ createdByUserType: import_zod25.z.optional(ExactUserType),
3502
+ createdBy: import_zod25.z.optional(Exact),
3503
+ updatedBy: import_zod25.z.optional(Exact),
3504
+ trackingId: import_zod25.z.optional(Exact),
3505
+ flags: import_zod25.z.optional(ContainsFlags),
3506
+ // @todo: The type for this comes out as "any"
2869
3507
  data: QueryInput
2870
- }).partial().openapi({
3508
+ }).partial().refine((obj) => Object.values(obj).some((val) => val !== void 0), {
3509
+ message: "At least one query field must be specified."
3510
+ }).openapi({
2871
3511
  ref: "QueryExpression"
2872
3512
  });
2873
- var QueryType = import_zod22.z.object({
2874
- type: import_zod22.z.literal("and").or(import_zod22.z.literal("or")).openapi({ default: "and" }),
2875
- clauses: import_zod22.z.preprocess(
3513
+ var QueryType = import_zod25.z.object({
3514
+ type: import_zod25.z.literal("and").or(import_zod25.z.literal("or")).openapi({ default: "and" }),
3515
+ clauses: import_zod25.z.preprocess(
2876
3516
  (val) => {
2877
3517
  if (typeof val === "string") {
2878
3518
  return [JSON.parse(val)];
@@ -2882,7 +3522,7 @@ var QueryType = import_zod22.z.object({
2882
3522
  }
2883
3523
  return val;
2884
3524
  },
2885
- import_zod22.z.array(QueryExpression).nonempty("At least one clause is required.").openapi({
3525
+ import_zod25.z.array(QueryExpression).nonempty("At least one clause is required.").openapi({
2886
3526
  default: [
2887
3527
  {
2888
3528
  eventType: TENNIS_CLUB_MEMBERSHIP,
@@ -2903,52 +3543,62 @@ var QueryType = import_zod22.z.object({
2903
3543
  }).openapi({
2904
3544
  ref: "QueryType"
2905
3545
  });
3546
+ var SearchScopeAccessLevels = {
3547
+ MY_JURISDICTION: "my-jurisdiction",
3548
+ ALL: "all"
3549
+ };
2906
3550
 
2907
3551
  // ../commons/src/events/CountryConfigQueryInput.ts
2908
- var SerializableExact = import_zod23.z.object({
2909
- type: import_zod23.z.literal("exact"),
2910
- term: import_zod23.z.union([import_zod23.z.string(), SerializedUserField])
3552
+ var SerializableExact = import_zod26.z.object({
3553
+ type: import_zod26.z.literal("exact"),
3554
+ term: import_zod26.z.union([import_zod26.z.string(), SerializedUserField])
2911
3555
  });
2912
- var SerializableWithin = import_zod23.z.object({
2913
- type: import_zod23.z.literal("within"),
2914
- location: import_zod23.z.union([import_zod23.z.string(), SerializedUserField])
3556
+ var SerializableWithin = import_zod26.z.object({
3557
+ type: import_zod26.z.literal("within"),
3558
+ location: import_zod26.z.union([import_zod26.z.string(), SerializedUserField])
2915
3559
  });
2916
- var SerializedQueryExpression = import_zod23.z.object({
2917
- eventType: import_zod23.z.string(),
2918
- status: import_zod23.z.optional(import_zod23.z.union([AnyOfStatus, ExactStatus])),
2919
- createdAt: import_zod23.z.optional(DateCondition),
2920
- updatedAt: import_zod23.z.optional(DateCondition),
2921
- createdAtLocation: import_zod23.z.optional(
2922
- import_zod23.z.union([SerializableWithin, SerializableExact])
3560
+ var SerializedQueryExpression = import_zod26.z.object({
3561
+ eventType: import_zod26.z.string(),
3562
+ status: import_zod26.z.optional(import_zod26.z.union([AnyOfStatus, ExactStatus])),
3563
+ createdAt: import_zod26.z.optional(DateCondition),
3564
+ updatedAt: import_zod26.z.optional(DateCondition),
3565
+ "legalStatuses.REGISTERED.createdAt": import_zod26.z.optional(DateCondition),
3566
+ "legalStatuses.REGISTERED.createdAtLocation": import_zod26.z.optional(
3567
+ import_zod26.z.union([Within, Exact])
2923
3568
  ),
2924
- updatedAtLocation: import_zod23.z.optional(
2925
- import_zod23.z.union([SerializableWithin, SerializableExact])
3569
+ "legalStatuses.REGISTERED.registrationNumber": import_zod26.z.optional(Exact),
3570
+ createdAtLocation: import_zod26.z.optional(
3571
+ import_zod26.z.union([SerializableWithin, SerializableExact])
2926
3572
  ),
2927
- assignedTo: import_zod23.z.optional(SerializableExact),
2928
- createdBy: import_zod23.z.optional(SerializableExact),
2929
- updatedBy: import_zod23.z.optional(SerializableExact),
2930
- trackingId: import_zod23.z.optional(Exact),
2931
- flags: import_zod23.z.optional(import_zod23.z.array(import_zod23.z.union([AnyOf, Not]))),
3573
+ updatedAtLocation: import_zod26.z.optional(
3574
+ import_zod26.z.union([SerializableWithin, SerializableExact])
3575
+ ),
3576
+ assignedTo: import_zod26.z.optional(SerializableExact),
3577
+ createdBy: import_zod26.z.optional(SerializableExact),
3578
+ createdByUserType: ExactUserType,
3579
+ updatedBy: import_zod26.z.optional(SerializableExact),
3580
+ trackingId: import_zod26.z.optional(Exact),
3581
+ flags: import_zod26.z.optional(ContainsFlags),
2932
3582
  data: QueryInput
2933
3583
  }).partial();
2934
- var Or2 = import_zod23.z.object({
2935
- type: import_zod23.z.literal("or"),
2936
- clauses: import_zod23.z.array(SerializedQueryExpression)
3584
+ var Or2 = import_zod26.z.object({
3585
+ type: import_zod26.z.literal("or"),
3586
+ clauses: import_zod26.z.array(SerializedQueryExpression)
2937
3587
  });
2938
- var And2 = import_zod23.z.object({
2939
- type: import_zod23.z.literal("and"),
2940
- clauses: import_zod23.z.array(SerializedQueryExpression)
3588
+ var And2 = import_zod26.z.object({
3589
+ type: import_zod26.z.literal("and"),
3590
+ clauses: import_zod26.z.array(SerializedQueryExpression)
2941
3591
  });
2942
- var CountryConfigQueryType = import_zod23.z.discriminatedUnion("type", [And2, Or2]);
2943
- var CountryConfigQueryInputType = import_zod23.z.union([
3592
+ var CountryConfigQueryType = import_zod26.z.discriminatedUnion("type", [And2, Or2]);
3593
+ var CountryConfigQueryInputType = import_zod26.z.union([
2944
3594
  SerializedQueryExpression,
2945
3595
  And2,
2946
3596
  Or2
2947
3597
  ]);
2948
3598
 
2949
3599
  // ../commons/src/icons.ts
2950
- var import_zod24 = require("zod");
2951
- var AvailableIcons = import_zod24.z.enum([
3600
+ var import_zod27 = require("zod");
3601
+ var AvailableIcons = import_zod27.z.enum([
2952
3602
  "Archived",
2953
3603
  "Assigned",
2954
3604
  "Certified",
@@ -2986,7 +3636,6 @@ var AvailableIcons = import_zod24.z.enum([
2986
3636
  "Copy",
2987
3637
  "Database",
2988
3638
  "DotsThreeVertical",
2989
- "DownloadSimple",
2990
3639
  "ArrowCounterClockwise",
2991
3640
  "MagnifyingGlassMinus",
2992
3641
  "MagnifyingGlassPlus",
@@ -3070,38 +3719,42 @@ var mandatoryColumns = defineWorkqueuesColumns([
3070
3719
  value: event.field("updatedAt")
3071
3720
  }
3072
3721
  ]);
3073
- var WorkqueueActionsWithDefault = import_zod25.z.enum([
3722
+ var WorkqueueActionsWithDefault = import_zod28.z.enum([
3074
3723
  ...workqueueActions.options,
3075
3724
  "DEFAULT"
3076
3725
  ]);
3077
- var WorkqueueConfig = import_zod25.z.object({
3078
- slug: import_zod25.z.string().describe("Determines the url of the workqueue."),
3726
+ var WorkqueueConfig = import_zod28.z.object({
3727
+ slug: import_zod28.z.string().describe("Determines the url of the workqueue."),
3079
3728
  name: TranslationConfig.describe(
3080
3729
  "Title of the workflow (both in navigation and on the page)"
3081
3730
  ),
3082
3731
  query: CountryConfigQueryType,
3083
- actions: import_zod25.z.array(
3084
- import_zod25.z.object({
3732
+ actions: import_zod28.z.array(
3733
+ import_zod28.z.object({
3085
3734
  type: WorkqueueActionsWithDefault,
3086
- conditionals: import_zod25.z.array(Conditional).optional()
3735
+ conditionals: import_zod28.z.array(Conditional).optional()
3087
3736
  })
3088
3737
  ),
3089
- columns: import_zod25.z.array(WorkqueueColumn).default(mandatoryColumns),
3738
+ columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
3090
3739
  icon: AvailableIcons
3091
3740
  }).describe("Configuration for workqueue.");
3092
- var WorkqueueConfigInput = import_zod25.z.object({
3093
- slug: import_zod25.z.string().describe("Determines the url of the workqueue."),
3741
+ var WorkqueueConfigWithoutQuery = WorkqueueConfig.omit({
3742
+ query: true,
3743
+ columns: true
3744
+ });
3745
+ var WorkqueueConfigInput = import_zod28.z.object({
3746
+ slug: import_zod28.z.string().describe("Determines the url of the workqueue."),
3094
3747
  name: TranslationConfig.describe(
3095
3748
  "Title of the workflow (both in navigation and on the page)"
3096
3749
  ),
3097
3750
  query: CountryConfigQueryInputType,
3098
- actions: import_zod25.z.array(
3099
- import_zod25.z.object({
3751
+ actions: import_zod28.z.array(
3752
+ import_zod28.z.object({
3100
3753
  type: WorkqueueActionsWithDefault,
3101
- conditionals: import_zod25.z.array(Conditional).optional()
3754
+ conditionals: import_zod28.z.array(Conditional).optional()
3102
3755
  })
3103
3756
  ),
3104
- columns: import_zod25.z.array(WorkqueueColumn).default(mandatoryColumns),
3757
+ columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
3105
3758
  icon: AvailableIcons
3106
3759
  });
3107
3760
  function defineWorkqueue(workqueueInput) {
@@ -3112,10 +3765,10 @@ function defineWorkqueue(workqueueInput) {
3112
3765
  function defineWorkqueues(workqueues) {
3113
3766
  return workqueues.map((workqueue) => defineWorkqueue(workqueue));
3114
3767
  }
3115
- var WorkqueueCountInput = import_zod25.z.array(
3116
- import_zod25.z.object({ slug: import_zod25.z.string(), query: QueryType })
3768
+ var WorkqueueCountInput = import_zod28.z.array(
3769
+ import_zod28.z.object({ slug: import_zod28.z.string(), query: QueryType })
3117
3770
  );
3118
- var WorkqueueCountOutput = import_zod25.z.record(import_zod25.z.string(), import_zod25.z.number());
3771
+ var WorkqueueCountOutput = import_zod28.z.record(import_zod28.z.string(), import_zod28.z.number());
3119
3772
 
3120
3773
  // ../commons/src/events/workqueueDefaultColumns.ts
3121
3774
  var defaultWorkqueueColumns = [
@@ -3138,115 +3791,115 @@ var defaultWorkqueueColumns = [
3138
3791
  ];
3139
3792
 
3140
3793
  // ../commons/src/events/Draft.ts
3141
- var import_zod27 = require("zod");
3794
+ var import_zod30 = require("zod");
3142
3795
 
3143
3796
  // ../commons/src/events/ActionInput.ts
3144
- var import_zod26 = require("zod");
3145
- var import_zod_openapi10 = require("zod-openapi");
3146
- var import_uuid3 = require("uuid");
3147
- (0, import_zod_openapi10.extendZodWithOpenApi)(import_zod26.z);
3148
- var BaseActionInput = import_zod26.z.object({
3149
- eventId: import_zod26.z.string(),
3150
- transactionId: import_zod26.z.string(),
3797
+ var import_zod29 = require("zod");
3798
+ var import_zod_openapi11 = require("zod-openapi");
3799
+ (0, import_zod_openapi11.extendZodWithOpenApi)(import_zod29.z);
3800
+ var BaseActionInput = import_zod29.z.object({
3801
+ eventId: UUID,
3802
+ transactionId: import_zod29.z.string(),
3151
3803
  declaration: ActionUpdate.default({}),
3152
3804
  annotation: ActionUpdate.optional(),
3153
- originalActionId: import_zod26.z.string().optional(),
3154
- keepAssignment: import_zod26.z.boolean().optional()
3805
+ originalActionId: UUID.optional(),
3806
+ // should not be part of base action.
3807
+ keepAssignment: import_zod29.z.boolean().optional()
3155
3808
  });
3156
3809
  var CreateActionInput = BaseActionInput.merge(
3157
- import_zod26.z.object({
3158
- type: import_zod26.z.literal(ActionType.CREATE).default(ActionType.CREATE),
3810
+ import_zod29.z.object({
3811
+ type: import_zod29.z.literal(ActionType.CREATE).default(ActionType.CREATE),
3159
3812
  createdAtLocation: CreatedAtLocation
3160
3813
  })
3161
3814
  );
3162
3815
  var RegisterActionInput = BaseActionInput.merge(
3163
- import_zod26.z.object({
3164
- type: import_zod26.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
3165
- registrationNumber: import_zod26.z.string().optional()
3816
+ import_zod29.z.object({
3817
+ type: import_zod29.z.literal(ActionType.REGISTER).default(ActionType.REGISTER),
3818
+ registrationNumber: import_zod29.z.string().optional()
3166
3819
  })
3167
- );
3820
+ ).strict();
3168
3821
  var ValidateActionInput = BaseActionInput.merge(
3169
- import_zod26.z.object({
3170
- type: import_zod26.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
3171
- duplicates: import_zod26.z.array(import_zod26.z.string())
3822
+ import_zod29.z.object({
3823
+ type: import_zod29.z.literal(ActionType.VALIDATE).default(ActionType.VALIDATE),
3824
+ duplicates: import_zod29.z.array(import_zod29.z.string())
3172
3825
  })
3173
3826
  );
3174
3827
  var NotifyActionInput = BaseActionInput.merge(
3175
- import_zod26.z.object({
3176
- type: import_zod26.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
3828
+ import_zod29.z.object({
3829
+ type: import_zod29.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
3177
3830
  })
3178
3831
  ).openapi({
3179
3832
  default: {
3180
3833
  eventId: "<event-id-here>",
3181
- transactionId: (0, import_uuid3.v4)(),
3834
+ transactionId: getUUID(),
3182
3835
  declaration: {},
3183
3836
  annotation: {},
3184
3837
  type: ActionType.NOTIFY
3185
3838
  }
3186
3839
  });
3187
3840
  var DeclareActionInput = BaseActionInput.merge(
3188
- import_zod26.z.object({
3189
- type: import_zod26.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
3841
+ import_zod29.z.object({
3842
+ type: import_zod29.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
3190
3843
  })
3191
3844
  );
3192
3845
  var PrintCertificateActionInput = BaseActionInput.merge(
3193
- import_zod26.z.object({
3194
- type: import_zod26.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
3846
+ import_zod29.z.object({
3847
+ type: import_zod29.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
3195
3848
  })
3196
3849
  );
3197
3850
  var RejectDeclarationActionInput = BaseActionInput.merge(
3198
- import_zod26.z.object({
3199
- type: import_zod26.z.literal(ActionType.REJECT).default(ActionType.REJECT),
3851
+ import_zod29.z.object({
3852
+ type: import_zod29.z.literal(ActionType.REJECT).default(ActionType.REJECT),
3200
3853
  reason: RejectionReason
3201
3854
  })
3202
3855
  );
3203
3856
  var MarkedAsDuplicateActionInput = BaseActionInput.merge(
3204
- import_zod26.z.object({
3205
- type: import_zod26.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
3857
+ import_zod29.z.object({
3858
+ type: import_zod29.z.literal(ActionType.MARKED_AS_DUPLICATE).default(ActionType.MARKED_AS_DUPLICATE)
3206
3859
  })
3207
3860
  );
3208
3861
  var ArchiveActionInput = BaseActionInput.merge(
3209
- import_zod26.z.object({
3210
- type: import_zod26.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
3862
+ import_zod29.z.object({
3863
+ type: import_zod29.z.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
3211
3864
  reason: RejectionReason
3212
3865
  })
3213
3866
  );
3214
3867
  var AssignActionInput = BaseActionInput.merge(
3215
- import_zod26.z.object({
3216
- type: import_zod26.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
3217
- assignedTo: import_zod26.z.string()
3868
+ import_zod29.z.object({
3869
+ type: import_zod29.z.literal(ActionType.ASSIGN).default(ActionType.ASSIGN),
3870
+ assignedTo: import_zod29.z.string()
3218
3871
  })
3219
3872
  );
3220
3873
  var UnassignActionInput = BaseActionInput.merge(
3221
- import_zod26.z.object({
3222
- type: import_zod26.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
3223
- assignedTo: import_zod26.z.literal(null).default(null)
3874
+ import_zod29.z.object({
3875
+ type: import_zod29.z.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
3876
+ assignedTo: import_zod29.z.literal(null).default(null)
3224
3877
  })
3225
3878
  );
3226
3879
  var RequestCorrectionActionInput = BaseActionInput.merge(
3227
- import_zod26.z.object({
3228
- type: import_zod26.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
3880
+ import_zod29.z.object({
3881
+ type: import_zod29.z.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
3229
3882
  })
3230
3883
  );
3231
3884
  var RejectCorrectionActionInput = BaseActionInput.merge(
3232
- import_zod26.z.object({
3233
- requestId: import_zod26.z.string(),
3234
- type: import_zod26.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
3885
+ import_zod29.z.object({
3886
+ requestId: import_zod29.z.string(),
3887
+ type: import_zod29.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
3235
3888
  })
3236
3889
  );
3237
3890
  var ApproveCorrectionActionInput = BaseActionInput.merge(
3238
- import_zod26.z.object({
3239
- requestId: import_zod26.z.string(),
3240
- type: import_zod26.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
3891
+ import_zod29.z.object({
3892
+ requestId: import_zod29.z.string(),
3893
+ type: import_zod29.z.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
3241
3894
  })
3242
3895
  );
3243
3896
  var ReadActionInput = BaseActionInput.merge(
3244
- import_zod26.z.object({
3245
- type: import_zod26.z.literal(ActionType.READ).default(ActionType.READ)
3897
+ import_zod29.z.object({
3898
+ type: import_zod29.z.literal(ActionType.READ).default(ActionType.READ)
3246
3899
  })
3247
3900
  );
3248
- var DeleteActionInput = import_zod26.z.object({ eventId: import_zod26.z.string() });
3249
- var ActionInput = import_zod26.z.discriminatedUnion("type", [
3901
+ var DeleteActionInput = import_zod29.z.object({ eventId: UUID });
3902
+ var ActionInput = import_zod29.z.discriminatedUnion("type", [
3250
3903
  CreateActionInput.openapi({ ref: "CreateActionInput" }),
3251
3904
  ValidateActionInput.openapi({ ref: "ValidateActionInput" }),
3252
3905
  RegisterActionInput.openapi({ ref: "RegisterActionInput" }),
@@ -3275,18 +3928,18 @@ var ActionInput = import_zod26.z.discriminatedUnion("type", [
3275
3928
  });
3276
3929
 
3277
3930
  // ../commons/src/events/Draft.ts
3278
- var Draft = import_zod27.z.object({
3279
- id: import_zod27.z.string(),
3280
- eventId: import_zod27.z.string(),
3281
- transactionId: import_zod27.z.string(),
3282
- createdAt: import_zod27.z.string().datetime(),
3931
+ var Draft = import_zod30.z.object({
3932
+ id: UUID,
3933
+ eventId: UUID,
3934
+ transactionId: import_zod30.z.string(),
3935
+ createdAt: import_zod30.z.string().datetime(),
3283
3936
  action: ActionBase.extend({
3284
3937
  type: ActionTypes
3285
3938
  }).omit({ id: true })
3286
3939
  });
3287
3940
  var DraftInput = BaseActionInput.extend({
3288
3941
  type: ActionTypes,
3289
- status: import_zod27.z.enum([
3942
+ status: import_zod30.z.enum([
3290
3943
  ActionStatus.Requested,
3291
3944
  ActionStatus.Accepted,
3292
3945
  ActionStatus.Rejected
@@ -3294,27 +3947,28 @@ var DraftInput = BaseActionInput.extend({
3294
3947
  });
3295
3948
 
3296
3949
  // ../commons/src/events/EventInput.ts
3297
- var import_zod28 = require("zod");
3298
- var import_uuid4 = require("uuid");
3299
- var EventInput = import_zod28.z.object({
3300
- transactionId: import_zod28.z.string(),
3301
- type: import_zod28.z.string()
3302
- }).openapi({ default: { transactionId: (0, import_uuid4.v4)(), type: "v2.birth" } });
3950
+ var import_zod31 = require("zod");
3951
+ var import_uuid8 = require("uuid");
3952
+ var EventInput = import_zod31.z.object({
3953
+ transactionId: import_zod31.z.string(),
3954
+ type: import_zod31.z.string()
3955
+ }).openapi({ default: { transactionId: (0, import_uuid8.v4)(), type: "v2.birth" } });
3303
3956
 
3304
3957
  // ../commons/src/events/EventDocument.ts
3305
- var import_zod29 = require("zod");
3306
- var import_zod_openapi11 = require("zod-openapi");
3307
- (0, import_zod_openapi11.extendZodWithOpenApi)(import_zod29.z);
3308
- var EventDocument = import_zod29.z.object({
3309
- id: import_zod29.z.string(),
3310
- type: import_zod29.z.string(),
3311
- createdAt: import_zod29.z.string().datetime(),
3312
- updatedAt: import_zod29.z.string().datetime(),
3313
- actions: import_zod29.z.array(Action),
3314
- trackingId: import_zod29.z.string()
3958
+ var import_zod32 = require("zod");
3959
+ var import_zod_openapi12 = require("zod-openapi");
3960
+ (0, import_zod_openapi12.extendZodWithOpenApi)(import_zod32.z);
3961
+ var EventDocument = import_zod32.z.object({
3962
+ id: UUID,
3963
+ type: import_zod32.z.string(),
3964
+ createdAt: import_zod32.z.string().datetime(),
3965
+ updatedAt: import_zod32.z.string().datetime(),
3966
+ actions: import_zod32.z.array(Action),
3967
+ trackingId: import_zod32.z.string()
3315
3968
  }).openapi({ ref: "EventDocument" });
3316
3969
 
3317
3970
  // ../commons/src/events/state/utils.ts
3971
+ var import_lodash2 = require("lodash");
3318
3972
  function getActionRequests(actionType, actions) {
3319
3973
  const filtered = actions.filter((action) => action.type === actionType);
3320
3974
  const accept = filtered.find(
@@ -3345,6 +3999,7 @@ function getDeclarationActionCreationMetadata(actionType, actions) {
3345
3999
  // When 3rd party API returns 200 OK, we assume that the request was accepted, and persist single 'accepted' action.
3346
4000
  createdAt: requestAction?.createdAt ?? acceptAction.createdAt,
3347
4001
  createdBy: requestAction?.createdBy ?? acceptAction.createdBy,
4002
+ createdByUserType: requestAction?.createdByUserType ?? acceptAction.createdByUserType,
3348
4003
  createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
3349
4004
  acceptedAt: acceptAction.createdAt,
3350
4005
  createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
@@ -3352,27 +4007,38 @@ function getDeclarationActionCreationMetadata(actionType, actions) {
3352
4007
  registrationNumber
3353
4008
  };
3354
4009
  }
3355
- function getDeclarationActionUpdateMetadata(actions) {
4010
+ var updateActions = ActionTypes.extract([
4011
+ ActionType.CREATE,
4012
+ ActionType.NOTIFY,
4013
+ ActionType.DECLARE,
4014
+ ActionType.VALIDATE,
4015
+ ActionType.REGISTER,
4016
+ ActionType.REJECT,
4017
+ ActionType.ARCHIVE,
4018
+ ActionType.PRINT_CERTIFICATE,
4019
+ ActionType.REQUEST_CORRECTION
4020
+ ]);
4021
+ function getActionUpdateMetadata(actions) {
3356
4022
  const createAction = getOrThrow(
3357
4023
  actions.find((action) => action.type === ActionType.CREATE),
3358
4024
  `Event has no ${ActionType.CREATE} action`
3359
4025
  );
3360
- return [ActionType.DECLARE, ActionType.VALIDATE, ActionType.REGISTER].reduce(
3361
- (metadata, actionType) => {
3362
- const { accept, request } = getActionRequests(actionType, actions);
3363
- return {
3364
- createdAt: request?.createdAt ?? accept?.createdAt ?? metadata.createdAt,
3365
- createdBy: request?.createdBy ?? accept?.createdBy ?? metadata.createdBy,
3366
- createdAtLocation: request?.createdAtLocation ?? accept?.createdAtLocation ?? metadata.createdAtLocation,
3367
- createdByRole: request?.createdByRole ?? accept?.createdByRole ?? metadata.createdByRole
3368
- };
4026
+ const metadataFields = [
4027
+ "createdAt",
4028
+ "createdBy",
4029
+ "createdByUserType",
4030
+ "createdAtLocation",
4031
+ "createdByRole"
4032
+ ];
4033
+ return actions.filter(({ type }) => updateActions.safeParse(type).success).filter(({ status }) => status === ActionStatus.Accepted).reduce(
4034
+ (_, action) => {
4035
+ if (action.originalActionId) {
4036
+ const originalAction = actions.find(({ id }) => id === action.originalActionId) ?? action;
4037
+ return (0, import_lodash2.pick)(originalAction, metadataFields);
4038
+ }
4039
+ return (0, import_lodash2.pick)(action, metadataFields);
3369
4040
  },
3370
- {
3371
- createdAt: createAction.createdAt,
3372
- createdBy: createAction.createdBy,
3373
- createdAtLocation: createAction.createdAtLocation,
3374
- createdByRole: createAction.createdByRole
3375
- }
4041
+ (0, import_lodash2.pick)(createAction, metadataFields)
3376
4042
  );
3377
4043
  }
3378
4044
  function getLegalStatuses(actions) {
@@ -3388,15 +4054,69 @@ function getLegalStatuses(actions) {
3388
4054
  };
3389
4055
  }
3390
4056
 
3391
- // ../commons/src/events/state/index.ts
3392
- function getStatusFromActions(actions) {
3393
- const hasRejectedAction = actions.some(
3394
- (a) => a.status === ActionStatus.Rejected
4057
+ // ../commons/src/events/state/flags.ts
4058
+ function isCertificatePrinted(actions) {
4059
+ return actions.reduce((prev, { type }) => {
4060
+ if (type === ActionType.PRINT_CERTIFICATE) {
4061
+ return true;
4062
+ }
4063
+ if (type === ActionType.APPROVE_CORRECTION) {
4064
+ return false;
4065
+ }
4066
+ return prev;
4067
+ }, false);
4068
+ }
4069
+ function isCorrectionRequested(actions) {
4070
+ return actions.reduce((prev, { type }) => {
4071
+ if (type === ActionType.REQUEST_CORRECTION) {
4072
+ return true;
4073
+ }
4074
+ if (type === ActionType.APPROVE_CORRECTION) {
4075
+ return false;
4076
+ }
4077
+ if (type === ActionType.REJECT_CORRECTION) {
4078
+ return false;
4079
+ }
4080
+ return prev;
4081
+ }, false);
4082
+ }
4083
+ function isDeclarationIncomplete(actions) {
4084
+ return getStatusFromActions(actions) === EventStatus.enum.NOTIFIED;
4085
+ }
4086
+ function isRejected(actions) {
4087
+ return getStatusFromActions(actions) === EventStatus.enum.REJECTED;
4088
+ }
4089
+ function getFlagsFromActions(actions) {
4090
+ const sortedActions = actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
4091
+ const actionStatus = sortedActions.reduce(
4092
+ (actionStatuses, { type, status }) => ({
4093
+ ...actionStatuses,
4094
+ [type]: status
4095
+ }),
4096
+ {}
3395
4097
  );
3396
- if (hasRejectedAction) {
3397
- return EventStatus.enum.REJECTED;
4098
+ const flags = Object.entries(actionStatus).filter(([, status]) => status !== ActionStatus.Accepted).map(([type, status]) => {
4099
+ const flag = joinValues([type, status], ":").toLowerCase();
4100
+ return flag;
4101
+ });
4102
+ if (isCertificatePrinted(sortedActions)) {
4103
+ flags.push(InherentFlags.PRINTED);
4104
+ }
4105
+ if (isCorrectionRequested(sortedActions)) {
4106
+ flags.push(InherentFlags.CORRECTION_REQUESTED);
3398
4107
  }
3399
- return actions.reduce((status, action) => {
4108
+ if (isDeclarationIncomplete(sortedActions)) {
4109
+ flags.push(InherentFlags.INCOMPLETE);
4110
+ }
4111
+ if (isRejected(sortedActions)) {
4112
+ flags.push(InherentFlags.REJECTED);
4113
+ }
4114
+ return flags;
4115
+ }
4116
+
4117
+ // ../commons/src/events/state/index.ts
4118
+ function getStatusFromActions(actions) {
4119
+ return actions.filter(({ status }) => status === ActionStatus.Accepted).reduce((status, action) => {
3400
4120
  switch (action.type) {
3401
4121
  case ActionType.CREATE:
3402
4122
  return EventStatus.enum.CREATED;
@@ -3426,38 +4146,6 @@ function getStatusFromActions(actions) {
3426
4146
  }
3427
4147
  }, EventStatus.enum.CREATED);
3428
4148
  }
3429
- function getFlagsFromActions(actions) {
3430
- const sortedactions = actions.sort(
3431
- (a, b) => a.createdAt.localeCompare(b.createdAt)
3432
- );
3433
- const actionStatus = sortedactions.reduce(
3434
- (actionStatuses, { type, status }) => ({
3435
- ...actionStatuses,
3436
- [type]: status
3437
- }),
3438
- {}
3439
- );
3440
- const flags = Object.entries(actionStatus).filter(([, status]) => status !== ActionStatus.Accepted).map(([type, status]) => {
3441
- const flag = `${type.toLowerCase()}:${status.toLowerCase()}`;
3442
- return flag;
3443
- });
3444
- const isCertificatePrinted = sortedactions.reduce(
3445
- (prev, { type }) => {
3446
- if (type === ActionType.PRINT_CERTIFICATE) {
3447
- return true;
3448
- }
3449
- if (type === ActionType.APPROVE_CORRECTION) {
3450
- return false;
3451
- }
3452
- return prev;
3453
- },
3454
- false
3455
- );
3456
- if (isCertificatePrinted) {
3457
- flags.push(CustomFlags.CERTIFICATE_PRINTED);
3458
- }
3459
- return flags;
3460
- }
3461
4149
  function getAssignedUserFromActions(actions) {
3462
4150
  return actions.reduce((user2, action) => {
3463
4151
  if (action.type === ActionType.ASSIGN) {
@@ -3524,6 +4212,13 @@ function getAcceptedActions(event2) {
3524
4212
  );
3525
4213
  }
3526
4214
  var DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
4215
+ function resolveDateOfEvent(eventMetadata, declaration, config) {
4216
+ if (!config.dateOfEvent) {
4217
+ return eventMetadata[DEFAULT_DATE_OF_EVENT_PROPERTY].split("T")[0];
4218
+ }
4219
+ const parsedDate = ZodDate.safeParse(declaration[config.dateOfEvent.$$field]);
4220
+ return parsedDate.success ? parsedDate.data : void 0;
4221
+ }
3527
4222
  function getCurrentEventState(event2, config) {
3528
4223
  const creationAction = event2.actions.find(
3529
4224
  (action) => action.type === ActionType.CREATE
@@ -3531,22 +4226,12 @@ function getCurrentEventState(event2, config) {
3531
4226
  if (!creationAction) {
3532
4227
  throw new Error(`Event ${event2.id} has no creation action`);
3533
4228
  }
3534
- const acceptedActions = getAcceptedActions(event2);
3535
- const declarationUpdateMetadata = getDeclarationActionUpdateMetadata(
3536
- event2.actions
4229
+ const acceptedActions = getAcceptedActions(event2).sort(
4230
+ (a, b) => a.createdAt.localeCompare(b.createdAt)
3537
4231
  );
4232
+ const requestActionMetadata = getActionUpdateMetadata(event2.actions);
4233
+ const acceptedActionMetadata = getActionUpdateMetadata(acceptedActions);
3538
4234
  const declaration = aggregateActionDeclarations(acceptedActions);
3539
- let dateOfEvent;
3540
- if (config.dateOfEvent) {
3541
- const parsedDate = ZodDate.safeParse(
3542
- declaration[config.dateOfEvent.$$field]
3543
- );
3544
- if (parsedDate.success) {
3545
- dateOfEvent = parsedDate.data;
3546
- }
3547
- } else {
3548
- dateOfEvent = event2[DEFAULT_DATE_OF_EVENT_PROPERTY].split("T")[0];
3549
- }
3550
4235
  return deepDropNulls({
3551
4236
  id: event2.id,
3552
4237
  type: event2.type,
@@ -3554,17 +4239,18 @@ function getCurrentEventState(event2, config) {
3554
4239
  legalStatuses: getLegalStatuses(event2.actions),
3555
4240
  createdAt: creationAction.createdAt,
3556
4241
  createdBy: creationAction.createdBy,
4242
+ createdByUserType: creationAction.createdByUserType,
3557
4243
  createdAtLocation: creationAction.createdAtLocation,
3558
4244
  createdBySignature: creationAction.createdBySignature,
3559
- updatedAt: declarationUpdateMetadata.createdAt,
4245
+ updatedAt: acceptedActionMetadata.createdAt,
3560
4246
  assignedTo: getAssignedUserFromActions(acceptedActions),
3561
4247
  assignedToSignature: getAssignedUserSignatureFromActions(acceptedActions),
3562
- updatedBy: declarationUpdateMetadata.createdBy,
3563
- updatedAtLocation: declarationUpdateMetadata.createdAtLocation,
4248
+ updatedBy: requestActionMetadata.createdBy,
4249
+ updatedAtLocation: requestActionMetadata.createdAtLocation,
3564
4250
  declaration,
3565
4251
  trackingId: event2.trackingId,
3566
- updatedByUserRole: declarationUpdateMetadata.createdByRole,
3567
- dateOfEvent,
4252
+ updatedByUserRole: requestActionMetadata.createdByRole,
4253
+ dateOfEvent: resolveDateOfEvent(event2, declaration, config),
3568
4254
  flags: getFlagsFromActions(event2.actions)
3569
4255
  });
3570
4256
  }
@@ -3593,19 +4279,29 @@ function getCurrentEventStateWithDrafts({
3593
4279
  };
3594
4280
  return getCurrentEventState(withDrafts, configuration);
3595
4281
  }
3596
- function applyDraftsToEventIndex(eventIndex, drafts) {
4282
+ function applyDeclarationToEventIndex(eventIndex, declaration, eventConfiguration) {
4283
+ const updatedDeclaration = deepMerge(eventIndex.declaration, declaration);
4284
+ return {
4285
+ ...eventIndex,
4286
+ dateOfEvent: resolveDateOfEvent(
4287
+ eventIndex,
4288
+ updatedDeclaration,
4289
+ eventConfiguration
4290
+ ),
4291
+ declaration: updatedDeclaration
4292
+ };
4293
+ }
4294
+ function applyDraftsToEventIndex(eventIndex, drafts, eventConfiguration) {
3597
4295
  const indexedAt = eventIndex.updatedAt;
3598
4296
  const activeDrafts = drafts.filter(({ createdAt }) => new Date(createdAt) > new Date(indexedAt)).map((draft) => draft.action).sort();
3599
4297
  if (activeDrafts.length === 0) {
3600
4298
  return eventIndex;
3601
4299
  }
3602
- return {
3603
- ...eventIndex,
3604
- declaration: {
3605
- ...eventIndex.declaration,
3606
- ...activeDrafts[activeDrafts.length - 1].declaration
3607
- }
3608
- };
4300
+ return applyDeclarationToEventIndex(
4301
+ eventIndex,
4302
+ activeDrafts[activeDrafts.length - 1].declaration,
4303
+ eventConfiguration
4304
+ );
3609
4305
  }
3610
4306
  function getAnnotationFromDrafts(drafts) {
3611
4307
  const actions = drafts.map((draft) => draft.action);
@@ -3646,23 +4342,24 @@ function generateTransactionId() {
3646
4342
  }
3647
4343
 
3648
4344
  // ../commons/src/events/User.ts
3649
- var import_zod30 = require("zod");
3650
- var User = import_zod30.z.object({
3651
- id: import_zod30.z.string(),
3652
- name: import_zod30.z.array(
3653
- import_zod30.z.object({
3654
- use: import_zod30.z.string(),
3655
- given: import_zod30.z.array(import_zod30.z.string()),
3656
- family: import_zod30.z.string()
4345
+ var import_zod33 = require("zod");
4346
+ var User = import_zod33.z.object({
4347
+ id: import_zod33.z.string(),
4348
+ name: import_zod33.z.array(
4349
+ import_zod33.z.object({
4350
+ use: import_zod33.z.string(),
4351
+ given: import_zod33.z.array(import_zod33.z.string()),
4352
+ family: import_zod33.z.string()
3657
4353
  })
3658
4354
  ),
3659
- role: import_zod30.z.string(),
3660
- signatureFilename: import_zod30.z.string().optional()
4355
+ role: import_zod33.z.string(),
4356
+ avatar: FullDocumentPath.optional(),
4357
+ signature: FullDocumentPath.optional()
3661
4358
  });
3662
4359
 
3663
4360
  // ../commons/src/events/test.utils.ts
3664
- var import_lodash2 = require("lodash");
3665
- var import_addDays = __toESM(require("date-fns/addDays"));
4361
+ var import_lodash3 = require("lodash");
4362
+ var import_date_fns4 = require("date-fns");
3666
4363
 
3667
4364
  // ../commons/src/field-config/field-configuration.ts
3668
4365
  function createFieldConfig(fieldId, options) {
@@ -3683,7 +4380,7 @@ function field(fieldId, options = {}) {
3683
4380
  }
3684
4381
 
3685
4382
  // ../commons/src/fixtures/forms.ts
3686
- var import_date_fns2 = require("date-fns");
4383
+ var import_date_fns3 = require("date-fns");
3687
4384
  var PRINT_CERTIFICATE_FORM = defineActionForm({
3688
4385
  label: {
3689
4386
  id: "v2.event.tennis-club-membership.action.certificate.form.label",
@@ -4342,7 +5039,7 @@ var PRINT_CERTIFICATE_FORM = defineActionForm({
4342
5039
  var TENNIS_CLUB_DECLARATION_REVIEW = {
4343
5040
  title: {
4344
5041
  id: "v2.event.tennis-club-membership.action.declare.form.review.title",
4345
- defaultMessage: "{applicant.name.firstname, select, __EMPTY__ {Member declaration} other {{applicant.name.surname, select, __EMPTY__ {Member declaration} other {Member declaration for {applicant.name.firstname} {applicant.name.surname}}}}}",
5042
+ defaultMessage: "{applicant.name.firstname, select, __EMPTY__ {Member declaration} other {{applicant.name.surname, select, __EMPTY__ {Member declaration for {applicant.name.firstname}} other {Member declaration for {applicant.name.firstname} {applicant.name.surname}}}}}",
4346
5043
  description: "Title of the review page"
4347
5044
  },
4348
5045
  fields: [
@@ -4481,6 +5178,7 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
4481
5178
  id: "applicant.address",
4482
5179
  type: "ADDRESS",
4483
5180
  required: true,
5181
+ secured: true,
4484
5182
  conditionals: [],
4485
5183
  label: {
4486
5184
  defaultMessage: "Applicant's address",
@@ -4648,7 +5346,7 @@ var timePeriodOptions = [
4648
5346
  description: "Label for option of time period select: last 7 days",
4649
5347
  id: "form.section.label.timePeriodLast7Days"
4650
5348
  },
4651
- value: `${(0, import_date_fns2.format)((0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 7), "yyyy-MM-dd")},${(0, import_date_fns2.format)(
5349
+ value: `${(0, import_date_fns3.format)((0, import_date_fns3.subDays)(/* @__PURE__ */ new Date(), 7), "yyyy-MM-dd")},${(0, import_date_fns3.format)(
4652
5350
  /* @__PURE__ */ new Date(),
4653
5351
  "yyyy-MM-dd"
4654
5352
  )}`
@@ -4659,7 +5357,7 @@ var timePeriodOptions = [
4659
5357
  description: "Label for option of time period select: last 30 days",
4660
5358
  id: "form.section.label.timePeriodLast30Days"
4661
5359
  },
4662
- value: `${(0, import_date_fns2.format)((0, import_date_fns2.subMonths)(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd")},${(0, import_date_fns2.format)(
5360
+ value: `${(0, import_date_fns3.format)((0, import_date_fns3.subMonths)(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd")},${(0, import_date_fns3.format)(
4663
5361
  /* @__PURE__ */ new Date(),
4664
5362
  "yyyy-MM-dd"
4665
5363
  )}`
@@ -4670,7 +5368,7 @@ var timePeriodOptions = [
4670
5368
  description: "Label for option of time period select: last 90 days",
4671
5369
  id: "form.section.label.timePeriodLast90Days"
4672
5370
  },
4673
- value: `${(0, import_date_fns2.format)((0, import_date_fns2.subQuarters)(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd")},${(0, import_date_fns2.format)(
5371
+ value: `${(0, import_date_fns3.format)((0, import_date_fns3.subQuarters)(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd")},${(0, import_date_fns3.format)(
4674
5372
  /* @__PURE__ */ new Date(),
4675
5373
  "yyyy-MM-dd"
4676
5374
  )}`
@@ -4681,7 +5379,7 @@ var timePeriodOptions = [
4681
5379
  description: "Label for option of time period select: last year",
4682
5380
  id: "form.section.label.timePeriodLastYear"
4683
5381
  },
4684
- value: `${(0, import_date_fns2.format)((0, import_date_fns2.subYears)(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd")},${(0, import_date_fns2.format)(
5382
+ value: `${(0, import_date_fns3.format)((0, import_date_fns3.subYears)(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd")},${(0, import_date_fns3.format)(
4685
5383
  /* @__PURE__ */ new Date(),
4686
5384
  "yyyy-MM-dd"
4687
5385
  )}`
@@ -5038,10 +5736,10 @@ var tennisClubMembershipEvent = defineConfig({
5038
5736
  id: "v2.advancedSearch.form.registrationDetails"
5039
5737
  },
5040
5738
  fields: [
5041
- event("legalStatus.REGISTERED.createdAtLocation").exact(),
5042
- event("legalStatus.REGISTERED.createdAt").range(),
5043
- event("status", statusOptions).exact(),
5044
- event("updatedAt", timePeriodOptions).range()
5739
+ event("legalStatuses.REGISTERED.createdAtLocation").exact(),
5740
+ event("legalStatuses.REGISTERED.acceptedAt").range(),
5741
+ event("status").exact(),
5742
+ event("updatedAt").range()
5045
5743
  ]
5046
5744
  },
5047
5745
  {
@@ -5431,10 +6129,10 @@ var footballClubMembershipEvent = defineConfig({
5431
6129
  id: "v2.advancedSearch.form.registrationDetails"
5432
6130
  },
5433
6131
  fields: [
5434
- event("legalStatus.REGISTERED.createdAtLocation").exact(),
5435
- event("legalStatus.REGISTERED.createdAt").range(),
5436
- event("status", statusOptions).exact(),
5437
- event("updatedAt", timePeriodOptions).range()
6132
+ event("legalStatuses.REGISTERED.createdAtLocation").exact(),
6133
+ event("legalStatuses.REGISTERED.acceptedAt").range(),
6134
+ event("status").exact(),
6135
+ event("updatedAt").range()
5438
6136
  ]
5439
6137
  },
5440
6138
  {
@@ -5647,6 +6345,15 @@ var v2BirthEvent = defineConfig({
5647
6345
  });
5648
6346
 
5649
6347
  // ../commons/src/events/test.utils.ts
6348
+ var import_zod34 = require("zod");
6349
+ var TEST_SYSTEM_IANA_TIMEZONE = "Asia/Dhaka";
6350
+ var TestUserRole = import_zod34.z.enum([
6351
+ "FIELD_AGENT",
6352
+ "LOCAL_REGISTRAR",
6353
+ "LOCAL_SYSTEM_ADMIN",
6354
+ "NATIONAL_REGISTRAR",
6355
+ "REGISTRATION_AGENT"
6356
+ ]);
5650
6357
  function pickRandom(rng, items) {
5651
6358
  return items[Math.floor(rng() * items.length)];
5652
6359
  }
@@ -5725,14 +6432,18 @@ function mapFieldTypeToMockValue(field2, i, rng) {
5725
6432
  };
5726
6433
  case FieldType.DATE:
5727
6434
  return "2021-01-01";
6435
+ case FieldType.SELECT_DATE_RANGE:
5728
6436
  case FieldType.DATE_RANGE:
5729
- return ["2021-01-01", "2021-01-02"];
6437
+ return {
6438
+ start: "2021-01-01",
6439
+ end: "2021-01-31"
6440
+ };
5730
6441
  case FieldType.CHECKBOX:
5731
6442
  return true;
5732
6443
  case FieldType.SIGNATURE:
5733
6444
  case FieldType.FILE:
5734
6445
  return {
5735
- filename: "4f095fc4-4312-4de2-aa38-86dcc0f71044.png",
6446
+ path: "/ocrvs/4f095fc4-4312-4de2-aa38-86dcc0f71044.png",
5736
6447
  originalFilename: "abcd.png",
5737
6448
  type: "image/png"
5738
6449
  };
@@ -5795,7 +6506,11 @@ function eventPayloadGenerator(rng) {
5795
6506
  type: input.type ?? TENNIS_CLUB_MEMBERSHIP,
5796
6507
  id
5797
6508
  }),
5798
- draft: ({ eventId, actionType }, input = {}) => (0, import_lodash2.merge)(
6509
+ draft: ({
6510
+ eventId,
6511
+ actionType,
6512
+ annotation
6513
+ }, input = {}) => (0, import_lodash3.merge)(
5799
6514
  {
5800
6515
  id: getUUID(),
5801
6516
  eventId,
@@ -5815,10 +6530,12 @@ function eventPayloadGenerator(rng) {
5815
6530
  },
5816
6531
  annotation: {
5817
6532
  "correction.requester.relationship": "ANOTHER_AGENT",
5818
- "correction.request.reason": "Child's name was incorrect"
6533
+ "correction.request.reason": "Child's name was incorrect",
6534
+ ...annotation
5819
6535
  },
5820
6536
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
5821
6537
  createdBy: "@todo",
6538
+ createdByUserType: TokenUserType.Enum.user,
5822
6539
  createdByRole: "@todo",
5823
6540
  createdAtLocation: "@todo"
5824
6541
  }
@@ -5848,13 +6565,13 @@ function eventPayloadGenerator(rng) {
5848
6565
  notify: (eventId, input = {}) => {
5849
6566
  let declaration = input.declaration;
5850
6567
  if (!declaration) {
5851
- const partialDeclaration = (0, import_lodash2.omitBy)(
6568
+ const partialDeclaration = (0, import_lodash3.omitBy)(
5852
6569
  generateActionDeclarationInput(
5853
6570
  tennisClubMembershipEvent,
5854
6571
  ActionType.DECLARE,
5855
6572
  rng
5856
6573
  ),
5857
- import_lodash2.isString
6574
+ import_lodash3.isString
5858
6575
  );
5859
6576
  declaration = partialDeclaration;
5860
6577
  }
@@ -6004,16 +6721,18 @@ function generateActionDocument({
6004
6721
  configuration,
6005
6722
  action,
6006
6723
  rng = () => 0.1,
6007
- defaults = {}
6724
+ defaults = {},
6725
+ user: user2 = {}
6008
6726
  }) {
6009
6727
  const actionBase = {
6010
6728
  // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
6011
6729
  // @TODO: This should be fixed in the future.
6012
6730
  createdAt: new Date(Date.now() - 500).toISOString(),
6013
- createdBy: getUUID(),
6014
- createdByRole: "FIELD_AGENT",
6731
+ createdBy: user2.id ?? getUUID(),
6732
+ createdByUserType: TokenUserType.Enum.user,
6733
+ createdByRole: TestUserRole.Enum.FIELD_AGENT,
6015
6734
  id: getUUID(),
6016
- createdAtLocation: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
6735
+ createdAtLocation: user2.primaryOfficeId ?? "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
6017
6736
  declaration: generateActionDeclarationInput(configuration, action, rng),
6018
6737
  annotation: {},
6019
6738
  status: ActionStatus.Accepted,
@@ -6028,7 +6747,7 @@ function generateActionDocument({
6028
6747
  case ActionType.DECLARE:
6029
6748
  return { ...actionBase, type: action };
6030
6749
  case ActionType.UNASSIGN:
6031
- return { ...actionBase, type: action, assignedTo: null };
6750
+ return { ...actionBase, type: action };
6032
6751
  case ActionType.ASSIGN:
6033
6752
  return { ...actionBase, assignedTo: getUUID(), type: action };
6034
6753
  case ActionType.VALIDATE:
@@ -6067,13 +6786,14 @@ function generateActionDocument({
6067
6786
  function generateEventDocument({
6068
6787
  configuration,
6069
6788
  actions,
6070
- rng = () => 0.1
6789
+ rng = () => 0.1,
6790
+ user: user2
6071
6791
  }) {
6072
6792
  return {
6073
6793
  trackingId: getUUID(),
6074
6794
  type: configuration.id,
6075
6795
  actions: actions.map(
6076
- (action) => generateActionDocument({ configuration, action, rng })
6796
+ (action) => generateActionDocument({ configuration, action, rng, user: user2 })
6077
6797
  ),
6078
6798
  // Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
6079
6799
  // @TODO: This should be fixed in the future.
@@ -6141,7 +6861,7 @@ function createPrng(seed) {
6141
6861
  return state / MODULUS;
6142
6862
  };
6143
6863
  }
6144
- function generateUuid(rng) {
6864
+ function generateUuid(rng = () => 0.1) {
6145
6865
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
6146
6866
  const r = Math.floor(rng() * 16);
6147
6867
  const v = c === "x" ? r : r & 3 | 8;
@@ -6153,6 +6873,11 @@ function generateTrackingId(rng) {
6153
6873
  const trackingId = uuid.slice(0, 6).toUpperCase();
6154
6874
  return trackingId;
6155
6875
  }
6876
+ function generateRegistrationNumber(rng) {
6877
+ const uuid = generateUuid(rng).replace(/-/g, "");
6878
+ const registrationNumber = uuid.slice(0, 12).toUpperCase();
6879
+ return registrationNumber;
6880
+ }
6156
6881
  function generateRandomSignature(rng) {
6157
6882
  return `/random-bucket/${generateUuid(rng)}.png`;
6158
6883
  }
@@ -6168,11 +6893,12 @@ var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
6168
6893
  type: overrides.type ?? TENNIS_CLUB_MEMBERSHIP,
6169
6894
  status: overrides.status ?? pickRandom(rng, EventStatus.options),
6170
6895
  createdAt: overrides.createdAt ?? createdAt,
6896
+ createdByUserType: overrides.createdByUserType ?? "user",
6171
6897
  createdBy: overrides.createdBy ?? generateUuid(rng),
6172
6898
  createdAtLocation: overrides.createdAtLocation ?? generateUuid(rng),
6173
6899
  updatedAtLocation: overrides.updatedAtLocation ?? generateUuid(rng),
6174
6900
  createdBySignature: overrides.createdBySignature ?? generateRandomSignature(rng),
6175
- updatedAt: overrides.updatedAt ?? (0, import_addDays.default)(new Date(createdAt), 1).toISOString(),
6901
+ updatedAt: overrides.updatedAt ?? (0, import_date_fns4.addDays)(new Date(createdAt), 1).toISOString(),
6176
6902
  assignedTo: overrides.assignedTo ?? null,
6177
6903
  updatedBy: overrides.updatedBy ?? generateUuid(rng),
6178
6904
  updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
@@ -6244,235 +6970,7 @@ function isFieldConfigDefaultValue(value) {
6244
6970
  }
6245
6971
 
6246
6972
  // ../commons/src/events/scopes.ts
6247
- var import_lodash3 = require("lodash");
6248
-
6249
- // ../commons/src/scopes.ts
6250
- var import_zod31 = require("zod");
6251
- var SCOPES = {
6252
- // TODO v1.8 legacy scopes
6253
- NATLSYSADMIN: "natlsysadmin",
6254
- BYPASSRATELIMIT: "bypassratelimit",
6255
- DECLARE: "declare",
6256
- REGISTER: "register",
6257
- VALIDATE: "validate",
6258
- DEMO: "demo",
6259
- CERTIFY: "certify",
6260
- PERFORMANCE: "performance",
6261
- SYSADMIN: "sysadmin",
6262
- TEAMS: "teams",
6263
- CONFIG: "config",
6264
- // systems / integrations
6265
- WEBHOOK: "webhook",
6266
- NATIONALID: "nationalId",
6267
- NOTIFICATION_API: "notification-api",
6268
- RECORDSEARCH: "recordsearch",
6269
- /**
6270
- * @TODO This is a temporary scope to be used for V2 Events custom events declaration
6271
- */
6272
- RECORD_DECLARE: "record.declare-birth",
6273
- // declare
6274
- RECORD_IMPORT: "record.import",
6275
- // declare
6276
- RECORD_DECLARE_BIRTH: "record.declare-birth",
6277
- RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
6278
- RECORD_DECLARE_DEATH: "record.declare-death",
6279
- RECORD_DECLARE_DEATH_MY_JURISDICTION: "record.declare-death:my-jurisdiction",
6280
- RECORD_DECLARE_MARRIAGE: "record.declare-marriage",
6281
- RECORD_DECLARE_MARRIAGE_MY_JURISDICTION: "record.declare-marriage:my-jurisdiction",
6282
- RECORD_SUBMIT_INCOMPLETE: "record.declaration-submit-incomplete",
6283
- RECORD_SUBMIT_FOR_REVIEW: "record.declaration-submit-for-review",
6284
- RECORD_UNASSIGN_OTHERS: "record.unassign-others",
6285
- // validate
6286
- RECORD_SUBMIT_FOR_APPROVAL: "record.declaration-submit-for-approval",
6287
- RECORD_SUBMIT_FOR_UPDATES: "record.declaration-submit-for-updates",
6288
- RECORD_DECLARATION_EDIT: "record.declaration-edit",
6289
- RECORD_REVIEW_DUPLICATES: "record.review-duplicates",
6290
- RECORD_DECLARATION_ARCHIVE: "record.declaration-archive",
6291
- RECORD_DECLARATION_REINSTATE: "record.declaration-reinstate",
6292
- // register
6293
- RECORD_REGISTER: "record.register",
6294
- // certify
6295
- RECORD_EXPORT_RECORDS: "record.export-records",
6296
- RECORD_DECLARATION_PRINT: "record.declaration-print",
6297
- RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS: "record.declaration-print-supporting-documents",
6298
- RECORD_REGISTRATION_PRINT: "record.registration-print",
6299
- // v1.8
6300
- /**
6301
- * This scope is used to **print and **issue certified copies of a record
6302
- * after it has been registered. Previously Registrars had this permission.
6303
- */
6304
- RECORD_PRINT_ISSUE_CERTIFIED_COPIES: "record.registration-print&issue-certified-copies",
6305
- RECORD_PRINT_CERTIFIED_COPIES: "record.registration-print-certified-copies",
6306
- // v1.8
6307
- RECORD_BULK_PRINT_CERTIFIED_COPIES: "record.registration-bulk-print-certified-copies",
6308
- // v1.8
6309
- RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES: "record.registration-verify-certified-copies",
6310
- // v1.8
6311
- // correct
6312
- RECORD_REGISTRATION_REQUEST_CORRECTION: "record.registration-request-correction",
6313
- RECORD_REGISTRATION_CORRECT: "record.registration-correct",
6314
- RECORD_REGISTRATION_REQUEST_REVOCATION: "record.registration-request-revocation",
6315
- // v1.8
6316
- RECORD_REGISTRATION_REVOKE: "record.registration-revoke",
6317
- // v1.8
6318
- RECORD_REGISTRATION_REQUEST_REINSTATEMENT: "record.registration-request-reinstatement",
6319
- // v1.8
6320
- RECORD_REGISTRATION_REINSTATE: "record.registration-reinstate",
6321
- // v1.8
6322
- RECORD_CONFIRM_REGISTRATION: "record.confirm-registration",
6323
- RECORD_REJECT_REGISTRATION: "record.reject-registration",
6324
- // search
6325
- SEARCH_BIRTH_MY_JURISDICTION: "search.birth:my-jurisdiction",
6326
- SEARCH_BIRTH: "search.birth",
6327
- SEARCH_DEATH_MY_JURISDICTION: "search.death:my-jurisdiction",
6328
- SEARCH_DEATH: "search.death",
6329
- SEARCH_MARRIAGE_MY_JURISDICTION: "search.marriage:my-jurisdiction",
6330
- SEARCH_MARRIAGE: "search.marriage",
6331
- // audit v1.8
6332
- RECORD_READ: "record.read",
6333
- RECORD_READ_AUDIT: "record.read-audit",
6334
- RECORD_READ_COMMENTS: "record.read-comments",
6335
- RECORD_CREATE_COMMENTS: "record.create-comments",
6336
- // profile
6337
- PROFILE_UPDATE: "profile.update",
6338
- //v1.8
6339
- PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature",
6340
- // performance
6341
- PERFORMANCE_READ: "performance.read",
6342
- PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards",
6343
- PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export",
6344
- // organisation
6345
- ORGANISATION_READ_LOCATIONS: "organisation.read-locations:all",
6346
- ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office",
6347
- ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction",
6348
- // user
6349
- USER_READ: "user.read:all",
6350
- USER_READ_MY_OFFICE: "user.read:my-office",
6351
- USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction",
6352
- USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit",
6353
- //v1.8
6354
- USER_CREATE: "user.create:all",
6355
- USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction",
6356
- USER_UPDATE: "user.update:all",
6357
- USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction",
6358
- // config
6359
- CONFIG_UPDATE_ALL: "config.update:all",
6360
- // data seeding
6361
- USER_DATA_SEEDING: "user.data-seeding"
6362
- };
6363
- var LiteralScopes = import_zod31.z.union([
6364
- import_zod31.z.literal(SCOPES.NATLSYSADMIN),
6365
- import_zod31.z.literal(SCOPES.BYPASSRATELIMIT),
6366
- import_zod31.z.literal(SCOPES.DECLARE),
6367
- import_zod31.z.literal(SCOPES.REGISTER),
6368
- import_zod31.z.literal(SCOPES.VALIDATE),
6369
- import_zod31.z.literal(SCOPES.DEMO),
6370
- import_zod31.z.literal(SCOPES.CERTIFY),
6371
- import_zod31.z.literal(SCOPES.PERFORMANCE),
6372
- import_zod31.z.literal(SCOPES.SYSADMIN),
6373
- import_zod31.z.literal(SCOPES.TEAMS),
6374
- import_zod31.z.literal(SCOPES.CONFIG),
6375
- import_zod31.z.literal(SCOPES.WEBHOOK),
6376
- import_zod31.z.literal(SCOPES.NATIONALID),
6377
- import_zod31.z.literal(SCOPES.NOTIFICATION_API),
6378
- import_zod31.z.literal(SCOPES.RECORDSEARCH),
6379
- import_zod31.z.literal(SCOPES.RECORD_IMPORT),
6380
- import_zod31.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
6381
- import_zod31.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
6382
- import_zod31.z.literal(SCOPES.RECORD_DECLARE_DEATH),
6383
- import_zod31.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
6384
- import_zod31.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
6385
- import_zod31.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
6386
- import_zod31.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
6387
- import_zod31.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW),
6388
- import_zod31.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS),
6389
- import_zod31.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
6390
- import_zod31.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
6391
- import_zod31.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
6392
- import_zod31.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
6393
- import_zod31.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
6394
- import_zod31.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE),
6395
- import_zod31.z.literal(SCOPES.RECORD_REGISTER),
6396
- import_zod31.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
6397
- import_zod31.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
6398
- import_zod31.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
6399
- import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
6400
- import_zod31.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
6401
- import_zod31.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
6402
- import_zod31.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
6403
- import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES),
6404
- import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
6405
- import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
6406
- import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
6407
- import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
6408
- import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
6409
- import_zod31.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
6410
- import_zod31.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
6411
- import_zod31.z.literal(SCOPES.RECORD_REJECT_REGISTRATION),
6412
- import_zod31.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
6413
- import_zod31.z.literal(SCOPES.SEARCH_BIRTH),
6414
- import_zod31.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
6415
- import_zod31.z.literal(SCOPES.SEARCH_DEATH),
6416
- import_zod31.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
6417
- import_zod31.z.literal(SCOPES.SEARCH_MARRIAGE),
6418
- import_zod31.z.literal(SCOPES.RECORD_READ),
6419
- import_zod31.z.literal(SCOPES.RECORD_READ_AUDIT),
6420
- import_zod31.z.literal(SCOPES.RECORD_READ_COMMENTS),
6421
- import_zod31.z.literal(SCOPES.RECORD_CREATE_COMMENTS),
6422
- import_zod31.z.literal(SCOPES.PROFILE_UPDATE),
6423
- import_zod31.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE),
6424
- import_zod31.z.literal(SCOPES.PERFORMANCE_READ),
6425
- import_zod31.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
6426
- import_zod31.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS),
6427
- import_zod31.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
6428
- import_zod31.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
6429
- import_zod31.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION),
6430
- import_zod31.z.literal(SCOPES.USER_READ),
6431
- import_zod31.z.literal(SCOPES.USER_READ_MY_OFFICE),
6432
- import_zod31.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
6433
- import_zod31.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
6434
- import_zod31.z.literal(SCOPES.USER_CREATE),
6435
- import_zod31.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
6436
- import_zod31.z.literal(SCOPES.USER_UPDATE),
6437
- import_zod31.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION),
6438
- import_zod31.z.literal(SCOPES.CONFIG_UPDATE_ALL),
6439
- import_zod31.z.literal(SCOPES.USER_DATA_SEEDING)
6440
- ]);
6441
- var rawConfigurableScopeRegex = /^([a-zA-Z\.]+)\[((?:\w+=[\w.-]+(?:\|[\w.-]+)*)(?:,[\w]+=[\w.-]+(?:\|[\w.-]+)*)*)\]$/;
6442
- var rawConfigurableScope = import_zod31.z.string().regex(rawConfigurableScopeRegex);
6443
- var CreateUserScope = import_zod31.z.object({
6444
- type: import_zod31.z.literal("user.create"),
6445
- options: import_zod31.z.object({
6446
- role: import_zod31.z.array(import_zod31.z.string())
6447
- })
6448
- });
6449
- var EditUserScope = import_zod31.z.object({
6450
- type: import_zod31.z.literal("user.edit"),
6451
- options: import_zod31.z.object({
6452
- role: import_zod31.z.array(import_zod31.z.string())
6453
- })
6454
- });
6455
- var WorkqueueScope = import_zod31.z.object({
6456
- type: import_zod31.z.literal("workqueue"),
6457
- options: import_zod31.z.object({
6458
- id: import_zod31.z.array(import_zod31.z.string())
6459
- })
6460
- });
6461
- var NotifyRecordScope = import_zod31.z.object({
6462
- type: import_zod31.z.literal("record.notify"),
6463
- options: import_zod31.z.object({
6464
- event: import_zod31.z.array(import_zod31.z.string())
6465
- })
6466
- });
6467
- var ConfigurableScopes = import_zod31.z.discriminatedUnion("type", [
6468
- CreateUserScope,
6469
- EditUserScope,
6470
- WorkqueueScope,
6471
- NotifyRecordScope
6472
- ]);
6473
- var scopes = Object.values(SCOPES);
6474
-
6475
- // ../commons/src/events/scopes.ts
6973
+ var import_lodash4 = require("lodash");
6476
6974
  var CONFIG_GET_ALLOWED_SCOPES = [
6477
6975
  SCOPES.RECORD_DECLARE,
6478
6976
  SCOPES.RECORD_READ,
@@ -6549,36 +7047,26 @@ var ACTION_ALLOWED_CONFIGURABLE_SCOPES = {
6549
7047
  [ActionType.UNASSIGN]: [],
6550
7048
  [ActionType.DETECT_DUPLICATE]: []
6551
7049
  };
7050
+ var WRITE_ACTION_SCOPES = [
7051
+ ...ACTION_ALLOWED_SCOPES[ActionType.DECLARE],
7052
+ ...ACTION_ALLOWED_SCOPES[ActionType.VALIDATE],
7053
+ ...ACTION_ALLOWED_SCOPES[ActionType.REGISTER],
7054
+ ...ACTION_ALLOWED_SCOPES[ActionType.PRINT_CERTIFICATE]
7055
+ ];
6552
7056
  function hasAnyOfScopes(a, b) {
6553
- return (0, import_lodash3.intersection)(a, b).length > 0;
6554
- }
6555
- function filterUnallowedActions(actions, userScopes) {
6556
- const allowedActions = actions.filter((action) => {
6557
- const requiredScopes = ACTION_ALLOWED_SCOPES[action];
6558
- if (requiredScopes === null) {
6559
- return true;
6560
- }
6561
- return hasAnyOfScopes(userScopes, requiredScopes);
6562
- });
6563
- const hasOtherAllowedActions = allowedActions.some(
6564
- (action) => !isMetaAction(action)
6565
- );
6566
- if (hasOtherAllowedActions) {
6567
- return allowedActions;
6568
- }
6569
- return [ActionType.READ];
7057
+ return (0, import_lodash4.intersection)(a, b).length > 0;
6570
7058
  }
6571
7059
 
6572
7060
  // ../commons/src/events/serializers/user/deserializer.ts
6573
- var import_zod32 = require("zod");
7061
+ var import_zod35 = require("zod");
6574
7062
  var UserWithPrimaryOffice = User.extend({
6575
- primaryOfficeId: import_zod32.z.string()
7063
+ primaryOfficeId: import_zod35.z.string()
6576
7064
  });
6577
7065
  function userDeserializer(serializedUserField, user2) {
6578
7066
  if (typeof serializedUserField === "string") {
6579
7067
  return serializedUserField;
6580
7068
  }
6581
- if (serializedUserField.$userField === "name" || serializedUserField.$userField === "signatureFilename") {
7069
+ if (serializedUserField.$userField === "name" || serializedUserField.$userField === "signature" || serializedUserField.$userField === "avatar") {
6582
7070
  throw new Error(
6583
7071
  `Deserializer for ${serializedUserField.$userField} is not implemented yet`
6584
7072
  );
@@ -6592,6 +7080,7 @@ function deserializeQueryExpression(expression, user2) {
6592
7080
  ...expression.assignedTo,
6593
7081
  term: userDeserializer(expression.assignedTo.term, user2)
6594
7082
  },
7083
+ createdByUserType: expression.createdByUserType,
6595
7084
  createdBy: expression.createdBy && {
6596
7085
  ...expression.createdBy,
6597
7086
  term: userDeserializer(expression.createdBy.term, user2)
@@ -6634,15 +7123,31 @@ function deserializeQuery(query, user2) {
6634
7123
  }
6635
7124
 
6636
7125
  // ../commons/src/events/state/availableActions.ts
6637
- var AVAILABLE_ACTIONS_BY_STATUS = {
7126
+ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
6638
7127
  [EventStatus.enum.CREATED]: [
6639
7128
  ActionType.READ,
6640
7129
  ActionType.DECLARE,
7130
+ ActionType.NOTIFY,
6641
7131
  ActionType.DELETE
6642
7132
  ],
6643
- [EventStatus.enum.NOTIFIED]: [ActionType.READ, ActionType.VALIDATE],
6644
- [EventStatus.enum.DECLARED]: [ActionType.READ, ActionType.VALIDATE],
6645
- [EventStatus.enum.VALIDATED]: [ActionType.READ, ActionType.REGISTER],
7133
+ [EventStatus.enum.NOTIFIED]: [
7134
+ ActionType.READ,
7135
+ ActionType.DECLARE,
7136
+ ActionType.ARCHIVE,
7137
+ ActionType.REJECT
7138
+ ],
7139
+ [EventStatus.enum.DECLARED]: [
7140
+ ActionType.READ,
7141
+ ActionType.VALIDATE,
7142
+ ActionType.ARCHIVE,
7143
+ ActionType.REJECT
7144
+ ],
7145
+ [EventStatus.enum.VALIDATED]: [
7146
+ ActionType.READ,
7147
+ ActionType.REGISTER,
7148
+ ActionType.ARCHIVE,
7149
+ ActionType.REJECT
7150
+ ],
6646
7151
  [EventStatus.enum.REJECTED]: [
6647
7152
  ActionType.READ,
6648
7153
  ActionType.DECLARE,
@@ -6664,6 +7169,3 @@ var AVAILABLE_ACTIONS_BY_STATUS = {
6664
7169
  ActionType.UNASSIGN
6665
7170
  ]
6666
7171
  };
6667
- function getAvailableActionsByStatus(status) {
6668
- return AVAILABLE_ACTIONS_BY_STATUS[status];
6669
- }