@opencrvs/toolkit 2.1.0-rc.d1b9774 → 2.1.0-rc.d235243
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 +15 -5
- package/create-countryconfig/index.js +164 -4
- package/dist/application-config/index.js +36 -25
- package/dist/authentication/index.d.ts +8 -9
- package/dist/authentication/index.js +23 -8
- package/dist/cli.js +1981 -2823
- 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/conditionals/index.js +21 -7
- package/dist/environment/derived-variables.d.ts +18 -0
- package/dist/environment/derived-variables.d.ts.map +1 -1
- package/dist/environment/derived-variables.js +21 -0
- package/dist/environment/index.d.ts.map +1 -1
- package/dist/environment/index.js +2 -1
- package/dist/environment/manage-users.js +1 -1
- package/dist/environment/questions.d.ts +16 -0
- package/dist/environment/questions.d.ts.map +1 -1
- package/dist/environment/questions.js +27 -2
- 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 +633 -560
- 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 +6 -1
- 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.js +4 -4
- package/dist/migrations/v2.1/add-translations.d.ts.map +1 -1
- package/dist/migrations/v2.1/add-translations.js +4 -68
- package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -1
- package/dist/migrations/v2.1/enable-telemetry.js +30 -13
- package/dist/migrations/v2.1/index.d.ts.map +1 -1
- package/dist/migrations/v2.1/index.js +35 -1261
- 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 +348 -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/migrations/v2.2/add-e2e-tests.d.ts +19 -0
- package/dist/migrations/v2.2/add-e2e-tests.d.ts.map +1 -0
- package/dist/migrations/v2.2/add-e2e-tests.js +143 -0
- package/dist/migrations/v2.2/index.d.ts +6 -0
- package/dist/migrations/v2.2/index.d.ts.map +1 -0
- package/dist/migrations/v2.2/index.js +279 -0
- package/dist/migrations/v2.2/template-files.d.ts +8 -0
- package/dist/migrations/v2.2/template-files.d.ts.map +1 -0
- package/dist/migrations/v2.2/template-files.js +49 -0
- package/dist/migrations/v2.2/upgrade-tilt.d.ts +8 -0
- package/dist/migrations/v2.2/upgrade-tilt.d.ts.map +1 -0
- package/dist/migrations/v2.2/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 +4 -0
- 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/charts-values/traefik/values.yaml +2 -3
- 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/e2e/README.md +36 -0
- package/dist/templates/countryconfig-template/e2e/constants.ts +28 -0
- package/dist/templates/countryconfig-template/e2e/login.e2e.ts +59 -0
- package/dist/templates/countryconfig-template/package.json +153 -0
- package/dist/templates/countryconfig-template/playwright.config.ts +42 -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 +159 -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.map +1 -1
- package/dist/verify/endpoints.js +180 -15
- package/opencrvs-toolkit-2.1.0-rc.d235243.tgz +0 -0
- package/package.json +2 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- 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/dist/translations/check.d.ts +0 -19
- package/dist/translations/check.d.ts.map +0 -1
- package/dist/translations/check.js +0 -127
- package/opencrvs-toolkit-2.1.0-rc.d1b9774.tgz +0 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
4
|
+
#
|
|
5
|
+
# OpenCRVS is also distributed under the terms of the Civil Registration
|
|
6
|
+
# & Healthcare Disclaimer located at http://opencrvs.org/license.
|
|
7
|
+
#
|
|
8
|
+
# Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def copy_secrets(dependencies_namespace, opencrvs_namespace):
|
|
12
|
+
|
|
13
|
+
secrets_to_copy = [
|
|
14
|
+
"elasticsearch-admin-user",
|
|
15
|
+
"redis-opencrvs-users",
|
|
16
|
+
"minio-opencrvs-users",
|
|
17
|
+
"mongodb-admin-user",
|
|
18
|
+
"postgres-admin-user",
|
|
19
|
+
]
|
|
20
|
+
k8s_resource(
|
|
21
|
+
new_name="deps-secrets",
|
|
22
|
+
objects=["{}:secret".format(secret) for secret in secrets_to_copy],
|
|
23
|
+
labels=['3.Dependencies']
|
|
24
|
+
)
|
|
25
|
+
local_resource(
|
|
26
|
+
"copy-secrets",
|
|
27
|
+
cmd="""kubectl get secret {2} -n {0} -o yaml \
|
|
28
|
+
| sed "s#namespace: {0}#namespace: {1}#" | grep -v 'resourceVersion\\|uid\\|creationTimestamp' \
|
|
29
|
+
| kubectl apply -n {1} -f -""".format(dependencies_namespace, opencrvs_namespace, " ".join(secrets_to_copy)),
|
|
30
|
+
resource_deps=["deps-secrets"],
|
|
31
|
+
labels=['2.Data-tasks'])
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def data_cleanup(
|
|
35
|
+
opencrvs_namespace,
|
|
36
|
+
opencrvs_configuration_file,
|
|
37
|
+
core_images_tag,
|
|
38
|
+
countryconfig_image_name,
|
|
39
|
+
countryconfig_image_tag,
|
|
40
|
+
opencrvs_tools_chart_path
|
|
41
|
+
):
|
|
42
|
+
job_yaml = local("""
|
|
43
|
+
helm template {opencrvs_tools_chart_path} \
|
|
44
|
+
--namespace {opencrvs_namespace} \
|
|
45
|
+
-f {opencrvs_configuration_file} \
|
|
46
|
+
--set platform.tag={core_images_tag} \
|
|
47
|
+
--set data_cleanup.enabled=true \
|
|
48
|
+
--set countryconfig.image.name={countryconfig_image_name} \
|
|
49
|
+
--set countryconfig.image.tag={countryconfig_image_tag} \
|
|
50
|
+
--show-only templates/data-cleanup-job.yaml
|
|
51
|
+
""".format(
|
|
52
|
+
opencrvs_namespace=opencrvs_namespace,
|
|
53
|
+
opencrvs_configuration_file=opencrvs_configuration_file,
|
|
54
|
+
core_images_tag=core_images_tag,
|
|
55
|
+
countryconfig_image_name=countryconfig_image_name,
|
|
56
|
+
countryconfig_image_tag=countryconfig_image_tag,
|
|
57
|
+
opencrvs_tools_chart_path=opencrvs_tools_chart_path
|
|
58
|
+
),
|
|
59
|
+
quiet=True
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
k8s_yaml(job_yaml)
|
|
63
|
+
k8s_resource(
|
|
64
|
+
'data-cleanup',
|
|
65
|
+
labels=['2.Data-tasks'],
|
|
66
|
+
auto_init=False
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
def seed_data(
|
|
70
|
+
opencrvs_namespace,
|
|
71
|
+
opencrvs_configuration_file,
|
|
72
|
+
core_images_tag,
|
|
73
|
+
countryconfig_image_name,
|
|
74
|
+
countryconfig_image_tag,
|
|
75
|
+
opencrvs_tools_chart_path
|
|
76
|
+
):
|
|
77
|
+
job_yaml = local("""
|
|
78
|
+
helm template -f {opencrvs_configuration_file} \
|
|
79
|
+
--set platform.tag={core_images_tag} \
|
|
80
|
+
--set data_seed.enabled=true -s templates/data-seed-job.yaml --namespace {opencrvs_namespace} {opencrvs_tools_chart_path}
|
|
81
|
+
""".format(
|
|
82
|
+
opencrvs_namespace=opencrvs_namespace,
|
|
83
|
+
opencrvs_configuration_file=opencrvs_configuration_file,
|
|
84
|
+
core_images_tag=core_images_tag,
|
|
85
|
+
opencrvs_tools_chart_path=opencrvs_tools_chart_path
|
|
86
|
+
),
|
|
87
|
+
quiet=True
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
k8s_yaml(job_yaml)
|
|
91
|
+
k8s_resource(
|
|
92
|
+
'data-seed',
|
|
93
|
+
labels=['2.Data-tasks'],
|
|
94
|
+
auto_init=False
|
|
95
|
+
)
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
4
|
+
#
|
|
5
|
+
# OpenCRVS is also distributed under the terms of the Civil Registration
|
|
6
|
+
# & Healthcare Disclaimer located at http://opencrvs.org/license.
|
|
7
|
+
#
|
|
8
|
+
# Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# Shared OpenCRVS Tilt configuration
|
|
12
|
+
# Load extensions
|
|
13
|
+
load('ext://namespace', 'namespace_create', 'namespace_inject')
|
|
14
|
+
load("./lib.tilt",
|
|
15
|
+
"copy_secrets", "data_cleanup", "seed_data")
|
|
16
|
+
include('./common.tilt')
|
|
17
|
+
|
|
18
|
+
def setup_opencrvs(
|
|
19
|
+
core_images_tag,
|
|
20
|
+
countryconfig_image_tag,
|
|
21
|
+
countryconfig_image_name="opencrvs/ocrvs-countryconfig",
|
|
22
|
+
dependencies_namespace='opencrvs-deps-dev',
|
|
23
|
+
opencrvs_namespace='opencrvs-dev',
|
|
24
|
+
security_enabled=False,
|
|
25
|
+
monitoring_enabled=False,
|
|
26
|
+
opencrvs_chart_repo='.'
|
|
27
|
+
):
|
|
28
|
+
"""
|
|
29
|
+
Common OpenCRVS setup function
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
core_images_tag: OpenCRVS core images tag to use for deployment
|
|
33
|
+
countryconfig_image_name: Countryconfig image repository (e.g. your DockerHub repository or Farajaland demo repository)
|
|
34
|
+
countryconfig_image_tag: Countryconfig image tag to use for deployment
|
|
35
|
+
dependencies_namespace: Kubernetes namespace for dependencies (e.g. MongoDB, MinIO, Elasticsearch)
|
|
36
|
+
opencrvs_namespace: Kubernetes namespace for OpenCRVS services
|
|
37
|
+
security_enabled: If true, OpenCRVS and dependencies will be deployed in secure mode with authentication enabled. If false, OpenCRVS and dependencies will be deployed in non-secure mode with default passwords and no authentication.
|
|
38
|
+
monitoring_enabled: If true, monitoring components like Kibana will be deployed together with dependencies
|
|
39
|
+
opencrvs_chart_repo: Path to OpenCRVS charts directory (relative)
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
# Create namespaces
|
|
43
|
+
namespace_create(dependencies_namespace)
|
|
44
|
+
namespace_create(opencrvs_namespace)
|
|
45
|
+
|
|
46
|
+
# Select configuration files
|
|
47
|
+
if security_enabled:
|
|
48
|
+
print("🔑 Deploying OpenCRVS and Dependencies in secure mode")
|
|
49
|
+
deps_configuration_file = './tilt/examples/dependencies/values-secure.yaml'
|
|
50
|
+
opencrvs_configuration_file = './tilt/examples/opencrvs-services/values-secure.yaml'
|
|
51
|
+
else:
|
|
52
|
+
print("""🔑 Deploying OpenCRVS and Dependencies in non-secure mode
|
|
53
|
+
- Minio admin user/password: minioadmin/minioadmin
|
|
54
|
+
- Postgres admin user/password: postgres/postgres
|
|
55
|
+
- Authentication for Redis, MongoDB and Elasticsearch is disabled""")
|
|
56
|
+
deps_configuration_file = './tilt/examples/dependencies/values.yaml'
|
|
57
|
+
opencrvs_configuration_file = './tilt/examples/opencrvs-services/values.yaml'
|
|
58
|
+
|
|
59
|
+
# Country specific overrides, layered on top of the examples above.
|
|
60
|
+
# tilt/examples/ is replaced on every upgrade, tilt/helm/ is left alone.
|
|
61
|
+
deps_values = [deps_configuration_file]
|
|
62
|
+
if os.path.exists('./tilt/helm/dependencies/values.yaml'):
|
|
63
|
+
deps_values.append('./tilt/helm/dependencies/values.yaml')
|
|
64
|
+
opencrvs_values = [opencrvs_configuration_file]
|
|
65
|
+
if os.path.exists('./tilt/helm/opencrvs-services/values.yaml'):
|
|
66
|
+
opencrvs_values.append('./tilt/helm/opencrvs-services/values.yaml')
|
|
67
|
+
|
|
68
|
+
# Deploy dependencies
|
|
69
|
+
print("🚀 Deploying dependencies: mongo, minio, elasticsearch...")
|
|
70
|
+
dependencies_chart_path = '{}/charts/dependencies'.format(opencrvs_chart_repo)
|
|
71
|
+
k8s_yaml(helm(dependencies_chart_path,
|
|
72
|
+
namespace=dependencies_namespace,
|
|
73
|
+
values=deps_values,
|
|
74
|
+
set=["monitoring.enabled={}".format(monitoring_enabled).lower()]
|
|
75
|
+
))
|
|
76
|
+
opencrvs_chart_path = '{}/charts/opencrvs-services'.format(opencrvs_chart_repo)
|
|
77
|
+
certs_dir = '{opencrvs_chart_path}/certs'.format(opencrvs_chart_path=opencrvs_chart_path)
|
|
78
|
+
if not os.path.exists("{certs_dir}/tls.crt".format(certs_dir=certs_dir)):
|
|
79
|
+
local("""
|
|
80
|
+
mkdir -p {certs_dir}
|
|
81
|
+
openssl req -x509 -nodes -days 365 \
|
|
82
|
+
-newkey rsa:2048 \
|
|
83
|
+
-keyout {certs_dir}/tls.key \
|
|
84
|
+
-out {certs_dir}/tls.crt \
|
|
85
|
+
-subj "/CN=local.dev"
|
|
86
|
+
""".format(certs_dir=certs_dir))
|
|
87
|
+
|
|
88
|
+
# Deploy OpenCRVS services
|
|
89
|
+
print("🚀 Deploying services: auth, events, gateway...")
|
|
90
|
+
k8s_yaml(
|
|
91
|
+
helm(opencrvs_chart_path,
|
|
92
|
+
namespace=opencrvs_namespace,
|
|
93
|
+
values=opencrvs_values,
|
|
94
|
+
set=[
|
|
95
|
+
"platform.tag={}".format(core_images_tag),
|
|
96
|
+
"countryconfig.image.name={}".format(countryconfig_image_name),
|
|
97
|
+
"countryconfig.image.tag={}".format(countryconfig_image_tag),
|
|
98
|
+
"data_seed.enabled=false", # Disable data seeding on helm install for tilt
|
|
99
|
+
"certs.crt_file=certs/tls.crt",
|
|
100
|
+
"certs.key_file=certs/tls.key"
|
|
101
|
+
]
|
|
102
|
+
)
|
|
103
|
+
)
|
|
104
|
+
cleanup_cmd = "./scripts/cleanup.sh"
|
|
105
|
+
|
|
106
|
+
if os.name == "nt":
|
|
107
|
+
cleanup_cmd = "powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\\scripts\\cleanup.ps1"
|
|
108
|
+
|
|
109
|
+
local_resource(
|
|
110
|
+
name="clean-&-seed",
|
|
111
|
+
auto_init=False,
|
|
112
|
+
labels="2.Data-tasks",
|
|
113
|
+
cmd="./tilt/clear-all-data.sh",
|
|
114
|
+
allow_parallel=True,
|
|
115
|
+
)
|
|
116
|
+
# Add data tasks
|
|
117
|
+
data_cleanup(
|
|
118
|
+
opencrvs_namespace,
|
|
119
|
+
opencrvs_configuration_file,
|
|
120
|
+
core_images_tag,
|
|
121
|
+
countryconfig_image_name,
|
|
122
|
+
countryconfig_image_tag,
|
|
123
|
+
opencrvs_chart_path
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
seed_data(
|
|
127
|
+
opencrvs_namespace,
|
|
128
|
+
opencrvs_configuration_file,
|
|
129
|
+
core_images_tag,
|
|
130
|
+
countryconfig_image_name,
|
|
131
|
+
countryconfig_image_tag,
|
|
132
|
+
opencrvs_chart_path
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
if security_enabled:
|
|
136
|
+
copy_secrets(dependencies_namespace, opencrvs_namespace)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where to read the template from, most specific first: the newest release
|
|
3
|
+
* branch of the given version, then its newest tag, then `develop` for anyone
|
|
4
|
+
* running before the version has been cut.
|
|
5
|
+
*/
|
|
6
|
+
export declare function candidateRefs(version: string): Promise<string[]>;
|
|
7
|
+
export declare function fetchTemplate(refs: string[], application: string): Promise<{
|
|
8
|
+
ref: string;
|
|
9
|
+
contents: string;
|
|
10
|
+
} | undefined>;
|
|
11
|
+
//# sourceMappingURL=template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/translations/template.ts"],"names":[],"mappings":"AAgEA;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,qBAMlD;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM;;;eAoBtE"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
6
|
+
*
|
|
7
|
+
* OpenCRVS is also distributed under the terms of the Civil Registration
|
|
8
|
+
* & Healthcare Disclaimer located at http://opencrvs.org/license.
|
|
9
|
+
*
|
|
10
|
+
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
|
|
11
|
+
*/
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.candidateRefs = candidateRefs;
|
|
23
|
+
exports.fetchTemplate = fetchTemplate;
|
|
24
|
+
/**
|
|
25
|
+
* Reads the country config template's translation files off GitHub.
|
|
26
|
+
*
|
|
27
|
+
* The template is the record of the copy core requires: a pull request that
|
|
28
|
+
* introduces a translation key has to add it to
|
|
29
|
+
* `packages/countryconfig-template/src/translations/`, which the
|
|
30
|
+
* check-missing-translation workflow makes it do anyway. Two things read it —
|
|
31
|
+
* the `add-translations` codemod, which adds the new rows to a country config's
|
|
32
|
+
* own files, and `verify-endpoints`, which checks a running country config
|
|
33
|
+
* actually serves them — so the ref resolution lives here rather than in
|
|
34
|
+
* either.
|
|
35
|
+
*/
|
|
36
|
+
const REPOSITORY = 'opencrvs/opencrvs-core';
|
|
37
|
+
const TEMPLATE_TRANSLATIONS = 'packages/countryconfig-template/src/translations';
|
|
38
|
+
/**
|
|
39
|
+
* The refs matching a prefix, newest patch first.
|
|
40
|
+
*
|
|
41
|
+
* Every patch gets its own release branch — `release/2.1.0`, `release/2.1.1` —
|
|
42
|
+
* and a translation key added in a patch only exists on that patch's branch, so
|
|
43
|
+
* the newest one is the one worth reading.
|
|
44
|
+
*/
|
|
45
|
+
function matchingRefs(namespace, prefix) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const url = `https://api.github.com/repos/${REPOSITORY}/git/matching-refs/${namespace}/${prefix}`;
|
|
48
|
+
const response = yield fetch(url, {
|
|
49
|
+
headers: { accept: 'application/vnd.github+json' }
|
|
50
|
+
});
|
|
51
|
+
/*
|
|
52
|
+
* An empty list and a failed request are not the same thing: GitHub answers
|
|
53
|
+
* 200 with `[]` for a prefix nothing matches, so anything else is the request
|
|
54
|
+
* failing rather than the version having no release branch. Swallowing it
|
|
55
|
+
* would leave `develop` as the only candidate left, and an unauthenticated
|
|
56
|
+
* api.github.com allows 60 requests an hour per IP — a country upgrading from
|
|
57
|
+
* a shared network or a CI runner would quietly get unreleased copy.
|
|
58
|
+
*/
|
|
59
|
+
if (!response.ok) {
|
|
60
|
+
throw new Error(`GitHub answered ${response.status} ${response.statusText} for ${url}`);
|
|
61
|
+
}
|
|
62
|
+
const refs = (yield response.json());
|
|
63
|
+
const patchOf = (ref) => Number(ref.split('.').pop()) || 0;
|
|
64
|
+
return refs
|
|
65
|
+
.map(({ ref }) => ref.replace(/^refs\/(heads|tags)\//, ''))
|
|
66
|
+
.sort((a, b) => patchOf(b) - patchOf(a));
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Where to read the template from, most specific first: the newest release
|
|
71
|
+
* branch of the given version, then its newest tag, then `develop` for anyone
|
|
72
|
+
* running before the version has been cut.
|
|
73
|
+
*/
|
|
74
|
+
function candidateRefs(version) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
return [
|
|
77
|
+
...(yield matchingRefs('heads', `release/${version}.`)),
|
|
78
|
+
...(yield matchingRefs('tags', `v${version}.`)),
|
|
79
|
+
'develop'
|
|
80
|
+
];
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function fetchTemplate(refs, application) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
for (const ref of refs) {
|
|
86
|
+
const url = `https://raw.githubusercontent.com/${REPOSITORY}/${ref}/${TEMPLATE_TRANSLATIONS}/${application}.csv`;
|
|
87
|
+
const response = yield fetch(url);
|
|
88
|
+
if (response.ok) {
|
|
89
|
+
return { ref, contents: yield response.text() };
|
|
90
|
+
}
|
|
91
|
+
// 404 means this ref does not carry the file and the next one is worth a
|
|
92
|
+
// try. Anything else is the request failing, and moving on would read the
|
|
93
|
+
// template from a ref older than the one that was asked for.
|
|
94
|
+
if (response.status !== 404) {
|
|
95
|
+
throw new Error(`GitHub answered ${response.status} ${response.statusText} for ${url}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return undefined;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../../src/verify/endpoints.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../../src/verify/endpoints.ts"],"names":[],"mappings":"AAkdA,wBAAsB,kBAAkB,CACtC,MAAM,GAAE,MAA2B,GAClC,OAAO,CAAC,IAAI,CAAC,CAsIf"}
|
package/dist/verify/endpoints.js
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -22,6 +55,9 @@ exports.runVerifyEndpoints = runVerifyEndpoints;
|
|
|
22
55
|
*/
|
|
23
56
|
/* eslint-disable no-console */
|
|
24
57
|
const colors_1 = require("kleur/colors");
|
|
58
|
+
const z = __importStar(require("zod/v4"));
|
|
59
|
+
const csv_1 = require("../csv");
|
|
60
|
+
const template_1 = require("../translations/template");
|
|
25
61
|
const REQUEST_TIMEOUT_MS = 15000;
|
|
26
62
|
/**
|
|
27
63
|
* The country config service listens on port 3040 locally. This command is
|
|
@@ -85,10 +121,10 @@ const SECURED_TRIGGER_USER_EVENTS = [
|
|
|
85
121
|
const SECURED_ENDPOINTS = [
|
|
86
122
|
...SECURED_TRIGGER_USER_EVENTS.map((event) => ({
|
|
87
123
|
method: 'POST',
|
|
88
|
-
path: `/
|
|
124
|
+
path: `/trigger/user/${event}`
|
|
89
125
|
})),
|
|
90
126
|
{ method: 'POST', path: '/trigger/telemetry' },
|
|
91
|
-
{ method: 'GET', path: '/
|
|
127
|
+
{ method: 'GET', path: '/trigger/system/ready' },
|
|
92
128
|
{
|
|
93
129
|
method: 'GET',
|
|
94
130
|
path: `/certificates/${PROBE_SEGMENT}`,
|
|
@@ -126,12 +162,10 @@ const requiresAuthOrAbsent = (status) => status === 401 || status === 403 || sta
|
|
|
126
162
|
*/
|
|
127
163
|
function requestStatus(url, method) {
|
|
128
164
|
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
-
const controller = new AbortController();
|
|
130
|
-
const timer = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
131
165
|
try {
|
|
132
166
|
const response = yield fetch(url, {
|
|
133
167
|
method,
|
|
134
|
-
signal:
|
|
168
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
|
|
135
169
|
// Sent without an Authorization header on purpose. A secured route
|
|
136
170
|
// rejects with 401/403 before ever reading the body.
|
|
137
171
|
headers: method === 'POST' ? { 'Content-Type': 'application/json' } : undefined,
|
|
@@ -142,9 +176,6 @@ function requestStatus(url, method) {
|
|
|
142
176
|
catch (_a) {
|
|
143
177
|
return 'error';
|
|
144
178
|
}
|
|
145
|
-
finally {
|
|
146
|
-
clearTimeout(timer);
|
|
147
|
-
}
|
|
148
179
|
});
|
|
149
180
|
}
|
|
150
181
|
function toEventTriggerConfig(value) {
|
|
@@ -175,11 +206,9 @@ function toEventTriggerConfig(value) {
|
|
|
175
206
|
*/
|
|
176
207
|
function fetchEventConfigs(baseUrl) {
|
|
177
208
|
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
-
const controller = new AbortController();
|
|
179
|
-
const timer = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
180
209
|
try {
|
|
181
210
|
const response = yield fetch(`${baseUrl}/config/events`, {
|
|
182
|
-
signal:
|
|
211
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
183
212
|
});
|
|
184
213
|
if (!response.ok) {
|
|
185
214
|
return null;
|
|
@@ -195,9 +224,6 @@ function fetchEventConfigs(baseUrl) {
|
|
|
195
224
|
catch (_a) {
|
|
196
225
|
return null;
|
|
197
226
|
}
|
|
198
|
-
finally {
|
|
199
|
-
clearTimeout(timer);
|
|
200
|
-
}
|
|
201
227
|
});
|
|
202
228
|
}
|
|
203
229
|
/**
|
|
@@ -231,7 +257,143 @@ function securedDetail(status) {
|
|
|
231
257
|
if (status === 'error') {
|
|
232
258
|
return `${describeStatus(status)} — request failed`;
|
|
233
259
|
}
|
|
234
|
-
return `${describeStatus(status)} — INSECURE:
|
|
260
|
+
return `${describeStatus(status)} — INSECURE: ensure this endpoint requires authentication!`;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* The version of the country config template to check against. Bump it with
|
|
264
|
+
* the toolkit's own major.minor: a toolkit release checks that a country config
|
|
265
|
+
* serves the copy core requires *at that version*, which is the same template
|
|
266
|
+
* the `add-translations` codemod adds rows from.
|
|
267
|
+
*/
|
|
268
|
+
const TEMPLATE_VERSION = '2.1';
|
|
269
|
+
/** The translation bundles a country config serves, one per CSV file core owns. */
|
|
270
|
+
const TRANSLATED_APPLICATIONS = ['client', 'login'];
|
|
271
|
+
function readTemplateTranslations(contents) {
|
|
272
|
+
const lines = contents.replace(/\r?\n$/, '').split(/\r?\n/);
|
|
273
|
+
return {
|
|
274
|
+
ids: lines
|
|
275
|
+
.slice(1)
|
|
276
|
+
.filter((line) => line !== '')
|
|
277
|
+
.map(csv_1.idOf),
|
|
278
|
+
languages: (0, csv_1.parseCsvLine)(lines[0]).filter((column) => column !== 'id' && column !== 'description')
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* What `GET /content/{application}` answers with: one entry per language, each
|
|
283
|
+
* carrying every message id that language has copy for.
|
|
284
|
+
*
|
|
285
|
+
* Parsed rather than cast, because the whole check turns on which ids are
|
|
286
|
+
* present — a bundle that is not this shape cannot be read as "the id is
|
|
287
|
+
* missing", and reporting it as such would be a false failure.
|
|
288
|
+
*/
|
|
289
|
+
const ServedTranslations = z.object({
|
|
290
|
+
languages: z.array(z.object({
|
|
291
|
+
lang: z.string(),
|
|
292
|
+
messages: z.record(z.string(), z.string())
|
|
293
|
+
}))
|
|
294
|
+
});
|
|
295
|
+
/**
|
|
296
|
+
* The bundle `GET /content/{application}` serves, or `null` when it cannot be
|
|
297
|
+
* read. An unreachable endpoint is already a failure in the public-endpoints
|
|
298
|
+
* section above, so it is not counted twice here.
|
|
299
|
+
*/
|
|
300
|
+
function fetchServedTranslations(baseUrl, application) {
|
|
301
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
302
|
+
try {
|
|
303
|
+
const response = yield fetch(`${baseUrl}/content/${application}`, {
|
|
304
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
305
|
+
});
|
|
306
|
+
if (!response.ok) {
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
const parsed = ServedTranslations.safeParse(yield response.json());
|
|
310
|
+
return parsed.success ? parsed.data.languages : null;
|
|
311
|
+
}
|
|
312
|
+
catch (_a) {
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
/** How many missing ids to print before summarising the rest. */
|
|
318
|
+
const MISSING_IDS_SHOWN = 10;
|
|
319
|
+
/**
|
|
320
|
+
* Checks that every message id the country config template carries is served
|
|
321
|
+
* by the running country config.
|
|
322
|
+
*
|
|
323
|
+
* This is the API-side half of the translation checks: which files the copy is
|
|
324
|
+
* kept in, and what shape they are, is the country config's own business — this
|
|
325
|
+
* only asks whether the copy core needs comes back out of `/content/*`. A
|
|
326
|
+
* country config checks its *own* messages against its *own* files itself; see
|
|
327
|
+
* `check-translations.ts` in the country config template.
|
|
328
|
+
*
|
|
329
|
+
* An id is looked for across every language served rather than in one of them:
|
|
330
|
+
* a row in a CSV yields an entry under each of that file's language columns, so
|
|
331
|
+
* absent everywhere means absent from the files. Whether the copy is written is
|
|
332
|
+
* a separate matter, and an empty cell is legitimate — the template itself ships
|
|
333
|
+
* a few.
|
|
334
|
+
*
|
|
335
|
+
* Returns the number of failures.
|
|
336
|
+
*/
|
|
337
|
+
function verifyTranslations(baseUrl) {
|
|
338
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
339
|
+
let refs;
|
|
340
|
+
try {
|
|
341
|
+
refs = yield (0, template_1.candidateRefs)(TEMPLATE_VERSION);
|
|
342
|
+
}
|
|
343
|
+
catch (error) {
|
|
344
|
+
console.log(' ' +
|
|
345
|
+
(0, colors_1.yellow)(`Could not list the ${TEMPLATE_VERSION} refs on GitHub (${error.message}); translations not checked.`));
|
|
346
|
+
return 0;
|
|
347
|
+
}
|
|
348
|
+
let failures = 0;
|
|
349
|
+
for (const application of TRANSLATED_APPLICATIONS) {
|
|
350
|
+
const endpoint = `GET /content/${application}`;
|
|
351
|
+
let fetched;
|
|
352
|
+
try {
|
|
353
|
+
fetched = yield (0, template_1.fetchTemplate)(refs, application);
|
|
354
|
+
}
|
|
355
|
+
catch (error) {
|
|
356
|
+
console.log(' ' +
|
|
357
|
+
(0, colors_1.yellow)(`Could not read ${application}.csv from the country config template on GitHub (${error.message}); ${endpoint} not checked.`));
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
if (!fetched) {
|
|
361
|
+
console.log(' ' +
|
|
362
|
+
(0, colors_1.yellow)(`No ${application}.csv in the ${TEMPLATE_VERSION} country config template on GitHub; ${endpoint} not checked.`));
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
const template = readTemplateTranslations(fetched.contents);
|
|
366
|
+
const served = yield fetchServedTranslations(baseUrl, application);
|
|
367
|
+
if (!served) {
|
|
368
|
+
console.log(' ' + (0, colors_1.yellow)(`Could not read ${endpoint}; translations not checked.`));
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
const servedIds = new Set(served.flatMap(({ messages }) => Object.keys(messages)));
|
|
372
|
+
const missing = template.ids.filter((id) => !servedIds.has(id));
|
|
373
|
+
const servedLanguages = new Set(served.map(({ lang }) => lang));
|
|
374
|
+
const absentLanguages = template.languages.filter((lang) => !servedLanguages.has(lang));
|
|
375
|
+
if (missing.length === 0) {
|
|
376
|
+
console.log(line(true, endpoint, `all ${template.ids.length} id(s) from the ${fetched.ref} template served`));
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
failures++;
|
|
380
|
+
console.log(line(false, endpoint, `${missing.length} of ${template.ids.length} id(s) from the ${fetched.ref} template not served`));
|
|
381
|
+
for (const id of missing.slice(0, MISSING_IDS_SHOWN)) {
|
|
382
|
+
console.log(` ${(0, colors_1.dim)(id)}`);
|
|
383
|
+
}
|
|
384
|
+
if (missing.length > MISSING_IDS_SHOWN) {
|
|
385
|
+
console.log(` ${(0, colors_1.dim)(`… and ${missing.length - MISSING_IDS_SHOWN} more`)}`);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
// A country dropping a language the template ships is its own decision, so
|
|
389
|
+
// this is worth saying but is not a failure.
|
|
390
|
+
if (absentLanguages.length > 0) {
|
|
391
|
+
console.log(' ' +
|
|
392
|
+
(0, colors_1.yellow)(`${application}: the template carries ${absentLanguages.join(', ')}, which this country config does not serve.`));
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
return failures;
|
|
396
|
+
});
|
|
235
397
|
}
|
|
236
398
|
function runVerifyEndpoints() {
|
|
237
399
|
return __awaiter(this, arguments, void 0, function* (target = DEFAULT_TARGET_URL) {
|
|
@@ -335,6 +497,9 @@ function runVerifyEndpoints() {
|
|
|
335
497
|
}
|
|
336
498
|
}
|
|
337
499
|
console.log();
|
|
500
|
+
console.log((0, colors_1.bold)('Translations served (must cover the copy core requires):'));
|
|
501
|
+
failures += yield verifyTranslations(baseUrl);
|
|
502
|
+
console.log();
|
|
338
503
|
if (failures > 0) {
|
|
339
504
|
console.log((0, colors_1.red)((0, colors_1.bold)(`✗ ${failures} check(s) failed.`)) +
|
|
340
505
|
(0, colors_1.yellow)(' See the lines marked ✗ above.'));
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opencrvs/toolkit",
|
|
3
|
-
"version": "2.1.0-rc.
|
|
3
|
+
"version": "2.1.0-rc.d235243",
|
|
4
4
|
"description": "OpenCRVS toolkit for building country configurations",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"bin": {
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"libsodium-wrappers": "^0.7.13",
|
|
46
46
|
"lodash": "^4.17.10",
|
|
47
47
|
"object-hash": "^3.0.0",
|
|
48
|
+
"pino": "^7.0.0",
|
|
48
49
|
"prompts": "^2.4.2",
|
|
49
50
|
"qs": "6.15.2",
|
|
50
51
|
"ssh2": "^1.17.0",
|