@opencrvs/toolkit 2.1.0-rc.5396c75 → 2.1.0-rc.562608b

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 (129) hide show
  1. package/README.md +3 -12
  2. package/build.sh +12 -4
  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 +3347 -1229
  11. package/dist/commons/api/router.d.ts +785 -153
  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 +246 -13
  40. package/dist/commons/events/mocks.test.utils.d.ts +46 -2
  41. package/dist/commons/events/scopes.d.ts +21 -1
  42. package/dist/commons/events/test.utils.d.ts +82 -24
  43. package/dist/commons/events/utils.d.ts +34 -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/index.d.ts +1 -0
  52. package/dist/environment/index.d.ts.map +1 -1
  53. package/dist/environment/index.js +12 -1
  54. package/dist/environment/logger.d.ts +15 -3
  55. package/dist/environment/logger.d.ts.map +1 -1
  56. package/dist/environment/manage-users.js +1 -1
  57. package/dist/environment/paths.d.ts +7 -0
  58. package/dist/environment/paths.d.ts.map +1 -0
  59. package/dist/environment/paths.js +72 -0
  60. package/dist/environment/questions.d.ts.map +1 -1
  61. package/dist/environment/questions.js +20 -14
  62. package/dist/environment/setup-environment.d.ts +1 -1
  63. package/dist/environment/setup-environment.d.ts.map +1 -1
  64. package/dist/environment/setup-environment.js +587 -562
  65. package/dist/environment/templates.d.ts +0 -1
  66. package/dist/environment/templates.d.ts.map +1 -1
  67. package/dist/environment/templates.js +5 -9
  68. package/dist/environment/update-workflows.d.ts.map +1 -1
  69. package/dist/environment/update-workflows.js +21 -5
  70. package/dist/environment/upgrade.d.ts +2 -0
  71. package/dist/environment/upgrade.d.ts.map +1 -0
  72. package/dist/environment/upgrade.js +82 -0
  73. package/dist/environment/users.js +11 -13
  74. package/dist/environment/utils.d.ts +0 -12
  75. package/dist/environment/utils.d.ts.map +1 -1
  76. package/dist/environment/utils.js +1 -28
  77. package/dist/events/index.js +5873 -5292
  78. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
  79. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  80. package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
  81. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -1
  82. package/dist/migrations/v2.0/convert-config-files-to-ts.js +3 -10
  83. package/dist/migrations/v2.0/merge-infrastructure-directory.js +3 -3
  84. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +3 -0
  85. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -0
  86. package/dist/migrations/v2.1/add-recovery-link-notifications.js +511 -0
  87. package/dist/migrations/v2.1/add-translations.d.ts +9 -0
  88. package/dist/migrations/v2.1/add-translations.d.ts.map +1 -0
  89. package/dist/migrations/v2.1/add-translations.js +149 -0
  90. package/dist/migrations/v2.1/enable-telemetry.d.ts +3 -0
  91. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -0
  92. package/dist/migrations/v2.1/enable-telemetry.js +455 -0
  93. package/dist/migrations/v2.1/index.d.ts.map +1 -1
  94. package/dist/migrations/v2.1/index.js +1556 -0
  95. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +2 -0
  96. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +1 -0
  97. package/dist/migrations/v2.1/remove-metabase-package-installs.js +161 -0
  98. package/dist/migrations/v2.1/remove-sentry.d.ts +3 -0
  99. package/dist/migrations/v2.1/remove-sentry.d.ts.map +1 -0
  100. package/dist/migrations/v2.1/remove-sentry.js +354 -0
  101. package/dist/migrations/v2.1/rename-trigger-paths.d.ts +3 -0
  102. package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +1 -0
  103. package/dist/migrations/v2.1/rename-trigger-paths.js +216 -0
  104. package/dist/notification/index.js +1899 -1489
  105. package/dist/scopes/index.d.ts +614 -36
  106. package/dist/scopes/index.js +351 -65
  107. package/dist/telemetry/index.d.ts +45 -0
  108. package/dist/telemetry/index.d.ts.map +1 -0
  109. package/dist/telemetry/index.js +43 -0
  110. package/dist/templates/charts-values/dependencies/values.yaml +8 -0
  111. package/dist/templates/charts-values/opencrvs-services/values.yaml +10 -3
  112. package/dist/templates/charts-values/opentelemetry/values.yaml +102 -0
  113. package/dist/templates/charts-values/traefik/values.yaml +23 -9
  114. package/dist/templates/inventory/inventory.template.yml +1 -3
  115. package/dist/translations/template.d.ts +11 -0
  116. package/dist/translations/template.d.ts.map +1 -0
  117. package/dist/translations/template.js +100 -0
  118. package/dist/verify/endpoints.d.ts +2 -0
  119. package/dist/verify/endpoints.d.ts.map +1 -0
  120. package/dist/verify/endpoints.js +510 -0
  121. package/opencrvs-toolkit-2.1.0-rc.562608b.tgz +0 -0
  122. package/package.json +13 -7
  123. package/tsconfig.build.json +11 -0
  124. package/tsconfig.build.tsbuildinfo +1 -0
  125. package/tsconfig.json +3 -0
  126. package/dist/templates/inventory/production.example.yml +0 -77
  127. package/dist/templates/inventory/qa.example.yml +0 -48
  128. package/opencrvs-toolkit-2.1.0-rc.5396c75.tgz +0 -0
  129. package/tsconfig.tsbuildinfo +0 -1
@@ -7,6 +7,12 @@
7
7
  # null in values.override.yaml.
8
8
  ##################################################################################
9
9
 
10
+ network_policy:
11
+ ingress_mode: deny
12
+ egress_mode: deny
13
+ allowed_namespaces:
14
+ - opencrvs-{{env}}
15
+
10
16
  # Default: storage_type: host_path
11
17
  # host_path option is backward compatible with Docker Swarm,
12
18
  # configured to use sub-directories within /data folder
@@ -69,6 +75,7 @@ backup:
69
75
  schedule: "0 1 * * *"
70
76
  backup_server_secret: backup-server-ssh-credentials
71
77
  backup_server_dir: /home/backup/{{env}}
78
+ host: {{backup_host}}
72
79
 
73
80
 
74
81
  # Restore configuration
@@ -78,3 +85,4 @@ restore:
78
85
  backup_server_secret: backup-server-ssh-credentials
79
86
  backup_server_dir: /home/backup/{{restore_environment_name}}
80
87
  backup_encryption_secret: restore-encryption-secret
88
+ host: {{restore_host}}
@@ -17,16 +17,23 @@
17
17
  # - countryconfig.image.tag: Countryconfig image tag
18
18
  environment_type: {{environment_type}}
19
19
 
20
+ network_policy:
21
+ ingress_mode: deny
22
+ egress_mode: deny
23
+ allowed_namespaces:
24
+ - opencrvs-deps-{{env}}
25
+
20
26
  hpa:
21
27
  enabled: false
22
28
 
23
29
  env:
24
- APN_SERVICE_URL: "http://apm-server.opencrvs-deps-{{env}}.svc.cluster.local:8200"
25
30
  MINIO_BUCKET: ocrvs
26
31
  OPENCRVS_ENVIRONMENT: {{opencrvs_environment}}
27
32
 
28
- influxdb:
29
- host: influxdb-0.influxdb.opencrvs-deps-{{env}}.svc.cluster.local
33
+ otel:
34
+ enabled: true
35
+ deployment_environment: {{env}}
36
+ exporter_otlp_endpoint: "opentelemetry-collector.opencrvs-deps-{{env}}.svc.cluster.local:4317"
30
37
 
31
38
  elasticsearch:
32
39
  auth_mode: auto
@@ -0,0 +1,102 @@
1
+ mode: deployment
2
+
3
+ image:
4
+ repository: otel/opentelemetry-collector-k8s
5
+
6
+ networkPolicy:
7
+ enabled: true
8
+ presets:
9
+ kubernetesObjects:
10
+ networking:
11
+ enabled: true
12
+
13
+ resources:
14
+ requests:
15
+ cpu: 100m
16
+ memory: 128Mi
17
+ limits:
18
+ cpu: 500m
19
+ memory: 512Mi
20
+
21
+ ports:
22
+ jaeger-compact:
23
+ enabled: false
24
+ jaeger-thrift:
25
+ enabled: false
26
+ jaeger-grpc:
27
+ enabled: false
28
+ zipkin:
29
+ enabled: false
30
+
31
+ config:
32
+ receivers:
33
+ otlp:
34
+ protocols:
35
+ grpc:
36
+ endpoint: ${env:MY_POD_IP}:4317
37
+ http:
38
+ endpoint: ${env:MY_POD_IP}:4318
39
+ prometheus: null
40
+ jaeger: null
41
+ zipkin: null
42
+
43
+ exporters:
44
+ otlp/elastic:
45
+ endpoint: apm-server.opencrvs-deps-{{env}}.svc.cluster.local:8200
46
+ tls:
47
+ insecure: true
48
+ processors:
49
+ batch:
50
+ timeout: 15s
51
+ send_batch_size: 1024
52
+
53
+ memory_limiter:
54
+ check_interval: 5s
55
+ limit_percentage: 80
56
+ spike_limit_percentage: 25
57
+
58
+ transform/traces:
59
+ error_mode: ignore
60
+ trace_statements:
61
+ # Start with the raw path.
62
+ - set(span.attributes["http.route"], span.attributes["url.path"]) where resource.attributes["service.name"] == "traefik" and span.attributes["url.path"] != nil
63
+
64
+ # Match getTracePath(): collapse repeated slashes.
65
+ - replace_pattern(span.attributes["http.route"], "/+", "/") where resource.attributes["service.name"] == "traefik" and span.attributes["http.route"] != nil
66
+
67
+ # Match getTracePath(): replace dynamic-looking segments with "#".
68
+ - replace_pattern(span.attributes["http.route"], "/([^/]*\\.[^/]*|[0-9]+|[0-9a-fA-F]{24}|[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})(/|$)", "/#$$2") where resource.attributes["service.name"] == "traefik" and span.attributes["http.route"] != nil
69
+
70
+ # Concatenate Request method and normalized URL to conform same format as NodeJs.
71
+ - set(span.name, Concat([span.attributes["http.request.method"], span.attributes["http.route"]], " ")) where resource.attributes["service.name"] == "traefik" and span.attributes["http.request.method"] != nil and span.attributes["http.route"] != nil
72
+
73
+ # SDK language to avoid errors in Kibana on APM -> Service Inventory -> Traefik -> Metrics.
74
+ - delete_key(resource.attributes, "telemetry.sdk.language") where resource.attributes["service.name"] == "traefik"
75
+
76
+ # Nginx OTEL module uses older HTTP semantic convention names, so build the span name from http.method and http.route.
77
+ - set(span.name, Concat([span.attributes["http.method"], span.attributes["http.route"]], " ")) where (resource.attributes["service.name"] == "opencrvs_client" or resource.attributes["service.name"] == "opencrvs_login") and span.attributes["http.method"] != nil and span.attributes["http.route"] != nil
78
+
79
+ service:
80
+ telemetry:
81
+ metrics:
82
+ level: none
83
+ readers: null
84
+ pipelines:
85
+ logs: null
86
+ metrics:
87
+ receivers:
88
+ - otlp
89
+ processors:
90
+ - memory_limiter
91
+ - batch
92
+ exporters:
93
+ - otlp/elastic
94
+ traces:
95
+ receivers:
96
+ - otlp
97
+ processors:
98
+ - memory_limiter
99
+ - transform/traces
100
+ - batch
101
+ exporters:
102
+ - otlp/elastic
@@ -9,16 +9,28 @@
9
9
 
10
10
  # Overwriting https://github.com/traefik/traefik-helm-chart/blob/master/traefik/values.yaml
11
11
  namespaceOverride: "traefik"
12
- logs:
13
- general:
14
- # "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "PANIC"
15
- level: "INFO"
16
- # format: "common" # For local environment
17
- format: "json" # For server environment
18
- access:
19
- # -- To enable access logs
12
+ log:
13
+ # "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "PANIC"
14
+ level: "INFO"
15
+ # format: "common" # For local environment
16
+ format: "json" # For server environment
17
+ accessLog:
18
+ # -- To enable access logs
19
+ enabled: true
20
+ format: "json"
21
+
22
+ tracing:
23
+ serviceName: traefik
24
+ resourceAttributes:
25
+ deployment.environment.name: "{{env}}"
26
+ service.namespace: traefik
27
+ otlp:
20
28
  enabled: true
21
- format: "json"
29
+ grpc:
30
+ enabled: true
31
+ endpoint: "opentelemetry-collector.opencrvs-deps-{{env}}.svc.cluster.local:4317"
32
+ insecure: true
33
+
22
34
 
23
35
  ingressRoute:
24
36
  dashboard:
@@ -98,6 +110,8 @@ tlsStore:
98
110
 
99
111
  deployment:
100
112
  hostNetwork: true
113
+ podLabels:
114
+ service_name: traefik
101
115
  {{#if static_ssl}}
102
116
  kind: DaemonSet
103
117
  {{/if}}
@@ -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"}