@opencrvs/toolkit 1.8.1-rc.bbbfede → 1.8.1-rc.e32d7b8
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.
- package/dist/commons/api/router.d.ts +0 -4
- package/dist/commons/conditionals/validate.d.ts +2 -3
- package/dist/commons/events/EventIndex.d.ts +0 -6
- package/dist/commons/events/EventMetadata.d.ts +0 -6
- package/dist/commons/events/event.d.ts +1 -55
- package/dist/events/index.js +27 -115
- package/package.json +1 -1
@@ -7741,8 +7741,6 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
7741
7741
|
dateOfEvent?: string | null | undefined;
|
7742
7742
|
updatedAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
|
7743
7743
|
updatedBy?: string | null | undefined;
|
7744
|
-
copiesPrintedForTemplate?: number | undefined;
|
7745
|
-
modifiedAt?: string | undefined;
|
7746
7744
|
}[];
|
7747
7745
|
meta: import("trpc-to-openapi").OpenApiMeta;
|
7748
7746
|
}>;
|
@@ -7838,8 +7836,6 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
7838
7836
|
dateOfEvent?: string | null | undefined;
|
7839
7837
|
updatedAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
|
7840
7838
|
updatedBy?: string | null | undefined;
|
7841
|
-
copiesPrintedForTemplate?: number | undefined;
|
7842
|
-
modifiedAt?: string | undefined;
|
7843
7839
|
}[];
|
7844
7840
|
meta: import("trpc-to-openapi").OpenApiMeta;
|
7845
7841
|
}>;
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { ConditionalParameters, JSONSchema } from './conditionals';
|
2
|
-
import {
|
3
|
-
import { FieldConditional } from '../events/Conditional';
|
2
|
+
import { EventState, ActionUpdate } from '../events/ActionDocument';
|
4
3
|
import { FieldConfig } from '../events/FieldConfig';
|
5
4
|
import { FieldUpdateValue } from '../events/FieldValue';
|
6
5
|
import { TranslationConfig } from '../events/TranslationConfig';
|
6
|
+
import { FieldConditional } from '../events/Conditional';
|
7
7
|
export declare function validate(schema: JSONSchema, data: ConditionalParameters): boolean;
|
8
8
|
export declare function isConditionMet(conditional: JSONSchema, values: Record<string, unknown>): boolean;
|
9
9
|
export declare function areConditionsMet(conditions: FieldConditional[], values: Record<string, unknown>): boolean;
|
@@ -77,5 +77,4 @@ export declare function runFieldValidations({ field, values }: {
|
|
77
77
|
}[];
|
78
78
|
};
|
79
79
|
export declare function getValidatorsForField(fieldId: FieldConfig['id'], validations: NonNullable<FieldConfig['validation']>): NonNullable<FieldConfig['validation']>;
|
80
|
-
export declare function areCertificateConditionsMet(conditions: FieldConditional[], values: Record<string, unknown>): boolean;
|
81
80
|
//# sourceMappingURL=validate.d.ts.map
|
@@ -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 };
|
package/dist/events/index.js
CHANGED
@@ -198,7 +198,6 @@ __export(events_exports, {
|
|
198
198
|
annotationActions: () => annotationActions,
|
199
199
|
applyDeclarationToEventIndex: () => applyDeclarationToEventIndex,
|
200
200
|
applyDraftsToEventIndex: () => applyDraftsToEventIndex,
|
201
|
-
areCertificateConditionsMet: () => areCertificateConditionsMet,
|
202
201
|
areConditionsMet: () => areConditionsMet,
|
203
202
|
compositeFieldTypes: () => compositeFieldTypes,
|
204
203
|
createEmptyDraft: () => createEmptyDraft,
|
@@ -1224,8 +1223,7 @@ var CertificateConfig = import_zod11.z.object({
|
|
1224
1223
|
delayed: import_zod11.z.number()
|
1225
1224
|
}),
|
1226
1225
|
svgUrl: import_zod11.z.string(),
|
1227
|
-
fonts: import_zod11.z.record(FontFamily).optional()
|
1228
|
-
conditionals: import_zod11.z.array(ShowConditional).optional()
|
1226
|
+
fonts: import_zod11.z.record(FontFamily).optional()
|
1229
1227
|
});
|
1230
1228
|
var CertificateTemplateConfig = CertificateConfig.extend({
|
1231
1229
|
hash: import_zod11.z.string().optional(),
|
@@ -2038,7 +2036,7 @@ var ResolvedUser = import_zod19.z.object({
|
|
2038
2036
|
});
|
2039
2037
|
|
2040
2038
|
// ../commons/src/conditionals/validate.ts
|
2041
|
-
var
|
2039
|
+
var import_ajv = __toESM(require("ajv"));
|
2042
2040
|
var import_ajv_formats = __toESM(require("ajv-formats"));
|
2043
2041
|
var import_date_fns = require("date-fns");
|
2044
2042
|
|
@@ -2252,11 +2250,9 @@ var isNonInteractiveFieldType = (field2) => {
|
|
2252
2250
|
};
|
2253
2251
|
|
2254
2252
|
// ../commons/src/conditionals/validate.ts
|
2255
|
-
var ajv = new
|
2253
|
+
var ajv = new import_ajv.default({
|
2256
2254
|
$data: true,
|
2257
|
-
allowUnionTypes: true
|
2258
|
-
strict: false
|
2259
|
-
// Allow minContains and other newer features
|
2255
|
+
allowUnionTypes: true
|
2260
2256
|
});
|
2261
2257
|
(0, import_ajv_formats.default)(ajv);
|
2262
2258
|
ajv.addKeyword({
|
@@ -2494,11 +2490,6 @@ function getValidatorsForField(fieldId, validations) {
|
|
2494
2490
|
};
|
2495
2491
|
}).filter((x) => x !== null);
|
2496
2492
|
}
|
2497
|
-
function areCertificateConditionsMet(conditions, values) {
|
2498
|
-
return conditions.every((condition) => {
|
2499
|
-
return ajv.validate(condition.conditional, values);
|
2500
|
-
});
|
2501
|
-
}
|
2502
2493
|
|
2503
2494
|
// ../commons/src/utils.ts
|
2504
2495
|
function getOrThrow(x, message) {
|
@@ -3209,107 +3200,32 @@ function eventFn(fieldId) {
|
|
3209
3200
|
var event = Object.assign(eventFn, {
|
3210
3201
|
/**
|
3211
3202
|
* Checks if the event contains a specific action type.
|
3212
|
-
* Can be used directly as a conditional or chained with additional methods.
|
3213
3203
|
* @param action - The action type to check for.
|
3214
3204
|
*/
|
3215
|
-
hasAction: (action) => {
|
3216
|
-
|
3217
|
-
|
3218
|
-
|
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({
|
3205
|
+
hasAction: (action) => defineConditional({
|
3206
|
+
type: "object",
|
3207
|
+
properties: {
|
3208
|
+
$event: {
|
3256
3209
|
type: "object",
|
3257
3210
|
properties: {
|
3258
|
-
|
3259
|
-
type: "
|
3260
|
-
|
3261
|
-
|
3262
|
-
|
3263
|
-
|
3264
|
-
|
3265
|
-
|
3266
|
-
|
3267
|
-
|
3268
|
-
|
3269
|
-
}
|
3270
|
-
},
|
3271
|
-
required: ["actions"]
|
3211
|
+
actions: {
|
3212
|
+
type: "array",
|
3213
|
+
contains: {
|
3214
|
+
type: "object",
|
3215
|
+
properties: {
|
3216
|
+
type: {
|
3217
|
+
const: action
|
3218
|
+
}
|
3219
|
+
},
|
3220
|
+
required: ["type"]
|
3221
|
+
}
|
3272
3222
|
}
|
3273
3223
|
},
|
3274
|
-
required: ["
|
3275
|
-
}
|
3276
|
-
}
|
3277
|
-
|
3278
|
-
|
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
|
-
},
|
3224
|
+
required: ["actions"]
|
3225
|
+
}
|
3226
|
+
},
|
3227
|
+
required: ["$event"]
|
3228
|
+
}),
|
3313
3229
|
field(field2) {
|
3314
3230
|
return {
|
3315
3231
|
$event: field2
|
@@ -3394,9 +3310,7 @@ var EventMetadata = import_zod23.z.object({
|
|
3394
3310
|
trackingId: import_zod23.z.string().describe(
|
3395
3311
|
"System-generated tracking ID used by informants or registrars to look up the event."
|
3396
3312
|
),
|
3397
|
-
flags: import_zod23.z.array(Flag)
|
3398
|
-
copiesPrintedForTemplate: import_zod23.z.number().optional(),
|
3399
|
-
modifiedAt: import_zod23.z.string().optional()
|
3313
|
+
flags: import_zod23.z.array(Flag)
|
3400
3314
|
});
|
3401
3315
|
var EventMetadataKeysArray = [
|
3402
3316
|
"id",
|
@@ -4376,8 +4290,7 @@ function getCurrentEventState(event2, config) {
|
|
4376
4290
|
trackingId: event2.trackingId,
|
4377
4291
|
updatedByUserRole: requestActionMetadata.createdByRole,
|
4378
4292
|
dateOfEvent: resolveDateOfEvent(event2, declaration, config),
|
4379
|
-
flags: getFlagsFromActions(event2.actions)
|
4380
|
-
copiesPrintedForTemplate: event2.copiesPrintedForTemplate ?? 0
|
4293
|
+
flags: getFlagsFromActions(event2.actions)
|
4381
4294
|
});
|
4382
4295
|
}
|
4383
4296
|
function getCurrentEventStateWithDrafts({
|
@@ -7054,8 +6967,7 @@ var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
|
|
7054
6967
|
flags: [],
|
7055
6968
|
legalStatuses: overrides.legalStatuses ?? {},
|
7056
6969
|
declaration: overrides.declaration ?? generateRandomApplicant(rng),
|
7057
|
-
trackingId: overrides.trackingId ?? generateTrackingId(rng)
|
7058
|
-
copiesPrintedForTemplate: overrides.copiesPrintedForTemplate ?? 0
|
6970
|
+
trackingId: overrides.trackingId ?? generateTrackingId(rng)
|
7059
6971
|
};
|
7060
6972
|
};
|
7061
6973
|
var generateTranslationConfig = (message) => ({
|