@opencrvs/toolkit 2.1.0-rc.05a1257 → 2.1.0-rc.05b7761

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 (66) hide show
  1. package/README.md +2 -12
  2. package/build.sh +10 -3
  3. package/create-countryconfig/index.js +338 -4
  4. package/dist/application-config/index.js +17 -18
  5. package/dist/authentication/index.d.ts +67 -0
  6. package/dist/authentication/index.d.ts.map +1 -0
  7. package/dist/authentication/index.js +751 -0
  8. package/dist/cli.js +1090 -187
  9. package/dist/commons/api/router.d.ts +6 -42
  10. package/dist/commons/conditionals/conditionals.d.ts +6 -6
  11. package/dist/commons/conditionals/validate.d.ts +1 -1
  12. package/dist/commons/events/ActionConfig.d.ts +4 -0
  13. package/dist/commons/events/AdvancedSearchConfig.d.ts +12 -12
  14. package/dist/commons/events/FieldConfig.d.ts +16 -15
  15. package/dist/commons/events/FormConfig.d.ts +6 -0
  16. package/dist/commons/events/PageConfig.d.ts +4 -0
  17. package/dist/commons/events/locations.d.ts +4 -0
  18. package/dist/commons/events/test.utils.d.ts +18 -1
  19. package/dist/commons/events/utils.d.ts +15 -0
  20. package/dist/commons/notification/dispatch.d.ts +1 -6
  21. package/dist/conditionals/index.js +7 -6
  22. package/dist/csv.d.ts.map +1 -1
  23. package/dist/csv.js +7 -2
  24. package/dist/environment/logger.d.ts +3 -0
  25. package/dist/environment/logger.d.ts.map +1 -1
  26. package/dist/environment/manage-users.js +1 -1
  27. package/dist/environment/setup-environment.js +44 -26
  28. package/dist/environment/templates.d.ts +0 -1
  29. package/dist/environment/templates.d.ts.map +1 -1
  30. package/dist/environment/templates.js +3 -8
  31. package/dist/environment/update-workflows.d.ts.map +1 -1
  32. package/dist/environment/update-workflows.js +4 -0
  33. package/dist/environment/utils.d.ts +0 -12
  34. package/dist/environment/utils.d.ts.map +1 -1
  35. package/dist/environment/utils.js +1 -28
  36. package/dist/events/index.js +1901 -1792
  37. package/dist/migrations/v2.0/merge-infrastructure-directory.js +3 -3
  38. package/dist/migrations/v2.1/add-recovery-link-notifications.js +4 -4
  39. package/dist/migrations/v2.1/add-translations.d.ts.map +1 -1
  40. package/dist/migrations/v2.1/add-translations.js +42 -11
  41. package/dist/migrations/v2.1/enable-telemetry.d.ts +3 -0
  42. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -0
  43. package/dist/migrations/v2.1/enable-telemetry.js +455 -0
  44. package/dist/migrations/v2.1/index.d.ts.map +1 -1
  45. package/dist/migrations/v2.1/index.js +601 -19
  46. package/dist/migrations/v2.1/rename-trigger-paths.d.ts +3 -0
  47. package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +1 -0
  48. package/dist/migrations/v2.1/rename-trigger-paths.js +216 -0
  49. package/dist/notification/index.js +167 -155
  50. package/dist/scopes/index.d.ts +109 -5
  51. package/dist/scopes/index.js +7 -6
  52. package/dist/telemetry/index.d.ts +45 -0
  53. package/dist/telemetry/index.d.ts.map +1 -0
  54. package/dist/telemetry/index.js +43 -0
  55. package/dist/templates/charts-values/dependencies/values.yaml +2 -0
  56. package/dist/translations/check.d.ts +2 -4
  57. package/dist/translations/check.d.ts.map +1 -1
  58. package/dist/translations/check.js +14 -8
  59. package/dist/verify/endpoints.d.ts +2 -0
  60. package/dist/verify/endpoints.d.ts.map +1 -0
  61. package/dist/verify/endpoints.js +345 -0
  62. package/opencrvs-toolkit-2.1.0-rc.05b7761.tgz +0 -0
  63. package/package.json +5 -2
  64. package/tsconfig.build.tsbuildinfo +1 -1
  65. package/tsconfig.json +3 -0
  66. package/opencrvs-toolkit-2.1.0-rc.05a1257.tgz +0 -0
@@ -0,0 +1,216 @@
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: Rename the `/triggers/...` country config routes to `/trigger/...`.
28
+ *
29
+ * Usage:
30
+ * ts-node -r tsconfig-paths/register src/migrations/v2.1/rename-trigger-paths.ts
31
+ *
32
+ * Why:
33
+ * The user-notification and system-ready triggers were served under
34
+ * `/triggers/`, while the event action and telemetry triggers use
35
+ * `/trigger/`. v2.1 settles on the singular prefix for all of them, so core
36
+ * now posts to `/trigger/user/*` and gets `/trigger/system/ready`. A route
37
+ * left on the old path answers 404, which core logs and moves on from — the
38
+ * notification is simply never sent and the country config's integrations
39
+ * are never registered. See CHANGELOG.md ("Country config triggers are all
40
+ * served under /trigger").
41
+ *
42
+ * What it does:
43
+ * - Scans all TypeScript files under `src/`
44
+ * - Finds every object literal that looks like a Hapi route config (a
45
+ * `method` property holding an HTTP verb, or an array of them, plus a
46
+ * string-literal `path`)
47
+ * - Rewrites a `path` starting with any prefix in PATH_PREFIX_RENAMES
48
+ * - Saves the modified files in-place
49
+ * - Warns about every remaining `/triggers/` occurrence under `src/`, which
50
+ * is anything this codemod cannot rewrite safely: a path built from a
51
+ * template literal or variable, a route config it did not recognise, or a
52
+ * test that requests the old path
53
+ */
54
+ const ts_morph_1 = require("ts-morph");
55
+ const path_1 = __importDefault(require("path"));
56
+ // ─── Path rename table ────────────────────────────────────────────────────────
57
+ // Prefixes rather than whole paths: `/triggers/user/` covers one route per
58
+ // `TriggerEvent`, and a country config may have added its own.
59
+ const PATH_PREFIX_RENAMES = {
60
+ '/triggers/user/': '/trigger/user/',
61
+ '/triggers/system/': '/trigger/system/'
62
+ };
63
+ /** Matched against the remaining source text once the renames are applied. */
64
+ const STALE_PREFIX = '/triggers/';
65
+ // ─── Constants ────────────────────────────────────────────────────────────────
66
+ const METHOD_PROPERTY_NAME = 'method';
67
+ const PATH_PROPERTY_NAME = 'path';
68
+ const HTTP_VERBS = new Set([
69
+ 'GET',
70
+ 'POST',
71
+ 'PUT',
72
+ 'PATCH',
73
+ 'DELETE',
74
+ 'OPTIONS',
75
+ 'HEAD',
76
+ '*'
77
+ ]);
78
+ // ─── Helpers ──────────────────────────────────────────────────────────────────
79
+ /**
80
+ * Returns true when the given object literal looks like a Hapi route config,
81
+ * i.e. it has a `method` property holding a recognised HTTP verb string (or an
82
+ * array of them) and a string-literal `path` property.
83
+ */
84
+ function isRouteConfig(obj) {
85
+ const methodProp = obj.getProperty(METHOD_PROPERTY_NAME);
86
+ if (!methodProp || !ts_morph_1.Node.isPropertyAssignment(methodProp))
87
+ return false;
88
+ const methodInit = methodProp.getInitializer();
89
+ if (!methodInit)
90
+ return false;
91
+ if (ts_morph_1.Node.isStringLiteral(methodInit)) {
92
+ if (!HTTP_VERBS.has(methodInit.getLiteralValue().toUpperCase()))
93
+ return false;
94
+ }
95
+ else if (ts_morph_1.Node.isArrayLiteralExpression(methodInit)) {
96
+ const allVerbs = methodInit
97
+ .getElements()
98
+ .every((el) => ts_morph_1.Node.isStringLiteral(el) &&
99
+ HTTP_VERBS.has(el.getLiteralValue().toUpperCase()));
100
+ if (!allVerbs)
101
+ return false;
102
+ }
103
+ else {
104
+ return false;
105
+ }
106
+ const pathProp = obj.getProperty(PATH_PROPERTY_NAME);
107
+ if (!pathProp || !ts_morph_1.Node.isPropertyAssignment(pathProp))
108
+ return false;
109
+ const pathInit = pathProp.getInitializer();
110
+ return !!pathInit && ts_morph_1.Node.isStringLiteral(pathInit);
111
+ }
112
+ /**
113
+ * Applies PATH_PREFIX_RENAMES to the `path` of a confirmed route config.
114
+ * Returns the new path, or null when no prefix matched.
115
+ */
116
+ function renameRoutePath(obj) {
117
+ const pathProp = obj.getProperty(PATH_PROPERTY_NAME);
118
+ if (!pathProp || !ts_morph_1.Node.isPropertyAssignment(pathProp))
119
+ return null;
120
+ const pathInit = pathProp.getInitializer();
121
+ if (!pathInit || !ts_morph_1.Node.isStringLiteral(pathInit))
122
+ return null;
123
+ const oldPath = pathInit.getLiteralValue();
124
+ const match = Object.entries(PATH_PREFIX_RENAMES).find(([from]) => oldPath.startsWith(from));
125
+ if (!match)
126
+ return null;
127
+ const [from, to] = match;
128
+ const newPath = to + oldPath.slice(from.length);
129
+ pathInit.replaceWithText(`'${newPath}'`);
130
+ return newPath;
131
+ }
132
+ // ─── File processor ──────────────────────────────────────────────────────────
133
+ function processFile(filePath, project) {
134
+ const sourceFile = project.getSourceFile(filePath);
135
+ if (!sourceFile)
136
+ return 0;
137
+ let renamedCount = 0;
138
+ const relPath = path_1.default.relative(process.cwd(), filePath);
139
+ // Collect candidates first to avoid iterating a mutating tree
140
+ const candidates = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression);
141
+ for (const obj of candidates) {
142
+ if (!isRouteConfig(obj))
143
+ continue;
144
+ const newPath = renameRoutePath(obj);
145
+ if (newPath) {
146
+ renamedCount++;
147
+ console.log(` [${relPath}] Renamed route path → '${newPath}'`);
148
+ }
149
+ }
150
+ return renamedCount;
151
+ }
152
+ /**
153
+ * Reports leftover `/triggers/` occurrences. Rewriting these is guesswork —
154
+ * the path may be assembled at runtime — but leaving them unmentioned would
155
+ * hide a route that still answers on the old path.
156
+ */
157
+ function warnAboutStalePaths(sourceFiles) {
158
+ const stale = [];
159
+ for (const sourceFile of sourceFiles) {
160
+ const relPath = path_1.default.relative(process.cwd(), sourceFile.getFilePath());
161
+ const lines = sourceFile.getFullText().split('\n');
162
+ lines.forEach((line, index) => {
163
+ if (line.includes(STALE_PREFIX)) {
164
+ stale.push(` ${relPath}:${index + 1}: ${line.trim()}`);
165
+ }
166
+ });
167
+ }
168
+ if (stale.length === 0)
169
+ return;
170
+ console.log(`\nWARNING: ${stale.length} remaining '${STALE_PREFIX}' reference(s) need to be renamed by hand:`);
171
+ console.log(stale.join('\n'));
172
+ }
173
+ // ─── Entry point ─────────────────────────────────────────────────────────────
174
+ function main() {
175
+ return __awaiter(this, void 0, void 0, function* () {
176
+ const srcDir = path_1.default.join(process.cwd(), 'src');
177
+ console.log(`Scanning for Hapi route configs in: ${srcDir}\n`);
178
+ console.log('Active path renames:');
179
+ for (const [from, to] of Object.entries(PATH_PREFIX_RENAMES)) {
180
+ console.log(` '${from}*' → '${to}*'`);
181
+ }
182
+ console.log();
183
+ const project = new ts_morph_1.Project({
184
+ tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
185
+ skipAddingFilesFromTsConfig: false
186
+ });
187
+ const sourceFiles = project.getSourceFiles().filter((sf) => {
188
+ const fp = sf.getFilePath();
189
+ return fp.includes('/src/') && !fp.includes('/node_modules/');
190
+ });
191
+ console.log(`Found ${sourceFiles.length} source file(s) to analyse.\n`);
192
+ let totalRenamed = 0;
193
+ const modifiedFiles = [];
194
+ for (const sourceFile of sourceFiles) {
195
+ const filePath = sourceFile.getFilePath();
196
+ const renamed = processFile(filePath, project);
197
+ if (renamed > 0) {
198
+ totalRenamed += renamed;
199
+ modifiedFiles.push(filePath);
200
+ }
201
+ }
202
+ if (modifiedFiles.length === 0) {
203
+ console.log('No trigger route paths to rename.');
204
+ }
205
+ else {
206
+ console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
207
+ for (const filePath of modifiedFiles) {
208
+ const sourceFile = project.getSourceFileOrThrow(filePath);
209
+ yield sourceFile.save();
210
+ console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
211
+ }
212
+ console.log(`\nDone. Renamed ${totalRenamed} route path(s).`);
213
+ }
214
+ warnAboutStalePaths(sourceFiles);
215
+ });
216
+ }
@@ -360,10 +360,7 @@ var PlainScopeType = z7.enum([
360
360
  // Performance dashboard
361
361
  "performance.read",
362
362
  "performance.read-dashboards",
363
- "performance.vital-statistics-export",
364
- // Scopes used exclusively by countryconfig integration token
365
- "record.confirm-registration",
366
- "record.reject-registration"
363
+ "performance.vital-statistics-export"
367
364
  ]);
368
365
  var scopeByEvent = z7.preprocess(
369
366
  (val) => val === void 0 ? void 0 : [val].flat(),
@@ -381,7 +378,9 @@ var userRole = z7.preprocess(
381
378
  ).describe("User role, e.g. admin, field agent");
382
379
  var scopeOptionsPlaceEvent = z7.object({
383
380
  event: scopeByEvent,
384
- placeOfEvent: JurisdictionFilter.optional()
381
+ placeOfEvent: JurisdictionFilter.optional(),
382
+ createdBy: UserFilter.optional(),
383
+ createdIn: JurisdictionFilter.optional()
385
384
  }).describe("Options applicable to all record scopes.");
386
385
  var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
387
386
  notifiedIn: JurisdictionFilter.optional(),
@@ -424,7 +423,9 @@ var AllScopeOptions = z7.object({
424
423
  var ScopeOptionKey = AllScopeOptions.keyof();
425
424
  var ResolvedScopeOptionsPlaceEvent = z7.object({
426
425
  event: scopeByEvent,
427
- placeOfEvent: UUID.nullish()
426
+ placeOfEvent: UUID.nullish(),
427
+ createdBy: z7.string().optional(),
428
+ createdIn: UUID.nullish()
428
429
  }).describe(
429
430
  "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
430
431
  );
@@ -2244,9 +2245,6 @@ var AdministrativeAreaField = BaseField.extend({
2244
2245
  partOf: FieldReference.optional().describe("Parent location"),
2245
2246
  type: AdministrativeAreas,
2246
2247
  allowedLocations: AllowedLocations,
2247
- listHistoricalNames: import_v43.default.boolean().optional().describe(
2248
- "List every historical name a location has had as a separate, selectable option."
2249
- ),
2250
2248
  activeOnly: import_v43.default.boolean().optional().describe(
2251
2249
  "Offer only locations that are active at the resolved anchor date (today, or the date of event when anchorToDateOfEvent is set); inactive or not-yet-effective versions are excluded."
2252
2250
  ),
@@ -2264,9 +2262,6 @@ var LocationInput = BaseField.extend({
2264
2262
  configuration: import_v43.default.object({
2265
2263
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
2266
2264
  allowedLocations: AllowedLocations,
2267
- listHistoricalNames: import_v43.default.boolean().optional().describe(
2268
- "List every historical name a location has had as a separate, selectable option."
2269
- ),
2270
2265
  activeOnly: import_v43.default.boolean().optional().describe(
2271
2266
  "Offer only locations that are active at the resolved anchor date (today, or the date of event when anchorToDateOfEvent is set); inactive or not-yet-effective versions are excluded."
2272
2267
  ),
@@ -2300,7 +2295,6 @@ var Facility = BaseField.extend({
2300
2295
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2301
2296
  configuration: import_v43.default.object({
2302
2297
  allowedLocations: AllowedLocations,
2303
- listHistoricalNames: import_v43.default.boolean().optional(),
2304
2298
  activeOnly: import_v43.default.boolean().optional(),
2305
2299
  anchorToDateOfEvent: import_v43.default.boolean().optional()
2306
2300
  }).optional()
@@ -2310,7 +2304,6 @@ var Office = BaseField.extend({
2310
2304
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2311
2305
  configuration: import_v43.default.object({
2312
2306
  allowedLocations: AllowedLocations,
2313
- listHistoricalNames: import_v43.default.boolean().optional(),
2314
2307
  activeOnly: import_v43.default.boolean().optional(),
2315
2308
  anchorToDateOfEvent: import_v43.default.boolean().optional()
2316
2309
  }).optional()
@@ -2347,9 +2340,6 @@ var Address = BaseField.extend({
2347
2340
  })
2348
2341
  ).optional(),
2349
2342
  allowedLocations: AllowedLocations,
2350
- listHistoricalNames: import_v43.default.boolean().optional().describe(
2351
- "List every historical name a location has had as a separate, selectable option. Propagated to the embedded admin-area selectors."
2352
- ),
2353
2343
  activeOnly: import_v43.default.boolean().optional().describe(
2354
2344
  "Offer only admin areas that are active at the resolved anchor date (today, or the date of event when anchorToDateOfEvent is set); inactive or not-yet-effective versions are excluded. Propagated to the embedded admin-area selectors."
2355
2345
  ),
@@ -2410,10 +2400,19 @@ var ButtonField = BaseField.extend({
2410
2400
  description: "A generic button that can be used to trigger an action",
2411
2401
  id: "ButtonField"
2412
2402
  });
2403
+ var FieldGroupConfiguration = import_v43.default.object({
2404
+ separator: import_v43.default.string().optional().describe(
2405
+ 'Joins the subfield values when the group is rendered as output, e.g. ", ". Defaults to one subfield per line.'
2406
+ ),
2407
+ hideEmptyFields: import_v43.default.boolean().default(false).optional().describe(
2408
+ "Leaves subfields without a value out of the output. Pair it with a separator so the separator does not double up around the gaps."
2409
+ )
2410
+ });
2413
2411
  var FieldGroup = BaseField.extend({
2414
2412
  type: import_v43.default.literal(FieldType.FIELD_GROUP),
2415
2413
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
2416
- fields: import_v43.default.lazy(() => import_v43.default.array(FieldConfig))
2414
+ fields: import_v43.default.lazy(() => import_v43.default.array(FieldConfig)),
2415
+ configuration: FieldGroupConfiguration.optional()
2417
2416
  }).meta({
2418
2417
  description: "A group of fields that are displayed together",
2419
2418
  id: "FieldGroup"
@@ -2667,6 +2666,9 @@ var PageConfigBase = z22.object({
2667
2666
  requireCompletionToContinue: z22.boolean().default(false).describe(
2668
2667
  "If true, all required fields must be filled before continuing to the next page"
2669
2668
  ),
2669
+ showClearButton: z22.boolean().optional().describe(
2670
+ 'If true, a "Clear" button is shown at the top of the page allowing the user to reset all fields on the page to their default state'
2671
+ ),
2670
2672
  fields: z22.array(FieldConfig).describe("Fields to be rendered on the page"),
2671
2673
  conditional: Conditional.optional().describe(
2672
2674
  "Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
@@ -5885,6 +5887,7 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
5885
5887
  defaultMessage: "Who is applying for the membership?",
5886
5888
  description: "This is the title of the section"
5887
5889
  },
5890
+ showClearButton: true,
5888
5891
  fields: [
5889
5892
  {
5890
5893
  id: "applicant.name",
@@ -7555,53 +7558,39 @@ var digitalIdentityEvent = defineConfig({
7555
7558
  });
7556
7559
 
7557
7560
  // ../commons/src/events/test.utils.ts
7558
- var z43 = __toESM(require("zod/v4"));
7559
- var TestUserRole = z43.enum([
7560
- "FIELD_AGENT",
7561
- "LOCAL_REGISTRAR",
7562
- "LOCAL_SYSTEM_ADMIN",
7563
- "NATIONAL_REGISTRAR",
7564
- "REGISTRATION_AGENT",
7565
- "NATIONAL_SYSTEM_ADMIN",
7566
- "SOCIAL_WORKER",
7567
- "COMMUNITY_LEADER",
7568
- "PROVINCIAL_REGISTRAR"
7569
- ]);
7570
-
7571
- // ../commons/src/events/scopes.ts
7572
- var import_lodash6 = require("lodash");
7561
+ var z44 = __toESM(require("zod/v4"));
7573
7562
 
7574
7563
  // ../commons/src/events/locations.ts
7575
- var z44 = __toESM(require("zod/v4"));
7576
- var LocationTypeV1 = z44.enum([
7564
+ var z43 = __toESM(require("zod/v4"));
7565
+ var LocationTypeV1 = z43.enum([
7577
7566
  "ADMIN_STRUCTURE",
7578
7567
  "CRVS_OFFICE",
7579
7568
  "HEALTH_FACILITY"
7580
7569
  ]);
7581
- var LocationStatus = z44.enum(["active", "inactive"]);
7582
- var LocationVersion = z44.object({
7570
+ var LocationStatus = z43.enum(["active", "inactive"]);
7571
+ var LocationVersion = z43.object({
7583
7572
  versionId: UUID,
7584
- effectiveFrom: z44.iso.date(),
7585
- name: z44.string(),
7586
- externalId: z44.string().nullish(),
7573
+ effectiveFrom: z43.iso.date(),
7574
+ name: z43.string(),
7575
+ externalId: z43.string().nullish(),
7587
7576
  status: LocationStatus
7588
7577
  });
7589
- var AdministrativeArea = z44.object({
7578
+ var AdministrativeArea = z43.object({
7590
7579
  id: UUID,
7591
- name: z44.string(),
7592
- externalId: z44.string().nullish(),
7580
+ name: z43.string(),
7581
+ externalId: z43.string().nullish(),
7593
7582
  parentId: UUID.nullable(),
7594
7583
  status: LocationStatus,
7595
- versions: z44.array(LocationVersion)
7584
+ versions: z43.array(LocationVersion)
7596
7585
  });
7597
- var Location = z44.object({
7586
+ var Location = z43.object({
7598
7587
  id: UUID,
7599
- name: z44.string(),
7600
- externalId: z44.string().nullish(),
7588
+ name: z43.string(),
7589
+ externalId: z43.string().nullish(),
7601
7590
  administrativeAreaId: UUID.nullable(),
7602
- locationType: z44.string().nullable(),
7591
+ locationType: z43.string().nullable(),
7603
7592
  status: LocationStatus,
7604
- versions: z44.array(LocationVersion)
7593
+ versions: z43.array(LocationVersion)
7605
7594
  });
7606
7595
  var ClientAdministrativeArea = AdministrativeArea.omit({
7607
7596
  name: true,
@@ -7642,121 +7631,26 @@ function validateUniqueIds(versions, ctx) {
7642
7631
  ctx.addIssue("versions must not repeat a versionId");
7643
7632
  }
7644
7633
  }
7645
- var SeededLocationVersions = z44.array(LocationVersion).min(1).superRefine((versions, ctx) => {
7634
+ var SeededLocationVersions = z43.array(LocationVersion).min(1).superRefine((versions, ctx) => {
7646
7635
  validateAscendingDates(versions, ctx);
7647
7636
  validateUniqueIds(versions, ctx);
7648
7637
  });
7649
- var SetLocationPayload = z44.object({
7638
+ var SetLocationPayload = z43.object({
7650
7639
  id: UUID,
7651
- name: z44.string(),
7652
- externalId: z44.string().nullish(),
7640
+ name: z43.string(),
7641
+ externalId: z43.string().nullish(),
7653
7642
  administrativeAreaId: UUID.nullable(),
7654
- locationType: z44.string().nullable(),
7643
+ locationType: z43.string().nullable(),
7655
7644
  versions: SeededLocationVersions.optional()
7656
7645
  });
7657
- var SetAdministrativeAreaPayload = z44.object({
7646
+ var SetAdministrativeAreaPayload = z43.object({
7658
7647
  id: UUID,
7659
- name: z44.string(),
7660
- externalId: z44.string().nullish(),
7648
+ name: z43.string(),
7649
+ externalId: z43.string().nullish(),
7661
7650
  parentId: UUID.nullable(),
7662
7651
  versions: SeededLocationVersions.optional()
7663
7652
  });
7664
7653
 
7665
- // ../commons/src/events/scopes.ts
7666
- var ACTION_SCOPE_MAP = {
7667
- [ActionType.READ]: ["record.read"],
7668
- [ActionType.CREATE]: ["record.create"],
7669
- [ActionType.NOTIFY]: ["record.notify"],
7670
- [ActionType.DECLARE]: ["record.declare", "record.register"],
7671
- [ActionType.EDIT]: ["record.edit"],
7672
- [ActionType.DELETE]: ["record.declare", "record.notify"],
7673
- [ActionType.REGISTER]: ["record.register"],
7674
- [ActionType.PRINT_CERTIFICATE]: ["record.print-certified-copies"],
7675
- [ActionType.REQUEST_CORRECTION]: [
7676
- "record.request-correction",
7677
- "record.correct"
7678
- ],
7679
- [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: ["record.correct"],
7680
- [ActionType.REJECT_CORRECTION]: ["record.correct"],
7681
- [ActionType.APPROVE_CORRECTION]: ["record.correct"],
7682
- [ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
7683
- [ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
7684
- [ActionType.ARCHIVE]: ["record.archive"],
7685
- [ActionType.UNARCHIVE]: ["record.unarchive"],
7686
- [ActionType.REJECT]: ["record.reject"],
7687
- [ActionType.ASSIGN]: null,
7688
- [ActionType.UNASSIGN]: null,
7689
- [ActionType.DUPLICATE_DETECTED]: [],
7690
- [ActionType.CUSTOM]: []
7691
- };
7692
-
7693
- // ../commons/src/events/state/availableActions.ts
7694
- var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7695
- [EventStatus.enum.CREATED]: [
7696
- ActionType.READ,
7697
- ActionType.DECLARE,
7698
- ActionType.NOTIFY,
7699
- ActionType.DELETE
7700
- ],
7701
- [EventStatus.enum.NOTIFIED]: [
7702
- ActionType.READ,
7703
- ActionType.EDIT,
7704
- ActionType.MARK_AS_DUPLICATE,
7705
- ActionType.ARCHIVE,
7706
- ActionType.REJECT,
7707
- ActionType.CUSTOM
7708
- ],
7709
- [EventStatus.enum.DECLARED]: [
7710
- ActionType.READ,
7711
- ActionType.REGISTER,
7712
- ActionType.MARK_AS_DUPLICATE,
7713
- ActionType.ARCHIVE,
7714
- ActionType.REJECT,
7715
- ActionType.CUSTOM,
7716
- ActionType.EDIT
7717
- ],
7718
- [EventStatus.enum.REGISTERED]: [
7719
- ActionType.READ,
7720
- ActionType.PRINT_CERTIFICATE,
7721
- ActionType.REQUEST_CORRECTION,
7722
- ActionType.APPROVE_CORRECTION,
7723
- ActionType.REJECT_CORRECTION,
7724
- ActionType.CUSTOM,
7725
- ClientSpecificAction.REVIEW_CORRECTION_REQUEST
7726
- ],
7727
- [EventStatus.enum.ARCHIVED]: [
7728
- ActionType.READ,
7729
- ActionType.CUSTOM,
7730
- ActionType.UNARCHIVE
7731
- ]
7732
- };
7733
- var ACTION_FILTERS = {
7734
- [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
7735
- [ActionType.REQUEST_CORRECTION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
7736
- [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
7737
- [ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
7738
- [ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
7739
- [ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
7740
- [ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
7741
- [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
7742
- [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
7743
- [ActionType.ARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
7744
- [ActionType.UNARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
7745
- [ActionType.ASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
7746
- [ActionType.UNASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
7747
- [ActionType.CUSTOM]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested"))
7748
- };
7749
- var REJECTED_ACTIONS = [
7750
- ActionType.READ,
7751
- ActionType.NOTIFY,
7752
- ActionType.CUSTOM,
7753
- ActionType.EDIT,
7754
- ActionType.ARCHIVE
7755
- ];
7756
-
7757
- // ../commons/src/events/FileUtils.ts
7758
- var import_lodash7 = require("lodash");
7759
-
7760
7654
  // ../commons/src/events/mocks.test.utils.ts
7761
7655
  function withVersionFields(entity) {
7762
7656
  return {
@@ -8099,6 +7993,115 @@ var V2_DEFAULT_MOCK_CLIENT_ADMINISTRATIVE_AREAS_MAP = new Map(
8099
7993
  ])
8100
7994
  );
8101
7995
 
7996
+ // ../commons/src/events/test.utils.ts
7997
+ var TestUserRole = z44.enum([
7998
+ "FIELD_AGENT",
7999
+ "LOCAL_REGISTRAR",
8000
+ "LOCAL_SYSTEM_ADMIN",
8001
+ "NATIONAL_REGISTRAR",
8002
+ "REGISTRATION_AGENT",
8003
+ "NATIONAL_SYSTEM_ADMIN",
8004
+ "SOCIAL_WORKER",
8005
+ "COMMUNITY_LEADER",
8006
+ "PROVINCIAL_REGISTRAR"
8007
+ ]);
8008
+
8009
+ // ../commons/src/events/scopes.ts
8010
+ var import_lodash6 = require("lodash");
8011
+ var ACTION_SCOPE_MAP = {
8012
+ [ActionType.READ]: ["record.read"],
8013
+ [ActionType.CREATE]: ["record.create"],
8014
+ [ActionType.NOTIFY]: ["record.notify"],
8015
+ [ActionType.DECLARE]: ["record.declare", "record.register"],
8016
+ [ActionType.EDIT]: ["record.edit"],
8017
+ [ActionType.DELETE]: ["record.declare", "record.notify"],
8018
+ [ActionType.REGISTER]: ["record.register"],
8019
+ [ActionType.PRINT_CERTIFICATE]: ["record.print-certified-copies"],
8020
+ [ActionType.REQUEST_CORRECTION]: [
8021
+ "record.request-correction",
8022
+ "record.correct"
8023
+ ],
8024
+ [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: ["record.correct"],
8025
+ [ActionType.REJECT_CORRECTION]: ["record.correct"],
8026
+ [ActionType.APPROVE_CORRECTION]: ["record.correct"],
8027
+ [ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
8028
+ [ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
8029
+ [ActionType.ARCHIVE]: ["record.archive"],
8030
+ [ActionType.UNARCHIVE]: ["record.unarchive"],
8031
+ [ActionType.REJECT]: ["record.reject"],
8032
+ [ActionType.ASSIGN]: null,
8033
+ [ActionType.UNASSIGN]: null,
8034
+ [ActionType.DUPLICATE_DETECTED]: [],
8035
+ [ActionType.CUSTOM]: []
8036
+ };
8037
+
8038
+ // ../commons/src/events/state/availableActions.ts
8039
+ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
8040
+ [EventStatus.enum.CREATED]: [
8041
+ ActionType.READ,
8042
+ ActionType.DECLARE,
8043
+ ActionType.NOTIFY,
8044
+ ActionType.DELETE
8045
+ ],
8046
+ [EventStatus.enum.NOTIFIED]: [
8047
+ ActionType.READ,
8048
+ ActionType.EDIT,
8049
+ ActionType.MARK_AS_DUPLICATE,
8050
+ ActionType.ARCHIVE,
8051
+ ActionType.REJECT,
8052
+ ActionType.CUSTOM
8053
+ ],
8054
+ [EventStatus.enum.DECLARED]: [
8055
+ ActionType.READ,
8056
+ ActionType.REGISTER,
8057
+ ActionType.MARK_AS_DUPLICATE,
8058
+ ActionType.ARCHIVE,
8059
+ ActionType.REJECT,
8060
+ ActionType.CUSTOM,
8061
+ ActionType.EDIT
8062
+ ],
8063
+ [EventStatus.enum.REGISTERED]: [
8064
+ ActionType.READ,
8065
+ ActionType.PRINT_CERTIFICATE,
8066
+ ActionType.REQUEST_CORRECTION,
8067
+ ActionType.APPROVE_CORRECTION,
8068
+ ActionType.REJECT_CORRECTION,
8069
+ ActionType.CUSTOM,
8070
+ ClientSpecificAction.REVIEW_CORRECTION_REQUEST
8071
+ ],
8072
+ [EventStatus.enum.ARCHIVED]: [
8073
+ ActionType.READ,
8074
+ ActionType.CUSTOM,
8075
+ ActionType.UNARCHIVE
8076
+ ]
8077
+ };
8078
+ var ACTION_FILTERS = {
8079
+ [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8080
+ [ActionType.REQUEST_CORRECTION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8081
+ [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8082
+ [ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8083
+ [ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8084
+ [ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
8085
+ [ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
8086
+ [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
8087
+ [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8088
+ [ActionType.ARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
8089
+ [ActionType.UNARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
8090
+ [ActionType.ASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
8091
+ [ActionType.UNASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
8092
+ [ActionType.CUSTOM]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested"))
8093
+ };
8094
+ var REJECTED_ACTIONS = [
8095
+ ActionType.READ,
8096
+ ActionType.NOTIFY,
8097
+ ActionType.CUSTOM,
8098
+ ActionType.EDIT,
8099
+ ActionType.ARCHIVE
8100
+ ];
8101
+
8102
+ // ../commons/src/events/FileUtils.ts
8103
+ var import_lodash7 = require("lodash");
8104
+
8102
8105
  // ../commons/src/events/locationPayloads.ts
8103
8106
  var z45 = __toESM(require("zod/v4"));
8104
8107
  var CreateLocationPayload = z45.object({
@@ -8268,7 +8271,7 @@ function buildLoggerOptions() {
8268
8271
  hooks: { logMethod: filterHealthCheckLogs }
8269
8272
  };
8270
8273
  }
8271
- var logger = false ? (0, import_pino.default)({
8274
+ var logger = process.env.NODE_ENV === "production" ? (0, import_pino.default)({
8272
8275
  level: "info",
8273
8276
  redact: [
8274
8277
  "req.headers.authorization",
@@ -8287,7 +8290,7 @@ var logger = false ? (0, import_pino.default)({
8287
8290
  },
8288
8291
  ...buildLoggerOptions()
8289
8292
  });
8290
- var level = false ? "silent" : process.env.LOG_LEVEL;
8293
+ var level = process.env.NODE_ENV === "test" ? "silent" : process.env.LOG_LEVEL;
8291
8294
  if (level) {
8292
8295
  logger.level = level;
8293
8296
  }
@@ -8300,7 +8303,7 @@ async function triggerUserEventNotification({
8300
8303
  authHeader
8301
8304
  }) {
8302
8305
  const response = await fetch(
8303
- joinUrl(countryConfigUrl, `triggers/user/${event2}`),
8306
+ joinUrl(countryConfigUrl, `trigger/user/${event2}`),
8304
8307
  {
8305
8308
  method: "POST",
8306
8309
  body: JSON.stringify(payload),
@@ -8320,3 +8323,12 @@ async function triggerUserEventNotification({
8320
8323
 
8321
8324
  // src/notification/index.ts
8322
8325
  z47.globalRegistry.clear();
8326
+ // Annotate the CommonJS export names for ESM import in node:
8327
+ 0 && (module.exports = {
8328
+ BasePayload,
8329
+ Recipient,
8330
+ TriggerEvent,
8331
+ TriggerPayload,
8332
+ parseUserEventTrigger,
8333
+ triggerUserEventNotification
8334
+ });