@opencrvs/toolkit 1.8.1-rc.38ac682 → 1.8.1-rc.3a45fd9

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 (40) hide show
  1. package/build.sh +5 -0
  2. package/dist/commons/api/router.d.ts +409 -392
  3. package/dist/commons/conditionals/validate.d.ts +11 -2
  4. package/dist/commons/events/ActionConfig.d.ts +3441 -5805
  5. package/dist/commons/events/ActionDocument.d.ts +1252 -716
  6. package/dist/commons/events/ActionInput.d.ts +626 -600
  7. package/dist/commons/events/AdvancedSearchConfig.d.ts +83 -65
  8. package/dist/commons/events/CompositeFieldValue.d.ts +6 -6
  9. package/dist/commons/events/CountryConfigQueryInput.d.ts +88 -88
  10. package/dist/commons/events/Draft.d.ts +48 -48
  11. package/dist/commons/events/EventConfig.d.ts +1401 -2663
  12. package/dist/commons/events/EventDocument.d.ts +451 -432
  13. package/dist/commons/events/EventIndex.d.ts +184 -62
  14. package/dist/commons/events/EventMetadata.d.ts +9 -9
  15. package/dist/commons/events/FieldConfig.d.ts +254 -343
  16. package/dist/commons/events/FieldType.d.ts +1 -2
  17. package/dist/commons/events/FieldTypeMapping.d.ts +18 -25
  18. package/dist/commons/events/FieldValue.d.ts +12 -12
  19. package/dist/commons/events/FormConfig.d.ts +1296 -2388
  20. package/dist/commons/events/PageConfig.d.ts +264 -508
  21. package/dist/commons/events/WorkqueueConfig.d.ts +288 -164
  22. package/dist/commons/events/defineConfig.d.ts +129 -309
  23. package/dist/commons/events/event.d.ts +68 -6
  24. package/dist/commons/events/field.d.ts +14 -0
  25. package/dist/commons/events/test.utils.d.ts +12 -12
  26. package/dist/commons/events/utils.d.ts +248 -568
  27. package/dist/commons/notification/UserNotifications.d.ts +543 -0
  28. package/dist/commons/notification/index.d.ts +2 -0
  29. package/dist/conditionals/index.js +3 -2
  30. package/dist/events/index.js +258 -114
  31. package/dist/notification/index.d.ts +2 -0
  32. package/dist/notification/index.d.ts.map +1 -0
  33. package/dist/notification/index.js +5354 -0
  34. package/package.json +1 -1
  35. package/tsconfig.json +3 -2
  36. package/tsconfig.tsbuildinfo +1 -1
  37. package/dist/commons/conditionals/conditionals.test.d.ts +0 -2
  38. package/dist/commons/conditionals/validate-address.test.d.ts +0 -2
  39. package/dist/commons/conditionals/validate.test.d.ts +0 -2
  40. 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,
@@ -297,7 +303,6 @@ __export(events_exports, {
297
303
  isPageVisible: () => isPageVisible,
298
304
  isParagraphFieldType: () => isParagraphFieldType,
299
305
  isPhoneFieldType: () => isPhoneFieldType,
300
- isPrintButtonFieldType: () => isPrintButtonFieldType,
301
306
  isRadioGroupFieldType: () => isRadioGroupFieldType,
302
307
  isSelectDateRangeFieldType: () => isSelectDateRangeFieldType,
303
308
  isSelectFieldType: () => isSelectFieldType,
@@ -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,
@@ -538,8 +544,7 @@ var FieldType = {
538
544
  FACILITY: "FACILITY",
539
545
  OFFICE: "OFFICE",
540
546
  SIGNATURE: "SIGNATURE",
541
- DATA: "DATA",
542
- PRINT_BUTTON: "PRINT_BUTTON"
547
+ DATA: "DATA"
543
548
  };
544
549
  var fieldTypes = Object.values(FieldType);
545
550
  var compositeFieldTypes = [
@@ -556,7 +561,7 @@ var import_zod6 = require("zod");
556
561
  var import_zod4 = require("zod");
557
562
  var import_zod_openapi3 = require("zod-openapi");
558
563
  (0, import_zod_openapi3.extendZodWithOpenApi)(import_zod4.z);
559
- var FullDocumentURL = import_zod4.z.string().brand("FullDocumentURL").describe(
564
+ var FullDocumentUrl = import_zod4.z.string().brand("FullDocumentUrl").describe(
560
565
  "A full url with protocol, host, bucket name, starting from the root of the S3 server, https://minio/bucket-name/document-id.jpg"
561
566
  );
562
567
  var FullDocumentPath = import_zod4.z.string().transform((val) => val.startsWith("/") ? val : `/${val}`).openapi({ effectType: "input", type: "string" }).describe(
@@ -613,8 +618,8 @@ var NameFieldValue = import_zod5.z.object({
613
618
  middlename: import_zod5.z.string().optional()
614
619
  });
615
620
  var NameFieldUpdateValue = import_zod5.z.object({
616
- firstname: import_zod5.z.string().nullish(),
617
- surname: import_zod5.z.string().nullish(),
621
+ firstname: import_zod5.z.string(),
622
+ surname: import_zod5.z.string(),
618
623
  middlename: import_zod5.z.string().nullish()
619
624
  }).or(import_zod5.z.null()).or(import_zod5.z.undefined());
620
625
  var RuralAddressUpdateValue = AdminStructure.extend({
@@ -911,18 +916,32 @@ var SelectDateRangeField = BaseField.extend({
911
916
  defaultValue: SelectDateRangeValue.optional(),
912
917
  options: import_zod7.z.array(SelectDateRangeOption).describe("A list of options")
913
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() }).optional(),
921
+ middlename: import_zod7.z.object({ required: import_zod7.z.boolean() }).optional(),
922
+ surname: import_zod7.z.object({ required: import_zod7.z.boolean() }).optional()
923
+ });
914
924
  var NameField = BaseField.extend({
915
925
  type: import_zod7.z.literal(FieldType.NAME),
916
926
  defaultValue: import_zod7.z.object({
917
- firstname: NonEmptyTextValue,
918
- surname: NonEmptyTextValue
927
+ firstname: NonEmptyTextValue.optional(),
928
+ middlename: NonEmptyTextValue.optional(),
929
+ surname: NonEmptyTextValue.optional()
919
930
  }).optional(),
920
931
  configuration: import_zod7.z.object({
932
+ name: NameConfig.default({
933
+ firstname: { required: true },
934
+ surname: { required: true }
935
+ }).optional(),
921
936
  maxLength: import_zod7.z.number().optional().describe("Maximum length of the text"),
922
937
  prefix: TranslationConfig.optional(),
923
938
  postfix: TranslationConfig.optional(),
924
- includeMiddlename: import_zod7.z.boolean().default(false).optional().describe("To make middle name visible in Name form field"),
925
939
  searchMode: import_zod7.z.boolean().optional()
940
+ }).default({
941
+ name: {
942
+ firstname: { required: true },
943
+ surname: { required: true }
944
+ }
926
945
  }).optional()
927
946
  }).describe("Name input field");
928
947
  var PhoneField = BaseField.extend({
@@ -1006,15 +1025,6 @@ var DataField = BaseField.extend({
1006
1025
  data: import_zod7.z.array(DataEntry)
1007
1026
  })
1008
1027
  }).describe("Data field for displaying read-only data");
1009
- var PrintButton = BaseField.extend({
1010
- type: import_zod7.z.literal(FieldType.PRINT_BUTTON),
1011
- configuration: import_zod7.z.object({
1012
- template: import_zod7.z.string().describe("Template ID from countryconfig templates to use for printing"),
1013
- buttonLabel: TranslationConfig.optional().describe(
1014
- "Label for the print button"
1015
- )
1016
- })
1017
- }).describe("Print button field for printing certificates");
1018
1028
  var FieldConfig = import_zod7.z.discriminatedUnion("type", [
1019
1029
  Address,
1020
1030
  TextField,
@@ -1043,8 +1053,7 @@ var FieldConfig = import_zod7.z.discriminatedUnion("type", [
1043
1053
  SignatureField,
1044
1054
  EmailField,
1045
1055
  FileUploadWithOptions,
1046
- DataField,
1047
- PrintButton
1056
+ DataField
1048
1057
  ]).openapi({
1049
1058
  description: "Form field configuration",
1050
1059
  ref: "FieldConfig"
@@ -1234,7 +1243,8 @@ var CertificateConfig = import_zod11.z.object({
1234
1243
  delayed: import_zod11.z.number()
1235
1244
  }),
1236
1245
  svgUrl: import_zod11.z.string(),
1237
- fonts: import_zod11.z.record(FontFamily).optional()
1246
+ fonts: import_zod11.z.record(FontFamily).optional(),
1247
+ conditionals: import_zod11.z.array(ShowConditional).optional()
1238
1248
  });
1239
1249
  var CertificateTemplateConfig = CertificateConfig.extend({
1240
1250
  hash: import_zod11.z.string().optional(),
@@ -1352,7 +1362,7 @@ var SummaryConfig = import_zod14.z.object({
1352
1362
 
1353
1363
  // ../commons/src/events/AdvancedSearchConfig.ts
1354
1364
  var import_zod15 = require("zod");
1355
- var MatchType = import_zod15.z.enum(["fuzzy", "exact", "range"]);
1365
+ var MatchType = import_zod15.z.enum(["fuzzy", "exact", "range", "within"]);
1356
1366
  var BaseField3 = import_zod15.z.object({
1357
1367
  config: import_zod15.z.object({
1358
1368
  type: MatchType.describe("Determines the type of field")
@@ -1406,22 +1416,30 @@ var FieldConfigSchema = BaseField3.extend({
1406
1416
  fieldType: import_zod15.z.literal("field"),
1407
1417
  alternateFieldIds: import_zod15.z.array(import_zod15.z.string()).optional().describe(
1408
1418
  `Sometimes there might be need to search a value against multiple field of same FormField type. For example
1409
- search Country, Province, District against child.address.private and child.address.other. In such case, we
1419
+ search Country, Province, District against child.address.private and child.address.other. In such case, we
1410
1420
  add a one field as fieldId, and accomodate others in alternateFieldIds`
1411
1421
  ),
1412
- excludeInSearchQuery: import_zod15.z.boolean().default(false).optional().describe(`Sometimes there will be search fields which are used to
1413
- conditionally display another search field, but its not needed in search query. For example, child.placeOfBirth
1422
+ excludeInSearchQuery: import_zod15.z.boolean().default(false).optional().describe(`Sometimes there will be search fields which are used to
1423
+ conditionally display another search field, but its not needed in search query. For example, child.placeOfBirth
1414
1424
  is select field, which has 3 options, FACILITY, PRIVATE_HOME, OTHER. Upon selecting any of the option, pops up another field
1415
1425
  related to the selected option, whose value is required in the search query. But child.placeOfBirth itself is not needed in the query.
1416
1426
  In such case, populate this field (excludeInSearchQuery) with boolean true`)
1417
1427
  });
1418
- var EventFieldId = import_zod15.z.enum([
1428
+ var EventFieldIdInput = import_zod15.z.enum([
1419
1429
  "trackingId",
1420
1430
  "status",
1421
1431
  "legalStatuses.REGISTERED.acceptedAt",
1422
1432
  "legalStatuses.REGISTERED.createdAtLocation",
1423
1433
  "updatedAt"
1424
1434
  ]);
1435
+ var METADATA_FIELD_PREFIX = "event.";
1436
+ var EventFieldId = import_zod15.z.enum([
1437
+ `${METADATA_FIELD_PREFIX}trackingId`,
1438
+ `${METADATA_FIELD_PREFIX}status`,
1439
+ `${METADATA_FIELD_PREFIX}legalStatuses.REGISTERED.acceptedAt`,
1440
+ `${METADATA_FIELD_PREFIX}legalStatuses.REGISTERED.createdAtLocation`,
1441
+ `${METADATA_FIELD_PREFIX}updatedAt`
1442
+ ]);
1425
1443
  var EventFieldConfigSchema = BaseField3.extend({
1426
1444
  fieldId: EventFieldId,
1427
1445
  fieldType: import_zod15.z.literal("event")
@@ -1914,11 +1932,15 @@ var ActionBase = import_zod19.z.object({
1914
1932
  originalActionId: UUID.optional().nullable().describe(
1915
1933
  "Reference to the original action that was asynchronously rejected or accepted by 3rd party integration."
1916
1934
  )
1935
+ // 'content' field reserved for additional data
1936
+ // Each action can define its own content specifc to the action
1937
+ // See PrintCertificateAction
1917
1938
  });
1918
1939
  var AssignedAction = ActionBase.merge(
1919
1940
  import_zod19.z.object({
1920
1941
  type: import_zod19.z.literal(ActionType.ASSIGN),
1921
1942
  assignedTo: import_zod19.z.string()
1943
+ // TODO move into 'content' property
1922
1944
  })
1923
1945
  );
1924
1946
  var UnassignedAction = ActionBase.merge(
@@ -1930,6 +1952,7 @@ var RegisterAction = ActionBase.merge(
1930
1952
  import_zod19.z.object({
1931
1953
  type: import_zod19.z.literal(ActionType.REGISTER),
1932
1954
  registrationNumber: import_zod19.z.string().optional()
1955
+ // TODO move into 'content' property
1933
1956
  })
1934
1957
  );
1935
1958
  var DeclareAction = ActionBase.merge(
@@ -1950,6 +1973,7 @@ var RejectAction = ActionBase.merge(
1950
1973
  import_zod19.z.object({
1951
1974
  type: import_zod19.z.literal(ActionType.REJECT),
1952
1975
  reason: RejectionReason
1976
+ // TODO move into 'content' property
1953
1977
  })
1954
1978
  );
1955
1979
  var MarkAsDuplicateAction = ActionBase.merge(
@@ -1961,6 +1985,7 @@ var ArchiveAction = ActionBase.merge(
1961
1985
  import_zod19.z.object({
1962
1986
  type: import_zod19.z.literal(ActionType.ARCHIVE),
1963
1987
  reason: RejectionReason
1988
+ // TODO move into 'content' property
1964
1989
  })
1965
1990
  );
1966
1991
  var CreatedAction = ActionBase.merge(
@@ -1973,9 +1998,13 @@ var NotifiedAction = ActionBase.merge(
1973
1998
  type: import_zod19.z.literal(ActionType.NOTIFY)
1974
1999
  })
1975
2000
  );
2001
+ var PrintContent = import_zod19.z.object({
2002
+ templateId: import_zod19.z.string().optional()
2003
+ });
1976
2004
  var PrintCertificateAction = ActionBase.merge(
1977
2005
  import_zod19.z.object({
1978
- type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE)
2006
+ type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE),
2007
+ content: PrintContent.optional().nullable()
1979
2008
  })
1980
2009
  );
1981
2010
  var RequestedCorrectionAction = ActionBase.merge(
@@ -1987,12 +2016,14 @@ var ApprovedCorrectionAction = ActionBase.merge(
1987
2016
  import_zod19.z.object({
1988
2017
  type: import_zod19.z.literal(ActionType.APPROVE_CORRECTION),
1989
2018
  requestId: import_zod19.z.string()
2019
+ // TODO move into 'content' property
1990
2020
  })
1991
2021
  );
1992
2022
  var RejectedCorrectionAction = ActionBase.merge(
1993
2023
  import_zod19.z.object({
1994
2024
  type: import_zod19.z.literal(ActionType.REJECT_CORRECTION),
1995
2025
  requestId: import_zod19.z.string(),
2026
+ // TODO move into 'content' property
1996
2027
  reason: RejectionReason
1997
2028
  })
1998
2029
  );
@@ -2043,7 +2074,7 @@ var ResolvedUser = import_zod19.z.object({
2043
2074
  });
2044
2075
 
2045
2076
  // ../commons/src/conditionals/validate.ts
2046
- var import_ajv = __toESM(require("ajv"));
2077
+ var import__ = __toESM(require("ajv/dist/2019"));
2047
2078
  var import_ajv_formats = __toESM(require("ajv-formats"));
2048
2079
  var import_date_fns = require("date-fns");
2049
2080
 
@@ -2106,9 +2137,6 @@ function mapFieldTypeToZod(type, required) {
2106
2137
  case FieldType.NAME:
2107
2138
  schema = required ? NameFieldValue : NameFieldUpdateValue;
2108
2139
  break;
2109
- case FieldType.PRINT_BUTTON:
2110
- schema = TextValue;
2111
- break;
2112
2140
  }
2113
2141
  return required ? schema : schema.nullish();
2114
2142
  }
@@ -2169,8 +2197,6 @@ function mapFieldTypeToEmptyValue(field2) {
2169
2197
  };
2170
2198
  case FieldType.FILE_WITH_OPTIONS:
2171
2199
  return [];
2172
- case FieldType.PRINT_BUTTON:
2173
- return null;
2174
2200
  }
2175
2201
  }
2176
2202
  var isParagraphFieldType = (field2) => {
@@ -2257,17 +2283,16 @@ var isOfficeFieldType = (field2) => {
2257
2283
  var isDataFieldType = (field2) => {
2258
2284
  return field2.config.type === FieldType.DATA;
2259
2285
  };
2260
- var isPrintButtonFieldType = (field2) => {
2261
- return field2.config.type === FieldType.PRINT_BUTTON;
2262
- };
2263
2286
  var isNonInteractiveFieldType = (field2) => {
2264
2287
  return field2.type === FieldType.DIVIDER || field2.type === FieldType.PAGE_HEADER || field2.type === FieldType.PARAGRAPH || field2.type === FieldType.BULLET_LIST || field2.type === FieldType.DATA;
2265
2288
  };
2266
2289
 
2267
2290
  // ../commons/src/conditionals/validate.ts
2268
- var ajv = new import_ajv.default({
2291
+ var ajv = new import__.default({
2269
2292
  $data: true,
2270
- allowUnionTypes: true
2293
+ allowUnionTypes: true,
2294
+ strict: false
2295
+ // Allow minContains and other newer features
2271
2296
  });
2272
2297
  (0, import_ajv_formats.default)(ajv);
2273
2298
  ajv.addKeyword({
@@ -2440,6 +2465,23 @@ function validateFieldInput({
2440
2465
  const rawError = zodType.safeParse(value, { errorMap: zodToIntlErrorMap });
2441
2466
  return rawError.error?.issues.map((issue) => issue.message) ?? [];
2442
2467
  }
2468
+ function runStructuralValidations({
2469
+ field: field2,
2470
+ values
2471
+ }) {
2472
+ if (!isFieldVisible(field2, values) || isFieldEmptyAndNotRequired(field2, values)) {
2473
+ return {
2474
+ errors: []
2475
+ };
2476
+ }
2477
+ const fieldValidationResult = validateFieldInput({
2478
+ field: field2,
2479
+ value: values[field2.id]
2480
+ });
2481
+ return {
2482
+ errors: fieldValidationResult
2483
+ };
2484
+ }
2443
2485
  function runFieldValidations({
2444
2486
  field: field2,
2445
2487
  values
@@ -2505,6 +2547,11 @@ function getValidatorsForField(fieldId, validations) {
2505
2547
  };
2506
2548
  }).filter((x) => x !== null);
2507
2549
  }
2550
+ function areCertificateConditionsMet(conditions, values) {
2551
+ return conditions.every((condition) => {
2552
+ return ajv.validate(condition.conditional, values);
2553
+ });
2554
+ }
2508
2555
 
2509
2556
  // ../commons/src/utils.ts
2510
2557
  function getOrThrow(x, message) {
@@ -2725,16 +2772,16 @@ function timePeriodToDateRange(value) {
2725
2772
  let startDate;
2726
2773
  switch (value) {
2727
2774
  case "last7Days":
2728
- startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 6);
2775
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 7);
2729
2776
  break;
2730
2777
  case "last30Days":
2731
- startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 29);
2778
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 30);
2732
2779
  break;
2733
2780
  case "last90Days":
2734
- startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 89);
2781
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 90);
2735
2782
  break;
2736
2783
  case "last365Days":
2737
- startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 364);
2784
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 365);
2738
2785
  break;
2739
2786
  }
2740
2787
  return {
@@ -3101,8 +3148,9 @@ function createFieldConditionals(fieldId) {
3101
3148
  properties: {
3102
3149
  [fieldId]: {
3103
3150
  type: "string",
3104
- 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'._-]*)*$",
3105
- description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
3151
+ minLength: 1,
3152
+ 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'.-]*)*$",
3153
+ description: "Name must contain only letters, numbers, and allowed special characters ('.-). No double spaces."
3106
3154
  }
3107
3155
  }
3108
3156
  }),
@@ -3195,6 +3243,19 @@ function createSearchConfig(baseField) {
3195
3243
  fuzzy: () => ({
3196
3244
  ...baseField,
3197
3245
  config: { type: "fuzzy" }
3246
+ }),
3247
+ /**
3248
+ * Creates a configuration for matching locations and the child locations
3249
+ * @returns An object containing the field ID and a configuration object with a type of 'within'.
3250
+ * @example field('createdAtLocation').within()
3251
+ * // {
3252
+ * // ...
3253
+ * // config: { type: 'within' }
3254
+ * // }
3255
+ */
3256
+ within: () => ({
3257
+ ...baseField,
3258
+ config: { type: "within" }
3198
3259
  })
3199
3260
  };
3200
3261
  }
@@ -3202,7 +3263,7 @@ function createSearchConfig(baseField) {
3202
3263
  // ../commons/src/event-config/event-configuration.ts
3203
3264
  function createEventFieldConfig(fieldId) {
3204
3265
  const baseField = {
3205
- fieldId,
3266
+ fieldId: `${METADATA_FIELD_PREFIX}${fieldId}`,
3206
3267
  fieldType: "event"
3207
3268
  };
3208
3269
  return createSearchConfig(baseField);
@@ -3215,32 +3276,107 @@ function eventFn(fieldId) {
3215
3276
  var event = Object.assign(eventFn, {
3216
3277
  /**
3217
3278
  * Checks if the event contains a specific action type.
3279
+ * Can be used directly as a conditional or chained with additional methods.
3218
3280
  * @param action - The action type to check for.
3219
3281
  */
3220
- hasAction: (action) => defineConditional({
3221
- type: "object",
3222
- properties: {
3223
- $event: {
3282
+ hasAction: (action) => {
3283
+ const basicConditional = defineConditional({
3284
+ type: "object",
3285
+ properties: {
3286
+ $event: {
3287
+ type: "object",
3288
+ properties: {
3289
+ actions: {
3290
+ type: "array",
3291
+ contains: {
3292
+ type: "object",
3293
+ properties: {
3294
+ type: {
3295
+ const: action
3296
+ }
3297
+ },
3298
+ required: ["type"]
3299
+ }
3300
+ }
3301
+ },
3302
+ required: ["actions"]
3303
+ }
3304
+ },
3305
+ required: ["$event"]
3306
+ });
3307
+ const buildActionConstraints = (additionalFields) => {
3308
+ const actionProperties = {
3309
+ type: { const: action }
3310
+ };
3311
+ const requiredFields = ["type"];
3312
+ if (additionalFields) {
3313
+ Object.entries(additionalFields).forEach(([key, value]) => {
3314
+ actionProperties[key] = { const: value };
3315
+ requiredFields.push(key);
3316
+ });
3317
+ }
3318
+ return { actionProperties, requiredFields };
3319
+ };
3320
+ const createCountConditional = (countType, count, additionalFields) => {
3321
+ const { actionProperties, requiredFields } = buildActionConstraints(additionalFields);
3322
+ return defineConditional({
3224
3323
  type: "object",
3225
3324
  properties: {
3226
- actions: {
3227
- type: "array",
3228
- contains: {
3229
- type: "object",
3230
- properties: {
3231
- type: {
3232
- const: action
3233
- }
3234
- },
3235
- required: ["type"]
3236
- }
3325
+ $event: {
3326
+ type: "object",
3327
+ properties: {
3328
+ actions: {
3329
+ type: "array",
3330
+ contains: {
3331
+ type: "object",
3332
+ properties: actionProperties,
3333
+ required: requiredFields
3334
+ },
3335
+ [countType]: count
3336
+ }
3337
+ },
3338
+ required: ["actions"]
3237
3339
  }
3238
3340
  },
3239
- required: ["actions"]
3240
- }
3241
- },
3242
- required: ["$event"]
3243
- }),
3341
+ required: ["$event"]
3342
+ });
3343
+ };
3344
+ const withMinMax = (additionalFields) => {
3345
+ return {
3346
+ /**
3347
+ * Creates a conditional that checks if the event contains a specific action type
3348
+ * with a minimum count of occurrences.
3349
+ *
3350
+ * @param minCount - The minimum number of actions required.
3351
+ */
3352
+ minCount: (minCount) => createCountConditional("minContains", minCount, additionalFields),
3353
+ /**
3354
+ * Builds a conditional that sets a maximum count for the number of actions.
3355
+ * This is useful for limiting the number of actions of a specific type in a single event.
3356
+ */
3357
+ maxCount: (maxCount) => createCountConditional("maxContains", maxCount, additionalFields)
3358
+ };
3359
+ };
3360
+ const chainableMethods = {
3361
+ /**
3362
+ * Adds additional field constraints to the action matching.
3363
+ *
3364
+ * @param fields - Object containing additional fields to match on the action.
3365
+ */
3366
+ withFields: (fields) => withMinMax(fields),
3367
+ /**
3368
+ * Adds template ID constraint to the action matching.
3369
+ * This is a convenience method that adds content.templateId to the fields.
3370
+ *
3371
+ * @param id - The template ID to match against.
3372
+ */
3373
+ withTemplate: (id) => withMinMax({
3374
+ content: { templateId: id }
3375
+ }),
3376
+ ...withMinMax()
3377
+ };
3378
+ return { ...basicConditional, ...chainableMethods };
3379
+ },
3244
3380
  field(field2) {
3245
3381
  return {
3246
3382
  $event: field2
@@ -3259,24 +3395,23 @@ var EventStatus = import_zod23.z.enum([
3259
3395
  "DECLARED",
3260
3396
  "VALIDATED",
3261
3397
  "REGISTERED",
3262
- "CERTIFIED",
3263
3398
  "ARCHIVED"
3264
3399
  ]);
3265
- var VisibleStatus = import_zod23.z.enum([...EventStatus.options, "REJECTED"]);
3266
3400
  var InherentFlags = {
3267
- PRINTED: "printed",
3401
+ PENDING_CERTIFICATION: "pending-certification",
3268
3402
  INCOMPLETE: "incomplete",
3269
3403
  REJECTED: "rejected",
3270
3404
  CORRECTION_REQUESTED: "correction-requested"
3271
3405
  };
3272
- var Flag = import_zod23.z.string().regex(
3406
+ var ActionFlag = import_zod23.z.string().regex(
3273
3407
  new RegExp(
3274
3408
  `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
3275
3409
  ActionStatus
3276
3410
  ).join("|").toLowerCase()})$`
3277
3411
  ),
3278
3412
  "Flag must be in the format ActionType:ActionStatus (lowerCase)"
3279
- ).or(import_zod23.z.nativeEnum(InherentFlags));
3413
+ );
3414
+ var Flag = ActionFlag.or(import_zod23.z.nativeEnum(InherentFlags));
3280
3415
  var ZodDate = import_zod23.z.string().date();
3281
3416
  var ActionCreationMetadata = import_zod23.z.object({
3282
3417
  createdAt: import_zod23.z.string().datetime().describe("The timestamp when the action request was created."),
@@ -3544,6 +3679,9 @@ var QueryExpression = import_zod25.z.object({
3544
3679
  createdAt: import_zod25.z.optional(DateCondition),
3545
3680
  updatedAt: import_zod25.z.optional(DateCondition),
3546
3681
  "legalStatuses.REGISTERED.acceptedAt": import_zod25.z.optional(DateCondition),
3682
+ "legalStatuses.DECLARED.createdAtLocation": import_zod25.z.optional(
3683
+ import_zod25.z.union([Within, Exact])
3684
+ ),
3547
3685
  "legalStatuses.REGISTERED.createdAtLocation": import_zod25.z.optional(
3548
3686
  import_zod25.z.union([Within, Exact])
3549
3687
  ),
@@ -3789,7 +3927,8 @@ var WorkqueueConfig = import_zod28.z.object({
3789
3927
  })
3790
3928
  ),
3791
3929
  columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
3792
- icon: AvailableIcons
3930
+ icon: AvailableIcons,
3931
+ emptyMessage: TranslationConfig.optional()
3793
3932
  }).describe("Configuration for workqueue.");
3794
3933
  var WorkqueueConfigWithoutQuery = WorkqueueConfig.omit({
3795
3934
  query: true,
@@ -3808,7 +3947,8 @@ var WorkqueueConfigInput = import_zod28.z.object({
3808
3947
  })
3809
3948
  ),
3810
3949
  columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
3811
- icon: AvailableIcons
3950
+ icon: AvailableIcons,
3951
+ emptyMessage: TranslationConfig.optional()
3812
3952
  });
3813
3953
  function defineWorkqueue(workqueueInput) {
3814
3954
  const queryInput = workqueueInput.query;
@@ -3897,7 +4037,8 @@ var DeclareActionInput = BaseActionInput.merge(
3897
4037
  );
3898
4038
  var PrintCertificateActionInput = BaseActionInput.merge(
3899
4039
  import_zod29.z.object({
3900
- type: import_zod29.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
4040
+ type: import_zod29.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE),
4041
+ content: PrintContent.optional()
3901
4042
  })
3902
4043
  );
3903
4044
  var RejectDeclarationActionInput = BaseActionInput.merge(
@@ -4109,16 +4250,19 @@ function getLegalStatuses(actions) {
4109
4250
  }
4110
4251
 
4111
4252
  // ../commons/src/events/state/flags.ts
4112
- function isCertificatePrinted(actions) {
4253
+ function isPendingCertification(actions) {
4254
+ if (getStatusFromActions(actions) !== EventStatus.enum.REGISTERED) {
4255
+ return false;
4256
+ }
4113
4257
  return actions.reduce((prev, { type }) => {
4114
4258
  if (type === ActionType.PRINT_CERTIFICATE) {
4115
- return true;
4259
+ return false;
4116
4260
  }
4117
4261
  if (type === ActionType.APPROVE_CORRECTION) {
4118
- return false;
4262
+ return true;
4119
4263
  }
4120
4264
  return prev;
4121
- }, false);
4265
+ }, true);
4122
4266
  }
4123
4267
  function isCorrectionRequested(actions) {
4124
4268
  return actions.reduce((prev, { type }) => {
@@ -4153,8 +4297,8 @@ function getFlagsFromActions(actions) {
4153
4297
  const flag = joinValues([type, status], ":").toLowerCase();
4154
4298
  return flag;
4155
4299
  });
4156
- if (isCertificatePrinted(sortedActions)) {
4157
- flags.push(InherentFlags.PRINTED);
4300
+ if (isPendingCertification(sortedActions)) {
4301
+ flags.push(InherentFlags.PENDING_CERTIFICATION);
4158
4302
  }
4159
4303
  if (isCorrectionRequested(sortedActions)) {
4160
4304
  flags.push(InherentFlags.CORRECTION_REQUESTED);
@@ -4185,7 +4329,6 @@ function getStatusFromActions(actions) {
4185
4329
  case ActionType.NOTIFY:
4186
4330
  return EventStatus.enum.NOTIFIED;
4187
4331
  case ActionType.PRINT_CERTIFICATE:
4188
- return EventStatus.enum.CERTIFIED;
4189
4332
  case ActionType.ASSIGN:
4190
4333
  case ActionType.UNASSIGN:
4191
4334
  case ActionType.REJECT:
@@ -5150,7 +5293,27 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
5150
5293
  defaultMessage: "Applicant's name",
5151
5294
  description: "This is the label for the field",
5152
5295
  id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.firstname.label"
5153
- }
5296
+ },
5297
+ configuration: {
5298
+ name: {
5299
+ firstname: { required: true },
5300
+ middlename: { required: false },
5301
+ surname: { required: true }
5302
+ }
5303
+ },
5304
+ validation: [
5305
+ {
5306
+ validator: field("applicant.name").object({
5307
+ firstname: field("firstname").isValidEnglishName(),
5308
+ surname: field("surname").isValidEnglishName()
5309
+ }),
5310
+ message: {
5311
+ defaultMessage: "Input contains invalid characters. Please use only letters (a-z, A-Z), numbers (0-9), hyphens (-), apostrophes(') and underscores (_)",
5312
+ description: "This is the error message for invalid name",
5313
+ id: "v2.error.invalidName"
5314
+ }
5315
+ }
5316
+ ]
5154
5317
  },
5155
5318
  {
5156
5319
  id: "applicant.email",
@@ -5372,22 +5535,6 @@ var statusOptions = [
5372
5535
  id: "v2.advancedSearch.form.recordStatusRegistered"
5373
5536
  }
5374
5537
  },
5375
- {
5376
- value: EventStatus.enum.CERTIFIED,
5377
- label: {
5378
- defaultMessage: "Certified",
5379
- description: "Option for form field: status of record",
5380
- id: "v2.advancedSearch.form.recordStatusCertified"
5381
- }
5382
- },
5383
- {
5384
- value: VisibleStatus.enum.REJECTED,
5385
- label: {
5386
- defaultMessage: "Rejected",
5387
- description: "Option for form field: status of record",
5388
- id: "v2.advancedSearch.form.recordStatusRejected"
5389
- }
5390
- },
5391
5538
  {
5392
5539
  value: EventStatus.enum.ARCHIVED,
5393
5540
  label: {
@@ -6503,8 +6650,6 @@ function mapFieldTypeToMockValue(field2, i, rng) {
6503
6650
  return "2021-01-01";
6504
6651
  case FieldType.TIME:
6505
6652
  return "09:33";
6506
- case FieldType.PRINT_BUTTON:
6507
- return void 0;
6508
6653
  case FieldType.DATE_RANGE:
6509
6654
  return {
6510
6655
  start: "2021-01-01",
@@ -6841,7 +6986,11 @@ function generateActionDocument({
6841
6986
  case ActionType.NOTIFY:
6842
6987
  return { ...actionBase, type: action };
6843
6988
  case ActionType.PRINT_CERTIFICATE:
6844
- return { ...actionBase, type: action };
6989
+ return {
6990
+ ...actionBase,
6991
+ type: action,
6992
+ content: defaults.content
6993
+ };
6845
6994
  case ActionType.REQUEST_CORRECTION:
6846
6995
  return { ...actionBase, type: action };
6847
6996
  case ActionType.APPROVE_CORRECTION:
@@ -7241,14 +7390,6 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7241
7390
  ActionType.REJECT_CORRECTION,
7242
7391
  ExclusiveActions.REVIEW_CORRECTION_REQUEST
7243
7392
  ],
7244
- [EventStatus.enum.CERTIFIED]: [
7245
- ActionType.READ,
7246
- ActionType.PRINT_CERTIFICATE,
7247
- ActionType.REQUEST_CORRECTION,
7248
- ActionType.APPROVE_CORRECTION,
7249
- ActionType.REJECT_CORRECTION,
7250
- ExclusiveActions.REVIEW_CORRECTION_REQUEST
7251
- ],
7252
7393
  [EventStatus.enum.ARCHIVED]: [
7253
7394
  ActionType.READ,
7254
7395
  ActionType.ASSIGN,
@@ -7256,9 +7397,12 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7256
7397
  ]
7257
7398
  };
7258
7399
  var getAvailableActionsForEvent = (event2) => {
7259
- return event2.flags.includes(InherentFlags.REJECTED) ? [
7260
- ActionType.READ,
7261
- event2.status === EventStatus.Enum.VALIDATED ? ActionType.VALIDATE : ActionType.DECLARE,
7262
- ActionType.ARCHIVE
7263
- ] : AVAILABLE_ACTIONS_BY_EVENT_STATUS[event2.status];
7400
+ if (event2.flags.includes(InherentFlags.REJECTED)) {
7401
+ return [
7402
+ ActionType.READ,
7403
+ event2.status === EventStatus.Enum.VALIDATED ? ActionType.VALIDATE : ActionType.DECLARE,
7404
+ ActionType.ARCHIVE
7405
+ ];
7406
+ }
7407
+ return AVAILABLE_ACTIONS_BY_EVENT_STATUS[event2.status];
7264
7408
  };