@opencrvs/toolkit 2.0.0-rc.c2f305f → 2.0.0-rc.c30a093
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/build.sh +2 -2
- package/dist/application-config/index.js +15 -5
- package/dist/cli.js +166 -5101
- package/dist/commons/api/router.d.ts +8 -0
- package/dist/commons/conditionals/conditionals.d.ts +3 -3
- package/dist/commons/events/ActionConfig.d.ts +176 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +12 -0
- package/dist/commons/events/EventConfig.d.ts +2 -0
- package/dist/commons/events/EventIndex.d.ts +11 -0
- package/dist/commons/events/EventMetadata.d.ts +26 -0
- package/dist/commons/events/FieldConfig.d.ts +10 -0
- package/dist/commons/events/locations.d.ts +1 -0
- package/dist/commons/events/state/index.d.ts +8 -0
- package/dist/commons/events/state/utils.d.ts +9 -0
- package/dist/conditionals/index.js +10 -5
- package/dist/environment/templates.d.ts.map +1 -1
- package/dist/environment/templates.js +1 -0
- package/dist/events/index.js +130 -12
- package/dist/migrations/v2.0/index.js +88 -5139
- package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +3 -0
- package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +1 -0
- package/dist/migrations/v2.1/add-explicit-correction-flags.js +234 -0
- package/dist/migrations/v2.1/index.d.ts +6 -0
- package/dist/migrations/v2.1/index.d.ts.map +1 -0
- package/dist/migrations/v2.1/index.js +218 -0
- package/dist/notification/index.js +106 -8
- package/dist/scopes/index.d.ts +89 -1
- package/dist/scopes/index.js +10 -5
- package/dist/templates/charts-values/opencrvs-services/values.yaml +1 -0
- package/opencrvs-toolkit-2.0.0-rc.c30a093.tgz +0 -0
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/opencrvs-toolkit-2.0.0-rc.c2f305f.tgz +0 -0
package/dist/events/index.js
CHANGED
|
@@ -520,11 +520,13 @@ var scopeOptionsPlaceEvent = z2.object({
|
|
|
520
520
|
event: scopeByEvent,
|
|
521
521
|
placeOfEvent: JurisdictionFilter.optional()
|
|
522
522
|
}).describe("Options applicable to all record scopes.");
|
|
523
|
-
var
|
|
523
|
+
var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
|
|
524
|
+
notifiedIn: JurisdictionFilter.optional(),
|
|
525
|
+
notifiedBy: UserFilter.optional(),
|
|
524
526
|
declaredIn: JurisdictionFilter.optional(),
|
|
525
527
|
declaredBy: UserFilter.optional()
|
|
526
528
|
}).describe("Options applicable to actions that may take place after DECLARE");
|
|
527
|
-
var AllRecordScopeOptions =
|
|
529
|
+
var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
|
|
528
530
|
registeredIn: JurisdictionFilter.optional(),
|
|
529
531
|
registeredBy: UserFilter.optional()
|
|
530
532
|
}).describe(
|
|
@@ -562,6 +564,8 @@ var ResolvedScopeOptionsPlaceEvent = z2.object({
|
|
|
562
564
|
"Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
|
|
563
565
|
);
|
|
564
566
|
var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
|
|
567
|
+
notifiedIn: UUID.nullish(),
|
|
568
|
+
notifiedBy: z2.string().optional(),
|
|
565
569
|
declaredIn: UUID.nullish(),
|
|
566
570
|
declaredBy: z2.string().optional()
|
|
567
571
|
}).describe(
|
|
@@ -607,7 +611,7 @@ var RecordScopeV2 = z2.discriminatedUnion("type", [
|
|
|
607
611
|
}),
|
|
608
612
|
z2.object({
|
|
609
613
|
type: ScopesWithDeclaredOptions,
|
|
610
|
-
options:
|
|
614
|
+
options: scopeOptionsDeclaredOrNotified.optional()
|
|
611
615
|
}),
|
|
612
616
|
z2.object({
|
|
613
617
|
type: ScopesWithFullOptions,
|
|
@@ -730,8 +734,9 @@ var decodeScope = (encodedScope) => {
|
|
|
730
734
|
var DEFAULT_SCOPE_OPTIONS = {
|
|
731
735
|
placeOfEvent: JurisdictionFilter.enum.all,
|
|
732
736
|
accessLevel: JurisdictionFilter.enum.all,
|
|
733
|
-
|
|
734
|
-
declaredIn: JurisdictionFilter.enum.all
|
|
737
|
+
notifiedIn: JurisdictionFilter.enum.all,
|
|
738
|
+
declaredIn: JurisdictionFilter.enum.all,
|
|
739
|
+
registeredIn: JurisdictionFilter.enum.all
|
|
735
740
|
};
|
|
736
741
|
function getAcceptedScopesByType({
|
|
737
742
|
acceptedScopes,
|
|
@@ -1815,6 +1820,7 @@ var RegistrationCreationMetadata = ActionCreationMetadata.extend({
|
|
|
1815
1820
|
)
|
|
1816
1821
|
});
|
|
1817
1822
|
var LegalStatuses = z16.object({
|
|
1823
|
+
[EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
|
|
1818
1824
|
[EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
|
|
1819
1825
|
[EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
|
|
1820
1826
|
});
|
|
@@ -1956,6 +1962,8 @@ var eventMetadataLabelMap = {
|
|
|
1956
1962
|
var EventMetadataDateFieldIdInput = z16.enum([
|
|
1957
1963
|
"createdAt",
|
|
1958
1964
|
"updatedAt",
|
|
1965
|
+
"legalStatuses.NOTIFIED.createdAt",
|
|
1966
|
+
"legalStatuses.NOTIFIED.acceptedAt",
|
|
1959
1967
|
"legalStatuses.DECLARED.createdAt",
|
|
1960
1968
|
"legalStatuses.DECLARED.acceptedAt",
|
|
1961
1969
|
"legalStatuses.REGISTERED.createdAt",
|
|
@@ -1964,6 +1972,8 @@ var EventMetadataDateFieldIdInput = z16.enum([
|
|
|
1964
1972
|
var EventMetadataDateFieldId = z16.enum([
|
|
1965
1973
|
"event.createdAt",
|
|
1966
1974
|
"event.updatedAt",
|
|
1975
|
+
"event.legalStatuses.NOTIFIED.createdAt",
|
|
1976
|
+
"event.legalStatuses.NOTIFIED.acceptedAt",
|
|
1967
1977
|
"event.legalStatuses.DECLARED.createdAt",
|
|
1968
1978
|
"event.legalStatuses.DECLARED.acceptedAt",
|
|
1969
1979
|
"event.legalStatuses.REGISTERED.createdAt",
|
|
@@ -3228,6 +3238,52 @@ var NotifyConfig = ActionConfigBase.extend(
|
|
|
3228
3238
|
type: z24.literal(ActionType.NOTIFY)
|
|
3229
3239
|
}).shape
|
|
3230
3240
|
);
|
|
3241
|
+
var DuplicateDetectedConfig = ActionConfigBase.extend(
|
|
3242
|
+
z24.object({
|
|
3243
|
+
type: z24.literal(ActionType.DUPLICATE_DETECTED),
|
|
3244
|
+
label: z24.never().optional().describe(
|
|
3245
|
+
"DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no label."
|
|
3246
|
+
),
|
|
3247
|
+
supportingCopy: z24.never().optional(),
|
|
3248
|
+
icon: z24.never().optional().describe(
|
|
3249
|
+
"DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no icon."
|
|
3250
|
+
),
|
|
3251
|
+
conditionals: z24.never().optional().describe(
|
|
3252
|
+
"DUPLICATE_DETECTED is system-generated and never shown as a button, so it cannot be disabled or hidden with conditionals."
|
|
3253
|
+
)
|
|
3254
|
+
}).shape
|
|
3255
|
+
);
|
|
3256
|
+
var MarkAsDuplicateConfig = ActionConfigBase.extend(
|
|
3257
|
+
z24.object({
|
|
3258
|
+
type: z24.literal(ActionType.MARK_AS_DUPLICATE)
|
|
3259
|
+
}).shape
|
|
3260
|
+
);
|
|
3261
|
+
var MarkAsNotDuplicateConfig = ActionConfigBase.extend(
|
|
3262
|
+
z24.object({
|
|
3263
|
+
type: z24.literal(ActionType.MARK_AS_NOT_DUPLICATE)
|
|
3264
|
+
}).shape
|
|
3265
|
+
);
|
|
3266
|
+
var AssignConfig = ActionConfigBase.extend(
|
|
3267
|
+
z24.object({
|
|
3268
|
+
type: z24.literal(ActionType.ASSIGN),
|
|
3269
|
+
flags: z24.never().optional().describe(
|
|
3270
|
+
"ASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
|
|
3271
|
+
)
|
|
3272
|
+
}).shape
|
|
3273
|
+
);
|
|
3274
|
+
var UnassignConfig = ActionConfigBase.extend(
|
|
3275
|
+
z24.object({
|
|
3276
|
+
type: z24.literal(ActionType.UNASSIGN),
|
|
3277
|
+
flags: z24.never().optional().describe(
|
|
3278
|
+
"UNASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
|
|
3279
|
+
)
|
|
3280
|
+
}).shape
|
|
3281
|
+
);
|
|
3282
|
+
var DeleteConfig = ActionConfigBase.extend(
|
|
3283
|
+
z24.object({
|
|
3284
|
+
type: z24.literal(ActionType.DELETE)
|
|
3285
|
+
}).shape
|
|
3286
|
+
);
|
|
3231
3287
|
var DeclareConfig = DeclarationActionBase.extend(
|
|
3232
3288
|
z24.object({
|
|
3233
3289
|
type: z24.literal(ActionType.DECLARE),
|
|
@@ -3290,7 +3346,17 @@ var RequestCorrectionConfig = ActionConfigBase.extend(
|
|
|
3290
3346
|
correctionForm: ActionFormConfig
|
|
3291
3347
|
}).shape
|
|
3292
3348
|
);
|
|
3293
|
-
var
|
|
3349
|
+
var ApproveCorrectionConfig = ActionConfigBase.extend(
|
|
3350
|
+
z24.object({
|
|
3351
|
+
type: z24.literal(ActionType.APPROVE_CORRECTION)
|
|
3352
|
+
}).shape
|
|
3353
|
+
);
|
|
3354
|
+
var RejectCorrectionConfig = ActionConfigBase.extend(
|
|
3355
|
+
z24.object({
|
|
3356
|
+
type: z24.literal(ActionType.REJECT_CORRECTION)
|
|
3357
|
+
}).shape
|
|
3358
|
+
);
|
|
3359
|
+
var CustomActionConfig = ActionConfigBase.extend(
|
|
3294
3360
|
z24.object({
|
|
3295
3361
|
type: z24.literal(ActionType.CUSTOM),
|
|
3296
3362
|
customActionType: z24.string().describe("Type identifier of the custom action."),
|
|
@@ -3301,7 +3367,7 @@ var CustomActionConfig = ActionConfigBase.merge(
|
|
|
3301
3367
|
auditHistoryLabel: TranslationConfig.describe(
|
|
3302
3368
|
'The label to show in audit history for this action. For example "Approved".'
|
|
3303
3369
|
)
|
|
3304
|
-
})
|
|
3370
|
+
}).shape
|
|
3305
3371
|
);
|
|
3306
3372
|
var ActionConfig = z24.discriminatedUnion("type", [
|
|
3307
3373
|
/*
|
|
@@ -3312,6 +3378,18 @@ var ActionConfig = z24.discriminatedUnion("type", [
|
|
|
3312
3378
|
id: "ReadActionConfig",
|
|
3313
3379
|
description: "Configuration for the read action \u2014 defines the record-tab content displayed on the event overview page."
|
|
3314
3380
|
}),
|
|
3381
|
+
AssignConfig.meta({
|
|
3382
|
+
id: "AssignActionConfig",
|
|
3383
|
+
description: "Configuration for assigning a record to the current user."
|
|
3384
|
+
}),
|
|
3385
|
+
UnassignConfig.meta({
|
|
3386
|
+
id: "UnassignActionConfig",
|
|
3387
|
+
description: "Configuration for unassigning a record from its current assignee."
|
|
3388
|
+
}),
|
|
3389
|
+
DeleteConfig.meta({
|
|
3390
|
+
id: "DeleteActionConfig",
|
|
3391
|
+
description: "Configuration for deleting a draft record."
|
|
3392
|
+
}),
|
|
3315
3393
|
NotifyConfig.meta({
|
|
3316
3394
|
id: "NotifyActionConfig",
|
|
3317
3395
|
description: "Configuration for the notify action. When present, NOTIFY uses this config independently from DECLARE. When absent, NOTIFY falls back to the DeclareActionConfig."
|
|
@@ -3320,6 +3398,18 @@ var ActionConfig = z24.discriminatedUnion("type", [
|
|
|
3320
3398
|
id: "DeclareActionConfig",
|
|
3321
3399
|
description: "Configuration for the declare action. Includes review-page fields. NOTIFY falls back to this config when no dedicated NotifyActionConfig is provided."
|
|
3322
3400
|
}),
|
|
3401
|
+
DuplicateDetectedConfig.meta({
|
|
3402
|
+
id: "DuplicateDetectedActionConfig",
|
|
3403
|
+
description: "Configuration for the system-generated duplicate-detection action. Never shown as a button, so it only supports flags \u2014 not label, icon, or conditionals."
|
|
3404
|
+
}),
|
|
3405
|
+
MarkAsDuplicateConfig.meta({
|
|
3406
|
+
id: "MarkAsDuplicateActionConfig",
|
|
3407
|
+
description: "Configuration for marking a record as a duplicate."
|
|
3408
|
+
}),
|
|
3409
|
+
MarkAsNotDuplicateConfig.meta({
|
|
3410
|
+
id: "MarkAsNotDuplicateActionConfig",
|
|
3411
|
+
description: "Configuration for marking a record as not a duplicate, after it was previously flagged as one."
|
|
3412
|
+
}),
|
|
3323
3413
|
RejectConfig.meta({
|
|
3324
3414
|
id: "RejectActionConfig",
|
|
3325
3415
|
description: "Configuration for rejecting a record before registration."
|
|
@@ -3336,6 +3426,14 @@ var ActionConfig = z24.discriminatedUnion("type", [
|
|
|
3336
3426
|
id: "RequestCorrectionActionConfig",
|
|
3337
3427
|
description: "Configuration for requesting a correction on a registered record."
|
|
3338
3428
|
}),
|
|
3429
|
+
ApproveCorrectionConfig.meta({
|
|
3430
|
+
id: "ApproveCorrectionActionConfig",
|
|
3431
|
+
description: "Configuration for approving a requested correction."
|
|
3432
|
+
}),
|
|
3433
|
+
RejectCorrectionConfig.meta({
|
|
3434
|
+
id: "RejectCorrectionActionConfig",
|
|
3435
|
+
description: "Configuration for rejecting a requested correction."
|
|
3436
|
+
}),
|
|
3339
3437
|
EditActionConfig.meta({
|
|
3340
3438
|
id: "EditActionConfig",
|
|
3341
3439
|
description: "Configuration for editing a record before registration."
|
|
@@ -4494,9 +4592,6 @@ function getActionConfig({
|
|
|
4494
4592
|
if (a.type === ActionType.CUSTOM && customActionType) {
|
|
4495
4593
|
return a.customActionType === customActionType;
|
|
4496
4594
|
}
|
|
4497
|
-
if (actionType === ActionType.APPROVE_CORRECTION || actionType === ActionType.REJECT_CORRECTION) {
|
|
4498
|
-
return a.type === ActionType.REQUEST_CORRECTION;
|
|
4499
|
-
}
|
|
4500
4595
|
return a.type === actionType;
|
|
4501
4596
|
});
|
|
4502
4597
|
}
|
|
@@ -5650,7 +5745,7 @@ function validateActionFlags(event2, ctx) {
|
|
|
5650
5745
|
const isInherentFlag = (value) => Object.values(InherentFlags).includes(value);
|
|
5651
5746
|
const configuredFlagIds = event2.flags.map((flag2) => flag2.id);
|
|
5652
5747
|
const actionFlagIds = event2.actions.flatMap(
|
|
5653
|
-
(action) => action.flags.map((flag2) => flag2.id)
|
|
5748
|
+
(action) => (action.flags ?? []).map((flag2) => flag2.id)
|
|
5654
5749
|
);
|
|
5655
5750
|
for (const actionFlagId of actionFlagIds) {
|
|
5656
5751
|
const isConfigured = configuredFlagIds.includes(actionFlagId);
|
|
@@ -6531,6 +6626,10 @@ function getActionUpdateMetadata(actions) {
|
|
|
6531
6626
|
}
|
|
6532
6627
|
function getLegalStatuses(actions) {
|
|
6533
6628
|
return {
|
|
6629
|
+
[EventStatus.enum.NOTIFIED]: getDeclarationActionCreationMetadata(
|
|
6630
|
+
ActionType.NOTIFY,
|
|
6631
|
+
actions
|
|
6632
|
+
),
|
|
6534
6633
|
[EventStatus.enum.DECLARED]: getDeclarationActionCreationMetadata(
|
|
6535
6634
|
ActionType.DECLARE,
|
|
6536
6635
|
actions
|
|
@@ -6689,7 +6788,7 @@ function resolveEventCustomFlags(event2, eventConfiguration) {
|
|
|
6689
6788
|
const declaration = aggregateActionDeclarations(eventUpToThisAction);
|
|
6690
6789
|
const annotation = aggregateActionAnnotations(eventUpToThisAction);
|
|
6691
6790
|
const form = { ...declaration, ...annotation };
|
|
6692
|
-
const flagsWithMetConditions = actionConfig.flags.filter(
|
|
6791
|
+
const flagsWithMetConditions = (actionConfig.flags ?? []).filter(
|
|
6693
6792
|
({ conditional }) => (
|
|
6694
6793
|
// If conditional is not provided, the flag is resolved
|
|
6695
6794
|
conditional ? isFlagConditionMet(conditional, form, action) : true
|
|
@@ -10346,6 +10445,25 @@ function canAccessEventWithScope(event2, scope, user2, customActionType) {
|
|
|
10346
10445
|
}
|
|
10347
10446
|
if (scopeUsesDeclaredOptions(scope)) {
|
|
10348
10447
|
const { options } = scope;
|
|
10448
|
+
if (options?.notifiedBy === UserFilter.enum.user) {
|
|
10449
|
+
if (event2.legalStatuses?.NOTIFIED?.createdBy !== user2.id) {
|
|
10450
|
+
return false;
|
|
10451
|
+
}
|
|
10452
|
+
}
|
|
10453
|
+
if (options?.notifiedIn === JurisdictionFilter.enum.location && !matchesJurisdictionFilter(
|
|
10454
|
+
event2.legalStatuses?.NOTIFIED?.createdAtLocation,
|
|
10455
|
+
JurisdictionFilter.enum.location,
|
|
10456
|
+
user2
|
|
10457
|
+
)) {
|
|
10458
|
+
return false;
|
|
10459
|
+
}
|
|
10460
|
+
if (options?.notifiedIn === JurisdictionFilter.enum.administrativeArea && !matchesJurisdictionFilter(
|
|
10461
|
+
event2.legalStatuses?.NOTIFIED?.createdAtLocation,
|
|
10462
|
+
JurisdictionFilter.enum.administrativeArea,
|
|
10463
|
+
user2
|
|
10464
|
+
)) {
|
|
10465
|
+
return false;
|
|
10466
|
+
}
|
|
10349
10467
|
if (options?.declaredBy === UserFilter.enum.user) {
|
|
10350
10468
|
if (event2.legalStatuses?.DECLARED?.createdBy !== user2.id) {
|
|
10351
10469
|
return false;
|