@opencrvs/toolkit 2.1.0-rc.d13869e → 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.
Files changed (265) hide show
  1. package/README.md +3 -12
  2. package/build.sh +23 -5
  3. package/create-countryconfig/index.js +441 -59
  4. package/create-countryconfig/node_modules/.bin/degit +21 -0
  5. package/create-countryconfig/package.json +4 -1
  6. package/dist/application-config/index.js +362 -284
  7. package/dist/authentication/index.d.ts +66 -0
  8. package/dist/authentication/index.d.ts.map +1 -0
  9. package/dist/authentication/index.js +765 -0
  10. package/dist/cli.js +2119 -1321
  11. package/dist/commons/api/router.d.ts +940 -363
  12. package/dist/commons/application-config/index.d.ts +0 -2
  13. package/dist/commons/conditionals/conditionals.d.ts +6 -6
  14. package/dist/commons/conditionals/validate.d.ts +34 -8
  15. package/dist/commons/events/ActionConfig.d.ts +5 -14
  16. package/dist/commons/events/ActionDocument.d.ts +35 -15
  17. package/dist/commons/events/ActionInput.d.ts +4 -4
  18. package/dist/commons/events/ActionStatus.d.ts +14 -0
  19. package/dist/commons/events/AdvancedSearchConfig.d.ts +48 -12
  20. package/dist/commons/events/AuditLog.d.ts +148 -0
  21. package/dist/commons/events/Draft.d.ts +1 -21
  22. package/dist/commons/events/EventConfig.d.ts +3 -0
  23. package/dist/commons/events/EventDocument.d.ts +472 -4
  24. package/dist/commons/events/EventIndex.d.ts +3 -26
  25. package/dist/commons/events/EventMetadata.d.ts +1 -11
  26. package/dist/commons/events/EventStatus.d.ts +19 -0
  27. package/dist/commons/events/FieldConfig.d.ts +109 -63
  28. package/dist/commons/events/FieldTypeMapping.d.ts +17 -17
  29. package/dist/commons/events/FieldValue.d.ts +3 -2
  30. package/dist/commons/events/Flag.d.ts +42 -0
  31. package/dist/commons/events/FormConfig.d.ts +6 -0
  32. package/dist/commons/events/PageConfig.d.ts +4 -0
  33. package/dist/commons/events/PlainDate.d.ts +8 -0
  34. package/dist/commons/events/SummaryConfig.d.ts +249 -0
  35. package/dist/commons/events/WorkqueueConfig.d.ts +17 -14
  36. package/dist/commons/events/event.d.ts +12 -0
  37. package/dist/commons/events/index.d.ts +1 -0
  38. package/dist/commons/events/locationPayloads.d.ts +95 -0
  39. package/dist/commons/events/locations.d.ts +169 -26
  40. package/dist/commons/events/mocks.test.utils.d.ts +30 -0
  41. package/dist/commons/events/scopes.d.ts +21 -1
  42. package/dist/commons/events/test.utils.d.ts +78 -25
  43. package/dist/commons/events/utils.d.ts +39 -4
  44. package/dist/commons/notification/UserNotifications.d.ts +28 -13
  45. package/dist/commons/notification/dispatch.d.ts +10 -0
  46. package/dist/commons/notification/index.d.ts +1 -0
  47. package/dist/conditionals/index.js +349 -65
  48. package/dist/csv.d.ts +25 -0
  49. package/dist/csv.d.ts.map +1 -0
  50. package/dist/csv.js +120 -0
  51. package/dist/environment/derived-variables.d.ts +18 -0
  52. package/dist/environment/derived-variables.d.ts.map +1 -1
  53. package/dist/environment/derived-variables.js +21 -0
  54. package/dist/environment/index.d.ts +1 -0
  55. package/dist/environment/index.d.ts.map +1 -1
  56. package/dist/environment/index.js +12 -1
  57. package/dist/environment/logger.d.ts +15 -3
  58. package/dist/environment/logger.d.ts.map +1 -1
  59. package/dist/environment/manage-users.js +1 -1
  60. package/dist/environment/paths.d.ts +7 -0
  61. package/dist/environment/paths.d.ts.map +1 -0
  62. package/dist/environment/paths.js +72 -0
  63. package/dist/environment/questions.d.ts +16 -0
  64. package/dist/environment/questions.d.ts.map +1 -1
  65. package/dist/environment/questions.js +46 -15
  66. package/dist/environment/setup-environment.d.ts +1 -1
  67. package/dist/environment/setup-environment.d.ts.map +1 -1
  68. package/dist/environment/setup-environment.js +634 -560
  69. package/dist/environment/swarm-to-k8s.js +3 -4
  70. package/dist/environment/templates.d.ts +0 -1
  71. package/dist/environment/templates.d.ts.map +1 -1
  72. package/dist/environment/templates.js +5 -9
  73. package/dist/environment/update-workflows.d.ts.map +1 -1
  74. package/dist/environment/update-workflows.js +23 -6
  75. package/dist/environment/upgrade.d.ts +2 -0
  76. package/dist/environment/upgrade.d.ts.map +1 -0
  77. package/dist/environment/upgrade.js +82 -0
  78. package/dist/environment/users.js +11 -13
  79. package/dist/environment/utils.d.ts +0 -12
  80. package/dist/environment/utils.d.ts.map +1 -1
  81. package/dist/environment/utils.js +1 -28
  82. package/dist/events/index.js +7689 -7063
  83. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +3 -0
  84. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -0
  85. package/dist/migrations/v2.1/add-recovery-link-notifications.js +511 -0
  86. package/dist/migrations/v2.1/add-translations.d.ts +9 -0
  87. package/dist/migrations/v2.1/add-translations.d.ts.map +1 -0
  88. package/dist/migrations/v2.1/add-translations.js +149 -0
  89. package/dist/migrations/{v2.0/rename-api-paths.d.ts → v2.1/enable-telemetry.d.ts} +1 -1
  90. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -0
  91. package/dist/migrations/v2.1/enable-telemetry.js +455 -0
  92. package/dist/migrations/v2.1/index.d.ts.map +1 -1
  93. package/dist/migrations/v2.1/index.js +47 -215
  94. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +14 -0
  95. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +1 -0
  96. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.js +348 -0
  97. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +2 -0
  98. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +1 -0
  99. package/dist/migrations/v2.1/remove-metabase-package-installs.js +161 -0
  100. package/dist/migrations/{v2.0/migrate-scopes.d.ts → v2.1/remove-sentry.d.ts} +1 -1
  101. package/dist/migrations/v2.1/remove-sentry.d.ts.map +1 -0
  102. package/dist/migrations/v2.1/remove-sentry.js +354 -0
  103. package/dist/migrations/{v2.0/create-events-index.d.ts → v2.1/rename-trigger-paths.d.ts} +1 -1
  104. package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +1 -0
  105. package/dist/migrations/{v2.0/rename-api-paths.js → v2.1/rename-trigger-paths.js} +69 -40
  106. package/dist/migrations/v2.1/template-files.d.ts +8 -0
  107. package/dist/migrations/v2.1/template-files.d.ts.map +1 -0
  108. package/dist/migrations/v2.1/template-files.js +49 -0
  109. package/dist/migrations/v2.1/upgrade-tilt.d.ts +8 -0
  110. package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +1 -0
  111. package/dist/migrations/v2.1/upgrade-tilt.js +139 -0
  112. package/dist/migrations/v2.2/add-e2e-tests.d.ts +19 -0
  113. package/dist/migrations/v2.2/add-e2e-tests.d.ts.map +1 -0
  114. package/dist/migrations/v2.2/add-e2e-tests.js +143 -0
  115. package/dist/migrations/v2.2/index.d.ts +6 -0
  116. package/dist/migrations/v2.2/index.d.ts.map +1 -0
  117. package/dist/migrations/v2.2/index.js +279 -0
  118. package/dist/migrations/v2.2/template-files.d.ts +8 -0
  119. package/dist/migrations/v2.2/template-files.d.ts.map +1 -0
  120. package/dist/migrations/v2.2/template-files.js +49 -0
  121. package/dist/migrations/v2.2/upgrade-tilt.d.ts +8 -0
  122. package/dist/migrations/v2.2/upgrade-tilt.d.ts.map +1 -0
  123. package/dist/migrations/v2.2/upgrade-tilt.js +139 -0
  124. package/dist/notification/index.js +1887 -1438
  125. package/dist/scopes/index.d.ts +614 -36
  126. package/dist/scopes/index.js +351 -65
  127. package/dist/telemetry/index.d.ts +45 -0
  128. package/dist/telemetry/index.d.ts.map +1 -0
  129. package/dist/telemetry/index.js +43 -0
  130. package/dist/templates/charts-values/dependencies/values.yaml +8 -0
  131. package/dist/templates/charts-values/opencrvs-services/values.yaml +10 -3
  132. package/dist/templates/charts-values/opentelemetry/values.yaml +102 -0
  133. package/dist/templates/charts-values/traefik/values.yaml +25 -12
  134. package/dist/templates/countryconfig-template/.tiltignore +1 -0
  135. package/dist/templates/countryconfig-template/Dockerfile.assets +7 -0
  136. package/dist/templates/countryconfig-template/Tiltfile +112 -0
  137. package/dist/templates/countryconfig-template/assets/README.md +1 -0
  138. package/dist/templates/countryconfig-template/assets/clear-all-data-dev.sh +61 -0
  139. package/dist/templates/countryconfig-template/assets/deployment/deploy.sh +455 -0
  140. package/dist/templates/countryconfig-template/assets/deployment/reindex.sh +168 -0
  141. package/dist/templates/countryconfig-template/assets/deployment/validate-required-variables-in-compose-files.ts +67 -0
  142. package/dist/templates/countryconfig-template/assets/elasticsearch/reindex.sh +168 -0
  143. package/dist/templates/countryconfig-template/assets/metabase/README.md +34 -0
  144. package/dist/templates/countryconfig-template/assets/metabase/environment-configuration.sql +36 -0
  145. package/dist/templates/countryconfig-template/assets/metabase/initialize-database.sh +46 -0
  146. package/dist/templates/countryconfig-template/assets/metabase/metabase.init.db.sql +27737 -0
  147. package/dist/templates/countryconfig-template/assets/metabase/open-shell.sh +21 -0
  148. package/dist/templates/countryconfig-template/assets/metabase/package.json +13 -0
  149. package/dist/templates/countryconfig-template/assets/metabase/run-dev.sh +108 -0
  150. package/dist/templates/countryconfig-template/assets/metabase/run.sh +120 -0
  151. package/dist/templates/countryconfig-template/assets/metabase/update-database.sh +40 -0
  152. package/dist/templates/countryconfig-template/assets/postgres/setup-analytics.sh +135 -0
  153. package/dist/templates/countryconfig-template/assets/postgres/setup-reference-data.sh +108 -0
  154. package/dist/templates/countryconfig-template/e2e/README.md +36 -0
  155. package/dist/templates/countryconfig-template/e2e/constants.ts +28 -0
  156. package/dist/templates/countryconfig-template/e2e/login.e2e.ts +59 -0
  157. package/dist/templates/countryconfig-template/package.json +153 -0
  158. package/dist/templates/countryconfig-template/playwright.config.ts +42 -0
  159. package/dist/templates/countryconfig-template/tilt/clear-all-data.ps1 +50 -0
  160. package/dist/templates/countryconfig-template/tilt/clear-all-data.sh +35 -0
  161. package/dist/templates/countryconfig-template/tilt/common.tilt +159 -0
  162. package/dist/templates/countryconfig-template/tilt/examples/dependencies/values.yaml +15 -0
  163. package/dist/templates/countryconfig-template/tilt/examples/opencrvs-services/values.yaml +56 -0
  164. package/dist/templates/countryconfig-template/tilt/examples/traefik/values-minikube.yaml +21 -0
  165. package/dist/templates/countryconfig-template/tilt/examples/traefik/values.yaml +38 -0
  166. package/dist/templates/countryconfig-template/tilt/helm/dependencies/values.yaml +17 -0
  167. package/dist/templates/countryconfig-template/tilt/helm/opencrvs-services/values.yaml +16 -0
  168. package/dist/templates/countryconfig-template/tilt/lib.tilt +95 -0
  169. package/dist/templates/countryconfig-template/tilt/opencrvs.tilt +136 -0
  170. package/dist/templates/inventory/inventory.template.yml +1 -3
  171. package/dist/translations/template.d.ts +11 -0
  172. package/dist/translations/template.d.ts.map +1 -0
  173. package/dist/translations/template.js +100 -0
  174. package/dist/verify/endpoints.d.ts +2 -0
  175. package/dist/verify/endpoints.d.ts.map +1 -0
  176. package/dist/verify/endpoints.js +510 -0
  177. package/opencrvs-toolkit-2.1.0-rc.d235243.tgz +0 -0
  178. package/package.json +13 -7
  179. package/tsconfig.build.json +11 -0
  180. package/tsconfig.build.tsbuildinfo +1 -0
  181. package/tsconfig.json +3 -0
  182. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts +0 -3
  183. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +0 -1
  184. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +0 -429
  185. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +0 -3
  186. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +0 -1
  187. package/dist/migrations/v2.0/add-resend-invite-notification.js +0 -373
  188. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +0 -22
  189. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +0 -1
  190. package/dist/migrations/v2.0/checkout-upstream-files.js +0 -146
  191. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts +0 -2
  192. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +0 -1
  193. package/dist/migrations/v2.0/convert-config-files-to-ts.js +0 -838
  194. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts +0 -3
  195. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +0 -1
  196. package/dist/migrations/v2.0/convert-paragraph-to-heading.js +0 -158
  197. package/dist/migrations/v2.0/create-events-index.d.ts.map +0 -1
  198. package/dist/migrations/v2.0/create-events-index.js +0 -325
  199. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +0 -11
  200. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +0 -1
  201. package/dist/migrations/v2.0/delete-infrastructure-directory.js +0 -123
  202. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts +0 -3
  203. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts.map +0 -1
  204. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.js +0 -110
  205. package/dist/migrations/v2.0/index.d.ts +0 -13
  206. package/dist/migrations/v2.0/index.d.ts.map +0 -1
  207. package/dist/migrations/v2.0/index.js +0 -103
  208. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts +0 -3
  209. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +0 -1
  210. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +0 -432
  211. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +0 -13
  212. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +0 -1
  213. package/dist/migrations/v2.0/merge-infrastructure-directory.js +0 -222
  214. package/dist/migrations/v2.0/migrate-application-config-url.d.ts +0 -3
  215. package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +0 -1
  216. package/dist/migrations/v2.0/migrate-application-config-url.js +0 -343
  217. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +0 -1
  218. package/dist/migrations/v2.0/migrate-scopes.js +0 -305
  219. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts +0 -3
  220. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +0 -1
  221. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +0 -267
  222. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts +0 -3
  223. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +0 -1
  224. package/dist/migrations/v2.0/migrate-workqueue-configs.js +0 -317
  225. package/dist/migrations/v2.0/remove-delete-actions.d.ts +0 -3
  226. package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +0 -1
  227. package/dist/migrations/v2.0/remove-delete-actions.js +0 -156
  228. package/dist/migrations/v2.0/remove-demo-scope.d.ts +0 -3
  229. package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +0 -1
  230. package/dist/migrations/v2.0/remove-demo-scope.js +0 -74
  231. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts +0 -3
  232. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +0 -1
  233. package/dist/migrations/v2.0/remove-deprecated-imports.js +0 -96
  234. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +0 -3
  235. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +0 -1
  236. package/dist/migrations/v2.0/remove-fhir-url-helpers.js +0 -163
  237. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts +0 -3
  238. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +0 -1
  239. package/dist/migrations/v2.0/remove-hearth-migrations.js +0 -87
  240. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +0 -3
  241. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +0 -1
  242. package/dist/migrations/v2.0/remove-old-statistics-service.js +0 -356
  243. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts +0 -3
  244. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +0 -1
  245. package/dist/migrations/v2.0/remove-pending-certification-flag.js +0 -109
  246. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts +0 -3
  247. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +0 -1
  248. package/dist/migrations/v2.0/remove-review-from-register-action.js +0 -163
  249. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +0 -3
  250. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +0 -1
  251. package/dist/migrations/v2.0/remove-unused-environment-variables.js +0 -186
  252. package/dist/migrations/v2.0/rename-api-paths.d.ts.map +0 -1
  253. package/dist/migrations/v2.0/rename-location-parent-id.d.ts +0 -3
  254. package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +0 -1
  255. package/dist/migrations/v2.0/rename-location-parent-id.js +0 -180
  256. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts +0 -3
  257. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +0 -1
  258. package/dist/migrations/v2.0/simplify-analytics-precalculations.js +0 -195
  259. package/dist/migrations/v2.0/update-package-json.d.ts +0 -3
  260. package/dist/migrations/v2.0/update-package-json.d.ts.map +0 -1
  261. package/dist/migrations/v2.0/update-package-json.js +0 -105
  262. package/dist/templates/inventory/production.example.yml +0 -77
  263. package/dist/templates/inventory/qa.example.yml +0 -48
  264. package/opencrvs-toolkit-2.1.0-rc.d13869e.tgz +0 -0
  265. package/tsconfig.tsbuildinfo +0 -1
@@ -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)
@@ -13,10 +13,8 @@ all:
13
13
  # - If you are behind VPN, use private IP address
14
14
  # - If your server is exposed (not recommeded), use public IP address
15
15
  # - If you would like to run kubectl commands from the remote server, leave this field empty
16
- # kube_api_endpoint: ''
17
-
16
+ # kube_api_host: ''
18
17
  # IMPORTANT: If master VM has multiple ethernet interfaces, put private IP address at kube_api_host
19
- # kube_api_host: 10.10.10.10
20
18
  kube_api_host: {{kube_api_host}}
21
19
 
22
20
  # Default ansible provision user, keep as is
@@ -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
+ }
@@ -0,0 +1,2 @@
1
+ export declare function runVerifyEndpoints(target?: string): Promise<void>;
2
+ //# sourceMappingURL=endpoints.d.ts.map
@@ -0,0 +1 @@
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"}