@opencrvs/toolkit 1.8.1-rc.3e74262 → 1.8.1-rc.448a7dd

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 (32) hide show
  1. package/dist/commons/api/router.d.ts +433 -392
  2. package/dist/commons/conditionals/validate.d.ts +11 -2
  3. package/dist/commons/events/ActionConfig.d.ts +3924 -642
  4. package/dist/commons/events/ActionDocument.d.ts +1319 -747
  5. package/dist/commons/events/ActionInput.d.ts +662 -600
  6. package/dist/commons/events/AdvancedSearchConfig.d.ts +83 -65
  7. package/dist/commons/events/CompositeFieldValue.d.ts +6 -6
  8. package/dist/commons/events/CountryConfigQueryInput.d.ts +88 -88
  9. package/dist/commons/events/Draft.d.ts +48 -48
  10. package/dist/commons/events/EventConfig.d.ts +1281 -262
  11. package/dist/commons/events/EventDocument.d.ts +477 -432
  12. package/dist/commons/events/EventIndex.d.ts +184 -62
  13. package/dist/commons/events/EventMetadata.d.ts +9 -9
  14. package/dist/commons/events/FieldConfig.d.ts +517 -71
  15. package/dist/commons/events/FieldTypeMapping.d.ts +16 -16
  16. package/dist/commons/events/FieldValue.d.ts +12 -12
  17. package/dist/commons/events/FormConfig.d.ts +1956 -378
  18. package/dist/commons/events/PageConfig.d.ts +524 -82
  19. package/dist/commons/events/WorkqueueConfig.d.ts +288 -164
  20. package/dist/commons/events/defineConfig.d.ts +183 -48
  21. package/dist/commons/events/event.d.ts +68 -6
  22. package/dist/commons/events/field.d.ts +14 -0
  23. package/dist/commons/events/test.utils.d.ts +17 -13
  24. package/dist/commons/events/utils.d.ts +332 -92
  25. package/dist/conditionals/index.js +3 -2
  26. package/dist/events/index.js +293 -101
  27. package/package.json +1 -1
  28. package/tsconfig.json +1 -1
  29. package/dist/commons/conditionals/conditionals.test.d.ts +0 -2
  30. package/dist/commons/conditionals/validate-address.test.d.ts +0 -2
  31. package/dist/commons/conditionals/validate.test.d.ts +0 -2
  32. package/dist/commons/events/utils.test.d.ts +0 -2
@@ -40,6 +40,7 @@ __export(events_exports, {
40
40
  ActionConfigBase: () => ActionConfigBase,
41
41
  ActionCreationMetadata: () => ActionCreationMetadata,
42
42
  ActionDocument: () => ActionDocument,
43
+ ActionFlag: () => ActionFlag,
43
44
  ActionFormConfig: () => ActionFormConfig,
44
45
  ActionInput: () => ActionInput,
45
46
  ActionStatus: () => ActionStatus,
@@ -95,6 +96,7 @@ __export(events_exports, {
95
96
  EventDocument: () => EventDocument,
96
97
  EventFieldConfigSchema: () => EventFieldConfigSchema,
97
98
  EventFieldId: () => EventFieldId,
99
+ EventFieldIdInput: () => EventFieldIdInput,
98
100
  EventIndex: () => EventIndex,
99
101
  EventInput: () => EventInput,
100
102
  EventMetadata: () => EventMetadata,
@@ -129,8 +131,10 @@ __export(events_exports, {
129
131
  InherentFlags: () => InherentFlags,
130
132
  LanguageConfig: () => LanguageConfig,
131
133
  LegalStatuses: () => LegalStatuses,
134
+ METADATA_FIELD_PREFIX: () => METADATA_FIELD_PREFIX,
132
135
  MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
133
136
  MimeType: () => MimeType,
137
+ NameConfig: () => NameConfig,
134
138
  NameFieldUpdateValue: () => NameFieldUpdateValue,
135
139
  NameFieldValue: () => NameFieldValue,
136
140
  NonEmptyTextValue: () => NonEmptyTextValue,
@@ -139,6 +143,7 @@ __export(events_exports, {
139
143
  PageConfig: () => PageConfig,
140
144
  PageTypes: () => PageTypes,
141
145
  PrintCertificateActionInput: () => PrintCertificateActionInput,
146
+ PrintContent: () => PrintContent,
142
147
  QueryExpression: () => QueryExpression,
143
148
  QueryInput: () => QueryInput,
144
149
  QueryType: () => QueryType,
@@ -167,6 +172,7 @@ __export(events_exports, {
167
172
  TENNIS_CLUB_MEMBERSHIP: () => TENNIS_CLUB_MEMBERSHIP,
168
173
  TEST_SYSTEM_IANA_TIMEZONE: () => TEST_SYSTEM_IANA_TIMEZONE,
169
174
  TestUserRole: () => TestUserRole,
175
+ TextField: () => TextField,
170
176
  TextValue: () => TextValue,
171
177
  TimeValue: () => TimeValue,
172
178
  TranslationConfig: () => TranslationConfig,
@@ -178,7 +184,6 @@ __export(events_exports, {
178
184
  ValidationConfig: () => ValidationConfig,
179
185
  VerificationActionConfig: () => VerificationActionConfig,
180
186
  VerificationPageConfig: () => VerificationPageConfig,
181
- VisibleStatus: () => VisibleStatus,
182
187
  WRITE_ACTION_SCOPES: () => WRITE_ACTION_SCOPES,
183
188
  Within: () => Within,
184
189
  WorkqueueActionsWithDefault: () => WorkqueueActionsWithDefault,
@@ -197,6 +202,7 @@ __export(events_exports, {
197
202
  annotationActions: () => annotationActions,
198
203
  applyDeclarationToEventIndex: () => applyDeclarationToEventIndex,
199
204
  applyDraftsToEventIndex: () => applyDraftsToEventIndex,
205
+ areCertificateConditionsMet: () => areCertificateConditionsMet,
200
206
  areConditionsMet: () => areConditionsMet,
201
207
  compositeFieldTypes: () => compositeFieldTypes,
202
208
  createEmptyDraft: () => createEmptyDraft,
@@ -320,6 +326,7 @@ __export(events_exports, {
320
326
  or: () => or,
321
327
  resolveDateOfEvent: () => resolveDateOfEvent,
322
328
  runFieldValidations: () => runFieldValidations,
329
+ runStructuralValidations: () => runStructuralValidations,
323
330
  timePeriodToDateRange: () => timePeriodToDateRange,
324
331
  user: () => user,
325
332
  validate: () => validate,
@@ -554,7 +561,7 @@ var import_zod6 = require("zod");
554
561
  var import_zod4 = require("zod");
555
562
  var import_zod_openapi3 = require("zod-openapi");
556
563
  (0, import_zod_openapi3.extendZodWithOpenApi)(import_zod4.z);
557
- var FullDocumentURL = import_zod4.z.string().brand("FullDocumentURL").describe(
564
+ var FullDocumentUrl = import_zod4.z.string().brand("FullDocumentUrl").describe(
558
565
  "A full url with protocol, host, bucket name, starting from the root of the S3 server, https://minio/bucket-name/document-id.jpg"
559
566
  );
560
567
  var FullDocumentPath = import_zod4.z.string().transform((val) => val.startsWith("/") ? val : `/${val}`).openapi({ effectType: "input", type: "string" }).describe(
@@ -611,8 +618,8 @@ var NameFieldValue = import_zod5.z.object({
611
618
  middlename: import_zod5.z.string().optional()
612
619
  });
613
620
  var NameFieldUpdateValue = import_zod5.z.object({
614
- firstname: import_zod5.z.string().nullish(),
615
- surname: import_zod5.z.string().nullish(),
621
+ firstname: import_zod5.z.string(),
622
+ surname: import_zod5.z.string(),
616
623
  middlename: import_zod5.z.string().nullish()
617
624
  }).or(import_zod5.z.null()).or(import_zod5.z.undefined());
618
625
  var RuralAddressUpdateValue = AdminStructure.extend({
@@ -909,18 +916,32 @@ var SelectDateRangeField = BaseField.extend({
909
916
  defaultValue: SelectDateRangeValue.optional(),
910
917
  options: import_zod7.z.array(SelectDateRangeOption).describe("A list of options")
911
918
  }).describe("Select input with date range options");
919
+ var NameConfig = import_zod7.z.object({
920
+ firstname: import_zod7.z.object({ required: import_zod7.z.boolean(), label: TranslationConfig.optional() }).optional(),
921
+ middlename: import_zod7.z.object({ required: import_zod7.z.boolean(), label: TranslationConfig.optional() }).optional(),
922
+ surname: import_zod7.z.object({ required: import_zod7.z.boolean(), label: TranslationConfig.optional() }).optional()
923
+ });
912
924
  var NameField = BaseField.extend({
913
925
  type: import_zod7.z.literal(FieldType.NAME),
914
926
  defaultValue: import_zod7.z.object({
915
- firstname: NonEmptyTextValue,
916
- surname: NonEmptyTextValue
927
+ firstname: NonEmptyTextValue.optional(),
928
+ middlename: NonEmptyTextValue.optional(),
929
+ surname: NonEmptyTextValue.optional()
917
930
  }).optional(),
918
931
  configuration: import_zod7.z.object({
932
+ name: NameConfig.default({
933
+ firstname: { required: true },
934
+ surname: { required: true }
935
+ }).optional(),
936
+ order: import_zod7.z.array(import_zod7.z.enum(["firstname", "middlename", "surname"])).optional(),
919
937
  maxLength: import_zod7.z.number().optional().describe("Maximum length of the text"),
920
938
  prefix: TranslationConfig.optional(),
921
- postfix: TranslationConfig.optional(),
922
- includeMiddlename: import_zod7.z.boolean().default(false).optional().describe("To make middle name visible in Name form field"),
923
- searchMode: import_zod7.z.boolean().optional()
939
+ postfix: TranslationConfig.optional()
940
+ }).default({
941
+ name: {
942
+ firstname: { required: true },
943
+ surname: { required: true }
944
+ }
924
945
  }).optional()
925
946
  }).describe("Name input field");
926
947
  var PhoneField = BaseField.extend({
@@ -983,10 +1004,32 @@ var Office = BaseField.extend({
983
1004
  }).describe("Input field for an office");
984
1005
  var Address = BaseField.extend({
985
1006
  type: import_zod7.z.literal(FieldType.ADDRESS),
986
- defaultValue: AddressFieldValue.optional(),
987
1007
  configuration: import_zod7.z.object({
988
- searchMode: import_zod7.z.boolean().optional()
989
- }).optional()
1008
+ lineSeparator: import_zod7.z.string().optional(),
1009
+ fields: import_zod7.z.array(
1010
+ import_zod7.z.enum([
1011
+ "number",
1012
+ "country",
1013
+ "province",
1014
+ "addressType",
1015
+ "district",
1016
+ "urbanOrRural",
1017
+ "town",
1018
+ "residentialArea",
1019
+ "street",
1020
+ "zipCode",
1021
+ "village",
1022
+ "state",
1023
+ "district2",
1024
+ "cityOrTown",
1025
+ "addressLine1",
1026
+ "addressLine2",
1027
+ "addressLine3",
1028
+ "postcodeOrZip"
1029
+ ])
1030
+ ).optional()
1031
+ }).optional(),
1032
+ defaultValue: AddressFieldValue.optional()
990
1033
  }).describe("Address input field \u2013 a combination of location and text fields");
991
1034
  var DataEntry = import_zod7.z.union([
992
1035
  import_zod7.z.object({
@@ -1222,7 +1265,8 @@ var CertificateConfig = import_zod11.z.object({
1222
1265
  delayed: import_zod11.z.number()
1223
1266
  }),
1224
1267
  svgUrl: import_zod11.z.string(),
1225
- fonts: import_zod11.z.record(FontFamily).optional()
1268
+ fonts: import_zod11.z.record(FontFamily).optional(),
1269
+ conditionals: import_zod11.z.array(ShowConditional).optional()
1226
1270
  });
1227
1271
  var CertificateTemplateConfig = CertificateConfig.extend({
1228
1272
  hash: import_zod11.z.string().optional(),
@@ -1340,7 +1384,7 @@ var SummaryConfig = import_zod14.z.object({
1340
1384
 
1341
1385
  // ../commons/src/events/AdvancedSearchConfig.ts
1342
1386
  var import_zod15 = require("zod");
1343
- var MatchType = import_zod15.z.enum(["fuzzy", "exact", "range"]);
1387
+ var MatchType = import_zod15.z.enum(["fuzzy", "exact", "range", "within"]);
1344
1388
  var BaseField3 = import_zod15.z.object({
1345
1389
  config: import_zod15.z.object({
1346
1390
  type: MatchType.describe("Determines the type of field")
@@ -1394,22 +1438,30 @@ var FieldConfigSchema = BaseField3.extend({
1394
1438
  fieldType: import_zod15.z.literal("field"),
1395
1439
  alternateFieldIds: import_zod15.z.array(import_zod15.z.string()).optional().describe(
1396
1440
  `Sometimes there might be need to search a value against multiple field of same FormField type. For example
1397
- search Country, Province, District against child.address.private and child.address.other. In such case, we
1441
+ search Country, Province, District against child.address.private and child.address.other. In such case, we
1398
1442
  add a one field as fieldId, and accomodate others in alternateFieldIds`
1399
1443
  ),
1400
- excludeInSearchQuery: import_zod15.z.boolean().default(false).optional().describe(`Sometimes there will be search fields which are used to
1401
- conditionally display another search field, but its not needed in search query. For example, child.placeOfBirth
1444
+ excludeInSearchQuery: import_zod15.z.boolean().default(false).optional().describe(`Sometimes there will be search fields which are used to
1445
+ conditionally display another search field, but its not needed in search query. For example, child.placeOfBirth
1402
1446
  is select field, which has 3 options, FACILITY, PRIVATE_HOME, OTHER. Upon selecting any of the option, pops up another field
1403
1447
  related to the selected option, whose value is required in the search query. But child.placeOfBirth itself is not needed in the query.
1404
1448
  In such case, populate this field (excludeInSearchQuery) with boolean true`)
1405
1449
  });
1406
- var EventFieldId = import_zod15.z.enum([
1450
+ var EventFieldIdInput = import_zod15.z.enum([
1407
1451
  "trackingId",
1408
1452
  "status",
1409
1453
  "legalStatuses.REGISTERED.acceptedAt",
1410
1454
  "legalStatuses.REGISTERED.createdAtLocation",
1411
1455
  "updatedAt"
1412
1456
  ]);
1457
+ var METADATA_FIELD_PREFIX = "event.";
1458
+ var EventFieldId = import_zod15.z.enum([
1459
+ `${METADATA_FIELD_PREFIX}trackingId`,
1460
+ `${METADATA_FIELD_PREFIX}status`,
1461
+ `${METADATA_FIELD_PREFIX}legalStatuses.REGISTERED.acceptedAt`,
1462
+ `${METADATA_FIELD_PREFIX}legalStatuses.REGISTERED.createdAtLocation`,
1463
+ `${METADATA_FIELD_PREFIX}updatedAt`
1464
+ ]);
1413
1465
  var EventFieldConfigSchema = BaseField3.extend({
1414
1466
  fieldId: EventFieldId,
1415
1467
  fieldType: import_zod15.z.literal("event")
@@ -1902,11 +1954,15 @@ var ActionBase = import_zod19.z.object({
1902
1954
  originalActionId: UUID.optional().nullable().describe(
1903
1955
  "Reference to the original action that was asynchronously rejected or accepted by 3rd party integration."
1904
1956
  )
1957
+ // 'content' field reserved for additional data
1958
+ // Each action can define its own content specifc to the action
1959
+ // See PrintCertificateAction
1905
1960
  });
1906
1961
  var AssignedAction = ActionBase.merge(
1907
1962
  import_zod19.z.object({
1908
1963
  type: import_zod19.z.literal(ActionType.ASSIGN),
1909
1964
  assignedTo: import_zod19.z.string()
1965
+ // TODO move into 'content' property
1910
1966
  })
1911
1967
  );
1912
1968
  var UnassignedAction = ActionBase.merge(
@@ -1918,6 +1974,7 @@ var RegisterAction = ActionBase.merge(
1918
1974
  import_zod19.z.object({
1919
1975
  type: import_zod19.z.literal(ActionType.REGISTER),
1920
1976
  registrationNumber: import_zod19.z.string().optional()
1977
+ // TODO move into 'content' property
1921
1978
  })
1922
1979
  );
1923
1980
  var DeclareAction = ActionBase.merge(
@@ -1938,6 +1995,7 @@ var RejectAction = ActionBase.merge(
1938
1995
  import_zod19.z.object({
1939
1996
  type: import_zod19.z.literal(ActionType.REJECT),
1940
1997
  reason: RejectionReason
1998
+ // TODO move into 'content' property
1941
1999
  })
1942
2000
  );
1943
2001
  var MarkAsDuplicateAction = ActionBase.merge(
@@ -1949,6 +2007,7 @@ var ArchiveAction = ActionBase.merge(
1949
2007
  import_zod19.z.object({
1950
2008
  type: import_zod19.z.literal(ActionType.ARCHIVE),
1951
2009
  reason: RejectionReason
2010
+ // TODO move into 'content' property
1952
2011
  })
1953
2012
  );
1954
2013
  var CreatedAction = ActionBase.merge(
@@ -1961,9 +2020,13 @@ var NotifiedAction = ActionBase.merge(
1961
2020
  type: import_zod19.z.literal(ActionType.NOTIFY)
1962
2021
  })
1963
2022
  );
2023
+ var PrintContent = import_zod19.z.object({
2024
+ templateId: import_zod19.z.string().optional()
2025
+ });
1964
2026
  var PrintCertificateAction = ActionBase.merge(
1965
2027
  import_zod19.z.object({
1966
- type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE)
2028
+ type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE),
2029
+ content: PrintContent.optional().nullable()
1967
2030
  })
1968
2031
  );
1969
2032
  var RequestedCorrectionAction = ActionBase.merge(
@@ -1975,12 +2038,15 @@ var ApprovedCorrectionAction = ActionBase.merge(
1975
2038
  import_zod19.z.object({
1976
2039
  type: import_zod19.z.literal(ActionType.APPROVE_CORRECTION),
1977
2040
  requestId: import_zod19.z.string()
2041
+ // TODO move into 'content' property
1978
2042
  })
1979
2043
  );
1980
2044
  var RejectedCorrectionAction = ActionBase.merge(
1981
2045
  import_zod19.z.object({
1982
2046
  type: import_zod19.z.literal(ActionType.REJECT_CORRECTION),
1983
- requestId: import_zod19.z.string()
2047
+ requestId: import_zod19.z.string(),
2048
+ // TODO move into 'content' property
2049
+ reason: RejectionReason
1984
2050
  })
1985
2051
  );
1986
2052
  var ReadAction = ActionBase.merge(
@@ -2030,7 +2096,7 @@ var ResolvedUser = import_zod19.z.object({
2030
2096
  });
2031
2097
 
2032
2098
  // ../commons/src/conditionals/validate.ts
2033
- var import_ajv = __toESM(require("ajv"));
2099
+ var import__ = __toESM(require("ajv/dist/2019"));
2034
2100
  var import_ajv_formats = __toESM(require("ajv-formats"));
2035
2101
  var import_date_fns = require("date-fns");
2036
2102
 
@@ -2244,9 +2310,11 @@ var isNonInteractiveFieldType = (field2) => {
2244
2310
  };
2245
2311
 
2246
2312
  // ../commons/src/conditionals/validate.ts
2247
- var ajv = new import_ajv.default({
2313
+ var ajv = new import__.default({
2248
2314
  $data: true,
2249
- allowUnionTypes: true
2315
+ allowUnionTypes: true,
2316
+ strict: false
2317
+ // Allow minContains and other newer features
2250
2318
  });
2251
2319
  (0, import_ajv_formats.default)(ajv);
2252
2320
  ajv.addKeyword({
@@ -2419,6 +2487,23 @@ function validateFieldInput({
2419
2487
  const rawError = zodType.safeParse(value, { errorMap: zodToIntlErrorMap });
2420
2488
  return rawError.error?.issues.map((issue) => issue.message) ?? [];
2421
2489
  }
2490
+ function runStructuralValidations({
2491
+ field: field2,
2492
+ values
2493
+ }) {
2494
+ if (!isFieldVisible(field2, values) || isFieldEmptyAndNotRequired(field2, values)) {
2495
+ return {
2496
+ errors: []
2497
+ };
2498
+ }
2499
+ const fieldValidationResult = validateFieldInput({
2500
+ field: field2,
2501
+ value: values[field2.id]
2502
+ });
2503
+ return {
2504
+ errors: fieldValidationResult
2505
+ };
2506
+ }
2422
2507
  function runFieldValidations({
2423
2508
  field: field2,
2424
2509
  values
@@ -2484,6 +2569,11 @@ function getValidatorsForField(fieldId, validations) {
2484
2569
  };
2485
2570
  }).filter((x) => x !== null);
2486
2571
  }
2572
+ function areCertificateConditionsMet(conditions, values) {
2573
+ return conditions.every((condition) => {
2574
+ return ajv.validate(condition.conditional, values);
2575
+ });
2576
+ }
2487
2577
 
2488
2578
  // ../commons/src/utils.ts
2489
2579
  function getOrThrow(x, message) {
@@ -2704,16 +2794,16 @@ function timePeriodToDateRange(value) {
2704
2794
  let startDate;
2705
2795
  switch (value) {
2706
2796
  case "last7Days":
2707
- startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 6);
2797
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 7);
2708
2798
  break;
2709
2799
  case "last30Days":
2710
- startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 29);
2800
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 30);
2711
2801
  break;
2712
2802
  case "last90Days":
2713
- startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 89);
2803
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 90);
2714
2804
  break;
2715
2805
  case "last365Days":
2716
- startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 364);
2806
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 365);
2717
2807
  break;
2718
2808
  }
2719
2809
  return {
@@ -3080,8 +3170,9 @@ function createFieldConditionals(fieldId) {
3080
3170
  properties: {
3081
3171
  [fieldId]: {
3082
3172
  type: "string",
3083
- pattern: "^[\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*( [\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*)*$",
3084
- description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
3173
+ minLength: 1,
3174
+ pattern: "^[\\p{Script=Latin}0-9'.-]*(\\([\\p{Script=Latin}0-9'.-]+\\))?[\\p{Script=Latin}0-9'.-]*( [\\p{Script=Latin}0-9'.-]*(\\([\\p{Script=Latin}0-9'.-]+\\))?[\\p{Script=Latin}0-9'.-]*)*$",
3175
+ description: "Name must contain only letters, numbers, and allowed special characters ('.-). No double spaces."
3085
3176
  }
3086
3177
  }
3087
3178
  }),
@@ -3174,6 +3265,19 @@ function createSearchConfig(baseField) {
3174
3265
  fuzzy: () => ({
3175
3266
  ...baseField,
3176
3267
  config: { type: "fuzzy" }
3268
+ }),
3269
+ /**
3270
+ * Creates a configuration for matching locations and the child locations
3271
+ * @returns An object containing the field ID and a configuration object with a type of 'within'.
3272
+ * @example field('createdAtLocation').within()
3273
+ * // {
3274
+ * // ...
3275
+ * // config: { type: 'within' }
3276
+ * // }
3277
+ */
3278
+ within: () => ({
3279
+ ...baseField,
3280
+ config: { type: "within" }
3177
3281
  })
3178
3282
  };
3179
3283
  }
@@ -3181,7 +3285,7 @@ function createSearchConfig(baseField) {
3181
3285
  // ../commons/src/event-config/event-configuration.ts
3182
3286
  function createEventFieldConfig(fieldId) {
3183
3287
  const baseField = {
3184
- fieldId,
3288
+ fieldId: `${METADATA_FIELD_PREFIX}${fieldId}`,
3185
3289
  fieldType: "event"
3186
3290
  };
3187
3291
  return createSearchConfig(baseField);
@@ -3194,32 +3298,107 @@ function eventFn(fieldId) {
3194
3298
  var event = Object.assign(eventFn, {
3195
3299
  /**
3196
3300
  * Checks if the event contains a specific action type.
3301
+ * Can be used directly as a conditional or chained with additional methods.
3197
3302
  * @param action - The action type to check for.
3198
3303
  */
3199
- hasAction: (action) => defineConditional({
3200
- type: "object",
3201
- properties: {
3202
- $event: {
3304
+ hasAction: (action) => {
3305
+ const basicConditional = defineConditional({
3306
+ type: "object",
3307
+ properties: {
3308
+ $event: {
3309
+ type: "object",
3310
+ properties: {
3311
+ actions: {
3312
+ type: "array",
3313
+ contains: {
3314
+ type: "object",
3315
+ properties: {
3316
+ type: {
3317
+ const: action
3318
+ }
3319
+ },
3320
+ required: ["type"]
3321
+ }
3322
+ }
3323
+ },
3324
+ required: ["actions"]
3325
+ }
3326
+ },
3327
+ required: ["$event"]
3328
+ });
3329
+ const buildActionConstraints = (additionalFields) => {
3330
+ const actionProperties = {
3331
+ type: { const: action }
3332
+ };
3333
+ const requiredFields = ["type"];
3334
+ if (additionalFields) {
3335
+ Object.entries(additionalFields).forEach(([key, value]) => {
3336
+ actionProperties[key] = { const: value };
3337
+ requiredFields.push(key);
3338
+ });
3339
+ }
3340
+ return { actionProperties, requiredFields };
3341
+ };
3342
+ const createCountConditional = (countType, count, additionalFields) => {
3343
+ const { actionProperties, requiredFields } = buildActionConstraints(additionalFields);
3344
+ return defineConditional({
3203
3345
  type: "object",
3204
3346
  properties: {
3205
- actions: {
3206
- type: "array",
3207
- contains: {
3208
- type: "object",
3209
- properties: {
3210
- type: {
3211
- const: action
3212
- }
3213
- },
3214
- required: ["type"]
3215
- }
3347
+ $event: {
3348
+ type: "object",
3349
+ properties: {
3350
+ actions: {
3351
+ type: "array",
3352
+ contains: {
3353
+ type: "object",
3354
+ properties: actionProperties,
3355
+ required: requiredFields
3356
+ },
3357
+ [countType]: count
3358
+ }
3359
+ },
3360
+ required: ["actions"]
3216
3361
  }
3217
3362
  },
3218
- required: ["actions"]
3219
- }
3220
- },
3221
- required: ["$event"]
3222
- }),
3363
+ required: ["$event"]
3364
+ });
3365
+ };
3366
+ const withMinMax = (additionalFields) => {
3367
+ return {
3368
+ /**
3369
+ * Creates a conditional that checks if the event contains a specific action type
3370
+ * with a minimum count of occurrences.
3371
+ *
3372
+ * @param minCount - The minimum number of actions required.
3373
+ */
3374
+ minCount: (minCount) => createCountConditional("minContains", minCount, additionalFields),
3375
+ /**
3376
+ * Builds a conditional that sets a maximum count for the number of actions.
3377
+ * This is useful for limiting the number of actions of a specific type in a single event.
3378
+ */
3379
+ maxCount: (maxCount) => createCountConditional("maxContains", maxCount, additionalFields)
3380
+ };
3381
+ };
3382
+ const chainableMethods = {
3383
+ /**
3384
+ * Adds additional field constraints to the action matching.
3385
+ *
3386
+ * @param fields - Object containing additional fields to match on the action.
3387
+ */
3388
+ withFields: (fields) => withMinMax(fields),
3389
+ /**
3390
+ * Adds template ID constraint to the action matching.
3391
+ * This is a convenience method that adds content.templateId to the fields.
3392
+ *
3393
+ * @param id - The template ID to match against.
3394
+ */
3395
+ withTemplate: (id) => withMinMax({
3396
+ content: { templateId: id }
3397
+ }),
3398
+ ...withMinMax()
3399
+ };
3400
+ return { ...basicConditional, ...chainableMethods };
3401
+ },
3223
3402
  field(field2) {
3224
3403
  return {
3225
3404
  $event: field2
@@ -3238,24 +3417,23 @@ var EventStatus = import_zod23.z.enum([
3238
3417
  "DECLARED",
3239
3418
  "VALIDATED",
3240
3419
  "REGISTERED",
3241
- "CERTIFIED",
3242
3420
  "ARCHIVED"
3243
3421
  ]);
3244
- var VisibleStatus = import_zod23.z.enum([...EventStatus.options, "REJECTED"]);
3245
3422
  var InherentFlags = {
3246
- PRINTED: "printed",
3423
+ PENDING_CERTIFICATION: "pending-certification",
3247
3424
  INCOMPLETE: "incomplete",
3248
3425
  REJECTED: "rejected",
3249
3426
  CORRECTION_REQUESTED: "correction-requested"
3250
3427
  };
3251
- var Flag = import_zod23.z.string().regex(
3428
+ var ActionFlag = import_zod23.z.string().regex(
3252
3429
  new RegExp(
3253
3430
  `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
3254
3431
  ActionStatus
3255
3432
  ).join("|").toLowerCase()})$`
3256
3433
  ),
3257
3434
  "Flag must be in the format ActionType:ActionStatus (lowerCase)"
3258
- ).or(import_zod23.z.nativeEnum(InherentFlags));
3435
+ );
3436
+ var Flag = ActionFlag.or(import_zod23.z.nativeEnum(InherentFlags));
3259
3437
  var ZodDate = import_zod23.z.string().date();
3260
3438
  var ActionCreationMetadata = import_zod23.z.object({
3261
3439
  createdAt: import_zod23.z.string().datetime().describe("The timestamp when the action request was created."),
@@ -3523,6 +3701,9 @@ var QueryExpression = import_zod25.z.object({
3523
3701
  createdAt: import_zod25.z.optional(DateCondition),
3524
3702
  updatedAt: import_zod25.z.optional(DateCondition),
3525
3703
  "legalStatuses.REGISTERED.acceptedAt": import_zod25.z.optional(DateCondition),
3704
+ "legalStatuses.DECLARED.createdAtLocation": import_zod25.z.optional(
3705
+ import_zod25.z.union([Within, Exact])
3706
+ ),
3526
3707
  "legalStatuses.REGISTERED.createdAtLocation": import_zod25.z.optional(
3527
3708
  import_zod25.z.union([Within, Exact])
3528
3709
  ),
@@ -3768,7 +3949,8 @@ var WorkqueueConfig = import_zod28.z.object({
3768
3949
  })
3769
3950
  ),
3770
3951
  columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
3771
- icon: AvailableIcons
3952
+ icon: AvailableIcons,
3953
+ emptyMessage: TranslationConfig.optional()
3772
3954
  }).describe("Configuration for workqueue.");
3773
3955
  var WorkqueueConfigWithoutQuery = WorkqueueConfig.omit({
3774
3956
  query: true,
@@ -3787,7 +3969,8 @@ var WorkqueueConfigInput = import_zod28.z.object({
3787
3969
  })
3788
3970
  ),
3789
3971
  columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
3790
- icon: AvailableIcons
3972
+ icon: AvailableIcons,
3973
+ emptyMessage: TranslationConfig.optional()
3791
3974
  });
3792
3975
  function defineWorkqueue(workqueueInput) {
3793
3976
  const queryInput = workqueueInput.query;
@@ -3876,7 +4059,8 @@ var DeclareActionInput = BaseActionInput.merge(
3876
4059
  );
3877
4060
  var PrintCertificateActionInput = BaseActionInput.merge(
3878
4061
  import_zod29.z.object({
3879
- type: import_zod29.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
4062
+ type: import_zod29.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE),
4063
+ content: PrintContent.optional()
3880
4064
  })
3881
4065
  );
3882
4066
  var RejectDeclarationActionInput = BaseActionInput.merge(
@@ -3916,7 +4100,8 @@ var RequestCorrectionActionInput = BaseActionInput.merge(
3916
4100
  var RejectCorrectionActionInput = BaseActionInput.merge(
3917
4101
  import_zod29.z.object({
3918
4102
  requestId: import_zod29.z.string(),
3919
- type: import_zod29.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
4103
+ type: import_zod29.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION),
4104
+ reason: RejectionReason
3920
4105
  })
3921
4106
  );
3922
4107
  var ApproveCorrectionActionInput = BaseActionInput.merge(
@@ -4087,16 +4272,19 @@ function getLegalStatuses(actions) {
4087
4272
  }
4088
4273
 
4089
4274
  // ../commons/src/events/state/flags.ts
4090
- function isCertificatePrinted(actions) {
4275
+ function isPendingCertification(actions) {
4276
+ if (getStatusFromActions(actions) !== EventStatus.enum.REGISTERED) {
4277
+ return false;
4278
+ }
4091
4279
  return actions.reduce((prev, { type }) => {
4092
4280
  if (type === ActionType.PRINT_CERTIFICATE) {
4093
- return true;
4281
+ return false;
4094
4282
  }
4095
4283
  if (type === ActionType.APPROVE_CORRECTION) {
4096
- return false;
4284
+ return true;
4097
4285
  }
4098
4286
  return prev;
4099
- }, false);
4287
+ }, true);
4100
4288
  }
4101
4289
  function isCorrectionRequested(actions) {
4102
4290
  return actions.reduce((prev, { type }) => {
@@ -4131,8 +4319,8 @@ function getFlagsFromActions(actions) {
4131
4319
  const flag = joinValues([type, status], ":").toLowerCase();
4132
4320
  return flag;
4133
4321
  });
4134
- if (isCertificatePrinted(sortedActions)) {
4135
- flags.push(InherentFlags.PRINTED);
4322
+ if (isPendingCertification(sortedActions)) {
4323
+ flags.push(InherentFlags.PENDING_CERTIFICATION);
4136
4324
  }
4137
4325
  if (isCorrectionRequested(sortedActions)) {
4138
4326
  flags.push(InherentFlags.CORRECTION_REQUESTED);
@@ -4163,7 +4351,6 @@ function getStatusFromActions(actions) {
4163
4351
  case ActionType.NOTIFY:
4164
4352
  return EventStatus.enum.NOTIFIED;
4165
4353
  case ActionType.PRINT_CERTIFICATE:
4166
- return EventStatus.enum.CERTIFIED;
4167
4354
  case ActionType.ASSIGN:
4168
4355
  case ActionType.UNASSIGN:
4169
4356
  case ActionType.REJECT:
@@ -4292,7 +4479,7 @@ function getCurrentEventStateWithDrafts({
4292
4479
  configuration
4293
4480
  }) {
4294
4481
  const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
4295
- const activeDrafts = findActiveDrafts(event2, drafts).map((draft) => draft.action).flatMap((action) => {
4482
+ const activeDrafts = drafts.map((draft) => draft.action).flatMap((action) => {
4296
4483
  if (action.type === ActionType.REQUEST_CORRECTION) {
4297
4484
  return [
4298
4485
  action,
@@ -5128,7 +5315,27 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
5128
5315
  defaultMessage: "Applicant's name",
5129
5316
  description: "This is the label for the field",
5130
5317
  id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.firstname.label"
5131
- }
5318
+ },
5319
+ configuration: {
5320
+ name: {
5321
+ firstname: { required: true },
5322
+ middlename: { required: false },
5323
+ surname: { required: true }
5324
+ }
5325
+ },
5326
+ validation: [
5327
+ {
5328
+ validator: field("applicant.name").object({
5329
+ firstname: field("firstname").isValidEnglishName(),
5330
+ surname: field("surname").isValidEnglishName()
5331
+ }),
5332
+ message: {
5333
+ defaultMessage: "Input contains invalid characters. Please use only letters (a-z, A-Z), numbers (0-9), hyphens (-), apostrophes(') and underscores (_)",
5334
+ description: "This is the error message for invalid name",
5335
+ id: "v2.error.invalidName"
5336
+ }
5337
+ }
5338
+ ]
5132
5339
  },
5133
5340
  {
5134
5341
  id: "applicant.email",
@@ -5350,22 +5557,6 @@ var statusOptions = [
5350
5557
  id: "v2.advancedSearch.form.recordStatusRegistered"
5351
5558
  }
5352
5559
  },
5353
- {
5354
- value: EventStatus.enum.CERTIFIED,
5355
- label: {
5356
- defaultMessage: "Certified",
5357
- description: "Option for form field: status of record",
5358
- id: "v2.advancedSearch.form.recordStatusCertified"
5359
- }
5360
- },
5361
- {
5362
- value: VisibleStatus.enum.REJECTED,
5363
- label: {
5364
- defaultMessage: "Rejected",
5365
- description: "Option for form field: status of record",
5366
- id: "v2.advancedSearch.form.recordStatusRejected"
5367
- }
5368
- },
5369
5560
  {
5370
5561
  value: EventStatus.enum.ARCHIVED,
5371
5562
  label: {
@@ -6755,7 +6946,7 @@ function eventPayloadGenerator(rng) {
6755
6946
  requestId,
6756
6947
  keepAssignment: input.keepAssignment
6757
6948
  }),
6758
- reject: (eventId, requestId, input = {}) => ({
6949
+ reject: (eventId, requestId, input) => ({
6759
6950
  type: ActionType.REJECT_CORRECTION,
6760
6951
  transactionId: input.transactionId ?? getUUID(),
6761
6952
  declaration: {},
@@ -6766,7 +6957,8 @@ function eventPayloadGenerator(rng) {
6766
6957
  ),
6767
6958
  eventId,
6768
6959
  requestId,
6769
- keepAssignment: input.keepAssignment
6960
+ keepAssignment: input.keepAssignment,
6961
+ reason: input.reason ?? { message: "" }
6770
6962
  })
6771
6963
  }
6772
6964
  }
@@ -6816,7 +7008,11 @@ function generateActionDocument({
6816
7008
  case ActionType.NOTIFY:
6817
7009
  return { ...actionBase, type: action };
6818
7010
  case ActionType.PRINT_CERTIFICATE:
6819
- return { ...actionBase, type: action };
7011
+ return {
7012
+ ...actionBase,
7013
+ type: action,
7014
+ content: defaults.content
7015
+ };
6820
7016
  case ActionType.REQUEST_CORRECTION:
6821
7017
  return { ...actionBase, type: action };
6822
7018
  case ActionType.APPROVE_CORRECTION:
@@ -6825,7 +7021,8 @@ function generateActionDocument({
6825
7021
  return {
6826
7022
  ...actionBase,
6827
7023
  requestId: getUUID(),
6828
- type: action
7024
+ type: action,
7025
+ reason: { message: "Correction rejection" }
6829
7026
  };
6830
7027
  case ActionType.REGISTER:
6831
7028
  return {
@@ -7215,14 +7412,6 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7215
7412
  ActionType.REJECT_CORRECTION,
7216
7413
  ExclusiveActions.REVIEW_CORRECTION_REQUEST
7217
7414
  ],
7218
- [EventStatus.enum.CERTIFIED]: [
7219
- ActionType.READ,
7220
- ActionType.PRINT_CERTIFICATE,
7221
- ActionType.REQUEST_CORRECTION,
7222
- ActionType.APPROVE_CORRECTION,
7223
- ActionType.REJECT_CORRECTION,
7224
- ExclusiveActions.REVIEW_CORRECTION_REQUEST
7225
- ],
7226
7415
  [EventStatus.enum.ARCHIVED]: [
7227
7416
  ActionType.READ,
7228
7417
  ActionType.ASSIGN,
@@ -7230,9 +7419,12 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7230
7419
  ]
7231
7420
  };
7232
7421
  var getAvailableActionsForEvent = (event2) => {
7233
- return event2.flags.includes(InherentFlags.REJECTED) ? [
7234
- ActionType.READ,
7235
- event2.status === EventStatus.Enum.VALIDATED ? ActionType.VALIDATE : ActionType.DECLARE,
7236
- ActionType.ARCHIVE
7237
- ] : AVAILABLE_ACTIONS_BY_EVENT_STATUS[event2.status];
7422
+ if (event2.flags.includes(InherentFlags.REJECTED)) {
7423
+ return [
7424
+ ActionType.READ,
7425
+ event2.status === EventStatus.Enum.VALIDATED ? ActionType.VALIDATE : ActionType.DECLARE,
7426
+ ActionType.ARCHIVE
7427
+ ];
7428
+ }
7429
+ return AVAILABLE_ACTIONS_BY_EVENT_STATUS[event2.status];
7238
7430
  };