@opencrvs/toolkit 1.8.1-rc.1e3e9b5 → 1.8.1-rc.22fb1a7

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 +2004 -366
  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 +695 -168
  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 +254 -43
  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 +1032 -246
  18. package/dist/commons/events/PageConfig.d.ts +264 -46
  19. package/dist/commons/events/WorkqueueConfig.d.ts +288 -164
  20. package/dist/commons/events/defineConfig.d.ts +129 -30
  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 +236 -60
  25. package/dist/conditionals/index.js +3 -2
  26. package/dist/events/index.js +304 -127
  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() }).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
+ });
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(),
919
936
  maxLength: import_zod7.z.number().optional().describe("Maximum length of the text"),
920
937
  prefix: TranslationConfig.optional(),
921
938
  postfix: TranslationConfig.optional(),
922
- includeMiddlename: import_zod7.z.boolean().default(false).optional().describe("To make middle name visible in Name form field"),
923
939
  searchMode: import_zod7.z.boolean().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({
@@ -1222,7 +1243,8 @@ var CertificateConfig = import_zod11.z.object({
1222
1243
  delayed: import_zod11.z.number()
1223
1244
  }),
1224
1245
  svgUrl: import_zod11.z.string(),
1225
- fonts: import_zod11.z.record(FontFamily).optional()
1246
+ fonts: import_zod11.z.record(FontFamily).optional(),
1247
+ conditionals: import_zod11.z.array(ShowConditional).optional()
1226
1248
  });
1227
1249
  var CertificateTemplateConfig = CertificateConfig.extend({
1228
1250
  hash: import_zod11.z.string().optional(),
@@ -1340,7 +1362,7 @@ var SummaryConfig = import_zod14.z.object({
1340
1362
 
1341
1363
  // ../commons/src/events/AdvancedSearchConfig.ts
1342
1364
  var import_zod15 = require("zod");
1343
- var MatchType = import_zod15.z.enum(["fuzzy", "exact", "range"]);
1365
+ var MatchType = import_zod15.z.enum(["fuzzy", "exact", "range", "within"]);
1344
1366
  var BaseField3 = import_zod15.z.object({
1345
1367
  config: import_zod15.z.object({
1346
1368
  type: MatchType.describe("Determines the type of field")
@@ -1394,22 +1416,30 @@ var FieldConfigSchema = BaseField3.extend({
1394
1416
  fieldType: import_zod15.z.literal("field"),
1395
1417
  alternateFieldIds: import_zod15.z.array(import_zod15.z.string()).optional().describe(
1396
1418
  `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
1419
+ search Country, Province, District against child.address.private and child.address.other. In such case, we
1398
1420
  add a one field as fieldId, and accomodate others in alternateFieldIds`
1399
1421
  ),
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
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
1402
1424
  is select field, which has 3 options, FACILITY, PRIVATE_HOME, OTHER. Upon selecting any of the option, pops up another field
1403
1425
  related to the selected option, whose value is required in the search query. But child.placeOfBirth itself is not needed in the query.
1404
1426
  In such case, populate this field (excludeInSearchQuery) with boolean true`)
1405
1427
  });
1406
- var EventFieldId = import_zod15.z.enum([
1428
+ var EventFieldIdInput = import_zod15.z.enum([
1407
1429
  "trackingId",
1408
1430
  "status",
1409
1431
  "legalStatuses.REGISTERED.acceptedAt",
1410
1432
  "legalStatuses.REGISTERED.createdAtLocation",
1411
1433
  "updatedAt"
1412
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
+ ]);
1413
1443
  var EventFieldConfigSchema = BaseField3.extend({
1414
1444
  fieldId: EventFieldId,
1415
1445
  fieldType: import_zod15.z.literal("event")
@@ -1902,11 +1932,15 @@ var ActionBase = import_zod19.z.object({
1902
1932
  originalActionId: UUID.optional().nullable().describe(
1903
1933
  "Reference to the original action that was asynchronously rejected or accepted by 3rd party integration."
1904
1934
  )
1935
+ // 'content' field reserved for additional data
1936
+ // Each action can define its own content specifc to the action
1937
+ // See PrintCertificateAction
1905
1938
  });
1906
1939
  var AssignedAction = ActionBase.merge(
1907
1940
  import_zod19.z.object({
1908
1941
  type: import_zod19.z.literal(ActionType.ASSIGN),
1909
1942
  assignedTo: import_zod19.z.string()
1943
+ // TODO move into 'content' property
1910
1944
  })
1911
1945
  );
1912
1946
  var UnassignedAction = ActionBase.merge(
@@ -1918,6 +1952,7 @@ var RegisterAction = ActionBase.merge(
1918
1952
  import_zod19.z.object({
1919
1953
  type: import_zod19.z.literal(ActionType.REGISTER),
1920
1954
  registrationNumber: import_zod19.z.string().optional()
1955
+ // TODO move into 'content' property
1921
1956
  })
1922
1957
  );
1923
1958
  var DeclareAction = ActionBase.merge(
@@ -1938,6 +1973,7 @@ var RejectAction = ActionBase.merge(
1938
1973
  import_zod19.z.object({
1939
1974
  type: import_zod19.z.literal(ActionType.REJECT),
1940
1975
  reason: RejectionReason
1976
+ // TODO move into 'content' property
1941
1977
  })
1942
1978
  );
1943
1979
  var MarkAsDuplicateAction = ActionBase.merge(
@@ -1949,6 +1985,7 @@ var ArchiveAction = ActionBase.merge(
1949
1985
  import_zod19.z.object({
1950
1986
  type: import_zod19.z.literal(ActionType.ARCHIVE),
1951
1987
  reason: RejectionReason
1988
+ // TODO move into 'content' property
1952
1989
  })
1953
1990
  );
1954
1991
  var CreatedAction = ActionBase.merge(
@@ -1961,9 +1998,13 @@ var NotifiedAction = ActionBase.merge(
1961
1998
  type: import_zod19.z.literal(ActionType.NOTIFY)
1962
1999
  })
1963
2000
  );
2001
+ var PrintContent = import_zod19.z.object({
2002
+ templateId: import_zod19.z.string().optional()
2003
+ });
1964
2004
  var PrintCertificateAction = ActionBase.merge(
1965
2005
  import_zod19.z.object({
1966
- type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE)
2006
+ type: import_zod19.z.literal(ActionType.PRINT_CERTIFICATE),
2007
+ content: PrintContent.optional().nullable()
1967
2008
  })
1968
2009
  );
1969
2010
  var RequestedCorrectionAction = ActionBase.merge(
@@ -1975,12 +2016,15 @@ var ApprovedCorrectionAction = ActionBase.merge(
1975
2016
  import_zod19.z.object({
1976
2017
  type: import_zod19.z.literal(ActionType.APPROVE_CORRECTION),
1977
2018
  requestId: import_zod19.z.string()
2019
+ // TODO move into 'content' property
1978
2020
  })
1979
2021
  );
1980
2022
  var RejectedCorrectionAction = ActionBase.merge(
1981
2023
  import_zod19.z.object({
1982
2024
  type: import_zod19.z.literal(ActionType.REJECT_CORRECTION),
1983
- requestId: import_zod19.z.string()
2025
+ requestId: import_zod19.z.string(),
2026
+ // TODO move into 'content' property
2027
+ reason: RejectionReason
1984
2028
  })
1985
2029
  );
1986
2030
  var ReadAction = ActionBase.merge(
@@ -2030,7 +2074,7 @@ var ResolvedUser = import_zod19.z.object({
2030
2074
  });
2031
2075
 
2032
2076
  // ../commons/src/conditionals/validate.ts
2033
- var import_ajv = __toESM(require("ajv"));
2077
+ var import__ = __toESM(require("ajv/dist/2019"));
2034
2078
  var import_ajv_formats = __toESM(require("ajv-formats"));
2035
2079
  var import_date_fns = require("date-fns");
2036
2080
 
@@ -2244,12 +2288,17 @@ var isNonInteractiveFieldType = (field2) => {
2244
2288
  };
2245
2289
 
2246
2290
  // ../commons/src/conditionals/validate.ts
2247
- var ajv = new import_ajv.default({
2291
+ var AJV_OPTIONS = {
2248
2292
  $data: true,
2249
- allowUnionTypes: true
2250
- });
2251
- (0, import_ajv_formats.default)(ajv);
2252
- ajv.addKeyword({
2293
+ allowUnionTypes: true,
2294
+ // This must be here to prevent memory leaks
2295
+ // https://www.poberezkin.com/posts/2021-02-11-ajv-version-7-big-changes-and-improvements.html#caching-compiled-schemas
2296
+ // https://github.com/ajv-validator/ajv/issues/1413
2297
+ addUsedSchema: false,
2298
+ strict: false
2299
+ // Allow minContains and other newer features
2300
+ };
2301
+ var daysFromNow = {
2253
2302
  keyword: "daysFromNow",
2254
2303
  type: "string",
2255
2304
  schemaType: "object",
@@ -2271,8 +2320,11 @@ ajv.addKeyword({
2271
2320
  const offsetDate = new Date(now.getTime() + days * 24 * 60 * 60 * 1e3);
2272
2321
  return clause === "after" ? (0, import_date_fns.isAfter)(date, offsetDate) : (0, import_date_fns.isBefore)(date, offsetDate);
2273
2322
  }
2274
- });
2323
+ };
2275
2324
  function validate(schema, data) {
2325
+ const ajv = new import__.default(AJV_OPTIONS);
2326
+ (0, import_ajv_formats.default)(ajv);
2327
+ ajv.addKeyword(daysFromNow);
2276
2328
  return ajv.validate(schema, data);
2277
2329
  }
2278
2330
  function isConditionMet(conditional, values) {
@@ -2419,6 +2471,23 @@ function validateFieldInput({
2419
2471
  const rawError = zodType.safeParse(value, { errorMap: zodToIntlErrorMap });
2420
2472
  return rawError.error?.issues.map((issue) => issue.message) ?? [];
2421
2473
  }
2474
+ function runStructuralValidations({
2475
+ field: field2,
2476
+ values
2477
+ }) {
2478
+ if (!isFieldVisible(field2, values) || isFieldEmptyAndNotRequired(field2, values)) {
2479
+ return {
2480
+ errors: []
2481
+ };
2482
+ }
2483
+ const fieldValidationResult = validateFieldInput({
2484
+ field: field2,
2485
+ value: values[field2.id]
2486
+ });
2487
+ return {
2488
+ errors: fieldValidationResult
2489
+ };
2490
+ }
2422
2491
  function runFieldValidations({
2423
2492
  field: field2,
2424
2493
  values
@@ -2484,6 +2553,14 @@ function getValidatorsForField(fieldId, validations) {
2484
2553
  };
2485
2554
  }).filter((x) => x !== null);
2486
2555
  }
2556
+ function areCertificateConditionsMet(conditions, values) {
2557
+ const ajv = new import__.default(AJV_OPTIONS);
2558
+ (0, import_ajv_formats.default)(ajv);
2559
+ ajv.addKeyword(daysFromNow);
2560
+ return conditions.every((condition) => {
2561
+ return ajv.validate(condition.conditional, values);
2562
+ });
2563
+ }
2487
2564
 
2488
2565
  // ../commons/src/utils.ts
2489
2566
  function getOrThrow(x, message) {
@@ -2704,16 +2781,16 @@ function timePeriodToDateRange(value) {
2704
2781
  let startDate;
2705
2782
  switch (value) {
2706
2783
  case "last7Days":
2707
- startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 6);
2784
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 7);
2708
2785
  break;
2709
2786
  case "last30Days":
2710
- startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 29);
2787
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 30);
2711
2788
  break;
2712
2789
  case "last90Days":
2713
- startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 89);
2790
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 90);
2714
2791
  break;
2715
2792
  case "last365Days":
2716
- startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 364);
2793
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 365);
2717
2794
  break;
2718
2795
  }
2719
2796
  return {
@@ -3080,8 +3157,9 @@ function createFieldConditionals(fieldId) {
3080
3157
  properties: {
3081
3158
  [fieldId]: {
3082
3159
  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."
3160
+ minLength: 1,
3161
+ 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'.-]*)*$",
3162
+ description: "Name must contain only letters, numbers, and allowed special characters ('.-). No double spaces."
3085
3163
  }
3086
3164
  }
3087
3165
  }),
@@ -3174,6 +3252,19 @@ function createSearchConfig(baseField) {
3174
3252
  fuzzy: () => ({
3175
3253
  ...baseField,
3176
3254
  config: { type: "fuzzy" }
3255
+ }),
3256
+ /**
3257
+ * Creates a configuration for matching locations and the child locations
3258
+ * @returns An object containing the field ID and a configuration object with a type of 'within'.
3259
+ * @example field('createdAtLocation').within()
3260
+ * // {
3261
+ * // ...
3262
+ * // config: { type: 'within' }
3263
+ * // }
3264
+ */
3265
+ within: () => ({
3266
+ ...baseField,
3267
+ config: { type: "within" }
3177
3268
  })
3178
3269
  };
3179
3270
  }
@@ -3181,7 +3272,7 @@ function createSearchConfig(baseField) {
3181
3272
  // ../commons/src/event-config/event-configuration.ts
3182
3273
  function createEventFieldConfig(fieldId) {
3183
3274
  const baseField = {
3184
- fieldId,
3275
+ fieldId: `${METADATA_FIELD_PREFIX}${fieldId}`,
3185
3276
  fieldType: "event"
3186
3277
  };
3187
3278
  return createSearchConfig(baseField);
@@ -3194,32 +3285,107 @@ function eventFn(fieldId) {
3194
3285
  var event = Object.assign(eventFn, {
3195
3286
  /**
3196
3287
  * Checks if the event contains a specific action type.
3288
+ * Can be used directly as a conditional or chained with additional methods.
3197
3289
  * @param action - The action type to check for.
3198
3290
  */
3199
- hasAction: (action) => defineConditional({
3200
- type: "object",
3201
- properties: {
3202
- $event: {
3291
+ hasAction: (action) => {
3292
+ const basicConditional = defineConditional({
3293
+ type: "object",
3294
+ properties: {
3295
+ $event: {
3296
+ type: "object",
3297
+ properties: {
3298
+ actions: {
3299
+ type: "array",
3300
+ contains: {
3301
+ type: "object",
3302
+ properties: {
3303
+ type: {
3304
+ const: action
3305
+ }
3306
+ },
3307
+ required: ["type"]
3308
+ }
3309
+ }
3310
+ },
3311
+ required: ["actions"]
3312
+ }
3313
+ },
3314
+ required: ["$event"]
3315
+ });
3316
+ const buildActionConstraints = (additionalFields) => {
3317
+ const actionProperties = {
3318
+ type: { const: action }
3319
+ };
3320
+ const requiredFields = ["type"];
3321
+ if (additionalFields) {
3322
+ Object.entries(additionalFields).forEach(([key, value]) => {
3323
+ actionProperties[key] = { const: value };
3324
+ requiredFields.push(key);
3325
+ });
3326
+ }
3327
+ return { actionProperties, requiredFields };
3328
+ };
3329
+ const createCountConditional = (countType, count, additionalFields) => {
3330
+ const { actionProperties, requiredFields } = buildActionConstraints(additionalFields);
3331
+ return defineConditional({
3203
3332
  type: "object",
3204
3333
  properties: {
3205
- actions: {
3206
- type: "array",
3207
- contains: {
3208
- type: "object",
3209
- properties: {
3210
- type: {
3211
- const: action
3212
- }
3213
- },
3214
- required: ["type"]
3215
- }
3334
+ $event: {
3335
+ type: "object",
3336
+ properties: {
3337
+ actions: {
3338
+ type: "array",
3339
+ contains: {
3340
+ type: "object",
3341
+ properties: actionProperties,
3342
+ required: requiredFields
3343
+ },
3344
+ [countType]: count
3345
+ }
3346
+ },
3347
+ required: ["actions"]
3216
3348
  }
3217
3349
  },
3218
- required: ["actions"]
3219
- }
3220
- },
3221
- required: ["$event"]
3222
- }),
3350
+ required: ["$event"]
3351
+ });
3352
+ };
3353
+ const withMinMax = (additionalFields) => {
3354
+ return {
3355
+ /**
3356
+ * Creates a conditional that checks if the event contains a specific action type
3357
+ * with a minimum count of occurrences.
3358
+ *
3359
+ * @param minCount - The minimum number of actions required.
3360
+ */
3361
+ minCount: (minCount) => createCountConditional("minContains", minCount, additionalFields),
3362
+ /**
3363
+ * Builds a conditional that sets a maximum count for the number of actions.
3364
+ * This is useful for limiting the number of actions of a specific type in a single event.
3365
+ */
3366
+ maxCount: (maxCount) => createCountConditional("maxContains", maxCount, additionalFields)
3367
+ };
3368
+ };
3369
+ const chainableMethods = {
3370
+ /**
3371
+ * Adds additional field constraints to the action matching.
3372
+ *
3373
+ * @param fields - Object containing additional fields to match on the action.
3374
+ */
3375
+ withFields: (fields) => withMinMax(fields),
3376
+ /**
3377
+ * Adds template ID constraint to the action matching.
3378
+ * This is a convenience method that adds content.templateId to the fields.
3379
+ *
3380
+ * @param id - The template ID to match against.
3381
+ */
3382
+ withTemplate: (id) => withMinMax({
3383
+ content: { templateId: id }
3384
+ }),
3385
+ ...withMinMax()
3386
+ };
3387
+ return { ...basicConditional, ...chainableMethods };
3388
+ },
3223
3389
  field(field2) {
3224
3390
  return {
3225
3391
  $event: field2
@@ -3238,24 +3404,23 @@ var EventStatus = import_zod23.z.enum([
3238
3404
  "DECLARED",
3239
3405
  "VALIDATED",
3240
3406
  "REGISTERED",
3241
- "CERTIFIED",
3242
3407
  "ARCHIVED"
3243
3408
  ]);
3244
- var VisibleStatus = import_zod23.z.enum([...EventStatus.options, "REJECTED"]);
3245
3409
  var InherentFlags = {
3246
- PRINTED: "printed",
3410
+ PENDING_CERTIFICATION: "pending-certification",
3247
3411
  INCOMPLETE: "incomplete",
3248
3412
  REJECTED: "rejected",
3249
3413
  CORRECTION_REQUESTED: "correction-requested"
3250
3414
  };
3251
- var Flag = import_zod23.z.string().regex(
3415
+ var ActionFlag = import_zod23.z.string().regex(
3252
3416
  new RegExp(
3253
3417
  `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
3254
3418
  ActionStatus
3255
3419
  ).join("|").toLowerCase()})$`
3256
3420
  ),
3257
3421
  "Flag must be in the format ActionType:ActionStatus (lowerCase)"
3258
- ).or(import_zod23.z.nativeEnum(InherentFlags));
3422
+ );
3423
+ var Flag = ActionFlag.or(import_zod23.z.nativeEnum(InherentFlags));
3259
3424
  var ZodDate = import_zod23.z.string().date();
3260
3425
  var ActionCreationMetadata = import_zod23.z.object({
3261
3426
  createdAt: import_zod23.z.string().datetime().describe("The timestamp when the action request was created."),
@@ -3523,6 +3688,9 @@ var QueryExpression = import_zod25.z.object({
3523
3688
  createdAt: import_zod25.z.optional(DateCondition),
3524
3689
  updatedAt: import_zod25.z.optional(DateCondition),
3525
3690
  "legalStatuses.REGISTERED.acceptedAt": import_zod25.z.optional(DateCondition),
3691
+ "legalStatuses.DECLARED.createdAtLocation": import_zod25.z.optional(
3692
+ import_zod25.z.union([Within, Exact])
3693
+ ),
3526
3694
  "legalStatuses.REGISTERED.createdAtLocation": import_zod25.z.optional(
3527
3695
  import_zod25.z.union([Within, Exact])
3528
3696
  ),
@@ -3768,7 +3936,8 @@ var WorkqueueConfig = import_zod28.z.object({
3768
3936
  })
3769
3937
  ),
3770
3938
  columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
3771
- icon: AvailableIcons
3939
+ icon: AvailableIcons,
3940
+ emptyMessage: TranslationConfig.optional()
3772
3941
  }).describe("Configuration for workqueue.");
3773
3942
  var WorkqueueConfigWithoutQuery = WorkqueueConfig.omit({
3774
3943
  query: true,
@@ -3787,7 +3956,8 @@ var WorkqueueConfigInput = import_zod28.z.object({
3787
3956
  })
3788
3957
  ),
3789
3958
  columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
3790
- icon: AvailableIcons
3959
+ icon: AvailableIcons,
3960
+ emptyMessage: TranslationConfig.optional()
3791
3961
  });
3792
3962
  function defineWorkqueue(workqueueInput) {
3793
3963
  const queryInput = workqueueInput.query;
@@ -3876,7 +4046,8 @@ var DeclareActionInput = BaseActionInput.merge(
3876
4046
  );
3877
4047
  var PrintCertificateActionInput = BaseActionInput.merge(
3878
4048
  import_zod29.z.object({
3879
- type: import_zod29.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
4049
+ type: import_zod29.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE),
4050
+ content: PrintContent.optional()
3880
4051
  })
3881
4052
  );
3882
4053
  var RejectDeclarationActionInput = BaseActionInput.merge(
@@ -3916,7 +4087,8 @@ var RequestCorrectionActionInput = BaseActionInput.merge(
3916
4087
  var RejectCorrectionActionInput = BaseActionInput.merge(
3917
4088
  import_zod29.z.object({
3918
4089
  requestId: import_zod29.z.string(),
3919
- type: import_zod29.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
4090
+ type: import_zod29.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION),
4091
+ reason: RejectionReason
3920
4092
  })
3921
4093
  );
3922
4094
  var ApproveCorrectionActionInput = BaseActionInput.merge(
@@ -4087,16 +4259,19 @@ function getLegalStatuses(actions) {
4087
4259
  }
4088
4260
 
4089
4261
  // ../commons/src/events/state/flags.ts
4090
- function isCertificatePrinted(actions) {
4262
+ function isPendingCertification(actions) {
4263
+ if (getStatusFromActions(actions) !== EventStatus.enum.REGISTERED) {
4264
+ return false;
4265
+ }
4091
4266
  return actions.reduce((prev, { type }) => {
4092
4267
  if (type === ActionType.PRINT_CERTIFICATE) {
4093
- return true;
4268
+ return false;
4094
4269
  }
4095
4270
  if (type === ActionType.APPROVE_CORRECTION) {
4096
- return false;
4271
+ return true;
4097
4272
  }
4098
4273
  return prev;
4099
- }, false);
4274
+ }, true);
4100
4275
  }
4101
4276
  function isCorrectionRequested(actions) {
4102
4277
  return actions.reduce((prev, { type }) => {
@@ -4131,8 +4306,8 @@ function getFlagsFromActions(actions) {
4131
4306
  const flag = joinValues([type, status], ":").toLowerCase();
4132
4307
  return flag;
4133
4308
  });
4134
- if (isCertificatePrinted(sortedActions)) {
4135
- flags.push(InherentFlags.PRINTED);
4309
+ if (isPendingCertification(sortedActions)) {
4310
+ flags.push(InherentFlags.PENDING_CERTIFICATION);
4136
4311
  }
4137
4312
  if (isCorrectionRequested(sortedActions)) {
4138
4313
  flags.push(InherentFlags.CORRECTION_REQUESTED);
@@ -4163,7 +4338,6 @@ function getStatusFromActions(actions) {
4163
4338
  case ActionType.NOTIFY:
4164
4339
  return EventStatus.enum.NOTIFIED;
4165
4340
  case ActionType.PRINT_CERTIFICATE:
4166
- return EventStatus.enum.CERTIFIED;
4167
4341
  case ActionType.ASSIGN:
4168
4342
  case ActionType.UNASSIGN:
4169
4343
  case ActionType.REJECT:
@@ -5128,7 +5302,27 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
5128
5302
  defaultMessage: "Applicant's name",
5129
5303
  description: "This is the label for the field",
5130
5304
  id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.firstname.label"
5131
- }
5305
+ },
5306
+ configuration: {
5307
+ name: {
5308
+ firstname: { required: true },
5309
+ middlename: { required: false },
5310
+ surname: { required: true }
5311
+ }
5312
+ },
5313
+ validation: [
5314
+ {
5315
+ validator: field("applicant.name").object({
5316
+ firstname: field("firstname").isValidEnglishName(),
5317
+ surname: field("surname").isValidEnglishName()
5318
+ }),
5319
+ message: {
5320
+ defaultMessage: "Input contains invalid characters. Please use only letters (a-z, A-Z), numbers (0-9), hyphens (-), apostrophes(') and underscores (_)",
5321
+ description: "This is the error message for invalid name",
5322
+ id: "v2.error.invalidName"
5323
+ }
5324
+ }
5325
+ ]
5132
5326
  },
5133
5327
  {
5134
5328
  id: "applicant.email",
@@ -5350,22 +5544,6 @@ var statusOptions = [
5350
5544
  id: "v2.advancedSearch.form.recordStatusRegistered"
5351
5545
  }
5352
5546
  },
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
5547
  {
5370
5548
  value: EventStatus.enum.ARCHIVED,
5371
5549
  label: {
@@ -5572,44 +5750,41 @@ var tennisClubMembershipEvent = defineConfig({
5572
5750
  },
5573
5751
  {
5574
5752
  id: "identity-check",
5575
- type: PageTypes.enum.FORM,
5753
+ type: PageTypes.enum.VERIFICATION,
5576
5754
  title: {
5577
- id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
5578
- defaultMessage: "Verify their identity",
5755
+ id: "v2.event.birth.action.correction.form.section.requester.identity.verify.title",
5756
+ defaultMessage: "Verify ID",
5579
5757
  description: "This is the title of the section"
5580
5758
  },
5581
- fields: [
5582
- {
5583
- id: "correction.identity-check.instructions",
5584
- type: "PAGE_HEADER",
5759
+ fields: [],
5760
+ actions: {
5761
+ verify: {
5585
5762
  label: {
5586
- id: "correction.corrector.identity.instruction",
5587
- defaultMessage: "Please verify the identity of the person making this request",
5588
- description: "The title for the corrector form"
5763
+ defaultMessage: "Verified",
5764
+ description: "This is the label for the verification button",
5765
+ id: "v2.event.birth.action.correction.form.verify"
5589
5766
  }
5590
5767
  },
5591
- {
5592
- id: "correction.identity-check.verified",
5593
- type: "RADIO_GROUP",
5768
+ cancel: {
5594
5769
  label: {
5595
- id: "correction.corrector.identity.verified.label",
5596
- defaultMessage: "Identity verified",
5597
- description: "The title for the corrector form"
5770
+ defaultMessage: "Identity does not match",
5771
+ description: "This is the label for the verification cancellation button",
5772
+ id: "v2.event.birth.action.correction.form.cancel"
5598
5773
  },
5599
- defaultValue: "",
5600
- required: true,
5601
- options: [
5602
- {
5603
- value: "VERIFIED",
5604
- label: {
5605
- id: "correction.corrector.identity.verified",
5606
- defaultMessage: "I have verified their identity",
5607
- description: "Label for verified option in corrector identity check page"
5608
- }
5774
+ confirmation: {
5775
+ title: {
5776
+ defaultMessage: "Correct without proof of ID?",
5777
+ description: "This is the title for the verification cancellation modal",
5778
+ id: "v2.event.birth.action.correction.form.cancel.confirmation.title"
5779
+ },
5780
+ body: {
5781
+ defaultMessage: "Please be aware that if you proceed, you will be responsible for making a change to this record without the necessary proof of identification",
5782
+ description: "This is the body for the verification cancellation modal",
5783
+ id: "v2.event.birth.action.correction.form.cancel.confirmation.body"
5609
5784
  }
5610
- ]
5785
+ }
5611
5786
  }
5612
- ]
5787
+ }
5613
5788
  },
5614
5789
  {
5615
5790
  id: "correction-request.supporting-documents",
@@ -6583,6 +6758,7 @@ function eventPayloadGenerator(rng) {
6583
6758
  annotation: {
6584
6759
  "correction.requester.relationship": "ANOTHER_AGENT",
6585
6760
  "correction.request.reason": "Child's name was incorrect",
6761
+ "identity-check": true,
6586
6762
  ...annotation
6587
6763
  },
6588
6764
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -6755,7 +6931,7 @@ function eventPayloadGenerator(rng) {
6755
6931
  requestId,
6756
6932
  keepAssignment: input.keepAssignment
6757
6933
  }),
6758
- reject: (eventId, requestId, input = {}) => ({
6934
+ reject: (eventId, requestId, input) => ({
6759
6935
  type: ActionType.REJECT_CORRECTION,
6760
6936
  transactionId: input.transactionId ?? getUUID(),
6761
6937
  declaration: {},
@@ -6766,7 +6942,8 @@ function eventPayloadGenerator(rng) {
6766
6942
  ),
6767
6943
  eventId,
6768
6944
  requestId,
6769
- keepAssignment: input.keepAssignment
6945
+ keepAssignment: input.keepAssignment,
6946
+ reason: input.reason ?? { message: "" }
6770
6947
  })
6771
6948
  }
6772
6949
  }
@@ -6816,7 +6993,11 @@ function generateActionDocument({
6816
6993
  case ActionType.NOTIFY:
6817
6994
  return { ...actionBase, type: action };
6818
6995
  case ActionType.PRINT_CERTIFICATE:
6819
- return { ...actionBase, type: action };
6996
+ return {
6997
+ ...actionBase,
6998
+ type: action,
6999
+ content: defaults.content
7000
+ };
6820
7001
  case ActionType.REQUEST_CORRECTION:
6821
7002
  return { ...actionBase, type: action };
6822
7003
  case ActionType.APPROVE_CORRECTION:
@@ -6825,7 +7006,8 @@ function generateActionDocument({
6825
7006
  return {
6826
7007
  ...actionBase,
6827
7008
  requestId: getUUID(),
6828
- type: action
7009
+ type: action,
7010
+ reason: { message: "Correction rejection" }
6829
7011
  };
6830
7012
  case ActionType.REGISTER:
6831
7013
  return {
@@ -7215,14 +7397,6 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7215
7397
  ActionType.REJECT_CORRECTION,
7216
7398
  ExclusiveActions.REVIEW_CORRECTION_REQUEST
7217
7399
  ],
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
7400
  [EventStatus.enum.ARCHIVED]: [
7227
7401
  ActionType.READ,
7228
7402
  ActionType.ASSIGN,
@@ -7230,9 +7404,12 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7230
7404
  ]
7231
7405
  };
7232
7406
  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];
7407
+ if (event2.flags.includes(InherentFlags.REJECTED)) {
7408
+ return [
7409
+ ActionType.READ,
7410
+ event2.status === EventStatus.Enum.VALIDATED ? ActionType.VALIDATE : ActionType.DECLARE,
7411
+ ActionType.ARCHIVE
7412
+ ];
7413
+ }
7414
+ return AVAILABLE_ACTIONS_BY_EVENT_STATUS[event2.status];
7238
7415
  };