@opencrvs/toolkit 2.2.0-rc.045257f → 2.2.0-rc.19ec10b

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 (84) hide show
  1. package/build.sh +7 -2
  2. package/dist/application-config/index.js +16 -5
  3. package/dist/authentication/index.d.ts +1 -1
  4. package/dist/authentication/index.js +4 -8
  5. package/dist/cli.js +927 -356
  6. package/dist/commons/api/router.d.ts +17 -4
  7. package/dist/commons/application-config/index.d.ts +1 -1
  8. package/dist/commons/conditionals/conditionals.d.ts +55 -4
  9. package/dist/commons/conditionals/validate.d.ts +1 -1
  10. package/dist/commons/events/ActionStatus.d.ts +2 -2
  11. package/dist/commons/events/ActionType.d.ts +2 -0
  12. package/dist/commons/events/AdvancedSearchConfig.d.ts +3 -0
  13. package/dist/commons/events/Draft.d.ts +34 -1
  14. package/dist/commons/events/EventConfig.d.ts +446 -0
  15. package/dist/commons/events/EventDocument.d.ts +2 -0
  16. package/dist/commons/events/EventIndex.d.ts +1 -0
  17. package/dist/commons/events/EventInput.d.ts +1 -0
  18. package/dist/commons/events/EventMetadata.d.ts +1 -0
  19. package/dist/commons/events/FieldTypeMapping.d.ts +19 -19
  20. package/dist/commons/events/PlainDate.d.ts +5 -0
  21. package/dist/commons/events/defineConfig.d.ts +7 -2
  22. package/dist/commons/events/event.d.ts +20 -1
  23. package/dist/commons/events/field.d.ts +37 -0
  24. package/dist/commons/events/locations.d.ts +1 -1
  25. package/dist/commons/events/scopes.d.ts +2 -1
  26. package/dist/commons/events/state/index.d.ts +1 -0
  27. package/dist/commons/events/test.utils.d.ts +59 -6
  28. package/dist/commons/events/utils.d.ts +28 -2
  29. package/dist/commons/users/Role.d.ts +23 -0
  30. package/dist/commons/users/User.d.ts +263 -0
  31. package/dist/commons/users/authentication.d.ts +67 -0
  32. package/dist/commons/users/index.d.ts +5 -0
  33. package/dist/commons/users/roleValidations.d.ts +15 -0
  34. package/dist/commons/users/scopes.d.ts +1402 -0
  35. package/dist/commons/users/userReferences.d.ts +176 -0
  36. package/dist/conditionals/index.js +13 -5
  37. package/dist/environment/custom-types.d.ts +1 -0
  38. package/dist/environment/custom-types.d.ts.map +1 -1
  39. package/dist/environment/derived-variables.d.ts +8 -0
  40. package/dist/environment/derived-variables.d.ts.map +1 -1
  41. package/dist/environment/derived-variables.js +9 -0
  42. package/dist/environment/questions.d.ts +42 -9
  43. package/dist/environment/questions.d.ts.map +1 -1
  44. package/dist/environment/questions.js +70 -47
  45. package/dist/environment/registry.d.ts +15 -0
  46. package/dist/environment/registry.d.ts.map +1 -0
  47. package/dist/environment/registry.js +112 -0
  48. package/dist/environment/setup-environment.d.ts.map +1 -1
  49. package/dist/environment/setup-environment.js +104 -23
  50. package/dist/events/index.js +1627 -1100
  51. package/dist/migrations/add-notify-config.d.ts +40 -0
  52. package/dist/migrations/add-notify-config.d.ts.map +1 -0
  53. package/dist/migrations/add-notify-config.js +249 -0
  54. package/dist/migrations/index.d.ts.map +1 -1
  55. package/dist/migrations/index.js +602 -143
  56. package/dist/migrations/move-declaration-to-declare-action.d.ts.map +1 -1
  57. package/dist/migrations/move-declaration-to-declare-action.js +27 -144
  58. package/dist/migrations/read-declaration-through-helper.d.ts.map +1 -1
  59. package/dist/migrations/read-declaration-through-helper.js +3 -61
  60. package/dist/migrations/resolve-versioned-event-config.d.ts +56 -0
  61. package/dist/migrations/resolve-versioned-event-config.d.ts.map +1 -0
  62. package/dist/migrations/resolve-versioned-event-config.js +353 -0
  63. package/dist/migrations/utils.d.ts +61 -0
  64. package/dist/migrations/utils.d.ts.map +1 -0
  65. package/dist/migrations/utils.js +218 -0
  66. package/dist/notification/index.js +707 -119
  67. package/dist/roles/index.d.ts +2 -0
  68. package/dist/roles/index.d.ts.map +1 -0
  69. package/dist/roles/index.js +730 -0
  70. package/dist/scopes/index.d.ts +0 -10
  71. package/dist/scopes/index.js +3 -7
  72. package/dist/templates/charts-values/dependencies/values.yaml +5 -2
  73. package/dist/templates/charts-values/opencrvs-services/values.yaml +2 -5
  74. package/dist/verify/endpoints.d.ts +11 -0
  75. package/dist/verify/endpoints.d.ts.map +1 -1
  76. package/dist/verify/endpoints.js +21 -27
  77. package/opencrvs-toolkit-2.2.0-rc.19ec10b.tgz +0 -0
  78. package/package.json +4 -2
  79. package/tsconfig.build.tsbuildinfo +1 -1
  80. package/tsconfig.json +3 -5
  81. package/dist/environment/dockerhub.d.ts +0 -15
  82. package/dist/environment/dockerhub.d.ts.map +0 -1
  83. package/dist/environment/dockerhub.js +0 -104
  84. package/opencrvs-toolkit-2.2.0-rc.045257f.tgz +0 -0
@@ -1,5 +1,4 @@
1
1
  import * as z from 'zod/v4';
2
- import { Role } from './roles';
3
2
  export declare const JurisdictionFilter: z.ZodEnum<{
4
3
  administrativeArea: "administrativeArea";
5
4
  all: "all";
@@ -1399,14 +1398,5 @@ export declare function canUserNotifyEvent(userScopes: EncodedScope[], eventType
1399
1398
  * @returns Array of scopes in string format, encoded for use in JWT tokens.
1400
1399
  */
1401
1400
  export declare function defineScopes(scopes: Scope[]): (string & z.$brand<"EncodedScope">)[];
1402
- /**
1403
- * Helper for defining user roles. Should be used in country config.
1404
- *
1405
- * @param roles Array of roles in object format.
1406
- */
1407
- export declare function defineRoles(roles: Role[]): {
1408
- id: string;
1409
- scopes: (string & z.$brand<"EncodedScope">)[];
1410
- }[];
1411
1401
  export {};
1412
1402
  //# sourceMappingURL=scopes.d.ts.map
@@ -47,7 +47,6 @@ __export(scopes_exports, {
47
47
  canUserCreateEvent: () => canUserCreateEvent,
48
48
  canUserNotifyEvent: () => canUserNotifyEvent,
49
49
  decodeScope: () => decodeScope,
50
- defineRoles: () => defineRoles,
51
50
  defineScopes: () => defineScopes,
52
51
  encodeScope: () => encodeScope,
53
52
  getAcceptedScopesByType: () => getAcceptedScopesByType,
@@ -64,7 +63,7 @@ __export(scopes_exports, {
64
63
  module.exports = __toCommonJS(scopes_exports);
65
64
  var z9 = __toESM(require("zod/v4"));
66
65
 
67
- // ../commons/src/scopes.ts
66
+ // ../commons/src/users/scopes.ts
68
67
  var z8 = __toESM(require("zod/v4"));
69
68
  var qs = __toESM(require("qs"));
70
69
 
@@ -73,7 +72,7 @@ var import_uuid = require("uuid");
73
72
  var z = __toESM(require("zod/v4"));
74
73
  var UUID = z.uuid().brand("UUID");
75
74
 
76
- // ../commons/src/authentication.ts
75
+ // ../commons/src/users/authentication.ts
77
76
  var import_jwt_decode = __toESM(require("jwt-decode"));
78
77
  var z2 = __toESM(require("zod/v4"));
79
78
  var TokenUserType = z2.enum(["user", "system"]);
@@ -362,7 +361,7 @@ var EventStatus = z7.enum([
362
361
  "ARCHIVED"
363
362
  ]);
364
363
 
365
- // ../commons/src/scopes.ts
364
+ // ../commons/src/users/scopes.ts
366
365
  var JurisdictionFilter = z8.enum(["administrativeArea", "location", "all"]).describe(
367
366
  "Filters based on user jurisdiction relative to their office location in hierarchy."
368
367
  );
@@ -737,9 +736,6 @@ function canUserNotifyEvent(userScopes, eventType) {
737
736
  function defineScopes(scopes) {
738
737
  return scopes.map((scope) => Scope2.parse(scope)).map(encodeScope);
739
738
  }
740
- function defineRoles(roles) {
741
- return roles;
742
- }
743
739
 
744
740
  // src/scopes/index.ts
745
741
  z9.globalRegistry.clear();
@@ -25,8 +25,11 @@ storage_type: host_path
25
25
  node_selector:
26
26
  role: data1
27
27
 
28
- minio:
28
+ rustfs:
29
29
  use_default_credentials: false
30
+ host_data_path: {{rustfs_host_data_path}}
31
+ pvc:
32
+ name: {{rustfs_pvc_name}}
30
33
  {{#if restore_enabled}}
31
34
  restore:
32
35
  type: {{restore_type}}
@@ -51,7 +54,7 @@ postgres:
51
54
  {{/if}}
52
55
 
53
56
  redis:
54
- auth_mode: acl
57
+ use_default_credentials: false
55
58
 
56
59
  monitoring:
57
60
  enabled: {{monitoring_enabled}}
@@ -36,24 +36,21 @@ otel:
36
36
  exporter_otlp_endpoint: "opentelemetry-collector.opencrvs-deps-{{env}}.svc.cluster.local:4317"
37
37
 
38
38
  elasticsearch:
39
- auth_mode: auto
40
39
  host: elasticsearch.opencrvs-deps-{{env}}.svc.cluster.local
41
40
 
42
41
  s3:
43
- host: minio-0.minio.opencrvs-deps-{{env}}.svc.cluster.local
42
+ host: rustfs-0.rustfs.opencrvs-deps-{{env}}.svc.cluster.local
44
43
 
45
44
  redis:
46
- auth_mode: use_secret
47
45
  host: redis-0.redis.opencrvs-deps-{{env}}.svc.cluster.local
48
46
 
49
47
  postgres:
50
- auth_mode: auto
51
48
  host: postgres-0.postgres.opencrvs-deps-{{env}}.svc.cluster.local
52
49
 
53
50
  platform:
54
51
  imagePullSecrets:
55
52
  # Default value for credentials created while yarn environment:init
56
- - name: dockerhub-credentials
53
+ - name: registry-credentials
57
54
 
58
55
  auth:
59
56
  env:
@@ -1,2 +1,13 @@
1
+ interface EventTriggerConfig {
2
+ id: string;
3
+ actions: string[];
4
+ }
5
+ /**
6
+ * Fetches the event configuration so the event action triggers can be checked
7
+ * against the real event ids and action types. Returns `null` if the endpoint
8
+ * is unreachable or does not return the expected shape.
9
+ */
10
+ export declare function fetchEventConfigs(baseUrl: string): Promise<EventTriggerConfig[] | null>;
1
11
  export declare function runVerifyEndpoints(target?: string): Promise<void>;
12
+ export {};
2
13
  //# sourceMappingURL=endpoints.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../../src/verify/endpoints.ts"],"names":[],"mappings":"AAuKA,UAAU,kBAAkB;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AA4BD;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,kBAAkB,EAAE,GAAG,IAAI,CAAC,CActC;AAmPD,wBAAsB,kBAAkB,CACtC,MAAM,GAAE,MAA2B,GAClC,OAAO,CAAC,IAAI,CAAC,CAsIf"}
@@ -42,6 +42,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
42
42
  });
43
43
  };
44
44
  Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.fetchEventConfigs = fetchEventConfigs;
45
46
  exports.runVerifyEndpoints = runVerifyEndpoints;
46
47
  /*
47
48
  * This Source Code Form is subject to the terms of the Mozilla Public
@@ -178,26 +179,24 @@ function requestStatus(url, method) {
178
179
  }
179
180
  });
180
181
  }
181
- function toEventTriggerConfig(value) {
182
- if (typeof value !== 'object' || value === null) {
183
- return null;
184
- }
185
- const record = value;
186
- if (typeof record.id !== 'string') {
187
- return null;
188
- }
189
- const actions = Array.isArray(record.actions)
190
- ? Array.from(new Set(record.actions
191
- .map((action) => {
192
- if (typeof action !== 'object' || action === null) {
193
- return null;
194
- }
195
- const type = action.type;
196
- return typeof type === 'string' ? type : null;
197
- })
198
- .filter((type) => type !== null)))
199
- : [];
200
- return { id: record.id, actions };
182
+ /** One version of an event. Only its action types are needed here. */
183
+ const ServedEventConfigVersion = z.object({
184
+ actions: z.array(z.object({ type: z.string() }))
185
+ });
186
+ /**
187
+ * One event from `GET /config/events`. It comes in two shapes:
188
+ * - `{ id, versions: [{ actions }] }` from toolkit 2.2 and later
189
+ * - `{ id, actions }` from older toolkits, which have no versions
190
+ */
191
+ const ServedEventConfig = z.union([
192
+ z.object({ id: z.string(), versions: z.array(ServedEventConfigVersion) }),
193
+ ServedEventConfigVersion.extend({ id: z.string() })
194
+ ]);
195
+ function toEventTriggerConfig(config) {
196
+ // A trigger may use an action from any version, so collect them all
197
+ const versions = 'versions' in config ? config.versions : [config];
198
+ const actions = versions.flatMap((version) => version.actions.map(({ type }) => type));
199
+ return { id: config.id, actions: Array.from(new Set(actions)) };
201
200
  }
202
201
  /**
203
202
  * Fetches the event configuration so the event action triggers can be checked
@@ -213,13 +212,8 @@ function fetchEventConfigs(baseUrl) {
213
212
  if (!response.ok) {
214
213
  return null;
215
214
  }
216
- const body = yield response.json();
217
- if (!Array.isArray(body)) {
218
- return null;
219
- }
220
- return body
221
- .map(toEventTriggerConfig)
222
- .filter((config) => config !== null);
215
+ const parsed = z.array(ServedEventConfig).safeParse(yield response.json());
216
+ return parsed.success ? parsed.data.map(toEventTriggerConfig) : null;
223
217
  }
224
218
  catch (_a) {
225
219
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/toolkit",
3
- "version": "2.2.0-rc.045257f",
3
+ "version": "2.2.0-rc.19ec10b",
4
4
  "description": "OpenCRVS toolkit for building country configurations",
5
5
  "license": "MPL-2.0",
6
6
  "bin": {
@@ -13,6 +13,7 @@
13
13
  "./events": "./dist/events/index.js",
14
14
  "./telemetry": "./dist/telemetry/index.js",
15
15
  "./scopes": "./dist/scopes/index.js",
16
+ "./roles": "./dist/roles/index.js",
16
17
  "./authentication": "./dist/authentication/index.js",
17
18
  "./events/deduplication": "./dist/events/deduplication.js",
18
19
  "./conditionals": "./dist/conditionals/index.js",
@@ -22,6 +23,7 @@
22
23
  "build": "./build.sh",
23
24
  "build:all": "pnpm -w exec lerna run build --include-dependencies --scope @opencrvs/toolkit",
24
25
  "test": "vitest run",
26
+ "test:watch": "vitest",
25
27
  "test:compilation": "tsc --noEmit"
26
28
  },
27
29
  "repository": {
@@ -69,6 +71,6 @@
69
71
  },
70
72
  "moduleNameMapper": {
71
73
  "@opencrvs/commons/events": "@opencrvs/commons/build/dist/common/events/index.js",
72
- "@opencrvs/commons/scopes": "@opencrvs/commons/build/dist/common/scopes.js"
74
+ "@opencrvs/commons/scopes": "@opencrvs/commons/build/dist/common/users/scopes.js"
73
75
  }
74
76
  }