@opencrvs/toolkit 2.1.0-rc.1bd2a41 → 2.1.0-rc.1f4b4ad

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 (35) hide show
  1. package/README.md +0 -1
  2. package/dist/application-config/index.js +1 -0
  3. package/dist/cli.js +57 -164
  4. package/dist/commons/api/router.d.ts +85 -0
  5. package/dist/commons/conditionals/conditionals.d.ts +3 -3
  6. package/dist/commons/events/AdvancedSearchConfig.d.ts +6 -0
  7. package/dist/commons/events/AuditLog.d.ts +37 -0
  8. package/dist/commons/events/FieldConfig.d.ts +5 -0
  9. package/dist/commons/events/index.d.ts +1 -0
  10. package/dist/commons/events/locationPayloads.d.ts +95 -0
  11. package/dist/commons/events/locations.d.ts +7 -0
  12. package/dist/conditionals/index.js +1 -0
  13. package/dist/environment/index.d.ts +0 -1
  14. package/dist/environment/index.d.ts.map +1 -1
  15. package/dist/environment/index.js +0 -10
  16. package/dist/environment/setup-environment.js +1 -2
  17. package/dist/environment/templates.d.ts.map +1 -1
  18. package/dist/environment/templates.js +1 -2
  19. package/dist/environment/update-workflows.d.ts.map +1 -1
  20. package/dist/environment/update-workflows.js +3 -4
  21. package/dist/environment/users.js +13 -11
  22. package/dist/events/index.js +88 -0
  23. package/dist/notification/index.js +99 -25
  24. package/dist/scopes/index.d.ts +3 -1
  25. package/dist/scopes/index.js +1 -0
  26. package/opencrvs-toolkit-2.1.0-rc.1f4b4ad.tgz +0 -0
  27. package/package.json +3 -2
  28. package/tsconfig.tsbuildinfo +1 -1
  29. package/dist/environment/paths.d.ts +0 -7
  30. package/dist/environment/paths.d.ts.map +0 -1
  31. package/dist/environment/paths.js +0 -72
  32. package/dist/environment/upgrade.d.ts +0 -2
  33. package/dist/environment/upgrade.d.ts.map +0 -1
  34. package/dist/environment/upgrade.js +0 -80
  35. package/opencrvs-toolkit-2.1.0-rc.1bd2a41.tgz +0 -0
@@ -281,6 +281,43 @@ export declare const AuditLogEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
281
281
  responseSummary: z.ZodObject<{
282
282
  clientId: z.ZodString;
283
283
  }, z.core.$strip>;
284
+ }, z.core.$strip>, z.ZodObject<{
285
+ id: z.ZodString;
286
+ clientId: z.ZodString;
287
+ clientType: z.ZodEnum<{
288
+ system: "system";
289
+ user: "user";
290
+ }>;
291
+ createdAt: z.ZodString;
292
+ operation: z.ZodLiteral<"locations.create">;
293
+ requestData: z.ZodObject<{
294
+ id: z.ZodString;
295
+ versionId: z.ZodString;
296
+ name: z.ZodString;
297
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
298
+ effectiveFrom: z.ZodString;
299
+ status: z.ZodString;
300
+ administrativeAreaId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
301
+ locationType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
302
+ }, z.core.$strip>;
303
+ }, z.core.$strip>, z.ZodObject<{
304
+ id: z.ZodString;
305
+ clientId: z.ZodString;
306
+ clientType: z.ZodEnum<{
307
+ system: "system";
308
+ user: "user";
309
+ }>;
310
+ createdAt: z.ZodString;
311
+ operation: z.ZodLiteral<"administrativeAreas.create">;
312
+ requestData: z.ZodObject<{
313
+ id: z.ZodString;
314
+ versionId: z.ZodString;
315
+ name: z.ZodString;
316
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
317
+ effectiveFrom: z.ZodString;
318
+ status: z.ZodString;
319
+ parentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
320
+ }, z.core.$strip>;
284
321
  }, z.core.$strip>, z.ZodObject<{
285
322
  id: z.ZodString;
286
323
  clientId: z.ZodString;
@@ -1883,6 +1883,7 @@ declare const AdministrativeAreaField: z.ZodObject<{
1883
1883
  "config.update-all": "config.update-all";
1884
1884
  "dashboard.view": "dashboard.view";
1885
1885
  "integration.create": "integration.create";
1886
+ "location.edit": "location.edit";
1886
1887
  "organisation.read-locations": "organisation.read-locations";
1887
1888
  "performance.read": "performance.read";
1888
1889
  "performance.read-dashboards": "performance.read-dashboards";
@@ -2012,6 +2013,7 @@ declare const LocationInput: z.ZodObject<{
2012
2013
  "config.update-all": "config.update-all";
2013
2014
  "dashboard.view": "dashboard.view";
2014
2015
  "integration.create": "integration.create";
2016
+ "location.edit": "location.edit";
2015
2017
  "organisation.read-locations": "organisation.read-locations";
2016
2018
  "performance.read": "performance.read";
2017
2019
  "performance.read-dashboards": "performance.read-dashboards";
@@ -2212,6 +2214,7 @@ declare const Facility: z.ZodObject<{
2212
2214
  "config.update-all": "config.update-all";
2213
2215
  "dashboard.view": "dashboard.view";
2214
2216
  "integration.create": "integration.create";
2217
+ "location.edit": "location.edit";
2215
2218
  "organisation.read-locations": "organisation.read-locations";
2216
2219
  "performance.read": "performance.read";
2217
2220
  "performance.read-dashboards": "performance.read-dashboards";
@@ -2327,6 +2330,7 @@ declare const Office: z.ZodObject<{
2327
2330
  "config.update-all": "config.update-all";
2328
2331
  "dashboard.view": "dashboard.view";
2329
2332
  "integration.create": "integration.create";
2333
+ "location.edit": "location.edit";
2330
2334
  "organisation.read-locations": "organisation.read-locations";
2331
2335
  "performance.read": "performance.read";
2332
2336
  "performance.read-dashboards": "performance.read-dashboards";
@@ -2528,6 +2532,7 @@ declare const Address: z.ZodObject<{
2528
2532
  "config.update-all": "config.update-all";
2529
2533
  "dashboard.view": "dashboard.view";
2530
2534
  "integration.create": "integration.create";
2535
+ "location.edit": "location.edit";
2531
2536
  "organisation.read-locations": "organisation.read-locations";
2532
2537
  "performance.read": "performance.read";
2533
2538
  "performance.read-dashboards": "performance.read-dashboards";
@@ -45,6 +45,7 @@ export * from './field';
45
45
  export * from './Flag';
46
46
  export * from './event';
47
47
  export * from './locations';
48
+ export * from './locationPayloads';
48
49
  export { UUID } from '../uuid';
49
50
  export { DocumentPath } from '../documents';
50
51
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,95 @@
1
+ import * as z from 'zod/v4';
2
+ /**
3
+ * Input payload for creating a location: the identity fields (parent and
4
+ * locationType are set once, immutable thereafter) plus the first version.
5
+ * `id` and `versionId` may be supplied by the caller for idempotent retries.
6
+ * `effectiveFrom` defaults to the beginning-of-time sentinel on the server.
7
+ */
8
+ export declare const CreateLocationPayload: z.ZodObject<{
9
+ id: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
10
+ versionId: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
11
+ name: z.ZodString;
12
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
13
+ administrativeAreaId: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
14
+ locationType: z.ZodNullable<z.ZodString>;
15
+ effectiveFrom: z.ZodOptional<z.ZodISODate>;
16
+ status: z.ZodDefault<z.ZodEnum<{
17
+ active: "active";
18
+ inactive: "inactive";
19
+ }>>;
20
+ }, z.core.$strip>;
21
+ export type CreateLocationPayload = z.infer<typeof CreateLocationPayload>;
22
+ /**
23
+ * Input payload for appending a new version to a location. A full snapshot of
24
+ * every versioned field is required — omitted does not mean unchanged. The
25
+ * schema is strict: identity fields (`administrativeAreaId`, `locationType`)
26
+ * are rejected rather than ignored, as they cannot change. `lastVersionId`
27
+ * is the optimistic-concurrency check: it must be the id of the last element
28
+ * the caller observed. `effectiveFrom` defaults to today on the server;
29
+ * supply it explicitly for idempotent retries.
30
+ */
31
+ export declare const UpdateLocationPayload: z.ZodObject<{
32
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
33
+ versionId: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
34
+ name: z.ZodString;
35
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
36
+ status: z.ZodEnum<{
37
+ active: "active";
38
+ inactive: "inactive";
39
+ }>;
40
+ effectiveFrom: z.ZodOptional<z.ZodISODate>;
41
+ lastVersionId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
42
+ }, z.core.$strict>;
43
+ export type UpdateLocationPayload = z.infer<typeof UpdateLocationPayload>;
44
+ /**
45
+ * Input payload for withdrawing a pending (future-dated) version element.
46
+ * Only elements whose `effectiveFrom` has not yet passed can be withdrawn.
47
+ */
48
+ export declare const WithdrawLocationVersionPayload: z.ZodObject<{
49
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
50
+ versionId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
51
+ }, z.core.$strip>;
52
+ export type WithdrawLocationVersionPayload = z.infer<typeof WithdrawLocationVersionPayload>;
53
+ /**
54
+ * Administrative-area twin of {@link CreateLocationPayload}: `parentId`
55
+ * instead of `administrativeAreaId`, no `locationType`.
56
+ */
57
+ export declare const CreateAdministrativeAreaPayload: z.ZodObject<{
58
+ id: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
59
+ versionId: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
60
+ name: z.ZodString;
61
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
62
+ parentId: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
63
+ effectiveFrom: z.ZodOptional<z.ZodISODate>;
64
+ status: z.ZodDefault<z.ZodEnum<{
65
+ active: "active";
66
+ inactive: "inactive";
67
+ }>>;
68
+ }, z.core.$strip>;
69
+ export type CreateAdministrativeAreaPayload = z.infer<typeof CreateAdministrativeAreaPayload>;
70
+ /**
71
+ * Administrative-area twin of {@link UpdateLocationPayload} — strict for the
72
+ * same reason: the identity field (`parentId`) is rejected, not ignored.
73
+ */
74
+ export declare const UpdateAdministrativeAreaPayload: z.ZodObject<{
75
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
76
+ versionId: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
77
+ name: z.ZodString;
78
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
79
+ status: z.ZodEnum<{
80
+ active: "active";
81
+ inactive: "inactive";
82
+ }>;
83
+ effectiveFrom: z.ZodOptional<z.ZodISODate>;
84
+ lastVersionId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
85
+ }, z.core.$strict>;
86
+ export type UpdateAdministrativeAreaPayload = z.infer<typeof UpdateAdministrativeAreaPayload>;
87
+ /**
88
+ * Administrative-area twin of {@link WithdrawLocationVersionPayload}.
89
+ */
90
+ export declare const WithdrawAdministrativeAreaVersionPayload: z.ZodObject<{
91
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
92
+ versionId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
93
+ }, z.core.$strip>;
94
+ export type WithdrawAdministrativeAreaVersionPayload = z.infer<typeof WithdrawAdministrativeAreaVersionPayload>;
95
+ //# sourceMappingURL=locationPayloads.d.ts.map
@@ -111,6 +111,13 @@ export type SetAdministrativeAreaPayload = z.infer<typeof SetAdministrativeAreaP
111
111
  export declare function resolveVersion<T extends {
112
112
  effectiveFrom: string;
113
113
  }>(versions: T[], anchor: string): T;
114
+ /**
115
+ * Whether the entity holds the given externalId with active status at the
116
+ * anchor date or at any point after it. Used for point-in-time uniqueness of
117
+ * external codes: a new holder starting at `anchor` collides when an existing
118
+ * holder is (or is scheduled to be) active with the code from then on.
119
+ */
120
+ export declare function hasActiveExternalIdOnOrAfter(versions: LocationVersion[], externalId: string, anchor: string): boolean;
114
121
  type WrapArrayPreserveNullish<V> = V extends readonly any[] ? V : NonNullable<V>[] | Extract<V, null | undefined>;
115
122
  /**
116
123
  * For type T, convert fields K to arrays. If field is string, convert to string[].
@@ -169,6 +169,7 @@ var PlainScopeType = z6.enum([
169
169
  "integration.create",
170
170
  "record.import",
171
171
  "config.update-all",
172
+ "location.edit",
172
173
  "attachment.upload",
173
174
  "profile.electronic-signature",
174
175
  "user.read-only-my-audit",
@@ -1,5 +1,4 @@
1
1
  export declare function runEnvironmentInit(): Promise<void>;
2
- export declare function runEnvironmentUpgrade(): Promise<void>;
3
2
  export declare function runEnvironmentUpdateWorkflows(): Promise<void>;
4
3
  export declare function runEnvironmentUsers(): Promise<void>;
5
4
  export declare function runEnvironmentSwarmToK8s(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/environment/index.ts"],"names":[],"mappings":"AAyCA,wBAAsB,kBAAkB,kBAIvC;AAED,wBAAsB,qBAAqB,kBAI1C;AAED,wBAAsB,6BAA6B,kBAIlD;AAED,wBAAsB,mBAAmB,kBAIxC;AAED,wBAAsB,wBAAwB,kBAG7C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/environment/index.ts"],"names":[],"mappings":"AAwCA,wBAAsB,kBAAkB,kBAGvC;AAED,wBAAsB,6BAA6B,kBAIlD;AAED,wBAAsB,mBAAmB,kBAIxC;AAED,wBAAsB,wBAAwB,kBAG7C"}
@@ -20,13 +20,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
22
  exports.runEnvironmentInit = runEnvironmentInit;
23
- exports.runEnvironmentUpgrade = runEnvironmentUpgrade;
24
23
  exports.runEnvironmentUpdateWorkflows = runEnvironmentUpdateWorkflows;
25
24
  exports.runEnvironmentUsers = runEnvironmentUsers;
26
25
  exports.runEnvironmentSwarmToK8s = runEnvironmentSwarmToK8s;
27
26
  const fs_1 = require("fs");
28
27
  const path_1 = require("path");
29
- const paths_1 = require("./paths");
30
28
  const REQUIRED_REPOSITORY_DIRECTORIES = [
31
29
  '.github/workflows',
32
30
  'environments',
@@ -48,17 +46,9 @@ function validateRepositoryStructure(repositoryRoot = process.cwd()) {
48
46
  function runEnvironmentInit() {
49
47
  return __awaiter(this, void 0, void 0, function* () {
50
48
  validateRepositoryStructure();
51
- (0, paths_1.assertNoOldInventoryLayout)();
52
49
  yield import('./setup-environment.js');
53
50
  });
54
51
  }
55
- function runEnvironmentUpgrade() {
56
- return __awaiter(this, void 0, void 0, function* () {
57
- validateRepositoryStructure();
58
- const { upgradeEnvironmentLayout } = yield import('./upgrade.js');
59
- yield upgradeEnvironmentLayout();
60
- });
61
- }
62
52
  function runEnvironmentUpdateWorkflows() {
63
53
  return __awaiter(this, void 0, void 0, function* () {
64
54
  validateRepositoryStructure();
@@ -59,7 +59,6 @@ const questions_1 = require("./questions");
59
59
  const editor_questions_1 = require("./editor-questions");
60
60
  const questions_helper_1 = require("./questions-helper");
61
61
  const manage_users_1 = require("./manage-users");
62
- const paths_1 = require("./paths");
63
62
  function questionToPrompt(_a) {
64
63
  var { valueType, valueLabel, scope } = _a, promptOptions = __rest(_a, ["valueType", "valueLabel", "scope"]);
65
64
  return promptOptions;
@@ -272,7 +271,7 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
272
271
  ? infrastructure.kubeWorkerNodes.split(',').map((ip) => ip.trim())
273
272
  : [];
274
273
  (0, logger_1.log)('\n', kleur_1.default.bold().underline('SSH Users'), '\n');
275
- const users = yield (0, manage_users_1.manageUsers)((0, paths_1.getEnvironmentInventoryPath)(environment));
274
+ const users = yield (0, manage_users_1.manageUsers)(`infrastructure/server-setup/inventory/${environment}.yml`);
276
275
  (0, logger_1.log)('\n', kleur_1.default.bold().underline('Traefik SSL Certificate'), '\n');
277
276
  const sslCertExists = (0, utils_1.findExistingValue)('SSL_CRT', 'SECRET', 'ENVIRONMENT', existingValues);
278
277
  let ssl_answers = [];
@@ -1 +1 @@
1
- {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/environment/templates.ts"],"names":[],"mappings":"AAuBA,wBAAgB,QAAQ,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,CAKvC;AAID,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,CAYpD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CAWpD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CASnD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,EAAE,CAStD;AAGD;;;;GAIG;AACH;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QA0CzC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAsBzE"}
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/environment/templates.ts"],"names":[],"mappings":"AAsBA,wBAAgB,QAAQ,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,CAKvC;AAID,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,CAYpD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CAWpD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CASnD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,EAAE,CAStD;AAGD;;;;GAIG;AACH;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QA0CzC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QA4BzE"}
@@ -34,7 +34,6 @@ exports.generateInventory = generateInventory;
34
34
  const fs_1 = __importDefault(require("fs"));
35
35
  const path_1 = __importDefault(require("path"));
36
36
  const logger_1 = require("./logger");
37
- const paths_1 = require("./paths");
38
37
  const handlebars_1 = __importDefault(require("handlebars"));
39
38
  // Register a helper to increment numbers
40
39
  handlebars_1.default.registerHelper('data_label_idx', function (value) {
@@ -150,7 +149,7 @@ function copyChartsValues(env, values) {
150
149
  function generateInventory(env, values) {
151
150
  // Template and output paths
152
151
  const templatePath = path_1.default.join(__dirname, 'templates', 'inventory', 'inventory.template.yml');
153
- const outputPath = path_1.default.resolve(process.cwd(), (0, paths_1.getEnvironmentInventoryPath)(env));
152
+ const outputPath = path_1.default.join(process.cwd(), 'infrastructure', 'server-setup', 'inventory', `${env}.yml`);
154
153
  const templateFile = fs_1.default.readFileSync(templatePath, 'utf-8');
155
154
  const template = handlebars_1.default.compile(templateFile);
156
155
  values['single_node'] =
@@ -1 +1 @@
1
- {"version":3,"file":"update-workflows.d.ts","sourceRoot":"","sources":["../../src/environment/update-workflows.ts"],"names":[],"mappings":"AAiHA,wBAAsB,0BAA0B,IAAI,OAAO,CAAC,IAAI,CAAC,CAgDhE"}
1
+ {"version":3,"file":"update-workflows.d.ts","sourceRoot":"","sources":["../../src/environment/update-workflows.ts"],"names":[],"mappings":"AAgHA,wBAAsB,0BAA0B,IAAI,OAAO,CAAC,IAAI,CAAC,CAgDhE"}
@@ -60,13 +60,12 @@ const path_1 = require("path");
60
60
  const glob = __importStar(require("glob"));
61
61
  const yaml = __importStar(require("js-yaml"));
62
62
  const logger_1 = require("./logger");
63
- const paths_1 = require("./paths");
64
63
  function extractInfrastructureNames() {
65
64
  return __awaiter(this, void 0, void 0, function* () {
66
- const files = glob.sync((0, path_1.join)('environments', '*', paths_1.INVENTORY_FILE_NAME));
67
- const infraEnvironments = files.map((file) => (0, path_1.basename)((0, path_1.dirname)(file)));
65
+ const files = glob.sync('infrastructure/server-setup/inventory/*.yml');
66
+ const infraEnvironments = files.map((file) => (0, path_1.basename)(file, '.yml'));
68
67
  if (infraEnvironments.length === 0) {
69
- console.log(`⚠️ Warning: No environment inventory files found at environments/*/${paths_1.INVENTORY_FILE_NAME}`);
68
+ console.log('⚠️ Warning: No environment directories found in infrastructure/server-setup/inventory/');
70
69
  return [];
71
70
  }
72
71
  (0, logger_1.log)('🔍 Found infrastructure configurations:', infraEnvironments.join(', '));
@@ -62,7 +62,6 @@ const path = __importStar(require("path"));
62
62
  const kleur_1 = __importDefault(require("kleur"));
63
63
  const manage_users_1 = require("./manage-users");
64
64
  const logger_1 = require("./logger");
65
- const paths_1 = require("./paths");
66
65
  function select(options) {
67
66
  return __awaiter(this, void 0, void 0, function* () {
68
67
  const inquirer = yield import('@inquirer/prompts');
@@ -77,29 +76,32 @@ function select(options) {
77
76
  * * @returns {string} Inventory file
78
77
  */
79
78
  function selectInventoryFile() {
80
- return __awaiter(this, arguments, void 0, function* (dirPath = './environments') {
79
+ return __awaiter(this, arguments, void 0, function* (dirPath = './infrastructure/server-setup/inventory/') {
81
80
  // Check if directory exists
82
81
  if (!fs.existsSync(dirPath)) {
83
82
  (0, logger_1.warn)(`⚠️ No environment configuration directory found at ${dirPath}`);
84
83
  (0, logger_1.warn)('Hint: If this is a new infrastructure repository, run `opencrvs environment init` first.');
85
84
  return null;
86
85
  }
87
- const environments = fs
86
+ // Read and filter files
87
+ const files = fs
88
88
  .readdirSync(dirPath)
89
- .filter((entry) => {
90
- const filePath = path.join(dirPath, entry);
91
- return (fs.statSync(filePath).isDirectory() &&
92
- fs.existsSync((0, paths_1.getEnvironmentInventoryPath)(entry)));
89
+ .filter((file) => {
90
+ const filePath = path.join(dirPath, file);
91
+ const isFile = fs.statSync(filePath).isFile();
92
+ const ext = path.extname(file).slice(1).toLowerCase();
93
+ return isFile && (ext === 'yml' || ext === 'yaml');
93
94
  })
94
95
  .sort();
95
- if (environments.length === 0) {
96
+ if (files.length === 0) {
96
97
  (0, logger_1.warn)(`⚠️ No environment configuration files found at ${dirPath}`);
97
98
  (0, logger_1.warn)('Hint: If this is a new infrastructure repository, run `opencrvs environment init` first.');
98
99
  return null;
99
100
  }
100
- const choices = environments.map((environment) => ({
101
- name: environment,
102
- value: (0, paths_1.getEnvironmentInventoryPath)(environment)
101
+ // Create choices - remove extension from display
102
+ const choices = files.map((file) => ({
103
+ name: path.basename(file, path.extname(file)),
104
+ value: path.join(dirPath, file)
103
105
  }));
104
106
  const selectedFile = yield select({
105
107
  message: 'Select environment (inventory file) to load users:',
@@ -80,6 +80,8 @@ __export(events_exports, {
80
80
  ConditionalType: () => ConditionalType,
81
81
  ConfirmableActions: () => ConfirmableActions,
82
82
  ContainsFlags: () => ContainsFlags,
83
+ CreateAdministrativeAreaPayload: () => CreateAdministrativeAreaPayload,
84
+ CreateLocationPayload: () => CreateLocationPayload,
83
85
  CustomActionInput: () => CustomActionInput,
84
86
  CustomFieldValue: () => CustomFieldValue,
85
87
  CustomFlag: () => CustomFlag,
@@ -220,6 +222,8 @@ __export(events_exports, {
220
222
  UUID: () => UUID,
221
223
  UnarchiveActionInput: () => UnarchiveActionInput,
222
224
  UnassignActionInput: () => UnassignActionInput,
225
+ UpdateAdministrativeAreaPayload: () => UpdateAdministrativeAreaPayload,
226
+ UpdateLocationPayload: () => UpdateLocationPayload,
223
227
  UserAuditRecordInput: () => UserAuditRecordInput,
224
228
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS: () => V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS,
225
229
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP: () => V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP,
@@ -229,6 +233,8 @@ __export(events_exports, {
229
233
  VerificationActionConfig: () => VerificationActionConfig,
230
234
  VerificationPageConfig: () => VerificationPageConfig,
231
235
  VerificationStatusValue: () => VerificationStatusValue,
236
+ WithdrawAdministrativeAreaVersionPayload: () => WithdrawAdministrativeAreaVersionPayload,
237
+ WithdrawLocationVersionPayload: () => WithdrawLocationVersionPayload,
232
238
  Within: () => Within,
233
239
  WorkqueueActionType: () => WorkqueueActionType,
234
240
  WorkqueueColumn: () => WorkqueueColumn,
@@ -347,6 +353,7 @@ __export(events_exports, {
347
353
  getStatusFromActions: () => getStatusFromActions,
348
354
  getValidatorsForField: () => getValidatorsForField,
349
355
  getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
356
+ hasActiveExternalIdOnOrAfter: () => hasActiveExternalIdOnOrAfter,
350
357
  hasAnyOfScopes: () => hasAnyOfScopes,
351
358
  isActionAvailable: () => isActionAvailable,
352
359
  isActionConfigType: () => isActionConfigType,
@@ -505,6 +512,7 @@ var PlainScopeType = z2.enum([
505
512
  "integration.create",
506
513
  "record.import",
507
514
  "config.update-all",
515
+ "location.edit",
508
516
  "attachment.upload",
509
517
  "profile.electronic-signature",
510
518
  "user.read-only-my-audit",
@@ -987,6 +995,29 @@ var IntegrationRefreshSecretEntrySchema = AuditLogEntryBase.extend({
987
995
  requestData: z5.object({ id: z5.string() }),
988
996
  responseSummary: z5.object({ clientId: z5.string() })
989
997
  });
998
+ var createdVersionFields = {
999
+ id: z5.string(),
1000
+ versionId: z5.string(),
1001
+ name: z5.string(),
1002
+ externalId: z5.string().nullish(),
1003
+ effectiveFrom: z5.string(),
1004
+ status: z5.string()
1005
+ };
1006
+ var LocationCreateEntrySchema = AuditLogEntryBase.extend({
1007
+ operation: z5.literal("locations.create"),
1008
+ requestData: z5.object({
1009
+ ...createdVersionFields,
1010
+ administrativeAreaId: z5.string().nullish(),
1011
+ locationType: z5.string().nullish()
1012
+ })
1013
+ });
1014
+ var AdministrativeAreaCreateEntrySchema = AuditLogEntryBase.extend({
1015
+ operation: z5.literal("administrativeAreas.create"),
1016
+ requestData: z5.object({
1017
+ ...createdVersionFields,
1018
+ parentId: z5.string().nullish()
1019
+ })
1020
+ });
990
1021
  var AttachmentUploadEntrySchema = AuditLogEntryBase.extend({
991
1022
  operation: z5.literal("attachments.upload"),
992
1023
  requestData: z5.object({
@@ -1062,6 +1093,8 @@ var AuditLogEntrySchema = z5.discriminatedUnion("operation", [
1062
1093
  IntegrationActivateEntrySchema,
1063
1094
  IntegrationDeleteEntrySchema,
1064
1095
  IntegrationRefreshSecretEntrySchema,
1096
+ LocationCreateEntrySchema,
1097
+ AdministrativeAreaCreateEntrySchema,
1065
1098
  AttachmentUploadEntrySchema,
1066
1099
  UserCreateEntrySchema,
1067
1100
  UserReasonEntrySchema,
@@ -10518,6 +10551,13 @@ function resolveVersion(versions, anchor) {
10518
10551
  }
10519
10552
  return resolved;
10520
10553
  }
10554
+ function hasActiveExternalIdOnOrAfter(versions, externalId, anchor) {
10555
+ const inEffectAtAnchor = resolveVersion(versions, anchor);
10556
+ const laterVersions = versions.filter((v) => v.effectiveFrom > anchor);
10557
+ return [inEffectAtAnchor, ...laterVersions].some(
10558
+ (v) => v.externalId === externalId && v.status === "active"
10559
+ );
10560
+ }
10521
10561
  function matchesJurisdictionFilter(locationIds, filter, user2) {
10522
10562
  if (!locationIds) {
10523
10563
  return false;
@@ -11328,3 +11368,51 @@ var V2_DEFAULT_MOCK_LOCATIONS_MAP = new Map(
11328
11368
  var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP = new Map(
11329
11369
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [a.id, a])
11330
11370
  );
11371
+
11372
+ // ../commons/src/events/locationPayloads.ts
11373
+ var z44 = __toESM(require("zod/v4"));
11374
+ var CreateLocationPayload = z44.object({
11375
+ id: UUID.optional(),
11376
+ versionId: UUID.optional(),
11377
+ name: z44.string(),
11378
+ externalId: z44.string().nullish(),
11379
+ administrativeAreaId: UUID.nullable(),
11380
+ locationType: z44.string().nullable(),
11381
+ effectiveFrom: z44.iso.date().optional(),
11382
+ status: LocationStatus.default("active")
11383
+ });
11384
+ var UpdateLocationPayload = z44.strictObject({
11385
+ id: UUID,
11386
+ versionId: UUID.optional(),
11387
+ name: z44.string(),
11388
+ externalId: z44.string().nullish(),
11389
+ status: LocationStatus,
11390
+ effectiveFrom: z44.iso.date().optional(),
11391
+ lastVersionId: UUID
11392
+ });
11393
+ var WithdrawLocationVersionPayload = z44.object({
11394
+ id: UUID,
11395
+ versionId: UUID
11396
+ });
11397
+ var CreateAdministrativeAreaPayload = z44.object({
11398
+ id: UUID.optional(),
11399
+ versionId: UUID.optional(),
11400
+ name: z44.string(),
11401
+ externalId: z44.string().nullish(),
11402
+ parentId: UUID.nullable(),
11403
+ effectiveFrom: z44.iso.date().optional(),
11404
+ status: LocationStatus.default("active")
11405
+ });
11406
+ var UpdateAdministrativeAreaPayload = z44.strictObject({
11407
+ id: UUID,
11408
+ versionId: UUID.optional(),
11409
+ name: z44.string(),
11410
+ externalId: z44.string().nullish(),
11411
+ status: LocationStatus,
11412
+ effectiveFrom: z44.iso.date().optional(),
11413
+ lastVersionId: UUID
11414
+ });
11415
+ var WithdrawAdministrativeAreaVersionPayload = z44.object({
11416
+ id: UUID,
11417
+ versionId: UUID
11418
+ });