@opencrvs/toolkit 1.8.1-rc.e32d7b8 → 1.8.1-rc.ebf61ab

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 -796
  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 +1302 -1389
  5. package/dist/commons/events/ActionInput.d.ts +658 -1136
  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 -92
  10. package/dist/commons/events/EventConfig.d.ts +1281 -262
  11. package/dist/commons/events/EventDocument.d.ts +475 -846
  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 -96
  25. package/dist/conditionals/index.js +3 -2
  26. package/dist/events/index.js +293 -108
  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
@@ -39,8 +39,8 @@ __export(events_exports, {
39
39
  ActionConfig: () => ActionConfig,
40
40
  ActionConfigBase: () => ActionConfigBase,
41
41
  ActionCreationMetadata: () => ActionCreationMetadata,
42
- ActionDetails: () => ActionDetails,
43
42
  ActionDocument: () => ActionDocument,
43
+ ActionFlag: () => ActionFlag,
44
44
  ActionFormConfig: () => ActionFormConfig,
45
45
  ActionInput: () => ActionInput,
46
46
  ActionStatus: () => ActionStatus,
@@ -96,6 +96,7 @@ __export(events_exports, {
96
96
  EventDocument: () => EventDocument,
97
97
  EventFieldConfigSchema: () => EventFieldConfigSchema,
98
98
  EventFieldId: () => EventFieldId,
99
+ EventFieldIdInput: () => EventFieldIdInput,
99
100
  EventIndex: () => EventIndex,
100
101
  EventInput: () => EventInput,
101
102
  EventMetadata: () => EventMetadata,
@@ -130,8 +131,10 @@ __export(events_exports, {
130
131
  InherentFlags: () => InherentFlags,
131
132
  LanguageConfig: () => LanguageConfig,
132
133
  LegalStatuses: () => LegalStatuses,
134
+ METADATA_FIELD_PREFIX: () => METADATA_FIELD_PREFIX,
133
135
  MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
134
136
  MimeType: () => MimeType,
137
+ NameConfig: () => NameConfig,
135
138
  NameFieldUpdateValue: () => NameFieldUpdateValue,
136
139
  NameFieldValue: () => NameFieldValue,
137
140
  NonEmptyTextValue: () => NonEmptyTextValue,
@@ -140,6 +143,7 @@ __export(events_exports, {
140
143
  PageConfig: () => PageConfig,
141
144
  PageTypes: () => PageTypes,
142
145
  PrintCertificateActionInput: () => PrintCertificateActionInput,
146
+ PrintContent: () => PrintContent,
143
147
  QueryExpression: () => QueryExpression,
144
148
  QueryInput: () => QueryInput,
145
149
  QueryType: () => QueryType,
@@ -168,6 +172,7 @@ __export(events_exports, {
168
172
  TENNIS_CLUB_MEMBERSHIP: () => TENNIS_CLUB_MEMBERSHIP,
169
173
  TEST_SYSTEM_IANA_TIMEZONE: () => TEST_SYSTEM_IANA_TIMEZONE,
170
174
  TestUserRole: () => TestUserRole,
175
+ TextField: () => TextField,
171
176
  TextValue: () => TextValue,
172
177
  TimeValue: () => TimeValue,
173
178
  TranslationConfig: () => TranslationConfig,
@@ -179,7 +184,6 @@ __export(events_exports, {
179
184
  ValidationConfig: () => ValidationConfig,
180
185
  VerificationActionConfig: () => VerificationActionConfig,
181
186
  VerificationPageConfig: () => VerificationPageConfig,
182
- VisibleStatus: () => VisibleStatus,
183
187
  WRITE_ACTION_SCOPES: () => WRITE_ACTION_SCOPES,
184
188
  Within: () => Within,
185
189
  WorkqueueActionsWithDefault: () => WorkqueueActionsWithDefault,
@@ -198,6 +202,7 @@ __export(events_exports, {
198
202
  annotationActions: () => annotationActions,
199
203
  applyDeclarationToEventIndex: () => applyDeclarationToEventIndex,
200
204
  applyDraftsToEventIndex: () => applyDraftsToEventIndex,
205
+ areCertificateConditionsMet: () => areCertificateConditionsMet,
201
206
  areConditionsMet: () => areConditionsMet,
202
207
  compositeFieldTypes: () => compositeFieldTypes,
203
208
  createEmptyDraft: () => createEmptyDraft,
@@ -321,6 +326,7 @@ __export(events_exports, {
321
326
  or: () => or,
322
327
  resolveDateOfEvent: () => resolveDateOfEvent,
323
328
  runFieldValidations: () => runFieldValidations,
329
+ runStructuralValidations: () => runStructuralValidations,
324
330
  timePeriodToDateRange: () => timePeriodToDateRange,
325
331
  user: () => user,
326
332
  validate: () => validate,
@@ -555,7 +561,7 @@ var import_zod6 = require("zod");
555
561
  var import_zod4 = require("zod");
556
562
  var import_zod_openapi3 = require("zod-openapi");
557
563
  (0, import_zod_openapi3.extendZodWithOpenApi)(import_zod4.z);
558
- var FullDocumentURL = import_zod4.z.string().brand("FullDocumentURL").describe(
564
+ var FullDocumentUrl = import_zod4.z.string().brand("FullDocumentUrl").describe(
559
565
  "A full url with protocol, host, bucket name, starting from the root of the S3 server, https://minio/bucket-name/document-id.jpg"
560
566
  );
561
567
  var FullDocumentPath = import_zod4.z.string().transform((val) => val.startsWith("/") ? val : `/${val}`).openapi({ effectType: "input", type: "string" }).describe(
@@ -612,8 +618,8 @@ var NameFieldValue = import_zod5.z.object({
612
618
  middlename: import_zod5.z.string().optional()
613
619
  });
614
620
  var NameFieldUpdateValue = import_zod5.z.object({
615
- firstname: import_zod5.z.string().nullish(),
616
- surname: import_zod5.z.string().nullish(),
621
+ firstname: import_zod5.z.string(),
622
+ surname: import_zod5.z.string(),
617
623
  middlename: import_zod5.z.string().nullish()
618
624
  }).or(import_zod5.z.null()).or(import_zod5.z.undefined());
619
625
  var RuralAddressUpdateValue = AdminStructure.extend({
@@ -910,18 +916,32 @@ var SelectDateRangeField = BaseField.extend({
910
916
  defaultValue: SelectDateRangeValue.optional(),
911
917
  options: import_zod7.z.array(SelectDateRangeOption).describe("A list of options")
912
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
+ });
913
924
  var NameField = BaseField.extend({
914
925
  type: import_zod7.z.literal(FieldType.NAME),
915
926
  defaultValue: import_zod7.z.object({
916
- firstname: NonEmptyTextValue,
917
- surname: NonEmptyTextValue
927
+ firstname: NonEmptyTextValue.optional(),
928
+ middlename: NonEmptyTextValue.optional(),
929
+ surname: NonEmptyTextValue.optional()
918
930
  }).optional(),
919
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(),
920
937
  maxLength: import_zod7.z.number().optional().describe("Maximum length of the text"),
921
938
  prefix: TranslationConfig.optional(),
922
- postfix: TranslationConfig.optional(),
923
- includeMiddlename: import_zod7.z.boolean().default(false).optional().describe("To make middle name visible in Name form field"),
924
- searchMode: import_zod7.z.boolean().optional()
939
+ postfix: TranslationConfig.optional()
940
+ }).default({
941
+ name: {
942
+ firstname: { required: true },
943
+ surname: { required: true }
944
+ }
925
945
  }).optional()
926
946
  }).describe("Name input field");
927
947
  var PhoneField = BaseField.extend({
@@ -984,10 +1004,32 @@ var Office = BaseField.extend({
984
1004
  }).describe("Input field for an office");
985
1005
  var Address = BaseField.extend({
986
1006
  type: import_zod7.z.literal(FieldType.ADDRESS),
987
- defaultValue: AddressFieldValue.optional(),
988
1007
  configuration: import_zod7.z.object({
989
- searchMode: import_zod7.z.boolean().optional()
990
- }).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()
991
1033
  }).describe("Address input field \u2013 a combination of location and text fields");
992
1034
  var DataEntry = import_zod7.z.union([
993
1035
  import_zod7.z.object({
@@ -1223,7 +1265,8 @@ var CertificateConfig = import_zod11.z.object({
1223
1265
  delayed: import_zod11.z.number()
1224
1266
  }),
1225
1267
  svgUrl: import_zod11.z.string(),
1226
- fonts: import_zod11.z.record(FontFamily).optional()
1268
+ fonts: import_zod11.z.record(FontFamily).optional(),
1269
+ conditionals: import_zod11.z.array(ShowConditional).optional()
1227
1270
  });
1228
1271
  var CertificateTemplateConfig = CertificateConfig.extend({
1229
1272
  hash: import_zod11.z.string().optional(),
@@ -1341,7 +1384,7 @@ var SummaryConfig = import_zod14.z.object({
1341
1384
 
1342
1385
  // ../commons/src/events/AdvancedSearchConfig.ts
1343
1386
  var import_zod15 = require("zod");
1344
- var MatchType = import_zod15.z.enum(["fuzzy", "exact", "range"]);
1387
+ var MatchType = import_zod15.z.enum(["fuzzy", "exact", "range", "within"]);
1345
1388
  var BaseField3 = import_zod15.z.object({
1346
1389
  config: import_zod15.z.object({
1347
1390
  type: MatchType.describe("Determines the type of field")
@@ -1395,22 +1438,30 @@ var FieldConfigSchema = BaseField3.extend({
1395
1438
  fieldType: import_zod15.z.literal("field"),
1396
1439
  alternateFieldIds: import_zod15.z.array(import_zod15.z.string()).optional().describe(
1397
1440
  `Sometimes there might be need to search a value against multiple field of same FormField type. For example
1398
- 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
1399
1442
  add a one field as fieldId, and accomodate others in alternateFieldIds`
1400
1443
  ),
1401
- excludeInSearchQuery: import_zod15.z.boolean().default(false).optional().describe(`Sometimes there will be search fields which are used to
1402
- 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
1403
1446
  is select field, which has 3 options, FACILITY, PRIVATE_HOME, OTHER. Upon selecting any of the option, pops up another field
1404
1447
  related to the selected option, whose value is required in the search query. But child.placeOfBirth itself is not needed in the query.
1405
1448
  In such case, populate this field (excludeInSearchQuery) with boolean true`)
1406
1449
  });
1407
- var EventFieldId = import_zod15.z.enum([
1450
+ var EventFieldIdInput = import_zod15.z.enum([
1408
1451
  "trackingId",
1409
1452
  "status",
1410
1453
  "legalStatuses.REGISTERED.acceptedAt",
1411
1454
  "legalStatuses.REGISTERED.createdAtLocation",
1412
1455
  "updatedAt"
1413
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
+ ]);
1414
1465
  var EventFieldConfigSchema = BaseField3.extend({
1415
1466
  fieldId: EventFieldId,
1416
1467
  fieldType: import_zod15.z.literal("event")
@@ -1883,10 +1934,6 @@ var ActionStatus = {
1883
1934
  Accepted: "Accepted",
1884
1935
  Rejected: "Rejected"
1885
1936
  };
1886
- var ActionDetails = import_zod19.z.object({
1887
- templateId: import_zod19.z.string().optional(),
1888
- isImmediateCorrection: import_zod19.z.boolean().optional()
1889
- });
1890
1937
  var ActionBase = import_zod19.z.object({
1891
1938
  id: UUID,
1892
1939
  transactionId: import_zod19.z.string(),
@@ -1898,7 +1945,6 @@ var ActionBase = import_zod19.z.object({
1898
1945
  createdAtLocation: CreatedAtLocation,
1899
1946
  declaration: ActionUpdate,
1900
1947
  annotation: ActionUpdate.optional().nullable(),
1901
- actionDetails: ActionDetails.optional().nullable(),
1902
1948
  status: import_zod19.z.enum([
1903
1949
  ActionStatus.Requested,
1904
1950
  ActionStatus.Accepted,
@@ -1908,11 +1954,15 @@ var ActionBase = import_zod19.z.object({
1908
1954
  originalActionId: UUID.optional().nullable().describe(
1909
1955
  "Reference to the original action that was asynchronously rejected or accepted by 3rd party integration."
1910
1956
  )
1957
+ // 'content' field reserved for additional data
1958
+ // Each action can define its own content specifc to the action
1959
+ // See PrintCertificateAction
1911
1960
  });
1912
1961
  var AssignedAction = ActionBase.merge(
1913
1962
  import_zod19.z.object({
1914
1963
  type: import_zod19.z.literal(ActionType.ASSIGN),
1915
1964
  assignedTo: import_zod19.z.string()
1965
+ // TODO move into 'content' property
1916
1966
  })
1917
1967
  );
1918
1968
  var UnassignedAction = ActionBase.merge(
@@ -1924,6 +1974,7 @@ var RegisterAction = ActionBase.merge(
1924
1974
  import_zod19.z.object({
1925
1975
  type: import_zod19.z.literal(ActionType.REGISTER),
1926
1976
  registrationNumber: import_zod19.z.string().optional()
1977
+ // TODO move into 'content' property
1927
1978
  })
1928
1979
  );
1929
1980
  var DeclareAction = ActionBase.merge(
@@ -1944,6 +1995,7 @@ var RejectAction = ActionBase.merge(
1944
1995
  import_zod19.z.object({
1945
1996
  type: import_zod19.z.literal(ActionType.REJECT),
1946
1997
  reason: RejectionReason
1998
+ // TODO move into 'content' property
1947
1999
  })
1948
2000
  );
1949
2001
  var MarkAsDuplicateAction = ActionBase.merge(
@@ -1955,6 +2007,7 @@ var ArchiveAction = ActionBase.merge(
1955
2007
  import_zod19.z.object({
1956
2008
  type: import_zod19.z.literal(ActionType.ARCHIVE),
1957
2009
  reason: RejectionReason
2010
+ // TODO move into 'content' property
1958
2011
  })
1959
2012
  );
1960
2013
  var CreatedAction = ActionBase.merge(
@@ -1967,9 +2020,13 @@ var NotifiedAction = ActionBase.merge(
1967
2020
  type: import_zod19.z.literal(ActionType.NOTIFY)
1968
2021
  })
1969
2022
  );
2023
+ var PrintContent = import_zod19.z.object({
2024
+ templateId: import_zod19.z.string().optional()
2025
+ });
1970
2026
  var PrintCertificateAction = ActionBase.merge(
1971
2027
  import_zod19.z.object({
1972
- type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE)
2028
+ type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE),
2029
+ content: PrintContent.optional().nullable()
1973
2030
  })
1974
2031
  );
1975
2032
  var RequestedCorrectionAction = ActionBase.merge(
@@ -1981,12 +2038,15 @@ var ApprovedCorrectionAction = ActionBase.merge(
1981
2038
  import_zod19.z.object({
1982
2039
  type: import_zod19.z.literal(ActionType.APPROVE_CORRECTION),
1983
2040
  requestId: import_zod19.z.string()
2041
+ // TODO move into 'content' property
1984
2042
  })
1985
2043
  );
1986
2044
  var RejectedCorrectionAction = ActionBase.merge(
1987
2045
  import_zod19.z.object({
1988
2046
  type: import_zod19.z.literal(ActionType.REJECT_CORRECTION),
1989
- requestId: import_zod19.z.string()
2047
+ requestId: import_zod19.z.string(),
2048
+ // TODO move into 'content' property
2049
+ reason: RejectionReason
1990
2050
  })
1991
2051
  );
1992
2052
  var ReadAction = ActionBase.merge(
@@ -2036,7 +2096,7 @@ var ResolvedUser = import_zod19.z.object({
2036
2096
  });
2037
2097
 
2038
2098
  // ../commons/src/conditionals/validate.ts
2039
- var import_ajv = __toESM(require("ajv"));
2099
+ var import__ = __toESM(require("ajv/dist/2019"));
2040
2100
  var import_ajv_formats = __toESM(require("ajv-formats"));
2041
2101
  var import_date_fns = require("date-fns");
2042
2102
 
@@ -2250,9 +2310,11 @@ var isNonInteractiveFieldType = (field2) => {
2250
2310
  };
2251
2311
 
2252
2312
  // ../commons/src/conditionals/validate.ts
2253
- var ajv = new import_ajv.default({
2313
+ var ajv = new import__.default({
2254
2314
  $data: true,
2255
- allowUnionTypes: true
2315
+ allowUnionTypes: true,
2316
+ strict: false
2317
+ // Allow minContains and other newer features
2256
2318
  });
2257
2319
  (0, import_ajv_formats.default)(ajv);
2258
2320
  ajv.addKeyword({
@@ -2425,6 +2487,23 @@ function validateFieldInput({
2425
2487
  const rawError = zodType.safeParse(value, { errorMap: zodToIntlErrorMap });
2426
2488
  return rawError.error?.issues.map((issue) => issue.message) ?? [];
2427
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
+ }
2428
2507
  function runFieldValidations({
2429
2508
  field: field2,
2430
2509
  values
@@ -2490,6 +2569,11 @@ function getValidatorsForField(fieldId, validations) {
2490
2569
  };
2491
2570
  }).filter((x) => x !== null);
2492
2571
  }
2572
+ function areCertificateConditionsMet(conditions, values) {
2573
+ return conditions.every((condition) => {
2574
+ return ajv.validate(condition.conditional, values);
2575
+ });
2576
+ }
2493
2577
 
2494
2578
  // ../commons/src/utils.ts
2495
2579
  function getOrThrow(x, message) {
@@ -2710,16 +2794,16 @@ function timePeriodToDateRange(value) {
2710
2794
  let startDate;
2711
2795
  switch (value) {
2712
2796
  case "last7Days":
2713
- startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 6);
2797
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 7);
2714
2798
  break;
2715
2799
  case "last30Days":
2716
- startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 29);
2800
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 30);
2717
2801
  break;
2718
2802
  case "last90Days":
2719
- startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 89);
2803
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 90);
2720
2804
  break;
2721
2805
  case "last365Days":
2722
- startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 364);
2806
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 365);
2723
2807
  break;
2724
2808
  }
2725
2809
  return {
@@ -3086,8 +3170,9 @@ function createFieldConditionals(fieldId) {
3086
3170
  properties: {
3087
3171
  [fieldId]: {
3088
3172
  type: "string",
3089
- 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'._-]*)*$",
3090
- 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."
3091
3176
  }
3092
3177
  }
3093
3178
  }),
@@ -3180,6 +3265,19 @@ function createSearchConfig(baseField) {
3180
3265
  fuzzy: () => ({
3181
3266
  ...baseField,
3182
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" }
3183
3281
  })
3184
3282
  };
3185
3283
  }
@@ -3187,7 +3285,7 @@ function createSearchConfig(baseField) {
3187
3285
  // ../commons/src/event-config/event-configuration.ts
3188
3286
  function createEventFieldConfig(fieldId) {
3189
3287
  const baseField = {
3190
- fieldId,
3288
+ fieldId: `${METADATA_FIELD_PREFIX}${fieldId}`,
3191
3289
  fieldType: "event"
3192
3290
  };
3193
3291
  return createSearchConfig(baseField);
@@ -3200,32 +3298,107 @@ function eventFn(fieldId) {
3200
3298
  var event = Object.assign(eventFn, {
3201
3299
  /**
3202
3300
  * Checks if the event contains a specific action type.
3301
+ * Can be used directly as a conditional or chained with additional methods.
3203
3302
  * @param action - The action type to check for.
3204
3303
  */
3205
- hasAction: (action) => defineConditional({
3206
- type: "object",
3207
- properties: {
3208
- $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({
3209
3345
  type: "object",
3210
3346
  properties: {
3211
- actions: {
3212
- type: "array",
3213
- contains: {
3214
- type: "object",
3215
- properties: {
3216
- type: {
3217
- const: action
3218
- }
3219
- },
3220
- required: ["type"]
3221
- }
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"]
3222
3361
  }
3223
3362
  },
3224
- required: ["actions"]
3225
- }
3226
- },
3227
- required: ["$event"]
3228
- }),
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
+ },
3229
3402
  field(field2) {
3230
3403
  return {
3231
3404
  $event: field2
@@ -3244,24 +3417,23 @@ var EventStatus = import_zod23.z.enum([
3244
3417
  "DECLARED",
3245
3418
  "VALIDATED",
3246
3419
  "REGISTERED",
3247
- "CERTIFIED",
3248
3420
  "ARCHIVED"
3249
3421
  ]);
3250
- var VisibleStatus = import_zod23.z.enum([...EventStatus.options, "REJECTED"]);
3251
3422
  var InherentFlags = {
3252
- PRINTED: "printed",
3423
+ PENDING_CERTIFICATION: "pending-certification",
3253
3424
  INCOMPLETE: "incomplete",
3254
3425
  REJECTED: "rejected",
3255
3426
  CORRECTION_REQUESTED: "correction-requested"
3256
3427
  };
3257
- var Flag = import_zod23.z.string().regex(
3428
+ var ActionFlag = import_zod23.z.string().regex(
3258
3429
  new RegExp(
3259
3430
  `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
3260
3431
  ActionStatus
3261
3432
  ).join("|").toLowerCase()})$`
3262
3433
  ),
3263
3434
  "Flag must be in the format ActionType:ActionStatus (lowerCase)"
3264
- ).or(import_zod23.z.nativeEnum(InherentFlags));
3435
+ );
3436
+ var Flag = ActionFlag.or(import_zod23.z.nativeEnum(InherentFlags));
3265
3437
  var ZodDate = import_zod23.z.string().date();
3266
3438
  var ActionCreationMetadata = import_zod23.z.object({
3267
3439
  createdAt: import_zod23.z.string().datetime().describe("The timestamp when the action request was created."),
@@ -3529,6 +3701,9 @@ var QueryExpression = import_zod25.z.object({
3529
3701
  createdAt: import_zod25.z.optional(DateCondition),
3530
3702
  updatedAt: import_zod25.z.optional(DateCondition),
3531
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
+ ),
3532
3707
  "legalStatuses.REGISTERED.createdAtLocation": import_zod25.z.optional(
3533
3708
  import_zod25.z.union([Within, Exact])
3534
3709
  ),
@@ -3774,7 +3949,8 @@ var WorkqueueConfig = import_zod28.z.object({
3774
3949
  })
3775
3950
  ),
3776
3951
  columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
3777
- icon: AvailableIcons
3952
+ icon: AvailableIcons,
3953
+ emptyMessage: TranslationConfig.optional()
3778
3954
  }).describe("Configuration for workqueue.");
3779
3955
  var WorkqueueConfigWithoutQuery = WorkqueueConfig.omit({
3780
3956
  query: true,
@@ -3793,7 +3969,8 @@ var WorkqueueConfigInput = import_zod28.z.object({
3793
3969
  })
3794
3970
  ),
3795
3971
  columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
3796
- icon: AvailableIcons
3972
+ icon: AvailableIcons,
3973
+ emptyMessage: TranslationConfig.optional()
3797
3974
  });
3798
3975
  function defineWorkqueue(workqueueInput) {
3799
3976
  const queryInput = workqueueInput.query;
@@ -3840,7 +4017,6 @@ var BaseActionInput = import_zod29.z.object({
3840
4017
  transactionId: import_zod29.z.string(),
3841
4018
  declaration: ActionUpdate.default({}),
3842
4019
  annotation: ActionUpdate.optional(),
3843
- actionDetails: ActionDetails.optional(),
3844
4020
  originalActionId: UUID.optional(),
3845
4021
  // should not be part of base action.
3846
4022
  keepAssignment: import_zod29.z.boolean().optional()
@@ -3883,7 +4059,8 @@ var DeclareActionInput = BaseActionInput.merge(
3883
4059
  );
3884
4060
  var PrintCertificateActionInput = BaseActionInput.merge(
3885
4061
  import_zod29.z.object({
3886
- 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()
3887
4064
  })
3888
4065
  );
3889
4066
  var RejectDeclarationActionInput = BaseActionInput.merge(
@@ -3923,7 +4100,8 @@ var RequestCorrectionActionInput = BaseActionInput.merge(
3923
4100
  var RejectCorrectionActionInput = BaseActionInput.merge(
3924
4101
  import_zod29.z.object({
3925
4102
  requestId: import_zod29.z.string(),
3926
- 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
3927
4105
  })
3928
4106
  );
3929
4107
  var ApproveCorrectionActionInput = BaseActionInput.merge(
@@ -4094,16 +4272,19 @@ function getLegalStatuses(actions) {
4094
4272
  }
4095
4273
 
4096
4274
  // ../commons/src/events/state/flags.ts
4097
- function isCertificatePrinted(actions) {
4275
+ function isPendingCertification(actions) {
4276
+ if (getStatusFromActions(actions) !== EventStatus.enum.REGISTERED) {
4277
+ return false;
4278
+ }
4098
4279
  return actions.reduce((prev, { type }) => {
4099
4280
  if (type === ActionType.PRINT_CERTIFICATE) {
4100
- return true;
4281
+ return false;
4101
4282
  }
4102
4283
  if (type === ActionType.APPROVE_CORRECTION) {
4103
- return false;
4284
+ return true;
4104
4285
  }
4105
4286
  return prev;
4106
- }, false);
4287
+ }, true);
4107
4288
  }
4108
4289
  function isCorrectionRequested(actions) {
4109
4290
  return actions.reduce((prev, { type }) => {
@@ -4138,8 +4319,8 @@ function getFlagsFromActions(actions) {
4138
4319
  const flag = joinValues([type, status], ":").toLowerCase();
4139
4320
  return flag;
4140
4321
  });
4141
- if (isCertificatePrinted(sortedActions)) {
4142
- flags.push(InherentFlags.PRINTED);
4322
+ if (isPendingCertification(sortedActions)) {
4323
+ flags.push(InherentFlags.PENDING_CERTIFICATION);
4143
4324
  }
4144
4325
  if (isCorrectionRequested(sortedActions)) {
4145
4326
  flags.push(InherentFlags.CORRECTION_REQUESTED);
@@ -4170,7 +4351,6 @@ function getStatusFromActions(actions) {
4170
4351
  case ActionType.NOTIFY:
4171
4352
  return EventStatus.enum.NOTIFIED;
4172
4353
  case ActionType.PRINT_CERTIFICATE:
4173
- return EventStatus.enum.CERTIFIED;
4174
4354
  case ActionType.ASSIGN:
4175
4355
  case ActionType.UNASSIGN:
4176
4356
  case ActionType.REJECT:
@@ -4299,7 +4479,7 @@ function getCurrentEventStateWithDrafts({
4299
4479
  configuration
4300
4480
  }) {
4301
4481
  const actions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
4302
- const activeDrafts = findActiveDrafts(event2, drafts).map((draft) => draft.action).flatMap((action) => {
4482
+ const activeDrafts = drafts.map((draft) => draft.action).flatMap((action) => {
4303
4483
  if (action.type === ActionType.REQUEST_CORRECTION) {
4304
4484
  return [
4305
4485
  action,
@@ -5135,7 +5315,27 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
5135
5315
  defaultMessage: "Applicant's name",
5136
5316
  description: "This is the label for the field",
5137
5317
  id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.firstname.label"
5138
- }
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
+ ]
5139
5339
  },
5140
5340
  {
5141
5341
  id: "applicant.email",
@@ -5357,22 +5557,6 @@ var statusOptions = [
5357
5557
  id: "v2.advancedSearch.form.recordStatusRegistered"
5358
5558
  }
5359
5559
  },
5360
- {
5361
- value: EventStatus.enum.CERTIFIED,
5362
- label: {
5363
- defaultMessage: "Certified",
5364
- description: "Option for form field: status of record",
5365
- id: "v2.advancedSearch.form.recordStatusCertified"
5366
- }
5367
- },
5368
- {
5369
- value: VisibleStatus.enum.REJECTED,
5370
- label: {
5371
- defaultMessage: "Rejected",
5372
- description: "Option for form field: status of record",
5373
- id: "v2.advancedSearch.form.recordStatusRejected"
5374
- }
5375
- },
5376
5560
  {
5377
5561
  value: EventStatus.enum.ARCHIVED,
5378
5562
  label: {
@@ -6762,7 +6946,7 @@ function eventPayloadGenerator(rng) {
6762
6946
  requestId,
6763
6947
  keepAssignment: input.keepAssignment
6764
6948
  }),
6765
- reject: (eventId, requestId, input = {}) => ({
6949
+ reject: (eventId, requestId, input) => ({
6766
6950
  type: ActionType.REJECT_CORRECTION,
6767
6951
  transactionId: input.transactionId ?? getUUID(),
6768
6952
  declaration: {},
@@ -6773,7 +6957,8 @@ function eventPayloadGenerator(rng) {
6773
6957
  ),
6774
6958
  eventId,
6775
6959
  requestId,
6776
- keepAssignment: input.keepAssignment
6960
+ keepAssignment: input.keepAssignment,
6961
+ reason: input.reason ?? { message: "" }
6777
6962
  })
6778
6963
  }
6779
6964
  }
@@ -6823,7 +7008,11 @@ function generateActionDocument({
6823
7008
  case ActionType.NOTIFY:
6824
7009
  return { ...actionBase, type: action };
6825
7010
  case ActionType.PRINT_CERTIFICATE:
6826
- return { ...actionBase, type: action };
7011
+ return {
7012
+ ...actionBase,
7013
+ type: action,
7014
+ content: defaults.content
7015
+ };
6827
7016
  case ActionType.REQUEST_CORRECTION:
6828
7017
  return { ...actionBase, type: action };
6829
7018
  case ActionType.APPROVE_CORRECTION:
@@ -6832,7 +7021,8 @@ function generateActionDocument({
6832
7021
  return {
6833
7022
  ...actionBase,
6834
7023
  requestId: getUUID(),
6835
- type: action
7024
+ type: action,
7025
+ reason: { message: "Correction rejection" }
6836
7026
  };
6837
7027
  case ActionType.REGISTER:
6838
7028
  return {
@@ -7222,14 +7412,6 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7222
7412
  ActionType.REJECT_CORRECTION,
7223
7413
  ExclusiveActions.REVIEW_CORRECTION_REQUEST
7224
7414
  ],
7225
- [EventStatus.enum.CERTIFIED]: [
7226
- ActionType.READ,
7227
- ActionType.PRINT_CERTIFICATE,
7228
- ActionType.REQUEST_CORRECTION,
7229
- ActionType.APPROVE_CORRECTION,
7230
- ActionType.REJECT_CORRECTION,
7231
- ExclusiveActions.REVIEW_CORRECTION_REQUEST
7232
- ],
7233
7415
  [EventStatus.enum.ARCHIVED]: [
7234
7416
  ActionType.READ,
7235
7417
  ActionType.ASSIGN,
@@ -7237,9 +7419,12 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7237
7419
  ]
7238
7420
  };
7239
7421
  var getAvailableActionsForEvent = (event2) => {
7240
- return event2.flags.includes(InherentFlags.REJECTED) ? [
7241
- ActionType.READ,
7242
- event2.status === EventStatus.Enum.VALIDATED ? ActionType.VALIDATE : ActionType.DECLARE,
7243
- ActionType.ARCHIVE
7244
- ] : 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];
7245
7430
  };