@opencrvs/toolkit 2.1.0-rc.1f688f9 → 2.1.0-rc.268cfbe
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/README.md +2 -12
- package/build.sh +20 -5
- package/create-countryconfig/index.js +164 -4
- package/dist/application-config/index.js +36 -25
- package/dist/authentication/index.d.ts +66 -0
- package/dist/authentication/index.d.ts.map +1 -0
- package/dist/authentication/index.js +765 -0
- package/dist/cli.js +2829 -1294
- package/dist/commons/api/router.d.ts +252 -290
- package/dist/commons/application-config/index.d.ts +0 -2
- package/dist/commons/conditionals/conditionals.d.ts +6 -6
- package/dist/commons/conditionals/validate.d.ts +19 -4
- package/dist/commons/events/ActionConfig.d.ts +5 -14
- package/dist/commons/events/ActionDocument.d.ts +30 -4
- package/dist/commons/events/AdvancedSearchConfig.d.ts +24 -12
- package/dist/commons/events/AuditLog.d.ts +1 -0
- package/dist/commons/events/Draft.d.ts +1 -21
- package/dist/commons/events/EventDocument.d.ts +4 -4
- package/dist/commons/events/FieldConfig.d.ts +26 -15
- package/dist/commons/events/FieldTypeMapping.d.ts +10 -10
- package/dist/commons/events/FieldValue.d.ts +1 -0
- package/dist/commons/events/FormConfig.d.ts +6 -0
- package/dist/commons/events/PageConfig.d.ts +4 -0
- package/dist/commons/events/locations.d.ts +4 -0
- package/dist/commons/events/scopes.d.ts +21 -1
- package/dist/commons/events/test.utils.d.ts +71 -22
- package/dist/commons/events/utils.d.ts +37 -2
- package/dist/commons/notification/dispatch.d.ts +1 -6
- package/dist/conditionals/index.js +21 -7
- package/dist/csv.d.ts +25 -0
- package/dist/csv.d.ts.map +1 -0
- package/dist/csv.js +120 -0
- package/dist/environment/index.d.ts.map +1 -1
- package/dist/environment/index.js +2 -1
- package/dist/environment/logger.d.ts +3 -0
- package/dist/environment/logger.d.ts.map +1 -1
- package/dist/environment/manage-users.js +1 -1
- package/dist/environment/setup-environment.d.ts +1 -1
- package/dist/environment/setup-environment.d.ts.map +1 -1
- package/dist/environment/setup-environment.js +593 -562
- package/dist/environment/swarm-to-k8s.js +3 -4
- package/dist/environment/templates.d.ts +0 -1
- package/dist/environment/templates.d.ts.map +1 -1
- package/dist/environment/templates.js +3 -8
- package/dist/environment/update-workflows.d.ts.map +1 -1
- package/dist/environment/update-workflows.js +4 -0
- package/dist/environment/utils.d.ts +0 -12
- package/dist/environment/utils.d.ts.map +1 -1
- package/dist/environment/utils.js +1 -28
- package/dist/events/index.js +2115 -1884
- package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -1
- package/dist/migrations/v2.1/add-recovery-link-notifications.js +13 -32
- package/dist/migrations/v2.1/add-translations.d.ts +9 -0
- package/dist/migrations/v2.1/add-translations.d.ts.map +1 -0
- package/dist/migrations/v2.1/add-translations.js +149 -0
- package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -1
- package/dist/migrations/v2.1/enable-telemetry.js +32 -15
- package/dist/migrations/v2.1/index.d.ts.map +1 -1
- package/dist/migrations/v2.1/index.js +1160 -70
- package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +14 -0
- package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +1 -0
- package/dist/migrations/v2.1/migrate-infrastructure-to-assets.js +345 -0
- package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +2 -0
- package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +1 -0
- package/dist/migrations/v2.1/remove-metabase-package-installs.js +161 -0
- package/dist/migrations/{v2.0/migrate-scopes.d.ts → v2.1/remove-sentry.d.ts} +1 -1
- package/dist/migrations/v2.1/remove-sentry.d.ts.map +1 -0
- package/dist/migrations/v2.1/remove-sentry.js +354 -0
- package/dist/migrations/{v2.0/rename-api-paths.d.ts → v2.1/rename-trigger-paths.d.ts} +1 -1
- package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +1 -0
- package/dist/migrations/{v2.0/rename-api-paths.js → v2.1/rename-trigger-paths.js} +69 -40
- package/dist/migrations/v2.1/template-files.d.ts +8 -0
- package/dist/migrations/v2.1/template-files.d.ts.map +1 -0
- package/dist/migrations/v2.1/template-files.js +49 -0
- package/dist/migrations/v2.1/upgrade-tilt.d.ts +8 -0
- package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +1 -0
- package/dist/migrations/v2.1/upgrade-tilt.js +139 -0
- package/dist/notification/index.js +249 -207
- package/dist/scopes/index.d.ts +288 -5
- package/dist/scopes/index.js +22 -7
- package/dist/telemetry/index.js +5 -1
- package/dist/templates/charts-values/dependencies/values.yaml +8 -0
- package/dist/templates/charts-values/opencrvs-services/values.yaml +6 -0
- package/dist/templates/charts-values/opentelemetry/values.yaml +7 -0
- package/dist/templates/countryconfig-template/.tiltignore +1 -0
- package/dist/templates/countryconfig-template/Dockerfile.assets +7 -0
- package/dist/templates/countryconfig-template/Tiltfile +112 -0
- package/dist/templates/countryconfig-template/assets/README.md +1 -0
- package/dist/templates/countryconfig-template/assets/clear-all-data-dev.sh +61 -0
- package/dist/templates/countryconfig-template/assets/deployment/deploy.sh +455 -0
- package/dist/templates/countryconfig-template/assets/deployment/reindex.sh +168 -0
- package/dist/templates/countryconfig-template/assets/deployment/validate-required-variables-in-compose-files.ts +67 -0
- package/dist/templates/countryconfig-template/assets/elasticsearch/reindex.sh +168 -0
- package/dist/templates/countryconfig-template/assets/metabase/README.md +34 -0
- package/dist/templates/countryconfig-template/assets/metabase/environment-configuration.sql +36 -0
- package/dist/templates/countryconfig-template/assets/metabase/initialize-database.sh +46 -0
- package/dist/templates/countryconfig-template/assets/metabase/metabase.init.db.sql +27737 -0
- package/dist/templates/countryconfig-template/assets/metabase/open-shell.sh +21 -0
- package/dist/templates/countryconfig-template/assets/metabase/package.json +13 -0
- package/dist/templates/countryconfig-template/assets/metabase/run-dev.sh +108 -0
- package/dist/templates/countryconfig-template/assets/metabase/run.sh +120 -0
- package/dist/templates/countryconfig-template/assets/metabase/update-database.sh +40 -0
- package/dist/templates/countryconfig-template/assets/postgres/setup-analytics.sh +135 -0
- package/dist/templates/countryconfig-template/assets/postgres/setup-reference-data.sh +108 -0
- package/dist/templates/countryconfig-template/tilt/clear-all-data.ps1 +50 -0
- package/dist/templates/countryconfig-template/tilt/clear-all-data.sh +35 -0
- package/dist/templates/countryconfig-template/tilt/common.tilt +145 -0
- package/dist/templates/countryconfig-template/tilt/examples/dependencies/values.yaml +15 -0
- package/dist/templates/countryconfig-template/tilt/examples/opencrvs-services/values.yaml +56 -0
- package/dist/templates/countryconfig-template/tilt/examples/traefik/values-minikube.yaml +21 -0
- package/dist/templates/countryconfig-template/tilt/examples/traefik/values.yaml +38 -0
- package/dist/templates/countryconfig-template/tilt/helm/dependencies/values.yaml +17 -0
- package/dist/templates/countryconfig-template/tilt/helm/opencrvs-services/values.yaml +16 -0
- package/dist/templates/countryconfig-template/tilt/lib.tilt +95 -0
- package/dist/templates/countryconfig-template/tilt/opencrvs.tilt +136 -0
- package/dist/translations/template.d.ts +11 -0
- package/dist/translations/template.d.ts.map +1 -0
- package/dist/translations/template.js +100 -0
- package/dist/verify/endpoints.d.ts +2 -0
- package/dist/verify/endpoints.d.ts.map +1 -0
- package/dist/verify/endpoints.js +510 -0
- package/opencrvs-toolkit-2.1.0-rc.268cfbe.tgz +0 -0
- package/package.json +9 -4
- package/tsconfig.build.json +11 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +3 -0
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts +0 -3
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +0 -1
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +0 -429
- package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +0 -3
- package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +0 -1
- package/dist/migrations/v2.0/add-resend-invite-notification.js +0 -373
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts +0 -22
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +0 -1
- package/dist/migrations/v2.0/checkout-upstream-files.js +0 -146
- package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts +0 -2
- package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +0 -1
- package/dist/migrations/v2.0/convert-config-files-to-ts.js +0 -838
- package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts +0 -3
- package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +0 -1
- package/dist/migrations/v2.0/convert-paragraph-to-heading.js +0 -158
- package/dist/migrations/v2.0/create-events-index.d.ts +0 -3
- package/dist/migrations/v2.0/create-events-index.d.ts.map +0 -1
- package/dist/migrations/v2.0/create-events-index.js +0 -325
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +0 -11
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +0 -1
- package/dist/migrations/v2.0/delete-infrastructure-directory.js +0 -123
- package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts +0 -3
- package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts.map +0 -1
- package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.js +0 -110
- package/dist/migrations/v2.0/index.d.ts +0 -13
- package/dist/migrations/v2.0/index.d.ts.map +0 -1
- package/dist/migrations/v2.0/index.js +0 -103
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts +0 -3
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +0 -1
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +0 -432
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +0 -13
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +0 -1
- package/dist/migrations/v2.0/merge-infrastructure-directory.js +0 -222
- package/dist/migrations/v2.0/migrate-application-config-url.d.ts +0 -3
- package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +0 -1
- package/dist/migrations/v2.0/migrate-application-config-url.js +0 -343
- package/dist/migrations/v2.0/migrate-scopes.d.ts.map +0 -1
- package/dist/migrations/v2.0/migrate-scopes.js +0 -305
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts +0 -3
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +0 -1
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +0 -267
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts +0 -3
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +0 -1
- package/dist/migrations/v2.0/migrate-workqueue-configs.js +0 -317
- package/dist/migrations/v2.0/remove-delete-actions.d.ts +0 -3
- package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-delete-actions.js +0 -156
- package/dist/migrations/v2.0/remove-demo-scope.d.ts +0 -3
- package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-demo-scope.js +0 -74
- package/dist/migrations/v2.0/remove-deprecated-imports.d.ts +0 -3
- package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-deprecated-imports.js +0 -96
- package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +0 -3
- package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-fhir-url-helpers.js +0 -163
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts +0 -3
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-hearth-migrations.js +0 -87
- package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +0 -3
- package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-old-statistics-service.js +0 -356
- package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts +0 -3
- package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-pending-certification-flag.js +0 -109
- package/dist/migrations/v2.0/remove-review-from-register-action.d.ts +0 -3
- package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-review-from-register-action.js +0 -163
- package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +0 -3
- package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-unused-environment-variables.js +0 -186
- package/dist/migrations/v2.0/rename-api-paths.d.ts.map +0 -1
- package/dist/migrations/v2.0/rename-location-parent-id.d.ts +0 -3
- package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +0 -1
- package/dist/migrations/v2.0/rename-location-parent-id.js +0 -180
- package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts +0 -3
- package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +0 -1
- package/dist/migrations/v2.0/simplify-analytics-precalculations.js +0 -195
- package/dist/migrations/v2.0/update-package-json.d.ts +0 -3
- package/dist/migrations/v2.0/update-package-json.d.ts.map +0 -1
- package/dist/migrations/v2.0/update-package-json.js +0 -105
- package/opencrvs-toolkit-2.1.0-rc.1f688f9.tgz +0 -0
- package/tsconfig.tsbuildinfo +0 -1
package/README.md
CHANGED
|
@@ -55,19 +55,9 @@ Toolkit "re-exports" TRPC router to allow for easy client interaction.
|
|
|
55
55
|
|
|
56
56
|
Toolkit "re-exports" common definitions (e.g. events, conditionals) and make them available through npm.
|
|
57
57
|
|
|
58
|
-
###
|
|
58
|
+
### Publishing
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
1. Update version number in `package.json`
|
|
63
|
-
2. `yarn build:all`
|
|
64
|
-
3. `npm publish`
|
|
65
|
-
|
|
66
|
-
#### Through version control
|
|
67
|
-
|
|
68
|
-
1. Update version number in `package.json`
|
|
69
|
-
2. Create a pull request
|
|
70
|
-
3. Once merged, github action will get triggered.
|
|
60
|
+
Publish via [Publish toolkit to NPM registry](https://github.com/opencrvs/opencrvs-core/actions/workflows/publish-toolkit-to-npm.yml).
|
|
71
61
|
|
|
72
62
|
#### Gotchas, good to know
|
|
73
63
|
|
package/build.sh
CHANGED
|
@@ -13,13 +13,14 @@ set -e
|
|
|
13
13
|
|
|
14
14
|
rm -rf dist
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
# tsconfig.build.json excludes the test files, which dist publishes otherwise.
|
|
17
|
+
npx tsc --build tsconfig.build.json
|
|
17
18
|
|
|
18
19
|
# Build common events
|
|
19
20
|
npx esbuild src/events/index.ts --bundle --format=cjs --outdir=./dist/events --allow-overwrite --packages=external
|
|
20
21
|
|
|
21
22
|
# Build telemetry client (self-contained; .d.ts comes from tsc --build above)
|
|
22
|
-
npx esbuild src/telemetry/index.ts --bundle --format=cjs --outdir=./dist/telemetry --allow-overwrite --packages=external
|
|
23
|
+
npx esbuild src/telemetry/index.ts --bundle --platform=node --format=cjs --outdir=./dist/telemetry --allow-overwrite --packages=external
|
|
23
24
|
mkdir -p ./dist/commons/events
|
|
24
25
|
cp -r ../commons/build/dist/common/events/*.d.ts ./dist/commons/events
|
|
25
26
|
mkdir -p ./dist/commons/events/state
|
|
@@ -34,6 +35,10 @@ cp -r ../commons/build/dist/common/conditionals/*.d.ts ./dist/commons/conditiona
|
|
|
34
35
|
npx esbuild src/scopes/index.ts --bundle --format=cjs --outdir=./dist/scopes --allow-overwrite --packages=external
|
|
35
36
|
cp -r ../commons/build/dist/common/scopes.d.ts ./dist/scopes/index.d.ts
|
|
36
37
|
|
|
38
|
+
# Build common authentication
|
|
39
|
+
npx esbuild src/authentication/index.ts --bundle --format=cjs --outdir=./dist/authentication --allow-overwrite --packages=external
|
|
40
|
+
cp -r ../commons/build/dist/common/authentication.d.ts ./dist/authentication/index.d.ts
|
|
41
|
+
|
|
37
42
|
# Build api client
|
|
38
43
|
npx esbuild src/api/index.ts --bundle --format=cjs --outdir=./dist/api --allow-overwrite --packages=external
|
|
39
44
|
mkdir -p ./dist/commons/api
|
|
@@ -44,7 +49,7 @@ npx esbuild src/events/deduplication.ts --bundle --format=cjs --outdir=./dist/ev
|
|
|
44
49
|
cp -r ../commons/build/dist/common/events/deduplication.d.ts ./dist/events/deduplication.d.ts
|
|
45
50
|
|
|
46
51
|
# Build common notifications
|
|
47
|
-
npx esbuild src/notification/index.ts --bundle --format=cjs --outdir=./dist/notification --allow-overwrite --packages=external
|
|
52
|
+
npx esbuild src/notification/index.ts --bundle --platform=node --format=cjs --outdir=./dist/notification --allow-overwrite --packages=external
|
|
48
53
|
mkdir -p ./dist/commons/notification
|
|
49
54
|
cp -r ../commons/build/dist/common/notification/*.d.ts ./dist/commons/notification
|
|
50
55
|
|
|
@@ -54,7 +59,7 @@ mkdir -p ./dist/commons/application-config
|
|
|
54
59
|
cp -r ../commons/build/dist/common/application-config.d.ts ./dist/commons/application-config/index.d.ts
|
|
55
60
|
|
|
56
61
|
# Build migration CLI
|
|
57
|
-
npx esbuild src/migrations/v2.1/index.ts --bundle --format=cjs --outdir=./dist/migrations/v2.1 --allow-overwrite --packages=external --banner:js="#!/usr/bin/env node"
|
|
62
|
+
npx esbuild src/migrations/v2.1/index.ts --bundle --platform=node --format=cjs --outdir=./dist/migrations/v2.1 --allow-overwrite --packages=external --banner:js="#!/usr/bin/env node"
|
|
58
63
|
chmod +x ./dist/migrations/v2.1/index.js
|
|
59
64
|
|
|
60
65
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
@@ -66,8 +71,18 @@ else
|
|
|
66
71
|
fi
|
|
67
72
|
|
|
68
73
|
# Build CLI
|
|
69
|
-
npx esbuild src/cli.ts --bundle --format=cjs --outdir=./dist --allow-overwrite --packages=external --banner:js="#!/usr/bin/env node"
|
|
74
|
+
npx esbuild src/cli.ts --bundle --platform=node --format=cjs --outdir=./dist --allow-overwrite --packages=external --banner:js="#!/usr/bin/env node"
|
|
70
75
|
cp -R src/environment/templates dist/templates
|
|
76
|
+
# Template files copied into country configs by the upgrade-tilt and
|
|
77
|
+
# migrate-infrastructure-to-assets codemods. Image builds that use the toolkit as
|
|
78
|
+
# a library (testland, mosip-api) do not copy the template in and do not need them.
|
|
79
|
+
TEMPLATE_DIR=../countryconfig-template
|
|
80
|
+
if [ -d "$TEMPLATE_DIR" ]; then
|
|
81
|
+
mkdir -p dist/templates/countryconfig-template
|
|
82
|
+
cp -R $TEMPLATE_DIR/Tiltfile $TEMPLATE_DIR/.tiltignore $TEMPLATE_DIR/tilt $TEMPLATE_DIR/assets $TEMPLATE_DIR/Dockerfile.assets dist/templates/countryconfig-template/
|
|
83
|
+
else
|
|
84
|
+
echo "$TEMPLATE_DIR not found, 'opencrvs upgrade' will not be able to copy the template files"
|
|
85
|
+
fi
|
|
71
86
|
chmod +x ./dist/cli.js
|
|
72
87
|
|
|
73
88
|
echo "Build completed successfully."
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
const path = require('path')
|
|
15
15
|
const fs = require('fs')
|
|
16
|
+
const { execSync } = require('child_process')
|
|
16
17
|
const readline = require('readline/promises')
|
|
17
18
|
const degit = require('degit').default
|
|
18
19
|
|
|
@@ -21,6 +22,14 @@ const CORE_REPOSITORY = 'opencrvs/opencrvs-core'
|
|
|
21
22
|
const COUNTRYCONFIG_TEMPLATE_REPOSITORY_SUBPATH =
|
|
22
23
|
'packages/countryconfig-template'
|
|
23
24
|
|
|
25
|
+
const CORE_REPO_URL = 'https://github.com/' + CORE_REPOSITORY + '.git'
|
|
26
|
+
const INFRASTRUCTURE_REPO_URL =
|
|
27
|
+
'https://github.com/' + INFRASTRUCTURE_REPOSITORY + '.git'
|
|
28
|
+
|
|
29
|
+
const { version } = JSON.parse(
|
|
30
|
+
fs.readFileSync(path.join(__dirname, 'package.json'), 'utf-8')
|
|
31
|
+
)
|
|
32
|
+
|
|
24
33
|
function joinValues(values, separator) {
|
|
25
34
|
return values
|
|
26
35
|
.filter((value) => !!value)
|
|
@@ -28,19 +37,162 @@ function joinValues(values, separator) {
|
|
|
28
37
|
.trim()
|
|
29
38
|
}
|
|
30
39
|
|
|
40
|
+
function tagExists(repoUrl, tag) {
|
|
41
|
+
try {
|
|
42
|
+
execSync(
|
|
43
|
+
'git ls-remote --exit-code --tags ' + repoUrl + ' refs/tags/' + tag,
|
|
44
|
+
{ stdio: 'pipe' }
|
|
45
|
+
)
|
|
46
|
+
return true
|
|
47
|
+
} catch (err) {
|
|
48
|
+
return false
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function branchExists(repoUrl, branch) {
|
|
53
|
+
try {
|
|
54
|
+
execSync(
|
|
55
|
+
'git ls-remote --exit-code --heads ' + repoUrl + ' refs/heads/' + branch,
|
|
56
|
+
{ stdio: 'pipe' }
|
|
57
|
+
)
|
|
58
|
+
return true
|
|
59
|
+
} catch (err) {
|
|
60
|
+
return false
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Release tags (e.g. "v2.1.0"), highest first. Delegates the version-aware
|
|
66
|
+
* ordering to git itself rather than hand-parsing semver, then filters down
|
|
67
|
+
* to strict "vX.Y.Z" tags - `--sort=-version:refname` alone still leaves in
|
|
68
|
+
* non-release refs (e.g. "vtesting", "v2.0.0-beta") and peeled annotated-tag
|
|
69
|
+
* lines ("refs/tags/v2.0.0^{}").
|
|
70
|
+
*/
|
|
71
|
+
function listReleaseTags(repoUrl) {
|
|
72
|
+
const output = execSync(
|
|
73
|
+
'git ls-remote --tags --sort=-version:refname ' + repoUrl,
|
|
74
|
+
{ encoding: 'utf-8' }
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
return output
|
|
78
|
+
.split('\n')
|
|
79
|
+
.map((line) => line.split('\t')[1])
|
|
80
|
+
.filter(Boolean)
|
|
81
|
+
.map((ref) => ref.replace('refs/tags/', ''))
|
|
82
|
+
.filter((tag) => /^v\d+\.\d+\.\d+$/.test(tag))
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The highest release tag present in *both* repositories - used as the
|
|
87
|
+
* fallback when the version-specific tag can't be found in one or both, so
|
|
88
|
+
* scaffolding still lands on a real, matched release rather than develop.
|
|
89
|
+
*/
|
|
90
|
+
function getLatestCommonReleaseTag() {
|
|
91
|
+
const infrastructureTags = new Set(listReleaseTags(INFRASTRUCTURE_REPO_URL))
|
|
92
|
+
return (
|
|
93
|
+
listReleaseTags(CORE_REPO_URL).find((tag) => infrastructureTags.has(tag)) ||
|
|
94
|
+
null
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Resolves the ref that both repositories are cloned from. A single ref
|
|
100
|
+
* clones both, so every candidate must exist in *both* - a tag present in
|
|
101
|
+
* only one of them can't be used.
|
|
102
|
+
*
|
|
103
|
+
* The exact "v<version>" tag wins whenever it exists: it pins a commit, so
|
|
104
|
+
* a release, an explicit `@X.Y.Z` pin, or a blessed prerelease (npm `@beta`,
|
|
105
|
+
* published from that tag) reproduces however late it's scaffolded.
|
|
106
|
+
*
|
|
107
|
+
* Otherwise a prerelease falls back to a branch, since a rolling release
|
|
108
|
+
* candidate (npm `@next`) is never tagged: "release/X.Y.Z" of the base
|
|
109
|
+
* version when that release has been cut, otherwise develop. A release
|
|
110
|
+
* falls back to the highest tag common to both repositories - never a
|
|
111
|
+
* mismatched pairing of the two at different releases - or errors.
|
|
112
|
+
*/
|
|
113
|
+
function resolveRef() {
|
|
114
|
+
const versionTag = 'v' + version
|
|
115
|
+
if (
|
|
116
|
+
tagExists(CORE_REPO_URL, versionTag) &&
|
|
117
|
+
tagExists(INFRASTRUCTURE_REPO_URL, versionTag)
|
|
118
|
+
) {
|
|
119
|
+
return versionTag
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (version.includes('-')) {
|
|
123
|
+
const releaseBranch = 'release/' + version.split('-')[0]
|
|
124
|
+
if (
|
|
125
|
+
branchExists(CORE_REPO_URL, releaseBranch) &&
|
|
126
|
+
branchExists(INFRASTRUCTURE_REPO_URL, releaseBranch)
|
|
127
|
+
) {
|
|
128
|
+
return releaseBranch
|
|
129
|
+
}
|
|
130
|
+
return 'develop'
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const latestCommonTag = getLatestCommonReleaseTag()
|
|
134
|
+
if (latestCommonTag) {
|
|
135
|
+
console.warn(
|
|
136
|
+
'\nWarning: tag "' +
|
|
137
|
+
versionTag +
|
|
138
|
+
'" was not found in both repositories; falling back to the latest ' +
|
|
139
|
+
'available release, ' +
|
|
140
|
+
latestCommonTag +
|
|
141
|
+
'.'
|
|
142
|
+
)
|
|
143
|
+
return latestCommonTag
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
console.error(
|
|
147
|
+
'\nError: no matching release tag was found in both the core and ' +
|
|
148
|
+
'infrastructure repositories.'
|
|
149
|
+
)
|
|
150
|
+
process.exit(1)
|
|
151
|
+
}
|
|
152
|
+
|
|
31
153
|
/**
|
|
32
154
|
* Clones a repository from GitHub to a target directory.
|
|
33
155
|
*
|
|
34
156
|
* @param {*} param0 repository - The repository to clone (e.g., 'opencrvs/opencrvs-core').
|
|
35
157
|
* @param {*} param0 repositorySubPath - The subpath within the repository to clone (optional). Otherwise the entire repository will be cloned.
|
|
36
158
|
* @param {*} param0 branch - The branch to clone (optional). Defaults to the default branch if not specified.
|
|
159
|
+
* @param {*} param0 keepHistory - Keep the repository's git history instead of degit's usual history-free copy (optional, defaults to false). The cloned "origin" remote is replaced with "upstream", leaving the directory ready for the user to add their own fork/repo as "origin". Not supported together with repositorySubPath, since a plain git clone can't fetch a single subdirectory.
|
|
37
160
|
*
|
|
38
161
|
* @param {*} targetDir - The target directory where the repository will be cloned.
|
|
39
162
|
*/
|
|
40
163
|
async function cloneRepository(
|
|
41
|
-
{ repository, repositorySubPath, branch },
|
|
164
|
+
{ repository, repositorySubPath, branch, keepHistory = false },
|
|
42
165
|
targetDir
|
|
43
166
|
) {
|
|
167
|
+
if (keepHistory && repositorySubPath) {
|
|
168
|
+
throw new Error(
|
|
169
|
+
'cloneRepository: keepHistory is not supported together with repositorySubPath.'
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (keepHistory) {
|
|
174
|
+
const repoUrl = `https://github.com/${repository}.git`
|
|
175
|
+
console.log(
|
|
176
|
+
`Cloning repository from ${repoUrl}#${branch} to ${targetDir}...`
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
execSync('git clone --branch ' + branch + ' ' + repoUrl + ' ' + targetDir, {
|
|
180
|
+
stdio: 'inherit'
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
console.log(
|
|
184
|
+
`Copied files from ${repoUrl}#${branch} to ${targetDir} succesfully.`
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
console.log(`Replacing 'origin' remote with 'upstream' in ${targetDir}...`)
|
|
188
|
+
execSync('git remote remove origin', { cwd: targetDir, stdio: 'inherit' })
|
|
189
|
+
execSync('git remote add upstream ' + repoUrl, {
|
|
190
|
+
cwd: targetDir,
|
|
191
|
+
stdio: 'inherit'
|
|
192
|
+
})
|
|
193
|
+
return
|
|
194
|
+
}
|
|
195
|
+
|
|
44
196
|
const repositoryPath = joinValues([repository, repositorySubPath], '/')
|
|
45
197
|
const fullPath = joinValues([repositoryPath, branch], '#')
|
|
46
198
|
|
|
@@ -271,6 +423,8 @@ async function main() {
|
|
|
271
423
|
ensureTargetDirectoryDoesNotExist(countryconfigDirName)
|
|
272
424
|
ensureTargetDirectoryDoesNotExist(infrastructureDirName)
|
|
273
425
|
|
|
426
|
+
const ref = resolveRef()
|
|
427
|
+
|
|
274
428
|
// Gather all answers up front so the operator isn't interrupted mid-clone.
|
|
275
429
|
const organisation = await promptOrganisation()
|
|
276
430
|
const countryCode = await promptCountryCode()
|
|
@@ -280,7 +434,8 @@ async function main() {
|
|
|
280
434
|
await cloneRepository(
|
|
281
435
|
{
|
|
282
436
|
repository: CORE_REPOSITORY,
|
|
283
|
-
repositorySubPath: COUNTRYCONFIG_TEMPLATE_REPOSITORY_SUBPATH
|
|
437
|
+
repositorySubPath: COUNTRYCONFIG_TEMPLATE_REPOSITORY_SUBPATH,
|
|
438
|
+
branch: ref
|
|
284
439
|
},
|
|
285
440
|
countryconfigTargetPath
|
|
286
441
|
)
|
|
@@ -293,7 +448,7 @@ async function main() {
|
|
|
293
448
|
|
|
294
449
|
try {
|
|
295
450
|
await cloneRepository(
|
|
296
|
-
{ repository: INFRASTRUCTURE_REPOSITORY },
|
|
451
|
+
{ repository: INFRASTRUCTURE_REPOSITORY, branch: ref, keepHistory: true },
|
|
297
452
|
infrastructureTargetPath
|
|
298
453
|
)
|
|
299
454
|
} catch (err) {
|
|
@@ -319,7 +474,12 @@ async function main() {
|
|
|
319
474
|
console.log(' tilt up\n')
|
|
320
475
|
console.log('To get started with the infrastructure:\n')
|
|
321
476
|
console.log(' cd ' + infrastructureDirName)
|
|
322
|
-
console.log(' git
|
|
477
|
+
console.log(' git remote add origin <your-infrastructure-repo-url>')
|
|
478
|
+
console.log(' git push -u origin ' + ref + '\n')
|
|
479
|
+
console.log(
|
|
480
|
+
'The "upstream" remote points at the official infrastructure repository, ' +
|
|
481
|
+
'so you can pull future releases with `git fetch upstream`.\n'
|
|
482
|
+
)
|
|
323
483
|
}
|
|
324
484
|
|
|
325
485
|
main()
|
|
@@ -331,8 +331,9 @@ var TextValue = z7.string();
|
|
|
331
331
|
var HiddenFieldValue = z7.string();
|
|
332
332
|
var NonEmptyTextValue = z7.string().trim().min(1);
|
|
333
333
|
var DateValue = z7.iso.date().describe("Date in the format YYYY-MM-DD");
|
|
334
|
+
var AGE_MAX_VALUE = 999;
|
|
334
335
|
var AgeValue = z7.object({
|
|
335
|
-
age: z7.number(),
|
|
336
|
+
age: z7.number().int().min(0).max(AGE_MAX_VALUE),
|
|
336
337
|
asOfDateRef: z7.string()
|
|
337
338
|
});
|
|
338
339
|
var AgeUpdateValue = AgeValue.optional().nullable();
|
|
@@ -719,7 +720,9 @@ var RecordScopeTypeV2 = z13.enum([
|
|
|
719
720
|
"record.request-correction",
|
|
720
721
|
"record.correct",
|
|
721
722
|
"record.unassign-others",
|
|
722
|
-
"record.custom-action"
|
|
723
|
+
"record.custom-action",
|
|
724
|
+
"record.action.accept",
|
|
725
|
+
"record.action.reject"
|
|
723
726
|
]);
|
|
724
727
|
var PlainScopeType = z13.enum([
|
|
725
728
|
// Misc. system scopes
|
|
@@ -741,10 +744,7 @@ var PlainScopeType = z13.enum([
|
|
|
741
744
|
// Performance dashboard
|
|
742
745
|
"performance.read",
|
|
743
746
|
"performance.read-dashboards",
|
|
744
|
-
"performance.vital-statistics-export"
|
|
745
|
-
// Scopes used exclusively by countryconfig integration token
|
|
746
|
-
"record.confirm-registration",
|
|
747
|
-
"record.reject-registration"
|
|
747
|
+
"performance.vital-statistics-export"
|
|
748
748
|
]);
|
|
749
749
|
var scopeByEvent = z13.preprocess(
|
|
750
750
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
@@ -762,7 +762,9 @@ var userRole = z13.preprocess(
|
|
|
762
762
|
).describe("User role, e.g. admin, field agent");
|
|
763
763
|
var scopeOptionsPlaceEvent = z13.object({
|
|
764
764
|
event: scopeByEvent,
|
|
765
|
-
placeOfEvent: JurisdictionFilter.optional()
|
|
765
|
+
placeOfEvent: JurisdictionFilter.optional(),
|
|
766
|
+
createdBy: UserFilter.optional(),
|
|
767
|
+
createdIn: JurisdictionFilter.optional()
|
|
766
768
|
}).describe("Options applicable to all record scopes.");
|
|
767
769
|
var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
|
|
768
770
|
notifiedIn: JurisdictionFilter.optional(),
|
|
@@ -805,7 +807,9 @@ var AllScopeOptions = z13.object({
|
|
|
805
807
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
806
808
|
var ResolvedScopeOptionsPlaceEvent = z13.object({
|
|
807
809
|
event: scopeByEvent,
|
|
808
|
-
placeOfEvent: UUID.nullish()
|
|
810
|
+
placeOfEvent: UUID.nullish(),
|
|
811
|
+
createdBy: z13.string().optional(),
|
|
812
|
+
createdIn: UUID.nullish()
|
|
809
813
|
}).describe(
|
|
810
814
|
"Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
|
|
811
815
|
);
|
|
@@ -852,6 +856,13 @@ var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
|
|
|
852
856
|
"Template IDs for certified copies. Controls which certificate templates are returned to the client via the config service. Certificate printing is a client-side operation \u2014 this option is not validated when the printCertificate action is submitted."
|
|
853
857
|
)
|
|
854
858
|
});
|
|
859
|
+
var ActionConfirmationScopeType = RecordScopeTypeV2.extract([
|
|
860
|
+
"record.action.accept",
|
|
861
|
+
"record.action.reject"
|
|
862
|
+
]);
|
|
863
|
+
var ActionConfirmationScopeOptions = AllRecordScopeOptions.describe(
|
|
864
|
+
"Options for confirming (accepting or rejecting) an action."
|
|
865
|
+
);
|
|
855
866
|
var RecordScopeV2 = z13.discriminatedUnion("type", [
|
|
856
867
|
z13.object({
|
|
857
868
|
type: ScopesWithPlaceEventOptions,
|
|
@@ -872,6 +883,10 @@ var RecordScopeV2 = z13.discriminatedUnion("type", [
|
|
|
872
883
|
z13.object({
|
|
873
884
|
type: z13.literal("record.print-certified-copies"),
|
|
874
885
|
options: ScopeOptionsPrintCertifiedCopies.optional()
|
|
886
|
+
}),
|
|
887
|
+
z13.object({
|
|
888
|
+
type: ActionConfirmationScopeType,
|
|
889
|
+
options: ActionConfirmationScopeOptions.optional()
|
|
875
890
|
})
|
|
876
891
|
]).describe(
|
|
877
892
|
"Scopes used to check user's permission to perform actions on a record."
|
|
@@ -1108,7 +1123,7 @@ var RequestedCorrectionAction = ActionBase.extend(
|
|
|
1108
1123
|
var ApprovedCorrectionAction = ActionBase.extend(
|
|
1109
1124
|
z15.object({
|
|
1110
1125
|
type: z15.literal(ActionType.APPROVE_CORRECTION),
|
|
1111
|
-
requestId:
|
|
1126
|
+
requestId: UUID,
|
|
1112
1127
|
// TODO move into 'content' property
|
|
1113
1128
|
content: z15.object({ immediateCorrection: z15.boolean().optional() }).optional()
|
|
1114
1129
|
}).shape
|
|
@@ -1116,7 +1131,7 @@ var ApprovedCorrectionAction = ActionBase.extend(
|
|
|
1116
1131
|
var RejectedCorrectionAction = ActionBase.extend(
|
|
1117
1132
|
z15.object({
|
|
1118
1133
|
type: z15.literal(ActionType.REJECT_CORRECTION),
|
|
1119
|
-
requestId:
|
|
1134
|
+
requestId: UUID,
|
|
1120
1135
|
// TODO move into 'content' property
|
|
1121
1136
|
content: ReasonContent
|
|
1122
1137
|
}).shape
|
|
@@ -1912,9 +1927,6 @@ var AdministrativeAreaField = BaseField.extend({
|
|
|
1912
1927
|
partOf: FieldReference.optional().describe("Parent location"),
|
|
1913
1928
|
type: AdministrativeAreas,
|
|
1914
1929
|
allowedLocations: AllowedLocations,
|
|
1915
|
-
listHistoricalNames: import_v43.default.boolean().optional().describe(
|
|
1916
|
-
"List every historical name a location has had as a separate, selectable option."
|
|
1917
|
-
),
|
|
1918
1930
|
activeOnly: import_v43.default.boolean().optional().describe(
|
|
1919
1931
|
"Offer only locations that are active at the resolved anchor date (today, or the date of event when anchorToDateOfEvent is set); inactive or not-yet-effective versions are excluded."
|
|
1920
1932
|
),
|
|
@@ -1932,9 +1944,6 @@ var LocationInput = BaseField.extend({
|
|
|
1932
1944
|
configuration: import_v43.default.object({
|
|
1933
1945
|
locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
|
|
1934
1946
|
allowedLocations: AllowedLocations,
|
|
1935
|
-
listHistoricalNames: import_v43.default.boolean().optional().describe(
|
|
1936
|
-
"List every historical name a location has had as a separate, selectable option."
|
|
1937
|
-
),
|
|
1938
1947
|
activeOnly: import_v43.default.boolean().optional().describe(
|
|
1939
1948
|
"Offer only locations that are active at the resolved anchor date (today, or the date of event when anchorToDateOfEvent is set); inactive or not-yet-effective versions are excluded."
|
|
1940
1949
|
),
|
|
@@ -1968,7 +1977,6 @@ var Facility = BaseField.extend({
|
|
|
1968
1977
|
defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
|
|
1969
1978
|
configuration: import_v43.default.object({
|
|
1970
1979
|
allowedLocations: AllowedLocations,
|
|
1971
|
-
listHistoricalNames: import_v43.default.boolean().optional(),
|
|
1972
1980
|
activeOnly: import_v43.default.boolean().optional(),
|
|
1973
1981
|
anchorToDateOfEvent: import_v43.default.boolean().optional()
|
|
1974
1982
|
}).optional()
|
|
@@ -1978,7 +1986,6 @@ var Office = BaseField.extend({
|
|
|
1978
1986
|
defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
|
|
1979
1987
|
configuration: import_v43.default.object({
|
|
1980
1988
|
allowedLocations: AllowedLocations,
|
|
1981
|
-
listHistoricalNames: import_v43.default.boolean().optional(),
|
|
1982
1989
|
activeOnly: import_v43.default.boolean().optional(),
|
|
1983
1990
|
anchorToDateOfEvent: import_v43.default.boolean().optional()
|
|
1984
1991
|
}).optional()
|
|
@@ -2015,9 +2022,6 @@ var Address = BaseField.extend({
|
|
|
2015
2022
|
})
|
|
2016
2023
|
).optional(),
|
|
2017
2024
|
allowedLocations: AllowedLocations,
|
|
2018
|
-
listHistoricalNames: import_v43.default.boolean().optional().describe(
|
|
2019
|
-
"List every historical name a location has had as a separate, selectable option. Propagated to the embedded admin-area selectors."
|
|
2020
|
-
),
|
|
2021
2025
|
activeOnly: import_v43.default.boolean().optional().describe(
|
|
2022
2026
|
"Offer only admin areas that are active at the resolved anchor date (today, or the date of event when anchorToDateOfEvent is set); inactive or not-yet-effective versions are excluded. Propagated to the embedded admin-area selectors."
|
|
2023
2027
|
),
|
|
@@ -2078,10 +2082,19 @@ var ButtonField = BaseField.extend({
|
|
|
2078
2082
|
description: "A generic button that can be used to trigger an action",
|
|
2079
2083
|
id: "ButtonField"
|
|
2080
2084
|
});
|
|
2085
|
+
var FieldGroupConfiguration = import_v43.default.object({
|
|
2086
|
+
separator: import_v43.default.string().optional().describe(
|
|
2087
|
+
'Joins the subfield values when the group is rendered as output, e.g. ", ". Defaults to one subfield per line.'
|
|
2088
|
+
),
|
|
2089
|
+
hideEmptyFields: import_v43.default.boolean().default(false).optional().describe(
|
|
2090
|
+
"Leaves subfields without a value out of the output. Pair it with a separator so the separator does not double up around the gaps."
|
|
2091
|
+
)
|
|
2092
|
+
});
|
|
2081
2093
|
var FieldGroup = BaseField.extend({
|
|
2082
2094
|
type: import_v43.default.literal(FieldType.FIELD_GROUP),
|
|
2083
2095
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
2084
|
-
fields: import_v43.default.lazy(() => import_v43.default.array(FieldConfig))
|
|
2096
|
+
fields: import_v43.default.lazy(() => import_v43.default.array(FieldConfig)),
|
|
2097
|
+
configuration: FieldGroupConfiguration.optional()
|
|
2085
2098
|
}).meta({
|
|
2086
2099
|
description: "A group of fields that are displayed together",
|
|
2087
2100
|
id: "FieldGroup"
|
|
@@ -2372,8 +2385,7 @@ var LoginConfig = z21.object({
|
|
|
2372
2385
|
USER_NOTIFICATION_DELIVERY_METHOD: z21.enum(["email", "sms"]),
|
|
2373
2386
|
INFORMANT_NOTIFICATION_DELIVERY_METHOD: z21.enum(["email", "sms"]),
|
|
2374
2387
|
PHONE_NUMBER_PATTERN: z21.string().or(z21.instanceof(RegExp)),
|
|
2375
|
-
LOGIN_BACKGROUND: BackgroundConfig
|
|
2376
|
-
SENTRY: z21.string().optional()
|
|
2388
|
+
LOGIN_BACKGROUND: BackgroundConfig
|
|
2377
2389
|
});
|
|
2378
2390
|
var defineLoginConfig = (config) => {
|
|
2379
2391
|
return LoginConfig.parse(config);
|
|
@@ -2381,7 +2393,6 @@ var defineLoginConfig = (config) => {
|
|
|
2381
2393
|
var ClientConfig = z21.object({
|
|
2382
2394
|
COUNTRY: z21.string(),
|
|
2383
2395
|
LANGUAGES: z21.array(z21.string()),
|
|
2384
|
-
SENTRY: z21.string().optional(),
|
|
2385
2396
|
LOGIN_URL: z21.string().optional(),
|
|
2386
2397
|
REGISTER_BACKGROUND: BackgroundConfig,
|
|
2387
2398
|
DASHBOARDS: z21.array(
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Nominal } from './nominal';
|
|
2
|
+
import * as z from 'zod/v4';
|
|
3
|
+
import { ScopeType, Scope, EncodedScope } from './scopes';
|
|
4
|
+
export * from './scopes';
|
|
5
|
+
/**
|
|
6
|
+
* Returns an array of accepted scopes from a JWT token, filtered by the given accepted scope types.
|
|
7
|
+
*
|
|
8
|
+
* @param token - The JWT token containing scope definitions.
|
|
9
|
+
* @param acceptedScopes - An array of acceptable scope types to filter by.
|
|
10
|
+
* @returns An array of parsed RecordScopeV2 objects that are found in the token and match the accepted scope types.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getAcceptedScopesFromToken<T extends ScopeType>(token: string, acceptedScopes: T[]): Array<Extract<Scope, {
|
|
13
|
+
type: T;
|
|
14
|
+
}>>;
|
|
15
|
+
export declare const TokenUserType: z.ZodEnum<{
|
|
16
|
+
system: "system";
|
|
17
|
+
user: "user";
|
|
18
|
+
}>;
|
|
19
|
+
export type TokenUserType = z.infer<typeof TokenUserType>;
|
|
20
|
+
export interface ITokenPayload {
|
|
21
|
+
sub: string;
|
|
22
|
+
exp: string;
|
|
23
|
+
algorithm: string;
|
|
24
|
+
scope: EncodedScope[];
|
|
25
|
+
role?: string;
|
|
26
|
+
userType: TokenUserType;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Depending on how the API is called, there might or might not be Bearer keyword in the header.
|
|
30
|
+
* To allow for usage with both direct HTTP calls and TRPC, ensure it's present to be able to use shared scope auth functions.
|
|
31
|
+
*/
|
|
32
|
+
export declare function setBearerForToken(token: string): string;
|
|
33
|
+
export declare function getScopes(token: string): EncodedScope[];
|
|
34
|
+
export declare const getTokenPayload: (token: string) => ITokenPayload;
|
|
35
|
+
export declare const getUserId: (token: TokenWithBearer) => string;
|
|
36
|
+
/**
|
|
37
|
+
* Extracts the subject (user ID) from a raw JWT string (without Bearer prefix).
|
|
38
|
+
* Returns null if the token cannot be decoded.
|
|
39
|
+
*/
|
|
40
|
+
export declare const getUserIdFromToken: (token: string) => string | null;
|
|
41
|
+
/**
|
|
42
|
+
* Fixed subject (`sub`) of the service token that core's auth service mints at `GET /internal/service-token`.
|
|
43
|
+
* Core uses it for service-to-service calls where no user is involved.
|
|
44
|
+
*
|
|
45
|
+
* Must be a well-formed UUID so a service verifying the token can resolve it as
|
|
46
|
+
* a `SystemContext` as with `INTEGRATION_CREATOR_USER_ID` / `REINDEX_USER_ID`.
|
|
47
|
+
*
|
|
48
|
+
* See packages/auth/src/features/serviceToken/handler.ts
|
|
49
|
+
*/
|
|
50
|
+
export declare const SERVICE_USER_ID = "00000000-0000-4000-8000-000000000002";
|
|
51
|
+
/**
|
|
52
|
+
* True when a decoded token payload (e.g. Hapi's `request.auth.credentials`)
|
|
53
|
+
* belongs to core's service token, identified by its fixed subject. A country
|
|
54
|
+
* configuration uses this to accept core's own service-to-service calls (e.g.
|
|
55
|
+
* telemetry, all-user broadcasts) while rejecting any logged-in user's token.
|
|
56
|
+
*
|
|
57
|
+
* Accepts `unknown` so loosely-typed framework credentials can be passed
|
|
58
|
+
* directly without a cast; anything that is not an object with the matching
|
|
59
|
+
* `sub` yields `false`.
|
|
60
|
+
*/
|
|
61
|
+
export declare function isServiceToken(credentials: unknown): boolean;
|
|
62
|
+
export declare const getUserTypeFromToken: (token: TokenWithBearer) => TokenUserType;
|
|
63
|
+
export declare const TokenWithBearer: z.ZodType<`Bearer ${string}`>;
|
|
64
|
+
export type TokenWithBearer = z.infer<typeof TokenWithBearer>;
|
|
65
|
+
export type Token = Nominal<string, 'TokenWithoutBearer'>;
|
|
66
|
+
//# sourceMappingURL=authentication.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/authentication/index.ts"],"names":[],"mappings":"AAaA,cAAc,kCAAkC,CAAA"}
|