@opencrvs/toolkit 1.8.1-rc.2d48701 → 1.8.1-rc.30d472b
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.
@@ -10805,7 +10805,6 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
10805
10805
|
set: import("@trpc/server").TRPCMutationProcedure<{
|
10806
10806
|
input: {
|
10807
10807
|
id: string;
|
10808
|
-
externalId: string | null;
|
10809
10808
|
name: string;
|
10810
10809
|
partOf: string | null;
|
10811
10810
|
}[];
|
@@ -10816,7 +10815,6 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
10816
10815
|
input: void;
|
10817
10816
|
output: {
|
10818
10817
|
id: string & import("zod").BRAND<"UUID">;
|
10819
|
-
externalId: string | null;
|
10820
10818
|
name: string;
|
10821
10819
|
partOf: (string & import("zod").BRAND<"UUID">) | null;
|
10822
10820
|
}[];
|
@@ -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
|
@@ -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
|
@@ -6934,11 +6850,7 @@ function generateActionDocument({
|
|
6934
6850
|
case ActionType.NOTIFY:
|
6935
6851
|
return { ...actionBase, type: action };
|
6936
6852
|
case ActionType.PRINT_CERTIFICATE:
|
6937
|
-
return {
|
6938
|
-
...actionBase,
|
6939
|
-
type: action,
|
6940
|
-
content: defaults.content
|
6941
|
-
};
|
6853
|
+
return { ...actionBase, type: action };
|
6942
6854
|
case ActionType.REQUEST_CORRECTION:
|
6943
6855
|
return { ...actionBase, type: action };
|
6944
6856
|
case ActionType.APPROVE_CORRECTION:
|