@opencrvs/toolkit 1.8.1-rc.9f4c5c5 → 1.8.1-rc.a9d9f0d

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.
@@ -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,
@@ -168,6 +172,7 @@ __export(events_exports, {
168
172
  TENNIS_CLUB_MEMBERSHIP: () => TENNIS_CLUB_MEMBERSHIP,
169
173
  TEST_SYSTEM_IANA_TIMEZONE: () => TEST_SYSTEM_IANA_TIMEZONE,
170
174
  TestUserRole: () => TestUserRole,
175
+ TextField: () => TextField,
171
176
  TextValue: () => TextValue,
172
177
  TimeValue: () => TimeValue,
173
178
  TranslationConfig: () => TranslationConfig,
@@ -179,7 +184,6 @@ __export(events_exports, {
179
184
  ValidationConfig: () => ValidationConfig,
180
185
  VerificationActionConfig: () => VerificationActionConfig,
181
186
  VerificationPageConfig: () => VerificationPageConfig,
182
- VisibleStatus: () => VisibleStatus,
183
187
  WRITE_ACTION_SCOPES: () => WRITE_ACTION_SCOPES,
184
188
  Within: () => Within,
185
189
  WorkqueueActionsWithDefault: () => WorkqueueActionsWithDefault,
@@ -322,6 +326,7 @@ __export(events_exports, {
322
326
  or: () => or,
323
327
  resolveDateOfEvent: () => resolveDateOfEvent,
324
328
  runFieldValidations: () => runFieldValidations,
329
+ runStructuralValidations: () => runStructuralValidations,
325
330
  timePeriodToDateRange: () => timePeriodToDateRange,
326
331
  user: () => user,
327
332
  validate: () => validate,
@@ -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(
@@ -608,13 +613,13 @@ var UrbanAddressUpdateValue = AdminStructure.extend({
608
613
  zipCode: import_zod5.z.string().nullish()
609
614
  });
610
615
  var NameFieldValue = import_zod5.z.object({
611
- firstname: import_zod5.z.string().min(1),
612
- surname: import_zod5.z.string().min(1),
616
+ firstname: import_zod5.z.string(),
617
+ surname: import_zod5.z.string(),
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({
@@ -1397,22 +1416,30 @@ var FieldConfigSchema = BaseField3.extend({
1397
1416
  fieldType: import_zod15.z.literal("field"),
1398
1417
  alternateFieldIds: import_zod15.z.array(import_zod15.z.string()).optional().describe(
1399
1418
  `Sometimes there might be need to search a value against multiple field of same FormField type. For example
1400
- 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
1401
1420
  add a one field as fieldId, and accomodate others in alternateFieldIds`
1402
1421
  ),
1403
- excludeInSearchQuery: import_zod15.z.boolean().default(false).optional().describe(`Sometimes there will be search fields which are used to
1404
- 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
1405
1424
  is select field, which has 3 options, FACILITY, PRIVATE_HOME, OTHER. Upon selecting any of the option, pops up another field
1406
1425
  related to the selected option, whose value is required in the search query. But child.placeOfBirth itself is not needed in the query.
1407
1426
  In such case, populate this field (excludeInSearchQuery) with boolean true`)
1408
1427
  });
1409
- var EventFieldId = import_zod15.z.enum([
1428
+ var EventFieldIdInput = import_zod15.z.enum([
1410
1429
  "trackingId",
1411
1430
  "status",
1412
1431
  "legalStatuses.REGISTERED.acceptedAt",
1413
1432
  "legalStatuses.REGISTERED.createdAtLocation",
1414
1433
  "updatedAt"
1415
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
+ ]);
1416
1443
  var EventFieldConfigSchema = BaseField3.extend({
1417
1444
  fieldId: EventFieldId,
1418
1445
  fieldType: import_zod15.z.literal("event")
@@ -2438,6 +2465,23 @@ function validateFieldInput({
2438
2465
  const rawError = zodType.safeParse(value, { errorMap: zodToIntlErrorMap });
2439
2466
  return rawError.error?.issues.map((issue) => issue.message) ?? [];
2440
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
+ }
2441
2485
  function runFieldValidations({
2442
2486
  field: field2,
2443
2487
  values
@@ -2728,16 +2772,16 @@ function timePeriodToDateRange(value) {
2728
2772
  let startDate;
2729
2773
  switch (value) {
2730
2774
  case "last7Days":
2731
- startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 6);
2775
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 7);
2732
2776
  break;
2733
2777
  case "last30Days":
2734
- startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 29);
2778
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 30);
2735
2779
  break;
2736
2780
  case "last90Days":
2737
- startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 89);
2781
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 90);
2738
2782
  break;
2739
2783
  case "last365Days":
2740
- startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 364);
2784
+ startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 365);
2741
2785
  break;
2742
2786
  }
2743
2787
  return {
@@ -3104,8 +3148,9 @@ function createFieldConditionals(fieldId) {
3104
3148
  properties: {
3105
3149
  [fieldId]: {
3106
3150
  type: "string",
3107
- 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'._-]*)*$",
3108
- 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."
3109
3154
  }
3110
3155
  }
3111
3156
  }),
@@ -3218,7 +3263,7 @@ function createSearchConfig(baseField) {
3218
3263
  // ../commons/src/event-config/event-configuration.ts
3219
3264
  function createEventFieldConfig(fieldId) {
3220
3265
  const baseField = {
3221
- fieldId,
3266
+ fieldId: `${METADATA_FIELD_PREFIX}${fieldId}`,
3222
3267
  fieldType: "event"
3223
3268
  };
3224
3269
  return createSearchConfig(baseField);
@@ -3350,24 +3395,23 @@ var EventStatus = import_zod23.z.enum([
3350
3395
  "DECLARED",
3351
3396
  "VALIDATED",
3352
3397
  "REGISTERED",
3353
- "CERTIFIED",
3354
3398
  "ARCHIVED"
3355
3399
  ]);
3356
- var VisibleStatus = import_zod23.z.enum([...EventStatus.options, "REJECTED"]);
3357
3400
  var InherentFlags = {
3358
- PRINTED: "printed",
3401
+ PENDING_CERTIFICATION: "pending-certification",
3359
3402
  INCOMPLETE: "incomplete",
3360
3403
  REJECTED: "rejected",
3361
3404
  CORRECTION_REQUESTED: "correction-requested"
3362
3405
  };
3363
- var Flag = import_zod23.z.string().regex(
3406
+ var ActionFlag = import_zod23.z.string().regex(
3364
3407
  new RegExp(
3365
3408
  `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
3366
3409
  ActionStatus
3367
3410
  ).join("|").toLowerCase()})$`
3368
3411
  ),
3369
3412
  "Flag must be in the format ActionType:ActionStatus (lowerCase)"
3370
- ).or(import_zod23.z.nativeEnum(InherentFlags));
3413
+ );
3414
+ var Flag = ActionFlag.or(import_zod23.z.nativeEnum(InherentFlags));
3371
3415
  var ZodDate = import_zod23.z.string().date();
3372
3416
  var ActionCreationMetadata = import_zod23.z.object({
3373
3417
  createdAt: import_zod23.z.string().datetime().describe("The timestamp when the action request was created."),
@@ -3883,7 +3927,8 @@ var WorkqueueConfig = import_zod28.z.object({
3883
3927
  })
3884
3928
  ),
3885
3929
  columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
3886
- icon: AvailableIcons
3930
+ icon: AvailableIcons,
3931
+ emptyMessage: TranslationConfig.optional()
3887
3932
  }).describe("Configuration for workqueue.");
3888
3933
  var WorkqueueConfigWithoutQuery = WorkqueueConfig.omit({
3889
3934
  query: true,
@@ -3902,7 +3947,8 @@ var WorkqueueConfigInput = import_zod28.z.object({
3902
3947
  })
3903
3948
  ),
3904
3949
  columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
3905
- icon: AvailableIcons
3950
+ icon: AvailableIcons,
3951
+ emptyMessage: TranslationConfig.optional()
3906
3952
  });
3907
3953
  function defineWorkqueue(workqueueInput) {
3908
3954
  const queryInput = workqueueInput.query;
@@ -4204,16 +4250,19 @@ function getLegalStatuses(actions) {
4204
4250
  }
4205
4251
 
4206
4252
  // ../commons/src/events/state/flags.ts
4207
- function isCertificatePrinted(actions) {
4253
+ function isPendingCertification(actions) {
4254
+ if (getStatusFromActions(actions) !== EventStatus.enum.REGISTERED) {
4255
+ return false;
4256
+ }
4208
4257
  return actions.reduce((prev, { type }) => {
4209
4258
  if (type === ActionType.PRINT_CERTIFICATE) {
4210
- return true;
4259
+ return false;
4211
4260
  }
4212
4261
  if (type === ActionType.APPROVE_CORRECTION) {
4213
- return false;
4262
+ return true;
4214
4263
  }
4215
4264
  return prev;
4216
- }, false);
4265
+ }, true);
4217
4266
  }
4218
4267
  function isCorrectionRequested(actions) {
4219
4268
  return actions.reduce((prev, { type }) => {
@@ -4248,8 +4297,8 @@ function getFlagsFromActions(actions) {
4248
4297
  const flag = joinValues([type, status], ":").toLowerCase();
4249
4298
  return flag;
4250
4299
  });
4251
- if (isCertificatePrinted(sortedActions)) {
4252
- flags.push(InherentFlags.PRINTED);
4300
+ if (isPendingCertification(sortedActions)) {
4301
+ flags.push(InherentFlags.PENDING_CERTIFICATION);
4253
4302
  }
4254
4303
  if (isCorrectionRequested(sortedActions)) {
4255
4304
  flags.push(InherentFlags.CORRECTION_REQUESTED);
@@ -4280,7 +4329,6 @@ function getStatusFromActions(actions) {
4280
4329
  case ActionType.NOTIFY:
4281
4330
  return EventStatus.enum.NOTIFIED;
4282
4331
  case ActionType.PRINT_CERTIFICATE:
4283
- return EventStatus.enum.CERTIFIED;
4284
4332
  case ActionType.ASSIGN:
4285
4333
  case ActionType.UNASSIGN:
4286
4334
  case ActionType.REJECT:
@@ -5245,7 +5293,27 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
5245
5293
  defaultMessage: "Applicant's name",
5246
5294
  description: "This is the label for the field",
5247
5295
  id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.firstname.label"
5248
- }
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
+ ]
5249
5317
  },
5250
5318
  {
5251
5319
  id: "applicant.email",
@@ -5467,22 +5535,6 @@ var statusOptions = [
5467
5535
  id: "v2.advancedSearch.form.recordStatusRegistered"
5468
5536
  }
5469
5537
  },
5470
- {
5471
- value: EventStatus.enum.CERTIFIED,
5472
- label: {
5473
- defaultMessage: "Certified",
5474
- description: "Option for form field: status of record",
5475
- id: "v2.advancedSearch.form.recordStatusCertified"
5476
- }
5477
- },
5478
- {
5479
- value: VisibleStatus.enum.REJECTED,
5480
- label: {
5481
- defaultMessage: "Rejected",
5482
- description: "Option for form field: status of record",
5483
- id: "v2.advancedSearch.form.recordStatusRejected"
5484
- }
5485
- },
5486
5538
  {
5487
5539
  value: EventStatus.enum.ARCHIVED,
5488
5540
  label: {
@@ -7338,14 +7390,6 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7338
7390
  ActionType.REJECT_CORRECTION,
7339
7391
  ExclusiveActions.REVIEW_CORRECTION_REQUEST
7340
7392
  ],
7341
- [EventStatus.enum.CERTIFIED]: [
7342
- ActionType.READ,
7343
- ActionType.PRINT_CERTIFICATE,
7344
- ActionType.REQUEST_CORRECTION,
7345
- ActionType.APPROVE_CORRECTION,
7346
- ActionType.REJECT_CORRECTION,
7347
- ExclusiveActions.REVIEW_CORRECTION_REQUEST
7348
- ],
7349
7393
  [EventStatus.enum.ARCHIVED]: [
7350
7394
  ActionType.READ,
7351
7395
  ActionType.ASSIGN,
@@ -7353,9 +7397,12 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7353
7397
  ]
7354
7398
  };
7355
7399
  var getAvailableActionsForEvent = (event2) => {
7356
- return event2.flags.includes(InherentFlags.REJECTED) ? [
7357
- ActionType.READ,
7358
- event2.status === EventStatus.Enum.VALIDATED ? ActionType.VALIDATE : ActionType.DECLARE,
7359
- ActionType.ARCHIVE
7360
- ] : 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];
7361
7408
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/toolkit",
3
- "version": "1.8.1-rc.9f4c5c5",
3
+ "version": "1.8.1-rc.a9d9f0d",
4
4
  "description": "OpenCRVS toolkit for building country configurations",
5
5
  "license": "MPL-2.0",
6
6
  "exports": {