@opencrvs/toolkit 2.0.0-rc.2625051 → 2.0.0-rc.32c9d97

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 (79) hide show
  1. package/dist/application-config/index.js +7 -35
  2. package/dist/cli.js +1390 -177
  3. package/dist/commons/api/router.d.ts +1 -2
  4. package/dist/commons/conditionals/conditionals.d.ts +3 -3
  5. package/dist/commons/events/FieldConfig.d.ts +0 -5
  6. package/dist/commons/events/locations.d.ts +1 -17
  7. package/dist/conditionals/index.js +7 -35
  8. package/dist/events/index.js +7 -73
  9. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +1 -1
  10. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +3 -4
  11. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +3 -0
  12. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +1 -0
  13. package/dist/migrations/v2.0/add-resend-invite-notification.js +373 -0
  14. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +19 -0
  15. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  16. package/dist/migrations/v2.0/checkout-upstream-files.js +17 -13
  17. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -1
  18. package/dist/migrations/v2.0/convert-config-files-to-ts.js +4 -5
  19. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +1 -1
  20. package/dist/migrations/v2.0/convert-paragraph-to-heading.js +4 -5
  21. package/dist/migrations/v2.0/create-events-index.d.ts.map +1 -1
  22. package/dist/migrations/v2.0/create-events-index.js +1 -2
  23. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +3 -0
  24. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -0
  25. package/dist/migrations/v2.0/delete-infrastructure-directory.js +77 -0
  26. package/dist/migrations/v2.0/index.d.ts +8 -4
  27. package/dist/migrations/v2.0/index.d.ts.map +1 -1
  28. package/dist/migrations/v2.0/index.js +1358 -174
  29. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -1
  30. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +5 -6
  31. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +3 -0
  32. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -0
  33. package/dist/migrations/v2.0/merge-infrastructure-directory.js +221 -0
  34. package/dist/migrations/v2.0/migrate-application-config-url.d.ts +3 -0
  35. package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +1 -0
  36. package/dist/migrations/v2.0/migrate-application-config-url.js +342 -0
  37. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -1
  38. package/dist/migrations/v2.0/migrate-scopes.js +6 -7
  39. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +1 -1
  40. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +3 -4
  41. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -1
  42. package/dist/migrations/v2.0/migrate-workqueue-configs.js +3 -4
  43. package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +1 -1
  44. package/dist/migrations/v2.0/remove-delete-actions.js +3 -4
  45. package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -1
  46. package/dist/migrations/v2.0/remove-demo-scope.js +2 -3
  47. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +1 -1
  48. package/dist/migrations/v2.0/remove-deprecated-imports.js +3 -4
  49. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +3 -0
  50. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +1 -0
  51. package/dist/migrations/v2.0/remove-fhir-url-helpers.js +163 -0
  52. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -1
  53. package/dist/migrations/v2.0/remove-hearth-migrations.js +1 -2
  54. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +3 -0
  55. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +1 -0
  56. package/dist/migrations/v2.0/remove-old-statistics-service.js +356 -0
  57. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +1 -1
  58. package/dist/migrations/v2.0/remove-pending-certification-flag.js +3 -4
  59. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +1 -1
  60. package/dist/migrations/v2.0/remove-review-from-register-action.js +3 -4
  61. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +3 -0
  62. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +1 -0
  63. package/dist/migrations/v2.0/remove-unused-environment-variables.js +186 -0
  64. package/dist/migrations/v2.0/rename-api-paths.d.ts.map +1 -1
  65. package/dist/migrations/v2.0/rename-api-paths.js +3 -4
  66. package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +1 -1
  67. package/dist/migrations/v2.0/rename-location-parent-id.js +3 -4
  68. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +1 -1
  69. package/dist/migrations/v2.0/simplify-analytics-precalculations.js +1 -2
  70. package/dist/migrations/v2.0/update-package-json.d.ts +3 -0
  71. package/dist/migrations/v2.0/update-package-json.d.ts.map +1 -0
  72. package/dist/migrations/v2.0/update-package-json.js +105 -0
  73. package/dist/notification/index.js +7 -35
  74. package/dist/scopes/index.d.ts +10 -82
  75. package/dist/scopes/index.js +8 -41
  76. package/opencrvs-toolkit-2.0.0-rc.32c9d97.tgz +0 -0
  77. package/package.json +1 -1
  78. package/tsconfig.tsbuildinfo +1 -1
  79. package/opencrvs-toolkit-2.0.0-rc.2625051.tgz +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"rename-location-parent-id.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/rename-location-parent-id.ts"],"names":[],"mappings":"AAqJA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"rename-location-parent-id.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/rename-location-parent-id.ts"],"names":[],"mappings":"AAmJA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -45,7 +45,6 @@ exports.main = main;
45
45
  */
46
46
  const ts_morph_1 = require("ts-morph");
47
47
  const path_1 = __importDefault(require("path"));
48
- const _1 = require(".");
49
48
  const OLD_PROPERTY_NAME = 'parentId';
50
49
  const NEW_PROPERTY_NAME = 'administrativeAreaId';
51
50
  const LOCATION_TYPE_NAME = 'Location';
@@ -138,14 +137,14 @@ function processFile(filePath, project) {
138
137
  // surrounding whitespace and optional-chain tokens (?.)
139
138
  propAccess.getNameNode().replaceWithText(NEW_PROPERTY_NAME);
140
139
  renamedCount++;
141
- console.log(` [${path_1.default.relative((0, _1.getCwd)(), filePath)}] Renamed Location.${OLD_PROPERTY_NAME} → Location.${NEW_PROPERTY_NAME}`);
140
+ console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Renamed Location.${OLD_PROPERTY_NAME} → Location.${NEW_PROPERTY_NAME}`);
142
141
  }
143
142
  return renamedCount;
144
143
  }
145
144
  // ─── Entry point ─────────────────────────────────────────────────────────────
146
145
  function main() {
147
146
  return __awaiter(this, void 0, void 0, function* () {
148
- const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
147
+ const srcDir = path_1.default.join(process.cwd(), 'src');
149
148
  console.log(`Scanning for Location.${OLD_PROPERTY_NAME} references in: ${srcDir}\n`);
150
149
  const project = new ts_morph_1.Project({
151
150
  tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
@@ -174,7 +173,7 @@ function main() {
174
173
  for (const filePath of modifiedFiles) {
175
174
  const sourceFile = project.getSourceFileOrThrow(filePath);
176
175
  yield sourceFile.save();
177
- console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
176
+ console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
178
177
  }
179
178
  console.log(`\nDone. Renamed ${totalRenamed} Location.${OLD_PROPERTY_NAME} reference(s) to Location.${NEW_PROPERTY_NAME}.`);
180
179
  });
@@ -1 +1 @@
1
- {"version":3,"file":"simplify-analytics-precalculations.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/simplify-analytics-precalculations.ts"],"names":[],"mappings":"AAuLA,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAyCnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"simplify-analytics-precalculations.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/simplify-analytics-precalculations.ts"],"names":[],"mappings":"AAqLA,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAyCnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -51,7 +51,6 @@ exports.main = main;
51
51
  const ts_morph_1 = require("ts-morph");
52
52
  const fs_1 = __importDefault(require("fs"));
53
53
  const path_1 = __importDefault(require("path"));
54
- const _1 = require(".");
55
54
  const ANALYTICS_FILE_REL = 'src/analytics/analytics.ts';
56
55
  const FUNCTION_NAME = 'precalculateAdditionalAnalytics';
57
56
  const IMPORT_NAMES_TO_REMOVE = new Set(['Event', 'precalculateBirthEvent']);
@@ -164,7 +163,7 @@ function simplifyPrecalculateFunction(sourceFile) {
164
163
  // ─── Entry point ─────────────────────────────────────────────────────────────
165
164
  function main() {
166
165
  return __awaiter(this, void 0, void 0, function* () {
167
- const cwd = (0, _1.getCwd)();
166
+ const cwd = process.cwd();
168
167
  const absPath = path_1.default.join(cwd, ANALYTICS_FILE_REL);
169
168
  if (!fs_1.default.existsSync(absPath)) {
170
169
  console.log(`[${ANALYTICS_FILE_REL}] does not exist — nothing to clean up.`);
@@ -0,0 +1,3 @@
1
+ declare function main(): Promise<void>;
2
+ export { main };
3
+ //# sourceMappingURL=update-package-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-package-json.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/update-package-json.ts"],"names":[],"mappings":"AA2CA,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAyEnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -0,0 +1,105 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.main = main;
26
+ /**
27
+ * Codemod: Update root `package.json` for the v1.9 → v2.0 upgrade.
28
+ *
29
+ * Changes applied:
30
+ * 1. Sets `version` to `2.0.0`.
31
+ * 2. Sets `zod` to `^4.2.1` in `dependencies` (or `devDependencies` if it
32
+ * already lives there). If `zod` is absent from both, it's added to
33
+ * `dependencies`.
34
+ *
35
+ * Caveats:
36
+ * - The codemod preserves the file's existing 2-space indentation and
37
+ * trailing newline. Any non-standard formatting (e.g. tabs) will be
38
+ * replaced with 2-space indentation.
39
+ * - No-op when `package.json` is missing.
40
+ * - No automatic `yarn install` is run; the developer should reinstall
41
+ * dependencies after the codemods complete.
42
+ */
43
+ const fs_1 = require("fs");
44
+ const path_1 = __importDefault(require("path"));
45
+ const PACKAGE_JSON_RELATIVE = 'package.json';
46
+ const TARGET_VERSION = '2.0.0';
47
+ const TARGET_ZOD_RANGE = '^4.2.1';
48
+ function main() {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ const packageJsonPath = path_1.default.join(process.cwd(), PACKAGE_JSON_RELATIVE);
51
+ if (!(0, fs_1.existsSync)(packageJsonPath)) {
52
+ console.log(`'${PACKAGE_JSON_RELATIVE}' not found in ${process.cwd()} — skipping.`);
53
+ return;
54
+ }
55
+ const raw = (0, fs_1.readFileSync)(packageJsonPath, 'utf8');
56
+ let parsed;
57
+ try {
58
+ parsed = JSON.parse(raw);
59
+ }
60
+ catch (error) {
61
+ console.warn(` [${PACKAGE_JSON_RELATIVE}] Failed to parse JSON — skipping update. ${error.message}`);
62
+ return;
63
+ }
64
+ console.log(`Updating '${PACKAGE_JSON_RELATIVE}'...`);
65
+ const previousVersion = parsed.version;
66
+ const versionChanged = previousVersion !== TARGET_VERSION;
67
+ parsed.version = TARGET_VERSION;
68
+ if (versionChanged) {
69
+ console.log(` Set version: ${previousVersion !== null && previousVersion !== void 0 ? previousVersion : '<unset>'} → ${TARGET_VERSION}`);
70
+ }
71
+ else {
72
+ console.log(` Version already ${TARGET_VERSION} — no change.`);
73
+ }
74
+ // Resolve which dependency bucket already holds zod, defaulting to
75
+ // `dependencies` when absent.
76
+ let zodBucket = 'dependencies';
77
+ if (parsed.devDependencies && 'zod' in parsed.devDependencies) {
78
+ zodBucket = 'devDependencies';
79
+ }
80
+ if (!parsed[zodBucket]) {
81
+ parsed[zodBucket] = {};
82
+ }
83
+ const bucket = parsed[zodBucket];
84
+ const previousZod = bucket.zod;
85
+ const zodChanged = previousZod !== TARGET_ZOD_RANGE;
86
+ bucket.zod = TARGET_ZOD_RANGE;
87
+ if (zodChanged) {
88
+ console.log(` Set ${zodBucket}.zod: ${previousZod !== null && previousZod !== void 0 ? previousZod : '<absent>'} → ${TARGET_ZOD_RANGE}`);
89
+ }
90
+ else {
91
+ console.log(` ${zodBucket}.zod already ${TARGET_ZOD_RANGE} — no change.`);
92
+ }
93
+ // Preserve trailing newline if the source had one (default to LF since
94
+ // most repos commit JSON with a trailing newline).
95
+ const trailingNewline = raw.endsWith('\n') ? '\n' : '';
96
+ const next = JSON.stringify(parsed, null, 2) + trailingNewline;
97
+ if (next === raw) {
98
+ console.log('\n No changes to write.');
99
+ return;
100
+ }
101
+ (0, fs_1.writeFileSync)(packageJsonPath, next, 'utf8');
102
+ console.log(`\n Saved '${PACKAGE_JSON_RELATIVE}'.`);
103
+ console.log(` NOTE: run \`yarn install\` (or your package manager equivalent) to install the updated dependency versions.`);
104
+ });
105
+ }
@@ -110,10 +110,6 @@ var scopeByEvent = z2.preprocess(
110
110
  (val) => val === void 0 ? void 0 : [val].flat(),
111
111
  z2.array(z2.string()).optional()
112
112
  ).describe("Event type, e.g. birth, death");
113
- var userRole = z2.preprocess(
114
- (val) => val === void 0 ? void 0 : [val].flat(),
115
- z2.array(z2.string()).optional()
116
- ).describe("User role, e.g. admin, field agent");
117
113
  var scopeOptionsPlaceEvent = z2.object({
118
114
  event: scopeByEvent,
119
115
  placeOfEvent: JurisdictionFilter.optional()
@@ -137,9 +133,6 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
137
133
  var AccessLevelOptions = z2.object({
138
134
  accessLevel: JurisdictionFilter.optional()
139
135
  });
140
- var AllUserScopeOptions = AccessLevelOptions.extend({
141
- role: userRole.optional()
142
- });
143
136
  var WorkqueueOrDashboardOptions = z2.object({
144
137
  ids: z2.preprocess(
145
138
  (val) => val === void 0 ? void 0 : [val].flat(),
@@ -149,7 +142,6 @@ var WorkqueueOrDashboardOptions = z2.object({
149
142
  var AllScopeOptions = z2.object({
150
143
  ...AllRecordScopeOptions.shape,
151
144
  ...AccessLevelOptions.shape,
152
- ...AllUserScopeOptions.shape,
153
145
  ...WorkqueueOrDashboardOptions.shape
154
146
  });
155
147
  var ScopeOptionKey = AllScopeOptions.keyof();
@@ -222,28 +214,6 @@ var RecordScopeV2 = z2.discriminatedUnion("type", [
222
214
  ]).describe(
223
215
  "Scopes used to check user's permission to perform actions on a record."
224
216
  );
225
- var SystemScopeType = z2.enum([
226
- "organisation.read-locations",
227
- "user.read",
228
- "user.create",
229
- "user.edit"
230
- ]);
231
- var UserScopeType = SystemScopeType.extract([
232
- "user.read",
233
- "user.create",
234
- "user.edit"
235
- ]);
236
- var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
237
- var UserScopeV2 = z2.discriminatedUnion("type", [
238
- z2.object({
239
- type: ScopesWithRoleOption,
240
- options: AllUserScopeOptions.optional()
241
- }),
242
- z2.object({
243
- type: UserScopeType.extract(["user.read"]),
244
- options: AccessLevelOptions.optional()
245
- })
246
- ]);
247
217
  var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
248
218
  z2.object({
249
219
  type: ScopesWithPlaceEventOptions,
@@ -264,14 +234,16 @@ var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
264
234
  }).optional()
265
235
  })
266
236
  ]).describe("Resolved scope with location/user IDs instead of filters.");
237
+ var SystemScopeType = z2.enum([
238
+ "organisation.read-locations",
239
+ "user.read",
240
+ "user.create",
241
+ "user.edit"
242
+ ]);
267
243
  var Scope = z2.discriminatedUnion("type", [
268
244
  z2.object({ type: PlainScopeType }),
269
245
  ...RecordScopeV2.options,
270
- ...UserScopeV2.options,
271
- z2.object({
272
- type: z2.literal("organisation.read-locations"),
273
- options: AccessLevelOptions.optional()
274
- }),
246
+ z2.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
275
247
  z2.object({
276
248
  type: z2.literal("workqueue"),
277
249
  options: WorkqueueOrDashboardOptions
@@ -41,7 +41,6 @@ declare const AllScopeOptions: z.ZodObject<{
41
41
  location: "location";
42
42
  all: "all";
43
43
  }>>;
44
- role: z.ZodOptional<z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>>;
45
44
  event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
46
45
  placeOfEvent: z.ZodOptional<z.ZodEnum<{
47
46
  administrativeArea: "administrativeArea";
@@ -67,7 +66,6 @@ declare const AllScopeOptions: z.ZodObject<{
67
66
  }, z.core.$strip>;
68
67
  type AllScopeOptions = z.infer<typeof AllScopeOptions>;
69
68
  export declare const ScopeOptionKey: z.ZodEnum<{
70
- role: "role";
71
69
  event: "event";
72
70
  placeOfEvent: "placeOfEvent";
73
71
  declaredIn: "declaredIn";
@@ -222,53 +220,6 @@ export declare const RecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
222
220
  templates: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
223
221
  }, z.core.$strip>>;
224
222
  }, z.core.$strip>], "type">;
225
- declare const SystemScopeType: z.ZodEnum<{
226
- "organisation.read-locations": "organisation.read-locations";
227
- "user.read": "user.read";
228
- "user.create": "user.create";
229
- "user.edit": "user.edit";
230
- }>;
231
- export type SystemScopeType = z.infer<typeof SystemScopeType>;
232
- declare const UserScopeType: z.ZodEnum<{
233
- "user.read": "user.read";
234
- "user.create": "user.create";
235
- "user.edit": "user.edit";
236
- }>;
237
- export type UserScopeType = z.infer<typeof UserScopeType>;
238
- declare const ScopesWithRoleOption: z.ZodEnum<{
239
- "user.create": "user.create";
240
- "user.edit": "user.edit";
241
- }>;
242
- export type ScopesWithRoleOption = z.infer<typeof ScopesWithRoleOption>;
243
- export declare const UserScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
244
- type: z.ZodEnum<{
245
- "user.create": "user.create";
246
- "user.edit": "user.edit";
247
- }>;
248
- options: z.ZodOptional<z.ZodObject<{
249
- accessLevel: z.ZodOptional<z.ZodEnum<{
250
- administrativeArea: "administrativeArea";
251
- location: "location";
252
- all: "all";
253
- }>>;
254
- role: z.ZodOptional<z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>>;
255
- }, z.core.$strip>>;
256
- }, z.core.$strip>, z.ZodObject<{
257
- type: z.ZodEnum<{
258
- "user.read": "user.read";
259
- }>;
260
- options: z.ZodOptional<z.ZodObject<{
261
- accessLevel: z.ZodOptional<z.ZodEnum<{
262
- administrativeArea: "administrativeArea";
263
- location: "location";
264
- all: "all";
265
- }>>;
266
- }, z.core.$strip>>;
267
- }, z.core.$strip>], "type">;
268
- export type UserScopeV2 = z.infer<typeof UserScopeV2>;
269
- export declare function scopeUsesRoleOptions(scope: UserScopeV2): scope is Extract<UserScopeV2, {
270
- type: ScopesWithRoleOption;
271
- }>;
272
223
  export declare function scopeUsesDeclaredOptions(scope: Scope): scope is Extract<Scope, {
273
224
  type: z.infer<typeof ScopesWithDeclaredOptions>;
274
225
  }>;
@@ -335,6 +286,13 @@ export declare const ResolvedRecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject
335
286
  }, z.core.$strip>], "type">;
336
287
  export type RecordScopeV2 = z.infer<typeof RecordScopeV2>;
337
288
  export type ResolvedRecordScopeV2 = z.infer<typeof ResolvedRecordScopeV2>;
289
+ declare const SystemScopeType: z.ZodEnum<{
290
+ "organisation.read-locations": "organisation.read-locations";
291
+ "user.read": "user.read";
292
+ "user.create": "user.create";
293
+ "user.edit": "user.edit";
294
+ }>;
295
+ export type SystemScopeType = z.infer<typeof SystemScopeType>;
338
296
  /** The primary scope schema which gathers all scope types together. All scopes are discriminated by type and options are determined according to the type. */
339
297
  export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
340
298
  type: z.ZodEnum<{
@@ -479,30 +437,11 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
479
437
  }, z.core.$strip>>;
480
438
  }, z.core.$strip>, z.ZodObject<{
481
439
  type: z.ZodEnum<{
440
+ "organisation.read-locations": "organisation.read-locations";
441
+ "user.read": "user.read";
482
442
  "user.create": "user.create";
483
443
  "user.edit": "user.edit";
484
444
  }>;
485
- options: z.ZodOptional<z.ZodObject<{
486
- accessLevel: z.ZodOptional<z.ZodEnum<{
487
- administrativeArea: "administrativeArea";
488
- location: "location";
489
- all: "all";
490
- }>>;
491
- role: z.ZodOptional<z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>>;
492
- }, z.core.$strip>>;
493
- }, z.core.$strip>, z.ZodObject<{
494
- type: z.ZodEnum<{
495
- "user.read": "user.read";
496
- }>;
497
- options: z.ZodOptional<z.ZodObject<{
498
- accessLevel: z.ZodOptional<z.ZodEnum<{
499
- administrativeArea: "administrativeArea";
500
- location: "location";
501
- all: "all";
502
- }>>;
503
- }, z.core.$strip>>;
504
- }, z.core.$strip>, z.ZodObject<{
505
- type: z.ZodLiteral<"organisation.read-locations">;
506
445
  options: z.ZodOptional<z.ZodObject<{
507
446
  accessLevel: z.ZodOptional<z.ZodEnum<{
508
447
  administrativeArea: "administrativeArea";
@@ -628,21 +567,10 @@ export declare const decodeScope: (query: EncodedScope) => {
628
567
  registeredBy?: "user" | undefined;
629
568
  templates?: string[] | undefined;
630
569
  } | undefined;
631
- } | {
632
- type: "user.create" | "user.edit";
633
- options?: {
634
- accessLevel?: "administrativeArea" | "location" | "all" | undefined;
635
- role?: string[] | undefined;
636
- } | undefined;
637
- } | {
638
- type: "user.read";
639
- options?: {
640
- accessLevel?: "administrativeArea" | "location" | "all" | undefined;
641
- } | undefined;
642
570
  } | {
643
571
  type: "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration";
644
572
  } | {
645
- type: "organisation.read-locations";
573
+ type: "organisation.read-locations" | "user.read" | "user.create" | "user.edit";
646
574
  options?: {
647
575
  accessLevel?: "administrativeArea" | "location" | "all" | undefined;
648
576
  } | undefined;
@@ -42,7 +42,6 @@ __export(scopes_exports, {
42
42
  ScopesWithFullOptions: () => ScopesWithFullOptions,
43
43
  ScopesWithPlaceEventOptions: () => ScopesWithPlaceEventOptions,
44
44
  UserFilter: () => UserFilter,
45
- UserScopeV2: () => UserScopeV2,
46
45
  canUserCreateEvent: () => canUserCreateEvent,
47
46
  decodeScope: () => decodeScope,
48
47
  defineRoles: () => defineRoles,
@@ -55,8 +54,7 @@ __export(scopes_exports, {
55
54
  isCustomActionScope: () => isCustomActionScope,
56
55
  scopeUsesDeclaredOptions: () => scopeUsesDeclaredOptions,
57
56
  scopeUsesFullOptions: () => scopeUsesFullOptions,
58
- scopeUsesPrintCertifiedCopiesOptions: () => scopeUsesPrintCertifiedCopiesOptions,
59
- scopeUsesRoleOptions: () => scopeUsesRoleOptions
57
+ scopeUsesPrintCertifiedCopiesOptions: () => scopeUsesPrintCertifiedCopiesOptions
60
58
  });
61
59
  module.exports = __toCommonJS(scopes_exports);
62
60
  var z4 = __toESM(require("zod/v4"));
@@ -141,10 +139,6 @@ var scopeByEvent = z3.preprocess(
141
139
  (val) => val === void 0 ? void 0 : [val].flat(),
142
140
  z3.array(z3.string()).optional()
143
141
  ).describe("Event type, e.g. birth, death");
144
- var userRole = z3.preprocess(
145
- (val) => val === void 0 ? void 0 : [val].flat(),
146
- z3.array(z3.string()).optional()
147
- ).describe("User role, e.g. admin, field agent");
148
142
  var scopeOptionsPlaceEvent = z3.object({
149
143
  event: scopeByEvent,
150
144
  placeOfEvent: JurisdictionFilter.optional()
@@ -168,9 +162,6 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
168
162
  var AccessLevelOptions = z3.object({
169
163
  accessLevel: JurisdictionFilter.optional()
170
164
  });
171
- var AllUserScopeOptions = AccessLevelOptions.extend({
172
- role: userRole.optional()
173
- });
174
165
  var WorkqueueOrDashboardOptions = z3.object({
175
166
  ids: z3.preprocess(
176
167
  (val) => val === void 0 ? void 0 : [val].flat(),
@@ -180,7 +171,6 @@ var WorkqueueOrDashboardOptions = z3.object({
180
171
  var AllScopeOptions = z3.object({
181
172
  ...AllRecordScopeOptions.shape,
182
173
  ...AccessLevelOptions.shape,
183
- ...AllUserScopeOptions.shape,
184
174
  ...WorkqueueOrDashboardOptions.shape
185
175
  });
186
176
  var ScopeOptionKey = AllScopeOptions.keyof();
@@ -253,31 +243,6 @@ var RecordScopeV2 = z3.discriminatedUnion("type", [
253
243
  ]).describe(
254
244
  "Scopes used to check user's permission to perform actions on a record."
255
245
  );
256
- var SystemScopeType = z3.enum([
257
- "organisation.read-locations",
258
- "user.read",
259
- "user.create",
260
- "user.edit"
261
- ]);
262
- var UserScopeType = SystemScopeType.extract([
263
- "user.read",
264
- "user.create",
265
- "user.edit"
266
- ]);
267
- var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
268
- var UserScopeV2 = z3.discriminatedUnion("type", [
269
- z3.object({
270
- type: ScopesWithRoleOption,
271
- options: AllUserScopeOptions.optional()
272
- }),
273
- z3.object({
274
- type: UserScopeType.extract(["user.read"]),
275
- options: AccessLevelOptions.optional()
276
- })
277
- ]);
278
- function scopeUsesRoleOptions(scope) {
279
- return ScopesWithRoleOption?.options.some((opt) => opt === scope.type);
280
- }
281
246
  function scopeUsesDeclaredOptions(scope) {
282
247
  return !ScopesWithPlaceEventOptions.options.some((opt) => opt === scope.type);
283
248
  }
@@ -310,14 +275,16 @@ var ResolvedRecordScopeV2 = z3.discriminatedUnion("type", [
310
275
  }).optional()
311
276
  })
312
277
  ]).describe("Resolved scope with location/user IDs instead of filters.");
278
+ var SystemScopeType = z3.enum([
279
+ "organisation.read-locations",
280
+ "user.read",
281
+ "user.create",
282
+ "user.edit"
283
+ ]);
313
284
  var Scope2 = z3.discriminatedUnion("type", [
314
285
  z3.object({ type: PlainScopeType }),
315
286
  ...RecordScopeV2.options,
316
- ...UserScopeV2.options,
317
- z3.object({
318
- type: z3.literal("organisation.read-locations"),
319
- options: AccessLevelOptions.optional()
320
- }),
287
+ z3.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
321
288
  z3.object({
322
289
  type: z3.literal("workqueue"),
323
290
  options: WorkqueueOrDashboardOptions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/toolkit",
3
- "version": "2.0.0-rc.2625051",
3
+ "version": "2.0.0-rc.32c9d97",
4
4
  "description": "OpenCRVS toolkit for building country configurations",
5
5
  "license": "MPL-2.0",
6
6
  "bin": {
@@ -1 +1 @@
1
- {"root":["./src/cli.ts","./src/api/index.ts","./src/application-config/index.ts","./src/conditionals/index.ts","./src/events/deduplication.ts","./src/events/index.ts","./src/migrations/v2.0/add-birth-certificate-issuance-flag.ts","./src/migrations/v2.0/checkout-upstream-files.ts","./src/migrations/v2.0/convert-config-files-to-ts.ts","./src/migrations/v2.0/convert-paragraph-to-heading.ts","./src/migrations/v2.0/create-events-index.ts","./src/migrations/v2.0/index.ts","./src/migrations/v2.0/make-built-in-validate-actions-custom.ts","./src/migrations/v2.0/migrate-scopes.ts","./src/migrations/v2.0/migrate-validated-workqueue-status-to-flag.ts","./src/migrations/v2.0/migrate-workqueue-configs.ts","./src/migrations/v2.0/remove-delete-actions.ts","./src/migrations/v2.0/remove-demo-scope.ts","./src/migrations/v2.0/remove-deprecated-imports.ts","./src/migrations/v2.0/remove-hearth-migrations.ts","./src/migrations/v2.0/remove-pending-certification-flag.ts","./src/migrations/v2.0/remove-review-from-register-action.ts","./src/migrations/v2.0/rename-api-paths.ts","./src/migrations/v2.0/rename-location-parent-id.ts","./src/migrations/v2.0/simplify-analytics-precalculations.ts","./src/notification/index.ts","./src/scopes/index.ts"],"version":"5.6.3"}
1
+ {"root":["./src/cli.ts","./src/api/index.ts","./src/application-config/index.ts","./src/conditionals/index.ts","./src/events/deduplication.ts","./src/events/index.ts","./src/migrations/v2.0/add-birth-certificate-issuance-flag.ts","./src/migrations/v2.0/add-resend-invite-notification.ts","./src/migrations/v2.0/checkout-upstream-files.ts","./src/migrations/v2.0/convert-config-files-to-ts.ts","./src/migrations/v2.0/convert-paragraph-to-heading.ts","./src/migrations/v2.0/create-events-index.ts","./src/migrations/v2.0/delete-infrastructure-directory.ts","./src/migrations/v2.0/index.ts","./src/migrations/v2.0/make-built-in-validate-actions-custom.ts","./src/migrations/v2.0/merge-infrastructure-directory.ts","./src/migrations/v2.0/migrate-application-config-url.ts","./src/migrations/v2.0/migrate-scopes.ts","./src/migrations/v2.0/migrate-validated-workqueue-status-to-flag.ts","./src/migrations/v2.0/migrate-workqueue-configs.ts","./src/migrations/v2.0/remove-delete-actions.ts","./src/migrations/v2.0/remove-demo-scope.ts","./src/migrations/v2.0/remove-deprecated-imports.ts","./src/migrations/v2.0/remove-fhir-url-helpers.ts","./src/migrations/v2.0/remove-hearth-migrations.ts","./src/migrations/v2.0/remove-old-statistics-service.ts","./src/migrations/v2.0/remove-pending-certification-flag.ts","./src/migrations/v2.0/remove-review-from-register-action.ts","./src/migrations/v2.0/remove-unused-environment-variables.ts","./src/migrations/v2.0/rename-api-paths.ts","./src/migrations/v2.0/rename-location-parent-id.ts","./src/migrations/v2.0/simplify-analytics-precalculations.ts","./src/migrations/v2.0/update-package-json.ts","./src/notification/index.ts","./src/scopes/index.ts"],"version":"5.6.3"}