@opencrvs/toolkit 1.8.1-rc.b6b235d → 1.8.1-rc.b98fee0
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 -2
- package/dist/commons/conditionals/validate.d.ts +2 -3
- package/dist/commons/events/EventIndex.d.ts +0 -3
- package/dist/commons/events/EventMetadata.d.ts +0 -3
- package/dist/commons/events/event.d.ts +1 -55
- package/dist/events/index.js +25 -110
- package/package.json +1 -1
- package/tsconfig.json +1 -1
- package/dist/commons/conditionals/conditionals.test.d.ts +0 -2
- package/dist/commons/conditionals/validate-address.test.d.ts +0 -2
- package/dist/commons/conditionals/validate.test.d.ts +0 -2
- package/dist/commons/events/utils.test.d.ts +0 -2
@@ -7493,7 +7493,6 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
7493
7493
|
dateOfEvent?: string | null | undefined;
|
7494
7494
|
updatedAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
|
7495
7495
|
updatedBy?: string | null | undefined;
|
7496
|
-
modifiedAt?: string | undefined;
|
7497
7496
|
}[];
|
7498
7497
|
meta: import("trpc-to-openapi").OpenApiMeta;
|
7499
7498
|
}>;
|
@@ -7589,7 +7588,6 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
7589
7588
|
dateOfEvent?: string | null | undefined;
|
7590
7589
|
updatedAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
|
7591
7590
|
updatedBy?: string | null | undefined;
|
7592
|
-
modifiedAt?: string | undefined;
|
7593
7591
|
}[];
|
7594
7592
|
meta: import("trpc-to-openapi").OpenApiMeta;
|
7595
7593
|
}>;
|
@@ -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,7 +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
|
-
modifiedAt: z.ZodOptional<z.ZodString>;
|
121
120
|
}, {
|
122
121
|
declaration: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodString, z.ZodString, z.ZodUnion<[z.ZodObject<{
|
123
122
|
start: z.ZodString;
|
@@ -353,7 +352,6 @@ export declare const EventIndex: z.ZodObject<z.objectUtil.extendShape<{
|
|
353
352
|
dateOfEvent?: string | null | undefined;
|
354
353
|
updatedAtLocation?: (string & z.BRAND<"UUID">) | null | undefined;
|
355
354
|
updatedBy?: string | null | undefined;
|
356
|
-
modifiedAt?: string | undefined;
|
357
355
|
}, {
|
358
356
|
type: string;
|
359
357
|
id: string;
|
@@ -441,7 +439,6 @@ export declare const EventIndex: z.ZodObject<z.objectUtil.extendShape<{
|
|
441
439
|
dateOfEvent?: string | null | undefined;
|
442
440
|
updatedAtLocation?: string | null | undefined;
|
443
441
|
updatedBy?: string | null | undefined;
|
444
|
-
modifiedAt?: string | undefined;
|
445
442
|
}>;
|
446
443
|
export declare const EventSearchIndex: z.ZodIntersection<z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodObject<{
|
447
444
|
type: z.ZodString;
|
@@ -297,7 +297,6 @@ export declare const EventMetadata: z.ZodObject<{
|
|
297
297
|
readonly REJECTED: "rejected";
|
298
298
|
readonly CORRECTION_REQUESTED: "correction-requested";
|
299
299
|
}>]>, "many">;
|
300
|
-
modifiedAt: z.ZodOptional<z.ZodString>;
|
301
300
|
}, "strip", z.ZodTypeAny, {
|
302
301
|
type: string;
|
303
302
|
id: string & z.BRAND<"UUID">;
|
@@ -336,7 +335,6 @@ export declare const EventMetadata: z.ZodObject<{
|
|
336
335
|
dateOfEvent?: string | null | undefined;
|
337
336
|
updatedAtLocation?: (string & z.BRAND<"UUID">) | null | undefined;
|
338
337
|
updatedBy?: string | null | undefined;
|
339
|
-
modifiedAt?: string | undefined;
|
340
338
|
}, {
|
341
339
|
type: string;
|
342
340
|
id: string;
|
@@ -375,7 +373,6 @@ export declare const EventMetadata: z.ZodObject<{
|
|
375
373
|
dateOfEvent?: string | null | undefined;
|
376
374
|
updatedAtLocation?: string | null | undefined;
|
377
375
|
updatedBy?: string | null | undefined;
|
378
|
-
modifiedAt?: string | undefined;
|
379
376
|
}>;
|
380
377
|
export type EventMetadata = z.infer<typeof EventMetadata>;
|
381
378
|
export declare const EventMetadataKeysArray: readonly ["id", "type", "status", "createdAt", "dateOfEvent", "createdBy", "createdByUserType", "updatedByUserRole", "createdAtLocation", "updatedAtLocation", "updatedAt", "assignedTo", "updatedBy", "trackingId", "legalStatuses", "flags"];
|
@@ -45,63 +45,9 @@ declare function eventFn(fieldId: EventFieldId): {
|
|
45
45
|
declare const event: typeof eventFn & {
|
46
46
|
/**
|
47
47
|
* Checks if the event contains a specific action type.
|
48
|
-
* Can be used directly as a conditional or chained with additional methods.
|
49
48
|
* @param action - The action type to check for.
|
50
49
|
*/
|
51
|
-
hasAction: (action: ActionType) =>
|
52
|
-
/**
|
53
|
-
* Creates a conditional that checks if the event contains a specific action type
|
54
|
-
* with a minimum count of occurrences.
|
55
|
-
*
|
56
|
-
* @param minCount - The minimum number of actions required.
|
57
|
-
*/
|
58
|
-
minCount: (minCount: number) => import("../conditionals/conditionals").JSONSchema;
|
59
|
-
/**
|
60
|
-
* Builds a conditional that sets a maximum count for the number of actions.
|
61
|
-
* This is useful for limiting the number of actions of a specific type in a single event.
|
62
|
-
*/
|
63
|
-
maxCount: (maxCount: number) => import("../conditionals/conditionals").JSONSchema;
|
64
|
-
/**
|
65
|
-
* Adds additional field constraints to the action matching.
|
66
|
-
*
|
67
|
-
* @param fields - Object containing additional fields to match on the action.
|
68
|
-
*/
|
69
|
-
withFields: (fields: Record<string, unknown>) => {
|
70
|
-
/**
|
71
|
-
* Creates a conditional that checks if the event contains a specific action type
|
72
|
-
* with a minimum count of occurrences.
|
73
|
-
*
|
74
|
-
* @param minCount - The minimum number of actions required.
|
75
|
-
*/
|
76
|
-
minCount: (minCount: number) => import("../conditionals/conditionals").JSONSchema;
|
77
|
-
/**
|
78
|
-
* Builds a conditional that sets a maximum count for the number of actions.
|
79
|
-
* This is useful for limiting the number of actions of a specific type in a single event.
|
80
|
-
*/
|
81
|
-
maxCount: (maxCount: number) => import("../conditionals/conditionals").JSONSchema;
|
82
|
-
};
|
83
|
-
/**
|
84
|
-
* Adds template ID constraint to the action matching.
|
85
|
-
* This is a convenience method that adds content.templateId to the fields.
|
86
|
-
*
|
87
|
-
* @param id - The template ID to match against.
|
88
|
-
*/
|
89
|
-
withTemplate: (id: string) => {
|
90
|
-
/**
|
91
|
-
* Creates a conditional that checks if the event contains a specific action type
|
92
|
-
* with a minimum count of occurrences.
|
93
|
-
*
|
94
|
-
* @param minCount - The minimum number of actions required.
|
95
|
-
*/
|
96
|
-
minCount: (minCount: number) => import("../conditionals/conditionals").JSONSchema;
|
97
|
-
/**
|
98
|
-
* Builds a conditional that sets a maximum count for the number of actions.
|
99
|
-
* This is useful for limiting the number of actions of a specific type in a single event.
|
100
|
-
*/
|
101
|
-
maxCount: (maxCount: number) => import("../conditionals/conditionals").JSONSchema;
|
102
|
-
};
|
103
|
-
__nominal__type: "JSONSchema";
|
104
|
-
};
|
50
|
+
hasAction: (action: ActionType) => import("../conditionals/conditionals").JSONSchema;
|
105
51
|
field(field: WorkqueueColumnKeys): WorkqueueColumnValue;
|
106
52
|
};
|
107
53
|
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(),
|
@@ -2047,7 +2045,7 @@ var ResolvedUser = import_zod19.z.object({
|
|
2047
2045
|
});
|
2048
2046
|
|
2049
2047
|
// ../commons/src/conditionals/validate.ts
|
2050
|
-
var
|
2048
|
+
var import_ajv = __toESM(require("ajv"));
|
2051
2049
|
var import_ajv_formats = __toESM(require("ajv-formats"));
|
2052
2050
|
var import_date_fns = require("date-fns");
|
2053
2051
|
|
@@ -2261,11 +2259,9 @@ var isNonInteractiveFieldType = (field2) => {
|
|
2261
2259
|
};
|
2262
2260
|
|
2263
2261
|
// ../commons/src/conditionals/validate.ts
|
2264
|
-
var ajv = new
|
2262
|
+
var ajv = new import_ajv.default({
|
2265
2263
|
$data: true,
|
2266
|
-
allowUnionTypes: true
|
2267
|
-
strict: false
|
2268
|
-
// Allow minContains and other newer features
|
2264
|
+
allowUnionTypes: true
|
2269
2265
|
});
|
2270
2266
|
(0, import_ajv_formats.default)(ajv);
|
2271
2267
|
ajv.addKeyword({
|
@@ -2503,11 +2499,6 @@ function getValidatorsForField(fieldId, validations) {
|
|
2503
2499
|
};
|
2504
2500
|
}).filter((x) => x !== null);
|
2505
2501
|
}
|
2506
|
-
function areCertificateConditionsMet(conditions, values) {
|
2507
|
-
return conditions.every((condition) => {
|
2508
|
-
return ajv.validate(condition.conditional, values);
|
2509
|
-
});
|
2510
|
-
}
|
2511
2502
|
|
2512
2503
|
// ../commons/src/utils.ts
|
2513
2504
|
function getOrThrow(x, message) {
|
@@ -3231,107 +3222,32 @@ function eventFn(fieldId) {
|
|
3231
3222
|
var event = Object.assign(eventFn, {
|
3232
3223
|
/**
|
3233
3224
|
* Checks if the event contains a specific action type.
|
3234
|
-
* Can be used directly as a conditional or chained with additional methods.
|
3235
3225
|
* @param action - The action type to check for.
|
3236
3226
|
*/
|
3237
|
-
hasAction: (action) => {
|
3238
|
-
|
3239
|
-
|
3240
|
-
|
3241
|
-
$event: {
|
3242
|
-
type: "object",
|
3243
|
-
properties: {
|
3244
|
-
actions: {
|
3245
|
-
type: "array",
|
3246
|
-
contains: {
|
3247
|
-
type: "object",
|
3248
|
-
properties: {
|
3249
|
-
type: {
|
3250
|
-
const: action
|
3251
|
-
}
|
3252
|
-
},
|
3253
|
-
required: ["type"]
|
3254
|
-
}
|
3255
|
-
}
|
3256
|
-
},
|
3257
|
-
required: ["actions"]
|
3258
|
-
}
|
3259
|
-
},
|
3260
|
-
required: ["$event"]
|
3261
|
-
});
|
3262
|
-
const buildActionConstraints = (additionalFields) => {
|
3263
|
-
const actionProperties = {
|
3264
|
-
type: { const: action }
|
3265
|
-
};
|
3266
|
-
const requiredFields = ["type"];
|
3267
|
-
if (additionalFields) {
|
3268
|
-
Object.entries(additionalFields).forEach(([key, value]) => {
|
3269
|
-
actionProperties[key] = { const: value };
|
3270
|
-
requiredFields.push(key);
|
3271
|
-
});
|
3272
|
-
}
|
3273
|
-
return { actionProperties, requiredFields };
|
3274
|
-
};
|
3275
|
-
const createCountConditional = (countType, count, additionalFields) => {
|
3276
|
-
const { actionProperties, requiredFields } = buildActionConstraints(additionalFields);
|
3277
|
-
return defineConditional({
|
3227
|
+
hasAction: (action) => defineConditional({
|
3228
|
+
type: "object",
|
3229
|
+
properties: {
|
3230
|
+
$event: {
|
3278
3231
|
type: "object",
|
3279
3232
|
properties: {
|
3280
|
-
|
3281
|
-
type: "
|
3282
|
-
|
3283
|
-
|
3284
|
-
|
3285
|
-
|
3286
|
-
|
3287
|
-
|
3288
|
-
|
3289
|
-
|
3290
|
-
|
3291
|
-
}
|
3292
|
-
},
|
3293
|
-
required: ["actions"]
|
3233
|
+
actions: {
|
3234
|
+
type: "array",
|
3235
|
+
contains: {
|
3236
|
+
type: "object",
|
3237
|
+
properties: {
|
3238
|
+
type: {
|
3239
|
+
const: action
|
3240
|
+
}
|
3241
|
+
},
|
3242
|
+
required: ["type"]
|
3243
|
+
}
|
3294
3244
|
}
|
3295
3245
|
},
|
3296
|
-
required: ["
|
3297
|
-
}
|
3298
|
-
}
|
3299
|
-
|
3300
|
-
|
3301
|
-
/**
|
3302
|
-
* Creates a conditional that checks if the event contains a specific action type
|
3303
|
-
* with a minimum count of occurrences.
|
3304
|
-
*
|
3305
|
-
* @param minCount - The minimum number of actions required.
|
3306
|
-
*/
|
3307
|
-
minCount: (minCount) => createCountConditional("minContains", minCount, additionalFields),
|
3308
|
-
/**
|
3309
|
-
* Builds a conditional that sets a maximum count for the number of actions.
|
3310
|
-
* This is useful for limiting the number of actions of a specific type in a single event.
|
3311
|
-
*/
|
3312
|
-
maxCount: (maxCount) => createCountConditional("maxContains", maxCount, additionalFields)
|
3313
|
-
};
|
3314
|
-
};
|
3315
|
-
const chainableMethods = {
|
3316
|
-
/**
|
3317
|
-
* Adds additional field constraints to the action matching.
|
3318
|
-
*
|
3319
|
-
* @param fields - Object containing additional fields to match on the action.
|
3320
|
-
*/
|
3321
|
-
withFields: (fields) => withMinMax(fields),
|
3322
|
-
/**
|
3323
|
-
* Adds template ID constraint to the action matching.
|
3324
|
-
* This is a convenience method that adds content.templateId to the fields.
|
3325
|
-
*
|
3326
|
-
* @param id - The template ID to match against.
|
3327
|
-
*/
|
3328
|
-
withTemplate: (id) => withMinMax({
|
3329
|
-
content: { templateId: id }
|
3330
|
-
}),
|
3331
|
-
...withMinMax()
|
3332
|
-
};
|
3333
|
-
return { ...basicConditional, ...chainableMethods };
|
3334
|
-
},
|
3246
|
+
required: ["actions"]
|
3247
|
+
}
|
3248
|
+
},
|
3249
|
+
required: ["$event"]
|
3250
|
+
}),
|
3335
3251
|
field(field2) {
|
3336
3252
|
return {
|
3337
3253
|
$event: field2
|
@@ -3416,8 +3332,7 @@ var EventMetadata = import_zod23.z.object({
|
|
3416
3332
|
trackingId: import_zod23.z.string().describe(
|
3417
3333
|
"System-generated tracking ID used by informants or registrars to look up the event."
|
3418
3334
|
),
|
3419
|
-
flags: import_zod23.z.array(Flag)
|
3420
|
-
modifiedAt: import_zod23.z.string().optional()
|
3335
|
+
flags: import_zod23.z.array(Flag)
|
3421
3336
|
});
|
3422
3337
|
var EventMetadataKeysArray = [
|
3423
3338
|
"id",
|
package/package.json
CHANGED
package/tsconfig.json
CHANGED
@@ -19,7 +19,7 @@
|
|
19
19
|
"@opencrvs/commons/events": ["../commons/src/events/index.ts"]
|
20
20
|
}
|
21
21
|
},
|
22
|
-
"references": [{ "path": "../commons" }],
|
22
|
+
"references": [{ "path": "../commons/tsconfig-commonjs.json" }],
|
23
23
|
"include": ["src/**/*.ts"],
|
24
24
|
"exclude": ["**/node_modules/**", "dist"]
|
25
25
|
}
|