@opencrvs/toolkit 2.2.0-rc.045257f → 2.2.0-rc.25c3c81
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/build.sh +15 -2
- package/dist/application-config/index.js +16 -5
- package/dist/authentication/index.d.ts +1 -1
- package/dist/authentication/index.js +4 -8
- package/dist/cli.js +2197 -544
- package/dist/commons/api/router.d.ts +17 -4
- package/dist/commons/application-config/index.d.ts +1 -1
- package/dist/commons/conditionals/conditionals.d.ts +4 -4
- package/dist/commons/conditionals/validate.d.ts +1 -1
- package/dist/commons/events/ActionStatus.d.ts +2 -2
- package/dist/commons/events/ActionType.d.ts +2 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +3 -0
- package/dist/commons/events/Draft.d.ts +34 -1
- package/dist/commons/events/EventConfig.d.ts +446 -0
- package/dist/commons/events/EventDocument.d.ts +2 -0
- package/dist/commons/events/EventIndex.d.ts +1 -0
- package/dist/commons/events/EventInput.d.ts +1 -0
- package/dist/commons/events/EventMetadata.d.ts +1 -0
- package/dist/commons/events/FieldTypeMapping.d.ts +19 -19
- package/dist/commons/events/PlainDate.d.ts +5 -0
- package/dist/commons/events/defineConfig.d.ts +7 -2
- package/dist/commons/events/event.d.ts +4 -1
- package/dist/commons/events/field.d.ts +5 -0
- package/dist/commons/events/locations.d.ts +1 -1
- package/dist/commons/events/scopes.d.ts +2 -1
- package/dist/commons/events/state/index.d.ts +1 -0
- package/dist/commons/events/test.utils.d.ts +59 -6
- package/dist/commons/events/utils.d.ts +28 -2
- package/dist/commons/users/Role.d.ts +23 -0
- package/dist/commons/users/User.d.ts +263 -0
- package/dist/commons/users/authentication.d.ts +67 -0
- package/dist/commons/users/index.d.ts +5 -0
- package/dist/commons/users/roleValidations.d.ts +15 -0
- package/dist/commons/users/scopes.d.ts +1402 -0
- package/dist/commons/users/userReferences.d.ts +176 -0
- package/dist/conditionals/index.js +3 -3
- package/dist/configurator/index.d.ts +24 -0
- package/dist/configurator/index.d.ts.map +1 -0
- package/dist/configurator/index.js +161 -0
- package/dist/configurator/layout.d.ts +28 -0
- package/dist/configurator/layout.d.ts.map +1 -0
- package/dist/configurator/layout.js +78 -0
- package/dist/configurator/paths.d.ts +13 -0
- package/dist/configurator/paths.d.ts.map +1 -0
- package/dist/configurator/paths.js +48 -0
- package/dist/configurator/server/environments.d.ts +20 -0
- package/dist/configurator/server/environments.d.ts.map +1 -0
- package/dist/configurator/server/environments.js +143 -0
- package/dist/configurator/server/files.d.ts +11 -0
- package/dist/configurator/server/files.d.ts.map +1 -0
- package/dist/configurator/server/files.js +67 -0
- package/dist/configurator/server/github.d.ts +56 -0
- package/dist/configurator/server/github.d.ts.map +1 -0
- package/dist/configurator/server/github.js +239 -0
- package/dist/configurator/server/plugin.d.ts +39 -0
- package/dist/configurator/server/plugin.d.ts.map +1 -0
- package/dist/configurator/server/plugin.js +298 -0
- package/dist/configurator/server/seal.d.ts +2 -0
- package/dist/configurator/server/seal.d.ts.map +1 -0
- package/dist/configurator/server/seal.js +36 -0
- package/dist/configurator/server/sshKeys.d.ts +5 -0
- package/dist/configurator/server/sshKeys.d.ts.map +1 -0
- package/dist/configurator/server/sshKeys.js +28 -0
- package/dist/configurator/server/start.d.ts +12 -0
- package/dist/configurator/server/start.d.ts.map +1 -0
- package/dist/configurator/server/start.js +91 -0
- package/dist/configurator/testing.d.ts +11 -0
- package/dist/configurator/testing.d.ts.map +1 -0
- package/dist/configurator/testing.js +74 -0
- package/dist/configurator/ui/bindings/bindings.d.ts +35 -0
- package/dist/configurator/ui/bindings/bindings.d.ts.map +1 -0
- package/dist/configurator/ui/bindings/bindings.js +5 -0
- package/dist/configurator/ui/bindings/parsers.d.ts +7 -0
- package/dist/configurator/ui/bindings/parsers.d.ts.map +1 -0
- package/dist/configurator/ui/bindings/parsers.js +85 -0
- package/dist/configurator/ui/form/users.d.ts +11 -0
- package/dist/configurator/ui/form/users.d.ts.map +1 -0
- package/dist/configurator/ui/form/users.js +33 -0
- package/dist/configurator/ui/plan/dependencyHosts.d.ts +2 -0
- package/dist/configurator/ui/plan/dependencyHosts.d.ts.map +1 -0
- package/dist/configurator/ui/plan/dependencyHosts.js +36 -0
- package/dist/configurator/ui/plan/templateValues.d.ts +11 -0
- package/dist/configurator/ui/plan/templateValues.d.ts.map +1 -0
- package/dist/configurator/ui/plan/templateValues.js +70 -0
- package/dist/configurator/workflows.d.ts +53 -0
- package/dist/configurator/workflows.d.ts.map +1 -0
- package/dist/configurator/workflows.js +161 -0
- package/dist/configurator-assets/forms/bindings.yml +263 -0
- package/dist/configurator-assets/templates/README.md +18 -0
- package/dist/configurator-assets/templates/charts-values/dependencies/values.override.yaml +4 -0
- package/dist/configurator-assets/templates/charts-values/dependencies/values.yaml +99 -0
- package/dist/configurator-assets/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
- package/dist/configurator-assets/templates/charts-values/opencrvs-services/values.yaml +83 -0
- package/dist/configurator-assets/templates/charts-values/opentelemetry/values.yaml +102 -0
- package/dist/configurator-assets/templates/charts-values/traefik/values.override.yaml +4 -0
- package/dist/configurator-assets/templates/charts-values/traefik/values.yaml +130 -0
- package/dist/configurator-assets/templates/inventory/inventory.template.yml +98 -0
- package/dist/configurator-assets/ui/apple-touch-icon.png +0 -0
- package/dist/configurator-assets/ui/assets/index-Bf3eC7uO.js +169 -0
- package/dist/configurator-assets/ui/assets/index-CaqYFJUk.css +6 -0
- package/dist/configurator-assets/ui/assets/opencrvs-logo-sIjz08HT.svg +1 -0
- package/dist/configurator-assets/ui/assets/poppins-400-BwTUGeWf.woff2 +0 -0
- package/dist/configurator-assets/ui/assets/poppins-500-CWICHMj6.woff2 +0 -0
- package/dist/configurator-assets/ui/assets/poppins-600-DJVo7c07.woff2 +0 -0
- package/dist/configurator-assets/ui/assets/poppins-700-g9MkRaG0.woff2 +0 -0
- package/dist/configurator-assets/ui/favicon-32x32.png +0 -0
- package/dist/configurator-assets/ui/index.html +25 -0
- package/dist/environment/custom-types.d.ts +1 -0
- package/dist/environment/custom-types.d.ts.map +1 -1
- package/dist/environment/derived-variables.d.ts +8 -0
- package/dist/environment/derived-variables.d.ts.map +1 -1
- package/dist/environment/derived-variables.js +9 -0
- package/dist/environment/questions.d.ts +42 -9
- package/dist/environment/questions.d.ts.map +1 -1
- package/dist/environment/questions.js +70 -47
- package/dist/environment/registry.d.ts +15 -0
- package/dist/environment/registry.d.ts.map +1 -0
- package/dist/environment/registry.js +112 -0
- package/dist/environment/setup-environment.d.ts.map +1 -1
- package/dist/environment/setup-environment.js +104 -23
- package/dist/events/index.js +635 -149
- package/dist/migrations/add-notify-config.d.ts +40 -0
- package/dist/migrations/add-notify-config.d.ts.map +1 -0
- package/dist/migrations/add-notify-config.js +249 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +602 -143
- package/dist/migrations/move-declaration-to-declare-action.d.ts.map +1 -1
- package/dist/migrations/move-declaration-to-declare-action.js +27 -144
- package/dist/migrations/read-declaration-through-helper.d.ts.map +1 -1
- package/dist/migrations/read-declaration-through-helper.js +3 -61
- package/dist/migrations/resolve-versioned-event-config.d.ts +56 -0
- package/dist/migrations/resolve-versioned-event-config.d.ts.map +1 -0
- package/dist/migrations/resolve-versioned-event-config.js +353 -0
- package/dist/migrations/utils.d.ts +61 -0
- package/dist/migrations/utils.d.ts.map +1 -0
- package/dist/migrations/utils.js +218 -0
- package/dist/notification/index.js +616 -66
- package/dist/roles/index.d.ts +2 -0
- package/dist/roles/index.d.ts.map +1 -0
- package/dist/roles/index.js +730 -0
- package/dist/scopes/index.d.ts +0 -10
- package/dist/scopes/index.js +3 -7
- package/dist/templates/charts-values/dependencies/values.yaml +4 -1
- package/dist/templates/charts-values/opencrvs-services/values.yaml +2 -2
- package/dist/verify/endpoints.d.ts +11 -0
- package/dist/verify/endpoints.d.ts.map +1 -1
- package/dist/verify/endpoints.js +21 -27
- package/opencrvs-toolkit-2.2.0-rc.25c3c81.tgz +0 -0
- package/package.json +16 -3
- package/tsconfig.build.json +11 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.json +15 -6
- package/dist/environment/dockerhub.d.ts +0 -15
- package/dist/environment/dockerhub.d.ts.map +0 -1
- package/dist/environment/dockerhub.js +0 -104
- package/opencrvs-toolkit-2.2.0-rc.045257f.tgz +0 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SAFE_NAME = exports.ENVIRONMENT_FILES = void 0;
|
|
13
|
+
exports.listEnvironmentNames = listEnvironmentNames;
|
|
14
|
+
exports.readEnvironmentFiles = readEnvironmentFiles;
|
|
15
|
+
exports.fileTargets = fileTargets;
|
|
16
|
+
exports.parseGitRemote = parseGitRemote;
|
|
17
|
+
exports.readGitRemote = readGitRemote;
|
|
18
|
+
/*
|
|
19
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
20
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
21
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
22
|
+
*
|
|
23
|
+
* OpenCRVS is also distributed under the terms of the Civil Registration
|
|
24
|
+
* & Healthcare Disclaimer located at http://opencrvs.org/license.
|
|
25
|
+
*
|
|
26
|
+
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
|
|
27
|
+
*/
|
|
28
|
+
const promises_1 = require("node:fs/promises");
|
|
29
|
+
const node_path_1 = require("node:path");
|
|
30
|
+
// Files read from an environment, relative to its folder. Only these are ever
|
|
31
|
+
// returned, so the API cannot be used to read anything else on disk.
|
|
32
|
+
// `values.override.yaml` files belong to the user and are deliberately left out.
|
|
33
|
+
exports.ENVIRONMENT_FILES = ['inventory.yml', 'dependencies/values.yaml', 'traefik/values.yaml', 'opencrvs-services/values.yaml'];
|
|
34
|
+
const INVENTORY = exports.ENVIRONMENT_FILES[0];
|
|
35
|
+
const YAML_FILE = /\.ya?ml$/;
|
|
36
|
+
exports.SAFE_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
37
|
+
// Subfolders win; if there are none, the names of *.yaml / *.yml files are used.
|
|
38
|
+
function listEnvironmentNames(dir) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
let entries;
|
|
41
|
+
try {
|
|
42
|
+
entries = yield (0, promises_1.readdir)(dir, { withFileTypes: true });
|
|
43
|
+
}
|
|
44
|
+
catch (_a) {
|
|
45
|
+
return { names: [], layout: 'none' };
|
|
46
|
+
}
|
|
47
|
+
const folders = entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith('.'));
|
|
48
|
+
if (folders.length > 0) {
|
|
49
|
+
return { names: folders.map((entry) => entry.name).sort(), layout: 'folders' };
|
|
50
|
+
}
|
|
51
|
+
const files = entries.filter((entry) => entry.isFile() && YAML_FILE.test(entry.name));
|
|
52
|
+
if (files.length > 0) {
|
|
53
|
+
return { names: files.map((entry) => entry.name.replace(YAML_FILE, '')).sort(), layout: 'files' };
|
|
54
|
+
}
|
|
55
|
+
return { names: [], layout: 'none' };
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function readIfPresent(path) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
try {
|
|
61
|
+
return yield (0, promises_1.readFile)(path, 'utf8');
|
|
62
|
+
}
|
|
63
|
+
catch (_a) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
// Returns the known files that exist for an environment, keyed by their path
|
|
69
|
+
// inside the environment folder. Unknown names return undefined. In the flat layout the one
|
|
70
|
+
// file is returned under `flatFile` (the rendered file it holds, `flat:` in bindings.yml).
|
|
71
|
+
function readEnvironmentFiles(dir_1, name_1) {
|
|
72
|
+
return __awaiter(this, arguments, void 0, function* (dir, name, flatFile = INVENTORY) {
|
|
73
|
+
if (!exports.SAFE_NAME.test(name))
|
|
74
|
+
return undefined;
|
|
75
|
+
const { names, layout } = yield listEnvironmentNames(dir);
|
|
76
|
+
if (!names.includes(name))
|
|
77
|
+
return undefined;
|
|
78
|
+
const files = {};
|
|
79
|
+
if (layout === 'files') {
|
|
80
|
+
// .yml first, so that .yaml wins if both exist.
|
|
81
|
+
for (const extension of ['.yml', '.yaml']) {
|
|
82
|
+
const text = yield readIfPresent((0, node_path_1.join)(dir, `${name}${extension}`));
|
|
83
|
+
if (text !== undefined)
|
|
84
|
+
files[flatFile] = text;
|
|
85
|
+
}
|
|
86
|
+
return files;
|
|
87
|
+
}
|
|
88
|
+
for (const file of exports.ENVIRONMENT_FILES) {
|
|
89
|
+
const text = yield readIfPresent((0, node_path_1.join)(dir, name, file));
|
|
90
|
+
if (text !== undefined)
|
|
91
|
+
files[file] = text;
|
|
92
|
+
}
|
|
93
|
+
return files;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
// Where each rendered file goes for an environment, relative to environments/. A file with no
|
|
97
|
+
// place in the layout is null: in the flat layout only `flatFile` has one. An environment that
|
|
98
|
+
// does not exist yet is created in the tree layout, unless the folder already holds flat files.
|
|
99
|
+
function fileTargets(dir_1, name_1) {
|
|
100
|
+
return __awaiter(this, arguments, void 0, function* (dir, name, flatFile = INVENTORY) {
|
|
101
|
+
const { layout } = yield listEnvironmentNames(dir);
|
|
102
|
+
const targets = {};
|
|
103
|
+
if (layout === 'files') {
|
|
104
|
+
// Keep the extension the environment already has; .yaml wins if both exist (as when reading).
|
|
105
|
+
const hasYaml = (yield readIfPresent((0, node_path_1.join)(dir, `${name}.yaml`))) !== undefined;
|
|
106
|
+
const hasYml = (yield readIfPresent((0, node_path_1.join)(dir, `${name}.yml`))) !== undefined;
|
|
107
|
+
const extension = hasYml && !hasYaml ? '.yml' : '.yaml';
|
|
108
|
+
for (const path of exports.ENVIRONMENT_FILES)
|
|
109
|
+
targets[path] = path === flatFile ? `${name}${extension}` : null;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
for (const path of exports.ENVIRONMENT_FILES)
|
|
113
|
+
targets[path] = `${name}/${path}`;
|
|
114
|
+
}
|
|
115
|
+
return { layout, targets };
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
// Accepts git@github.com:owner/repo.git and https://github.com/owner/repo(.git)
|
|
119
|
+
function parseGitRemote(url) {
|
|
120
|
+
const match = url.trim().match(/github\.com[:/]([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/);
|
|
121
|
+
return match ? { owner: match[1], repo: match[2] } : null;
|
|
122
|
+
}
|
|
123
|
+
// Reads the url of remote "origin" from .git/config, without running git (which can refuse to
|
|
124
|
+
// work in a mounted folder owned by another user, as in a container).
|
|
125
|
+
function readGitRemote(cwd) {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
const config = yield readIfPresent((0, node_path_1.join)(cwd, '.git', 'config'));
|
|
128
|
+
if (config === undefined)
|
|
129
|
+
return undefined;
|
|
130
|
+
let inOrigin = false;
|
|
131
|
+
for (const line of config.split(/\r?\n/)) {
|
|
132
|
+
const section = line.match(/^\s*\[(.*)\]\s*$/);
|
|
133
|
+
if (section) {
|
|
134
|
+
inOrigin = /^remote\s+"origin"$/.test(section[1].trim());
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
const url = inOrigin ? line.match(/^\s*url\s*=\s*(.+?)\s*$/) : null;
|
|
138
|
+
if (url)
|
|
139
|
+
return url[1];
|
|
140
|
+
}
|
|
141
|
+
return undefined;
|
|
142
|
+
});
|
|
143
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Bindings } from '../ui/bindings/bindings.ts';
|
|
2
|
+
interface RenderInput {
|
|
3
|
+
environment: string;
|
|
4
|
+
values: Record<string, unknown>;
|
|
5
|
+
bindings: Bindings;
|
|
6
|
+
readTemplate: (path: string) => string;
|
|
7
|
+
}
|
|
8
|
+
export declare function renderEnvironmentFiles({ environment, values, bindings, readTemplate }: RenderInput): Record<string, string>;
|
|
9
|
+
export declare function writeEnvironmentFiles(dir: string, environment: string, files: Record<string, string>, flatFile?: string): Promise<string[]>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/configurator/server/files.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAI1D,UAAU,WAAW;IACnB,WAAW,EAAE,MAAM,CAAA;IAEnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,QAAQ,EAAE,QAAQ,CAAA;IAElB,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;CACvC;AAID,wBAAgB,sBAAsB,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQ3H;AAMD,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7B,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,EAAE,CAAC,CAenB"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.renderEnvironmentFiles = renderEnvironmentFiles;
|
|
16
|
+
exports.writeEnvironmentFiles = writeEnvironmentFiles;
|
|
17
|
+
/*
|
|
18
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
19
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
20
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
21
|
+
*
|
|
22
|
+
* OpenCRVS is also distributed under the terms of the Civil Registration
|
|
23
|
+
* & Healthcare Disclaimer located at http://opencrvs.org/license.
|
|
24
|
+
*
|
|
25
|
+
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
|
|
26
|
+
*/
|
|
27
|
+
const handlebars_1 = __importDefault(require("handlebars"));
|
|
28
|
+
const promises_1 = require("node:fs/promises");
|
|
29
|
+
const node_path_1 = require("node:path");
|
|
30
|
+
const templateValues_ts_1 = require("../ui/plan/templateValues.js");
|
|
31
|
+
const environments_ts_1 = require("./environments.js");
|
|
32
|
+
// Renders every template listed under `files:` in bindings.yml, the way the CLI does
|
|
33
|
+
// (same Handlebars, same worker label helper). Returns the files by their path inside the environment folder.
|
|
34
|
+
function renderEnvironmentFiles({ environment, values, bindings, readTemplate }) {
|
|
35
|
+
const files = {};
|
|
36
|
+
for (const [template, output] of Object.entries(bindings.files)) {
|
|
37
|
+
const handlebars = handlebars_1.default.create();
|
|
38
|
+
handlebars.registerHelper('data_label_idx', (value) => Number.parseInt(String(value), 10) + 2);
|
|
39
|
+
files[output] = handlebars.compile(readTemplate(template))((0, templateValues_ts_1.templateValues)(template, environment, values, bindings));
|
|
40
|
+
}
|
|
41
|
+
return files;
|
|
42
|
+
}
|
|
43
|
+
// Writes rendered files where the layout puts them (see fileTargets): environments/<name>/<path> in
|
|
44
|
+
// the tree layout, the one file environments/<name>.yaml in the flat layout. Only the known paths
|
|
45
|
+
// are accepted, so this can never be used to write anything else, and values.override.yaml is
|
|
46
|
+
// never touched. Returns the places written, relative to environments/.
|
|
47
|
+
function writeEnvironmentFiles(dir, environment, files, flatFile) {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
if (!environments_ts_1.SAFE_NAME.test(environment))
|
|
50
|
+
throw new Error('Invalid environment name.');
|
|
51
|
+
for (const path of Object.keys(files)) {
|
|
52
|
+
if (!environments_ts_1.ENVIRONMENT_FILES.includes(path))
|
|
53
|
+
throw new Error(`Refusing to write ${path}.`);
|
|
54
|
+
}
|
|
55
|
+
const { targets } = yield (0, environments_ts_1.fileTargets)(dir, environment, flatFile);
|
|
56
|
+
const written = [];
|
|
57
|
+
for (const [path, text] of Object.entries(files)) {
|
|
58
|
+
const target = targets[path];
|
|
59
|
+
if (target === null || target === undefined)
|
|
60
|
+
continue; // no place for it in this layout
|
|
61
|
+
yield (0, promises_1.mkdir)((0, node_path_1.dirname)((0, node_path_1.join)(dir, target)), { recursive: true });
|
|
62
|
+
yield (0, promises_1.writeFile)((0, node_path_1.join)(dir, target), text);
|
|
63
|
+
written.push(target);
|
|
64
|
+
}
|
|
65
|
+
return written;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
interface ScopeState {
|
|
2
|
+
variables: Record<string, string>;
|
|
3
|
+
secretNames: string[];
|
|
4
|
+
}
|
|
5
|
+
export type ConnectResult = {
|
|
6
|
+
ok: true;
|
|
7
|
+
login: string;
|
|
8
|
+
missingPermissions: string[];
|
|
9
|
+
} | {
|
|
10
|
+
ok: false;
|
|
11
|
+
error: string;
|
|
12
|
+
};
|
|
13
|
+
export interface WriteTarget {
|
|
14
|
+
scope: 'environment' | 'repository';
|
|
15
|
+
environment?: string;
|
|
16
|
+
name: string;
|
|
17
|
+
value: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class GitHubError extends Error {
|
|
20
|
+
status: number | undefined;
|
|
21
|
+
constructor(message: string, status?: number);
|
|
22
|
+
}
|
|
23
|
+
interface GitHubOptions {
|
|
24
|
+
token: string;
|
|
25
|
+
owner: string;
|
|
26
|
+
repo: string;
|
|
27
|
+
baseUrl?: string;
|
|
28
|
+
fetch?: typeof fetch;
|
|
29
|
+
}
|
|
30
|
+
export declare class GitHubClient {
|
|
31
|
+
readonly owner: string;
|
|
32
|
+
readonly repo: string;
|
|
33
|
+
private readonly token;
|
|
34
|
+
private readonly baseUrl;
|
|
35
|
+
private readonly fetchImpl;
|
|
36
|
+
constructor(options: GitHubOptions);
|
|
37
|
+
private repoPath;
|
|
38
|
+
private request;
|
|
39
|
+
private get;
|
|
40
|
+
private url;
|
|
41
|
+
private paginate;
|
|
42
|
+
connect(): Promise<ConnectResult>;
|
|
43
|
+
listEnvironments(): Promise<string[]>;
|
|
44
|
+
private readScope;
|
|
45
|
+
readRepository(): Promise<ScopeState>;
|
|
46
|
+
readEnvironment(name: string): Promise<ScopeState>;
|
|
47
|
+
private scopeBase;
|
|
48
|
+
createEnvironment(name: string): Promise<void>;
|
|
49
|
+
private inEnvironment;
|
|
50
|
+
putVariable(target: WriteTarget, exists?: boolean): Promise<void>;
|
|
51
|
+
putSecret(target: WriteTarget): Promise<void>;
|
|
52
|
+
private putVariableUnchecked;
|
|
53
|
+
private putSecretUnchecked;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=github.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../../src/configurator/server/github.ts"],"names":[],"mappings":"AAcA,UAAU,UAAU;IAClB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,WAAW,EAAE,MAAM,EAAE,CAAA;CACtB;AAED,MAAM,MAAM,aAAa,GACrB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,MAAM,EAAE,CAAA;CAAE,GACzD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAEhC,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,aAAa,GAAG,YAAY,CAAA;IAEnC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd;AAED,qBAAa,WAAY,SAAQ,KAAK;IACpC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,YAAY,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAG3C;CACF;AAED,UAAU,aAAa;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IAEZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;CACrB;AAOD,qBAAa,YAAY;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAK;IAC7B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAc;IAExC,YAAY,OAAO,EAAE,aAAa,EAMjC;IAED,OAAO,CAAC,QAAQ;YAKF,OAAO;IAsCrB,OAAO,CAAC,GAAG;IAIX,OAAO,CAAC,GAAG;YAKG,QAAQ;IAiBhB,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC,CAoBtC;IAEK,gBAAgB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAG1C;YAEa,SAAS;IAYvB,cAAc,IAAI,OAAO,CAAC,UAAU,CAAC,CAEpC;IAEK,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAQvD;IAID,OAAO,CAAC,SAAS;IAOX,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnD;YAIa,aAAa;IAW3B,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhE;IAED,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5C;YAGa,oBAAoB;YAepB,kBAAkB;CASjC"}
|
|
@@ -0,0 +1,239 @@
|
|
|
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
|
+
// GitHub REST client used by the dev server. The page never talks to GitHub: it asks the dev
|
|
13
|
+
// server, which holds the token in memory and makes these calls. It reads environments, variables
|
|
14
|
+
// and secret names, and writes environments, variables and (encrypted) secrets.
|
|
15
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
16
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
17
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
18
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
19
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
20
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
21
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.GitHubClient = exports.GitHubError = void 0;
|
|
26
|
+
class GitHubError extends Error {
|
|
27
|
+
constructor(message, status) {
|
|
28
|
+
super(message);
|
|
29
|
+
this.status = status;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.GitHubError = GitHubError;
|
|
33
|
+
const seal_ts_1 = require("./seal.js");
|
|
34
|
+
const API_VERSION = '2022-11-28';
|
|
35
|
+
const PER_PAGE = 100;
|
|
36
|
+
class GitHubClient {
|
|
37
|
+
constructor(options) {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
this.owner = options.owner;
|
|
40
|
+
this.repo = options.repo;
|
|
41
|
+
this.token = options.token;
|
|
42
|
+
this.baseUrl = new URL((_a = options.baseUrl) !== null && _a !== void 0 ? _a : 'https://api.github.com');
|
|
43
|
+
this.fetchImpl = (_b = options.fetch) !== null && _b !== void 0 ? _b : fetch;
|
|
44
|
+
}
|
|
45
|
+
repoPath(suffix = '') {
|
|
46
|
+
return `/repos/${encodeURIComponent(this.owner)}/${encodeURIComponent(this.repo)}${suffix}`;
|
|
47
|
+
}
|
|
48
|
+
// Messages never contain the token, a value that was sent, or anything GitHub sent back.
|
|
49
|
+
request(method, url, body) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
let response;
|
|
52
|
+
try {
|
|
53
|
+
response = yield this.fetchImpl(url, {
|
|
54
|
+
method,
|
|
55
|
+
headers: Object.assign({ Authorization: `Bearer ${this.token}`, Accept: 'application/vnd.github+json', 'X-GitHub-Api-Version': API_VERSION, 'User-Agent': 'env-init-ui' }, (body === undefined ? {} : { 'Content-Type': 'application/json' })),
|
|
56
|
+
body: body === undefined ? undefined : JSON.stringify(body)
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
catch (_a) {
|
|
60
|
+
throw new GitHubError('Could not reach GitHub.');
|
|
61
|
+
}
|
|
62
|
+
if (response.ok)
|
|
63
|
+
return response;
|
|
64
|
+
if (response.status === 401)
|
|
65
|
+
throw new GitHubError('GitHub rejected the token (bad credentials).', 401);
|
|
66
|
+
if (response.status === 403 && response.headers.get('x-ratelimit-remaining') === '0') {
|
|
67
|
+
throw new GitHubError('GitHub rate limit reached. Try again later.', 403);
|
|
68
|
+
}
|
|
69
|
+
if (response.status === 403) {
|
|
70
|
+
throw new GitHubError(method === 'GET'
|
|
71
|
+
? 'The token is not allowed to read this (HTTP 403).'
|
|
72
|
+
: 'The token is not allowed to change this (HTTP 403). Writing needs access to the repository, and creating environments needs admin access.', 403);
|
|
73
|
+
}
|
|
74
|
+
if (response.status === 404) {
|
|
75
|
+
throw new GitHubError(`Not found: ${this.owner}/${this.repo}, or the token cannot see it.`, 404);
|
|
76
|
+
}
|
|
77
|
+
if (response.status === 409)
|
|
78
|
+
throw new GitHubError('GitHub reports a conflict (HTTP 409).', 409);
|
|
79
|
+
if (response.status === 422)
|
|
80
|
+
throw new GitHubError('GitHub refused the request (HTTP 422).', 422);
|
|
81
|
+
throw new GitHubError(`GitHub answered with HTTP ${response.status}.`, response.status);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
get(url) {
|
|
85
|
+
return this.request('GET', url);
|
|
86
|
+
}
|
|
87
|
+
url(path) {
|
|
88
|
+
return new URL(path, this.baseUrl);
|
|
89
|
+
}
|
|
90
|
+
// Follows rel="next" links, but only ones on the same host: the token must never be sent elsewhere.
|
|
91
|
+
paginate(path, pick) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
var _a;
|
|
94
|
+
var _b;
|
|
95
|
+
const items = [];
|
|
96
|
+
let next = this.url(path);
|
|
97
|
+
next.searchParams.set('per_page', String(PER_PAGE));
|
|
98
|
+
for (let page = 0; next && page < 100; page++) {
|
|
99
|
+
const response = yield this.get(next);
|
|
100
|
+
items.push(...pick(yield response.json()));
|
|
101
|
+
const link = (_b = response.headers.get('link')) !== null && _b !== void 0 ? _b : '';
|
|
102
|
+
const target = (_a = link.match(/<([^>]+)>;\s*rel="next"/)) === null || _a === void 0 ? void 0 : _a[1];
|
|
103
|
+
const candidate = target ? new URL(target, this.baseUrl) : undefined;
|
|
104
|
+
next = candidate && candidate.origin === this.baseUrl.origin ? candidate : undefined;
|
|
105
|
+
}
|
|
106
|
+
return items;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
// Checks the token and what it can do. Classic tokens report their scopes in a header;
|
|
110
|
+
// fine-grained tokens do not, so for those only the repository permissions can be checked.
|
|
111
|
+
connect() {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
var _a, _b;
|
|
114
|
+
try {
|
|
115
|
+
const user = yield this.get(this.url('/user'));
|
|
116
|
+
const scopesHeader = user.headers.get('x-oauth-scopes');
|
|
117
|
+
const login = String((_a = (yield user.json()).login) !== null && _a !== void 0 ? _a : this.owner);
|
|
118
|
+
const repository = yield this.get(this.url(this.repoPath()));
|
|
119
|
+
const permissions = (_b = (yield repository.json()).permissions) !== null && _b !== void 0 ? _b : {};
|
|
120
|
+
const missing = [];
|
|
121
|
+
if (scopesHeader !== null) {
|
|
122
|
+
const scopes = scopesHeader.split(',').map((scope) => scope.trim());
|
|
123
|
+
if (!scopes.includes('repo'))
|
|
124
|
+
missing.push('manage environments, secrets and variables or trigger workflows (classic token scope "repo")');
|
|
125
|
+
if (!scopes.includes('workflow'))
|
|
126
|
+
missing.push('update workflow files (classic token scope "workflow")');
|
|
127
|
+
}
|
|
128
|
+
if (!permissions.admin)
|
|
129
|
+
missing.push('create environments (needs admin access to the repository)');
|
|
130
|
+
return { ok: true, login, missingPermissions: missing };
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
return { ok: false, error: error instanceof GitHubError ? error.message : 'Could not reach GitHub.' };
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
listEnvironments() {
|
|
138
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
+
const environments = yield this.paginate(this.repoPath('/environments'), (body) => { var _a; return (_a = body.environments) !== null && _a !== void 0 ? _a : []; });
|
|
140
|
+
return environments.map((environment) => environment.name);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
readScope(base) {
|
|
144
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
const [variables, secrets] = yield Promise.all([
|
|
146
|
+
this.paginate(`${base}/variables`, (body) => { var _a; return (_a = body.variables) !== null && _a !== void 0 ? _a : []; }),
|
|
147
|
+
this.paginate(`${base}/secrets`, (body) => { var _a; return (_a = body.secrets) !== null && _a !== void 0 ? _a : []; })
|
|
148
|
+
]);
|
|
149
|
+
return {
|
|
150
|
+
variables: Object.fromEntries(variables.map((variable) => [variable.name, variable.value])),
|
|
151
|
+
// GitHub returns names (and dates) for secrets, never values.
|
|
152
|
+
secretNames: secrets.map((secret) => secret.name)
|
|
153
|
+
};
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
readRepository() {
|
|
157
|
+
return this.readScope(this.repoPath('/actions'));
|
|
158
|
+
}
|
|
159
|
+
readEnvironment(name) {
|
|
160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
try {
|
|
162
|
+
return yield this.readScope(this.repoPath(`/environments/${encodeURIComponent(name)}`));
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
// An environment that does not exist simply has nothing in it.
|
|
166
|
+
if (error instanceof GitHubError && error.status === 404)
|
|
167
|
+
return { variables: {}, secretNames: [] };
|
|
168
|
+
throw error;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
// --- writing ---------------------------------------------------------------------------
|
|
173
|
+
scopeBase(target) {
|
|
174
|
+
var _a;
|
|
175
|
+
return target.scope === 'environment'
|
|
176
|
+
? this.repoPath(`/environments/${encodeURIComponent((_a = target.environment) !== null && _a !== void 0 ? _a : '')}`)
|
|
177
|
+
: this.repoPath('/actions');
|
|
178
|
+
}
|
|
179
|
+
// Creates the environment, or leaves it as it is if it exists.
|
|
180
|
+
createEnvironment(name) {
|
|
181
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
yield this.request('PUT', this.url(this.repoPath(`/environments/${encodeURIComponent(name)}`)), {});
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
// A 404 on an environment's variables or secrets means the environment is missing,
|
|
186
|
+
// not that the repository is: say so.
|
|
187
|
+
inEnvironment(target, action) {
|
|
188
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
189
|
+
try {
|
|
190
|
+
yield action();
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
if (error instanceof GitHubError && error.status === 404 && target.scope === 'environment') {
|
|
194
|
+
throw new GitHubError(`The environment “${target.environment}” does not exist yet.`, 404);
|
|
195
|
+
}
|
|
196
|
+
throw error;
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
putVariable(target, exists) {
|
|
201
|
+
return this.inEnvironment(target, () => this.putVariableUnchecked(target, exists));
|
|
202
|
+
}
|
|
203
|
+
putSecret(target) {
|
|
204
|
+
return this.inEnvironment(target, () => this.putSecretUnchecked(target));
|
|
205
|
+
}
|
|
206
|
+
// `exists` is what the plan found out; if it was wrong, the other call is tried.
|
|
207
|
+
putVariableUnchecked(target, exists) {
|
|
208
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
209
|
+
const base = `${this.scopeBase(target)}/variables`;
|
|
210
|
+
const create = () => this.request('POST', this.url(base), { name: target.name, value: target.value });
|
|
211
|
+
const update = () => this.request('PATCH', this.url(`${base}/${encodeURIComponent(target.name)}`), { name: target.name, value: target.value });
|
|
212
|
+
try {
|
|
213
|
+
yield (exists ? update() : create());
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
if (!(error instanceof GitHubError))
|
|
217
|
+
throw error;
|
|
218
|
+
if (!exists && error.status === 409)
|
|
219
|
+
yield update();
|
|
220
|
+
else if (exists && error.status === 404)
|
|
221
|
+
yield create();
|
|
222
|
+
else
|
|
223
|
+
throw error;
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
putSecretUnchecked(target) {
|
|
228
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
229
|
+
const base = `${this.scopeBase(target)}/secrets`;
|
|
230
|
+
const key = (yield (yield this.get(this.url(`${base}/public-key`))).json());
|
|
231
|
+
const encrypted = yield (0, seal_ts_1.sealSecret)(key.key, target.value);
|
|
232
|
+
yield this.request('PUT', this.url(`${base}/${encodeURIComponent(target.name)}`), {
|
|
233
|
+
encrypted_value: encrypted,
|
|
234
|
+
key_id: key.key_id
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
exports.GitHubClient = GitHubClient;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import type { Bindings } from '../ui/bindings/bindings.ts';
|
|
3
|
+
import { GitHubClient, type ConnectResult } from './github.ts';
|
|
4
|
+
export declare class GitHubSession {
|
|
5
|
+
private client;
|
|
6
|
+
private readonly baseUrl;
|
|
7
|
+
private readonly fetchImpl;
|
|
8
|
+
constructor(options?: {
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
fetch?: typeof fetch;
|
|
11
|
+
});
|
|
12
|
+
connect(token: string, owner: string, repo: string): Promise<ConnectResult>;
|
|
13
|
+
disconnect(): void;
|
|
14
|
+
get current(): GitHubClient | undefined;
|
|
15
|
+
}
|
|
16
|
+
interface ApiOptions {
|
|
17
|
+
environmentsDir: string;
|
|
18
|
+
projectDir: string;
|
|
19
|
+
github: GitHubSession;
|
|
20
|
+
files?: {
|
|
21
|
+
bindings: Bindings;
|
|
22
|
+
templatesDir: string;
|
|
23
|
+
};
|
|
24
|
+
gitRemote?: () => Promise<string | undefined>;
|
|
25
|
+
}
|
|
26
|
+
export interface ApiRequest {
|
|
27
|
+
method?: string;
|
|
28
|
+
body?: unknown;
|
|
29
|
+
host?: string;
|
|
30
|
+
origin?: string;
|
|
31
|
+
}
|
|
32
|
+
interface ApiResult {
|
|
33
|
+
status: number;
|
|
34
|
+
body: unknown;
|
|
35
|
+
}
|
|
36
|
+
export declare function handleApiRequest(path: string, options: ApiOptions, request?: ApiRequest): Promise<ApiResult | null>;
|
|
37
|
+
export declare function middleware(options: ApiOptions): (request: IncomingMessage, response: ServerResponse, next: () => void) => Promise<void>;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/configurator/server/plugin.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAGhE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAG1D,OAAO,EAAE,YAAY,EAAe,KAAK,aAAa,EAAoB,MAAM,aAAa,CAAA;AAK7F,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAC5C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA0B;IAEpD,YAAY,OAAO,GAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;KAAO,EAGnE;IAEK,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAKhF;IAED,UAAU,SAET;IAED,IAAI,OAAO,6BAEV;CACF;AAED,UAAU,UAAU;IAElB,eAAe,EAAE,MAAM,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,aAAa,CAAA;IAErB,KAAK,CAAC,EAAE;QAAE,QAAQ,EAAE,QAAQ,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAA;IAEpD,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;CAC9C;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,OAAO,CAAA;IAEd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,UAAU,SAAS;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,OAAO,CAAA;CACd;AAgJD,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,UAAU,EACnB,OAAO,GAAE,UAAe,GACvB,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CA+B3B;AAaD,wBAAgB,UAAU,CAAC,OAAO,EAAE,UAAU,aACrB,eAAe,YAAY,cAAc,QAAQ,MAAM,IAAI,mBA6BnF"}
|