@opencrvs/toolkit 1.8.1-rc.bbbfede → 1.8.1-rc.c2e6905
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 +24 -408
- package/dist/commons/conditionals/validate.d.ts +2 -3
- package/dist/commons/events/ActionDocument.d.ts +36 -659
- package/dist/commons/events/ActionInput.d.ts +36 -540
- package/dist/commons/events/AdvancedSearchConfig.d.ts +34 -34
- package/dist/commons/events/Draft.d.ts +0 -44
- package/dist/commons/events/EventConfig.d.ts +22 -22
- package/dist/commons/events/EventDocument.d.ts +26 -416
- package/dist/commons/events/EventIndex.d.ts +122 -6
- package/dist/commons/events/EventMetadata.d.ts +0 -6
- package/dist/commons/events/WorkqueueConfig.d.ts +89 -0
- package/dist/commons/events/defineConfig.d.ts +2 -2
- package/dist/commons/events/event.d.ts +9 -55
- package/dist/commons/events/field.d.ts +14 -0
- package/dist/commons/events/test.utils.d.ts +5 -1
- package/dist/commons/events/utils.d.ts +2 -6
- package/dist/events/index.js +53 -128
- package/package.json +1 -1
package/dist/events/index.js
CHANGED
@@ -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,
|
@@ -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(),
|
@@ -1343,7 +1340,7 @@ var SummaryConfig = import_zod14.z.object({
|
|
1343
1340
|
|
1344
1341
|
// ../commons/src/events/AdvancedSearchConfig.ts
|
1345
1342
|
var import_zod15 = require("zod");
|
1346
|
-
var MatchType = import_zod15.z.enum(["fuzzy", "exact", "range"]);
|
1343
|
+
var MatchType = import_zod15.z.enum(["fuzzy", "exact", "range", "within"]);
|
1347
1344
|
var BaseField3 = import_zod15.z.object({
|
1348
1345
|
config: import_zod15.z.object({
|
1349
1346
|
type: MatchType.describe("Determines the type of field")
|
@@ -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
|
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
|
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) {
|
@@ -3189,6 +3175,19 @@ function createSearchConfig(baseField) {
|
|
3189
3175
|
fuzzy: () => ({
|
3190
3176
|
...baseField,
|
3191
3177
|
config: { type: "fuzzy" }
|
3178
|
+
}),
|
3179
|
+
/**
|
3180
|
+
* Creates a configuration for matching locations and the child locations
|
3181
|
+
* @returns An object containing the field ID and a configuration object with a type of 'within'.
|
3182
|
+
* @example field('createdAtLocation').within()
|
3183
|
+
* // {
|
3184
|
+
* // ...
|
3185
|
+
* // config: { type: 'within' }
|
3186
|
+
* // }
|
3187
|
+
*/
|
3188
|
+
within: () => ({
|
3189
|
+
...baseField,
|
3190
|
+
config: { type: "within" }
|
3192
3191
|
})
|
3193
3192
|
};
|
3194
3193
|
}
|
@@ -3209,107 +3208,32 @@ function eventFn(fieldId) {
|
|
3209
3208
|
var event = Object.assign(eventFn, {
|
3210
3209
|
/**
|
3211
3210
|
* Checks if the event contains a specific action type.
|
3212
|
-
* Can be used directly as a conditional or chained with additional methods.
|
3213
3211
|
* @param action - The action type to check for.
|
3214
3212
|
*/
|
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({
|
3213
|
+
hasAction: (action) => defineConditional({
|
3214
|
+
type: "object",
|
3215
|
+
properties: {
|
3216
|
+
$event: {
|
3256
3217
|
type: "object",
|
3257
3218
|
properties: {
|
3258
|
-
|
3259
|
-
type: "
|
3260
|
-
|
3261
|
-
|
3262
|
-
|
3263
|
-
|
3264
|
-
|
3265
|
-
|
3266
|
-
|
3267
|
-
|
3268
|
-
|
3269
|
-
}
|
3270
|
-
},
|
3271
|
-
required: ["actions"]
|
3219
|
+
actions: {
|
3220
|
+
type: "array",
|
3221
|
+
contains: {
|
3222
|
+
type: "object",
|
3223
|
+
properties: {
|
3224
|
+
type: {
|
3225
|
+
const: action
|
3226
|
+
}
|
3227
|
+
},
|
3228
|
+
required: ["type"]
|
3229
|
+
}
|
3272
3230
|
}
|
3273
3231
|
},
|
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
|
-
},
|
3232
|
+
required: ["actions"]
|
3233
|
+
}
|
3234
|
+
},
|
3235
|
+
required: ["$event"]
|
3236
|
+
}),
|
3313
3237
|
field(field2) {
|
3314
3238
|
return {
|
3315
3239
|
$event: field2
|
@@ -3394,9 +3318,7 @@ var EventMetadata = import_zod23.z.object({
|
|
3394
3318
|
trackingId: import_zod23.z.string().describe(
|
3395
3319
|
"System-generated tracking ID used by informants or registrars to look up the event."
|
3396
3320
|
),
|
3397
|
-
flags: import_zod23.z.array(Flag)
|
3398
|
-
copiesPrintedForTemplate: import_zod23.z.number().optional(),
|
3399
|
-
modifiedAt: import_zod23.z.string().optional()
|
3321
|
+
flags: import_zod23.z.array(Flag)
|
3400
3322
|
});
|
3401
3323
|
var EventMetadataKeysArray = [
|
3402
3324
|
"id",
|
@@ -3615,6 +3537,9 @@ var QueryExpression = import_zod25.z.object({
|
|
3615
3537
|
createdAt: import_zod25.z.optional(DateCondition),
|
3616
3538
|
updatedAt: import_zod25.z.optional(DateCondition),
|
3617
3539
|
"legalStatuses.REGISTERED.acceptedAt": import_zod25.z.optional(DateCondition),
|
3540
|
+
"legalStatuses.DECLARED.createdAtLocation": import_zod25.z.optional(
|
3541
|
+
import_zod25.z.union([Within, Exact])
|
3542
|
+
),
|
3618
3543
|
"legalStatuses.REGISTERED.createdAtLocation": import_zod25.z.optional(
|
3619
3544
|
import_zod25.z.union([Within, Exact])
|
3620
3545
|
),
|
@@ -3926,7 +3851,6 @@ var BaseActionInput = import_zod29.z.object({
|
|
3926
3851
|
transactionId: import_zod29.z.string(),
|
3927
3852
|
declaration: ActionUpdate.default({}),
|
3928
3853
|
annotation: ActionUpdate.optional(),
|
3929
|
-
actionDetails: ActionDetails.optional(),
|
3930
3854
|
originalActionId: UUID.optional(),
|
3931
3855
|
// should not be part of base action.
|
3932
3856
|
keepAssignment: import_zod29.z.boolean().optional()
|
@@ -4009,7 +3933,8 @@ var RequestCorrectionActionInput = BaseActionInput.merge(
|
|
4009
3933
|
var RejectCorrectionActionInput = BaseActionInput.merge(
|
4010
3934
|
import_zod29.z.object({
|
4011
3935
|
requestId: import_zod29.z.string(),
|
4012
|
-
type: import_zod29.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION)
|
3936
|
+
type: import_zod29.z.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION),
|
3937
|
+
reason: RejectionReason
|
4013
3938
|
})
|
4014
3939
|
);
|
4015
3940
|
var ApproveCorrectionActionInput = BaseActionInput.merge(
|
@@ -4376,8 +4301,7 @@ function getCurrentEventState(event2, config) {
|
|
4376
4301
|
trackingId: event2.trackingId,
|
4377
4302
|
updatedByUserRole: requestActionMetadata.createdByRole,
|
4378
4303
|
dateOfEvent: resolveDateOfEvent(event2, declaration, config),
|
4379
|
-
flags: getFlagsFromActions(event2.actions)
|
4380
|
-
copiesPrintedForTemplate: event2.copiesPrintedForTemplate ?? 0
|
4304
|
+
flags: getFlagsFromActions(event2.actions)
|
4381
4305
|
});
|
4382
4306
|
}
|
4383
4307
|
function getCurrentEventStateWithDrafts({
|
@@ -6849,7 +6773,7 @@ function eventPayloadGenerator(rng) {
|
|
6849
6773
|
requestId,
|
6850
6774
|
keepAssignment: input.keepAssignment
|
6851
6775
|
}),
|
6852
|
-
reject: (eventId, requestId, input
|
6776
|
+
reject: (eventId, requestId, input) => ({
|
6853
6777
|
type: ActionType.REJECT_CORRECTION,
|
6854
6778
|
transactionId: input.transactionId ?? getUUID(),
|
6855
6779
|
declaration: {},
|
@@ -6860,7 +6784,8 @@ function eventPayloadGenerator(rng) {
|
|
6860
6784
|
),
|
6861
6785
|
eventId,
|
6862
6786
|
requestId,
|
6863
|
-
keepAssignment: input.keepAssignment
|
6787
|
+
keepAssignment: input.keepAssignment,
|
6788
|
+
reason: input.reason ?? { message: "" }
|
6864
6789
|
})
|
6865
6790
|
}
|
6866
6791
|
}
|
@@ -6919,7 +6844,8 @@ function generateActionDocument({
|
|
6919
6844
|
return {
|
6920
6845
|
...actionBase,
|
6921
6846
|
requestId: getUUID(),
|
6922
|
-
type: action
|
6847
|
+
type: action,
|
6848
|
+
reason: { message: "Correction rejection" }
|
6923
6849
|
};
|
6924
6850
|
case ActionType.REGISTER:
|
6925
6851
|
return {
|
@@ -7054,8 +6980,7 @@ var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
|
|
7054
6980
|
flags: [],
|
7055
6981
|
legalStatuses: overrides.legalStatuses ?? {},
|
7056
6982
|
declaration: overrides.declaration ?? generateRandomApplicant(rng),
|
7057
|
-
trackingId: overrides.trackingId ?? generateTrackingId(rng)
|
7058
|
-
copiesPrintedForTemplate: overrides.copiesPrintedForTemplate ?? 0
|
6983
|
+
trackingId: overrides.trackingId ?? generateTrackingId(rng)
|
7059
6984
|
};
|
7060
6985
|
};
|
7061
6986
|
var generateTranslationConfig = (message) => ({
|