@opencrvs/toolkit 2.0.0-rc.22faee8 → 2.0.0-rc.23284a8
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/create-countryconfig/index.js +73 -0
- package/create-countryconfig/package.json +11 -0
- package/dist/application-config/index.js +63 -32
- package/dist/cli.js +1860 -346
- package/dist/commons/api/router.d.ts +3036 -292
- package/dist/commons/application-config/index.d.ts +16 -4
- package/dist/commons/conditionals/conditionals.d.ts +6 -6
- package/dist/commons/conditionals/validate.d.ts +1 -0
- package/dist/commons/events/ActionInput.d.ts +108 -0
- package/dist/commons/events/AuditLog.d.ts +2 -0
- package/dist/commons/events/Draft.d.ts +3 -0
- package/dist/commons/events/FieldConfig.d.ts +10 -0
- package/dist/commons/events/locations.d.ts +38 -1
- package/dist/commons/events/mocks.test.utils.d.ts +19 -0
- package/dist/commons/events/scopes.d.ts +24 -1
- package/dist/commons/events/utils.d.ts +1 -1
- package/dist/commons/notification/UserNotifications.d.ts +15 -0
- package/dist/conditionals/index.js +37 -7
- package/dist/events/index.js +173 -46
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +1 -1
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +63 -39
- package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +3 -0
- package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +1 -0
- package/dist/migrations/v2.0/add-resend-invite-notification.js +373 -0
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts +19 -0
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
- package/dist/migrations/v2.0/checkout-upstream-files.js +17 -14
- package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -1
- package/dist/migrations/v2.0/convert-config-files-to-ts.js +4 -5
- package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +1 -1
- package/dist/migrations/v2.0/convert-paragraph-to-heading.js +4 -5
- package/dist/migrations/v2.0/create-events-index.d.ts.map +1 -1
- package/dist/migrations/v2.0/create-events-index.js +1 -2
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +11 -0
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -0
- package/dist/migrations/v2.0/delete-infrastructure-directory.js +123 -0
- package/dist/migrations/v2.0/index.d.ts +10 -4
- package/dist/migrations/v2.0/index.d.ts.map +1 -1
- package/dist/migrations/v2.0/index.js +1828 -343
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -1
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +95 -7
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +13 -0
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -0
- package/dist/migrations/v2.0/merge-infrastructure-directory.js +222 -0
- package/dist/migrations/v2.0/migrate-application-config-url.d.ts +3 -0
- package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +1 -0
- package/dist/migrations/v2.0/migrate-application-config-url.js +342 -0
- package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-scopes.js +55 -32
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +3 -4
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-workqueue-configs.js +143 -63
- package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-delete-actions.js +3 -4
- package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-demo-scope.js +2 -3
- package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-deprecated-imports.js +3 -4
- package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +3 -0
- package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-fhir-url-helpers.js +163 -0
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-hearth-migrations.js +1 -2
- package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +3 -0
- package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-old-statistics-service.js +356 -0
- package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-pending-certification-flag.js +3 -4
- package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-review-from-register-action.js +3 -4
- package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +3 -0
- package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-unused-environment-variables.js +186 -0
- package/dist/migrations/v2.0/rename-api-paths.d.ts.map +1 -1
- package/dist/migrations/v2.0/rename-api-paths.js +3 -4
- package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +1 -1
- package/dist/migrations/v2.0/rename-location-parent-id.js +3 -4
- package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +1 -1
- package/dist/migrations/v2.0/simplify-analytics-precalculations.js +1 -2
- package/dist/migrations/v2.0/update-package-json.d.ts +3 -0
- package/dist/migrations/v2.0/update-package-json.d.ts.map +1 -0
- package/dist/migrations/v2.0/update-package-json.js +105 -0
- package/dist/notification/index.js +72 -32
- package/dist/scopes/index.d.ts +87 -10
- package/dist/scopes/index.js +43 -8
- package/opencrvs-toolkit-2.0.0-rc.23284a8.tgz +0 -0
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/opencrvs-toolkit-2.0.0-rc.22faee8.tgz +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
5
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
6
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
7
|
+
*
|
|
8
|
+
* OpenCRVS is also distributed under the terms of the Civil Registration
|
|
9
|
+
* & Healthcare Disclaimer located at http://opencrvs.org/license.
|
|
10
|
+
*
|
|
11
|
+
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const { execSync } = require('child_process')
|
|
15
|
+
const path = require('path')
|
|
16
|
+
const fs = require('fs')
|
|
17
|
+
|
|
18
|
+
const REPO_URL = 'https://github.com/opencrvs/opencrvs-countryconfig.git'
|
|
19
|
+
|
|
20
|
+
const projectName = process.argv[2]
|
|
21
|
+
|
|
22
|
+
if (!projectName) {
|
|
23
|
+
console.error(
|
|
24
|
+
'Please specify a project name:\n\n npm create @opencrvs/countryconfig <project-name>\n'
|
|
25
|
+
)
|
|
26
|
+
process.exit(1)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const targetDir = path.resolve(process.cwd(), projectName)
|
|
30
|
+
|
|
31
|
+
if (fs.existsSync(targetDir)) {
|
|
32
|
+
console.error(`Error: Directory "${projectName}" already exists.`)
|
|
33
|
+
process.exit(1)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
console.log(`\nScaffolding OpenCRVS country config in ./${projectName}...\n`)
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
execSync(`git clone --depth 1 ${REPO_URL} ${projectName}`, {
|
|
40
|
+
stdio: 'inherit'
|
|
41
|
+
})
|
|
42
|
+
} catch (err) {
|
|
43
|
+
console.error('Failed to clone the repository:', err.message)
|
|
44
|
+
process.exit(1)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
fs.rmSync(path.join(targetDir, '.git'), { recursive: true, force: true })
|
|
49
|
+
} catch (err) {
|
|
50
|
+
console.error('Failed to remove .git directory:', err.message)
|
|
51
|
+
process.exit(1)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const pkgPath = path.join(targetDir, 'package.json')
|
|
55
|
+
if (fs.existsSync(pkgPath)) {
|
|
56
|
+
try {
|
|
57
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))
|
|
58
|
+
pkg.name = projectName
|
|
59
|
+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n')
|
|
60
|
+
} catch (err) {
|
|
61
|
+
console.error('Failed to update package.json:', err.message)
|
|
62
|
+
process.exit(1)
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
console.warn(
|
|
66
|
+
`Warning: No package.json found in the cloned repository. Project name was not updated.`
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
console.log(`\nDone! To get started:\n`)
|
|
71
|
+
console.log(` cd ${projectName}`)
|
|
72
|
+
console.log(` git init`)
|
|
73
|
+
console.log(` npm install\n`)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@opencrvs/create-countryconfig",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Scaffold a new OpenCRVS country configuration",
|
|
5
|
+
"bin": {
|
|
6
|
+
"create-countryconfig": "./index.js"
|
|
7
|
+
},
|
|
8
|
+
"files": ["index.js"],
|
|
9
|
+
"keywords": ["opencrvs", "countryconfig", "create"],
|
|
10
|
+
"license": "MPL-2.0"
|
|
11
|
+
}
|
|
@@ -75,7 +75,10 @@ var ActionConditional = z.discriminatedUnion("type", [
|
|
|
75
75
|
ShowConditional,
|
|
76
76
|
// Action can be shown to the user in the list but as disabled
|
|
77
77
|
EnableConditional
|
|
78
|
-
])
|
|
78
|
+
]).meta({
|
|
79
|
+
description: "Action conditional configuration",
|
|
80
|
+
id: "ActionConditional"
|
|
81
|
+
});
|
|
79
82
|
var DisplayOnReviewConditional = z.object({
|
|
80
83
|
type: z.literal(ConditionalType.DISPLAY_ON_REVIEW),
|
|
81
84
|
conditional: Conditional
|
|
@@ -418,28 +421,20 @@ function schemaPriority(schema) {
|
|
|
418
421
|
return idx === -1 ? 9999 : idx;
|
|
419
422
|
}
|
|
420
423
|
function safeUnion(schemas) {
|
|
424
|
+
const sortedSchemas = [...schemas].sort(
|
|
425
|
+
(a, b) => schemaPriority(a) - schemaPriority(b)
|
|
426
|
+
);
|
|
421
427
|
return z7.any().superRefine((val, ctx) => {
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
if (successful.length === 0) {
|
|
427
|
-
ctx.addIssue({
|
|
428
|
-
code: "invalid_type",
|
|
429
|
-
expected: "custom",
|
|
430
|
-
message: "Value does not match any schema"
|
|
431
|
-
});
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
successful.sort((a, b) => schemaPriority(a) - schemaPriority(b));
|
|
435
|
-
const best = successful[0];
|
|
436
|
-
if (!best.safeParse(val).success) {
|
|
437
|
-
ctx.addIssue({
|
|
438
|
-
expected: "custom",
|
|
439
|
-
code: "invalid_type",
|
|
440
|
-
message: "Value did not match the best schema"
|
|
441
|
-
});
|
|
428
|
+
for (const schema of sortedSchemas) {
|
|
429
|
+
if (schema.safeParse(val).success) {
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
442
432
|
}
|
|
433
|
+
ctx.addIssue({
|
|
434
|
+
code: "invalid_type",
|
|
435
|
+
expected: "custom",
|
|
436
|
+
message: "Value does not match any schema"
|
|
437
|
+
});
|
|
443
438
|
}).meta({
|
|
444
439
|
description: "Value that matches exactly one of the possible schema types (TextValue, DateValue, DateRangeFieldValue). The best matching schema is chosen by priority."
|
|
445
440
|
});
|
|
@@ -656,6 +651,10 @@ var scopeByEvent = z11.preprocess(
|
|
|
656
651
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
657
652
|
z11.array(z11.string()).optional()
|
|
658
653
|
).describe("Event type, e.g. birth, death");
|
|
654
|
+
var userRole = z11.preprocess(
|
|
655
|
+
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
656
|
+
z11.array(z11.string()).optional()
|
|
657
|
+
).describe("User role, e.g. admin, field agent");
|
|
659
658
|
var scopeOptionsPlaceEvent = z11.object({
|
|
660
659
|
event: scopeByEvent,
|
|
661
660
|
placeOfEvent: JurisdictionFilter.optional()
|
|
@@ -679,6 +678,9 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
|
679
678
|
var AccessLevelOptions = z11.object({
|
|
680
679
|
accessLevel: JurisdictionFilter.optional()
|
|
681
680
|
});
|
|
681
|
+
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
682
|
+
role: userRole.optional()
|
|
683
|
+
});
|
|
682
684
|
var WorkqueueOrDashboardOptions = z11.object({
|
|
683
685
|
ids: z11.preprocess(
|
|
684
686
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
@@ -688,6 +690,7 @@ var WorkqueueOrDashboardOptions = z11.object({
|
|
|
688
690
|
var AllScopeOptions = z11.object({
|
|
689
691
|
...AllRecordScopeOptions.shape,
|
|
690
692
|
...AccessLevelOptions.shape,
|
|
693
|
+
...AllUserScopeOptions.shape,
|
|
691
694
|
...WorkqueueOrDashboardOptions.shape
|
|
692
695
|
});
|
|
693
696
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
@@ -760,6 +763,30 @@ var RecordScopeV2 = z11.discriminatedUnion("type", [
|
|
|
760
763
|
]).describe(
|
|
761
764
|
"Scopes used to check user's permission to perform actions on a record."
|
|
762
765
|
);
|
|
766
|
+
var SystemScopeType = z11.enum([
|
|
767
|
+
"organisation.read-locations",
|
|
768
|
+
"user.read",
|
|
769
|
+
"user.create",
|
|
770
|
+
"user.edit",
|
|
771
|
+
"user.search"
|
|
772
|
+
]);
|
|
773
|
+
var UserScopeType = SystemScopeType.extract([
|
|
774
|
+
"user.read",
|
|
775
|
+
"user.create",
|
|
776
|
+
"user.edit",
|
|
777
|
+
"user.search"
|
|
778
|
+
]);
|
|
779
|
+
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
780
|
+
var UserScopeV2 = z11.discriminatedUnion("type", [
|
|
781
|
+
z11.object({
|
|
782
|
+
type: ScopesWithRoleOption,
|
|
783
|
+
options: AllUserScopeOptions.optional()
|
|
784
|
+
}),
|
|
785
|
+
z11.object({
|
|
786
|
+
type: UserScopeType.extract(["user.read", "user.search"]),
|
|
787
|
+
options: AccessLevelOptions.optional()
|
|
788
|
+
})
|
|
789
|
+
]);
|
|
763
790
|
var ResolvedRecordScopeV2 = z11.discriminatedUnion("type", [
|
|
764
791
|
z11.object({
|
|
765
792
|
type: ScopesWithPlaceEventOptions,
|
|
@@ -780,16 +807,14 @@ var ResolvedRecordScopeV2 = z11.discriminatedUnion("type", [
|
|
|
780
807
|
}).optional()
|
|
781
808
|
})
|
|
782
809
|
]).describe("Resolved scope with location/user IDs instead of filters.");
|
|
783
|
-
var SystemScopeType = z11.enum([
|
|
784
|
-
"organisation.read-locations",
|
|
785
|
-
"user.read",
|
|
786
|
-
"user.create",
|
|
787
|
-
"user.edit"
|
|
788
|
-
]);
|
|
789
810
|
var Scope = z11.discriminatedUnion("type", [
|
|
790
811
|
z11.object({ type: PlainScopeType }),
|
|
791
812
|
...RecordScopeV2.options,
|
|
792
|
-
|
|
813
|
+
...UserScopeV2.options,
|
|
814
|
+
z11.object({
|
|
815
|
+
type: z11.literal("organisation.read-locations"),
|
|
816
|
+
options: AccessLevelOptions.optional()
|
|
817
|
+
}),
|
|
793
818
|
z11.object({
|
|
794
819
|
type: z11.literal("workqueue"),
|
|
795
820
|
options: WorkqueueOrDashboardOptions
|
|
@@ -1055,6 +1080,9 @@ var FlagConfig = z14.object({
|
|
|
1055
1080
|
"Indicates if this flag expects an action to be performed to be cleared."
|
|
1056
1081
|
),
|
|
1057
1082
|
label: TranslationConfig.describe("Human readable label of the flag.")
|
|
1083
|
+
}).meta({
|
|
1084
|
+
description: "Flag configuration",
|
|
1085
|
+
id: "FlagConfig"
|
|
1058
1086
|
});
|
|
1059
1087
|
var ActionFlagConfig = z14.object({
|
|
1060
1088
|
id: Flag,
|
|
@@ -1062,6 +1090,9 @@ var ActionFlagConfig = z14.object({
|
|
|
1062
1090
|
conditional: Conditional.optional().describe(
|
|
1063
1091
|
"When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
|
|
1064
1092
|
)
|
|
1093
|
+
}).meta({
|
|
1094
|
+
description: "Action flag configuration",
|
|
1095
|
+
id: "ActionFlagConfig"
|
|
1065
1096
|
});
|
|
1066
1097
|
|
|
1067
1098
|
// ../commons/src/events/EventMetadata.ts
|
|
@@ -2078,8 +2109,8 @@ var ApplicationConfig = z20.object({
|
|
|
2078
2109
|
})
|
|
2079
2110
|
),
|
|
2080
2111
|
PHONE_NUMBER_PATTERN: z20.string().or(z20.instanceof(RegExp)),
|
|
2081
|
-
USER_NOTIFICATION_DELIVERY_METHOD: z20.
|
|
2082
|
-
INFORMANT_NOTIFICATION_DELIVERY_METHOD: z20.
|
|
2112
|
+
USER_NOTIFICATION_DELIVERY_METHOD: z20.enum(["email", "sms"]),
|
|
2113
|
+
INFORMANT_NOTIFICATION_DELIVERY_METHOD: z20.enum(["email", "sms"]),
|
|
2083
2114
|
SEARCH_DEFAULT_CRITERIA: SearchCriteria.optional().default("TRACKING_ID"),
|
|
2084
2115
|
ADDITIONAL_USER_FIELDS: z20.array(FieldConfig).optional().default([])
|
|
2085
2116
|
});
|
|
@@ -2097,8 +2128,8 @@ var BackgroundConfig = z20.object({
|
|
|
2097
2128
|
var LoginConfig = z20.object({
|
|
2098
2129
|
COUNTRY: z20.string(),
|
|
2099
2130
|
LANGUAGES: z20.array(z20.string()),
|
|
2100
|
-
USER_NOTIFICATION_DELIVERY_METHOD: z20.
|
|
2101
|
-
INFORMANT_NOTIFICATION_DELIVERY_METHOD: z20.
|
|
2131
|
+
USER_NOTIFICATION_DELIVERY_METHOD: z20.enum(["email", "sms"]),
|
|
2132
|
+
INFORMANT_NOTIFICATION_DELIVERY_METHOD: z20.enum(["email", "sms"]),
|
|
2102
2133
|
PHONE_NUMBER_PATTERN: z20.string().or(z20.instanceof(RegExp)),
|
|
2103
2134
|
LOGIN_BACKGROUND: BackgroundConfig,
|
|
2104
2135
|
SENTRY: z20.string().optional()
|