@opencrvs/toolkit 1.8.1-rc.bbbfede → 1.8.1-rc.facd84c

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.
@@ -117,8 +117,6 @@ export declare const EventIndex: z.ZodObject<z.objectUtil.extendShape<{
117
117
  readonly REJECTED: "rejected";
118
118
  readonly CORRECTION_REQUESTED: "correction-requested";
119
119
  }>]>, "many">;
120
- copiesPrintedForTemplate: z.ZodOptional<z.ZodNumber>;
121
- modifiedAt: z.ZodOptional<z.ZodString>;
122
120
  }, {
123
121
  declaration: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodString, z.ZodString, z.ZodUnion<[z.ZodObject<{
124
122
  start: z.ZodString;
@@ -354,8 +352,6 @@ export declare const EventIndex: z.ZodObject<z.objectUtil.extendShape<{
354
352
  dateOfEvent?: string | null | undefined;
355
353
  updatedAtLocation?: (string & z.BRAND<"UUID">) | null | undefined;
356
354
  updatedBy?: string | null | undefined;
357
- copiesPrintedForTemplate?: number | undefined;
358
- modifiedAt?: string | undefined;
359
355
  }, {
360
356
  type: string;
361
357
  id: string;
@@ -443,8 +439,6 @@ export declare const EventIndex: z.ZodObject<z.objectUtil.extendShape<{
443
439
  dateOfEvent?: string | null | undefined;
444
440
  updatedAtLocation?: string | null | undefined;
445
441
  updatedBy?: string | null | undefined;
446
- copiesPrintedForTemplate?: number | undefined;
447
- modifiedAt?: string | undefined;
448
442
  }>;
449
443
  export declare const EventSearchIndex: z.ZodIntersection<z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodObject<{
450
444
  type: z.ZodString;
@@ -297,8 +297,6 @@ export declare const EventMetadata: z.ZodObject<{
297
297
  readonly REJECTED: "rejected";
298
298
  readonly CORRECTION_REQUESTED: "correction-requested";
299
299
  }>]>, "many">;
300
- copiesPrintedForTemplate: z.ZodOptional<z.ZodNumber>;
301
- modifiedAt: z.ZodOptional<z.ZodString>;
302
300
  }, "strip", z.ZodTypeAny, {
303
301
  type: string;
304
302
  id: string & z.BRAND<"UUID">;
@@ -337,8 +335,6 @@ export declare const EventMetadata: z.ZodObject<{
337
335
  dateOfEvent?: string | null | undefined;
338
336
  updatedAtLocation?: (string & z.BRAND<"UUID">) | null | undefined;
339
337
  updatedBy?: string | null | undefined;
340
- copiesPrintedForTemplate?: number | undefined;
341
- modifiedAt?: string | undefined;
342
338
  }, {
343
339
  type: string;
344
340
  id: string;
@@ -377,8 +373,6 @@ export declare const EventMetadata: z.ZodObject<{
377
373
  dateOfEvent?: string | null | undefined;
378
374
  updatedAtLocation?: string | null | undefined;
379
375
  updatedBy?: string | null | undefined;
380
- copiesPrintedForTemplate?: number | undefined;
381
- modifiedAt?: string | undefined;
382
376
  }>;
383
377
  export type EventMetadata = z.infer<typeof EventMetadata>;
384
378
  export declare const EventMetadataKeysArray: readonly ["id", "type", "status", "createdAt", "dateOfEvent", "createdBy", "createdByUserType", "updatedByUserRole", "createdAtLocation", "updatedAtLocation", "updatedAt", "assignedTo", "updatedBy", "trackingId", "legalStatuses", "flags"];
@@ -37,63 +37,9 @@ declare function eventFn(fieldId: EventFieldId): {
37
37
  declare const event: typeof eventFn & {
38
38
  /**
39
39
  * Checks if the event contains a specific action type.
40
- * Can be used directly as a conditional or chained with additional methods.
41
40
  * @param action - The action type to check for.
42
41
  */
43
- hasAction: (action: ActionType) => {
44
- /**
45
- * Creates a conditional that checks if the event contains a specific action type
46
- * with a minimum count of occurrences.
47
- *
48
- * @param minCount - The minimum number of actions required.
49
- */
50
- minCount: (minCount: number) => import("../conditionals/conditionals").JSONSchema;
51
- /**
52
- * Builds a conditional that sets a maximum count for the number of actions.
53
- * This is useful for limiting the number of actions of a specific type in a single event.
54
- */
55
- maxCount: (maxCount: number) => import("../conditionals/conditionals").JSONSchema;
56
- /**
57
- * Adds additional field constraints to the action matching.
58
- *
59
- * @param fields - Object containing additional fields to match on the action.
60
- */
61
- withFields: (fields: Record<string, unknown>) => {
62
- /**
63
- * Creates a conditional that checks if the event contains a specific action type
64
- * with a minimum count of occurrences.
65
- *
66
- * @param minCount - The minimum number of actions required.
67
- */
68
- minCount: (minCount: number) => import("../conditionals/conditionals").JSONSchema;
69
- /**
70
- * Builds a conditional that sets a maximum count for the number of actions.
71
- * This is useful for limiting the number of actions of a specific type in a single event.
72
- */
73
- maxCount: (maxCount: number) => import("../conditionals/conditionals").JSONSchema;
74
- };
75
- /**
76
- * Adds template ID constraint to the action matching.
77
- * This is a convenience method that adds actionDetails.templateId to the fields.
78
- *
79
- * @param id - The template ID to match against.
80
- */
81
- withTemplate: (id: string) => {
82
- /**
83
- * Creates a conditional that checks if the event contains a specific action type
84
- * with a minimum count of occurrences.
85
- *
86
- * @param minCount - The minimum number of actions required.
87
- */
88
- minCount: (minCount: number) => import("../conditionals/conditionals").JSONSchema;
89
- /**
90
- * Builds a conditional that sets a maximum count for the number of actions.
91
- * This is useful for limiting the number of actions of a specific type in a single event.
92
- */
93
- maxCount: (maxCount: number) => import("../conditionals/conditionals").JSONSchema;
94
- };
95
- __nominal__type: "JSONSchema";
96
- };
42
+ hasAction: (action: ActionType) => import("../conditionals/conditionals").JSONSchema;
97
43
  field(field: WorkqueueColumnKeys): WorkqueueColumnValue;
98
44
  };
99
45
  export { event };
@@ -414,7 +414,7 @@ export declare function eventPayloadGenerator(rng: () => number): {
414
414
  requestId: string;
415
415
  keepAssignment: boolean | undefined;
416
416
  };
417
- reject: (eventId: string, requestId: string, input?: Partial<Pick<RejectCorrectionActionInput, "transactionId" | "annotation" | "keepAssignment">>) => {
417
+ reject: (eventId: string, requestId: string, input: Partial<Pick<RejectCorrectionActionInput, "transactionId" | "annotation" | "keepAssignment" | "reason">>) => {
418
418
  type: "REJECT_CORRECTION";
419
419
  transactionId: string;
420
420
  declaration: {};
@@ -422,6 +422,10 @@ export declare function eventPayloadGenerator(rng: () => number): {
422
422
  eventId: string;
423
423
  requestId: string;
424
424
  keepAssignment: boolean | undefined;
425
+ reason: {
426
+ message: string;
427
+ isDuplicate?: boolean | undefined;
428
+ };
425
429
  };
426
430
  };
427
431
  };
@@ -6758,10 +6758,6 @@ export declare function findActiveDrafts(event: EventDocument, drafts: Draft[]):
6758
6758
  start: string;
6759
6759
  end: string;
6760
6760
  } | null | undefined> | null | undefined;
6761
- actionDetails?: {
6762
- templateId?: string | undefined;
6763
- isImmediateCorrection?: boolean | undefined;
6764
- } | null | undefined;
6765
6761
  originalActionId?: (string & import("zod").BRAND<"UUID">) | null | undefined;
6766
6762
  };
6767
6763
  }[];
@@ -39,7 +39,6 @@ __export(events_exports, {
39
39
  ActionConfig: () => ActionConfig,
40
40
  ActionConfigBase: () => ActionConfigBase,
41
41
  ActionCreationMetadata: () => ActionCreationMetadata,
42
- ActionDetails: () => ActionDetails,
43
42
  ActionDocument: () => ActionDocument,
44
43
  ActionFormConfig: () => ActionFormConfig,
45
44
  ActionInput: () => ActionInput,
@@ -198,7 +197,6 @@ __export(events_exports, {
198
197
  annotationActions: () => annotationActions,
199
198
  applyDeclarationToEventIndex: () => applyDeclarationToEventIndex,
200
199
  applyDraftsToEventIndex: () => applyDraftsToEventIndex,
201
- areCertificateConditionsMet: () => areCertificateConditionsMet,
202
200
  areConditionsMet: () => areConditionsMet,
203
201
  compositeFieldTypes: () => compositeFieldTypes,
204
202
  createEmptyDraft: () => createEmptyDraft,
@@ -608,8 +606,8 @@ var UrbanAddressUpdateValue = AdminStructure.extend({
608
606
  zipCode: import_zod5.z.string().nullish()
609
607
  });
610
608
  var NameFieldValue = import_zod5.z.object({
611
- firstname: import_zod5.z.string(),
612
- surname: import_zod5.z.string(),
609
+ firstname: import_zod5.z.string().min(1),
610
+ surname: import_zod5.z.string().min(1),
613
611
  middlename: import_zod5.z.string().optional()
614
612
  });
615
613
  var NameFieldUpdateValue = import_zod5.z.object({
@@ -1224,8 +1222,7 @@ var CertificateConfig = import_zod11.z.object({
1224
1222
  delayed: import_zod11.z.number()
1225
1223
  }),
1226
1224
  svgUrl: import_zod11.z.string(),
1227
- fonts: import_zod11.z.record(FontFamily).optional(),
1228
- conditionals: import_zod11.z.array(ShowConditional).optional()
1225
+ fonts: import_zod11.z.record(FontFamily).optional()
1229
1226
  });
1230
1227
  var CertificateTemplateConfig = CertificateConfig.extend({
1231
1228
  hash: import_zod11.z.string().optional(),
@@ -1885,10 +1882,6 @@ var ActionStatus = {
1885
1882
  Accepted: "Accepted",
1886
1883
  Rejected: "Rejected"
1887
1884
  };
1888
- var ActionDetails = import_zod19.z.object({
1889
- templateId: import_zod19.z.string().optional(),
1890
- isImmediateCorrection: import_zod19.z.boolean().optional()
1891
- });
1892
1885
  var ActionBase = import_zod19.z.object({
1893
1886
  id: UUID,
1894
1887
  transactionId: import_zod19.z.string(),
@@ -1900,7 +1893,6 @@ var ActionBase = import_zod19.z.object({
1900
1893
  createdAtLocation: CreatedAtLocation,
1901
1894
  declaration: ActionUpdate,
1902
1895
  annotation: ActionUpdate.optional().nullable(),
1903
- actionDetails: ActionDetails.optional().nullable(),
1904
1896
  status: import_zod19.z.enum([
1905
1897
  ActionStatus.Requested,
1906
1898
  ActionStatus.Accepted,
@@ -1988,7 +1980,8 @@ var ApprovedCorrectionAction = ActionBase.merge(
1988
1980
  var RejectedCorrectionAction = ActionBase.merge(
1989
1981
  import_zod19.z.object({
1990
1982
  type: import_zod19.z.literal(ActionType.REJECT_CORRECTION),
1991
- requestId: import_zod19.z.string()
1983
+ requestId: import_zod19.z.string(),
1984
+ reason: RejectionReason
1992
1985
  })
1993
1986
  );
1994
1987
  var ReadAction = ActionBase.merge(
@@ -2038,7 +2031,7 @@ var ResolvedUser = import_zod19.z.object({
2038
2031
  });
2039
2032
 
2040
2033
  // ../commons/src/conditionals/validate.ts
2041
- var import__ = __toESM(require("ajv/dist/2019"));
2034
+ var import_ajv = __toESM(require("ajv"));
2042
2035
  var import_ajv_formats = __toESM(require("ajv-formats"));
2043
2036
  var import_date_fns = require("date-fns");
2044
2037
 
@@ -2252,11 +2245,9 @@ var isNonInteractiveFieldType = (field2) => {
2252
2245
  };
2253
2246
 
2254
2247
  // ../commons/src/conditionals/validate.ts
2255
- var ajv = new import__.default({
2248
+ var ajv = new import_ajv.default({
2256
2249
  $data: true,
2257
- allowUnionTypes: true,
2258
- strict: false
2259
- // Allow minContains and other newer features
2250
+ allowUnionTypes: true
2260
2251
  });
2261
2252
  (0, import_ajv_formats.default)(ajv);
2262
2253
  ajv.addKeyword({
@@ -2494,11 +2485,6 @@ function getValidatorsForField(fieldId, validations) {
2494
2485
  };
2495
2486
  }).filter((x) => x !== null);
2496
2487
  }
2497
- function areCertificateConditionsMet(conditions, values) {
2498
- return conditions.every((condition) => {
2499
- return ajv.validate(condition.conditional, values);
2500
- });
2501
- }
2502
2488
 
2503
2489
  // ../commons/src/utils.ts
2504
2490
  function getOrThrow(x, message) {
@@ -3209,107 +3195,32 @@ function eventFn(fieldId) {
3209
3195
  var event = Object.assign(eventFn, {
3210
3196
  /**
3211
3197
  * Checks if the event contains a specific action type.
3212
- * Can be used directly as a conditional or chained with additional methods.
3213
3198
  * @param action - The action type to check for.
3214
3199
  */
3215
- hasAction: (action) => {
3216
- const basicConditional = defineConditional({
3217
- type: "object",
3218
- properties: {
3219
- $event: {
3220
- type: "object",
3221
- properties: {
3222
- actions: {
3223
- type: "array",
3224
- contains: {
3225
- type: "object",
3226
- properties: {
3227
- type: {
3228
- const: action
3229
- }
3230
- },
3231
- required: ["type"]
3232
- }
3233
- }
3234
- },
3235
- required: ["actions"]
3236
- }
3237
- },
3238
- required: ["$event"]
3239
- });
3240
- const buildActionConstraints = (additionalFields) => {
3241
- const actionProperties = {
3242
- type: { const: action }
3243
- };
3244
- const requiredFields = ["type"];
3245
- if (additionalFields) {
3246
- Object.entries(additionalFields).forEach(([key, value]) => {
3247
- actionProperties[key] = { const: value };
3248
- requiredFields.push(key);
3249
- });
3250
- }
3251
- return { actionProperties, requiredFields };
3252
- };
3253
- const createCountConditional = (countType, count, additionalFields) => {
3254
- const { actionProperties, requiredFields } = buildActionConstraints(additionalFields);
3255
- return defineConditional({
3200
+ hasAction: (action) => defineConditional({
3201
+ type: "object",
3202
+ properties: {
3203
+ $event: {
3256
3204
  type: "object",
3257
3205
  properties: {
3258
- $event: {
3259
- type: "object",
3260
- properties: {
3261
- actions: {
3262
- type: "array",
3263
- contains: {
3264
- type: "object",
3265
- properties: actionProperties,
3266
- required: requiredFields
3267
- },
3268
- [countType]: count
3269
- }
3270
- },
3271
- required: ["actions"]
3206
+ actions: {
3207
+ type: "array",
3208
+ contains: {
3209
+ type: "object",
3210
+ properties: {
3211
+ type: {
3212
+ const: action
3213
+ }
3214
+ },
3215
+ required: ["type"]
3216
+ }
3272
3217
  }
3273
3218
  },
3274
- required: ["$event"]
3275
- });
3276
- };
3277
- const withMinMax = (additionalFields) => {
3278
- return {
3279
- /**
3280
- * Creates a conditional that checks if the event contains a specific action type
3281
- * with a minimum count of occurrences.
3282
- *
3283
- * @param minCount - The minimum number of actions required.
3284
- */
3285
- minCount: (minCount) => createCountConditional("minContains", minCount, additionalFields),
3286
- /**
3287
- * Builds a conditional that sets a maximum count for the number of actions.
3288
- * This is useful for limiting the number of actions of a specific type in a single event.
3289
- */
3290
- maxCount: (maxCount) => createCountConditional("maxContains", maxCount, additionalFields)
3291
- };
3292
- };
3293
- const chainableMethods = {
3294
- /**
3295
- * Adds additional field constraints to the action matching.
3296
- *
3297
- * @param fields - Object containing additional fields to match on the action.
3298
- */
3299
- withFields: (fields) => withMinMax(fields),
3300
- /**
3301
- * Adds template ID constraint to the action matching.
3302
- * This is a convenience method that adds actionDetails.templateId to the fields.
3303
- *
3304
- * @param id - The template ID to match against.
3305
- */
3306
- withTemplate: (id) => withMinMax({
3307
- actionDetails: { templateId: id }
3308
- }),
3309
- ...withMinMax()
3310
- };
3311
- return { ...basicConditional, ...chainableMethods };
3312
- },
3219
+ required: ["actions"]
3220
+ }
3221
+ },
3222
+ required: ["$event"]
3223
+ }),
3313
3224
  field(field2) {
3314
3225
  return {
3315
3226
  $event: field2
@@ -3394,9 +3305,7 @@ var EventMetadata = import_zod23.z.object({
3394
3305
  trackingId: import_zod23.z.string().describe(
3395
3306
  "System-generated tracking ID used by informants or registrars to look up the event."
3396
3307
  ),
3397
- flags: import_zod23.z.array(Flag),
3398
- copiesPrintedForTemplate: import_zod23.z.number().optional(),
3399
- modifiedAt: import_zod23.z.string().optional()
3308
+ flags: import_zod23.z.array(Flag)
3400
3309
  });
3401
3310
  var EventMetadataKeysArray = [
3402
3311
  "id",
@@ -3926,7 +3835,6 @@ var BaseActionInput = import_zod29.z.object({
3926
3835
  transactionId: import_zod29.z.string(),
3927
3836
  declaration: ActionUpdate.default({}),
3928
3837
  annotation: ActionUpdate.optional(),
3929
- actionDetails: ActionDetails.optional(),
3930
3838
  originalActionId: UUID.optional(),
3931
3839
  // should not be part of base action.
3932
3840
  keepAssignment: import_zod29.z.boolean().optional()
@@ -4009,7 +3917,8 @@ var RequestCorrectionActionInput = BaseActionInput.merge(
4009
3917
  var RejectCorrectionActionInput = BaseActionInput.merge(
4010
3918
  import_zod29.z.object({
4011
3919
  requestId: import_zod29.z.string(),
4012
- type: import_zod29.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
3920
+ type: import_zod29.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION),
3921
+ reason: RejectionReason
4013
3922
  })
4014
3923
  );
4015
3924
  var ApproveCorrectionActionInput = BaseActionInput.merge(
@@ -4376,8 +4285,7 @@ function getCurrentEventState(event2, config) {
4376
4285
  trackingId: event2.trackingId,
4377
4286
  updatedByUserRole: requestActionMetadata.createdByRole,
4378
4287
  dateOfEvent: resolveDateOfEvent(event2, declaration, config),
4379
- flags: getFlagsFromActions(event2.actions),
4380
- copiesPrintedForTemplate: event2.copiesPrintedForTemplate ?? 0
4288
+ flags: getFlagsFromActions(event2.actions)
4381
4289
  });
4382
4290
  }
4383
4291
  function getCurrentEventStateWithDrafts({
@@ -6849,7 +6757,7 @@ function eventPayloadGenerator(rng) {
6849
6757
  requestId,
6850
6758
  keepAssignment: input.keepAssignment
6851
6759
  }),
6852
- reject: (eventId, requestId, input = {}) => ({
6760
+ reject: (eventId, requestId, input) => ({
6853
6761
  type: ActionType.REJECT_CORRECTION,
6854
6762
  transactionId: input.transactionId ?? getUUID(),
6855
6763
  declaration: {},
@@ -6860,7 +6768,8 @@ function eventPayloadGenerator(rng) {
6860
6768
  ),
6861
6769
  eventId,
6862
6770
  requestId,
6863
- keepAssignment: input.keepAssignment
6771
+ keepAssignment: input.keepAssignment,
6772
+ reason: input.reason ?? { message: "" }
6864
6773
  })
6865
6774
  }
6866
6775
  }
@@ -6919,7 +6828,8 @@ function generateActionDocument({
6919
6828
  return {
6920
6829
  ...actionBase,
6921
6830
  requestId: getUUID(),
6922
- type: action
6831
+ type: action,
6832
+ reason: { message: "Correction rejection" }
6923
6833
  };
6924
6834
  case ActionType.REGISTER:
6925
6835
  return {
@@ -7054,8 +6964,7 @@ var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
7054
6964
  flags: [],
7055
6965
  legalStatuses: overrides.legalStatuses ?? {},
7056
6966
  declaration: overrides.declaration ?? generateRandomApplicant(rng),
7057
- trackingId: overrides.trackingId ?? generateTrackingId(rng),
7058
- copiesPrintedForTemplate: overrides.copiesPrintedForTemplate ?? 0
6967
+ trackingId: overrides.trackingId ?? generateTrackingId(rng)
7059
6968
  };
7060
6969
  };
7061
6970
  var generateTranslationConfig = (message) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/toolkit",
3
- "version": "1.8.1-rc.bbbfede",
3
+ "version": "1.8.1-rc.facd84c",
4
4
  "description": "OpenCRVS toolkit for building country configurations",
5
5
  "license": "MPL-2.0",
6
6
  "exports": {