@opencrvs/toolkit 2.1.0-rc.ffe0b7f → 2.2.0-rc.ab91cce

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 (246) hide show
  1. package/README.md +2 -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 +5 -2
  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 +2041 -1311
  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 +77 -7
  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 +29 -6
  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/eventConfigValidation.d.ts +17 -1
  38. package/dist/commons/events/index.d.ts +1 -0
  39. package/dist/commons/events/locationPayloads.d.ts +95 -0
  40. package/dist/commons/events/locations.d.ts +169 -26
  41. package/dist/commons/events/mocks.test.utils.d.ts +30 -0
  42. package/dist/commons/events/scopes.d.ts +21 -1
  43. package/dist/commons/events/test.utils.d.ts +83 -25
  44. package/dist/commons/events/utils.d.ts +52 -17
  45. package/dist/commons/notification/UserNotifications.d.ts +28 -13
  46. package/dist/commons/notification/dispatch.d.ts +10 -0
  47. package/dist/commons/notification/index.d.ts +1 -0
  48. package/dist/conditionals/index.js +349 -65
  49. package/dist/csv.d.ts +25 -0
  50. package/dist/csv.d.ts.map +1 -0
  51. package/dist/csv.js +120 -0
  52. package/dist/environment/derived-variables.d.ts +18 -0
  53. package/dist/environment/derived-variables.d.ts.map +1 -1
  54. package/dist/environment/derived-variables.js +22 -1
  55. package/dist/environment/index.d.ts.map +1 -1
  56. package/dist/environment/index.js +2 -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/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 +610 -560
  65. package/dist/environment/swarm-to-k8s.js +3 -4
  66. package/dist/environment/templates.d.ts +0 -1
  67. package/dist/environment/templates.d.ts.map +1 -1
  68. package/dist/environment/templates.js +3 -8
  69. package/dist/environment/update-workflows.d.ts.map +1 -1
  70. package/dist/environment/update-workflows.js +4 -0
  71. package/dist/environment/utils.d.ts +0 -12
  72. package/dist/environment/utils.d.ts.map +1 -1
  73. package/dist/environment/utils.js +1 -28
  74. package/dist/events/index.js +6115 -5378
  75. package/dist/migrations/add-translations.d.ts +15 -0
  76. package/dist/migrations/add-translations.d.ts.map +1 -0
  77. package/dist/migrations/add-translations.js +151 -0
  78. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +3 -0
  79. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -0
  80. package/dist/migrations/v2.1/add-recovery-link-notifications.js +511 -0
  81. package/dist/migrations/{v2.0/rename-api-paths.d.ts → v2.1/enable-telemetry.d.ts} +1 -1
  82. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -0
  83. package/dist/migrations/v2.1/enable-telemetry.js +455 -0
  84. package/dist/migrations/v2.1/index.d.ts.map +1 -1
  85. package/dist/migrations/v2.1/index.js +47 -215
  86. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +17 -0
  87. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +1 -0
  88. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.js +348 -0
  89. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +2 -0
  90. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +1 -0
  91. package/dist/migrations/v2.1/remove-metabase-package-installs.js +161 -0
  92. package/dist/migrations/{v2.0/migrate-scopes.d.ts → v2.1/remove-sentry.d.ts} +1 -1
  93. package/dist/migrations/v2.1/remove-sentry.d.ts.map +1 -0
  94. package/dist/migrations/v2.1/remove-sentry.js +354 -0
  95. package/dist/migrations/{v2.0/create-events-index.d.ts → v2.1/rename-trigger-paths.d.ts} +1 -1
  96. package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +1 -0
  97. package/dist/migrations/{v2.0/rename-api-paths.js → v2.1/rename-trigger-paths.js} +69 -40
  98. package/dist/migrations/v2.1/template-files.d.ts +8 -0
  99. package/dist/migrations/v2.1/template-files.d.ts.map +1 -0
  100. package/dist/migrations/v2.1/template-files.js +49 -0
  101. package/dist/migrations/v2.1/upgrade-tilt.d.ts +11 -0
  102. package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +1 -0
  103. package/dist/migrations/v2.1/upgrade-tilt.js +139 -0
  104. package/dist/migrations/v2.2/index.d.ts +6 -0
  105. package/dist/migrations/v2.2/index.d.ts.map +1 -0
  106. package/dist/migrations/v2.2/index.js +456 -0
  107. package/dist/migrations/v2.2/read-declaration-through-helper.d.ts +39 -0
  108. package/dist/migrations/v2.2/read-declaration-through-helper.d.ts.map +1 -0
  109. package/dist/migrations/v2.2/read-declaration-through-helper.js +257 -0
  110. package/dist/notification/index.js +2012 -1455
  111. package/dist/scopes/index.d.ts +614 -36
  112. package/dist/scopes/index.js +351 -65
  113. package/dist/telemetry/index.d.ts +45 -0
  114. package/dist/telemetry/index.d.ts.map +1 -0
  115. package/dist/telemetry/index.js +43 -0
  116. package/dist/templates/charts-values/dependencies/values.yaml +8 -0
  117. package/dist/templates/charts-values/opencrvs-services/values.yaml +10 -3
  118. package/dist/templates/charts-values/opentelemetry/values.yaml +102 -0
  119. package/dist/templates/charts-values/traefik/values.yaml +25 -12
  120. package/dist/templates/countryconfig-template/.tiltignore +1 -0
  121. package/dist/templates/countryconfig-template/Dockerfile.assets +7 -0
  122. package/dist/templates/countryconfig-template/Tiltfile +112 -0
  123. package/dist/templates/countryconfig-template/assets/README.md +1 -0
  124. package/dist/templates/countryconfig-template/assets/clear-all-data-dev.sh +61 -0
  125. package/dist/templates/countryconfig-template/assets/deployment/deploy.sh +455 -0
  126. package/dist/templates/countryconfig-template/assets/deployment/reindex.sh +168 -0
  127. package/dist/templates/countryconfig-template/assets/deployment/validate-required-variables-in-compose-files.ts +67 -0
  128. package/dist/templates/countryconfig-template/assets/elasticsearch/reindex.sh +168 -0
  129. package/dist/templates/countryconfig-template/assets/metabase/README.md +34 -0
  130. package/dist/templates/countryconfig-template/assets/metabase/environment-configuration.sql +36 -0
  131. package/dist/templates/countryconfig-template/assets/metabase/initialize-database.sh +46 -0
  132. package/dist/templates/countryconfig-template/assets/metabase/metabase.init.db.sql +27737 -0
  133. package/dist/templates/countryconfig-template/assets/metabase/open-shell.sh +21 -0
  134. package/dist/templates/countryconfig-template/assets/metabase/package.json +13 -0
  135. package/dist/templates/countryconfig-template/assets/metabase/run-dev.sh +108 -0
  136. package/dist/templates/countryconfig-template/assets/metabase/run.sh +120 -0
  137. package/dist/templates/countryconfig-template/assets/metabase/update-database.sh +40 -0
  138. package/dist/templates/countryconfig-template/assets/postgres/setup-analytics.sh +135 -0
  139. package/dist/templates/countryconfig-template/assets/postgres/setup-reference-data.sh +108 -0
  140. package/dist/templates/countryconfig-template/tilt/clear-all-data.ps1 +50 -0
  141. package/dist/templates/countryconfig-template/tilt/clear-all-data.sh +35 -0
  142. package/dist/templates/countryconfig-template/tilt/common.tilt +145 -0
  143. package/dist/templates/countryconfig-template/tilt/examples/dependencies/values.yaml +15 -0
  144. package/dist/templates/countryconfig-template/tilt/examples/opencrvs-services/values.yaml +56 -0
  145. package/dist/templates/countryconfig-template/tilt/examples/traefik/values-minikube.yaml +21 -0
  146. package/dist/templates/countryconfig-template/tilt/examples/traefik/values.yaml +38 -0
  147. package/dist/templates/countryconfig-template/tilt/helm/dependencies/values.yaml +17 -0
  148. package/dist/templates/countryconfig-template/tilt/helm/opencrvs-services/values.yaml +16 -0
  149. package/dist/templates/countryconfig-template/tilt/lib.tilt +95 -0
  150. package/dist/templates/countryconfig-template/tilt/opencrvs.tilt +136 -0
  151. package/dist/templates/inventory/inventory.template.yml +1 -3
  152. package/dist/translations/template.d.ts +11 -0
  153. package/dist/translations/template.d.ts.map +1 -0
  154. package/dist/translations/template.js +100 -0
  155. package/dist/verify/endpoints.d.ts +2 -0
  156. package/dist/verify/endpoints.d.ts.map +1 -0
  157. package/dist/verify/endpoints.js +510 -0
  158. package/opencrvs-toolkit-2.2.0-rc.ab91cce.tgz +0 -0
  159. package/package.json +13 -7
  160. package/tsconfig.build.json +11 -0
  161. package/tsconfig.build.tsbuildinfo +1 -0
  162. package/tsconfig.json +3 -0
  163. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts +0 -3
  164. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +0 -1
  165. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +0 -429
  166. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +0 -3
  167. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +0 -1
  168. package/dist/migrations/v2.0/add-resend-invite-notification.js +0 -373
  169. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +0 -22
  170. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +0 -1
  171. package/dist/migrations/v2.0/checkout-upstream-files.js +0 -146
  172. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts +0 -2
  173. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +0 -1
  174. package/dist/migrations/v2.0/convert-config-files-to-ts.js +0 -838
  175. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts +0 -3
  176. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +0 -1
  177. package/dist/migrations/v2.0/convert-paragraph-to-heading.js +0 -158
  178. package/dist/migrations/v2.0/create-events-index.d.ts.map +0 -1
  179. package/dist/migrations/v2.0/create-events-index.js +0 -325
  180. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +0 -11
  181. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +0 -1
  182. package/dist/migrations/v2.0/delete-infrastructure-directory.js +0 -123
  183. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts +0 -3
  184. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts.map +0 -1
  185. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.js +0 -110
  186. package/dist/migrations/v2.0/index.d.ts +0 -13
  187. package/dist/migrations/v2.0/index.d.ts.map +0 -1
  188. package/dist/migrations/v2.0/index.js +0 -103
  189. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts +0 -3
  190. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +0 -1
  191. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +0 -432
  192. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +0 -13
  193. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +0 -1
  194. package/dist/migrations/v2.0/merge-infrastructure-directory.js +0 -222
  195. package/dist/migrations/v2.0/migrate-application-config-url.d.ts +0 -3
  196. package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +0 -1
  197. package/dist/migrations/v2.0/migrate-application-config-url.js +0 -343
  198. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +0 -1
  199. package/dist/migrations/v2.0/migrate-scopes.js +0 -305
  200. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts +0 -3
  201. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +0 -1
  202. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +0 -267
  203. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts +0 -3
  204. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +0 -1
  205. package/dist/migrations/v2.0/migrate-workqueue-configs.js +0 -317
  206. package/dist/migrations/v2.0/remove-delete-actions.d.ts +0 -3
  207. package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +0 -1
  208. package/dist/migrations/v2.0/remove-delete-actions.js +0 -156
  209. package/dist/migrations/v2.0/remove-demo-scope.d.ts +0 -3
  210. package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +0 -1
  211. package/dist/migrations/v2.0/remove-demo-scope.js +0 -74
  212. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts +0 -3
  213. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +0 -1
  214. package/dist/migrations/v2.0/remove-deprecated-imports.js +0 -96
  215. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +0 -3
  216. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +0 -1
  217. package/dist/migrations/v2.0/remove-fhir-url-helpers.js +0 -163
  218. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts +0 -3
  219. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +0 -1
  220. package/dist/migrations/v2.0/remove-hearth-migrations.js +0 -87
  221. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +0 -3
  222. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +0 -1
  223. package/dist/migrations/v2.0/remove-old-statistics-service.js +0 -356
  224. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts +0 -3
  225. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +0 -1
  226. package/dist/migrations/v2.0/remove-pending-certification-flag.js +0 -109
  227. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts +0 -3
  228. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +0 -1
  229. package/dist/migrations/v2.0/remove-review-from-register-action.js +0 -163
  230. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +0 -3
  231. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +0 -1
  232. package/dist/migrations/v2.0/remove-unused-environment-variables.js +0 -186
  233. package/dist/migrations/v2.0/rename-api-paths.d.ts.map +0 -1
  234. package/dist/migrations/v2.0/rename-location-parent-id.d.ts +0 -3
  235. package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +0 -1
  236. package/dist/migrations/v2.0/rename-location-parent-id.js +0 -180
  237. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts +0 -3
  238. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +0 -1
  239. package/dist/migrations/v2.0/simplify-analytics-precalculations.js +0 -195
  240. package/dist/migrations/v2.0/update-package-json.d.ts +0 -3
  241. package/dist/migrations/v2.0/update-package-json.d.ts.map +0 -1
  242. package/dist/migrations/v2.0/update-package-json.js +0 -105
  243. package/dist/templates/inventory/production.example.yml +0 -77
  244. package/dist/templates/inventory/qa.example.yml +0 -48
  245. package/opencrvs-toolkit-2.1.0-rc.ffe0b7f.tgz +0 -0
  246. package/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,66 @@
1
+ import { Nominal } from './nominal';
2
+ import * as z from 'zod/v4';
3
+ import { ScopeType, Scope, EncodedScope } from './scopes';
4
+ export * from './scopes';
5
+ /**
6
+ * Returns an array of accepted scopes from a JWT token, filtered by the given accepted scope types.
7
+ *
8
+ * @param token - The JWT token containing scope definitions.
9
+ * @param acceptedScopes - An array of acceptable scope types to filter by.
10
+ * @returns An array of parsed RecordScopeV2 objects that are found in the token and match the accepted scope types.
11
+ */
12
+ export declare function getAcceptedScopesFromToken<T extends ScopeType>(token: string, acceptedScopes: T[]): Array<Extract<Scope, {
13
+ type: T;
14
+ }>>;
15
+ export declare const TokenUserType: z.ZodEnum<{
16
+ system: "system";
17
+ user: "user";
18
+ }>;
19
+ export type TokenUserType = z.infer<typeof TokenUserType>;
20
+ export interface ITokenPayload {
21
+ sub: string;
22
+ exp: string;
23
+ algorithm: string;
24
+ scope: EncodedScope[];
25
+ role?: string;
26
+ userType: TokenUserType;
27
+ }
28
+ /**
29
+ * Depending on how the API is called, there might or might not be Bearer keyword in the header.
30
+ * To allow for usage with both direct HTTP calls and TRPC, ensure it's present to be able to use shared scope auth functions.
31
+ */
32
+ export declare function setBearerForToken(token: string): string;
33
+ export declare function getScopes(token: string): EncodedScope[];
34
+ export declare const getTokenPayload: (token: string) => ITokenPayload;
35
+ export declare const getUserId: (token: TokenWithBearer) => string;
36
+ /**
37
+ * Extracts the subject (user ID) from a raw JWT string (without Bearer prefix).
38
+ * Returns null if the token cannot be decoded.
39
+ */
40
+ export declare const getUserIdFromToken: (token: string) => string | null;
41
+ /**
42
+ * Fixed subject (`sub`) of the service token that core's auth service mints at `GET /internal/service-token`.
43
+ * Core uses it for service-to-service calls where no user is involved.
44
+ *
45
+ * Must be a well-formed UUID so a service verifying the token can resolve it as
46
+ * a `SystemContext` as with `INTEGRATION_CREATOR_USER_ID` / `REINDEX_USER_ID`.
47
+ *
48
+ * See packages/auth/src/features/serviceToken/handler.ts
49
+ */
50
+ export declare const SERVICE_USER_ID = "00000000-0000-4000-8000-000000000002";
51
+ /**
52
+ * True when a decoded token payload (e.g. Hapi's `request.auth.credentials`)
53
+ * belongs to core's service token, identified by its fixed subject. A country
54
+ * configuration uses this to accept core's own service-to-service calls (e.g.
55
+ * telemetry, all-user broadcasts) while rejecting any logged-in user's token.
56
+ *
57
+ * Accepts `unknown` so loosely-typed framework credentials can be passed
58
+ * directly without a cast; anything that is not an object with the matching
59
+ * `sub` yields `false`.
60
+ */
61
+ export declare function isServiceToken(credentials: unknown): boolean;
62
+ export declare const getUserTypeFromToken: (token: TokenWithBearer) => TokenUserType;
63
+ export declare const TokenWithBearer: z.ZodType<`Bearer ${string}`>;
64
+ export type TokenWithBearer = z.infer<typeof TokenWithBearer>;
65
+ export type Token = Nominal<string, 'TokenWithoutBearer'>;
66
+ //# sourceMappingURL=authentication.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/authentication/index.ts"],"names":[],"mappings":"AAaA,cAAc,kCAAkC,CAAA"}