@opencrvs/toolkit 2.1.0-rc.12673aa → 2.1.0-rc.14fb6a5

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 (188) hide show
  1. package/build.sh +14 -4
  2. package/create-countryconfig/index.js +59 -30
  3. package/dist/application-config/index.js +26 -13
  4. package/dist/authentication/index.d.ts +8 -9
  5. package/dist/authentication/index.js +23 -8
  6. package/dist/cli.js +2268 -1385
  7. package/dist/commons/api/router.d.ts +252 -290
  8. package/dist/commons/application-config/index.d.ts +0 -2
  9. package/dist/commons/conditionals/conditionals.d.ts +6 -6
  10. package/dist/commons/conditionals/validate.d.ts +18 -3
  11. package/dist/commons/events/ActionConfig.d.ts +5 -14
  12. package/dist/commons/events/ActionDocument.d.ts +30 -4
  13. package/dist/commons/events/AdvancedSearchConfig.d.ts +24 -12
  14. package/dist/commons/events/AuditLog.d.ts +1 -0
  15. package/dist/commons/events/Draft.d.ts +1 -21
  16. package/dist/commons/events/EventDocument.d.ts +4 -4
  17. package/dist/commons/events/FieldConfig.d.ts +20 -10
  18. package/dist/commons/events/FieldTypeMapping.d.ts +10 -10
  19. package/dist/commons/events/FieldValue.d.ts +1 -0
  20. package/dist/commons/events/FormConfig.d.ts +6 -0
  21. package/dist/commons/events/PageConfig.d.ts +4 -0
  22. package/dist/commons/events/scopes.d.ts +21 -1
  23. package/dist/commons/events/test.utils.d.ts +53 -21
  24. package/dist/commons/events/utils.d.ts +26 -2
  25. package/dist/conditionals/index.js +21 -7
  26. package/dist/environment/index.d.ts.map +1 -1
  27. package/dist/environment/index.js +2 -1
  28. package/dist/environment/setup-environment.d.ts +1 -1
  29. package/dist/environment/setup-environment.d.ts.map +1 -1
  30. package/dist/environment/setup-environment.js +586 -569
  31. package/dist/environment/swarm-to-k8s.js +3 -4
  32. package/dist/events/index.js +282 -138
  33. package/dist/migrations/v2.1/add-recovery-link-notifications.js +4 -4
  34. package/dist/migrations/v2.1/add-translations.d.ts.map +1 -1
  35. package/dist/migrations/v2.1/add-translations.js +4 -68
  36. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -1
  37. package/dist/migrations/v2.1/enable-telemetry.js +30 -13
  38. package/dist/migrations/v2.1/index.d.ts.map +1 -1
  39. package/dist/migrations/v2.1/index.js +927 -33
  40. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +14 -0
  41. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +1 -0
  42. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.js +348 -0
  43. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +2 -0
  44. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +1 -0
  45. package/dist/migrations/v2.1/remove-metabase-package-installs.js +161 -0
  46. package/dist/migrations/{v2.0/migrate-scopes.d.ts → v2.1/remove-sentry.d.ts} +1 -1
  47. package/dist/migrations/v2.1/remove-sentry.d.ts.map +1 -0
  48. package/dist/migrations/v2.1/remove-sentry.js +354 -0
  49. package/dist/migrations/{v2.0/rename-api-paths.d.ts → v2.1/rename-trigger-paths.d.ts} +1 -1
  50. package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +1 -0
  51. package/dist/migrations/{v2.0/rename-api-paths.js → v2.1/rename-trigger-paths.js} +69 -40
  52. package/dist/migrations/v2.1/template-files.d.ts +8 -0
  53. package/dist/migrations/v2.1/template-files.d.ts.map +1 -0
  54. package/dist/migrations/v2.1/template-files.js +49 -0
  55. package/dist/migrations/v2.1/upgrade-tilt.d.ts +8 -0
  56. package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +1 -0
  57. package/dist/migrations/v2.1/upgrade-tilt.js +139 -0
  58. package/dist/notification/index.js +105 -61
  59. package/dist/scopes/index.d.ts +288 -5
  60. package/dist/scopes/index.js +22 -7
  61. package/dist/telemetry/index.js +4 -0
  62. package/dist/templates/charts-values/dependencies/values.yaml +6 -0
  63. package/dist/templates/charts-values/opencrvs-services/values.yaml +6 -0
  64. package/dist/templates/charts-values/opentelemetry/values.yaml +7 -0
  65. package/dist/templates/countryconfig-template/.tiltignore +1 -0
  66. package/dist/templates/countryconfig-template/Dockerfile.assets +7 -0
  67. package/dist/templates/countryconfig-template/Tiltfile +112 -0
  68. package/dist/templates/countryconfig-template/assets/README.md +1 -0
  69. package/dist/templates/countryconfig-template/assets/clear-all-data-dev.sh +61 -0
  70. package/dist/templates/countryconfig-template/assets/deployment/deploy.sh +455 -0
  71. package/dist/templates/countryconfig-template/assets/deployment/reindex.sh +168 -0
  72. package/dist/templates/countryconfig-template/assets/deployment/validate-required-variables-in-compose-files.ts +67 -0
  73. package/dist/templates/countryconfig-template/assets/elasticsearch/reindex.sh +168 -0
  74. package/dist/templates/countryconfig-template/assets/metabase/README.md +34 -0
  75. package/dist/templates/countryconfig-template/assets/metabase/environment-configuration.sql +36 -0
  76. package/dist/templates/countryconfig-template/assets/metabase/initialize-database.sh +46 -0
  77. package/dist/templates/countryconfig-template/assets/metabase/metabase.init.db.sql +27737 -0
  78. package/dist/templates/countryconfig-template/assets/metabase/open-shell.sh +21 -0
  79. package/dist/templates/countryconfig-template/assets/metabase/package.json +13 -0
  80. package/dist/templates/countryconfig-template/assets/metabase/run-dev.sh +108 -0
  81. package/dist/templates/countryconfig-template/assets/metabase/run.sh +120 -0
  82. package/dist/templates/countryconfig-template/assets/metabase/update-database.sh +40 -0
  83. package/dist/templates/countryconfig-template/assets/postgres/setup-analytics.sh +135 -0
  84. package/dist/templates/countryconfig-template/assets/postgres/setup-reference-data.sh +108 -0
  85. package/dist/templates/countryconfig-template/tilt/clear-all-data.ps1 +50 -0
  86. package/dist/templates/countryconfig-template/tilt/clear-all-data.sh +35 -0
  87. package/dist/templates/countryconfig-template/tilt/common.tilt +145 -0
  88. package/dist/templates/countryconfig-template/tilt/examples/dependencies/values.yaml +15 -0
  89. package/dist/templates/countryconfig-template/tilt/examples/opencrvs-services/values.yaml +56 -0
  90. package/dist/templates/countryconfig-template/tilt/examples/traefik/values-minikube.yaml +21 -0
  91. package/dist/templates/countryconfig-template/tilt/examples/traefik/values.yaml +38 -0
  92. package/dist/templates/countryconfig-template/tilt/helm/dependencies/values.yaml +17 -0
  93. package/dist/templates/countryconfig-template/tilt/helm/opencrvs-services/values.yaml +16 -0
  94. package/dist/templates/countryconfig-template/tilt/lib.tilt +95 -0
  95. package/dist/templates/countryconfig-template/tilt/opencrvs.tilt +136 -0
  96. package/dist/translations/template.d.ts +11 -0
  97. package/dist/translations/template.d.ts.map +1 -0
  98. package/dist/translations/template.js +100 -0
  99. package/dist/verify/endpoints.d.ts.map +1 -1
  100. package/dist/verify/endpoints.js +179 -14
  101. package/opencrvs-toolkit-2.1.0-rc.14fb6a5.tgz +0 -0
  102. package/package.json +2 -1
  103. package/tsconfig.build.tsbuildinfo +1 -1
  104. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts +0 -3
  105. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +0 -1
  106. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +0 -429
  107. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +0 -3
  108. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +0 -1
  109. package/dist/migrations/v2.0/add-resend-invite-notification.js +0 -373
  110. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +0 -22
  111. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +0 -1
  112. package/dist/migrations/v2.0/checkout-upstream-files.js +0 -146
  113. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts +0 -2
  114. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +0 -1
  115. package/dist/migrations/v2.0/convert-config-files-to-ts.js +0 -838
  116. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts +0 -3
  117. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +0 -1
  118. package/dist/migrations/v2.0/convert-paragraph-to-heading.js +0 -158
  119. package/dist/migrations/v2.0/create-events-index.d.ts +0 -3
  120. package/dist/migrations/v2.0/create-events-index.d.ts.map +0 -1
  121. package/dist/migrations/v2.0/create-events-index.js +0 -325
  122. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +0 -11
  123. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +0 -1
  124. package/dist/migrations/v2.0/delete-infrastructure-directory.js +0 -123
  125. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts +0 -3
  126. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts.map +0 -1
  127. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.js +0 -110
  128. package/dist/migrations/v2.0/index.d.ts +0 -13
  129. package/dist/migrations/v2.0/index.d.ts.map +0 -1
  130. package/dist/migrations/v2.0/index.js +0 -103
  131. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts +0 -3
  132. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +0 -1
  133. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +0 -432
  134. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +0 -13
  135. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +0 -1
  136. package/dist/migrations/v2.0/merge-infrastructure-directory.js +0 -222
  137. package/dist/migrations/v2.0/migrate-application-config-url.d.ts +0 -3
  138. package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +0 -1
  139. package/dist/migrations/v2.0/migrate-application-config-url.js +0 -343
  140. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +0 -1
  141. package/dist/migrations/v2.0/migrate-scopes.js +0 -305
  142. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts +0 -3
  143. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +0 -1
  144. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +0 -267
  145. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts +0 -3
  146. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +0 -1
  147. package/dist/migrations/v2.0/migrate-workqueue-configs.js +0 -317
  148. package/dist/migrations/v2.0/remove-delete-actions.d.ts +0 -3
  149. package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +0 -1
  150. package/dist/migrations/v2.0/remove-delete-actions.js +0 -156
  151. package/dist/migrations/v2.0/remove-demo-scope.d.ts +0 -3
  152. package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +0 -1
  153. package/dist/migrations/v2.0/remove-demo-scope.js +0 -74
  154. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts +0 -3
  155. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +0 -1
  156. package/dist/migrations/v2.0/remove-deprecated-imports.js +0 -96
  157. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +0 -3
  158. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +0 -1
  159. package/dist/migrations/v2.0/remove-fhir-url-helpers.js +0 -163
  160. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts +0 -3
  161. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +0 -1
  162. package/dist/migrations/v2.0/remove-hearth-migrations.js +0 -87
  163. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +0 -3
  164. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +0 -1
  165. package/dist/migrations/v2.0/remove-old-statistics-service.js +0 -356
  166. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts +0 -3
  167. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +0 -1
  168. package/dist/migrations/v2.0/remove-pending-certification-flag.js +0 -109
  169. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts +0 -3
  170. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +0 -1
  171. package/dist/migrations/v2.0/remove-review-from-register-action.js +0 -163
  172. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +0 -3
  173. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +0 -1
  174. package/dist/migrations/v2.0/remove-unused-environment-variables.js +0 -186
  175. package/dist/migrations/v2.0/rename-api-paths.d.ts.map +0 -1
  176. package/dist/migrations/v2.0/rename-location-parent-id.d.ts +0 -3
  177. package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +0 -1
  178. package/dist/migrations/v2.0/rename-location-parent-id.js +0 -180
  179. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts +0 -3
  180. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +0 -1
  181. package/dist/migrations/v2.0/simplify-analytics-precalculations.js +0 -195
  182. package/dist/migrations/v2.0/update-package-json.d.ts +0 -3
  183. package/dist/migrations/v2.0/update-package-json.d.ts.map +0 -1
  184. package/dist/migrations/v2.0/update-package-json.js +0 -105
  185. package/dist/translations/check.d.ts +0 -21
  186. package/dist/translations/check.d.ts.map +0 -1
  187. package/dist/translations/check.js +0 -132
  188. package/opencrvs-toolkit-2.1.0-rc.12673aa.tgz +0 -0
package/build.sh CHANGED
@@ -20,7 +20,7 @@ npx tsc --build tsconfig.build.json
20
20
  npx esbuild src/events/index.ts --bundle --format=cjs --outdir=./dist/events --allow-overwrite --packages=external
21
21
 
22
22
  # Build telemetry client (self-contained; .d.ts comes from tsc --build above)
23
- npx esbuild src/telemetry/index.ts --bundle --format=cjs --outdir=./dist/telemetry --allow-overwrite --packages=external
23
+ npx esbuild src/telemetry/index.ts --bundle --platform=node --format=cjs --outdir=./dist/telemetry --allow-overwrite --packages=external
24
24
  mkdir -p ./dist/commons/events
25
25
  cp -r ../commons/build/dist/common/events/*.d.ts ./dist/commons/events
26
26
  mkdir -p ./dist/commons/events/state
@@ -49,7 +49,7 @@ npx esbuild src/events/deduplication.ts --bundle --format=cjs --outdir=./dist/ev
49
49
  cp -r ../commons/build/dist/common/events/deduplication.d.ts ./dist/events/deduplication.d.ts
50
50
 
51
51
  # Build common notifications
52
- npx esbuild src/notification/index.ts --bundle --format=cjs --outdir=./dist/notification --allow-overwrite --packages=external
52
+ npx esbuild src/notification/index.ts --bundle --platform=node --format=cjs --outdir=./dist/notification --allow-overwrite --packages=external
53
53
  mkdir -p ./dist/commons/notification
54
54
  cp -r ../commons/build/dist/common/notification/*.d.ts ./dist/commons/notification
55
55
 
@@ -59,7 +59,7 @@ mkdir -p ./dist/commons/application-config
59
59
  cp -r ../commons/build/dist/common/application-config.d.ts ./dist/commons/application-config/index.d.ts
60
60
 
61
61
  # Build migration CLI
62
- npx esbuild src/migrations/v2.1/index.ts --bundle --format=cjs --outdir=./dist/migrations/v2.1 --allow-overwrite --packages=external --banner:js="#!/usr/bin/env node"
62
+ npx esbuild src/migrations/v2.1/index.ts --bundle --platform=node --format=cjs --outdir=./dist/migrations/v2.1 --allow-overwrite --packages=external --banner:js="#!/usr/bin/env node"
63
63
  chmod +x ./dist/migrations/v2.1/index.js
64
64
 
65
65
  if [[ "$OSTYPE" == "darwin"* ]]; then
@@ -71,8 +71,18 @@ else
71
71
  fi
72
72
 
73
73
  # Build CLI
74
- npx esbuild src/cli.ts --bundle --format=cjs --outdir=./dist --allow-overwrite --packages=external --banner:js="#!/usr/bin/env node"
74
+ npx esbuild src/cli.ts --bundle --platform=node --format=cjs --outdir=./dist --allow-overwrite --packages=external --banner:js="#!/usr/bin/env node"
75
75
  cp -R src/environment/templates dist/templates
76
+ # Template files copied into country configs by the upgrade-tilt and
77
+ # migrate-infrastructure-to-assets codemods. Image builds that use the toolkit as
78
+ # a library (testland, mosip-api) do not copy the template in and do not need them.
79
+ TEMPLATE_DIR=../countryconfig-template
80
+ if [ -d "$TEMPLATE_DIR" ]; then
81
+ mkdir -p dist/templates/countryconfig-template
82
+ cp -R $TEMPLATE_DIR/Tiltfile $TEMPLATE_DIR/.tiltignore $TEMPLATE_DIR/tilt $TEMPLATE_DIR/assets $TEMPLATE_DIR/Dockerfile.assets dist/templates/countryconfig-template/
83
+ else
84
+ echo "$TEMPLATE_DIR not found, 'opencrvs upgrade' will not be able to copy the template files"
85
+ fi
76
86
  chmod +x ./dist/cli.js
77
87
 
78
88
  echo "Build completed successfully."
@@ -96,27 +96,29 @@ function getLatestCommonReleaseTag() {
96
96
  }
97
97
 
98
98
  /**
99
- * A prerelease-shaped own version (e.g. "2.1.0-rc.f5ea803", what npm resolves
100
- * `@next` to - a build published from every push to a branch) never has a
101
- * matching release tag, so it's resolved as a branch instead. Its base
102
- * version (stripped of the "-rc.<sha>" suffix) tells apart two different
103
- * situations: an RC for a version already being stabilized on its own
104
- * "release/X.Y.Z" branch (e.g. "2.0.1-rc.*" while a patch release is in
105
- * progress) versus an RC for a version that hasn't been branched off yet and
106
- * only exists on develop (e.g. "2.1.0-rc.*" while that release branch hasn't
107
- * been cut). Scaffold from the release branch when it exists in both
108
- * repositories, otherwise fall back to develop.
99
+ * Resolves the ref that both repositories are cloned from. A single ref
100
+ * clones both, so every candidate must exist in *both* - a tag present in
101
+ * only one of them can't be used.
109
102
  *
110
- * Otherwise, the own "X.Y.Z" version - whether resolved via npm's `latest`
111
- * dist-tag (bare invocation) or an explicit `@X.Y.Z` pin - scaffolds from the
112
- * matching "vX.Y.Z" tag when it exists in both repositories. If it doesn't
113
- * (e.g. `latest` lagging behind the repos, or a pin that predates one repo's
114
- * tagging), fall back to the highest release tag common to both, rather than
115
- * a mismatched pairing of one tagged repo at that version and another repo
116
- * at a different release. Exits with an error if no matching release tag
117
- * exists in both repositories.
103
+ * The exact "v<version>" tag wins whenever it exists: it pins a commit, so
104
+ * a release, an explicit `@X.Y.Z` pin, or a blessed prerelease (npm `@beta`,
105
+ * published from that tag) reproduces however late it's scaffolded.
106
+ *
107
+ * Otherwise a prerelease falls back to a branch, since a rolling release
108
+ * candidate (npm `@next`) is never tagged: "release/X.Y.Z" of the base
109
+ * version when that release has been cut, otherwise develop. A release
110
+ * falls back to the highest tag common to both repositories - never a
111
+ * mismatched pairing of the two at different releases - or errors.
118
112
  */
119
113
  function resolveRef() {
114
+ const versionTag = 'v' + version
115
+ if (
116
+ tagExists(CORE_REPO_URL, versionTag) &&
117
+ tagExists(INFRASTRUCTURE_REPO_URL, versionTag)
118
+ ) {
119
+ return versionTag
120
+ }
121
+
120
122
  if (version.includes('-')) {
121
123
  const releaseBranch = 'release/' + version.split('-')[0]
122
124
  if (
@@ -128,19 +130,11 @@ function resolveRef() {
128
130
  return 'develop'
129
131
  }
130
132
 
131
- const tag = 'v' + version
132
- if (
133
- tagExists(CORE_REPO_URL, tag) &&
134
- tagExists(INFRASTRUCTURE_REPO_URL, tag)
135
- ) {
136
- return tag
137
- }
138
-
139
133
  const latestCommonTag = getLatestCommonReleaseTag()
140
134
  if (latestCommonTag) {
141
135
  console.warn(
142
136
  '\nWarning: tag "' +
143
- tag +
137
+ versionTag +
144
138
  '" was not found in both repositories; falling back to the latest ' +
145
139
  'available release, ' +
146
140
  latestCommonTag +
@@ -162,13 +156,43 @@ function resolveRef() {
162
156
  * @param {*} param0 repository - The repository to clone (e.g., 'opencrvs/opencrvs-core').
163
157
  * @param {*} param0 repositorySubPath - The subpath within the repository to clone (optional). Otherwise the entire repository will be cloned.
164
158
  * @param {*} param0 branch - The branch to clone (optional). Defaults to the default branch if not specified.
159
+ * @param {*} param0 keepHistory - Keep the repository's git history instead of degit's usual history-free copy (optional, defaults to false). The cloned "origin" remote is replaced with "upstream", leaving the directory ready for the user to add their own fork/repo as "origin". Not supported together with repositorySubPath, since a plain git clone can't fetch a single subdirectory.
165
160
  *
166
161
  * @param {*} targetDir - The target directory where the repository will be cloned.
167
162
  */
168
163
  async function cloneRepository(
169
- { repository, repositorySubPath, branch },
164
+ { repository, repositorySubPath, branch, keepHistory = false },
170
165
  targetDir
171
166
  ) {
167
+ if (keepHistory && repositorySubPath) {
168
+ throw new Error(
169
+ 'cloneRepository: keepHistory is not supported together with repositorySubPath.'
170
+ )
171
+ }
172
+
173
+ if (keepHistory) {
174
+ const repoUrl = `https://github.com/${repository}.git`
175
+ console.log(
176
+ `Cloning repository from ${repoUrl}#${branch} to ${targetDir}...`
177
+ )
178
+
179
+ execSync('git clone --branch ' + branch + ' ' + repoUrl + ' ' + targetDir, {
180
+ stdio: 'inherit'
181
+ })
182
+
183
+ console.log(
184
+ `Copied files from ${repoUrl}#${branch} to ${targetDir} succesfully.`
185
+ )
186
+
187
+ console.log(`Replacing 'origin' remote with 'upstream' in ${targetDir}...`)
188
+ execSync('git remote remove origin', { cwd: targetDir, stdio: 'inherit' })
189
+ execSync('git remote add upstream ' + repoUrl, {
190
+ cwd: targetDir,
191
+ stdio: 'inherit'
192
+ })
193
+ return
194
+ }
195
+
172
196
  const repositoryPath = joinValues([repository, repositorySubPath], '/')
173
197
  const fullPath = joinValues([repositoryPath, branch], '#')
174
198
 
@@ -424,7 +448,7 @@ async function main() {
424
448
 
425
449
  try {
426
450
  await cloneRepository(
427
- { repository: INFRASTRUCTURE_REPOSITORY, branch: ref },
451
+ { repository: INFRASTRUCTURE_REPOSITORY, branch: ref, keepHistory: true },
428
452
  infrastructureTargetPath
429
453
  )
430
454
  } catch (err) {
@@ -450,7 +474,12 @@ async function main() {
450
474
  console.log(' tilt up\n')
451
475
  console.log('To get started with the infrastructure:\n')
452
476
  console.log(' cd ' + infrastructureDirName)
453
- console.log(' git init\n')
477
+ console.log(' git remote add origin <your-infrastructure-repo-url>')
478
+ console.log(' git push -u origin ' + ref + '\n')
479
+ console.log(
480
+ 'The "upstream" remote points at the official infrastructure repository, ' +
481
+ 'so you can pull future releases with `git fetch upstream`.\n'
482
+ )
454
483
  }
455
484
 
456
485
  main()
@@ -331,8 +331,9 @@ var TextValue = z7.string();
331
331
  var HiddenFieldValue = z7.string();
332
332
  var NonEmptyTextValue = z7.string().trim().min(1);
333
333
  var DateValue = z7.iso.date().describe("Date in the format YYYY-MM-DD");
334
+ var AGE_MAX_VALUE = 999;
334
335
  var AgeValue = z7.object({
335
- age: z7.number(),
336
+ age: z7.number().int().min(0).max(AGE_MAX_VALUE),
336
337
  asOfDateRef: z7.string()
337
338
  });
338
339
  var AgeUpdateValue = AgeValue.optional().nullable();
@@ -719,7 +720,9 @@ var RecordScopeTypeV2 = z13.enum([
719
720
  "record.request-correction",
720
721
  "record.correct",
721
722
  "record.unassign-others",
722
- "record.custom-action"
723
+ "record.custom-action",
724
+ "record.action.accept",
725
+ "record.action.reject"
723
726
  ]);
724
727
  var PlainScopeType = z13.enum([
725
728
  // Misc. system scopes
@@ -741,10 +744,7 @@ var PlainScopeType = z13.enum([
741
744
  // Performance dashboard
742
745
  "performance.read",
743
746
  "performance.read-dashboards",
744
- "performance.vital-statistics-export",
745
- // Scopes used exclusively by countryconfig integration token
746
- "record.confirm-registration",
747
- "record.reject-registration"
747
+ "performance.vital-statistics-export"
748
748
  ]);
749
749
  var scopeByEvent = z13.preprocess(
750
750
  (val) => val === void 0 ? void 0 : [val].flat(),
@@ -762,7 +762,9 @@ var userRole = z13.preprocess(
762
762
  ).describe("User role, e.g. admin, field agent");
763
763
  var scopeOptionsPlaceEvent = z13.object({
764
764
  event: scopeByEvent,
765
- placeOfEvent: JurisdictionFilter.optional()
765
+ placeOfEvent: JurisdictionFilter.optional(),
766
+ createdBy: UserFilter.optional(),
767
+ createdIn: JurisdictionFilter.optional()
766
768
  }).describe("Options applicable to all record scopes.");
767
769
  var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
768
770
  notifiedIn: JurisdictionFilter.optional(),
@@ -805,7 +807,9 @@ var AllScopeOptions = z13.object({
805
807
  var ScopeOptionKey = AllScopeOptions.keyof();
806
808
  var ResolvedScopeOptionsPlaceEvent = z13.object({
807
809
  event: scopeByEvent,
808
- placeOfEvent: UUID.nullish()
810
+ placeOfEvent: UUID.nullish(),
811
+ createdBy: z13.string().optional(),
812
+ createdIn: UUID.nullish()
809
813
  }).describe(
810
814
  "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
811
815
  );
@@ -852,6 +856,13 @@ var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
852
856
  "Template IDs for certified copies. Controls which certificate templates are returned to the client via the config service. Certificate printing is a client-side operation \u2014 this option is not validated when the printCertificate action is submitted."
853
857
  )
854
858
  });
859
+ var ActionConfirmationScopeType = RecordScopeTypeV2.extract([
860
+ "record.action.accept",
861
+ "record.action.reject"
862
+ ]);
863
+ var ActionConfirmationScopeOptions = AllRecordScopeOptions.describe(
864
+ "Options for confirming (accepting or rejecting) an action."
865
+ );
855
866
  var RecordScopeV2 = z13.discriminatedUnion("type", [
856
867
  z13.object({
857
868
  type: ScopesWithPlaceEventOptions,
@@ -872,6 +883,10 @@ var RecordScopeV2 = z13.discriminatedUnion("type", [
872
883
  z13.object({
873
884
  type: z13.literal("record.print-certified-copies"),
874
885
  options: ScopeOptionsPrintCertifiedCopies.optional()
886
+ }),
887
+ z13.object({
888
+ type: ActionConfirmationScopeType,
889
+ options: ActionConfirmationScopeOptions.optional()
875
890
  })
876
891
  ]).describe(
877
892
  "Scopes used to check user's permission to perform actions on a record."
@@ -1108,7 +1123,7 @@ var RequestedCorrectionAction = ActionBase.extend(
1108
1123
  var ApprovedCorrectionAction = ActionBase.extend(
1109
1124
  z15.object({
1110
1125
  type: z15.literal(ActionType.APPROVE_CORRECTION),
1111
- requestId: z15.string(),
1126
+ requestId: UUID,
1112
1127
  // TODO move into 'content' property
1113
1128
  content: z15.object({ immediateCorrection: z15.boolean().optional() }).optional()
1114
1129
  }).shape
@@ -1116,7 +1131,7 @@ var ApprovedCorrectionAction = ActionBase.extend(
1116
1131
  var RejectedCorrectionAction = ActionBase.extend(
1117
1132
  z15.object({
1118
1133
  type: z15.literal(ActionType.REJECT_CORRECTION),
1119
- requestId: z15.string(),
1134
+ requestId: UUID,
1120
1135
  // TODO move into 'content' property
1121
1136
  content: ReasonContent
1122
1137
  }).shape
@@ -2370,8 +2385,7 @@ var LoginConfig = z21.object({
2370
2385
  USER_NOTIFICATION_DELIVERY_METHOD: z21.enum(["email", "sms"]),
2371
2386
  INFORMANT_NOTIFICATION_DELIVERY_METHOD: z21.enum(["email", "sms"]),
2372
2387
  PHONE_NUMBER_PATTERN: z21.string().or(z21.instanceof(RegExp)),
2373
- LOGIN_BACKGROUND: BackgroundConfig,
2374
- SENTRY: z21.string().optional()
2388
+ LOGIN_BACKGROUND: BackgroundConfig
2375
2389
  });
2376
2390
  var defineLoginConfig = (config) => {
2377
2391
  return LoginConfig.parse(config);
@@ -2379,7 +2393,6 @@ var defineLoginConfig = (config) => {
2379
2393
  var ClientConfig = z21.object({
2380
2394
  COUNTRY: z21.string(),
2381
2395
  LANGUAGES: z21.array(z21.string()),
2382
- SENTRY: z21.string().optional(),
2383
2396
  LOGIN_URL: z21.string().optional(),
2384
2397
  REGISTER_BACKGROUND: BackgroundConfig,
2385
2398
  DASHBOARDS: z21.array(
@@ -1,7 +1,6 @@
1
1
  import { Nominal } from './nominal';
2
2
  import * as z from 'zod/v4';
3
3
  import { ScopeType, Scope, EncodedScope } from './scopes';
4
- import { UUID } from './uuid';
5
4
  export * from './scopes';
6
5
  /**
7
6
  * Returns an array of accepted scopes from a JWT token, filtered by the given accepted scope types.
@@ -25,8 +24,6 @@ export interface ITokenPayload {
25
24
  scope: EncodedScope[];
26
25
  role?: string;
27
26
  userType: TokenUserType;
28
- eventId?: UUID;
29
- actionId?: UUID;
30
27
  }
31
28
  /**
32
29
  * Depending on how the API is called, there might or might not be Bearer keyword in the header.
@@ -42,13 +39,15 @@ export declare const getUserId: (token: TokenWithBearer) => string;
42
39
  */
43
40
  export declare const getUserIdFromToken: (token: string) => string | null;
44
41
  /**
45
- * Fixed subject (`sub`) of the service token that core's auth service mints
46
- * at `GET /internal/service-token`. The token carries no scopes and has
47
- * userType 'system'; core uses it for unattended service-to-service calls where
48
- * no user is involved — startup event-config load, background broadcasts and
49
- * telemetry. See packages/auth/src/features/serviceToken/handler.ts.
42
+ * Fixed subject (`sub`) of the service token that core's auth service mints at `GET /internal/service-token`.
43
+ * Core uses it for service-to-service calls where no user is involved.
44
+ *
45
+ * Must be a well-formed UUID so a service verifying the token can resolve it as
46
+ * a `SystemContext` as with `INTEGRATION_CREATOR_USER_ID` / `REINDEX_USER_ID`.
47
+ *
48
+ * See packages/auth/src/features/serviceToken/handler.ts
50
49
  */
51
- export declare const SERVICE_USER_ID = "__SERVICE_USER__";
50
+ export declare const SERVICE_USER_ID = "00000000-0000-4000-8000-000000000002";
52
51
  /**
53
52
  * True when a decoded token payload (e.g. Hapi's `request.auth.credentials`)
54
53
  * belongs to core's service token, identified by its fixed subject. A country
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/authentication/index.ts
31
31
  var authentication_exports = {};
32
32
  __export(authentication_exports, {
33
+ ActionConfirmationScopeType: () => ActionConfirmationScopeType,
33
34
  EncodedScope: () => EncodedScope,
34
35
  JurisdictionFilter: () => JurisdictionFilter,
35
36
  RecordScopeTypeV2: () => RecordScopeTypeV2,
@@ -361,7 +362,9 @@ var RecordScopeTypeV2 = z7.enum([
361
362
  "record.request-correction",
362
363
  "record.correct",
363
364
  "record.unassign-others",
364
- "record.custom-action"
365
+ "record.custom-action",
366
+ "record.action.accept",
367
+ "record.action.reject"
365
368
  ]);
366
369
  var PlainScopeType = z7.enum([
367
370
  // Misc. system scopes
@@ -383,10 +386,7 @@ var PlainScopeType = z7.enum([
383
386
  // Performance dashboard
384
387
  "performance.read",
385
388
  "performance.read-dashboards",
386
- "performance.vital-statistics-export",
387
- // Scopes used exclusively by countryconfig integration token
388
- "record.confirm-registration",
389
- "record.reject-registration"
389
+ "performance.vital-statistics-export"
390
390
  ]);
391
391
  var scopeByEvent = z7.preprocess(
392
392
  (val) => val === void 0 ? void 0 : [val].flat(),
@@ -404,7 +404,9 @@ var userRole = z7.preprocess(
404
404
  ).describe("User role, e.g. admin, field agent");
405
405
  var scopeOptionsPlaceEvent = z7.object({
406
406
  event: scopeByEvent,
407
- placeOfEvent: JurisdictionFilter.optional()
407
+ placeOfEvent: JurisdictionFilter.optional(),
408
+ createdBy: UserFilter.optional(),
409
+ createdIn: JurisdictionFilter.optional()
408
410
  }).describe("Options applicable to all record scopes.");
409
411
  var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
410
412
  notifiedIn: JurisdictionFilter.optional(),
@@ -447,7 +449,9 @@ var AllScopeOptions = z7.object({
447
449
  var ScopeOptionKey = AllScopeOptions.keyof();
448
450
  var ResolvedScopeOptionsPlaceEvent = z7.object({
449
451
  event: scopeByEvent,
450
- placeOfEvent: UUID.nullish()
452
+ placeOfEvent: UUID.nullish(),
453
+ createdBy: z7.string().optional(),
454
+ createdIn: UUID.nullish()
451
455
  }).describe(
452
456
  "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
453
457
  );
@@ -494,6 +498,13 @@ var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
494
498
  "Template IDs for certified copies. Controls which certificate templates are returned to the client via the config service. Certificate printing is a client-side operation \u2014 this option is not validated when the printCertificate action is submitted."
495
499
  )
496
500
  });
501
+ var ActionConfirmationScopeType = RecordScopeTypeV2.extract([
502
+ "record.action.accept",
503
+ "record.action.reject"
504
+ ]);
505
+ var ActionConfirmationScopeOptions = AllRecordScopeOptions.describe(
506
+ "Options for confirming (accepting or rejecting) an action."
507
+ );
497
508
  var RecordScopeV2 = z7.discriminatedUnion("type", [
498
509
  z7.object({
499
510
  type: ScopesWithPlaceEventOptions,
@@ -514,6 +525,10 @@ var RecordScopeV2 = z7.discriminatedUnion("type", [
514
525
  z7.object({
515
526
  type: z7.literal("record.print-certified-copies"),
516
527
  options: ScopeOptionsPrintCertifiedCopies.optional()
528
+ }),
529
+ z7.object({
530
+ type: ActionConfirmationScopeType,
531
+ options: ActionConfirmationScopeOptions.optional()
517
532
  })
518
533
  ]).describe(
519
534
  "Scopes used to check user's permission to perform actions on a record."
@@ -736,7 +751,7 @@ var getUserIdFromToken = (token) => {
736
751
  return null;
737
752
  }
738
753
  };
739
- var SERVICE_USER_ID = "__SERVICE_USER__";
754
+ var SERVICE_USER_ID = "00000000-0000-4000-8000-000000000002";
740
755
  function isServiceToken(credentials) {
741
756
  return typeof credentials === "object" && credentials !== null && credentials.sub === SERVICE_USER_ID;
742
757
  }