@opencrvs/toolkit 1.8.1-rc.fa83f7b → 1.8.1-rc.faf1965
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 +8 -7
- package/dist/commons/conditionals/validate.d.ts +3 -2
- package/dist/commons/events/AdvancedSearchConfig.d.ts +13 -31
- package/dist/commons/events/CountryConfigQueryInput.d.ts +88 -88
- package/dist/commons/events/EventConfig.d.ts +9 -9
- package/dist/commons/events/EventIndex.d.ts +55 -52
- package/dist/commons/events/EventMetadata.d.ts +12 -9
- package/dist/commons/events/FieldConfig.d.ts +8 -1
- package/dist/commons/events/WorkqueueConfig.d.ts +164 -199
- package/dist/commons/events/defineConfig.d.ts +1 -1
- package/dist/commons/events/event.d.ts +61 -7
- package/dist/commons/events/utils.d.ts +2 -2
- package/dist/conditionals/index.js +2 -2
- package/dist/events/index.js +171 -74
- package/package.json +1 -1
@@ -8686,7 +8686,7 @@ export declare const defineConfig: (config: EventConfigInput) => {
|
|
8686
8686
|
config: {
|
8687
8687
|
type: "exact" | "fuzzy" | "range" | "within";
|
8688
8688
|
};
|
8689
|
-
fieldId: "
|
8689
|
+
fieldId: "status" | "updatedAt" | "trackingId" | "legalStatuses.REGISTERED.acceptedAt" | "legalStatuses.REGISTERED.createdAtLocation";
|
8690
8690
|
fieldType: "event";
|
8691
8691
|
options?: {
|
8692
8692
|
value: string;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { ActionType } from './ActionType';
|
2
|
-
import {
|
2
|
+
import { EventFieldId } from './AdvancedSearchConfig';
|
3
3
|
import { WorkqueueColumnKeys, WorkqueueColumnValue } from './WorkqueueColumnConfig';
|
4
4
|
/**
|
5
5
|
* Creates a function that acts like a callable + static method container.
|
@@ -8,9 +8,9 @@ import { WorkqueueColumnKeys, WorkqueueColumnValue } from './WorkqueueColumnConf
|
|
8
8
|
* event('status') // → returns search config
|
9
9
|
* event.hasAction('CLICKED') // → returns conditional
|
10
10
|
*/
|
11
|
-
declare function eventFn(fieldId:
|
11
|
+
declare function eventFn(fieldId: EventFieldId): {
|
12
12
|
range: () => {
|
13
|
-
fieldId: "
|
13
|
+
fieldId: "status" | "updatedAt" | "trackingId" | "legalStatuses.REGISTERED.acceptedAt" | "legalStatuses.REGISTERED.createdAtLocation";
|
14
14
|
fieldType: "event";
|
15
15
|
} & {
|
16
16
|
config: {
|
@@ -18,7 +18,7 @@ declare function eventFn(fieldId: EventFieldIdInput): {
|
|
18
18
|
};
|
19
19
|
};
|
20
20
|
exact: () => {
|
21
|
-
fieldId: "
|
21
|
+
fieldId: "status" | "updatedAt" | "trackingId" | "legalStatuses.REGISTERED.acceptedAt" | "legalStatuses.REGISTERED.createdAtLocation";
|
22
22
|
fieldType: "event";
|
23
23
|
} & {
|
24
24
|
config: {
|
@@ -26,7 +26,7 @@ declare function eventFn(fieldId: EventFieldIdInput): {
|
|
26
26
|
};
|
27
27
|
};
|
28
28
|
fuzzy: () => {
|
29
|
-
fieldId: "
|
29
|
+
fieldId: "status" | "updatedAt" | "trackingId" | "legalStatuses.REGISTERED.acceptedAt" | "legalStatuses.REGISTERED.createdAtLocation";
|
30
30
|
fieldType: "event";
|
31
31
|
} & {
|
32
32
|
config: {
|
@@ -34,7 +34,7 @@ declare function eventFn(fieldId: EventFieldIdInput): {
|
|
34
34
|
};
|
35
35
|
};
|
36
36
|
within: () => {
|
37
|
-
fieldId: "
|
37
|
+
fieldId: "status" | "updatedAt" | "trackingId" | "legalStatuses.REGISTERED.acceptedAt" | "legalStatuses.REGISTERED.createdAtLocation";
|
38
38
|
fieldType: "event";
|
39
39
|
} & {
|
40
40
|
config: {
|
@@ -45,9 +45,63 @@ declare function eventFn(fieldId: EventFieldIdInput): {
|
|
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.
|
48
49
|
* @param action - The action type to check for.
|
49
50
|
*/
|
50
|
-
hasAction: (action: ActionType) =>
|
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
|
+
};
|
51
105
|
field(field: WorkqueueColumnKeys): WorkqueueColumnValue;
|
52
106
|
};
|
53
107
|
export { event };
|
@@ -4723,7 +4723,7 @@ export declare const getActionAnnotationFields: (actionConfig: ActionConfig) =>
|
|
4723
4723
|
hideLabel?: boolean | undefined;
|
4724
4724
|
uncorrectable?: boolean | undefined;
|
4725
4725
|
})[];
|
4726
|
-
export declare function getAllUniqueFields(eventConfig: EventConfig): FieldConfig[];
|
4726
|
+
export declare function getAllUniqueFields(eventConfig: EventConfig): import("./FieldConfig").Inferred[];
|
4727
4727
|
export declare function getDeclarationFieldById(config: EventConfig, fieldId: string): FieldConfig;
|
4728
4728
|
/**
|
4729
4729
|
* @TODO: Request correction should have same format as print certificate
|
@@ -15549,7 +15549,7 @@ export declare function getEventConfigById(eventConfigs: EventConfig[], id: stri
|
|
15549
15549
|
config: {
|
15550
15550
|
type: "exact" | "fuzzy" | "range" | "within";
|
15551
15551
|
};
|
15552
|
-
fieldId: "
|
15552
|
+
fieldId: "status" | "updatedAt" | "trackingId" | "legalStatuses.REGISTERED.acceptedAt" | "legalStatuses.REGISTERED.createdAtLocation";
|
15553
15553
|
fieldType: "event";
|
15554
15554
|
options?: {
|
15555
15555
|
value: string;
|
@@ -287,8 +287,8 @@ function createFieldConditionals(fieldId) {
|
|
287
287
|
properties: {
|
288
288
|
[fieldId]: {
|
289
289
|
type: "string",
|
290
|
-
pattern: "^[\\p{Script=Latin}0-9'
|
291
|
-
description: "Name must contain only letters, numbers, and allowed special characters ('
|
290
|
+
pattern: "^[\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*( [\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*)*$",
|
291
|
+
description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
|
292
292
|
}
|
293
293
|
}
|
294
294
|
}),
|
package/dist/events/index.js
CHANGED
@@ -40,7 +40,6 @@ __export(events_exports, {
|
|
40
40
|
ActionConfigBase: () => ActionConfigBase,
|
41
41
|
ActionCreationMetadata: () => ActionCreationMetadata,
|
42
42
|
ActionDocument: () => ActionDocument,
|
43
|
-
ActionFlag: () => ActionFlag,
|
44
43
|
ActionFormConfig: () => ActionFormConfig,
|
45
44
|
ActionInput: () => ActionInput,
|
46
45
|
ActionStatus: () => ActionStatus,
|
@@ -96,7 +95,6 @@ __export(events_exports, {
|
|
96
95
|
EventDocument: () => EventDocument,
|
97
96
|
EventFieldConfigSchema: () => EventFieldConfigSchema,
|
98
97
|
EventFieldId: () => EventFieldId,
|
99
|
-
EventFieldIdInput: () => EventFieldIdInput,
|
100
98
|
EventIndex: () => EventIndex,
|
101
99
|
EventInput: () => EventInput,
|
102
100
|
EventMetadata: () => EventMetadata,
|
@@ -131,7 +129,6 @@ __export(events_exports, {
|
|
131
129
|
InherentFlags: () => InherentFlags,
|
132
130
|
LanguageConfig: () => LanguageConfig,
|
133
131
|
LegalStatuses: () => LegalStatuses,
|
134
|
-
METADATA_FIELD_PREFIX: () => METADATA_FIELD_PREFIX,
|
135
132
|
MarkedAsDuplicateActionInput: () => MarkedAsDuplicateActionInput,
|
136
133
|
MimeType: () => MimeType,
|
137
134
|
NameFieldUpdateValue: () => NameFieldUpdateValue,
|
@@ -182,6 +179,7 @@ __export(events_exports, {
|
|
182
179
|
ValidationConfig: () => ValidationConfig,
|
183
180
|
VerificationActionConfig: () => VerificationActionConfig,
|
184
181
|
VerificationPageConfig: () => VerificationPageConfig,
|
182
|
+
VisibleStatus: () => VisibleStatus,
|
185
183
|
WRITE_ACTION_SCOPES: () => WRITE_ACTION_SCOPES,
|
186
184
|
Within: () => Within,
|
187
185
|
WorkqueueActionsWithDefault: () => WorkqueueActionsWithDefault,
|
@@ -200,6 +198,7 @@ __export(events_exports, {
|
|
200
198
|
annotationActions: () => annotationActions,
|
201
199
|
applyDeclarationToEventIndex: () => applyDeclarationToEventIndex,
|
202
200
|
applyDraftsToEventIndex: () => applyDraftsToEventIndex,
|
201
|
+
areCertificateConditionsMet: () => areCertificateConditionsMet,
|
203
202
|
areConditionsMet: () => areConditionsMet,
|
204
203
|
compositeFieldTypes: () => compositeFieldTypes,
|
205
204
|
createEmptyDraft: () => createEmptyDraft,
|
@@ -557,7 +556,7 @@ var import_zod6 = require("zod");
|
|
557
556
|
var import_zod4 = require("zod");
|
558
557
|
var import_zod_openapi3 = require("zod-openapi");
|
559
558
|
(0, import_zod_openapi3.extendZodWithOpenApi)(import_zod4.z);
|
560
|
-
var
|
559
|
+
var FullDocumentURL = import_zod4.z.string().brand("FullDocumentURL").describe(
|
561
560
|
"A full url with protocol, host, bucket name, starting from the root of the S3 server, https://minio/bucket-name/document-id.jpg"
|
562
561
|
);
|
563
562
|
var FullDocumentPath = import_zod4.z.string().transform((val) => val.startsWith("/") ? val : `/${val}`).openapi({ effectType: "input", type: "string" }).describe(
|
@@ -1225,7 +1224,8 @@ var CertificateConfig = import_zod11.z.object({
|
|
1225
1224
|
delayed: import_zod11.z.number()
|
1226
1225
|
}),
|
1227
1226
|
svgUrl: import_zod11.z.string(),
|
1228
|
-
fonts: import_zod11.z.record(FontFamily).optional()
|
1227
|
+
fonts: import_zod11.z.record(FontFamily).optional(),
|
1228
|
+
conditionals: import_zod11.z.array(ShowConditional).optional()
|
1229
1229
|
});
|
1230
1230
|
var CertificateTemplateConfig = CertificateConfig.extend({
|
1231
1231
|
hash: import_zod11.z.string().optional(),
|
@@ -1397,30 +1397,22 @@ var FieldConfigSchema = BaseField3.extend({
|
|
1397
1397
|
fieldType: import_zod15.z.literal("field"),
|
1398
1398
|
alternateFieldIds: import_zod15.z.array(import_zod15.z.string()).optional().describe(
|
1399
1399
|
`Sometimes there might be need to search a value against multiple field of same FormField type. For example
|
1400
|
-
search Country, Province, District against child.address.private and child.address.other. In such case, we
|
1400
|
+
search Country, Province, District against child.address.private and child.address.other. In such case, we
|
1401
1401
|
add a one field as fieldId, and accomodate others in alternateFieldIds`
|
1402
1402
|
),
|
1403
|
-
excludeInSearchQuery: import_zod15.z.boolean().default(false).optional().describe(`Sometimes there will be search fields which are used to
|
1404
|
-
conditionally display another search field, but its not needed in search query. For example, child.placeOfBirth
|
1403
|
+
excludeInSearchQuery: import_zod15.z.boolean().default(false).optional().describe(`Sometimes there will be search fields which are used to
|
1404
|
+
conditionally display another search field, but its not needed in search query. For example, child.placeOfBirth
|
1405
1405
|
is select field, which has 3 options, FACILITY, PRIVATE_HOME, OTHER. Upon selecting any of the option, pops up another field
|
1406
1406
|
related to the selected option, whose value is required in the search query. But child.placeOfBirth itself is not needed in the query.
|
1407
1407
|
In such case, populate this field (excludeInSearchQuery) with boolean true`)
|
1408
1408
|
});
|
1409
|
-
var
|
1409
|
+
var EventFieldId = import_zod15.z.enum([
|
1410
1410
|
"trackingId",
|
1411
1411
|
"status",
|
1412
1412
|
"legalStatuses.REGISTERED.acceptedAt",
|
1413
1413
|
"legalStatuses.REGISTERED.createdAtLocation",
|
1414
1414
|
"updatedAt"
|
1415
1415
|
]);
|
1416
|
-
var METADATA_FIELD_PREFIX = "event.";
|
1417
|
-
var EventFieldId = import_zod15.z.enum([
|
1418
|
-
`${METADATA_FIELD_PREFIX}trackingId`,
|
1419
|
-
`${METADATA_FIELD_PREFIX}status`,
|
1420
|
-
`${METADATA_FIELD_PREFIX}legalStatuses.REGISTERED.acceptedAt`,
|
1421
|
-
`${METADATA_FIELD_PREFIX}legalStatuses.REGISTERED.createdAtLocation`,
|
1422
|
-
`${METADATA_FIELD_PREFIX}updatedAt`
|
1423
|
-
]);
|
1424
1416
|
var EventFieldConfigSchema = BaseField3.extend({
|
1425
1417
|
fieldId: EventFieldId,
|
1426
1418
|
fieldType: import_zod15.z.literal("event")
|
@@ -2055,7 +2047,7 @@ var ResolvedUser = import_zod19.z.object({
|
|
2055
2047
|
});
|
2056
2048
|
|
2057
2049
|
// ../commons/src/conditionals/validate.ts
|
2058
|
-
var
|
2050
|
+
var import__ = __toESM(require("ajv/dist/2019"));
|
2059
2051
|
var import_ajv_formats = __toESM(require("ajv-formats"));
|
2060
2052
|
var import_date_fns = require("date-fns");
|
2061
2053
|
|
@@ -2269,9 +2261,11 @@ var isNonInteractiveFieldType = (field2) => {
|
|
2269
2261
|
};
|
2270
2262
|
|
2271
2263
|
// ../commons/src/conditionals/validate.ts
|
2272
|
-
var ajv = new
|
2264
|
+
var ajv = new import__.default({
|
2273
2265
|
$data: true,
|
2274
|
-
allowUnionTypes: true
|
2266
|
+
allowUnionTypes: true,
|
2267
|
+
strict: false
|
2268
|
+
// Allow minContains and other newer features
|
2275
2269
|
});
|
2276
2270
|
(0, import_ajv_formats.default)(ajv);
|
2277
2271
|
ajv.addKeyword({
|
@@ -2509,6 +2503,11 @@ function getValidatorsForField(fieldId, validations) {
|
|
2509
2503
|
};
|
2510
2504
|
}).filter((x) => x !== null);
|
2511
2505
|
}
|
2506
|
+
function areCertificateConditionsMet(conditions, values) {
|
2507
|
+
return conditions.every((condition) => {
|
2508
|
+
return ajv.validate(condition.conditional, values);
|
2509
|
+
});
|
2510
|
+
}
|
2512
2511
|
|
2513
2512
|
// ../commons/src/utils.ts
|
2514
2513
|
function getOrThrow(x, message) {
|
@@ -2729,16 +2728,16 @@ function timePeriodToDateRange(value) {
|
|
2729
2728
|
let startDate;
|
2730
2729
|
switch (value) {
|
2731
2730
|
case "last7Days":
|
2732
|
-
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(),
|
2731
|
+
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 6);
|
2733
2732
|
break;
|
2734
2733
|
case "last30Days":
|
2735
|
-
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(),
|
2734
|
+
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 29);
|
2736
2735
|
break;
|
2737
2736
|
case "last90Days":
|
2738
|
-
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(),
|
2737
|
+
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 89);
|
2739
2738
|
break;
|
2740
2739
|
case "last365Days":
|
2741
|
-
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(),
|
2740
|
+
startDate = (0, import_date_fns2.subDays)(/* @__PURE__ */ new Date(), 364);
|
2742
2741
|
break;
|
2743
2742
|
}
|
2744
2743
|
return {
|
@@ -3105,8 +3104,8 @@ function createFieldConditionals(fieldId) {
|
|
3105
3104
|
properties: {
|
3106
3105
|
[fieldId]: {
|
3107
3106
|
type: "string",
|
3108
|
-
pattern: "^[\\p{Script=Latin}0-9'
|
3109
|
-
description: "Name must contain only letters, numbers, and allowed special characters ('
|
3107
|
+
pattern: "^[\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*( [\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*)*$",
|
3108
|
+
description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces."
|
3110
3109
|
}
|
3111
3110
|
}
|
3112
3111
|
}),
|
@@ -3219,7 +3218,7 @@ function createSearchConfig(baseField) {
|
|
3219
3218
|
// ../commons/src/event-config/event-configuration.ts
|
3220
3219
|
function createEventFieldConfig(fieldId) {
|
3221
3220
|
const baseField = {
|
3222
|
-
fieldId
|
3221
|
+
fieldId,
|
3223
3222
|
fieldType: "event"
|
3224
3223
|
};
|
3225
3224
|
return createSearchConfig(baseField);
|
@@ -3232,32 +3231,107 @@ function eventFn(fieldId) {
|
|
3232
3231
|
var event = Object.assign(eventFn, {
|
3233
3232
|
/**
|
3234
3233
|
* Checks if the event contains a specific action type.
|
3234
|
+
* Can be used directly as a conditional or chained with additional methods.
|
3235
3235
|
* @param action - The action type to check for.
|
3236
3236
|
*/
|
3237
|
-
hasAction: (action) =>
|
3238
|
-
|
3239
|
-
|
3240
|
-
|
3237
|
+
hasAction: (action) => {
|
3238
|
+
const basicConditional = defineConditional({
|
3239
|
+
type: "object",
|
3240
|
+
properties: {
|
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({
|
3241
3278
|
type: "object",
|
3242
3279
|
properties: {
|
3243
|
-
|
3244
|
-
type: "
|
3245
|
-
|
3246
|
-
|
3247
|
-
|
3248
|
-
|
3249
|
-
|
3250
|
-
|
3251
|
-
|
3252
|
-
|
3253
|
-
|
3280
|
+
$event: {
|
3281
|
+
type: "object",
|
3282
|
+
properties: {
|
3283
|
+
actions: {
|
3284
|
+
type: "array",
|
3285
|
+
contains: {
|
3286
|
+
type: "object",
|
3287
|
+
properties: actionProperties,
|
3288
|
+
required: requiredFields
|
3289
|
+
},
|
3290
|
+
[countType]: count
|
3291
|
+
}
|
3292
|
+
},
|
3293
|
+
required: ["actions"]
|
3254
3294
|
}
|
3255
3295
|
},
|
3256
|
-
required: ["
|
3257
|
-
}
|
3258
|
-
}
|
3259
|
-
|
3260
|
-
|
3296
|
+
required: ["$event"]
|
3297
|
+
});
|
3298
|
+
};
|
3299
|
+
const withMinMax = (additionalFields) => {
|
3300
|
+
return {
|
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
|
+
},
|
3261
3335
|
field(field2) {
|
3262
3336
|
return {
|
3263
3337
|
$event: field2
|
@@ -3276,23 +3350,24 @@ var EventStatus = import_zod23.z.enum([
|
|
3276
3350
|
"DECLARED",
|
3277
3351
|
"VALIDATED",
|
3278
3352
|
"REGISTERED",
|
3353
|
+
"CERTIFIED",
|
3279
3354
|
"ARCHIVED"
|
3280
3355
|
]);
|
3356
|
+
var VisibleStatus = import_zod23.z.enum([...EventStatus.options, "REJECTED"]);
|
3281
3357
|
var InherentFlags = {
|
3282
|
-
|
3358
|
+
PRINTED: "printed",
|
3283
3359
|
INCOMPLETE: "incomplete",
|
3284
3360
|
REJECTED: "rejected",
|
3285
3361
|
CORRECTION_REQUESTED: "correction-requested"
|
3286
3362
|
};
|
3287
|
-
var
|
3363
|
+
var Flag = import_zod23.z.string().regex(
|
3288
3364
|
new RegExp(
|
3289
3365
|
`^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
|
3290
3366
|
ActionStatus
|
3291
3367
|
).join("|").toLowerCase()})$`
|
3292
3368
|
),
|
3293
3369
|
"Flag must be in the format ActionType:ActionStatus (lowerCase)"
|
3294
|
-
);
|
3295
|
-
var Flag = ActionFlag.or(import_zod23.z.nativeEnum(InherentFlags));
|
3370
|
+
).or(import_zod23.z.nativeEnum(InherentFlags));
|
3296
3371
|
var ZodDate = import_zod23.z.string().date();
|
3297
3372
|
var ActionCreationMetadata = import_zod23.z.object({
|
3298
3373
|
createdAt: import_zod23.z.string().datetime().describe("The timestamp when the action request was created."),
|
@@ -3341,7 +3416,8 @@ var EventMetadata = import_zod23.z.object({
|
|
3341
3416
|
trackingId: import_zod23.z.string().describe(
|
3342
3417
|
"System-generated tracking ID used by informants or registrars to look up the event."
|
3343
3418
|
),
|
3344
|
-
flags: import_zod23.z.array(Flag)
|
3419
|
+
flags: import_zod23.z.array(Flag),
|
3420
|
+
modifiedAt: import_zod23.z.string().optional()
|
3345
3421
|
});
|
3346
3422
|
var EventMetadataKeysArray = [
|
3347
3423
|
"id",
|
@@ -3808,8 +3884,7 @@ var WorkqueueConfig = import_zod28.z.object({
|
|
3808
3884
|
})
|
3809
3885
|
),
|
3810
3886
|
columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
|
3811
|
-
icon: AvailableIcons
|
3812
|
-
emptyMessage: TranslationConfig.optional()
|
3887
|
+
icon: AvailableIcons
|
3813
3888
|
}).describe("Configuration for workqueue.");
|
3814
3889
|
var WorkqueueConfigWithoutQuery = WorkqueueConfig.omit({
|
3815
3890
|
query: true,
|
@@ -3828,8 +3903,7 @@ var WorkqueueConfigInput = import_zod28.z.object({
|
|
3828
3903
|
})
|
3829
3904
|
),
|
3830
3905
|
columns: import_zod28.z.array(WorkqueueColumn).default(mandatoryColumns),
|
3831
|
-
icon: AvailableIcons
|
3832
|
-
emptyMessage: TranslationConfig.optional()
|
3906
|
+
icon: AvailableIcons
|
3833
3907
|
});
|
3834
3908
|
function defineWorkqueue(workqueueInput) {
|
3835
3909
|
const queryInput = workqueueInput.query;
|
@@ -4131,19 +4205,16 @@ function getLegalStatuses(actions) {
|
|
4131
4205
|
}
|
4132
4206
|
|
4133
4207
|
// ../commons/src/events/state/flags.ts
|
4134
|
-
function
|
4135
|
-
if (getStatusFromActions(actions) !== EventStatus.enum.REGISTERED) {
|
4136
|
-
return false;
|
4137
|
-
}
|
4208
|
+
function isCertificatePrinted(actions) {
|
4138
4209
|
return actions.reduce((prev, { type }) => {
|
4139
4210
|
if (type === ActionType.PRINT_CERTIFICATE) {
|
4140
|
-
return
|
4211
|
+
return true;
|
4141
4212
|
}
|
4142
4213
|
if (type === ActionType.APPROVE_CORRECTION) {
|
4143
|
-
return
|
4214
|
+
return false;
|
4144
4215
|
}
|
4145
4216
|
return prev;
|
4146
|
-
},
|
4217
|
+
}, false);
|
4147
4218
|
}
|
4148
4219
|
function isCorrectionRequested(actions) {
|
4149
4220
|
return actions.reduce((prev, { type }) => {
|
@@ -4178,8 +4249,8 @@ function getFlagsFromActions(actions) {
|
|
4178
4249
|
const flag = joinValues([type, status], ":").toLowerCase();
|
4179
4250
|
return flag;
|
4180
4251
|
});
|
4181
|
-
if (
|
4182
|
-
flags.push(InherentFlags.
|
4252
|
+
if (isCertificatePrinted(sortedActions)) {
|
4253
|
+
flags.push(InherentFlags.PRINTED);
|
4183
4254
|
}
|
4184
4255
|
if (isCorrectionRequested(sortedActions)) {
|
4185
4256
|
flags.push(InherentFlags.CORRECTION_REQUESTED);
|
@@ -4210,6 +4281,7 @@ function getStatusFromActions(actions) {
|
|
4210
4281
|
case ActionType.NOTIFY:
|
4211
4282
|
return EventStatus.enum.NOTIFIED;
|
4212
4283
|
case ActionType.PRINT_CERTIFICATE:
|
4284
|
+
return EventStatus.enum.CERTIFIED;
|
4213
4285
|
case ActionType.ASSIGN:
|
4214
4286
|
case ActionType.UNASSIGN:
|
4215
4287
|
case ActionType.REJECT:
|
@@ -5396,6 +5468,22 @@ var statusOptions = [
|
|
5396
5468
|
id: "v2.advancedSearch.form.recordStatusRegistered"
|
5397
5469
|
}
|
5398
5470
|
},
|
5471
|
+
{
|
5472
|
+
value: EventStatus.enum.CERTIFIED,
|
5473
|
+
label: {
|
5474
|
+
defaultMessage: "Certified",
|
5475
|
+
description: "Option for form field: status of record",
|
5476
|
+
id: "v2.advancedSearch.form.recordStatusCertified"
|
5477
|
+
}
|
5478
|
+
},
|
5479
|
+
{
|
5480
|
+
value: VisibleStatus.enum.REJECTED,
|
5481
|
+
label: {
|
5482
|
+
defaultMessage: "Rejected",
|
5483
|
+
description: "Option for form field: status of record",
|
5484
|
+
id: "v2.advancedSearch.form.recordStatusRejected"
|
5485
|
+
}
|
5486
|
+
},
|
5399
5487
|
{
|
5400
5488
|
value: EventStatus.enum.ARCHIVED,
|
5401
5489
|
label: {
|
@@ -6847,7 +6935,11 @@ function generateActionDocument({
|
|
6847
6935
|
case ActionType.NOTIFY:
|
6848
6936
|
return { ...actionBase, type: action };
|
6849
6937
|
case ActionType.PRINT_CERTIFICATE:
|
6850
|
-
return {
|
6938
|
+
return {
|
6939
|
+
...actionBase,
|
6940
|
+
type: action,
|
6941
|
+
content: defaults.content
|
6942
|
+
};
|
6851
6943
|
case ActionType.REQUEST_CORRECTION:
|
6852
6944
|
return { ...actionBase, type: action };
|
6853
6945
|
case ActionType.APPROVE_CORRECTION:
|
@@ -7247,6 +7339,14 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
|
|
7247
7339
|
ActionType.REJECT_CORRECTION,
|
7248
7340
|
ExclusiveActions.REVIEW_CORRECTION_REQUEST
|
7249
7341
|
],
|
7342
|
+
[EventStatus.enum.CERTIFIED]: [
|
7343
|
+
ActionType.READ,
|
7344
|
+
ActionType.PRINT_CERTIFICATE,
|
7345
|
+
ActionType.REQUEST_CORRECTION,
|
7346
|
+
ActionType.APPROVE_CORRECTION,
|
7347
|
+
ActionType.REJECT_CORRECTION,
|
7348
|
+
ExclusiveActions.REVIEW_CORRECTION_REQUEST
|
7349
|
+
],
|
7250
7350
|
[EventStatus.enum.ARCHIVED]: [
|
7251
7351
|
ActionType.READ,
|
7252
7352
|
ActionType.ASSIGN,
|
@@ -7254,12 +7354,9 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
|
|
7254
7354
|
]
|
7255
7355
|
};
|
7256
7356
|
var getAvailableActionsForEvent = (event2) => {
|
7257
|
-
|
7258
|
-
|
7259
|
-
|
7260
|
-
|
7261
|
-
|
7262
|
-
];
|
7263
|
-
}
|
7264
|
-
return AVAILABLE_ACTIONS_BY_EVENT_STATUS[event2.status];
|
7357
|
+
return event2.flags.includes(InherentFlags.REJECTED) ? [
|
7358
|
+
ActionType.READ,
|
7359
|
+
event2.status === EventStatus.Enum.VALIDATED ? ActionType.VALIDATE : ActionType.DECLARE,
|
7360
|
+
ActionType.ARCHIVE
|
7361
|
+
] : AVAILABLE_ACTIONS_BY_EVENT_STATUS[event2.status];
|
7265
7362
|
};
|