@toa.io/extensions.exposition 1.0.0-alpha.47 → 1.0.0-alpha.49
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/documentation/flow.md +31 -0
- package/documentation/octets.md +0 -7
- package/features/{octets.redirect.feature → flow.feature} +3 -4
- package/features/routes.feature +22 -0
- package/features/steps/components/echo/manifest.toa.yaml +7 -0
- package/features/steps/components/echo/operations/parameters.js +7 -0
- package/features/steps/components/octets.tester/manifest.toa.yaml +12 -1
- package/features/steps/components/octets.tester/operations/redirect.js +2 -2
- package/package.json +7 -7
- package/schemas/octets/fetch.cos.yaml +0 -1
- package/source/RTD/Node.ts +2 -1
- package/source/RTD/Route.ts +4 -3
- package/source/directives/auth/Incept.ts +1 -1
- package/source/directives/flow/Fetch.ts +88 -0
- package/source/directives/flow/Flow.ts +34 -0
- package/source/directives/flow/index.ts +3 -0
- package/source/directives/flow/types.ts +6 -0
- package/source/directives/index.ts +2 -1
- package/source/directives/octets/Fetch.ts +4 -57
- package/transpiled/RTD/Node.js +2 -1
- package/transpiled/RTD/Node.js.map +1 -1
- package/transpiled/RTD/Route.js +0 -1
- package/transpiled/RTD/Route.js.map +1 -1
- package/transpiled/directives/auth/Incept.js +1 -1
- package/transpiled/directives/auth/Incept.js.map +1 -1
- package/transpiled/directives/flow/Fetch.d.ts +13 -0
- package/transpiled/directives/flow/Fetch.js +59 -0
- package/transpiled/directives/flow/Fetch.js.map +1 -0
- package/transpiled/directives/flow/Flow.d.ts +10 -0
- package/transpiled/directives/flow/Flow.js +27 -0
- package/transpiled/directives/flow/Flow.js.map +1 -0
- package/transpiled/directives/flow/index.d.ts +2 -0
- package/transpiled/directives/flow/index.js +6 -0
- package/transpiled/directives/flow/index.js.map +1 -0
- package/transpiled/directives/flow/types.d.ts +5 -0
- package/transpiled/directives/flow/types.js +3 -0
- package/transpiled/directives/flow/types.js.map +1 -0
- package/transpiled/directives/index.js +2 -1
- package/transpiled/directives/index.js.map +1 -1
- package/transpiled/directives/octets/Fetch.d.ts +2 -9
- package/transpiled/directives/octets/Fetch.js +3 -41
- package/transpiled/directives/octets/Fetch.js.map +1 -1
- package/transpiled/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Flow = void 0;
|
|
4
|
+
const Fetch_1 = require("./Fetch");
|
|
5
|
+
class Flow {
|
|
6
|
+
name = 'flow';
|
|
7
|
+
mandatory = false;
|
|
8
|
+
create(name, value, remotes) {
|
|
9
|
+
const Class = constructors[name];
|
|
10
|
+
if (Class === undefined)
|
|
11
|
+
throw new Error(`Directive '${this.name}:${name}' is not implemented.`);
|
|
12
|
+
return new Class(value, remotes);
|
|
13
|
+
}
|
|
14
|
+
async preflight(directives, input, parameters) {
|
|
15
|
+
for (const directive of directives) {
|
|
16
|
+
const output = await directive.apply(input, parameters);
|
|
17
|
+
if (output !== null)
|
|
18
|
+
return output;
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.Flow = Flow;
|
|
24
|
+
const constructors = {
|
|
25
|
+
fetch: Fetch_1.Fetch
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=Flow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Flow.js","sourceRoot":"","sources":["../../../source/directives/flow/Flow.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAM/B,MAAa,IAAI;IACC,IAAI,GAAW,MAAM,CAAA;IACrB,SAAS,GAAY,KAAK,CAAA;IAEnC,MAAM,CAAE,IAAY,EAAE,KAAc,EAAE,OAAgB;QAC3D,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;QAEhC,IAAI,KAAK,KAAK,SAAS;YACrB,MAAM,IAAI,KAAK,CAAC,cAAc,IAAI,CAAC,IAAI,IAAI,IAAI,uBAAuB,CAAC,CAAA;QAEzE,OAAO,IAAI,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IAClC,CAAC;IAEM,KAAK,CAAC,SAAS,CAAE,UAAuB,EAAE,KAAY,EAAE,UAAuB;QACpF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;YAEvD,IAAI,MAAM,KAAK,IAAI;gBACjB,OAAO,MAAM,CAAA;QACjB,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAvBD,oBAuBC;AAED,MAAM,YAAY,GAAsE;IACtF,KAAK,EAAE,aAAK;CACb,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/directives/flow/index.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAEhB,QAAA,IAAI,GAAG,IAAI,WAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../source/directives/flow/types.ts"],"names":[],"mappings":""}
|
|
@@ -9,6 +9,7 @@ const octets_1 = require("./octets");
|
|
|
9
9
|
const io_1 = require("./io");
|
|
10
10
|
const vary_1 = require("./vary");
|
|
11
11
|
const require_1 = require("./require");
|
|
12
|
-
|
|
12
|
+
const flow_1 = require("./flow");
|
|
13
|
+
exports.families = [auth_1.authorization, io_1.io, cache_1.cache, vary_1.vary, require_1.req, flow_1.flow, octets_1.octets, dev_1.dev];
|
|
13
14
|
exports.interceptors = [cors_1.cors];
|
|
14
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/directives/index.ts"],"names":[],"mappings":";;;AAAA,iCAAsC;AACtC,mCAA+B;AAC/B,iCAA6B;AAC7B,+BAA2B;AAC3B,qCAAiC;AACjC,6BAAyB;AACzB,iCAA6B;AAC7B,uCAA+B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/directives/index.ts"],"names":[],"mappings":";;;AAAA,iCAAsC;AACtC,mCAA+B;AAC/B,iCAA6B;AAC7B,+BAA2B;AAC3B,qCAAiC;AACjC,6BAAyB;AACzB,iCAA6B;AAC7B,uCAA+B;AAC/B,iCAA6B;AAIhB,QAAA,QAAQ,GAAsB,CAAC,oBAAa,EAAE,OAAE,EAAE,aAAK,EAAE,WAAI,EAAE,aAAG,EAAE,WAAI,EAAE,eAAM,EAAE,SAAG,CAAC,CAAA;AACtF,QAAA,YAAY,GAAkB,CAAC,WAAI,CAAC,CAAA"}
|
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
import { Directive } from './Directive';
|
|
2
|
-
import type { Remotes } from '../../Remotes';
|
|
3
2
|
import type { Component } from '@toa.io/core';
|
|
4
3
|
import type { Output } from '../../io';
|
|
5
4
|
import type { Input } from './types';
|
|
6
|
-
import type { Parameter } from '../../RTD';
|
|
7
5
|
export declare class Fetch extends Directive {
|
|
8
6
|
readonly targeted = true;
|
|
9
7
|
private readonly options;
|
|
10
8
|
private readonly discovery;
|
|
11
9
|
private storage;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
private remote;
|
|
15
|
-
constructor(options: Options | null, discovery: Promise<Component>, remotes: Remotes);
|
|
16
|
-
apply(storage: string, input: Input, parameters: Parameter[]): Promise<Output>;
|
|
10
|
+
constructor(options: Options | null, discovery: Promise<Component>);
|
|
11
|
+
apply(storage: string, input: Input): Promise<Output>;
|
|
17
12
|
private fetch;
|
|
18
|
-
private redirect;
|
|
19
13
|
private get;
|
|
20
14
|
}
|
|
21
15
|
export interface Options {
|
|
22
16
|
blob?: boolean;
|
|
23
17
|
meta?: boolean;
|
|
24
|
-
redirect?: string | null;
|
|
25
18
|
}
|
|
@@ -25,7 +25,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.Fetch = void 0;
|
|
27
27
|
const node_path_1 = require("node:path");
|
|
28
|
-
const node_stream_1 = require("node:stream");
|
|
29
28
|
const HTTP_1 = require("../../HTTP");
|
|
30
29
|
const schemas = __importStar(require("./schemas"));
|
|
31
30
|
const Directive_1 = require("./Directive");
|
|
@@ -33,24 +32,17 @@ class Fetch extends Directive_1.Directive {
|
|
|
33
32
|
targeted = true;
|
|
34
33
|
options = {
|
|
35
34
|
blob: true,
|
|
36
|
-
meta: false
|
|
37
|
-
redirect: null
|
|
35
|
+
meta: false
|
|
38
36
|
};
|
|
39
37
|
discovery;
|
|
40
38
|
storage;
|
|
41
|
-
|
|
42
|
-
connecting = null;
|
|
43
|
-
remote;
|
|
44
|
-
constructor(options, discovery, remotes) {
|
|
39
|
+
constructor(options, discovery) {
|
|
45
40
|
super();
|
|
46
41
|
schemas.fetch.validate(options);
|
|
47
42
|
Object.assign(this.options, options);
|
|
48
43
|
this.discovery = discovery;
|
|
49
|
-
this.remotes = remotes;
|
|
50
44
|
}
|
|
51
|
-
async apply(storage, input
|
|
52
|
-
if (this.options.redirect !== null)
|
|
53
|
-
return this.redirect(input, parameters);
|
|
45
|
+
async apply(storage, input) {
|
|
54
46
|
this.storage ??= await this.discovery;
|
|
55
47
|
const variant = node_path_1.posix.basename(input.request.url).includes('.');
|
|
56
48
|
const metadata = input.subtype === 'octets.entry';
|
|
@@ -84,36 +76,6 @@ class Fetch extends Directive_1.Directive {
|
|
|
84
76
|
body: result.stream
|
|
85
77
|
};
|
|
86
78
|
}
|
|
87
|
-
async redirect(input, parameters) {
|
|
88
|
-
if ('if-none-match' in input.request.headers)
|
|
89
|
-
return { status: 304 };
|
|
90
|
-
const [operation, name, namespace = 'default'] = this.options.redirect.split('.').reverse();
|
|
91
|
-
if (this.connecting === null)
|
|
92
|
-
this.connecting = this.remotes.discover(namespace, name);
|
|
93
|
-
this.remote ??= await this.connecting;
|
|
94
|
-
const url = await this.remote.invoke(operation, {
|
|
95
|
-
input: {
|
|
96
|
-
authority: input.authority,
|
|
97
|
-
path: input.request.url,
|
|
98
|
-
parameters: Object.fromEntries(parameters.map(({ name, value }) => [name, value]))
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
if (url instanceof Error)
|
|
102
|
-
throw new HTTP_1.NotFound(url);
|
|
103
|
-
const response = await fetch(url);
|
|
104
|
-
if (!response.ok)
|
|
105
|
-
throw new HTTP_1.NotFound();
|
|
106
|
-
const headers = new Headers();
|
|
107
|
-
for (const header of ['content-type', 'content-length', 'etag']) {
|
|
108
|
-
const value = response.headers.get(header);
|
|
109
|
-
if (value !== null)
|
|
110
|
-
headers.set(header, value);
|
|
111
|
-
}
|
|
112
|
-
return {
|
|
113
|
-
headers,
|
|
114
|
-
body: response.body === null ? null : node_stream_1.Readable.fromWeb(response.body)
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
79
|
async get(storage, input) {
|
|
118
80
|
const entry = await this.storage.invoke('get', {
|
|
119
81
|
input: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Fetch.js","sourceRoot":"","sources":["../../../source/directives/octets/Fetch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAiC;AACjC,
|
|
1
|
+
{"version":3,"file":"Fetch.js","sourceRoot":"","sources":["../../../source/directives/octets/Fetch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAiC;AACjC,qCAAgD;AAChD,mDAAoC;AACpC,2CAAuC;AAQvC,MAAa,KAAM,SAAQ,qBAAS;IAClB,QAAQ,GAAG,IAAI,CAAA;IAEd,OAAO,GAAsB;QAC5C,IAAI,EAAE,IAAI;QACV,IAAI,EAAE,KAAK;KACZ,CAAA;IAEgB,SAAS,CAAoB;IACtC,OAAO,CAAY;IAE3B,YAAoB,OAAuB,EAAE,SAA6B;QACxE,KAAK,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