@opencrvs/toolkit 1.8.1-rc.4d47be0 → 1.8.1-rc.4ed8a2e

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 +409 -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 +1252 -716
  5. package/dist/commons/events/ActionInput.d.ts +626 -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 +451 -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 +12 -12
  24. package/dist/commons/events/utils.d.ts +236 -60
  25. package/dist/conditionals/index.js +3 -2
  26. package/dist/events/index.js +288 -120
  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(
@@ -606,13 +613,13 @@ var UrbanAddressUpdateValue = AdminStructure.extend({
606
613
  zipCode: import_zod5.z.string().nullish()
607
614
  });
608
615
  var NameFieldValue = import_zod5.z.object({
609
- firstname: import_zod5.z.string().min(1),
610
- surname: import_zod5.z.string().min(1),
616
+ firstname: import_zod5.z.string(),
617
+ surname: import_zod5.z.string(),
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,14 @@ 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
2025
  requestId: import_zod19.z.string(),
2026
+ // TODO move into 'content' property
1984
2027
  reason: RejectionReason
1985
2028
  })
1986
2029
  );
@@ -2031,7 +2074,7 @@ var ResolvedUser = import_zod19.z.object({
2031
2074
  });
2032
2075
 
2033
2076
  // ../commons/src/conditionals/validate.ts
2034
- var import_ajv = __toESM(require("ajv"));
2077
+ var import__ = __toESM(require("ajv/dist/2019"));
2035
2078
  var import_ajv_formats = __toESM(require("ajv-formats"));
2036
2079
  var import_date_fns = require("date-fns");
2037
2080
 
@@ -2245,9 +2288,15 @@ var isNonInteractiveFieldType = (field2) => {
2245
2288
  };
2246
2289
 
2247
2290
  // ../commons/src/conditionals/validate.ts
2248
- var ajv = new import_ajv.default({
2291
+ var ajv = new import__.default({
2249
2292
  $data: true,
2250
- allowUnionTypes: true
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
2251
2300
  });
2252
2301
  (0, import_ajv_formats.default)(ajv);
2253
2302
  ajv.addKeyword({
@@ -2420,6 +2469,23 @@ function validateFieldInput({
2420
2469
  const rawError = zodType.safeParse(value, { errorMap: zodToIntlErrorMap });
2421
2470
  return rawError.error?.issues.map((issue) => issue.message) ?? [];
2422
2471
  }
2472
+ function runStructuralValidations({
2473
+ field: field2,
2474
+ values
2475
+ }) {
2476
+ if (!isFieldVisible(field2, values) || isFieldEmptyAndNotRequired(field2, values)) {
2477
+ return {
2478
+ errors: []
2479
+ };
2480
+ }
2481
+ const fieldValidationResult = validateFieldInput({
2482
+ field: field2,
2483
+ value: values[field2.id]
2484
+ });
2485
+ return {
2486
+ errors: fieldValidationResult
2487
+ };
2488
+ }
2423
2489
  function runFieldValidations({
2424
2490
  field: field2,
2425
2491
  values
@@ -2485,6 +2551,11 @@ function getValidatorsForField(fieldId, validations) {
2485
2551
  };
2486
2552
  }).filter((x) => x !== null);
2487
2553
  }
2554
+ function areCertificateConditionsMet(conditions, values) {
2555
+ return conditions.every((condition) => {
2556
+ return ajv.validate(condition.conditional, values);
2557
+ });
2558
+ }
2488
2559
 
2489
2560
  // ../commons/src/utils.ts
2490
2561
  function getOrThrow(x, message) {
@@ -2705,16 +2776,16 @@ function timePeriodToDateRange(value) {
2705
2776
  let startDate;
2706
2777
  switch (value) {
2707
2778
  case "last7Days":
2708
- startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 6);
2779
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 7);
2709
2780
  break;
2710
2781
  case "last30Days":
2711
- startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 29);
2782
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 30);
2712
2783
  break;
2713
2784
  case "last90Days":
2714
- startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 89);
2785
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 90);
2715
2786
  break;
2716
2787
  case "last365Days":
2717
- startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 364);
2788
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 365);
2718
2789
  break;
2719
2790
  }
2720
2791
  return {
@@ -3081,8 +3152,9 @@ function createFieldConditionals(fieldId) {
3081
3152
  properties: {
3082
3153
  [fieldId]: {
3083
3154
  type: "string",
3084
- 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'._-]*)*$",
3085
- description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
3155
+ minLength: 1,
3156
+ 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'.-]*)*$",
3157
+ description: "Name must contain only letters, numbers, and allowed special characters ('.-). No double spaces."
3086
3158
  }
3087
3159
  }
3088
3160
  }),
@@ -3175,6 +3247,19 @@ function createSearchConfig(baseField) {
3175
3247
  fuzzy: () => ({
3176
3248
  ...baseField,
3177
3249
  config: { type: "fuzzy" }
3250
+ }),
3251
+ /**
3252
+ * Creates a configuration for matching locations and the child locations
3253
+ * @returns An object containing the field ID and a configuration object with a type of 'within'.
3254
+ * @example field('createdAtLocation').within()
3255
+ * // {
3256
+ * // ...
3257
+ * // config: { type: 'within' }
3258
+ * // }
3259
+ */
3260
+ within: () => ({
3261
+ ...baseField,
3262
+ config: { type: "within" }
3178
3263
  })
3179
3264
  };
3180
3265
  }
@@ -3182,7 +3267,7 @@ function createSearchConfig(baseField) {
3182
3267
  // ../commons/src/event-config/event-configuration.ts
3183
3268
  function createEventFieldConfig(fieldId) {
3184
3269
  const baseField = {
3185
- fieldId,
3270
+ fieldId: `${METADATA_FIELD_PREFIX}${fieldId}`,
3186
3271
  fieldType: "event"
3187
3272
  };
3188
3273
  return createSearchConfig(baseField);
@@ -3195,32 +3280,107 @@ function eventFn(fieldId) {
3195
3280
  var event = Object.assign(eventFn, {
3196
3281
  /**
3197
3282
  * Checks if the event contains a specific action type.
3283
+ * Can be used directly as a conditional or chained with additional methods.
3198
3284
  * @param action - The action type to check for.
3199
3285
  */
3200
- hasAction: (action) => defineConditional({
3201
- type: "object",
3202
- properties: {
3203
- $event: {
3286
+ hasAction: (action) => {
3287
+ const basicConditional = defineConditional({
3288
+ type: "object",
3289
+ properties: {
3290
+ $event: {
3291
+ type: "object",
3292
+ properties: {
3293
+ actions: {
3294
+ type: "array",
3295
+ contains: {
3296
+ type: "object",
3297
+ properties: {
3298
+ type: {
3299
+ const: action
3300
+ }
3301
+ },
3302
+ required: ["type"]
3303
+ }
3304
+ }
3305
+ },
3306
+ required: ["actions"]
3307
+ }
3308
+ },
3309
+ required: ["$event"]
3310
+ });
3311
+ const buildActionConstraints = (additionalFields) => {
3312
+ const actionProperties = {
3313
+ type: { const: action }
3314
+ };
3315
+ const requiredFields = ["type"];
3316
+ if (additionalFields) {
3317
+ Object.entries(additionalFields).forEach(([key, value]) => {
3318
+ actionProperties[key] = { const: value };
3319
+ requiredFields.push(key);
3320
+ });
3321
+ }
3322
+ return { actionProperties, requiredFields };
3323
+ };
3324
+ const createCountConditional = (countType, count, additionalFields) => {
3325
+ const { actionProperties, requiredFields } = buildActionConstraints(additionalFields);
3326
+ return defineConditional({
3204
3327
  type: "object",
3205
3328
  properties: {
3206
- actions: {
3207
- type: "array",
3208
- contains: {
3209
- type: "object",
3210
- properties: {
3211
- type: {
3212
- const: action
3213
- }
3214
- },
3215
- required: ["type"]
3216
- }
3329
+ $event: {
3330
+ type: "object",
3331
+ properties: {
3332
+ actions: {
3333
+ type: "array",
3334
+ contains: {
3335
+ type: "object",
3336
+ properties: actionProperties,
3337
+ required: requiredFields
3338
+ },
3339
+ [countType]: count
3340
+ }
3341
+ },
3342
+ required: ["actions"]
3217
3343
  }
3218
3344
  },
3219
- required: ["actions"]
3220
- }
3221
- },
3222
- required: ["$event"]
3223
- }),
3345
+ required: ["$event"]
3346
+ });
3347
+ };
3348
+ const withMinMax = (additionalFields) => {
3349
+ return {
3350
+ /**
3351
+ * Creates a conditional that checks if the event contains a specific action type
3352
+ * with a minimum count of occurrences.
3353
+ *
3354
+ * @param minCount - The minimum number of actions required.
3355
+ */
3356
+ minCount: (minCount) => createCountConditional("minContains", minCount, additionalFields),
3357
+ /**
3358
+ * Builds a conditional that sets a maximum count for the number of actions.
3359
+ * This is useful for limiting the number of actions of a specific type in a single event.
3360
+ */
3361
+ maxCount: (maxCount) => createCountConditional("maxContains", maxCount, additionalFields)
3362
+ };
3363
+ };
3364
+ const chainableMethods = {
3365
+ /**
3366
+ * Adds additional field constraints to the action matching.
3367
+ *
3368
+ * @param fields - Object containing additional fields to match on the action.
3369
+ */
3370
+ withFields: (fields) => withMinMax(fields),
3371
+ /**
3372
+ * Adds template ID constraint to the action matching.
3373
+ * This is a convenience method that adds content.templateId to the fields.
3374
+ *
3375
+ * @param id - The template ID to match against.
3376
+ */
3377
+ withTemplate: (id) => withMinMax({
3378
+ content: { templateId: id }
3379
+ }),
3380
+ ...withMinMax()
3381
+ };
3382
+ return { ...basicConditional, ...chainableMethods };
3383
+ },
3224
3384
  field(field2) {
3225
3385
  return {
3226
3386
  $event: field2
@@ -3239,24 +3399,23 @@ var EventStatus = import_zod23.z.enum([
3239
3399
  "DECLARED",
3240
3400
  "VALIDATED",
3241
3401
  "REGISTERED",
3242
- "CERTIFIED",
3243
3402
  "ARCHIVED"
3244
3403
  ]);
3245
- var VisibleStatus = import_zod23.z.enum([...EventStatus.options, "REJECTED"]);
3246
3404
  var InherentFlags = {
3247
- PRINTED: "printed",
3405
+ PENDING_CERTIFICATION: "pending-certification",
3248
3406
  INCOMPLETE: "incomplete",
3249
3407
  REJECTED: "rejected",
3250
3408
  CORRECTION_REQUESTED: "correction-requested"
3251
3409
  };
3252
- var Flag = import_zod23.z.string().regex(
3410
+ var ActionFlag = import_zod23.z.string().regex(
3253
3411
  new RegExp(
3254
3412
  `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
3255
3413
  ActionStatus
3256
3414
  ).join("|").toLowerCase()})$`
3257
3415
  ),
3258
3416
  "Flag must be in the format ActionType:ActionStatus (lowerCase)"
3259
- ).or(import_zod23.z.nativeEnum(InherentFlags));
3417
+ );
3418
+ var Flag = ActionFlag.or(import_zod23.z.nativeEnum(InherentFlags));
3260
3419
  var ZodDate = import_zod23.z.string().date();
3261
3420
  var ActionCreationMetadata = import_zod23.z.object({
3262
3421
  createdAt: import_zod23.z.string().datetime().describe("The timestamp when the action request was created."),
@@ -3524,6 +3683,9 @@ var QueryExpression = import_zod25.z.object({
3524
3683
  createdAt: import_zod25.z.optional(DateCondition),
3525
3684
  updatedAt: import_zod25.z.optional(DateCondition),
3526
3685
  "legalStatuses.REGISTERED.acceptedAt": import_zod25.z.optional(DateCondition),
3686
+ "legalStatuses.DECLARED.createdAtLocation": import_zod25.z.optional(
3687
+ import_zod25.z.union([Within, Exact])
3688
+ ),
3527
3689
  "legalStatuses.REGISTERED.createdAtLocation": import_zod25.z.optional(
3528
3690
  import_zod25.z.union([Within, Exact])
3529
3691
  ),
@@ -3769,7 +3931,8 @@ var WorkqueueConfig = import_zod28.z.object({
3769
3931
  })
3770
3932
  ),
3771
3933
  columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
3772
- icon: AvailableIcons
3934
+ icon: AvailableIcons,
3935
+ emptyMessage: TranslationConfig.optional()
3773
3936
  }).describe("Configuration for workqueue.");
3774
3937
  var WorkqueueConfigWithoutQuery = WorkqueueConfig.omit({
3775
3938
  query: true,
@@ -3788,7 +3951,8 @@ var WorkqueueConfigInput = import_zod28.z.object({
3788
3951
  })
3789
3952
  ),
3790
3953
  columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
3791
- icon: AvailableIcons
3954
+ icon: AvailableIcons,
3955
+ emptyMessage: TranslationConfig.optional()
3792
3956
  });
3793
3957
  function defineWorkqueue(workqueueInput) {
3794
3958
  const queryInput = workqueueInput.query;
@@ -3877,7 +4041,8 @@ var DeclareActionInput = BaseActionInput.merge(
3877
4041
  );
3878
4042
  var PrintCertificateActionInput = BaseActionInput.merge(
3879
4043
  import_zod29.z.object({
3880
- type: import_zod29.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE)
4044
+ type: import_zod29.z.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE),
4045
+ content: PrintContent.optional()
3881
4046
  })
3882
4047
  );
3883
4048
  var RejectDeclarationActionInput = BaseActionInput.merge(
@@ -4089,16 +4254,19 @@ function getLegalStatuses(actions) {
4089
4254
  }
4090
4255
 
4091
4256
  // ../commons/src/events/state/flags.ts
4092
- function isCertificatePrinted(actions) {
4257
+ function isPendingCertification(actions) {
4258
+ if (getStatusFromActions(actions) !== EventStatus.enum.REGISTERED) {
4259
+ return false;
4260
+ }
4093
4261
  return actions.reduce((prev, { type }) => {
4094
4262
  if (type === ActionType.PRINT_CERTIFICATE) {
4095
- return true;
4263
+ return false;
4096
4264
  }
4097
4265
  if (type === ActionType.APPROVE_CORRECTION) {
4098
- return false;
4266
+ return true;
4099
4267
  }
4100
4268
  return prev;
4101
- }, false);
4269
+ }, true);
4102
4270
  }
4103
4271
  function isCorrectionRequested(actions) {
4104
4272
  return actions.reduce((prev, { type }) => {
@@ -4133,8 +4301,8 @@ function getFlagsFromActions(actions) {
4133
4301
  const flag = joinValues([type, status], ":").toLowerCase();
4134
4302
  return flag;
4135
4303
  });
4136
- if (isCertificatePrinted(sortedActions)) {
4137
- flags.push(InherentFlags.PRINTED);
4304
+ if (isPendingCertification(sortedActions)) {
4305
+ flags.push(InherentFlags.PENDING_CERTIFICATION);
4138
4306
  }
4139
4307
  if (isCorrectionRequested(sortedActions)) {
4140
4308
  flags.push(InherentFlags.CORRECTION_REQUESTED);
@@ -4165,7 +4333,6 @@ function getStatusFromActions(actions) {
4165
4333
  case ActionType.NOTIFY:
4166
4334
  return EventStatus.enum.NOTIFIED;
4167
4335
  case ActionType.PRINT_CERTIFICATE:
4168
- return EventStatus.enum.CERTIFIED;
4169
4336
  case ActionType.ASSIGN:
4170
4337
  case ActionType.UNASSIGN:
4171
4338
  case ActionType.REJECT:
@@ -5130,7 +5297,27 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
5130
5297
  defaultMessage: "Applicant's name",
5131
5298
  description: "This is the label for the field",
5132
5299
  id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.firstname.label"
5133
- }
5300
+ },
5301
+ configuration: {
5302
+ name: {
5303
+ firstname: { required: true },
5304
+ middlename: { required: false },
5305
+ surname: { required: true }
5306
+ }
5307
+ },
5308
+ validation: [
5309
+ {
5310
+ validator: field("applicant.name").object({
5311
+ firstname: field("firstname").isValidEnglishName(),
5312
+ surname: field("surname").isValidEnglishName()
5313
+ }),
5314
+ message: {
5315
+ defaultMessage: "Input contains invalid characters. Please use only letters (a-z, A-Z), numbers (0-9), hyphens (-), apostrophes(') and underscores (_)",
5316
+ description: "This is the error message for invalid name",
5317
+ id: "v2.error.invalidName"
5318
+ }
5319
+ }
5320
+ ]
5134
5321
  },
5135
5322
  {
5136
5323
  id: "applicant.email",
@@ -5352,22 +5539,6 @@ var statusOptions = [
5352
5539
  id: "v2.advancedSearch.form.recordStatusRegistered"
5353
5540
  }
5354
5541
  },
5355
- {
5356
- value: EventStatus.enum.CERTIFIED,
5357
- label: {
5358
- defaultMessage: "Certified",
5359
- description: "Option for form field: status of record",
5360
- id: "v2.advancedSearch.form.recordStatusCertified"
5361
- }
5362
- },
5363
- {
5364
- value: VisibleStatus.enum.REJECTED,
5365
- label: {
5366
- defaultMessage: "Rejected",
5367
- description: "Option for form field: status of record",
5368
- id: "v2.advancedSearch.form.recordStatusRejected"
5369
- }
5370
- },
5371
5542
  {
5372
5543
  value: EventStatus.enum.ARCHIVED,
5373
5544
  label: {
@@ -5574,44 +5745,41 @@ var tennisClubMembershipEvent = defineConfig({
5574
5745
  },
5575
5746
  {
5576
5747
  id: "identity-check",
5577
- type: PageTypes.enum.FORM,
5748
+ type: PageTypes.enum.VERIFICATION,
5578
5749
  title: {
5579
- id: "event.tennis-club-membership.action.requestCorrection.form.section.verify",
5580
- defaultMessage: "Verify their identity",
5750
+ id: "v2.event.birth.action.correction.form.section.requester.identity.verify.title",
5751
+ defaultMessage: "Verify ID",
5581
5752
  description: "This is the title of the section"
5582
5753
  },
5583
- fields: [
5584
- {
5585
- id: "correction.identity-check.instructions",
5586
- type: "PAGE_HEADER",
5754
+ fields: [],
5755
+ actions: {
5756
+ verify: {
5587
5757
  label: {
5588
- id: "correction.corrector.identity.instruction",
5589
- defaultMessage: "Please verify the identity of the person making this request",
5590
- description: "The title for the corrector form"
5758
+ defaultMessage: "Verified",
5759
+ description: "This is the label for the verification button",
5760
+ id: "v2.event.birth.action.correction.form.verify"
5591
5761
  }
5592
5762
  },
5593
- {
5594
- id: "correction.identity-check.verified",
5595
- type: "RADIO_GROUP",
5763
+ cancel: {
5596
5764
  label: {
5597
- id: "correction.corrector.identity.verified.label",
5598
- defaultMessage: "Identity verified",
5599
- description: "The title for the corrector form"
5765
+ defaultMessage: "Identity does not match",
5766
+ description: "This is the label for the verification cancellation button",
5767
+ id: "v2.event.birth.action.correction.form.cancel"
5600
5768
  },
5601
- defaultValue: "",
5602
- required: true,
5603
- options: [
5604
- {
5605
- value: "VERIFIED",
5606
- label: {
5607
- id: "correction.corrector.identity.verified",
5608
- defaultMessage: "I have verified their identity",
5609
- description: "Label for verified option in corrector identity check page"
5610
- }
5769
+ confirmation: {
5770
+ title: {
5771
+ defaultMessage: "Correct without proof of ID?",
5772
+ description: "This is the title for the verification cancellation modal",
5773
+ id: "v2.event.birth.action.correction.form.cancel.confirmation.title"
5774
+ },
5775
+ body: {
5776
+ 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",
5777
+ description: "This is the body for the verification cancellation modal",
5778
+ id: "v2.event.birth.action.correction.form.cancel.confirmation.body"
5611
5779
  }
5612
- ]
5780
+ }
5613
5781
  }
5614
- ]
5782
+ }
5615
5783
  },
5616
5784
  {
5617
5785
  id: "correction-request.supporting-documents",
@@ -6585,6 +6753,7 @@ function eventPayloadGenerator(rng) {
6585
6753
  annotation: {
6586
6754
  "correction.requester.relationship": "ANOTHER_AGENT",
6587
6755
  "correction.request.reason": "Child's name was incorrect",
6756
+ "identity-check": true,
6588
6757
  ...annotation
6589
6758
  },
6590
6759
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -6819,7 +6988,11 @@ function generateActionDocument({
6819
6988
  case ActionType.NOTIFY:
6820
6989
  return { ...actionBase, type: action };
6821
6990
  case ActionType.PRINT_CERTIFICATE:
6822
- return { ...actionBase, type: action };
6991
+ return {
6992
+ ...actionBase,
6993
+ type: action,
6994
+ content: defaults.content
6995
+ };
6823
6996
  case ActionType.REQUEST_CORRECTION:
6824
6997
  return { ...actionBase, type: action };
6825
6998
  case ActionType.APPROVE_CORRECTION:
@@ -7219,14 +7392,6 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7219
7392
  ActionType.REJECT_CORRECTION,
7220
7393
  ExclusiveActions.REVIEW_CORRECTION_REQUEST
7221
7394
  ],
7222
- [EventStatus.enum.CERTIFIED]: [
7223
- ActionType.READ,
7224
- ActionType.PRINT_CERTIFICATE,
7225
- ActionType.REQUEST_CORRECTION,
7226
- ActionType.APPROVE_CORRECTION,
7227
- ActionType.REJECT_CORRECTION,
7228
- ExclusiveActions.REVIEW_CORRECTION_REQUEST
7229
- ],
7230
7395
  [EventStatus.enum.ARCHIVED]: [
7231
7396
  ActionType.READ,
7232
7397
  ActionType.ASSIGN,
@@ -7234,9 +7399,12 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7234
7399
  ]
7235
7400
  };
7236
7401
  var getAvailableActionsForEvent = (event2) => {
7237
- return event2.flags.includes(InherentFlags.REJECTED) ? [
7238
- ActionType.READ,
7239
- event2.status === EventStatus.Enum.VALIDATED ? ActionType.VALIDATE : ActionType.DECLARE,
7240
- ActionType.ARCHIVE
7241
- ] : AVAILABLE_ACTIONS_BY_EVENT_STATUS[event2.status];
7402
+ if (event2.flags.includes(InherentFlags.REJECTED)) {
7403
+ return [
7404
+ ActionType.READ,
7405
+ event2.status === EventStatus.Enum.VALIDATED ? ActionType.VALIDATE : ActionType.DECLARE,
7406
+ ActionType.ARCHIVE
7407
+ ];
7408
+ }
7409
+ return AVAILABLE_ACTIONS_BY_EVENT_STATUS[event2.status];
7242
7410
  };