@toa.io/extensions.exposition 1.0.0-alpha.46 → 1.0.0-alpha.48
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 -4
- package/features/flow.feature +45 -0
- package/features/steps/components/octets.tester/manifest.toa.yaml +12 -1
- package/features/steps/components/octets.tester/operations/redirect.js +7 -2
- package/package.json +7 -7
- package/schemas/octets/fetch.cos.yaml +0 -1
- 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/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
- package/features/octets.redirect.feature +0 -27
|
@@ -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,EAAE,CAAA;QAEP,OAAO,CAAC,KAAK,CAAC,QAAQ,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