@opencrvs/toolkit 2.0.0-rc.c4ed9c8 → 2.0.0-rc.c54a6d5

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 (96) hide show
  1. package/create-countryconfig/index.js +73 -0
  2. package/create-countryconfig/package.json +11 -0
  3. package/dist/application-config/index.js +68 -39
  4. package/dist/cli.js +1952 -347
  5. package/dist/commons/api/router.d.ts +3355 -299
  6. package/dist/commons/application-config/index.d.ts +16 -4
  7. package/dist/commons/conditionals/conditionals.d.ts +6 -6
  8. package/dist/commons/conditionals/validate.d.ts +1 -0
  9. package/dist/commons/events/ActionInput.d.ts +108 -0
  10. package/dist/commons/events/Draft.d.ts +3 -0
  11. package/dist/commons/events/EventIndex.d.ts +0 -3
  12. package/dist/commons/events/EventMetadata.d.ts +0 -7
  13. package/dist/commons/events/FieldConfig.d.ts +10 -0
  14. package/dist/commons/events/WorkqueueConfig.d.ts +146 -146
  15. package/dist/commons/events/locations.d.ts +38 -1
  16. package/dist/commons/events/mocks.test.utils.d.ts +19 -0
  17. package/dist/commons/events/scopes.d.ts +24 -1
  18. package/dist/commons/events/state/index.d.ts +0 -4
  19. package/dist/commons/events/state/utils.d.ts +0 -2
  20. package/dist/commons/events/utils.d.ts +1 -1
  21. package/dist/conditionals/index.js +40 -8
  22. package/dist/events/index.js +184 -83
  23. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +1 -1
  24. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +63 -39
  25. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +3 -0
  26. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +1 -0
  27. package/dist/migrations/v2.0/add-resend-invite-notification.js +373 -0
  28. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +19 -0
  29. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  30. package/dist/migrations/v2.0/checkout-upstream-files.js +17 -14
  31. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -1
  32. package/dist/migrations/v2.0/convert-config-files-to-ts.js +4 -5
  33. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +1 -1
  34. package/dist/migrations/v2.0/convert-paragraph-to-heading.js +4 -5
  35. package/dist/migrations/v2.0/create-events-index.d.ts.map +1 -1
  36. package/dist/migrations/v2.0/create-events-index.js +1 -2
  37. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +11 -0
  38. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -0
  39. package/dist/migrations/v2.0/delete-infrastructure-directory.js +123 -0
  40. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts +3 -0
  41. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts.map +1 -0
  42. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.js +110 -0
  43. package/dist/migrations/v2.0/index.d.ts +10 -4
  44. package/dist/migrations/v2.0/index.d.ts.map +1 -1
  45. package/dist/migrations/v2.0/index.js +1920 -344
  46. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -1
  47. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +95 -7
  48. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +13 -0
  49. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -0
  50. package/dist/migrations/v2.0/merge-infrastructure-directory.js +222 -0
  51. package/dist/migrations/v2.0/migrate-application-config-url.d.ts +3 -0
  52. package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +1 -0
  53. package/dist/migrations/v2.0/migrate-application-config-url.js +342 -0
  54. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -1
  55. package/dist/migrations/v2.0/migrate-scopes.js +55 -32
  56. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +1 -1
  57. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +3 -4
  58. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -1
  59. package/dist/migrations/v2.0/migrate-workqueue-configs.js +143 -63
  60. package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +1 -1
  61. package/dist/migrations/v2.0/remove-delete-actions.js +3 -4
  62. package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -1
  63. package/dist/migrations/v2.0/remove-demo-scope.js +2 -3
  64. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +1 -1
  65. package/dist/migrations/v2.0/remove-deprecated-imports.js +3 -4
  66. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +3 -0
  67. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +1 -0
  68. package/dist/migrations/v2.0/remove-fhir-url-helpers.js +163 -0
  69. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -1
  70. package/dist/migrations/v2.0/remove-hearth-migrations.js +1 -2
  71. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +3 -0
  72. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +1 -0
  73. package/dist/migrations/v2.0/remove-old-statistics-service.js +356 -0
  74. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +1 -1
  75. package/dist/migrations/v2.0/remove-pending-certification-flag.js +3 -4
  76. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +1 -1
  77. package/dist/migrations/v2.0/remove-review-from-register-action.js +3 -4
  78. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +3 -0
  79. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +1 -0
  80. package/dist/migrations/v2.0/remove-unused-environment-variables.js +186 -0
  81. package/dist/migrations/v2.0/rename-api-paths.d.ts.map +1 -1
  82. package/dist/migrations/v2.0/rename-api-paths.js +3 -4
  83. package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +1 -1
  84. package/dist/migrations/v2.0/rename-location-parent-id.js +3 -4
  85. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +1 -1
  86. package/dist/migrations/v2.0/simplify-analytics-precalculations.js +1 -2
  87. package/dist/migrations/v2.0/update-package-json.d.ts +3 -0
  88. package/dist/migrations/v2.0/update-package-json.d.ts.map +1 -0
  89. package/dist/migrations/v2.0/update-package-json.js +105 -0
  90. package/dist/notification/index.js +78 -53
  91. package/dist/scopes/index.d.ts +87 -10
  92. package/dist/scopes/index.js +46 -9
  93. package/opencrvs-toolkit-2.0.0-rc.c54a6d5.tgz +0 -0
  94. package/package.json +1 -1
  95. package/tsconfig.tsbuildinfo +1 -1
  96. package/opencrvs-toolkit-2.0.0-rc.c4ed9c8.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,6 +110,10 @@ 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");
113
117
  var scopeOptionsPlaceEvent = z2.object({
114
118
  event: scopeByEvent,
115
119
  placeOfEvent: JurisdictionFilter.optional()
@@ -133,6 +137,9 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
133
137
  var AccessLevelOptions = z2.object({
134
138
  accessLevel: JurisdictionFilter.optional()
135
139
  });
140
+ var AllUserScopeOptions = AccessLevelOptions.extend({
141
+ role: userRole.optional()
142
+ });
136
143
  var WorkqueueOrDashboardOptions = z2.object({
137
144
  ids: z2.preprocess(
138
145
  (val) => val === void 0 ? void 0 : [val].flat(),
@@ -142,6 +149,7 @@ var WorkqueueOrDashboardOptions = z2.object({
142
149
  var AllScopeOptions = z2.object({
143
150
  ...AllRecordScopeOptions.shape,
144
151
  ...AccessLevelOptions.shape,
152
+ ...AllUserScopeOptions.shape,
145
153
  ...WorkqueueOrDashboardOptions.shape
146
154
  });
147
155
  var ScopeOptionKey = AllScopeOptions.keyof();
@@ -214,6 +222,30 @@ var RecordScopeV2 = z2.discriminatedUnion("type", [
214
222
  ]).describe(
215
223
  "Scopes used to check user's permission to perform actions on a record."
216
224
  );
225
+ var SystemScopeType = z2.enum([
226
+ "organisation.read-locations",
227
+ "user.read",
228
+ "user.create",
229
+ "user.edit",
230
+ "user.search"
231
+ ]);
232
+ var UserScopeType = SystemScopeType.extract([
233
+ "user.read",
234
+ "user.create",
235
+ "user.edit",
236
+ "user.search"
237
+ ]);
238
+ var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
239
+ var UserScopeV2 = z2.discriminatedUnion("type", [
240
+ z2.object({
241
+ type: ScopesWithRoleOption,
242
+ options: AllUserScopeOptions.optional()
243
+ }),
244
+ z2.object({
245
+ type: UserScopeType.extract(["user.read", "user.search"]),
246
+ options: AccessLevelOptions.optional()
247
+ })
248
+ ]);
217
249
  var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
218
250
  z2.object({
219
251
  type: ScopesWithPlaceEventOptions,
@@ -234,16 +266,14 @@ var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
234
266
  }).optional()
235
267
  })
236
268
  ]).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
- ]);
243
269
  var Scope = z2.discriminatedUnion("type", [
244
270
  z2.object({ type: PlainScopeType }),
245
271
  ...RecordScopeV2.options,
246
- z2.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
272
+ ...UserScopeV2.options,
273
+ z2.object({
274
+ type: z2.literal("organisation.read-locations"),
275
+ options: AccessLevelOptions.optional()
276
+ }),
247
277
  z2.object({
248
278
  type: z2.literal("workqueue"),
249
279
  options: WorkqueueOrDashboardOptions
@@ -263,7 +293,9 @@ var ScopeType = z2.enum([
263
293
  var EncodedScope = z2.string().brand("EncodedScope");
264
294
  var DEFAULT_SCOPE_OPTIONS = {
265
295
  placeOfEvent: JurisdictionFilter.enum.all,
266
- accessLevel: JurisdictionFilter.enum.all
296
+ accessLevel: JurisdictionFilter.enum.all,
297
+ registeredIn: JurisdictionFilter.enum.all,
298
+ declaredIn: JurisdictionFilter.enum.all
267
299
  };
268
300
 
269
301
  // ../commons/src/authentication.ts
@@ -622,7 +654,10 @@ var ActionConditional = z7.discriminatedUnion("type", [
622
654
  ShowConditional,
623
655
  // Action can be shown to the user in the list but as disabled
624
656
  EnableConditional
625
- ]);
657
+ ]).meta({
658
+ description: "Action conditional configuration",
659
+ id: "ActionConditional"
660
+ });
626
661
  var DisplayOnReviewConditional = z7.object({
627
662
  type: z7.literal(ConditionalType.DISPLAY_ON_REVIEW),
628
663
  conditional: Conditional
@@ -950,28 +985,20 @@ function schemaPriority(schema) {
950
985
  return idx === -1 ? 9999 : idx;
951
986
  }
952
987
  function safeUnion(schemas) {
988
+ const sortedSchemas = [...schemas].sort(
989
+ (a, b) => schemaPriority(a) - schemaPriority(b)
990
+ );
953
991
  return z12.any().superRefine((val, ctx) => {
954
- const successful = schemas.filter((s) => s.safeParse(val).success);
955
- if (successful.length === 1) {
956
- return;
957
- }
958
- if (successful.length === 0) {
959
- ctx.addIssue({
960
- code: "invalid_type",
961
- expected: "custom",
962
- message: "Value does not match any schema"
963
- });
964
- return;
965
- }
966
- successful.sort((a, b) => schemaPriority(a) - schemaPriority(b));
967
- const best = successful[0];
968
- if (!best.safeParse(val).success) {
969
- ctx.addIssue({
970
- expected: "custom",
971
- code: "invalid_type",
972
- message: "Value did not match the best schema"
973
- });
992
+ for (const schema of sortedSchemas) {
993
+ if (schema.safeParse(val).success) {
994
+ return;
995
+ }
974
996
  }
997
+ ctx.addIssue({
998
+ code: "invalid_type",
999
+ expected: "custom",
1000
+ message: "Value does not match any schema"
1001
+ });
975
1002
  }).meta({
976
1003
  description: "Value that matches exactly one of the possible schema types (TextValue, DateValue, DateRangeFieldValue). The best matching schema is chosen by priority."
977
1004
  });
@@ -1281,6 +1308,9 @@ var FlagConfig = z15.object({
1281
1308
  "Indicates if this flag expects an action to be performed to be cleared."
1282
1309
  ),
1283
1310
  label: TranslationConfig.describe("Human readable label of the flag.")
1311
+ }).meta({
1312
+ description: "Flag configuration",
1313
+ id: "FlagConfig"
1284
1314
  });
1285
1315
  var ActionFlagConfig = z15.object({
1286
1316
  id: Flag,
@@ -1288,6 +1318,9 @@ var ActionFlagConfig = z15.object({
1288
1318
  conditional: Conditional.optional().describe(
1289
1319
  "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
1290
1320
  )
1321
+ }).meta({
1322
+ description: "Action flag configuration",
1323
+ id: "ActionFlagConfig"
1291
1324
  });
1292
1325
 
1293
1326
  // ../commons/src/events/EventMetadata.ts
@@ -1309,8 +1342,7 @@ var ActionCreationMetadata = z16.object({
1309
1342
  ),
1310
1343
  createdByUserType: z16.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1311
1344
  acceptedAt: z16.iso.datetime().describe("Timestamp when the action request was accepted."),
1312
- createdByRole: z16.string().optional().describe("Role of the user at the time of action request creation."),
1313
- createdBySignature: z16.string().nullish().describe("Signature of the user who created the action request.")
1345
+ createdByRole: z16.string().optional().describe("Role of the user at the time of action request creation.")
1314
1346
  });
1315
1347
  var RegistrationCreationMetadata = ActionCreationMetadata.extend({
1316
1348
  registrationNumber: z16.string().describe(
@@ -1338,9 +1370,6 @@ var EventMetadata = z16.object({
1338
1370
  createdAtLocation: UUID.nullish().describe(
1339
1371
  "Location of the user who created the event."
1340
1372
  ),
1341
- createdBySignature: DocumentPath.nullish().describe(
1342
- "Signature of the user who created the event."
1343
- ),
1344
1373
  updatedAtLocation: UUID.nullish().describe(
1345
1374
  "Location of the user who last changed the status."
1346
1375
  ),
@@ -1633,7 +1662,7 @@ var FieldId = import_v43.default.string().superRefine((val, ctx) => {
1633
1662
  }
1634
1663
  }).describe("Unique identifier for the field");
1635
1664
  var FieldReference = import_v43.default.object({
1636
- $$field: FieldId,
1665
+ $$field: FieldId.describe("Id of the field to reference"),
1637
1666
  $$subfield: import_v43.default.array(import_v43.default.string()).optional().default([]).describe(
1638
1667
  'If the FieldValue is an object, subfield can be used to refer to e.g. `["foo", "bar"]` in `{ foo: { bar: 3 } }`'
1639
1668
  )
@@ -2346,10 +2375,10 @@ var VerificationPageConfig = FormPageConfig.extend({
2346
2375
  type: z21.literal(PageTypes.enum.VERIFICATION),
2347
2376
  actions: VerificationActionConfig
2348
2377
  });
2349
- var PageConfig = z21.discriminatedUnion("type", [
2350
- FormPageConfig,
2351
- VerificationPageConfig
2352
- ]);
2378
+ var PageConfig = z21.discriminatedUnion("type", [FormPageConfig, VerificationPageConfig]).meta({
2379
+ description: "Page configuration",
2380
+ id: "PageConfig"
2381
+ });
2353
2382
 
2354
2383
  // ../commons/src/events/FormConfig.ts
2355
2384
  var DeclarationFormConfig = z22.object({
@@ -3649,7 +3678,7 @@ var _EventConfigBase = z33.object({
3649
3678
  ),
3650
3679
  label: TranslationConfig.describe("Human-readable label for the event type."),
3651
3680
  actions: z33.array(ActionConfig).describe(
3652
- "Configuration of system-defined actions associated with the event."
3681
+ "Configuration of core and custom actions associated with the event."
3653
3682
  ),
3654
3683
  actionOrder: z33.array(z33.string()).optional().describe(
3655
3684
  "Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
@@ -3661,7 +3690,7 @@ var _EventConfigBase = z33.object({
3661
3690
  "Configuration of fields available in the advanced search feature."
3662
3691
  ),
3663
3692
  flags: z33.array(FlagConfig).optional().default([]).describe(
3664
- "Configuration of flags associated with the actions of this event type."
3693
+ "Configuration of custom flags associated with the actions of this event type."
3665
3694
  ),
3666
3695
  analytics: z33.boolean().optional().default(true).describe(
3667
3696
  "Indicates whether the records of this event type are included in analytics"
@@ -4099,18 +4128,11 @@ var WorkqueueConfigWithoutQuery = WorkqueueConfig.omit({
4099
4128
  query: true,
4100
4129
  columns: true
4101
4130
  });
4102
- var WorkqueueConfigInput = z37.object({
4103
- slug: z37.string().describe("Determines the url of the workqueue."),
4104
- name: TranslationConfig.describe(
4105
- "Title of the workflow (both in navigation and on the page)"
4106
- ),
4107
- query: CountryConfigQueryInputType,
4108
- action: z37.object({ type: WorkqueueActionType }).optional().describe(
4109
- "Workqueue call-to-action button configuration. This determines the quick action button shown on each event card and the action taken when the button is clicked."
4110
- ),
4111
- columns: z37.array(WorkqueueColumn).default(mandatoryColumns),
4112
- icon: AvailableIcons,
4113
- emptyMessage: TranslationConfig.optional()
4131
+ var WorkqueueConfigInput = WorkqueueConfig.extend({
4132
+ query: CountryConfigQueryInputType
4133
+ }).meta({
4134
+ description: "Workqueue configuration",
4135
+ id: "WorkqueueConfig"
4114
4136
  });
4115
4137
  var WorkqueueCountInput = z37.array(
4116
4138
  z37.object({ slug: z37.string(), query: QueryType })
@@ -4150,6 +4172,9 @@ var BaseActionInput = z38.object({
4150
4172
  originalActionId: UUID.optional(),
4151
4173
  // should not be part of base action.
4152
4174
  keepAssignment: z38.boolean().optional(),
4175
+ keepAssignmentIfAccepted: z38.boolean().optional(),
4176
+ keepAssignmentIfRejected: z38.boolean().optional(),
4177
+ waitFor: z38.boolean().optional(),
4153
4178
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
4154
4179
  // @TODO: createdAtLocation should be limited to actions that system users can perform. For normal users, it should not be part of the base action.
4155
4180
  createdAtLocation: UUID.nullish().describe(
@@ -41,6 +41,7 @@ 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>>>>;
44
45
  event: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
45
46
  placeOfEvent: z.ZodOptional<z.ZodEnum<{
46
47
  administrativeArea: "administrativeArea";
@@ -66,6 +67,7 @@ declare const AllScopeOptions: z.ZodObject<{
66
67
  }, z.core.$strip>;
67
68
  type AllScopeOptions = z.infer<typeof AllScopeOptions>;
68
69
  export declare const ScopeOptionKey: z.ZodEnum<{
70
+ role: "role";
69
71
  event: "event";
70
72
  placeOfEvent: "placeOfEvent";
71
73
  declaredIn: "declaredIn";
@@ -220,6 +222,56 @@ export declare const RecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
220
222
  templates: z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>;
221
223
  }, z.core.$strip>>;
222
224
  }, 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
+ "user.search": "user.search";
231
+ }>;
232
+ export type SystemScopeType = z.infer<typeof SystemScopeType>;
233
+ declare const UserScopeType: z.ZodEnum<{
234
+ "user.read": "user.read";
235
+ "user.create": "user.create";
236
+ "user.edit": "user.edit";
237
+ "user.search": "user.search";
238
+ }>;
239
+ export type UserScopeType = z.infer<typeof UserScopeType>;
240
+ declare const ScopesWithRoleOption: z.ZodEnum<{
241
+ "user.create": "user.create";
242
+ "user.edit": "user.edit";
243
+ }>;
244
+ export type ScopesWithRoleOption = z.infer<typeof ScopesWithRoleOption>;
245
+ export declare const UserScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
246
+ type: z.ZodEnum<{
247
+ "user.create": "user.create";
248
+ "user.edit": "user.edit";
249
+ }>;
250
+ options: z.ZodOptional<z.ZodObject<{
251
+ accessLevel: z.ZodOptional<z.ZodEnum<{
252
+ administrativeArea: "administrativeArea";
253
+ location: "location";
254
+ all: "all";
255
+ }>>;
256
+ role: z.ZodOptional<z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>>;
257
+ }, z.core.$strip>>;
258
+ }, z.core.$strip>, z.ZodObject<{
259
+ type: z.ZodEnum<{
260
+ "user.read": "user.read";
261
+ "user.search": "user.search";
262
+ }>;
263
+ options: z.ZodOptional<z.ZodObject<{
264
+ accessLevel: z.ZodOptional<z.ZodEnum<{
265
+ administrativeArea: "administrativeArea";
266
+ location: "location";
267
+ all: "all";
268
+ }>>;
269
+ }, z.core.$strip>>;
270
+ }, z.core.$strip>], "type">;
271
+ export type UserScopeV2 = z.infer<typeof UserScopeV2>;
272
+ export declare function scopeUsesRoleOptions(scope: UserScopeV2): scope is Extract<UserScopeV2, {
273
+ type: ScopesWithRoleOption;
274
+ }>;
223
275
  export declare function scopeUsesDeclaredOptions(scope: Scope): scope is Extract<Scope, {
224
276
  type: z.infer<typeof ScopesWithDeclaredOptions>;
225
277
  }>;
@@ -286,13 +338,6 @@ export declare const ResolvedRecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject
286
338
  }, z.core.$strip>], "type">;
287
339
  export type RecordScopeV2 = z.infer<typeof RecordScopeV2>;
288
340
  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>;
296
341
  /** The primary scope schema which gathers all scope types together. All scopes are discriminated by type and options are determined according to the type. */
297
342
  export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
298
343
  type: z.ZodEnum<{
@@ -437,11 +482,31 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
437
482
  }, z.core.$strip>>;
438
483
  }, z.core.$strip>, z.ZodObject<{
439
484
  type: z.ZodEnum<{
440
- "organisation.read-locations": "organisation.read-locations";
441
- "user.read": "user.read";
442
485
  "user.create": "user.create";
443
486
  "user.edit": "user.edit";
444
487
  }>;
488
+ options: z.ZodOptional<z.ZodObject<{
489
+ accessLevel: z.ZodOptional<z.ZodEnum<{
490
+ administrativeArea: "administrativeArea";
491
+ location: "location";
492
+ all: "all";
493
+ }>>;
494
+ role: z.ZodOptional<z.ZodPipe<z.ZodTransform<({} | null)[] | undefined, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>>;
495
+ }, z.core.$strip>>;
496
+ }, z.core.$strip>, z.ZodObject<{
497
+ type: z.ZodEnum<{
498
+ "user.read": "user.read";
499
+ "user.search": "user.search";
500
+ }>;
501
+ options: z.ZodOptional<z.ZodObject<{
502
+ accessLevel: z.ZodOptional<z.ZodEnum<{
503
+ administrativeArea: "administrativeArea";
504
+ location: "location";
505
+ all: "all";
506
+ }>>;
507
+ }, z.core.$strip>>;
508
+ }, z.core.$strip>, z.ZodObject<{
509
+ type: z.ZodLiteral<"organisation.read-locations">;
445
510
  options: z.ZodOptional<z.ZodObject<{
446
511
  accessLevel: z.ZodOptional<z.ZodEnum<{
447
512
  administrativeArea: "administrativeArea";
@@ -495,6 +560,7 @@ export declare const ScopeType: z.ZodEnum<{
495
560
  "user.read": "user.read";
496
561
  "user.create": "user.create";
497
562
  "user.edit": "user.edit";
563
+ "user.search": "user.search";
498
564
  workqueue: "workqueue";
499
565
  "dashboard.view": "dashboard.view";
500
566
  }>;
@@ -567,10 +633,21 @@ export declare const decodeScope: (query: EncodedScope) => {
567
633
  registeredBy?: "user" | undefined;
568
634
  templates?: string[] | undefined;
569
635
  } | undefined;
636
+ } | {
637
+ type: "user.create" | "user.edit";
638
+ options?: {
639
+ accessLevel?: "administrativeArea" | "location" | "all" | undefined;
640
+ role?: string[] | undefined;
641
+ } | undefined;
642
+ } | {
643
+ type: "user.read" | "user.search";
644
+ options?: {
645
+ accessLevel?: "administrativeArea" | "location" | "all" | undefined;
646
+ } | undefined;
570
647
  } | {
571
648
  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";
572
649
  } | {
573
- type: "organisation.read-locations" | "user.read" | "user.create" | "user.edit";
650
+ type: "organisation.read-locations";
574
651
  options?: {
575
652
  accessLevel?: "administrativeArea" | "location" | "all" | undefined;
576
653
  } | undefined;