@opencrvs/toolkit 2.0.1-rc.fed4de8 → 2.1.0-beta
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 +16 -0
- package/build.sh +14 -5
- package/create-countryconfig/index.js +412 -59
- package/create-countryconfig/node_modules/.bin/degit +21 -0
- package/create-countryconfig/package.json +5 -2
- package/dist/application-config/index.js +369 -280
- package/dist/authentication/index.d.ts +67 -0
- package/dist/authentication/index.d.ts.map +1 -0
- package/dist/authentication/index.js +750 -0
- package/dist/cli.js +4619 -4737
- package/dist/commons/api/router.d.ts +4122 -2944
- package/dist/commons/application-config/index.d.ts +6 -6
- package/dist/commons/conditionals/conditionals.d.ts +32 -323
- package/dist/commons/conditionals/validate.d.ts +16 -5
- package/dist/commons/events/ActionConfig.d.ts +302 -67
- package/dist/commons/events/ActionDocument.d.ts +159 -121
- package/dist/commons/events/ActionInput.d.ts +30 -10
- package/dist/commons/events/ActionStatus.d.ts +14 -0
- package/dist/commons/events/ActionType.d.ts +63 -58
- package/dist/commons/events/AdvancedSearchConfig.d.ts +531 -495
- package/dist/commons/events/AuditLog.d.ts +189 -40
- package/dist/commons/events/CompositeFieldValue.d.ts +4 -4
- package/dist/commons/events/Conditional.d.ts +3 -3
- package/dist/commons/events/CountryConfigQueryInput.d.ts +603 -561
- package/dist/commons/events/Draft.d.ts +38 -36
- package/dist/commons/events/DynamicFieldValue.d.ts +9 -9
- package/dist/commons/events/EventConfig.d.ts +8 -3
- package/dist/commons/events/EventDocument.d.ts +537 -47
- package/dist/commons/events/EventIndex.d.ts +61 -59
- package/dist/commons/events/EventMetadata.d.ts +59 -43
- package/dist/commons/events/EventStatus.d.ts +19 -0
- package/dist/commons/events/FieldConfig.d.ts +424 -379
- package/dist/commons/events/FieldType.d.ts +51 -51
- package/dist/commons/events/FieldTypeMapping.d.ts +86 -86
- package/dist/commons/events/FieldValue.d.ts +14 -14
- package/dist/commons/events/Flag.d.ts +57 -15
- package/dist/commons/events/PlainDate.d.ts +8 -0
- package/dist/commons/events/SummaryConfig.d.ts +249 -0
- package/dist/commons/events/TemplateConfig.d.ts +1 -1
- package/dist/commons/events/WorkqueueColumnConfig.d.ts +40 -40
- package/dist/commons/events/WorkqueueConfig.d.ts +835 -790
- package/dist/commons/events/deduplication.d.ts +1 -1
- package/dist/commons/events/event.d.ts +14 -2
- package/dist/commons/events/field.d.ts +69 -198
- package/dist/commons/events/index.d.ts +1 -0
- package/dist/commons/events/locationPayloads.d.ts +95 -0
- package/dist/commons/events/locations.d.ts +248 -14
- package/dist/commons/events/mocks.test.utils.d.ts +48 -4
- package/dist/commons/events/scopes.d.ts +5 -4
- package/dist/commons/events/state/index.d.ts +23 -15
- package/dist/commons/events/state/utils.d.ts +15 -6
- package/dist/commons/events/test.utils.d.ts +68 -42
- package/dist/commons/events/utils.d.ts +139 -106
- package/dist/commons/notification/UserNotifications.d.ts +38 -23
- package/dist/commons/notification/dispatch.d.ts +10 -0
- package/dist/commons/notification/index.d.ts +1 -0
- package/dist/conditionals/index.js +341 -66
- package/dist/csv.d.ts +25 -0
- package/dist/csv.d.ts.map +1 -0
- package/dist/csv.js +120 -0
- package/dist/environment/custom-types.d.ts +33 -0
- package/dist/environment/custom-types.d.ts.map +1 -0
- package/dist/environment/custom-types.js +12 -0
- package/dist/environment/derived-variables.d.ts +122 -0
- package/dist/environment/derived-variables.d.ts.map +1 -0
- package/dist/environment/derived-variables.js +155 -0
- package/dist/environment/editor-questions.d.ts +4 -0
- package/dist/environment/editor-questions.d.ts.map +1 -0
- package/dist/environment/editor-questions.js +67 -0
- package/dist/environment/git.d.ts +5 -0
- package/dist/environment/git.d.ts.map +1 -0
- package/dist/environment/git.js +38 -0
- package/dist/environment/github.d.ts +26 -0
- package/dist/environment/github.d.ts.map +1 -0
- package/dist/environment/github.js +247 -0
- package/dist/environment/index.d.ts +6 -0
- package/dist/environment/index.d.ts.map +1 -0
- package/dist/environment/index.js +81 -0
- package/dist/environment/logger.d.ts +18 -0
- package/dist/environment/logger.d.ts.map +1 -0
- package/dist/environment/logger.js +25 -0
- package/dist/environment/manage-users.d.ts +11 -0
- package/dist/environment/manage-users.d.ts.map +1 -0
- package/dist/environment/manage-users.js +507 -0
- package/dist/environment/paths.d.ts +7 -0
- package/dist/environment/paths.d.ts.map +1 -0
- package/dist/environment/paths.js +72 -0
- package/dist/environment/questions-helper.d.ts +15 -0
- package/dist/environment/questions-helper.d.ts.map +1 -0
- package/dist/environment/questions-helper.js +70 -0
- package/dist/environment/questions.d.ts +200 -0
- package/dist/environment/questions.d.ts.map +1 -0
- package/dist/environment/questions.js +418 -0
- package/dist/environment/setup-environment.d.ts +2 -0
- package/dist/environment/setup-environment.d.ts.map +1 -0
- package/dist/environment/setup-environment.js +795 -0
- package/dist/environment/ssh-keygen.d.ts +5 -0
- package/dist/environment/ssh-keygen.d.ts.map +1 -0
- package/dist/environment/ssh-keygen.js +21 -0
- package/dist/environment/swarm-to-k8s.d.ts +2 -0
- package/dist/environment/swarm-to-k8s.d.ts.map +1 -0
- package/dist/environment/swarm-to-k8s.js +183 -0
- package/dist/environment/templates.d.ts +27 -0
- package/dist/environment/templates.d.ts.map +1 -0
- package/dist/environment/templates.js +164 -0
- package/dist/environment/update-workflows.d.ts +2 -0
- package/dist/environment/update-workflows.d.ts.map +1 -0
- package/dist/environment/update-workflows.js +191 -0
- package/dist/environment/upgrade.d.ts +2 -0
- package/dist/environment/upgrade.d.ts.map +1 -0
- package/dist/environment/upgrade.js +82 -0
- package/dist/environment/users.d.ts +2 -0
- package/dist/environment/users.d.ts.map +1 -0
- package/dist/environment/users.js +120 -0
- package/dist/environment/utils.d.ts +18 -0
- package/dist/environment/utils.d.ts.map +1 -0
- package/dist/environment/utils.js +110 -0
- package/dist/events/deduplication.d.ts +1 -1
- package/dist/events/index.js +8106 -7390
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
- package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
- package/dist/migrations/v2.0/convert-config-files-to-ts.js +17 -7
- package/dist/migrations/v2.0/index.js +88 -5141
- package/dist/migrations/v2.0/merge-infrastructure-directory.js +3 -3
- package/dist/migrations/v2.0/migrate-application-config-url.js +4 -3
- package/dist/migrations/v2.0/remove-hearth-migrations.js +17 -7
- package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +3 -0
- package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +1 -0
- package/dist/migrations/v2.1/add-explicit-correction-flags.js +234 -0
- package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +3 -0
- package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -0
- package/dist/migrations/v2.1/add-recovery-link-notifications.js +511 -0
- package/dist/migrations/v2.1/add-translations.d.ts +9 -0
- package/dist/migrations/v2.1/add-translations.d.ts.map +1 -0
- package/dist/migrations/v2.1/add-translations.js +213 -0
- package/dist/migrations/v2.1/enable-telemetry.d.ts +3 -0
- package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -0
- package/dist/migrations/v2.1/enable-telemetry.js +438 -0
- package/dist/migrations/v2.1/index.d.ts +6 -0
- package/dist/migrations/v2.1/index.d.ts.map +1 -0
- package/dist/migrations/v2.1/index.js +1276 -0
- package/dist/notification/index.js +2011 -1446
- package/dist/scopes/index.d.ts +514 -168
- package/dist/scopes/index.js +342 -66
- package/dist/telemetry/index.d.ts +45 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +39 -0
- package/dist/templates/charts-values/dependencies/values.override.yaml +4 -0
- package/dist/templates/charts-values/dependencies/values.yaml +82 -0
- package/dist/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
- package/dist/templates/charts-values/opencrvs-services/values.yaml +78 -0
- package/dist/templates/charts-values/opentelemetry/values.yaml +95 -0
- package/dist/templates/charts-values/traefik/values.override.yaml +4 -0
- package/dist/templates/charts-values/traefik/values.yaml +129 -0
- package/dist/templates/inventory/inventory.template.yml +98 -0
- package/dist/translations/check.d.ts +19 -0
- package/dist/translations/check.d.ts.map +1 -0
- package/dist/translations/check.js +127 -0
- package/dist/verify/endpoints.d.ts +2 -0
- package/dist/verify/endpoints.d.ts.map +1 -0
- package/dist/verify/endpoints.js +345 -0
- package/opencrvs-toolkit-2.1.0-beta.tgz +0 -0
- package/package.json +25 -6
- package/tsconfig.build.json +11 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +3 -0
- package/opencrvs-toolkit-2.0.1-rc.fed4de8.tgz +0 -0
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,247 @@
|
|
|
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.createEnvironmentVariable = createEnvironmentVariable;
|
|
26
|
+
exports.updateEnvironmentVariable = updateEnvironmentVariable;
|
|
27
|
+
exports.createRepositoryVariable = createRepositoryVariable;
|
|
28
|
+
exports.updateRepositoryVariable = updateRepositoryVariable;
|
|
29
|
+
exports.getRepositoryId = getRepositoryId;
|
|
30
|
+
exports.createEnvironmentSecret = createEnvironmentSecret;
|
|
31
|
+
exports.createRepositorySecret = createRepositorySecret;
|
|
32
|
+
exports.getRepositoryEnvironments = getRepositoryEnvironments;
|
|
33
|
+
exports.createEnvironment = createEnvironment;
|
|
34
|
+
exports.listEnvironmentSecrets = listEnvironmentSecrets;
|
|
35
|
+
exports.listRepositorySecrets = listRepositorySecrets;
|
|
36
|
+
exports.listEnvironmentVariables = listEnvironmentVariables;
|
|
37
|
+
exports.listRepositoryVariables = listRepositoryVariables;
|
|
38
|
+
const libsodium_wrappers_1 = __importDefault(require("libsodium-wrappers"));
|
|
39
|
+
const logger_1 = require("./logger");
|
|
40
|
+
function createEnvironmentVariable(octokit, repositoryId, environment, name, value) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
yield octokit.request(`POST /repositories/${repositoryId}/environments/${environment}/variables`, {
|
|
43
|
+
repository_id: repositoryId,
|
|
44
|
+
environment_name: environment,
|
|
45
|
+
name: name,
|
|
46
|
+
value: value,
|
|
47
|
+
headers: {
|
|
48
|
+
'X-GitHub-Api-Version': '2022-11-28'
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function updateEnvironmentVariable(octokit, repositoryId, environment, name, value) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
yield octokit.request(`PATCH /repositories/${repositoryId}/environments/${environment}/variables/${name}`, {
|
|
56
|
+
repository_id: repositoryId,
|
|
57
|
+
environment_name: environment,
|
|
58
|
+
name: name,
|
|
59
|
+
value: value,
|
|
60
|
+
headers: {
|
|
61
|
+
'X-GitHub-Api-Version': '2022-11-28'
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
// Create repository variable
|
|
67
|
+
function createRepositoryVariable(octokit, repositoryId, name, value) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
yield octokit.request(`POST /repositories/${repositoryId}/actions/variables`, {
|
|
70
|
+
repository_id: repositoryId,
|
|
71
|
+
name: name,
|
|
72
|
+
value: value,
|
|
73
|
+
headers: {
|
|
74
|
+
'X-GitHub-Api-Version': '2022-11-28'
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
// Update repository variable
|
|
80
|
+
function updateRepositoryVariable(octokit, repositoryId, name, value) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
yield octokit.request(`PATCH /repositories/${repositoryId}/actions/variables/${name}`, {
|
|
83
|
+
repository_id: repositoryId,
|
|
84
|
+
name: name,
|
|
85
|
+
value: value,
|
|
86
|
+
headers: {
|
|
87
|
+
'X-GitHub-Api-Version': '2022-11-28'
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function getRepositoryId(octokit, owner, repo) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
const response = yield octokit.request('GET /repos/{owner}/{repo}', {
|
|
95
|
+
owner: owner,
|
|
96
|
+
repo: repo
|
|
97
|
+
});
|
|
98
|
+
return response.data.id;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
function getRepositoryPublicKey(octokit, owner, repo) {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
const res = yield octokit.request('GET /repos/{owner}/{repo}/actions/secrets/public-key', {
|
|
104
|
+
owner: owner,
|
|
105
|
+
repo: repo
|
|
106
|
+
});
|
|
107
|
+
return res.data;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function getPublicKey(octokit, environment, ORGANISATION, REPOSITORY_NAME) {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
const repositoryId = yield getRepositoryId(octokit, ORGANISATION, REPOSITORY_NAME);
|
|
113
|
+
yield octokit.request(`PUT /repos/${ORGANISATION}/${REPOSITORY_NAME}/environments/${environment}`, {
|
|
114
|
+
headers: {
|
|
115
|
+
'X-GitHub-Api-Version': '2022-11-28'
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
const res = yield octokit.request(`GET /repositories/${repositoryId}/environments/${environment}/secrets/public-key`, {
|
|
119
|
+
owner: ORGANISATION,
|
|
120
|
+
repo: REPOSITORY_NAME,
|
|
121
|
+
headers: {
|
|
122
|
+
'X-GitHub-Api-Version': '2022-11-28'
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
return res.data;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function createEnvironmentSecret(octokit, repositoryId, environment, name, secret, organisationName, repositoryName) {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
//Check if libsodium is ready and then proceed.
|
|
131
|
+
yield libsodium_wrappers_1.default.ready;
|
|
132
|
+
const { key, key_id } = yield getPublicKey(octokit, environment, organisationName, repositoryName);
|
|
133
|
+
// Convert Secret & Base64 key to Uint8Array.
|
|
134
|
+
const binkey = libsodium_wrappers_1.default.from_base64(key, libsodium_wrappers_1.default.base64_variants.ORIGINAL);
|
|
135
|
+
const binsec = libsodium_wrappers_1.default.from_string(secret);
|
|
136
|
+
//Encrypt the secret using LibSodium
|
|
137
|
+
const encBytes = libsodium_wrappers_1.default.crypto_box_seal(binsec, binkey);
|
|
138
|
+
// Convert encrypted Uint8Array to Base64
|
|
139
|
+
const encryptedValue = libsodium_wrappers_1.default.to_base64(encBytes, libsodium_wrappers_1.default.base64_variants.ORIGINAL);
|
|
140
|
+
yield octokit.request(`PUT /repositories/${repositoryId}/environments/${environment}/secrets/${name}`, {
|
|
141
|
+
repository_id: repositoryId,
|
|
142
|
+
environment_name: environment,
|
|
143
|
+
secret_name: name,
|
|
144
|
+
encrypted_value: encryptedValue,
|
|
145
|
+
key_id,
|
|
146
|
+
headers: {
|
|
147
|
+
'X-GitHub-Api-Version': '2022-11-28'
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
function createRepositorySecret(octokit, repositoryId, name, secret, organisationName, repositoryName) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
//Check if libsodium is ready and then proceed.
|
|
155
|
+
yield libsodium_wrappers_1.default.ready;
|
|
156
|
+
const { key, key_id } = yield getRepositoryPublicKey(octokit, organisationName, repositoryName);
|
|
157
|
+
// Convert Secret & Base64 key to Uint8Array.
|
|
158
|
+
const binkey = libsodium_wrappers_1.default.from_base64(key, libsodium_wrappers_1.default.base64_variants.ORIGINAL);
|
|
159
|
+
const binsec = libsodium_wrappers_1.default.from_string(secret);
|
|
160
|
+
//Encrypt the secret using LibSodium
|
|
161
|
+
const encBytes = libsodium_wrappers_1.default.crypto_box_seal(binsec, binkey);
|
|
162
|
+
// Convert encrypted Uint8Array to Base64
|
|
163
|
+
const encryptedValue = libsodium_wrappers_1.default.to_base64(encBytes, libsodium_wrappers_1.default.base64_variants.ORIGINAL);
|
|
164
|
+
yield octokit.request(`PUT /repositories/${repositoryId}/actions/secrets/${name}`, {
|
|
165
|
+
encrypted_value: encryptedValue,
|
|
166
|
+
key_id,
|
|
167
|
+
headers: {
|
|
168
|
+
'X-GitHub-Api-Version': '2022-11-28'
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
function getRepositoryEnvironments(octokit, githubOrganisation, repository) {
|
|
174
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
+
var _a;
|
|
176
|
+
const response = yield octokit.request('GET /repos/{githubOrganisation}/{repository}/environments', {
|
|
177
|
+
githubOrganisation,
|
|
178
|
+
repository
|
|
179
|
+
});
|
|
180
|
+
// Safe access with fallback to empty array if undefined
|
|
181
|
+
const environments = ((_a = response.data.environments) !== null && _a !== void 0 ? _a : []).map((env) => env.name);
|
|
182
|
+
return environments;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
function createEnvironment(octokit, environment, ORGANISATION, REPOSITORY_NAME) {
|
|
186
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
var _a, _b, _c, _d;
|
|
188
|
+
try {
|
|
189
|
+
yield octokit.request(`PUT /repos/${ORGANISATION}/${REPOSITORY_NAME}/environments/${environment}`, {
|
|
190
|
+
headers: {
|
|
191
|
+
'X-GitHub-Api-Version': '2022-11-28'
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
catch (err) {
|
|
197
|
+
(0, logger_1.error)(`Cannot create environment: [${err.status}] ${(_b = (_a = err.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message}`);
|
|
198
|
+
throw new Error(`Cannot create environment: [${err.status}] ${(_d = (_c = err.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.message}`);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
function listEnvironmentSecrets(octokit, owner, repositoryId, environmentName) {
|
|
203
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
204
|
+
const response = yield octokit.request('GET /repositories/{repository_id}/environments/{environment_name}/secrets', {
|
|
205
|
+
owner: owner,
|
|
206
|
+
repository_id: repositoryId,
|
|
207
|
+
environment_name: environmentName,
|
|
208
|
+
per_page: 100
|
|
209
|
+
});
|
|
210
|
+
return response.data.secrets.map((secret) => (Object.assign(Object.assign({}, secret), { type: 'SECRET', scope: 'ENVIRONMENT' })));
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
function listRepositorySecrets(octokit, owner, repositoryName) {
|
|
214
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
215
|
+
const response = yield octokit.request('GET /repos/{owner}/{repo}/actions/secrets', {
|
|
216
|
+
owner: owner,
|
|
217
|
+
repo: repositoryName,
|
|
218
|
+
per_page: 100
|
|
219
|
+
});
|
|
220
|
+
return response.data.secrets.map((secret) => (Object.assign(Object.assign({}, secret), { type: 'SECRET', scope: 'REPOSITORY' })));
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
function listEnvironmentVariables(octokit, repositoryId, environmentName) {
|
|
224
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
225
|
+
const response = yield octokit.request('GET /repositories/{repository_id}/environments/{environment_name}/variables', {
|
|
226
|
+
repository_id: repositoryId,
|
|
227
|
+
environment_name: environmentName,
|
|
228
|
+
per_page: 100,
|
|
229
|
+
headers: {
|
|
230
|
+
'X-GitHub-Api-Version': '2022-11-28'
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
return response.data.variables
|
|
234
|
+
.map((variable) => (Object.assign(Object.assign({}, variable), { type: 'VARIABLE', scope: 'ENVIRONMENT' })))
|
|
235
|
+
.filter((variable) => variable.name !== 'ACTIONS_RUNNER_DEBUG');
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
function listRepositoryVariables(octokit, owner, repositoryName) {
|
|
239
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
240
|
+
const response = yield octokit.request('GET /repos/{owner}/{repo}/actions/variables', {
|
|
241
|
+
owner: owner,
|
|
242
|
+
repo: repositoryName,
|
|
243
|
+
per_page: 100
|
|
244
|
+
});
|
|
245
|
+
return response.data.variables.map((variable) => (Object.assign(Object.assign({}, variable), { type: 'VARIABLE', scope: 'REPOSITORY' })));
|
|
246
|
+
});
|
|
247
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function runEnvironmentInit(): Promise<void>;
|
|
2
|
+
export declare function runEnvironmentUpgrade(): Promise<void>;
|
|
3
|
+
export declare function runEnvironmentUpdateWorkflows(): Promise<void>;
|
|
4
|
+
export declare function runEnvironmentUsers(): Promise<void>;
|
|
5
|
+
export declare function runEnvironmentSwarmToK8s(): Promise<void>;
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.runEnvironmentInit = runEnvironmentInit;
|
|
23
|
+
exports.runEnvironmentUpgrade = runEnvironmentUpgrade;
|
|
24
|
+
exports.runEnvironmentUpdateWorkflows = runEnvironmentUpdateWorkflows;
|
|
25
|
+
exports.runEnvironmentUsers = runEnvironmentUsers;
|
|
26
|
+
exports.runEnvironmentSwarmToK8s = runEnvironmentSwarmToK8s;
|
|
27
|
+
const fs_1 = require("fs");
|
|
28
|
+
const path_1 = require("path");
|
|
29
|
+
const paths_1 = require("./paths");
|
|
30
|
+
const REQUIRED_REPOSITORY_DIRECTORIES = [
|
|
31
|
+
'.github/workflows',
|
|
32
|
+
'environments',
|
|
33
|
+
'infrastructure'
|
|
34
|
+
];
|
|
35
|
+
function validateRepositoryStructure(repositoryRoot = process.cwd()) {
|
|
36
|
+
const missingDirectories = REQUIRED_REPOSITORY_DIRECTORIES.filter((directory) => {
|
|
37
|
+
try {
|
|
38
|
+
return !(0, fs_1.statSync)((0, path_1.resolve)(repositoryRoot, directory)).isDirectory();
|
|
39
|
+
}
|
|
40
|
+
catch (_a) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
if (missingDirectories.length > 0) {
|
|
45
|
+
throw new Error(`The current directory is not a valid OpenCRVS country configuration repository. Missing required director${missingDirectories.length === 1 ? 'y' : 'ies'}: ${missingDirectories.join(', ')}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function runEnvironmentInit() {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
validateRepositoryStructure();
|
|
51
|
+
(0, paths_1.assertNoOldInventoryLayout)();
|
|
52
|
+
yield import('./setup-environment.js');
|
|
53
|
+
});
|
|
54
|
+
}
|
|
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
|
+
function runEnvironmentUpdateWorkflows() {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
validateRepositoryStructure();
|
|
65
|
+
const { updateWorkflowEnvironments } = yield import('./update-workflows.js');
|
|
66
|
+
yield updateWorkflowEnvironments();
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function runEnvironmentUsers() {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
validateRepositoryStructure();
|
|
72
|
+
const { manageEnvironmentUsers } = yield import('./users.js');
|
|
73
|
+
yield manageEnvironmentUsers();
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function runEnvironmentSwarmToK8s() {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
validateRepositoryStructure();
|
|
79
|
+
yield import('./swarm-to-k8s.js');
|
|
80
|
+
});
|
|
81
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const log: {
|
|
2
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
3
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
4
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
5
|
+
};
|
|
6
|
+
export declare const warn: {
|
|
7
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
8
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
9
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
10
|
+
};
|
|
11
|
+
export declare const success: (...args: any[]) => void;
|
|
12
|
+
export declare const info: {
|
|
13
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
14
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
15
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
16
|
+
};
|
|
17
|
+
export declare const error: (...args: any[]) => void;
|
|
18
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/environment/logger.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,GAAG;;;;CAAc,CAAA;AAC9B,eAAO,MAAM,IAAI;;;;CAAe,CAAA;AAChC,eAAO,MAAM,OAAO,YAAa,GAAG,EAAE,SACI,CAAA;AAC1C,eAAO,MAAM,IAAI;;;;CAAe,CAAA;AAChC,eAAO,MAAM,KAAK,YAAa,GAAG,EAAE,SAA2C,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.error = exports.info = exports.success = exports.warn = exports.log = void 0;
|
|
17
|
+
const kleur_1 = __importDefault(require("kleur"));
|
|
18
|
+
/* eslint-disable no-console */
|
|
19
|
+
exports.log = console.log;
|
|
20
|
+
exports.warn = console.warn;
|
|
21
|
+
const success = (...args) => console.log(kleur_1.default.green(args.join(' ')));
|
|
22
|
+
exports.success = success;
|
|
23
|
+
exports.info = console.info;
|
|
24
|
+
const error = (...args) => console.log(kleur_1.default.red(args.join(' ')));
|
|
25
|
+
exports.error = error;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface User {
|
|
2
|
+
name: string;
|
|
3
|
+
ssh_keys: string[];
|
|
4
|
+
state: 'present' | 'absent';
|
|
5
|
+
role: 'admin' | 'operator';
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Main function to manage users
|
|
9
|
+
*/
|
|
10
|
+
export declare function manageUsers(inventoryPath: string): Promise<User[]>;
|
|
11
|
+
//# sourceMappingURL=manage-users.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manage-users.d.ts","sourceRoot":"","sources":["../../src/environment/manage-users.ts"],"names":[],"mappings":"AAkCA,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,KAAK,EAAE,SAAS,GAAG,QAAQ,CAAA;IAC3B,IAAI,EAAE,OAAO,GAAG,UAAU,CAAA;CAC3B;AAkWD;;GAEG;AACH,wBAAsB,WAAW,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAqIxE"}
|