@toa.io/pointer 0.20.0-dev.22 → 0.20.0-dev.23
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 +6 -6
- package/transpiled/Deployment.d.ts +15 -0
- package/transpiled/Deployment.js +40 -0
- package/transpiled/Deployment.js.map +1 -0
- package/transpiled/annotation.d.ts +3 -0
- package/transpiled/annotation.js +62 -0
- package/transpiled/annotation.js.map +1 -0
- package/transpiled/createDeployment.d.ts +4 -0
- package/transpiled/createDeployment.js +12 -0
- package/transpiled/createDeployment.js.map +1 -0
- package/transpiled/env.d.ts +1 -0
- package/transpiled/env.js +10 -0
- package/transpiled/env.js.map +1 -0
- package/transpiled/index.d.ts +3 -0
- package/transpiled/index.js +6 -0
- package/transpiled/index.js.map +1 -0
- package/transpiled/tsconfig.tsbuildinfo +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/pointer",
|
|
3
|
-
"version": "0.20.0-dev.
|
|
3
|
+
"version": "0.20.0-dev.23",
|
|
4
4
|
"description": "Toa Pointer",
|
|
5
5
|
"homepage": "https://toa.io",
|
|
6
6
|
"author": {
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"main": "source/index.js",
|
|
25
25
|
"types": "types/index.d.ts",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@toa.io/console": "0.20.0-dev.
|
|
28
|
-
"@toa.io/generic": "0.20.0-dev.
|
|
29
|
-
"@toa.io/schemas": "0.20.0-dev.
|
|
30
|
-
"@toa.io/yaml": "0.20.0-dev.
|
|
27
|
+
"@toa.io/console": "0.20.0-dev.23",
|
|
28
|
+
"@toa.io/generic": "0.20.0-dev.23",
|
|
29
|
+
"@toa.io/schemas": "0.20.0-dev.23",
|
|
30
|
+
"@toa.io/yaml": "0.20.0-dev.23"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "594d7a02c777e0c39252ff3dd1beddd069d8081d"
|
|
33
33
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Dependency } 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[]): Dependency;
|
|
7
|
+
private createVariables;
|
|
8
|
+
private createVariable;
|
|
9
|
+
private resolve;
|
|
10
|
+
}
|
|
11
|
+
export interface Request {
|
|
12
|
+
label: string;
|
|
13
|
+
selectors: string[];
|
|
14
|
+
}
|
|
15
|
+
export type URIMap = Record<string, string[]>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Deployment = void 0;
|
|
4
|
+
const env_1 = require("./env");
|
|
5
|
+
class Deployment {
|
|
6
|
+
id;
|
|
7
|
+
annotation;
|
|
8
|
+
constructor(id, annotation) {
|
|
9
|
+
this.id = id;
|
|
10
|
+
this.annotation = annotation;
|
|
11
|
+
}
|
|
12
|
+
export(requests) {
|
|
13
|
+
const variables = {};
|
|
14
|
+
for (const request of requests)
|
|
15
|
+
variables[request.label] = this.createVariables(request.selectors);
|
|
16
|
+
return { variables };
|
|
17
|
+
}
|
|
18
|
+
createVariables(selectors) {
|
|
19
|
+
return selectors.map(this.createVariable.bind(this));
|
|
20
|
+
}
|
|
21
|
+
createVariable(selector) {
|
|
22
|
+
const name = (0, env_1.nameVariable)('TOA', this.id, selector);
|
|
23
|
+
const values = this.resolve(selector);
|
|
24
|
+
const value = values.join(' ');
|
|
25
|
+
return { name, value };
|
|
26
|
+
}
|
|
27
|
+
resolve(selector) {
|
|
28
|
+
if (selector in this.annotation)
|
|
29
|
+
return this.annotation[selector];
|
|
30
|
+
const segments = selector.split('.');
|
|
31
|
+
while (segments.pop() !== undefined) {
|
|
32
|
+
const current = segments.join('.');
|
|
33
|
+
if (current in this.annotation)
|
|
34
|
+
return this.annotation[current];
|
|
35
|
+
}
|
|
36
|
+
return this.annotation['.'];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.Deployment = Deployment;
|
|
40
|
+
//# sourceMappingURL=Deployment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Deployment.js","sourceRoot":"","sources":["../source/Deployment.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AAGpC,MAAa,UAAU;IACJ,EAAE,CAAQ;IACV,UAAU,CAAQ;IAEnC,YAAoB,EAAU,EAAE,UAAkB;QAChD,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;IAEM,MAAM,CAAE,QAAmB;QAChC,MAAM,SAAS,GAAc,EAAE,CAAA;QAE/B,KAAK,MAAM,OAAO,IAAI,QAAQ;YAC5B,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QAEpE,OAAO,EAAE,SAAS,EAAE,CAAA;IACtB,CAAC;IAEO,eAAe,CAAE,SAAmB;QAC1C,OAAO,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IACtD,CAAC;IAEO,cAAc,CAAE,QAAgB;QACtC,MAAM,IAAI,GAAG,IAAA,kBAAY,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA;QACnD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QACrC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAE9B,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;IACxB,CAAC;IAEO,OAAO,CAAE,QAAgB;QAC/B,IAAI,QAAQ,IAAI,IAAI,CAAC,UAAU;YAAE,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;QAEjE,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAEpC,OAAO,QAAQ,CAAC,GAAG,EAAE,KAAK,SAAS,EAAE;YACnC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YAElC,IAAI,OAAO,IAAI,IAAI,CAAC,UAAU;gBAAE,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;SAChE;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IAC7B,CAAC;CACF;AA3CD,gCA2CC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
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 (typeof declaration === 'string' || Array.isArray(declaration))
|
|
33
|
+
declaration = { '.': declaration };
|
|
34
|
+
for (const [key, value] of Object.entries(declaration))
|
|
35
|
+
if (typeof value === 'string')
|
|
36
|
+
map[key] = format([value]);
|
|
37
|
+
else
|
|
38
|
+
map[key] = format(value);
|
|
39
|
+
validate(map);
|
|
40
|
+
return map;
|
|
41
|
+
}
|
|
42
|
+
exports.normalize = normalize;
|
|
43
|
+
function format(values) {
|
|
44
|
+
return values.map(generic_1.shards)
|
|
45
|
+
.flat()
|
|
46
|
+
.map((value) => (0, generic_1.echo)(value));
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotation.js","sourceRoot":"","sources":["../source/annotation.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AAI,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"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDeployment = void 0;
|
|
4
|
+
const Deployment_1 = require("./Deployment");
|
|
5
|
+
const annotation_1 = require("./annotation");
|
|
6
|
+
function createDeployment(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.createDeployment = createDeployment;
|
|
12
|
+
//# sourceMappingURL=createDeployment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDeployment.js","sourceRoot":"","sources":["../source/createDeployment.ts"],"names":[],"mappings":";;;AAAA,6CAAuD;AACvD,6CAAwC;AAIxC,SAAgB,gBAAgB,CAC/B,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,4CAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function nameVariable(...segments: string[]): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nameVariable = void 0;
|
|
4
|
+
function nameVariable(...segments) {
|
|
5
|
+
return segments.join('_')
|
|
6
|
+
.replaceAll(/[-.]/g, '_')
|
|
7
|
+
.toUpperCase();
|
|
8
|
+
}
|
|
9
|
+
exports.nameVariable = nameVariable;
|
|
10
|
+
//# sourceMappingURL=env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../source/env.ts"],"names":[],"mappings":";;;AAAA,SAAgB,YAAY,CAAE,GAAG,QAAkB;IACjD,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;SACtB,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC;SACxB,WAAW,EAAE,CAAA;AAClB,CAAC;AAJD,oCAIC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDeployment = void 0;
|
|
4
|
+
var createDeployment_1 = require("./createDeployment");
|
|
5
|
+
Object.defineProperty(exports, "createDeployment", { enumerable: true, get: function () { return createDeployment_1.createDeployment; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";;;AAAA,uDAAqD;AAA5C,oHAAA,gBAAgB,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"4.9.5"}
|