@opencrvs/toolkit 1.8.0-rc.ff0a1b5 → 1.8.0-rc.ff0b26c

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/events/index.ts
31
31
  var events_exports = {};
32
32
  __export(events_exports, {
33
+ ACTION_ALLOWED_CONFIGURABLE_SCOPES: () => ACTION_ALLOWED_CONFIGURABLE_SCOPES,
33
34
  ACTION_ALLOWED_SCOPES: () => ACTION_ALLOWED_SCOPES,
34
35
  Action: () => Action,
35
36
  ActionBase: () => ActionBase,
@@ -96,6 +97,7 @@ __export(events_exports, {
96
97
  EventSearchIndex: () => EventSearchIndex,
97
98
  EventState: () => EventState,
98
99
  EventStatus: () => EventStatus,
100
+ EventStatusEnum: () => EventStatusEnum,
99
101
  EventStatuses: () => EventStatuses,
100
102
  FieldConditional: () => FieldConditional,
101
103
  FieldConfig: () => FieldConfig,
@@ -136,6 +138,7 @@ __export(events_exports, {
136
138
  RuralAddressUpdateValue: () => RuralAddressUpdateValue,
137
139
  RuralAddressValue: () => RuralAddressValue,
138
140
  SearchField: () => SearchField,
141
+ SearchQueryParams: () => SearchQueryParams,
139
142
  SelectOption: () => SelectOption,
140
143
  ShowConditional: () => ShowConditional,
141
144
  SummaryConfig: () => SummaryConfig,
@@ -203,6 +206,7 @@ __export(events_exports, {
203
206
  getDeclarationFields: () => getDeclarationFields,
204
207
  getDeclarationPages: () => getDeclarationPages,
205
208
  getMixedPath: () => getMixedPath,
209
+ getRandomDatetime: () => getRandomDatetime,
206
210
  getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
207
211
  hasAnyOfScopes: () => hasAnyOfScopes,
208
212
  isAddressFieldType: () => isAddressFieldType,
@@ -262,9 +266,12 @@ var import_zod9 = require("zod");
262
266
 
263
267
  // ../commons/src/events/Conditional.ts
264
268
  var import_zod = require("zod");
265
- var Conditional = import_zod.z.custom(
266
- (val) => typeof val === "object" && val !== null
267
- );
269
+ var import_zod_openapi = require("zod-openapi");
270
+ (0, import_zod_openapi.extendZodWithOpenApi)(import_zod.z);
271
+ var Conditional = import_zod.z.custom((val) => typeof val === "object" && val !== null).openapi({
272
+ description: "JSON schema conditional configuration",
273
+ ref: "Conditional"
274
+ });
268
275
  var ConditionalType = {
269
276
  SHOW: "SHOW",
270
277
  ENABLE: "ENABLE",
@@ -301,7 +308,10 @@ var FieldConditional = import_zod.z.discriminatedUnion("type", [
301
308
  EnableConditional,
302
309
  // Field output can be shown / hidden on the review page
303
310
  DisplayOnReviewConditional
304
- ]);
311
+ ]).openapi({
312
+ description: "Field conditional configuration",
313
+ ref: "FieldConditional"
314
+ });
305
315
 
306
316
  // ../commons/src/events/PageConfig.ts
307
317
  var import_zod6 = require("zod");
@@ -311,6 +321,8 @@ var import_zod5 = require("zod");
311
321
 
312
322
  // ../commons/src/events/TranslationConfig.ts
313
323
  var import_zod2 = require("zod");
324
+ var import_zod_openapi2 = require("zod-openapi");
325
+ (0, import_zod_openapi2.extendZodWithOpenApi)(import_zod2.z);
314
326
  var TranslationConfig = import_zod2.z.object({
315
327
  id: import_zod2.z.string().describe(
316
328
  "The identifier of the translation referred in translation CSV files"
@@ -319,6 +331,9 @@ var TranslationConfig = import_zod2.z.object({
319
331
  description: import_zod2.z.string().describe(
320
332
  "Describe the translation for a translator to be able to identify it."
321
333
  )
334
+ }).openapi({
335
+ description: "Translation configuration",
336
+ ref: "TranslationConfig"
322
337
  });
323
338
 
324
339
  // ../commons/src/events/FieldType.ts
@@ -476,6 +491,8 @@ var FieldUpdateValue = import_zod4.z.union([
476
491
  ]);
477
492
 
478
493
  // ../commons/src/events/FieldConfig.ts
494
+ var import_zod_openapi3 = require("zod-openapi");
495
+ (0, import_zod_openapi3.extendZodWithOpenApi)(import_zod5.z);
479
496
  var FieldId = import_zod5.z.string();
480
497
  var ParentReference = import_zod5.z.object({
481
498
  _fieldId: FieldId.optional()
@@ -500,6 +517,7 @@ var BaseField = import_zod5.z.object({
500
517
  })
501
518
  ).default([]).optional(),
502
519
  label: TranslationConfig,
520
+ helperText: TranslationConfig.optional(),
503
521
  hideLabel: import_zod5.z.boolean().default(false).optional()
504
522
  });
505
523
  var Divider = BaseField.extend({
@@ -740,9 +758,14 @@ var FieldConfig = import_zod5.z.discriminatedUnion("type", [
740
758
  EmailField,
741
759
  FileUploadWithOptions,
742
760
  DataField
743
- ]);
761
+ ]).openapi({
762
+ description: "Form field configuration",
763
+ ref: "FieldConfig"
764
+ });
744
765
 
745
766
  // ../commons/src/events/PageConfig.ts
767
+ var import_zod_openapi4 = require("zod-openapi");
768
+ (0, import_zod_openapi4.extendZodWithOpenApi)(import_zod6.z);
746
769
  var PageTypes = import_zod6.z.enum(["FORM", "VERIFICATION"]);
747
770
  var PageConfigBase = import_zod6.z.object({
748
771
  id: import_zod6.z.string().describe("Unique identifier for the page"),
@@ -751,6 +774,9 @@ var PageConfigBase = import_zod6.z.object({
751
774
  conditional: Conditional.optional().describe(
752
775
  "Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
753
776
  )
777
+ }).openapi({
778
+ description: "Form page configuration",
779
+ ref: "FormPageConfig"
754
780
  });
755
781
  var FormPageConfig = PageConfigBase.extend({
756
782
  type: import_zod6.z.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
@@ -764,7 +790,10 @@ var VerificationActionConfig = import_zod6.z.object({
764
790
  body: TranslationConfig
765
791
  })
766
792
  })
767
- }).describe("Actions available on the verification page");
793
+ }).describe("Actions available on the verification page").openapi({
794
+ description: "Verification action configuration",
795
+ ref: "VerificationActionConfig"
796
+ });
768
797
  var VerificationPageConfig = FormPageConfig.extend({
769
798
  type: import_zod6.z.literal(PageTypes.enum.VERIFICATION),
770
799
  actions: VerificationActionConfig
@@ -864,8 +893,8 @@ var ActionFormConfig = import_zod8.z.object({
864
893
  var FormConfig = import_zod8.z.union([DeclarationFormConfig, ActionFormConfig]);
865
894
 
866
895
  // ../commons/src/events/ActionConfig.ts
867
- var import_zod_openapi = require("zod-openapi");
868
- (0, import_zod_openapi.extendZodWithOpenApi)(import_zod9.z);
896
+ var import_zod_openapi5 = require("zod-openapi");
897
+ (0, import_zod_openapi5.extendZodWithOpenApi)(import_zod9.z);
869
898
  var ActionConditional2 = import_zod9.z.discriminatedUnion("type", [
870
899
  /** If conditional is defined, the action is shown to the user only if the condition is met */
871
900
  ShowConditional,
@@ -1008,8 +1037,8 @@ var import_zod17 = require("zod");
1008
1037
 
1009
1038
  // ../commons/src/events/DeduplicationConfig.ts
1010
1039
  var import_zod12 = require("zod");
1011
- var import_zod_openapi2 = require("zod-openapi");
1012
- (0, import_zod_openapi2.extendZodWithOpenApi)(import_zod12.z);
1040
+ var import_zod_openapi6 = require("zod-openapi");
1041
+ (0, import_zod_openapi6.extendZodWithOpenApi)(import_zod12.z);
1013
1042
  var FieldReference = import_zod12.z.string();
1014
1043
  var Matcher = import_zod12.z.object({
1015
1044
  fieldId: import_zod12.z.string(),
@@ -1110,13 +1139,58 @@ var BaseField3 = import_zod14.z.object({
1110
1139
  config: import_zod14.z.object({
1111
1140
  type: MatchType.describe("Determines the type of field")
1112
1141
  }),
1113
- options: import_zod14.z.array(SelectOption).optional()
1142
+ options: import_zod14.z.array(SelectOption).optional(),
1143
+ searchCriteriaLabelPrefix: TranslationConfig.optional().describe(
1144
+ `
1145
+ This property determines whether to add a prefix (such as "Child" or "Applicant") before the field label
1146
+ when rendering search parameter labels \u2014 for example, in the search results page to indicate which fields were used in the search.
1147
+
1148
+ For example, a field config like { id: "child.firstname", label: { defaultMessage: "First Name(s)" } } would render as "First Name(s)" by default.
1149
+
1150
+ A field config like { id: "mother.firstname", label: { defaultMessage: "First Name(s)" } } would also render as "First Name(s)" by default.
1151
+
1152
+ So, if both child.firstname and mother.firstname are used in a search, the resulting search criteria labels would be "First Name(s)", "First Name(s)",
1153
+ which is ambiguous.
1154
+
1155
+ Now, if we treat the field ID prefix as a label (e.g., "applicant.firstname" \u2192 "Applicant"), and the field label is already
1156
+ descriptive \u2014 like { id: "applicant.firstname", label: { defaultMessage: "Applicant's First Name" } } \u2014 then the resulting
1157
+ label would be "Applicant Applicant's First Name", which is redundant and awkward.
1158
+
1159
+ By setting searchCriteriaLabelPrefix to a translation config object, we can explicitly define the desired prefix
1160
+ in the country-config > event.advancedSearch configuration. For example: field("child.dob", { searchCriteriaLabelPrefix: TranslationConfig }).
1161
+ `
1162
+ ),
1163
+ conditionals: import_zod14.z.array(FieldConditional).default([]).optional().describe(
1164
+ `
1165
+ In advanced search, we sometimes need to override the default field visibility conditionals.
1166
+
1167
+ For example, Informant fields in the declaration form may have conditional logic
1168
+ that hides them based on other field values. Since the advanced search form reuses
1169
+ the declaration form config, those same conditionals would apply by default.
1170
+
1171
+ However, in advanced search we often want to make all Informant fields searchable,
1172
+ regardless of their original visibility logic. To do this, we explicitly set their
1173
+ 'conditionals' to an empty array ('[]') in the search config. This ensures they
1174
+ are always rendered in the advanced search form.
1175
+ `
1176
+ )
1114
1177
  });
1178
+ var SearchQueryParams = import_zod14.z.object({
1179
+ eventType: import_zod14.z.string().optional().describe(
1180
+ "Defines type of event so that when redirecting to Advanced Search page, appropriate tab can be selected"
1181
+ )
1182
+ }).catchall(FieldValue);
1115
1183
  var FieldConfigSchema = BaseField3.extend({
1116
1184
  fieldId: import_zod14.z.string(),
1117
1185
  fieldType: import_zod14.z.literal("field")
1118
1186
  });
1119
- var EventFieldId = import_zod14.z.enum(["trackingId", "status"]);
1187
+ var EventFieldId = import_zod14.z.enum([
1188
+ "trackingId",
1189
+ "status",
1190
+ "legalStatus.REGISTERED.createdAt",
1191
+ "legalStatus.REGISTERED.createdAtLocation",
1192
+ "updatedAt"
1193
+ ]);
1120
1194
  var EventFieldConfigSchema = BaseField3.extend({
1121
1195
  fieldId: EventFieldId,
1122
1196
  fieldType: import_zod14.z.literal("event")
@@ -1135,8 +1209,8 @@ var import_lodash = require("lodash");
1135
1209
 
1136
1210
  // ../commons/src/events/ActionDocument.ts
1137
1211
  var import_zod15 = require("zod");
1138
- var import_zod_openapi3 = require("zod-openapi");
1139
- (0, import_zod_openapi3.extendZodWithOpenApi)(import_zod15.z);
1212
+ var import_zod_openapi7 = require("zod-openapi");
1213
+ (0, import_zod_openapi7.extendZodWithOpenApi)(import_zod15.z);
1140
1214
  var ActionUpdate = import_zod15.z.record(import_zod15.z.string(), FieldUpdateValue);
1141
1215
  var EventState = import_zod15.z.record(import_zod15.z.string(), FieldValue);
1142
1216
  var ActionStatus = {
@@ -1890,8 +1964,8 @@ function getMixedPath(obj, path, defaultValue) {
1890
1964
  }
1891
1965
 
1892
1966
  // ../commons/src/events/EventConfig.ts
1893
- var import_zod_openapi4 = require("zod-openapi");
1894
- (0, import_zod_openapi4.extendZodWithOpenApi)(import_zod17.z);
1967
+ var import_zod_openapi8 = require("zod-openapi");
1968
+ (0, import_zod_openapi8.extendZodWithOpenApi)(import_zod17.z);
1895
1969
  var EventConfig = import_zod17.z.object({
1896
1970
  id: import_zod17.z.string().describe(
1897
1971
  'A machine-readable identifier for the event, e.g. "birth" or "death"'
@@ -1985,6 +2059,17 @@ var EventStatus = {
1985
2059
  REJECTED: "REJECTED",
1986
2060
  ARCHIVED: "ARCHIVED"
1987
2061
  };
2062
+ var eventStatusValues = [
2063
+ EventStatus.CREATED,
2064
+ EventStatus.NOTIFIED,
2065
+ EventStatus.DECLARED,
2066
+ EventStatus.VALIDATED,
2067
+ EventStatus.REGISTERED,
2068
+ EventStatus.CERTIFIED,
2069
+ EventStatus.REJECTED,
2070
+ EventStatus.ARCHIVED
2071
+ ];
2072
+ var EventStatusEnum = import_zod18.z.enum(eventStatusValues);
1988
2073
  var CustomFlags = {
1989
2074
  CERTIFICATE_PRINTED: "certificate-printed"
1990
2075
  };
@@ -2144,6 +2229,14 @@ var AnyOf = import_zod19.z.object({
2144
2229
  type: import_zod19.z.literal("anyOf"),
2145
2230
  terms: import_zod19.z.array(import_zod19.z.string())
2146
2231
  });
2232
+ var ExactStatus = import_zod19.z.object({
2233
+ type: import_zod19.z.literal("exact"),
2234
+ term: EventStatusEnum
2235
+ });
2236
+ var AnyOfStatus = import_zod19.z.object({
2237
+ type: import_zod19.z.literal("anyOf"),
2238
+ terms: import_zod19.z.array(EventStatusEnum)
2239
+ });
2147
2240
  var Range = import_zod19.z.object({
2148
2241
  type: import_zod19.z.literal("range"),
2149
2242
  gte: import_zod19.z.string(),
@@ -2160,9 +2253,13 @@ var QueryInput = import_zod19.z.lazy(
2160
2253
  );
2161
2254
  var QueryExpression = import_zod19.z.object({
2162
2255
  eventType: import_zod19.z.string(),
2163
- status: import_zod19.z.optional(import_zod19.z.union([AnyOf, Exact])),
2256
+ status: import_zod19.z.optional(import_zod19.z.union([AnyOfStatus, ExactStatus])),
2164
2257
  createdAt: import_zod19.z.optional(DateCondition),
2165
2258
  updatedAt: import_zod19.z.optional(DateCondition),
2259
+ "legalStatus.REGISTERED.createdAt": import_zod19.z.optional(DateCondition),
2260
+ "legalStatus.REGISTERED.createdAtLocation": import_zod19.z.optional(
2261
+ import_zod19.z.union([Within, Exact])
2262
+ ),
2166
2263
  createAtLocation: import_zod19.z.optional(import_zod19.z.union([Within, Exact])),
2167
2264
  updatedAtLocation: import_zod19.z.optional(import_zod19.z.union([Within, Exact])),
2168
2265
  createdBy: import_zod19.z.optional(Exact),
@@ -2479,14 +2576,61 @@ function createFieldConditionals(fieldId) {
2479
2576
  };
2480
2577
  }
2481
2578
 
2579
+ // ../commons/src/searchConfigs.ts
2580
+ function createSearchConfig(baseField) {
2581
+ return {
2582
+ /**
2583
+ * Creates a range configuration for the specified field.
2584
+ *
2585
+ * @returns An object containing the field ID and a configuration object with a type of 'range'.
2586
+ *
2587
+ * @example event('legalStatus.REGISTERED.createdAt').range()
2588
+ * // {
2589
+ * // ...
2590
+ * // config: { type: 'range' }
2591
+ * // }
2592
+ */
2593
+ range: () => ({
2594
+ ...baseField,
2595
+ config: { type: "range" }
2596
+ }),
2597
+ /**
2598
+ * Creates a configuration for exact matching of the specified field.
2599
+ * @returns An object containing the field ID and a configuration object with a type of 'exact'.
2600
+ * @example field('dob').exact()
2601
+ * // {
2602
+ * // ...
2603
+ * // config: { type: 'exact' }
2604
+ * // }
2605
+ */
2606
+ exact: () => ({
2607
+ ...baseField,
2608
+ config: { type: "exact" }
2609
+ }),
2610
+ /**
2611
+ * Creates a configuration for fuzzy matching of the specified field.
2612
+ * @returns An object containing the field ID and a configuration object with a type of 'exact'.
2613
+ * @example field('name').fuzzy()
2614
+ * // {
2615
+ * // ...
2616
+ * // config: { type: 'fuzzy' }
2617
+ * // }
2618
+ */
2619
+ fuzzy: () => ({
2620
+ ...baseField,
2621
+ config: { type: "fuzzy" }
2622
+ })
2623
+ };
2624
+ }
2625
+
2482
2626
  // ../commons/src/event-config/event-configuration.ts
2483
2627
  function createEventFieldConfig(fieldId, options) {
2484
- return {
2628
+ const baseField = {
2485
2629
  fieldId,
2486
2630
  options,
2487
- config: { type: "exact" },
2488
2631
  fieldType: "event"
2489
2632
  };
2633
+ return createSearchConfig(baseField);
2490
2634
  }
2491
2635
 
2492
2636
  // ../commons/src/events/event.ts
@@ -2537,8 +2681,9 @@ var import_zod22 = require("zod");
2537
2681
 
2538
2682
  // ../commons/src/events/ActionInput.ts
2539
2683
  var import_zod21 = require("zod");
2540
- var import_zod_openapi5 = require("zod-openapi");
2541
- (0, import_zod_openapi5.extendZodWithOpenApi)(import_zod21.z);
2684
+ var import_zod_openapi9 = require("zod-openapi");
2685
+ var import_uuid3 = require("uuid");
2686
+ (0, import_zod_openapi9.extendZodWithOpenApi)(import_zod21.z);
2542
2687
  var BaseActionInput = import_zod21.z.object({
2543
2688
  eventId: import_zod21.z.string(),
2544
2689
  transactionId: import_zod21.z.string(),
@@ -2569,7 +2714,15 @@ var NotifyActionInput = BaseActionInput.merge(
2569
2714
  import_zod21.z.object({
2570
2715
  type: import_zod21.z.literal(ActionType.NOTIFY).default(ActionType.NOTIFY)
2571
2716
  })
2572
- );
2717
+ ).openapi({
2718
+ default: {
2719
+ eventId: "<event-id-here>",
2720
+ transactionId: (0, import_uuid3.v4)(),
2721
+ declaration: {},
2722
+ annotation: {},
2723
+ type: ActionType.NOTIFY
2724
+ }
2725
+ });
2573
2726
  var DeclareActionInput = BaseActionInput.merge(
2574
2727
  import_zod21.z.object({
2575
2728
  type: import_zod21.z.literal(ActionType.DECLARE).default(ActionType.DECLARE)
@@ -2679,16 +2832,17 @@ var DraftInput = BaseActionInput.extend({
2679
2832
 
2680
2833
  // ../commons/src/events/EventInput.ts
2681
2834
  var import_zod23 = require("zod");
2835
+ var import_uuid4 = require("uuid");
2682
2836
  var EventInput = import_zod23.z.object({
2683
2837
  transactionId: import_zod23.z.string(),
2684
2838
  type: import_zod23.z.string(),
2685
2839
  dateOfEvent: import_zod23.z.object({ fieldId: import_zod23.z.string() }).optional()
2686
- });
2840
+ }).openapi({ default: { transactionId: (0, import_uuid4.v4)(), type: "v2.birth" } });
2687
2841
 
2688
2842
  // ../commons/src/events/EventDocument.ts
2689
2843
  var import_zod24 = require("zod");
2690
- var import_zod_openapi6 = require("zod-openapi");
2691
- (0, import_zod_openapi6.extendZodWithOpenApi)(import_zod24.z);
2844
+ var import_zod_openapi10 = require("zod-openapi");
2845
+ (0, import_zod_openapi10.extendZodWithOpenApi)(import_zod24.z);
2692
2846
  var EventDocument = import_zod24.z.object({
2693
2847
  id: import_zod24.z.string(),
2694
2848
  type: import_zod24.z.string(),
@@ -3007,71 +3161,32 @@ function generateTransactionId() {
3007
3161
 
3008
3162
  // ../commons/src/events/test.utils.ts
3009
3163
  var import_lodash2 = require("lodash");
3164
+ var import_addDays = __toESM(require("date-fns/addDays"));
3010
3165
 
3011
3166
  // ../commons/src/field-config/field-configuration.ts
3012
- function createFieldConfigs(fieldId) {
3167
+ function createFieldConfig(fieldId, options) {
3013
3168
  const baseField = {
3014
3169
  fieldId,
3015
- fieldType: "field"
3016
- };
3017
- return {
3018
- /**
3019
- * Creates a range configuration for the specified field.
3020
- *
3021
- * @returns An object containing the field ID and a configuration object with a type of 'range'.
3022
- *
3023
- * @example field('age').range()
3024
- * // {
3025
- * // fieldId: 'age',
3026
- * // config: { type: 'range' }
3027
- * // }
3028
- */
3029
- range: () => ({
3030
- ...baseField,
3031
- config: { type: "range" }
3032
- }),
3033
- /**
3034
- * Creates a configuration for exact matching of the specified field.
3035
- * @returns An object containing the field ID and a configuration object with a type of 'exact'.
3036
- * @example field('dob').exact()
3037
- * // {
3038
- * // fieldId: 'dob',
3039
- * // config: { type: 'exact' }
3040
- * // }
3041
- */
3042
- exact: () => ({
3043
- ...baseField,
3044
- config: { type: "exact" }
3045
- }),
3046
- /**
3047
- * Creates a configuration for fuzzy matching of the specified field.
3048
- * @returns An object containing the field ID and a configuration object with a type of 'exact'.
3049
- * @example field('name').fuzzy()
3050
- * // {
3051
- * // fieldId: 'name',
3052
- * // config: { type: 'fuzzy' }
3053
- * // }
3054
- */
3055
- fuzzy: () => ({
3056
- ...baseField,
3057
- config: { type: "fuzzy" }
3058
- })
3170
+ fieldType: "field",
3171
+ ...options
3059
3172
  };
3173
+ return createSearchConfig(baseField);
3060
3174
  }
3061
3175
 
3062
3176
  // ../commons/src/events/field.ts
3063
- function field(fieldId) {
3177
+ function field(fieldId, options = {}) {
3064
3178
  return {
3065
3179
  /**
3066
3180
  * @private Internal property used for field reference tracking.
3067
3181
  */
3068
3182
  _fieldId: fieldId,
3069
3183
  ...createFieldConditionals(fieldId),
3070
- ...createFieldConfigs(fieldId)
3184
+ ...createFieldConfig(fieldId, options)
3071
3185
  };
3072
3186
  }
3073
3187
 
3074
3188
  // ../commons/src/fixtures/tennis-club-membership-event.ts
3189
+ var import_date_fns2 = require("date-fns");
3075
3190
  var PRINT_CERTIFICATE_FORM = defineActionForm({
3076
3191
  label: {
3077
3192
  id: "v2.event.tennis-club-membership.action.certificate.form.label",
@@ -3980,6 +4095,114 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
3980
4095
  }
3981
4096
  ]
3982
4097
  });
4098
+ var statusOptions = [
4099
+ {
4100
+ value: "ALL",
4101
+ label: {
4102
+ defaultMessage: "Any status",
4103
+ description: "Option for form field: status of record",
4104
+ id: "v2.advancedSearch.form.recordStatusAny"
4105
+ }
4106
+ },
4107
+ {
4108
+ value: EventStatus.CREATED,
4109
+ label: {
4110
+ defaultMessage: "Draft",
4111
+ description: "Option for form field: status of record",
4112
+ id: "v2.advancedSearch.form.recordStatusCreated"
4113
+ }
4114
+ },
4115
+ {
4116
+ value: EventStatus.NOTIFIED,
4117
+ label: {
4118
+ defaultMessage: "Notified",
4119
+ description: "Option for form field: status of record",
4120
+ id: "v2.advancedSearch.form.recordStatusNotified"
4121
+ }
4122
+ },
4123
+ {
4124
+ value: EventStatus.DECLARED,
4125
+ label: {
4126
+ defaultMessage: "Declared",
4127
+ description: "Option for form field: status of record",
4128
+ id: "v2.advancedSearch.form.recordStatusDeclared"
4129
+ }
4130
+ },
4131
+ {
4132
+ value: EventStatus.VALIDATED,
4133
+ label: {
4134
+ defaultMessage: "Validated",
4135
+ description: "Option for form field: status of record",
4136
+ id: "v2.advancedSearch.form.recordStatusValidated"
4137
+ }
4138
+ },
4139
+ {
4140
+ value: EventStatus.REGISTERED,
4141
+ label: {
4142
+ defaultMessage: "Registered",
4143
+ description: "Option for form field: status of record",
4144
+ id: "v2.advancedSearch.form.recordStatusRegistered"
4145
+ }
4146
+ },
4147
+ {
4148
+ value: EventStatus.CERTIFIED,
4149
+ label: {
4150
+ defaultMessage: "Certified",
4151
+ description: "Option for form field: status of record",
4152
+ id: "v2.advancedSearch.form.recordStatusCertified"
4153
+ }
4154
+ },
4155
+ {
4156
+ value: EventStatus.REJECTED,
4157
+ label: {
4158
+ defaultMessage: "Rejected",
4159
+ description: "Option for form field: status of record",
4160
+ id: "v2.advancedSearch.form.recordStatusRejected"
4161
+ }
4162
+ },
4163
+ {
4164
+ value: EventStatus.ARCHIVED,
4165
+ label: {
4166
+ defaultMessage: "Archived",
4167
+ description: "Option for form field: status of record",
4168
+ id: "v2.advancedSearch.form.recordStatusArchived"
4169
+ }
4170
+ }
4171
+ ];
4172
+ var timePeriodOptions = [
4173
+ {
4174
+ label: {
4175
+ defaultMessage: "Last 7 days",
4176
+ description: "Label for option of time period select: last 7 days",
4177
+ id: "form.section.label.timePeriodLast7Days"
4178
+ },
4179
+ value: `${(0, import_date_fns2.format)((0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 7), "yyyy-MM-dd")},${(0, import_date_fns2.format)(/* @__PURE__ */ new Date(), "yyyy-MM-dd")}`
4180
+ },
4181
+ {
4182
+ label: {
4183
+ defaultMessage: "Last 30 days",
4184
+ description: "Label for option of time period select: last 30 days",
4185
+ id: "form.section.label.timePeriodLast30Days"
4186
+ },
4187
+ value: `${(0, import_date_fns2.format)((0, import_date_fns2.subMonths)(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd")},${(0, import_date_fns2.format)(/* @__PURE__ */ new Date(), "yyyy-MM-dd")}`
4188
+ },
4189
+ {
4190
+ label: {
4191
+ defaultMessage: "Last 90 days",
4192
+ description: "Label for option of time period select: last 90 days",
4193
+ id: "form.section.label.timePeriodLast90Days"
4194
+ },
4195
+ value: `${(0, import_date_fns2.format)((0, import_date_fns2.subQuarters)(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd")},${(0, import_date_fns2.format)(/* @__PURE__ */ new Date(), "yyyy-MM-dd")}`
4196
+ },
4197
+ {
4198
+ label: {
4199
+ defaultMessage: "Last year",
4200
+ description: "Label for option of time period select: last year",
4201
+ id: "form.section.label.timePeriodLastYear"
4202
+ },
4203
+ value: `${(0, import_date_fns2.format)((0, import_date_fns2.subYears)(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd")},${(0, import_date_fns2.format)(/* @__PURE__ */ new Date(), "yyyy-MM-dd")}`
4204
+ }
4205
+ ];
3983
4206
  var tennisClubMembershipEvent = defineConfig({
3984
4207
  id: "TENNIS_CLUB_MEMBERSHIP",
3985
4208
  label: {
@@ -4328,11 +4551,40 @@ var tennisClubMembershipEvent = defineConfig({
4328
4551
  advancedSearch: [
4329
4552
  {
4330
4553
  title: {
4331
- defaultMessage: "Tennis club registration search",
4332
- description: "This is what this event is referred as in the system",
4333
- id: "v2.event.tennis-club-membership.search"
4554
+ defaultMessage: "Registration details",
4555
+ description: "The title of Registration details accordion",
4556
+ id: "v2.advancedSearch.form.registrationDetails"
4334
4557
  },
4335
- fields: [field("applicant.dob").exact()]
4558
+ fields: [
4559
+ event("legalStatus.REGISTERED.createdAtLocation").exact(),
4560
+ event("legalStatus.REGISTERED.createdAt").range(),
4561
+ event("status", statusOptions).exact(),
4562
+ event("updatedAt", timePeriodOptions).range()
4563
+ ]
4564
+ },
4565
+ {
4566
+ title: {
4567
+ defaultMessage: "Applicant's details",
4568
+ description: "Applicant details search field section title",
4569
+ id: "v2.event.tennis-club-membership.search.applicants"
4570
+ },
4571
+ fields: [
4572
+ field("applicant.firstname").fuzzy(),
4573
+ field("applicant.surname").fuzzy(),
4574
+ field("applicant.dob").range(),
4575
+ field("applicant.email").exact()
4576
+ ]
4577
+ },
4578
+ {
4579
+ title: {
4580
+ defaultMessage: "Recommender's details",
4581
+ description: "Recommender details search field section title",
4582
+ id: "v2.event.tennis-club-membership.search.recommender"
4583
+ },
4584
+ fields: [
4585
+ field("recommender.firstname").fuzzy(),
4586
+ field("recommender.surname").fuzzy()
4587
+ ]
4336
4588
  }
4337
4589
  ],
4338
4590
  declaration: TENNIS_CLUB_DECLARATION_FORM
@@ -4664,21 +4916,16 @@ function generateEventDraftDocument(eventId, actionType = ActionType.DECLARE, de
4664
4916
  eventId
4665
4917
  };
4666
4918
  }
4667
- function getEventStatus() {
4668
- const statuses = [
4669
- EventStatus.CREATED,
4670
- EventStatus.REGISTERED,
4671
- EventStatus.DECLARED
4672
- ];
4673
- const randomIndex = Math.floor(Math.random() * 3);
4674
- return statuses[randomIndex];
4919
+ function pickRandom(rng, items) {
4920
+ return items[Math.floor(rng() * items.length)];
4675
4921
  }
4676
- function getTrackingId() {
4677
- const uuid = getUUID().replace(/-/g, "");
4678
- const trackingId = uuid.slice(0, 6).toUpperCase();
4679
- return trackingId;
4922
+ function getRandomDatetime(rng, start, end) {
4923
+ const range = end.getTime() - start.getTime();
4924
+ const offset = Math.floor(rng() * range);
4925
+ const randomDate = new Date(start.getTime() + offset);
4926
+ return randomDate.toISOString();
4680
4927
  }
4681
- function getRandomApplicant() {
4928
+ function generateRandomApplicant(rng) {
4682
4929
  const firstNames = [
4683
4930
  "Danny",
4684
4931
  "John",
@@ -4699,18 +4946,13 @@ function getRandomApplicant() {
4699
4946
  "Garcia",
4700
4947
  "Miller"
4701
4948
  ];
4702
- function getRandomDate(start, end) {
4703
- const randomDate = new Date(
4704
- start.getTime() + Math.random() * (end.getTime() - start.getTime())
4705
- );
4706
- return randomDate.toISOString().split("T")[0];
4707
- }
4708
- const randomFirstName = firstNames[Math.floor(Math.random() * firstNames.length)];
4709
- const randomSurname = surnames[Math.floor(Math.random() * surnames.length)];
4710
- const randomDob = getRandomDate(
4949
+ const randomFirstName = pickRandom(rng, firstNames);
4950
+ const randomSurname = pickRandom(rng, surnames);
4951
+ const randomDob = getRandomDatetime(
4952
+ rng,
4711
4953
  /* @__PURE__ */ new Date("1990-01-01"),
4712
4954
  /* @__PURE__ */ new Date("2010-12-31")
4713
- );
4955
+ ).split("T")[0];
4714
4956
  return {
4715
4957
  "recommender.none": true,
4716
4958
  "applicant.firstname": randomFirstName,
@@ -4718,23 +4960,53 @@ function getRandomApplicant() {
4718
4960
  "applicant.dob": randomDob
4719
4961
  };
4720
4962
  }
4721
- var eventQueryDataGenerator = (overrides = {}) => ({
4722
- id: overrides.id ?? getUUID(),
4723
- type: overrides.type ?? "TENNIS_CLUB_MEMBERSHIP",
4724
- status: overrides.status ?? getEventStatus(),
4725
- createdAt: overrides.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
4726
- createdBy: overrides.createdBy ?? getUUID(),
4727
- createdAtLocation: overrides.createdAtLocation ?? getUUID(),
4728
- updatedAtLocation: overrides.updatedAtLocation ?? getUUID(),
4729
- updatedAt: overrides.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
4730
- assignedTo: overrides.assignedTo ?? null,
4731
- updatedBy: overrides.updatedBy ?? getUUID(),
4732
- updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
4733
- flags: [],
4734
- legalStatuses: overrides.legalStatuses ?? {},
4735
- declaration: overrides.declaration ?? getRandomApplicant(),
4736
- trackingId: overrides.trackingId ?? getTrackingId()
4737
- });
4963
+ function createPseudoRandomNumberGenerator(seed) {
4964
+ const MODULUS = 2 ** 32;
4965
+ const MULTIPLIER = 1664525;
4966
+ const INCREMENT = 1013904223;
4967
+ let state = seed >>> 0;
4968
+ return () => {
4969
+ state = (MULTIPLIER * state + INCREMENT) % MODULUS;
4970
+ return state / MODULUS;
4971
+ };
4972
+ }
4973
+ function generateUuid(rng) {
4974
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
4975
+ const r = Math.floor(rng() * 16);
4976
+ const v = c === "x" ? r : r & 3 | 8;
4977
+ return v.toString(16);
4978
+ });
4979
+ }
4980
+ function generateTrackingId(rng) {
4981
+ const uuid = generateUuid(rng).replace(/-/g, "");
4982
+ const trackingId = uuid.slice(0, 6).toUpperCase();
4983
+ return trackingId;
4984
+ }
4985
+ var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
4986
+ const rng = createPseudoRandomNumberGenerator(seed);
4987
+ const createdAt = getRandomDatetime(
4988
+ rng,
4989
+ /* @__PURE__ */ new Date("2024-01-01"),
4990
+ /* @__PURE__ */ new Date("2024-12-31")
4991
+ );
4992
+ return {
4993
+ id: overrides.id ?? generateUuid(rng),
4994
+ type: overrides.type ?? "TENNIS_CLUB_MEMBERSHIP",
4995
+ status: overrides.status ?? pickRandom(rng, eventStatuses),
4996
+ createdAt: overrides.createdAt ?? createdAt,
4997
+ createdBy: overrides.createdBy ?? generateUuid(rng),
4998
+ createdAtLocation: overrides.createdAtLocation ?? generateUuid(rng),
4999
+ updatedAtLocation: overrides.updatedAtLocation ?? generateUuid(rng),
5000
+ updatedAt: overrides.updatedAt ?? (0, import_addDays.default)(new Date(createdAt), 1).toISOString(),
5001
+ assignedTo: overrides.assignedTo ?? null,
5002
+ updatedBy: overrides.updatedBy ?? generateUuid(rng),
5003
+ updatedByUserRole: overrides.updatedByUserRole ?? "FIELD_AGENT",
5004
+ flags: [],
5005
+ legalStatuses: overrides.legalStatuses ?? {},
5006
+ declaration: overrides.declaration ?? generateRandomApplicant(rng),
5007
+ trackingId: overrides.trackingId ?? generateTrackingId(rng)
5008
+ };
5009
+ };
4738
5010
  var generateTranslationConfig = (message) => ({
4739
5011
  defaultMessage: message,
4740
5012
  description: "Description for ${message}",
@@ -4801,6 +5073,8 @@ var SCOPES = {
4801
5073
  */
4802
5074
  RECORD_DECLARE: "record.declare-birth",
4803
5075
  // declare
5076
+ RECORD_IMPORT: "record.import",
5077
+ // declare
4804
5078
  RECORD_DECLARE_BIRTH: "record.declare-birth",
4805
5079
  RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
4806
5080
  RECORD_DECLARE_DEATH: "record.declare-death",
@@ -4904,6 +5178,7 @@ var LiteralScopes = import_zod25.z.union([
4904
5178
  import_zod25.z.literal(SCOPES.NATIONALID),
4905
5179
  import_zod25.z.literal(SCOPES.NOTIFICATION_API),
4906
5180
  import_zod25.z.literal(SCOPES.RECORDSEARCH),
5181
+ import_zod25.z.literal(SCOPES.RECORD_IMPORT),
4907
5182
  import_zod25.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
4908
5183
  import_zod25.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
4909
5184
  import_zod25.z.literal(SCOPES.RECORD_DECLARE_DEATH),
@@ -4965,7 +5240,7 @@ var LiteralScopes = import_zod25.z.union([
4965
5240
  import_zod25.z.literal(SCOPES.CONFIG_UPDATE_ALL),
4966
5241
  import_zod25.z.literal(SCOPES.USER_DATA_SEEDING)
4967
5242
  ]);
4968
- var rawConfigurableScopeRegex = /^([a-zA-Z]+\.[a-zA-Z]+)\[((?:\w+=\w+(?:\|\w+)*)(:?,\w+=\w+(?:\|\w+)*)*)\]$/;
5243
+ var rawConfigurableScopeRegex = /^([a-zA-Z\.]+)\[((?:\w+=[\w.-]+(?:\|[\w.-]+)*)(?:,[\w]+=[\w.-]+(?:\|[\w.-]+)*)*)\]$/;
4969
5244
  var rawConfigurableScope = import_zod25.z.string().regex(rawConfigurableScopeRegex);
4970
5245
  var CreateUserScope = import_zod25.z.object({
4971
5246
  type: import_zod25.z.literal("user.create"),
@@ -4979,16 +5254,27 @@ var EditUserScope = import_zod25.z.object({
4979
5254
  role: import_zod25.z.array(import_zod25.z.string())
4980
5255
  })
4981
5256
  });
5257
+ var WorkqueueScope = import_zod25.z.object({
5258
+ type: import_zod25.z.literal("workqueue"),
5259
+ options: import_zod25.z.object({
5260
+ id: import_zod25.z.array(import_zod25.z.string())
5261
+ })
5262
+ });
5263
+ var NotifyRecordScope = import_zod25.z.object({
5264
+ type: import_zod25.z.literal("record.notify"),
5265
+ options: import_zod25.z.object({
5266
+ event: import_zod25.z.array(import_zod25.z.string())
5267
+ })
5268
+ });
4982
5269
  var ConfigurableScopes = import_zod25.z.discriminatedUnion("type", [
4983
5270
  CreateUserScope,
4984
- EditUserScope
5271
+ EditUserScope,
5272
+ WorkqueueScope,
5273
+ NotifyRecordScope
4985
5274
  ]);
4986
5275
  var scopes = Object.values(SCOPES);
4987
5276
 
4988
5277
  // ../commons/src/events/scopes.ts
4989
- function hasAnyOfScopes(a, b) {
4990
- return (0, import_lodash3.intersection)(a, b).length > 0;
4991
- }
4992
5278
  var CONFIG_GET_ALLOWED_SCOPES = [
4993
5279
  SCOPES.RECORD_DECLARE,
4994
5280
  SCOPES.RECORD_READ,
@@ -5046,6 +5332,28 @@ var ACTION_ALLOWED_SCOPES = {
5046
5332
  [ActionType.UNASSIGN]: null,
5047
5333
  [ActionType.DETECT_DUPLICATE]: []
5048
5334
  };
5335
+ var ACTION_ALLOWED_CONFIGURABLE_SCOPES = {
5336
+ [ActionType.READ]: [],
5337
+ [ActionType.CREATE]: ["record.notify"],
5338
+ [ActionType.NOTIFY]: ["record.notify"],
5339
+ [ActionType.DECLARE]: [],
5340
+ [ActionType.DELETE]: [],
5341
+ [ActionType.VALIDATE]: [],
5342
+ [ActionType.REGISTER]: [],
5343
+ [ActionType.PRINT_CERTIFICATE]: [],
5344
+ [ActionType.REQUEST_CORRECTION]: [],
5345
+ [ActionType.REJECT_CORRECTION]: [],
5346
+ [ActionType.APPROVE_CORRECTION]: [],
5347
+ [ActionType.MARKED_AS_DUPLICATE]: [],
5348
+ [ActionType.ARCHIVE]: [],
5349
+ [ActionType.REJECT]: [],
5350
+ [ActionType.ASSIGN]: [],
5351
+ [ActionType.UNASSIGN]: [],
5352
+ [ActionType.DETECT_DUPLICATE]: []
5353
+ };
5354
+ function hasAnyOfScopes(a, b) {
5355
+ return (0, import_lodash3.intersection)(a, b).length > 0;
5356
+ }
5049
5357
  function filterUnallowedActions(actions, userScopes) {
5050
5358
  const allowedActions = actions.filter((action) => {
5051
5359
  const requiredScopes = ACTION_ALLOWED_SCOPES[action];