@opencrvs/toolkit 2.1.0-rc.f5f3da9 → 2.1.0-rc.f85d99c
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.
- package/README.md +0 -1
- package/dist/application-config/index.js +200 -189
- package/dist/cli.js +77 -217
- package/dist/commons/api/router.d.ts +7 -26
- package/dist/commons/conditionals/conditionals.d.ts +3 -3
- package/dist/commons/conditionals/validate.d.ts +2 -1
- package/dist/commons/events/ActionConfig.d.ts +21 -0
- package/dist/commons/events/ActionDocument.d.ts +1 -7
- package/dist/commons/events/ActionStatus.d.ts +14 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +6 -0
- package/dist/commons/events/CountryConfigQueryInput.d.ts +18 -0
- package/dist/commons/events/EventIndex.d.ts +5 -24
- package/dist/commons/events/EventMetadata.d.ts +1 -0
- package/dist/commons/events/FieldConfig.d.ts +5 -0
- package/dist/commons/events/FieldTypeMapping.d.ts +19 -19
- package/dist/commons/events/Flag.d.ts +48 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +27 -12
- package/dist/commons/events/locations.d.ts +3 -93
- package/dist/commons/events/mocks.test.utils.d.ts +2 -16
- package/dist/commons/events/test.utils.d.ts +5 -5
- package/dist/conditionals/index.js +303 -55
- package/dist/environment/index.d.ts +0 -1
- package/dist/environment/index.d.ts.map +1 -1
- package/dist/environment/index.js +0 -10
- package/dist/environment/setup-environment.js +1 -2
- package/dist/environment/templates.d.ts.map +1 -1
- package/dist/environment/templates.js +1 -2
- package/dist/environment/update-workflows.d.ts.map +1 -1
- package/dist/environment/update-workflows.js +3 -4
- package/dist/environment/users.js +13 -11
- package/dist/events/index.js +3255 -3222
- package/dist/notification/index.js +1477 -907
- package/dist/scopes/index.d.ts +250 -0
- package/dist/scopes/index.js +304 -55
- package/opencrvs-toolkit-2.1.0-rc.f85d99c.tgz +0 -0
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/environment/paths.d.ts +0 -13
- package/dist/environment/paths.d.ts.map +0 -1
- package/dist/environment/paths.js +0 -94
- package/dist/environment/upgrade.d.ts +0 -2
- package/dist/environment/upgrade.d.ts.map +0 -1
- package/dist/environment/upgrade.js +0 -100
- package/opencrvs-toolkit-2.1.0-rc.f5f3da9.tgz +0 -0
package/dist/cli.js
CHANGED
|
@@ -30,53 +30,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
mod
|
|
31
31
|
));
|
|
32
32
|
|
|
33
|
-
// src/environment/paths.ts
|
|
34
|
-
function getEnvironmentDir(environment) {
|
|
35
|
-
return (0, import_path2.join)("environments", environment);
|
|
36
|
-
}
|
|
37
|
-
function getEnvironmentInventoryPath(environment) {
|
|
38
|
-
return (0, import_path2.join)(getEnvironmentDir(environment), INVENTORY_FILE_NAME);
|
|
39
|
-
}
|
|
40
|
-
function getEnvironmentInventoryVarsPath(environment) {
|
|
41
|
-
return (0, import_path2.join)(getEnvironmentDir(environment), INVENTORY_VARS_FILE_NAME);
|
|
42
|
-
}
|
|
43
|
-
function findOldInventoryFiles() {
|
|
44
|
-
return glob.sync((0, import_path2.join)(OLD_INVENTORY_DIR, "*.yml")).sort();
|
|
45
|
-
}
|
|
46
|
-
function getEnvironmentNameFromOldInventoryPath(filePath) {
|
|
47
|
-
return (0, import_path2.basename)(filePath, ".yml");
|
|
48
|
-
}
|
|
49
|
-
function hasOldInventoryLayout() {
|
|
50
|
-
return findOldInventoryFiles().length > 0;
|
|
51
|
-
}
|
|
52
|
-
function assertNoOldInventoryLayout() {
|
|
53
|
-
if (!hasOldInventoryLayout()) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
throw new Error(
|
|
57
|
-
[
|
|
58
|
-
`Old inventory layout detected at ${OLD_INVENTORY_DIR}.`,
|
|
59
|
-
"Please run `yarn environment:upgrade` before running `yarn environment:init`."
|
|
60
|
-
].join(" ")
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
var import_fs, import_path2, glob, OLD_INVENTORY_DIR, INVENTORY_FILE_NAME, INVENTORY_VARS_FILE_NAME;
|
|
64
|
-
var init_paths = __esm({
|
|
65
|
-
"src/environment/paths.ts"() {
|
|
66
|
-
"use strict";
|
|
67
|
-
import_fs = require("fs");
|
|
68
|
-
import_path2 = require("path");
|
|
69
|
-
glob = __toESM(require("glob"));
|
|
70
|
-
OLD_INVENTORY_DIR = (0, import_path2.join)(
|
|
71
|
-
"infrastructure",
|
|
72
|
-
"server-setup",
|
|
73
|
-
"inventory"
|
|
74
|
-
);
|
|
75
|
-
INVENTORY_FILE_NAME = "inventory.yml";
|
|
76
|
-
INVENTORY_VARS_FILE_NAME = "inventory-vars.yml";
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
|
|
80
33
|
// src/environment/logger.ts
|
|
81
34
|
var import_kleur, log, warn, success, info, error;
|
|
82
35
|
var init_logger = __esm({
|
|
@@ -518,9 +471,9 @@ function storeSecrets(environment, answers) {
|
|
|
518
471
|
let envConfig = {};
|
|
519
472
|
try {
|
|
520
473
|
envConfig = import_dotenv.default.parse(
|
|
521
|
-
(0,
|
|
474
|
+
(0, import_fs.readFileSync)(`${process.cwd()}/.env.${environment}`)
|
|
522
475
|
);
|
|
523
|
-
} catch (
|
|
476
|
+
} catch (error4) {
|
|
524
477
|
envConfig = {};
|
|
525
478
|
}
|
|
526
479
|
const linesFromAnswers = answers.map(
|
|
@@ -528,10 +481,10 @@ function storeSecrets(environment, answers) {
|
|
|
528
481
|
);
|
|
529
482
|
const linesFromEnvConfig = Object.entries(envConfig).filter(([name]) => !answers.find((update) => update.name === name)).map(([name, value]) => `${name}="${value}"`);
|
|
530
483
|
const allLines = [...linesFromEnvConfig, ...linesFromAnswers].sort();
|
|
531
|
-
(0,
|
|
484
|
+
(0, import_fs.writeFileSync)(`.env.${environment}`, allLines.join("\n"));
|
|
532
485
|
}
|
|
533
486
|
function readYamlFile(filePath) {
|
|
534
|
-
const fileContent =
|
|
487
|
+
const fileContent = import_fs.default.readFileSync(filePath, "utf8");
|
|
535
488
|
return yaml.load(fileContent);
|
|
536
489
|
}
|
|
537
490
|
function writeYamlFile(filePath, data) {
|
|
@@ -544,16 +497,16 @@ function writeYamlFile(filePath, data) {
|
|
|
544
497
|
noRefs: true,
|
|
545
498
|
sortKeys: false
|
|
546
499
|
});
|
|
547
|
-
|
|
548
|
-
} catch (
|
|
549
|
-
throw new Error(`Failed to write inventory file: ${
|
|
500
|
+
import_fs.default.writeFileSync(filePath, yamlContent, "utf8");
|
|
501
|
+
} catch (error4) {
|
|
502
|
+
throw new Error(`Failed to write inventory file: ${error4}`);
|
|
550
503
|
}
|
|
551
504
|
}
|
|
552
|
-
var
|
|
505
|
+
var import_fs, yaml, import_dotenv;
|
|
553
506
|
var init_utils = __esm({
|
|
554
507
|
"src/environment/utils.ts"() {
|
|
555
508
|
"use strict";
|
|
556
|
-
|
|
509
|
+
import_fs = __toESM(require("fs"));
|
|
557
510
|
yaml = __toESM(require("js-yaml"));
|
|
558
511
|
import_dotenv = __toESM(require("dotenv"));
|
|
559
512
|
}
|
|
@@ -606,29 +559,29 @@ function extractWorkerNodes(data) {
|
|
|
606
559
|
return worker_hosts;
|
|
607
560
|
}
|
|
608
561
|
function copyChartsValues(env, values) {
|
|
609
|
-
const srcDir =
|
|
610
|
-
const destDir =
|
|
611
|
-
|
|
562
|
+
const srcDir = import_path2.default.resolve(__dirname, "templates", "charts-values");
|
|
563
|
+
const destDir = import_path2.default.resolve(process.cwd(), "environments", env);
|
|
564
|
+
import_fs2.default.mkdirSync(destDir, { recursive: true });
|
|
612
565
|
values["lets_encrypt"] = values["traefik_mode"] === "lets_encrypt";
|
|
613
566
|
values["static_ssl"] = values["traefik_mode"] === "static_ssl";
|
|
614
567
|
values["opencrvs_environment"] = env;
|
|
615
568
|
function copyRecursive(src, dest) {
|
|
616
|
-
const stat =
|
|
569
|
+
const stat = import_fs2.default.statSync(src);
|
|
617
570
|
if (stat.isDirectory()) {
|
|
618
|
-
|
|
619
|
-
for (const item of
|
|
620
|
-
copyRecursive(
|
|
571
|
+
import_fs2.default.mkdirSync(dest, { recursive: true });
|
|
572
|
+
for (const item of import_fs2.default.readdirSync(src)) {
|
|
573
|
+
copyRecursive(import_path2.default.join(src, item), import_path2.default.join(dest, item));
|
|
621
574
|
}
|
|
622
575
|
} else {
|
|
623
|
-
const content =
|
|
576
|
+
const content = import_fs2.default.readFileSync(src, "utf8");
|
|
624
577
|
const template = import_handlebars.default.compile(content);
|
|
625
578
|
const updated = template(values);
|
|
626
579
|
const isOverridesFile = dest.endsWith("override.yaml");
|
|
627
|
-
if (isOverridesFile &&
|
|
580
|
+
if (isOverridesFile && import_fs2.default.existsSync(dest)) {
|
|
628
581
|
log(` \u21B7 Skipped existing overrides file: ${dest}`);
|
|
629
582
|
return;
|
|
630
583
|
}
|
|
631
|
-
|
|
584
|
+
import_fs2.default.writeFileSync(dest, updated, "utf8");
|
|
632
585
|
log(` \u2713 Created: ${dest}`);
|
|
633
586
|
}
|
|
634
587
|
}
|
|
@@ -639,31 +592,36 @@ function copyChartsValues(env, values) {
|
|
|
639
592
|
`);
|
|
640
593
|
}
|
|
641
594
|
function generateInventory(env, values) {
|
|
642
|
-
const templatePath =
|
|
595
|
+
const templatePath = import_path2.default.join(
|
|
643
596
|
__dirname,
|
|
644
597
|
"templates",
|
|
645
598
|
"inventory",
|
|
646
599
|
"inventory.template.yml"
|
|
647
600
|
);
|
|
648
|
-
const outputPath =
|
|
649
|
-
|
|
601
|
+
const outputPath = import_path2.default.join(
|
|
602
|
+
process.cwd(),
|
|
603
|
+
"infrastructure",
|
|
604
|
+
"server-setup",
|
|
605
|
+
"inventory",
|
|
606
|
+
`${env}.yml`
|
|
607
|
+
);
|
|
608
|
+
const templateFile = import_fs2.default.readFileSync(templatePath, "utf-8");
|
|
650
609
|
const template = import_handlebars.default.compile(templateFile);
|
|
651
610
|
values["single_node"] = values["kube_worker_nodes"].length > 0 || values["backup_host"] ? "false" : "true";
|
|
652
611
|
const updated = template(values);
|
|
653
|
-
|
|
654
|
-
|
|
612
|
+
import_fs2.default.mkdirSync(import_path2.default.dirname(outputPath), { recursive: true });
|
|
613
|
+
import_fs2.default.writeFileSync(outputPath, updated);
|
|
655
614
|
log(`
|
|
656
615
|
\u2705 Generated inventory file at ${outputPath}
|
|
657
616
|
`);
|
|
658
617
|
}
|
|
659
|
-
var
|
|
618
|
+
var import_fs2, import_path2, import_handlebars;
|
|
660
619
|
var init_templates = __esm({
|
|
661
620
|
"src/environment/templates.ts"() {
|
|
662
621
|
"use strict";
|
|
663
|
-
|
|
664
|
-
|
|
622
|
+
import_fs2 = __toESM(require("fs"));
|
|
623
|
+
import_path2 = __toESM(require("path"));
|
|
665
624
|
init_logger();
|
|
666
|
-
init_paths();
|
|
667
625
|
import_handlebars = __toESM(require("handlebars"));
|
|
668
626
|
import_handlebars.default.registerHelper("data_label_idx", function(value) {
|
|
669
627
|
return parseInt(value) + 2;
|
|
@@ -1279,7 +1237,7 @@ function getCurrentUserSSHKeys() {
|
|
|
1279
1237
|
keys.push(keyContent);
|
|
1280
1238
|
}
|
|
1281
1239
|
}
|
|
1282
|
-
} catch (
|
|
1240
|
+
} catch (error4) {
|
|
1283
1241
|
continue;
|
|
1284
1242
|
}
|
|
1285
1243
|
}
|
|
@@ -1815,7 +1773,6 @@ var init_setup_environment = __esm({
|
|
|
1815
1773
|
init_editor_questions();
|
|
1816
1774
|
init_questions_helper();
|
|
1817
1775
|
init_manage_users();
|
|
1818
|
-
init_paths();
|
|
1819
1776
|
ALL_QUESTIONS = [];
|
|
1820
1777
|
ALL_ANSWERS = [];
|
|
1821
1778
|
ALL_QUESTIONS.push(
|
|
@@ -1979,7 +1936,9 @@ var init_setup_environment = __esm({
|
|
|
1979
1936
|
);
|
|
1980
1937
|
const kubeWorkerNodes = infrastructure.kubeWorkerNodes ? infrastructure.kubeWorkerNodes.split(",").map((ip) => ip.trim()) : [];
|
|
1981
1938
|
log("\n", import_kleur4.default.bold().underline("SSH Users"), "\n");
|
|
1982
|
-
const users = await manageUsers(
|
|
1939
|
+
const users = await manageUsers(
|
|
1940
|
+
`infrastructure/server-setup/inventory/${environment}.yml`
|
|
1941
|
+
);
|
|
1983
1942
|
log("\n", import_kleur4.default.bold().underline("Traefik SSL Certificate"), "\n");
|
|
1984
1943
|
const sslCertExists = findExistingValue(
|
|
1985
1944
|
"SSL_CRT",
|
|
@@ -2793,11 +2752,11 @@ __export(update_workflows_exports, {
|
|
|
2793
2752
|
updateWorkflowEnvironments: () => updateWorkflowEnvironments
|
|
2794
2753
|
});
|
|
2795
2754
|
async function extractInfrastructureNames() {
|
|
2796
|
-
const files =
|
|
2797
|
-
const infraEnvironments = files.map((file) => (0,
|
|
2755
|
+
const files = glob.sync("infrastructure/server-setup/inventory/*.yml");
|
|
2756
|
+
const infraEnvironments = files.map((file) => (0, import_path3.basename)(file, ".yml"));
|
|
2798
2757
|
if (infraEnvironments.length === 0) {
|
|
2799
2758
|
console.log(
|
|
2800
|
-
|
|
2759
|
+
"\u26A0\uFE0F Warning: No environment directories found in infrastructure/server-setup/inventory/"
|
|
2801
2760
|
);
|
|
2802
2761
|
return [];
|
|
2803
2762
|
}
|
|
@@ -2807,8 +2766,8 @@ async function extractInfrastructureNames() {
|
|
|
2807
2766
|
async function extractEnvironmentNames() {
|
|
2808
2767
|
const entries = await (0, import_promises.readdir)("environments");
|
|
2809
2768
|
const environments = entries.filter((entry) => {
|
|
2810
|
-
const fullPath = (0,
|
|
2811
|
-
return (0,
|
|
2769
|
+
const fullPath = (0, import_path3.join)("environments", entry);
|
|
2770
|
+
return (0, import_fs3.statSync)(fullPath).isDirectory();
|
|
2812
2771
|
});
|
|
2813
2772
|
if (environments.length === 0) {
|
|
2814
2773
|
console.log(
|
|
@@ -2834,7 +2793,7 @@ async function updateWorkflows(envList, config) {
|
|
|
2834
2793
|
const { workflows } = config;
|
|
2835
2794
|
for (const workflowPath of workflows) {
|
|
2836
2795
|
try {
|
|
2837
|
-
const fileContents = (0,
|
|
2796
|
+
const fileContents = (0, import_fs3.readFileSync)(workflowPath, "utf8");
|
|
2838
2797
|
const workflowData = yaml2.load(fileContents);
|
|
2839
2798
|
if (!workflowData?.on?.workflow_dispatch?.inputs?.environment?.options) {
|
|
2840
2799
|
throw new Error(
|
|
@@ -2842,15 +2801,15 @@ async function updateWorkflows(envList, config) {
|
|
|
2842
2801
|
);
|
|
2843
2802
|
}
|
|
2844
2803
|
const updatedContent = updateOptionsInYaml(fileContents, envList);
|
|
2845
|
-
(0,
|
|
2804
|
+
(0, import_fs3.writeFileSync)(workflowPath, updatedContent, "utf8");
|
|
2846
2805
|
log(` \u2713 Successfully updated ${workflowPath}`);
|
|
2847
|
-
} catch (
|
|
2806
|
+
} catch (error4) {
|
|
2848
2807
|
console.error(
|
|
2849
2808
|
`
|
|
2850
2809
|
\u26A0\uFE0F Error updating ${workflowPath} with environments: [${envList.join(", ")}]`
|
|
2851
2810
|
);
|
|
2852
|
-
console.error(`\u2717 Failed to update ${workflowPath}:`,
|
|
2853
|
-
throw
|
|
2811
|
+
console.error(`\u2717 Failed to update ${workflowPath}:`, error4);
|
|
2812
|
+
throw error4;
|
|
2854
2813
|
}
|
|
2855
2814
|
}
|
|
2856
2815
|
}
|
|
@@ -2891,111 +2850,21 @@ async function updateWorkflowEnvironments() {
|
|
|
2891
2850
|
} else {
|
|
2892
2851
|
log("\u2139\uFE0F No workflows were updated.");
|
|
2893
2852
|
}
|
|
2894
|
-
} catch (
|
|
2895
|
-
console.error("\n\u274C Error updating workflows:",
|
|
2853
|
+
} catch (error4) {
|
|
2854
|
+
console.error("\n\u274C Error updating workflows:", error4);
|
|
2896
2855
|
process.exit(1);
|
|
2897
2856
|
}
|
|
2898
2857
|
}
|
|
2899
|
-
var import_promises,
|
|
2858
|
+
var import_promises, import_fs3, import_path3, glob, yaml2;
|
|
2900
2859
|
var init_update_workflows = __esm({
|
|
2901
2860
|
"src/environment/update-workflows.ts"() {
|
|
2902
2861
|
"use strict";
|
|
2903
2862
|
import_promises = require("fs/promises");
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2863
|
+
import_fs3 = require("fs");
|
|
2864
|
+
import_path3 = require("path");
|
|
2865
|
+
glob = __toESM(require("glob"));
|
|
2907
2866
|
yaml2 = __toESM(require("js-yaml"));
|
|
2908
2867
|
init_logger();
|
|
2909
|
-
init_paths();
|
|
2910
|
-
}
|
|
2911
|
-
});
|
|
2912
|
-
|
|
2913
|
-
// src/environment/upgrade.ts
|
|
2914
|
-
var upgrade_exports = {};
|
|
2915
|
-
__export(upgrade_exports, {
|
|
2916
|
-
upgradeEnvironmentLayout: () => upgradeEnvironmentLayout
|
|
2917
|
-
});
|
|
2918
|
-
function moveFileIfDestinationMissing(sourcePath, destinationPath) {
|
|
2919
|
-
if (!(0, import_fs5.existsSync)(sourcePath)) {
|
|
2920
|
-
return false;
|
|
2921
|
-
}
|
|
2922
|
-
if ((0, import_fs5.existsSync)(destinationPath)) {
|
|
2923
|
-
warn(
|
|
2924
|
-
`\u26A0\uFE0F Skipped ${sourcePath}; destination already exists at ${destinationPath}`
|
|
2925
|
-
);
|
|
2926
|
-
return false;
|
|
2927
|
-
}
|
|
2928
|
-
(0, import_fs5.mkdirSync)((0, import_path5.dirname)(destinationPath), { recursive: true });
|
|
2929
|
-
(0, import_fs5.renameSync)(sourcePath, destinationPath);
|
|
2930
|
-
log(` \u2713 Moved ${sourcePath} -> ${destinationPath}`);
|
|
2931
|
-
return true;
|
|
2932
|
-
}
|
|
2933
|
-
function migrateInventoryFiles() {
|
|
2934
|
-
const oldInventoryFiles = findOldInventoryFiles();
|
|
2935
|
-
if (oldInventoryFiles.length === 0) {
|
|
2936
|
-
log(`\u2139\uFE0F No old inventory files found at ${OLD_INVENTORY_DIR}`);
|
|
2937
|
-
return false;
|
|
2938
|
-
}
|
|
2939
|
-
log(import_kleur5.default.bold("\nMigrating Ansible inventory files"));
|
|
2940
|
-
let didMoveInventory = false;
|
|
2941
|
-
for (const oldInventoryFile of oldInventoryFiles) {
|
|
2942
|
-
const environment = getEnvironmentNameFromOldInventoryPath(oldInventoryFile);
|
|
2943
|
-
didMoveInventory = moveFileIfDestinationMissing(
|
|
2944
|
-
oldInventoryFile,
|
|
2945
|
-
getEnvironmentInventoryPath(environment)
|
|
2946
|
-
) || didMoveInventory;
|
|
2947
|
-
}
|
|
2948
|
-
try {
|
|
2949
|
-
if ((0, import_fs5.existsSync)(OLD_INVENTORY_DIR) && (0, import_fs5.readdirSync)(OLD_INVENTORY_DIR).length === 0) {
|
|
2950
|
-
(0, import_fs5.rmdirSync)(OLD_INVENTORY_DIR);
|
|
2951
|
-
log(` \u2713 Removed empty ${OLD_INVENTORY_DIR}`);
|
|
2952
|
-
}
|
|
2953
|
-
} catch {
|
|
2954
|
-
warn(`\u26A0\uFE0F Could not remove ${OLD_INVENTORY_DIR}; please review it manually`);
|
|
2955
|
-
}
|
|
2956
|
-
return didMoveInventory;
|
|
2957
|
-
}
|
|
2958
|
-
function migrateInventoryVarsFiles() {
|
|
2959
|
-
if (!(0, import_fs5.existsSync)("environments")) {
|
|
2960
|
-
return false;
|
|
2961
|
-
}
|
|
2962
|
-
log(import_kleur5.default.bold("\nMigrating optional inventory variable files"));
|
|
2963
|
-
let didMoveVars = false;
|
|
2964
|
-
for (const entry of (0, import_fs5.readdirSync)("environments")) {
|
|
2965
|
-
const environmentDir = (0, import_path5.join)("environments", entry);
|
|
2966
|
-
if (!(0, import_fs5.statSync)(environmentDir).isDirectory()) {
|
|
2967
|
-
continue;
|
|
2968
|
-
}
|
|
2969
|
-
didMoveVars = moveFileIfDestinationMissing(
|
|
2970
|
-
(0, import_path5.join)(environmentDir, "inventory.override.yml"),
|
|
2971
|
-
getEnvironmentInventoryVarsPath(entry)
|
|
2972
|
-
) || didMoveVars;
|
|
2973
|
-
}
|
|
2974
|
-
if (!didMoveVars) {
|
|
2975
|
-
log(`\u2139\uFE0F No inventory override files found to rename to ${INVENTORY_VARS_FILE_NAME}`);
|
|
2976
|
-
}
|
|
2977
|
-
return didMoveVars;
|
|
2978
|
-
}
|
|
2979
|
-
async function upgradeEnvironmentLayout() {
|
|
2980
|
-
const didMoveInventory = migrateInventoryFiles();
|
|
2981
|
-
const didMoveVars = migrateInventoryVarsFiles();
|
|
2982
|
-
await updateWorkflowEnvironments();
|
|
2983
|
-
if (didMoveInventory || didMoveVars) {
|
|
2984
|
-
success("\n\u2705 Environment layout upgrade completed successfully.");
|
|
2985
|
-
return;
|
|
2986
|
-
}
|
|
2987
|
-
success("\n\u2705 Environment layout already uses the current structure.");
|
|
2988
|
-
}
|
|
2989
|
-
var import_fs5, import_path5, import_kleur5;
|
|
2990
|
-
var init_upgrade = __esm({
|
|
2991
|
-
"src/environment/upgrade.ts"() {
|
|
2992
|
-
"use strict";
|
|
2993
|
-
import_fs5 = require("fs");
|
|
2994
|
-
import_path5 = require("path");
|
|
2995
|
-
import_kleur5 = __toESM(require("kleur"));
|
|
2996
|
-
init_logger();
|
|
2997
|
-
init_paths();
|
|
2998
|
-
init_update_workflows();
|
|
2999
2868
|
}
|
|
3000
2869
|
});
|
|
3001
2870
|
|
|
@@ -3008,7 +2877,7 @@ async function select4(options) {
|
|
|
3008
2877
|
const inquirer = await import("@inquirer/prompts");
|
|
3009
2878
|
return inquirer.select(options);
|
|
3010
2879
|
}
|
|
3011
|
-
async function selectInventoryFile(dirPath = "./
|
|
2880
|
+
async function selectInventoryFile(dirPath = "./infrastructure/server-setup/inventory/") {
|
|
3012
2881
|
if (!fs4.existsSync(dirPath)) {
|
|
3013
2882
|
warn(`\u26A0\uFE0F No environment configuration directory found at ${dirPath}`);
|
|
3014
2883
|
warn(
|
|
@@ -3016,20 +2885,22 @@ async function selectInventoryFile(dirPath = "./environments") {
|
|
|
3016
2885
|
);
|
|
3017
2886
|
return null;
|
|
3018
2887
|
}
|
|
3019
|
-
const
|
|
3020
|
-
const filePath = path4.join(dirPath,
|
|
3021
|
-
|
|
2888
|
+
const files = fs4.readdirSync(dirPath).filter((file) => {
|
|
2889
|
+
const filePath = path4.join(dirPath, file);
|
|
2890
|
+
const isFile = fs4.statSync(filePath).isFile();
|
|
2891
|
+
const ext = path4.extname(file).slice(1).toLowerCase();
|
|
2892
|
+
return isFile && (ext === "yml" || ext === "yaml");
|
|
3022
2893
|
}).sort();
|
|
3023
|
-
if (
|
|
2894
|
+
if (files.length === 0) {
|
|
3024
2895
|
warn(`\u26A0\uFE0F No environment configuration files found at ${dirPath}`);
|
|
3025
2896
|
warn(
|
|
3026
2897
|
"Hint: If this is a new infrastructure repository, run `opencrvs environment init` first."
|
|
3027
2898
|
);
|
|
3028
2899
|
return null;
|
|
3029
2900
|
}
|
|
3030
|
-
const choices =
|
|
3031
|
-
name:
|
|
3032
|
-
value:
|
|
2901
|
+
const choices = files.map((file) => ({
|
|
2902
|
+
name: path4.basename(file, path4.extname(file)),
|
|
2903
|
+
value: path4.join(dirPath, file)
|
|
3033
2904
|
}));
|
|
3034
2905
|
const selectedFile = await select4({
|
|
3035
2906
|
message: "Select environment (inventory file) to load users:",
|
|
@@ -3038,34 +2909,33 @@ async function selectInventoryFile(dirPath = "./environments") {
|
|
|
3038
2909
|
return selectedFile;
|
|
3039
2910
|
}
|
|
3040
2911
|
async function manageEnvironmentUsers() {
|
|
3041
|
-
console.log("\n",
|
|
2912
|
+
console.log("\n", import_kleur5.default.bold().underline("Manage users"), "\n");
|
|
3042
2913
|
const inventory_file = await selectInventoryFile();
|
|
3043
2914
|
if (!inventory_file) {
|
|
3044
2915
|
return;
|
|
3045
2916
|
}
|
|
3046
2917
|
await manageUsers(inventory_file);
|
|
3047
2918
|
}
|
|
3048
|
-
var fs4, path4,
|
|
2919
|
+
var fs4, path4, import_kleur5;
|
|
3049
2920
|
var init_users = __esm({
|
|
3050
2921
|
"src/environment/users.ts"() {
|
|
3051
2922
|
"use strict";
|
|
3052
2923
|
fs4 = __toESM(require("fs"));
|
|
3053
2924
|
path4 = __toESM(require("path"));
|
|
3054
|
-
|
|
2925
|
+
import_kleur5 = __toESM(require("kleur"));
|
|
3055
2926
|
init_manage_users();
|
|
3056
2927
|
init_logger();
|
|
3057
|
-
init_paths();
|
|
3058
2928
|
}
|
|
3059
2929
|
});
|
|
3060
2930
|
|
|
3061
2931
|
// src/environment/swarm-to-k8s.ts
|
|
3062
2932
|
var swarm_to_k8s_exports = {};
|
|
3063
|
-
var path5,
|
|
2933
|
+
var path5, import_kleur6, import_core2;
|
|
3064
2934
|
var init_swarm_to_k8s = __esm({
|
|
3065
2935
|
"src/environment/swarm-to-k8s.ts"() {
|
|
3066
2936
|
"use strict";
|
|
3067
2937
|
path5 = __toESM(require("path"));
|
|
3068
|
-
|
|
2938
|
+
import_kleur6 = __toESM(require("kleur"));
|
|
3069
2939
|
init_logger();
|
|
3070
2940
|
init_utils();
|
|
3071
2941
|
init_templates();
|
|
@@ -3074,7 +2944,7 @@ var init_swarm_to_k8s = __esm({
|
|
|
3074
2944
|
init_github();
|
|
3075
2945
|
(async () => {
|
|
3076
2946
|
log(
|
|
3077
|
-
|
|
2947
|
+
import_kleur6.default.bold(
|
|
3078
2948
|
"------------------------------------------------\nOpenCRVS Infrastructure migration script: \nMigrating Swarm configurations to Kubernetes\n------------------------------------------------\n"
|
|
3079
2949
|
)
|
|
3080
2950
|
);
|
|
@@ -3105,7 +2975,7 @@ var init_swarm_to_k8s = __esm({
|
|
|
3105
2975
|
);
|
|
3106
2976
|
process.exit(0);
|
|
3107
2977
|
}
|
|
3108
|
-
log(
|
|
2978
|
+
log(import_kleur6.default.bold().underline("Migration properties:"));
|
|
3109
2979
|
log(` \u2713 Environment: ${environment}`);
|
|
3110
2980
|
const old_inventory_path = process.env.OLD_INVENTORY_PATH || "";
|
|
3111
2981
|
if (!old_inventory_path) {
|
|
@@ -3423,9 +3293,8 @@ async function runUpgrade(dockerSwarm) {
|
|
|
3423
3293
|
}
|
|
3424
3294
|
|
|
3425
3295
|
// src/environment/index.ts
|
|
3426
|
-
var
|
|
3427
|
-
var
|
|
3428
|
-
init_paths();
|
|
3296
|
+
var import_fs4 = require("fs");
|
|
3297
|
+
var import_path4 = require("path");
|
|
3429
3298
|
var REQUIRED_REPOSITORY_DIRECTORIES = [
|
|
3430
3299
|
".github/workflows",
|
|
3431
3300
|
"environments",
|
|
@@ -3435,7 +3304,7 @@ function validateRepositoryStructure(repositoryRoot = process.cwd()) {
|
|
|
3435
3304
|
const missingDirectories = REQUIRED_REPOSITORY_DIRECTORIES.filter(
|
|
3436
3305
|
(directory) => {
|
|
3437
3306
|
try {
|
|
3438
|
-
return !(0,
|
|
3307
|
+
return !(0, import_fs4.statSync)((0, import_path4.resolve)(repositoryRoot, directory)).isDirectory();
|
|
3439
3308
|
} catch {
|
|
3440
3309
|
return true;
|
|
3441
3310
|
}
|
|
@@ -3449,14 +3318,8 @@ function validateRepositoryStructure(repositoryRoot = process.cwd()) {
|
|
|
3449
3318
|
}
|
|
3450
3319
|
async function runEnvironmentInit() {
|
|
3451
3320
|
validateRepositoryStructure();
|
|
3452
|
-
assertNoOldInventoryLayout();
|
|
3453
3321
|
await Promise.resolve().then(() => (init_setup_environment(), setup_environment_exports));
|
|
3454
3322
|
}
|
|
3455
|
-
async function runEnvironmentUpgrade() {
|
|
3456
|
-
validateRepositoryStructure();
|
|
3457
|
-
const { upgradeEnvironmentLayout: upgradeEnvironmentLayout2 } = await Promise.resolve().then(() => (init_upgrade(), upgrade_exports));
|
|
3458
|
-
await upgradeEnvironmentLayout2();
|
|
3459
|
-
}
|
|
3460
3323
|
async function runEnvironmentUpdateWorkflows() {
|
|
3461
3324
|
validateRepositoryStructure();
|
|
3462
3325
|
const { updateWorkflowEnvironments: updateWorkflowEnvironments2 } = await Promise.resolve().then(() => (init_update_workflows(), update_workflows_exports));
|
|
@@ -3526,7 +3389,6 @@ Usage: opencrvs environment <subcommand>
|
|
|
3526
3389
|
|
|
3527
3390
|
Subcommands:
|
|
3528
3391
|
init Initialise a new environment
|
|
3529
|
-
upgrade Upgrade existing environment configuration layout
|
|
3530
3392
|
update-workflows Update workflow environment options
|
|
3531
3393
|
users Manage environment users
|
|
3532
3394
|
swarm-to-k8s Migrate Docker Swarm configuration to Kubernetes
|
|
@@ -3537,8 +3399,6 @@ Subcommands:
|
|
|
3537
3399
|
switch (subcommand) {
|
|
3538
3400
|
case "init":
|
|
3539
3401
|
return runEnvironmentCommand("initialisation", runEnvironmentInit);
|
|
3540
|
-
case "upgrade":
|
|
3541
|
-
return runEnvironmentCommand("environment upgrade", runEnvironmentUpgrade);
|
|
3542
3402
|
case "update-workflows":
|
|
3543
3403
|
return runEnvironmentCommand(
|
|
3544
3404
|
"workflow update",
|
|
@@ -3559,10 +3419,10 @@ Subcommands:
|
|
|
3559
3419
|
async function runEnvironmentCommand(operation, command) {
|
|
3560
3420
|
try {
|
|
3561
3421
|
await command();
|
|
3562
|
-
} catch (
|
|
3422
|
+
} catch (error4) {
|
|
3563
3423
|
console.error(
|
|
3564
3424
|
`Environment ${operation} failed:`,
|
|
3565
|
-
|
|
3425
|
+
error4 instanceof Error ? error4.message : error4
|
|
3566
3426
|
);
|
|
3567
3427
|
process.exit(1);
|
|
3568
3428
|
}
|
|
@@ -3588,8 +3448,8 @@ async function handleUpgrade() {
|
|
|
3588
3448
|
try {
|
|
3589
3449
|
await runUpgrade(dockerSwarm);
|
|
3590
3450
|
console.log("Upgrade completed successfully!");
|
|
3591
|
-
} catch (
|
|
3592
|
-
console.error("Upgrade failed:",
|
|
3451
|
+
} catch (error4) {
|
|
3452
|
+
console.error("Upgrade failed:", error4);
|
|
3593
3453
|
process.exit(1);
|
|
3594
3454
|
}
|
|
3595
3455
|
}
|
|
@@ -7834,8 +7834,8 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
7834
7834
|
email?: string | undefined;
|
|
7835
7835
|
status?: string | undefined;
|
|
7836
7836
|
primaryOfficeId?: string | undefined;
|
|
7837
|
-
count
|
|
7838
|
-
skip
|
|
7837
|
+
count: number;
|
|
7838
|
+
skip: number;
|
|
7839
7839
|
sortBy?: "createdAt" | "email" | "firstname" | "role" | "status" | "surname" | "username" | undefined;
|
|
7840
7840
|
sortOrder: "asc" | "desc";
|
|
7841
7841
|
};
|
|
@@ -8351,15 +8351,8 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
8351
8351
|
name: string;
|
|
8352
8352
|
externalId?: string | null | undefined;
|
|
8353
8353
|
administrativeAreaId: (string & import("zod").$brand<"UUID">) | null;
|
|
8354
|
+
validUntil: string | null;
|
|
8354
8355
|
locationType: string | null;
|
|
8355
|
-
status: "active" | "inactive";
|
|
8356
|
-
versions: {
|
|
8357
|
-
versionId: string & import("zod").$brand<"UUID">;
|
|
8358
|
-
effectiveFrom: string;
|
|
8359
|
-
name: string;
|
|
8360
|
-
externalId?: string | null | undefined;
|
|
8361
|
-
status: "active" | "inactive";
|
|
8362
|
-
}[];
|
|
8363
8356
|
}[];
|
|
8364
8357
|
meta: object;
|
|
8365
8358
|
}>;
|
|
@@ -8369,6 +8362,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
8369
8362
|
name: string;
|
|
8370
8363
|
externalId?: string | null | undefined;
|
|
8371
8364
|
administrativeAreaId: string | null;
|
|
8365
|
+
validUntil: string | null;
|
|
8372
8366
|
locationType: string | null;
|
|
8373
8367
|
}[];
|
|
8374
8368
|
output: void;
|
|
@@ -8383,15 +8377,8 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
8383
8377
|
name: string;
|
|
8384
8378
|
externalId?: string | null | undefined;
|
|
8385
8379
|
administrativeAreaId: (string & import("zod").$brand<"UUID">) | null;
|
|
8380
|
+
validUntil: string | null;
|
|
8386
8381
|
locationType: string | null;
|
|
8387
|
-
status: "active" | "inactive";
|
|
8388
|
-
versions: {
|
|
8389
|
-
versionId: string & import("zod").$brand<"UUID">;
|
|
8390
|
-
effectiveFrom: string;
|
|
8391
|
-
name: string;
|
|
8392
|
-
externalId?: string | null | undefined;
|
|
8393
|
-
status: "active" | "inactive";
|
|
8394
|
-
}[];
|
|
8395
8382
|
};
|
|
8396
8383
|
meta: import("trpc-to-openapi").OpenApiMeta;
|
|
8397
8384
|
}>;
|
|
@@ -8799,14 +8786,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
8799
8786
|
name: string;
|
|
8800
8787
|
externalId?: string | null | undefined;
|
|
8801
8788
|
parentId: (string & import("zod").$brand<"UUID">) | null;
|
|
8802
|
-
|
|
8803
|
-
versions: {
|
|
8804
|
-
versionId: string & import("zod").$brand<"UUID">;
|
|
8805
|
-
effectiveFrom: string;
|
|
8806
|
-
name: string;
|
|
8807
|
-
externalId?: string | null | undefined;
|
|
8808
|
-
status: "active" | "inactive";
|
|
8809
|
-
}[];
|
|
8789
|
+
validUntil: string | null;
|
|
8810
8790
|
}[];
|
|
8811
8791
|
meta: import("trpc-to-openapi").OpenApiMeta;
|
|
8812
8792
|
}>;
|
|
@@ -8816,6 +8796,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
8816
8796
|
name: string;
|
|
8817
8797
|
externalId?: string | null | undefined;
|
|
8818
8798
|
parentId: string | null;
|
|
8799
|
+
validUntil: string | null;
|
|
8819
8800
|
}[];
|
|
8820
8801
|
output: void;
|
|
8821
8802
|
meta: object;
|
|
@@ -86,16 +86,16 @@ export declare const user: typeof userSerializer & {
|
|
|
86
86
|
scope: (scope: import("../scopes").ScopeType) => {
|
|
87
87
|
attribute: (option: import("../scopes").ScopeOptionKey) => {
|
|
88
88
|
$scope: "attachment.upload" | "bypassratelimit" | "config.update-all" | "dashboard.view" | "integration.create" | "organisation.read-locations" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "profile.electronic-signature" | "record.archive" | "record.confirm-registration" | "record.correct" | "record.create" | "record.custom-action" | "record.declare" | "record.edit" | "record.import" | "record.notify" | "record.print-certified-copies" | "record.read" | "record.register" | "record.reindex" | "record.reject" | "record.reject-registration" | "record.request-correction" | "record.review-duplicates" | "record.search" | "record.unarchive" | "record.unassign-others" | "user.create" | "user.data-seeding" | "user.edit" | "user.read" | "user.read-only-my-audit" | "user.search" | "workqueue";
|
|
89
|
-
$option: "accessLevel" | "declaredBy" | "declaredIn" | "event" | "ids" | "notifiedBy" | "notifiedIn" | "placeOfEvent" | "registeredBy" | "registeredIn" | "role";
|
|
89
|
+
$option: "accessLevel" | "declaredBy" | "declaredIn" | "event" | "flags" | "ids" | "notifiedBy" | "notifiedIn" | "placeOfEvent" | "registeredBy" | "registeredIn" | "role";
|
|
90
90
|
};
|
|
91
91
|
};
|
|
92
92
|
jurisdiction: (jurisdiction: import("../scopes").JurisdictionFilter | {
|
|
93
93
|
$scope: "attachment.upload" | "bypassratelimit" | "config.update-all" | "dashboard.view" | "integration.create" | "organisation.read-locations" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "profile.electronic-signature" | "record.archive" | "record.confirm-registration" | "record.correct" | "record.create" | "record.custom-action" | "record.declare" | "record.edit" | "record.import" | "record.notify" | "record.print-certified-copies" | "record.read" | "record.register" | "record.reindex" | "record.reject" | "record.reject-registration" | "record.request-correction" | "record.review-duplicates" | "record.search" | "record.unarchive" | "record.unassign-others" | "user.create" | "user.data-seeding" | "user.edit" | "user.read" | "user.read-only-my-audit" | "user.search" | "workqueue";
|
|
94
|
-
$option: "accessLevel" | "declaredBy" | "declaredIn" | "event" | "ids" | "notifiedBy" | "notifiedIn" | "placeOfEvent" | "registeredBy" | "registeredIn" | "role";
|
|
94
|
+
$option: "accessLevel" | "declaredBy" | "declaredIn" | "event" | "flags" | "ids" | "notifiedBy" | "notifiedIn" | "placeOfEvent" | "registeredBy" | "registeredIn" | "role";
|
|
95
95
|
}) => {
|
|
96
96
|
$jurisdiction: "administrativeArea" | "all" | "location" | {
|
|
97
97
|
$scope: "attachment.upload" | "bypassratelimit" | "config.update-all" | "dashboard.view" | "integration.create" | "organisation.read-locations" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "profile.electronic-signature" | "record.archive" | "record.confirm-registration" | "record.correct" | "record.create" | "record.custom-action" | "record.declare" | "record.edit" | "record.import" | "record.notify" | "record.print-certified-copies" | "record.read" | "record.register" | "record.reindex" | "record.reject" | "record.reject-registration" | "record.request-correction" | "record.review-duplicates" | "record.search" | "record.unarchive" | "record.unassign-others" | "user.create" | "user.data-seeding" | "user.edit" | "user.read" | "user.read-only-my-audit" | "user.search" | "workqueue";
|
|
98
|
-
$option: "accessLevel" | "declaredBy" | "declaredIn" | "event" | "ids" | "notifiedBy" | "notifiedIn" | "placeOfEvent" | "registeredBy" | "registeredIn" | "role";
|
|
98
|
+
$option: "accessLevel" | "declaredBy" | "declaredIn" | "event" | "flags" | "ids" | "notifiedBy" | "notifiedIn" | "placeOfEvent" | "registeredBy" | "registeredIn" | "role";
|
|
99
99
|
};
|
|
100
100
|
};
|
|
101
101
|
hasScope: (scope: string) => JSONSchema;
|