@toa.io/pointer 0.20.0-dev.3 → 0.20.0-dev.30

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toa.io/pointer",
3
- "version": "0.20.0-dev.3",
3
+ "version": "0.20.0-dev.30",
4
4
  "description": "Toa Pointer",
5
5
  "homepage": "https://toa.io",
6
6
  "author": {
@@ -22,11 +22,12 @@
22
22
  "access": "public"
23
23
  },
24
24
  "main": "source/index.js",
25
+ "types": "types/index.d.ts",
25
26
  "dependencies": {
26
- "@toa.io/console": "0.20.0-dev.3",
27
- "@toa.io/generic": "0.20.0-dev.3",
28
- "@toa.io/schemas": "0.20.0-dev.3",
29
- "@toa.io/yaml": "0.20.0-dev.3"
27
+ "@toa.io/console": "0.20.0-dev.30",
28
+ "@toa.io/generic": "0.20.0-dev.30",
29
+ "@toa.io/schemas": "0.20.0-dev.30",
30
+ "@toa.io/yaml": "0.20.0-dev.30"
30
31
  },
31
- "gitHead": "3eabf45761f4cf211e1e4c331933ec60b4a828a7"
32
+ "gitHead": "61c8e74a336385265767e9fd37d49128cb51b17f"
32
33
  }
package/readme.md CHANGED
@@ -103,10 +103,8 @@ amqp:
103
103
  ```
104
104
 
105
105
  ```shell
106
- $ toa conceal bindings-amqp-default username admin
107
- $ toa conceal bindings-amqp-default password ibreakthings
108
- $ toa conceal bindings-amqp-dummies-dummy username developer
109
- $ toa conceal bindings-amqp-dummies-dummy password iluvtests
106
+ $ toa conceal bindings-amqp-default username=admin password=ibreakthings
107
+ $ toa conceal bindings-amqp-dummies-dummy username=developer password=iluvtests
110
108
  ```
111
109
 
112
110
  See [`toa conceal`](../../runtime/cli/readme.md#conceal).
@@ -0,0 +1,15 @@
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 resolve;
10
+ }
11
+ export interface Request {
12
+ group: string;
13
+ selectors: string[];
14
+ }
15
+ export type URIMap = Record<string, string[]>;
@@ -0,0 +1,42 @@
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.group] = this.createVariables(request.selectors);
16
+ return variables;
17
+ }
18
+ createVariables(selectors) {
19
+ return selectors.map((selector) => this.createVariable(selector));
20
+ }
21
+ createVariable(selector) {
22
+ const name = (0, env_1.nameVariable)(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
+ if (this.annotation['.'] === undefined)
37
+ throw new Error(`Selector '${selector}' cannot be resolved.`);
38
+ return this.annotation['.'];
39
+ }
40
+ }
41
+ exports.Deployment = Deployment;
42
+ //# 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,C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AG,CAAC,CAAA;IAC7B,CAAC;CACF;AA9CD,gCA8CC"}
@@ -0,0 +1,15 @@
1
+ import type * as operations from '@toa.io/operations';
2
+ export declare class Variables {
3
+ private readonly id;
4
+ private readonly annotation;
5
+ constructor(id: string, annotation: URIMap);
6
+ export(requests: Request[]): operations.Variables;
7
+ private createVariables;
8
+ private createVariable;
9
+ private resolve;
10
+ }
11
+ export interface Request {
12
+ group: string;
13
+ selectors: string[];
14
+ }
15
+ export type URIMap = Record<string, string[]>;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Variables = void 0;
4
+ const env_1 = require("./env");
5
+ class Variables {
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.group] = this.createVariables(request.selectors);
16
+ return variables;
17
+ }
18
+ createVariables(selectors) {
19
+ return selectors.map((selector) => this.createVariable(selector));
20
+ }
21
+ createVariable(selector) {
22
+ const name = (0, env_1.nameVariable)(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
+ if (this.annotation['.'] === undefined)
37
+ throw new Error(`Selector '${selector}' cannot be resolved.`);
38
+ return this.annotation['.'];
39
+ }
40
+ }
41
+ exports.Variables = Variables;
42
+ //# sourceMappingURL=Variables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Variables.js","sourceRoot":"","sources":["../source/Variables.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AAGpC,MAAa,SAAS;IACH,EAAE,CAAQ;IACV,UAAU,CAAQ;IAEnC,YAAoB,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CAAA;SAChE;QAED,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,SAAS;YACpC,MAAM,IAAI,KAAK,CAAC,aAAa,QAAQ,uBAAuB,CAAC,CAAA;QAE/D,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IAC7B,CAAC;CACF;AA9CD,8BA8CC"}
@@ -0,0 +1,3 @@
1
+ import type { URIMap } from './Deployment';
2
+ export declare function normalize(declaration: Declaration): URIMap;
3
+ export type Declaration = string | string[] | Record<string, string | string[]>;
@@ -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.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAmC;AACnC,yDAA0C;AAC1C,6CAA8C;AAG9C,SAAgB,SAAS,CAAE,WAAwB;IACjD,MAAM,GAAG,GAAW,EAAE,CAAA;IAEtB,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;AAbD,8BAaC;AAED,SAAS,MAAM,CAAE,MAAgB;IAC/B,OAAO,MAAM,CAAC,GAAG,CAAC,gBAAM,CAAC;SACtB,IAAI,EAAE;SACN,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,cAAI,EAAC,KAAK,CAAC,CAAC,CAAA;AAChC,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"}
@@ -0,0 +1,4 @@
1
+ import { type Request } from './Deployment';
2
+ import type { Variables } from '@toa.io/operations';
3
+ import type { Declaration } from './annotation';
4
+ export declare function createVariables(id: string, declaration: Declaration, requests: Request[]): Variables;
@@ -0,0 +1,12 @@
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=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,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"}
@@ -0,0 +1,4 @@
1
+ import { type Request } from './Deployment';
2
+ import type { Variables } from '@toa.io/operations';
3
+ import type { Declaration } from './annotation';
4
+ export declare function createVariables(id: string, declaration: Declaration, requests: Request[]): Variables;
@@ -0,0 +1,12 @@
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
@@ -0,0 +1 @@
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"}
@@ -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 'TOA_' + 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,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;SAC/B,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC;SACxB,WAAW,EAAE,CAAA;AAClB,CAAC;AAJD,oCAIC"}
@@ -0,0 +1,4 @@
1
+ export { createVariables } from './createVariables';
2
+ export { resolve } from './resolve';
3
+ export type { Declaration } from './annotation';
4
+ export type { Request, URIMap } from './Deployment';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolve = exports.createVariables = void 0;
4
+ var createVariables_1 = require("./createVariables");
5
+ Object.defineProperty(exports, "createVariables", { enumerable: true, get: function () { return createVariables_1.createVariables; } });
6
+ var resolve_1 = require("./resolve");
7
+ Object.defineProperty(exports, "resolve", { enumerable: true, get: function () { return resolve_1.resolve; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";;;AAAA,qDAAmD;AAA1C,kHAAA,eAAe,OAAA;AACxB,qCAAmC;AAA1B,kGAAA,OAAO,OAAA"}
@@ -0,0 +1 @@
1
+ export declare function resolve(id: string, selector: string): string[];
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolve = void 0;
4
+ const env_1 = require("./env");
5
+ function resolve(id, selector) {
6
+ const variable = (0, env_1.nameVariable)(id, selector);
7
+ const value = process.env[variable];
8
+ if (value === undefined)
9
+ throw new Error(`${variable} is not set.`);
10
+ const urls = value.split(' ');
11
+ return withCredentials(variable, urls);
12
+ }
13
+ exports.resolve = resolve;
14
+ function withCredentials(variable, urls) {
15
+ const username = process.env[variable + '_USERNAME'] ?? '';
16
+ const password = process.env[variable + '_PASSWORD'] ?? '';
17
+ return urls.map((url) => addCredentials(url, username, password));
18
+ }
19
+ function addCredentials(ref, username, password) {
20
+ const url = new URL(ref);
21
+ url.username = username;
22
+ url.password = password;
23
+ return url.href;
24
+ }
25
+ //# sourceMappingURL=resolve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../source/resolve.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AAEpC,SAAgB,OAAO,CAAE,EAAU,EAAE,QAAgB;IACnD,MAAM,QAAQ,GAAG,IAAA,kBAAY,EAAC,EAAE,EAAE,QAAQ,CAAC,CAAA;IAC3C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IAEnC,IAAI,KAAK,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,cAAc,CAAC,CAAA;IAEnE,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAE7B,OAAO,eAAe,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;AACxC,CAAC;AATD,0BASC;AAED,SAAS,eAAe,CAAE,QAAgB,EAAE,IAAc;IACxD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,WAAW,CAAC,IAAI,EAAE,CAAA;IAC1D,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,WAAW,CAAC,IAAI,EAAE,CAAA;IAE1D,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAA;AACnE,CAAC;AAED,SAAS,cAAc,CAAE,GAAW,EAAE,QAAgB,EAAE,QAAgB;IACtE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAExB,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAA;IACvB,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAEvB,OAAO,GAAG,CAAC,IAAI,CAAA;AACjB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":"4.9.5"}
@@ -0,0 +1,27 @@
1
+ import { Locator } from '@toa.io/core/types'
2
+
3
+ declare namespace toa.pointer {
4
+
5
+ namespace uris {
6
+
7
+ type Node = string | {
8
+ [key: string]: Node
9
+ }
10
+
11
+ type Resolution = {
12
+ url: URL
13
+ entry: string
14
+ }
15
+
16
+ type Resolver = (locator: Locator, uris: URIs) => Resolution
17
+
18
+ }
19
+
20
+ type URIs = string | {
21
+ default?: string
22
+ [key: string]: uris.Node
23
+ }
24
+
25
+ }
26
+
27
+ export type URIs = toa.pointer.URIs
@@ -0,0 +1 @@
1
+ export * as uris from './uris'
package/types/uris.d.ts CHANGED
@@ -1,27 +1,19 @@
1
- import { Locator } from '@toa.io/core/types'
1
+ import type { Locator } from '@toa.io/core'
2
2
 
3
- declare namespace toa.pointer {
3
+ export function construct (declaration: URIs | string): URIs
4
4
 
5
- namespace uris {
5
+ export function resolve (locator: Locator, uris: URIs): Resolution
6
6
 
7
- type Node = string | {
8
- [key: string]: Node
9
- }
10
-
11
- type Resolution = {
12
- url: URL
13
- entry: string
14
- }
15
-
16
- type Resolver = (locator: Locator, uris: URIs) => Resolution
17
-
18
- }
19
-
20
- type URIs = string | {
21
- default?: string
22
- [key: string]: uris.Node
23
- }
7
+ type Node = string | {
8
+ [key: string]: Node
9
+ }
24
10
 
11
+ type URIs = string | {
12
+ default?: string
13
+ [key: string]: Node
25
14
  }
26
15
 
27
- export type URIs = toa.pointer.URIs
16
+ type Resolution = {
17
+ url: URL
18
+ entry: string
19
+ }