@toa.io/pointer 0.20.0-alpha.0 → 0.20.0-alpha.2
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/package.json +5 -5
- package/transpiled/Deployment.d.ts +0 -21
- package/transpiled/Deployment.js +0 -63
- package/transpiled/Deployment.js.map +0 -1
- package/transpiled/annotation.d.ts +0 -3
- package/transpiled/annotation.js +0 -62
- package/transpiled/annotation.js.map +0 -1
- package/transpiled/createVariables.d.ts +0 -4
- package/transpiled/createVariables.js +0 -12
- package/transpiled/createVariables.js.map +0 -1
- package/transpiled/index.d.ts +0 -6
- package/transpiled/index.js +0 -35
- package/transpiled/index.js.map +0 -1
- package/transpiled/naming.d.ts +0 -2
- package/transpiled/naming.js +0 -16
- package/transpiled/naming.js.map +0 -1
- package/transpiled/resolve.d.ts +0 -3
- package/transpiled/resolve.js +0 -54
- package/transpiled/resolve.js.map +0 -1
- package/transpiled/tsconfig.tsbuildinfo +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/pointer",
|
|
3
|
-
"version": "0.20.0-alpha.
|
|
3
|
+
"version": "0.20.0-alpha.2",
|
|
4
4
|
"description": "Toa Pointer",
|
|
5
5
|
"homepage": "https://toa.io",
|
|
6
6
|
"author": {
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"main": "transpiled/index.js",
|
|
25
25
|
"types": "transpiled/index.d.ts",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@toa.io/dns": "0.8.0-alpha.
|
|
28
|
-
"@toa.io/generic": "0.20.0-alpha.
|
|
29
|
-
"@toa.io/schemas": "0.20.0-alpha.
|
|
27
|
+
"@toa.io/dns": "0.8.0-alpha.2",
|
|
28
|
+
"@toa.io/generic": "0.20.0-alpha.2",
|
|
29
|
+
"@toa.io/schemas": "0.20.0-alpha.2"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"transpile": "tsc"
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"preset": "ts-jest",
|
|
36
36
|
"testEnvironment": "node"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "d6e8c5bdae26e2beb66f4d7f37f71a3494fe9fcb"
|
|
39
39
|
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Variables } from '@toa.io/operations';
|
|
2
|
-
export declare class Deployment {
|
|
3
|
-
private readonly id;
|
|
4
|
-
private readonly annotation;
|
|
5
|
-
constructor(id: string, annotation: URIMap);
|
|
6
|
-
export(requests: Request[]): Variables;
|
|
7
|
-
private createVariables;
|
|
8
|
-
private createVariable;
|
|
9
|
-
private createSecrets;
|
|
10
|
-
private resolveRecord;
|
|
11
|
-
private insecure;
|
|
12
|
-
}
|
|
13
|
-
export interface Request {
|
|
14
|
-
group: string;
|
|
15
|
-
selectors: string[];
|
|
16
|
-
}
|
|
17
|
-
export interface AnnotationRecord {
|
|
18
|
-
key: string;
|
|
19
|
-
references: string[];
|
|
20
|
-
}
|
|
21
|
-
export type URIMap = Record<string, string[]>;
|
package/transpiled/Deployment.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Deployment = void 0;
|
|
4
|
-
const naming_1 = require("./naming");
|
|
5
|
-
const resolve_1 = require("./resolve");
|
|
6
|
-
class Deployment {
|
|
7
|
-
id;
|
|
8
|
-
annotation;
|
|
9
|
-
constructor(id, annotation) {
|
|
10
|
-
this.id = id;
|
|
11
|
-
this.annotation = annotation;
|
|
12
|
-
}
|
|
13
|
-
export(requests) {
|
|
14
|
-
const variables = {};
|
|
15
|
-
for (const request of requests)
|
|
16
|
-
variables[request.group] = this.createVariables(request.selectors);
|
|
17
|
-
return variables;
|
|
18
|
-
}
|
|
19
|
-
createVariables(selectors) {
|
|
20
|
-
const variables = [];
|
|
21
|
-
for (const selector of selectors) {
|
|
22
|
-
const variable = this.createVariable(selector);
|
|
23
|
-
const secrets = this.createSecrets(selector);
|
|
24
|
-
variables.push(variable, ...secrets);
|
|
25
|
-
}
|
|
26
|
-
return variables;
|
|
27
|
-
}
|
|
28
|
-
createVariable(selector) {
|
|
29
|
-
const name = (0, naming_1.nameVariable)(this.id, selector);
|
|
30
|
-
const { references } = this.resolveRecord(selector);
|
|
31
|
-
const value = references.join(' ');
|
|
32
|
-
return { name, value };
|
|
33
|
-
}
|
|
34
|
-
createSecrets(selector) {
|
|
35
|
-
const varialbes = [];
|
|
36
|
-
const { key, references } = this.resolveRecord(selector);
|
|
37
|
-
if (this.insecure(references))
|
|
38
|
-
return [];
|
|
39
|
-
for (const token of ['username', 'password']) {
|
|
40
|
-
const varName = (0, naming_1.nameVariable)(this.id, selector, token);
|
|
41
|
-
const secretName = (0, naming_1.nameSecret)(this.id, key);
|
|
42
|
-
varialbes.push({
|
|
43
|
-
name: varName,
|
|
44
|
-
secret: {
|
|
45
|
-
name: secretName,
|
|
46
|
-
key: token
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
return varialbes;
|
|
51
|
-
}
|
|
52
|
-
resolveRecord(selector) {
|
|
53
|
-
return (0, resolve_1.resolveRecord)(this.annotation, selector);
|
|
54
|
-
}
|
|
55
|
-
insecure(references) {
|
|
56
|
-
const reference = references[0];
|
|
57
|
-
const url = new URL(reference);
|
|
58
|
-
return insecureProtocols.includes(url.protocol);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
exports.Deployment = Deployment;
|
|
62
|
-
const insecureProtocols = ['http:', 'https:', 'redis:'];
|
|
63
|
-
//# sourceMappingURL=Deployment.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Deployment.js","sourceRoot":"","sources":["../source/Deployment.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,uCAAyC;AAGzC,MAAa,UAAU;IACJ,E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,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;YAAE,OAAO,EAAE,CAAA;QAExC,KAAK,MAAM,KAAK,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE;YAC5C,MAAM,OAAO,GAAG,IAAA,qBAAY,EAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAA;YACtD,MAAM,UAAU,GAAG,IAAA,mBAAU,EAAC,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAAA;YAE3C,SAAS,CAAC,IAAI,CAAC;gBACb,IAAI,EAAE,OAAO;gBACb,MAAM,EAAE;oBACN,IAAI,EAAE,UAAU;oBAChB,GAAG,EAAE,KAAK;iBACX;aACF,CAAC,CAAA;SACH;QAED,OAAO,SAAS,CAAA;IAClB,CAAC;IAEO,aAAa,CAAE,QAAgB;QACrC,OAAO,IAAA,uBAAa,EAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IACjD,CAAC;IAEO,QAAQ,CAAE,UAAoB;QACpC,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC,CAAA;QAC/B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAA;QAE9B,OAAO,iBAAiB,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IACjD,CAAC;CACF;AAvED,gCAuEC;AAYD,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA"}
|
package/transpiled/annotation.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.normalize = void 0;
|
|
27
|
-
const node_path_1 = require("node:path");
|
|
28
|
-
const schemas = __importStar(require("@toa.io/schemas"));
|
|
29
|
-
const generic_1 = require("@toa.io/generic");
|
|
30
|
-
function normalize(declaration) {
|
|
31
|
-
const map = {};
|
|
32
|
-
if (declaration === undefined)
|
|
33
|
-
return map;
|
|
34
|
-
if (typeof declaration === 'string' || Array.isArray(declaration))
|
|
35
|
-
declaration = { '.': declaration };
|
|
36
|
-
for (const [key, value] of Object.entries(declaration))
|
|
37
|
-
if (typeof value === 'string')
|
|
38
|
-
map[key] = format([value]);
|
|
39
|
-
else
|
|
40
|
-
map[key] = format(value);
|
|
41
|
-
validate(map);
|
|
42
|
-
return map;
|
|
43
|
-
}
|
|
44
|
-
exports.normalize = normalize;
|
|
45
|
-
function format(values) {
|
|
46
|
-
return values.map(generic_1.shards).flat();
|
|
47
|
-
}
|
|
48
|
-
function validate(map) {
|
|
49
|
-
schema.validate(map);
|
|
50
|
-
for (const uris of Object.values(map))
|
|
51
|
-
for (const uri of uris)
|
|
52
|
-
checkCredentials(uri);
|
|
53
|
-
}
|
|
54
|
-
function checkCredentials(uri) {
|
|
55
|
-
const url = new URL(uri);
|
|
56
|
-
if (url.username !== '' || url.password !== '')
|
|
57
|
-
throw new Error(`Pointer URI '${uri}' must not contain credentials. ` +
|
|
58
|
-
'Please refer to the "Credentials" section in the documentation for more information.');
|
|
59
|
-
}
|
|
60
|
-
const path = (0, node_path_1.resolve)(__dirname, '../schemas/urimap.cos.yaml');
|
|
61
|
-
const schema = schemas.schema(path);
|
|
62
|
-
//# sourceMappingURL=annotation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"annotation.js","sourceRoot":"","sources":["../source/annotation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAmC;AACnC,yDAA0C;AAC1C,6CAAwC;AAGxC,SAAgB,SAAS,CAAE,WAAwB;IACjD,MAAM,GAAG,GAAW,EAAE,CAAA;IAEtB,IAAI,WAAW,KAAK,SAAS;QAAE,OAAO,GAAG,CAAA;IAEzC,IAAI,OAAO,WAAW,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC;QAC/D,WAAW,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,CAAA;IAEpC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC;QACpD,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;;YACpD,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IAE/B,QAAQ,CAAC,GAAG,CAAC,CAAA;IAEb,OAAO,GAAG,CAAA;AACZ,CAAC;AAfD,8BAeC;AAED,SAAS,MAAM,CAAE,MAAgB;IAC/B,OAAO,MAAM,CAAC,GAAG,CAAC,gBAAM,CAAC,CAAC,IAAI,EAAE,CAAA;AAClC,CAAC;AAED,SAAS,QAAQ,CAAE,GAAW;IAC5B,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;IAEpB,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;QACnC,KAAK,MAAM,GAAG,IAAI,IAAI;YACpB,gBAAgB,CAAC,GAAG,CAAC,CAAA;AAC3B,CAAC;AAED,SAAS,gBAAgB,CAAE,GAAW;IACpC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAExB,IAAI,GAAG,CAAC,QAAQ,KAAK,EAAE,IAAI,GAAG,CAAC,QAAQ,KAAK,EAAE;QAC5C,MAAM,IAAI,KAAK,CAAC,gBAAgB,GAAG,kCAAkC;YACnE,sFAAsF,CAAC,CAAA;AAC7F,CAAC;AAED,MAAM,IAAI,GAAG,IAAA,mBAAO,EAAC,SAAS,EAAE,4BAA4B,CAAC,CAAA;AAC7D,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createVariables = void 0;
|
|
4
|
-
const Deployment_1 = require("./Deployment");
|
|
5
|
-
const annotation_1 = require("./annotation");
|
|
6
|
-
function createVariables(id, declaration, requests) {
|
|
7
|
-
const annotation = (0, annotation_1.normalize)(declaration);
|
|
8
|
-
const deployment = new Deployment_1.Deployment(id, annotation);
|
|
9
|
-
return deployment.export(requests);
|
|
10
|
-
}
|
|
11
|
-
exports.createVariables = createVariables;
|
|
12
|
-
//# sourceMappingURL=createVariables.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createVariables.js","sourceRoot":"","sources":["../source/createVariables.ts"],"names":[],"mappings":";;;AAAA,6CAAuD;AACvD,6CAAwC;AAIxC,SAAgB,eAAe,CAC9B,EAAU,EAAE,WAAwB,EAAE,QAAmB;IACxD,MAAM,UAAU,GAAG,IAAA,sBAAS,EAAC,WAAW,CAAC,CAAA;IACzC,MAAM,UAAU,GAAG,IAAI,uBAAU,CAAC,EAAE,EAAE,UAAU,CAAC,CAAA;IAEjD,OAAO,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AACpC,CAAC;AAND,0CAMC"}
|
package/transpiled/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { createVariables } from './createVariables';
|
|
2
|
-
export { resolve, resolveRecord } from './resolve';
|
|
3
|
-
export { normalize } from './annotation';
|
|
4
|
-
export * as naming from './naming';
|
|
5
|
-
export type { Declaration } from './annotation';
|
|
6
|
-
export type { Request, URIMap } from './Deployment';
|
package/transpiled/index.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.naming = exports.normalize = exports.resolveRecord = exports.resolve = exports.createVariables = void 0;
|
|
27
|
-
var createVariables_1 = require("./createVariables");
|
|
28
|
-
Object.defineProperty(exports, "createVariables", { enumerable: true, get: function () { return createVariables_1.createVariables; } });
|
|
29
|
-
var resolve_1 = require("./resolve");
|
|
30
|
-
Object.defineProperty(exports, "resolve", { enumerable: true, get: function () { return resolve_1.resolve; } });
|
|
31
|
-
Object.defineProperty(exports, "resolveRecord", { enumerable: true, get: function () { return resolve_1.resolveRecord; } });
|
|
32
|
-
var annotation_1 = require("./annotation");
|
|
33
|
-
Object.defineProperty(exports, "normalize", { enumerable: true, get: function () { return annotation_1.normalize; } });
|
|
34
|
-
exports.naming = __importStar(require("./naming"));
|
|
35
|
-
//# sourceMappingURL=index.js.map
|
package/transpiled/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAmD;AAA1C,kHAAA,eAAe,OAAA;AACxB,qCAAkD;AAAzC,kGAAA,OAAO,OAAA;AAAE,wGAAA,aAAa,OAAA;AAC/B,2CAAwC;AAA/B,uGAAA,SAAS,OAAA;AAClB,mDAAkC"}
|
package/transpiled/naming.d.ts
DELETED
package/transpiled/naming.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.nameSecret = exports.nameVariable = void 0;
|
|
4
|
-
function nameVariable(...segments) {
|
|
5
|
-
return 'TOA_' + segments.join('_')
|
|
6
|
-
.replaceAll(/[-.]/g, '_')
|
|
7
|
-
.toUpperCase();
|
|
8
|
-
}
|
|
9
|
-
exports.nameVariable = nameVariable;
|
|
10
|
-
function nameSecret(...segments) {
|
|
11
|
-
return 'toa-' + segments.join('-')
|
|
12
|
-
.replaceAll('.', '-')
|
|
13
|
-
.replace(/--$/, '.default');
|
|
14
|
-
}
|
|
15
|
-
exports.nameSecret = nameSecret;
|
|
16
|
-
//# sourceMappingURL=naming.js.map
|
package/transpiled/naming.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"naming.js","sourceRoot":"","sources":["../source/naming.ts"],"names":[],"mappings":";;;AAAA,SAAgB,YAAY,CAAE,GAAG,QAAkB;IACjD,OAAO,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;SAC/B,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC;SACxB,WAAW,EAAE,CAAA;AAClB,CAAC;AAJD,oCAIC;AAED,SAAgB,UAAU,CAAE,GAAG,QAAkB;IAC/C,OAAO,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;SAC/B,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;SACpB,OAAO,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;AAC/B,CAAC;AAJD,gCAIC"}
|
package/transpiled/resolve.d.ts
DELETED
package/transpiled/resolve.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveRecord = exports.resolve = void 0;
|
|
4
|
-
const dns_1 = require("@toa.io/dns");
|
|
5
|
-
const naming_1 = require("./naming");
|
|
6
|
-
async function resolve(id, selector) {
|
|
7
|
-
const variable = (0, naming_1.nameVariable)(id, selector);
|
|
8
|
-
const value = process.env[variable];
|
|
9
|
-
if (value === undefined)
|
|
10
|
-
throw new Error(`${variable} is not set.`);
|
|
11
|
-
let urls = value.split(' ');
|
|
12
|
-
const protocol = getProtocol(urls);
|
|
13
|
-
if (protocol !== 'http:')
|
|
14
|
-
urls = await (0, dns_1.dedupe)(urls);
|
|
15
|
-
return withCredentials(variable, urls);
|
|
16
|
-
}
|
|
17
|
-
exports.resolve = resolve;
|
|
18
|
-
function resolveRecord(uris, selector) {
|
|
19
|
-
if (selector in uris)
|
|
20
|
-
return getRecord(uris, selector);
|
|
21
|
-
const segments = selector.split('.');
|
|
22
|
-
while (segments.pop() !== undefined) {
|
|
23
|
-
const current = segments.join('.');
|
|
24
|
-
if (current in uris)
|
|
25
|
-
return getRecord(uris, current);
|
|
26
|
-
}
|
|
27
|
-
if ('.' in uris)
|
|
28
|
-
return getRecord(uris, '.');
|
|
29
|
-
else
|
|
30
|
-
throw new Error(`Selector '${selector}' cannot be resolved.`);
|
|
31
|
-
}
|
|
32
|
-
exports.resolveRecord = resolveRecord;
|
|
33
|
-
function withCredentials(variable, urls) {
|
|
34
|
-
const username = process.env[variable + '_USERNAME'] ?? '';
|
|
35
|
-
const password = process.env[variable + '_PASSWORD'] ?? '';
|
|
36
|
-
return urls.map((url) => addCredentials(url, username, password));
|
|
37
|
-
}
|
|
38
|
-
function addCredentials(ref, username, password) {
|
|
39
|
-
const url = new URL(ref);
|
|
40
|
-
url.username = username;
|
|
41
|
-
url.password = password;
|
|
42
|
-
return url.href;
|
|
43
|
-
}
|
|
44
|
-
function getProtocol(urls) {
|
|
45
|
-
const url = new URL(urls[0]);
|
|
46
|
-
return url.protocol;
|
|
47
|
-
}
|
|
48
|
-
function getRecord(uris, key) {
|
|
49
|
-
return {
|
|
50
|
-
key,
|
|
51
|
-
references: uris[key]
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=resolve.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../source/resolve.ts"],"names":[],"mappings":";;;AAAA,qCAA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