@toa.io/extensions.exposition 1.0.0-alpha.43 → 1.0.0-alpha.45
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/components/identity.basic/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.federation/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.roles/manifest.toa.yaml +1 -1
- package/components/identity.roles/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.tokens/operations/tsconfig.tsbuildinfo +1 -1
- package/documentation/octets.md +14 -0
- package/features/identity.roles.feature +31 -3
- package/features/octets.redirect.feature +27 -0
- package/features/octets.workflows.feature +42 -0
- package/features/steps/components/octets.tester/manifest.toa.yaml +5 -0
- package/features/steps/components/octets.tester/operations/redirect.js +7 -0
- package/package.json +7 -7
- package/schemas/octets/fetch.cos.yaml +1 -0
- package/source/directives/octets/Fetch.ts +62 -10
- package/source/directives/octets/List.ts +5 -5
- package/source/directives/octets/schemas.ts +4 -4
- package/source/directives/octets/workflows/Execution.ts +8 -1
- package/source/manifest.ts +8 -9
- package/transpiled/directives/octets/Fetch.d.ts +9 -3
- package/transpiled/directives/octets/Fetch.js +45 -8
- package/transpiled/directives/octets/Fetch.js.map +1 -1
- package/transpiled/directives/octets/List.d.ts +3 -3
- package/transpiled/directives/octets/List.js +3 -3
- package/transpiled/directives/octets/List.js.map +1 -1
- package/transpiled/directives/octets/schemas.d.ts +4 -4
- package/transpiled/directives/octets/schemas.js.map +1 -1
- package/transpiled/directives/octets/workflows/Execution.js +6 -1
- package/transpiled/directives/octets/workflows/Execution.js.map +1 -1
- package/transpiled/manifest.js +8 -9
- package/transpiled/manifest.js.map +1 -1
- package/transpiled/tsconfig.tsbuildinfo +1 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { posix } from 'node:path'
|
|
2
|
+
import { Readable } from 'node:stream'
|
|
2
3
|
import { Forbidden, NotFound } from '../../HTTP'
|
|
3
4
|
import * as schemas from './schemas'
|
|
4
5
|
import { Directive } from './Directive'
|
|
6
|
+
import type { Remotes } from '../../Remotes'
|
|
5
7
|
import type { Maybe } from '@toa.io/types'
|
|
6
8
|
import type { Entry } from '@toa.io/extensions.storages'
|
|
7
|
-
import type { Readable } from 'node:stream'
|
|
8
9
|
import type { Component } from '@toa.io/core'
|
|
9
10
|
import type { Output } from '../../io'
|
|
10
11
|
import type { Input } from './types'
|
|
@@ -12,35 +13,44 @@ import type { Input } from './types'
|
|
|
12
13
|
export class Fetch extends Directive {
|
|
13
14
|
public readonly targeted = true
|
|
14
15
|
|
|
15
|
-
private readonly
|
|
16
|
+
private readonly options: Required<Options> = {
|
|
16
17
|
blob: true,
|
|
17
|
-
meta: false
|
|
18
|
+
meta: false,
|
|
19
|
+
redirect: null
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
private readonly discovery: Promise<Component>
|
|
21
|
-
private storage
|
|
23
|
+
private storage!: Component
|
|
24
|
+
private readonly remotes: Remotes
|
|
25
|
+
private connecting: Promise<Component> | null = null
|
|
26
|
+
private remote!: Component
|
|
22
27
|
|
|
23
|
-
public constructor (
|
|
28
|
+
public constructor (options: Options | null, discovery: Promise<Component>, remotes: Remotes) {
|
|
24
29
|
super()
|
|
25
|
-
schemas.fetch.validate(permissions)
|
|
26
30
|
|
|
27
|
-
|
|
31
|
+
schemas.fetch.validate(options)
|
|
32
|
+
Object.assign(this.options, options)
|
|
33
|
+
|
|
28
34
|
this.discovery = discovery
|
|
35
|
+
this.remotes = remotes
|
|
29
36
|
}
|
|
30
37
|
|
|
31
38
|
public async apply (storage: string, input: Input): Promise<Output> {
|
|
39
|
+
if (this.options.redirect !== null)
|
|
40
|
+
return this.redirect(input, this.options.redirect)
|
|
41
|
+
|
|
32
42
|
this.storage ??= await this.discovery
|
|
33
43
|
|
|
34
44
|
const variant = posix.basename(input.request.url).includes('.')
|
|
35
45
|
const metadata = input.subtype === 'octets.entry'
|
|
36
46
|
|
|
37
47
|
if (!variant && metadata)
|
|
38
|
-
if (this.
|
|
48
|
+
if (this.options.meta)
|
|
39
49
|
return this.get(storage, input)
|
|
40
50
|
else
|
|
41
51
|
throw new Forbidden('Metadata is not accessible.')
|
|
42
52
|
|
|
43
|
-
if (!variant && !this.
|
|
53
|
+
if (!variant && !this.options.blob)
|
|
44
54
|
throw new Forbidden('BLOB variant must be specified.')
|
|
45
55
|
|
|
46
56
|
return await this.fetch(storage, input)
|
|
@@ -72,6 +82,47 @@ export class Fetch extends Directive {
|
|
|
72
82
|
}
|
|
73
83
|
}
|
|
74
84
|
|
|
85
|
+
private async redirect (input: Input, redirect: string): Promise<Output> {
|
|
86
|
+
if ('if-none-match' in input.request.headers)
|
|
87
|
+
return { status: 304 }
|
|
88
|
+
|
|
89
|
+
const [operation, name, namespace = 'default'] = redirect.split('.').reverse()
|
|
90
|
+
|
|
91
|
+
if (this.connecting === null)
|
|
92
|
+
this.connecting = this.remotes.discover(namespace, name)
|
|
93
|
+
|
|
94
|
+
this.remote ??= await this.connecting
|
|
95
|
+
|
|
96
|
+
const url = await this.remote.invoke<Maybe<string>>(operation, {
|
|
97
|
+
input: {
|
|
98
|
+
authority: input.authority,
|
|
99
|
+
path: input.request.url
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
if (url instanceof Error)
|
|
104
|
+
throw new NotFound(url)
|
|
105
|
+
|
|
106
|
+
const response = await fetch(url)
|
|
107
|
+
|
|
108
|
+
if (!response.ok)
|
|
109
|
+
throw new NotFound()
|
|
110
|
+
|
|
111
|
+
const headers = new Headers()
|
|
112
|
+
|
|
113
|
+
for (const header of ['content-type', 'content-length', 'etag']) {
|
|
114
|
+
const value = response.headers.get(header)
|
|
115
|
+
|
|
116
|
+
if (value !== null)
|
|
117
|
+
headers.set(header, value)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
headers,
|
|
122
|
+
body: response.body === null ? null : Readable.fromWeb(response.body as any)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
75
126
|
private async get (storage: string, input: Input): Promise<Output> {
|
|
76
127
|
const entry = await this.storage.invoke<Maybe<Entry>>('get', {
|
|
77
128
|
input: {
|
|
@@ -87,9 +138,10 @@ export class Fetch extends Directive {
|
|
|
87
138
|
}
|
|
88
139
|
}
|
|
89
140
|
|
|
90
|
-
export interface
|
|
141
|
+
export interface Options {
|
|
91
142
|
blob?: boolean
|
|
92
143
|
meta?: boolean
|
|
144
|
+
redirect?: string | null
|
|
93
145
|
}
|
|
94
146
|
|
|
95
147
|
interface FetchResult {
|
|
@@ -12,15 +12,15 @@ import type { Input } from './types'
|
|
|
12
12
|
export class List extends Directive {
|
|
13
13
|
public readonly targeted = false
|
|
14
14
|
|
|
15
|
-
private readonly
|
|
15
|
+
private readonly options: Required<Options> = { meta: false }
|
|
16
16
|
private readonly discovery: Promise<Component>
|
|
17
17
|
private storage: Component | null = null
|
|
18
18
|
|
|
19
|
-
public constructor (permissions:
|
|
19
|
+
public constructor (permissions: Options | null, discovery: Promise<Component>) {
|
|
20
20
|
super()
|
|
21
21
|
schemas.list.validate(permissions)
|
|
22
22
|
|
|
23
|
-
Object.assign(this.
|
|
23
|
+
Object.assign(this.options, permissions)
|
|
24
24
|
this.discovery = discovery
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -29,7 +29,7 @@ export class List extends Directive {
|
|
|
29
29
|
|
|
30
30
|
const metadata = input.subtype === 'octets.entries'
|
|
31
31
|
|
|
32
|
-
if (metadata && !this.
|
|
32
|
+
if (metadata && !this.options.meta)
|
|
33
33
|
throw new Forbidden('Metadata is not accessible.')
|
|
34
34
|
|
|
35
35
|
const list = await this.storage.invoke<Maybe<string[]>>('list', {
|
|
@@ -67,6 +67,6 @@ export class List extends Directive {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
export interface
|
|
70
|
+
export interface Options {
|
|
71
71
|
meta?: boolean
|
|
72
72
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { resolve } from 'node:path'
|
|
2
2
|
import schemas from '@toa.io/schemas'
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
3
|
+
import type { Options as FetchOptions } from './Fetch'
|
|
4
|
+
import type { Options as ListOptions } from './List'
|
|
5
5
|
import type { Options as StoreOptions } from './Store'
|
|
6
6
|
import type { Options as DeleteOptions } from './Delete'
|
|
7
7
|
import type { Schema } from '@toa.io/schemas'
|
|
@@ -12,8 +12,8 @@ const namespace = schemas.namespace(path)
|
|
|
12
12
|
|
|
13
13
|
export const context: Schema<string> = namespace.schema('context')
|
|
14
14
|
export const store: Schema<StoreOptions | null> = namespace.schema('store')
|
|
15
|
-
export const fetch: Schema<
|
|
15
|
+
export const fetch: Schema<FetchOptions | null> = namespace.schema('fetch')
|
|
16
16
|
export const remove: Schema<DeleteOptions | null> = namespace.schema('delete')
|
|
17
|
-
export const list: Schema<
|
|
17
|
+
export const list: Schema<ListOptions | null> = namespace.schema('list')
|
|
18
18
|
export const permute: Schema<null> = namespace.schema('permute')
|
|
19
19
|
export const workflow: Schema<Unit[] | Unit> = namespace.schema('workflow')
|
|
@@ -88,12 +88,19 @@ export class Execution extends Readable {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
private async call (endpoint: string): Promise<Maybe<unknown>> {
|
|
91
|
+
let task = false
|
|
92
|
+
|
|
93
|
+
if (endpoint.startsWith('task:')) {
|
|
94
|
+
endpoint = endpoint.slice(5)
|
|
95
|
+
task = true
|
|
96
|
+
}
|
|
97
|
+
|
|
91
98
|
const [operation, component, namespace = 'default'] = endpoint.split('.').reverse()
|
|
92
99
|
const key = `${namespace}.${component}`
|
|
93
100
|
|
|
94
101
|
this.components[key] ??= await this.discover(key, namespace, component)
|
|
95
102
|
|
|
96
|
-
return this.components[key].invoke(operation, { input: this.context })
|
|
103
|
+
return this.components[key].invoke(operation, { input: this.context, task })
|
|
97
104
|
}
|
|
98
105
|
|
|
99
106
|
private async discover (key: string, namespace: string, component: string): Promise<Component> {
|
package/source/manifest.ts
CHANGED
|
@@ -12,7 +12,7 @@ export function manifest (declaration: object, manifest: Manifest): Node {
|
|
|
12
12
|
|
|
13
13
|
const node = parse(declaration, shortcuts)
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
specify(node, manifest)
|
|
16
16
|
schemas.node.validate(node)
|
|
17
17
|
|
|
18
18
|
return node
|
|
@@ -25,26 +25,25 @@ function wrap (declaration: object, namespace: string, name: string): object {
|
|
|
25
25
|
return { [path]: { protected: true, ...declaration } }
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
function
|
|
28
|
+
function specify (node: Node, manifest: Manifest): void {
|
|
29
29
|
for (const route of node.routes) {
|
|
30
30
|
for (const method of route.node.methods)
|
|
31
|
-
|
|
31
|
+
specifyMethod(method, manifest)
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
specify(route.node, manifest)
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
function
|
|
38
|
-
if (method.mapping === undefined)
|
|
37
|
+
function specifyMethod (method: Method, manifest: Manifest): void {
|
|
38
|
+
if (method.mapping?.endpoint === undefined)
|
|
39
39
|
return
|
|
40
40
|
|
|
41
41
|
const operation = manifest.operations[method.mapping.endpoint]
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
throw new Error(`Operation '${method.mapping.endpoint}' not found`)
|
|
43
|
+
assert.ok(operation !== undefined, `Operation '${method.mapping.endpoint}' not found`)
|
|
45
44
|
|
|
46
45
|
if (method.mapping.query === undefined && operation.query !== false)
|
|
47
|
-
method.mapping.query = {} as unknown as Query
|
|
46
|
+
method.mapping.query = {} as unknown as Query
|
|
48
47
|
|
|
49
48
|
method.mapping.namespace = manifest.namespace
|
|
50
49
|
method.mapping.component = manifest.name
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import { Directive } from './Directive';
|
|
2
|
+
import type { Remotes } from '../../Remotes';
|
|
2
3
|
import type { Component } from '@toa.io/core';
|
|
3
4
|
import type { Output } from '../../io';
|
|
4
5
|
import type { Input } from './types';
|
|
5
6
|
export declare class Fetch extends Directive {
|
|
6
7
|
readonly targeted = true;
|
|
7
|
-
private readonly
|
|
8
|
+
private readonly options;
|
|
8
9
|
private readonly discovery;
|
|
9
10
|
private storage;
|
|
10
|
-
|
|
11
|
+
private readonly remotes;
|
|
12
|
+
private connecting;
|
|
13
|
+
private remote;
|
|
14
|
+
constructor(options: Options | null, discovery: Promise<Component>, remotes: Remotes);
|
|
11
15
|
apply(storage: string, input: Input): Promise<Output>;
|
|
12
16
|
private fetch;
|
|
17
|
+
private redirect;
|
|
13
18
|
private get;
|
|
14
19
|
}
|
|
15
|
-
export interface
|
|
20
|
+
export interface Options {
|
|
16
21
|
blob?: boolean;
|
|
17
22
|
meta?: boolean;
|
|
23
|
+
redirect?: string | null;
|
|
18
24
|
}
|
|
@@ -25,33 +25,41 @@ 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");
|
|
28
29
|
const HTTP_1 = require("../../HTTP");
|
|
29
30
|
const schemas = __importStar(require("./schemas"));
|
|
30
31
|
const Directive_1 = require("./Directive");
|
|
31
32
|
class Fetch extends Directive_1.Directive {
|
|
32
33
|
targeted = true;
|
|
33
|
-
|
|
34
|
+
options = {
|
|
34
35
|
blob: true,
|
|
35
|
-
meta: false
|
|
36
|
+
meta: false,
|
|
37
|
+
redirect: null
|
|
36
38
|
};
|
|
37
39
|
discovery;
|
|
38
|
-
storage
|
|
39
|
-
|
|
40
|
+
storage;
|
|
41
|
+
remotes;
|
|
42
|
+
connecting = null;
|
|
43
|
+
remote;
|
|
44
|
+
constructor(options, discovery, remotes) {
|
|
40
45
|
super();
|
|
41
|
-
schemas.fetch.validate(
|
|
42
|
-
Object.assign(this.
|
|
46
|
+
schemas.fetch.validate(options);
|
|
47
|
+
Object.assign(this.options, options);
|
|
43
48
|
this.discovery = discovery;
|
|
49
|
+
this.remotes = remotes;
|
|
44
50
|
}
|
|
45
51
|
async apply(storage, input) {
|
|
52
|
+
if (this.options.redirect !== null)
|
|
53
|
+
return this.redirect(input, this.options.redirect);
|
|
46
54
|
this.storage ??= await this.discovery;
|
|
47
55
|
const variant = node_path_1.posix.basename(input.request.url).includes('.');
|
|
48
56
|
const metadata = input.subtype === 'octets.entry';
|
|
49
57
|
if (!variant && metadata)
|
|
50
|
-
if (this.
|
|
58
|
+
if (this.options.meta)
|
|
51
59
|
return this.get(storage, input);
|
|
52
60
|
else
|
|
53
61
|
throw new HTTP_1.Forbidden('Metadata is not accessible.');
|
|
54
|
-
if (!variant && !this.
|
|
62
|
+
if (!variant && !this.options.blob)
|
|
55
63
|
throw new HTTP_1.Forbidden('BLOB variant must be specified.');
|
|
56
64
|
return await this.fetch(storage, input);
|
|
57
65
|
}
|
|
@@ -76,6 +84,35 @@ class Fetch extends Directive_1.Directive {
|
|
|
76
84
|
body: result.stream
|
|
77
85
|
};
|
|
78
86
|
}
|
|
87
|
+
async redirect(input, redirect) {
|
|
88
|
+
if ('if-none-match' in input.request.headers)
|
|
89
|
+
return { status: 304 };
|
|
90
|
+
const [operation, name, namespace = 'default'] = 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
|
+
}
|
|
99
|
+
});
|
|
100
|
+
if (url instanceof Error)
|
|
101
|
+
throw new HTTP_1.NotFound(url);
|
|
102
|
+
const response = await fetch(url);
|
|
103
|
+
if (!response.ok)
|
|
104
|
+
throw new HTTP_1.NotFound();
|
|
105
|
+
const headers = new Headers();
|
|
106
|
+
for (const header of ['content-type', 'content-length', 'etag']) {
|
|
107
|
+
const value = response.headers.get(header);
|
|
108
|
+
if (value !== null)
|
|
109
|
+
headers.set(header, value);
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
headers,
|
|
113
|
+
body: response.body === null ? null : node_stream_1.Readable.fromWeb(response.body)
|
|
114
|
+
};
|
|
115
|
+
}
|
|
79
116
|
async get(storage, input) {
|
|
80
117
|
const entry = await this.storage.invoke('get', {
|
|
81
118
|
input: {
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
1
|
+
{"version":3,"file":"Fetch.js","sourceRoot":"","sources":["../../../source/directives/octets/Fetch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAiC;AACjC,6CAAsC;AACtC,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;QACX,QAAQ,EAAE,IAAI;KACf,CAAA;IAEgB,SAAS,CAAoB;IACtC,OAAO,CAAY;IACV,OAAO,CAAS;IACzB,UAAU,GAA8B,IAAI,CAAA;IAC5C,MAAM,CAAY;IAE1B,YAAoB,OAAuB,EAAE,SAA6B,EAAE,OAAgB;QAC1F,KAAK,EAAE,CAAA;QAEP,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QAC/B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAEpC,IAAI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AI,CAAC,QAAQ,CAAC,EAAE;YACd,MAAM,IAAI,eAAQ,EAAE,CAAA;QAEtB,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAA;QAE7B,KAAK,MAAM,MAAM,IAAI,CAAC,cAAc,EAAE,gBAAgB,EAAE,MAAM,CAAC,EAAE,CAAC;YAChE,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;YAE1C,IAAI,KAAK,KAAK,IAAI;gBAChB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;QAC9B,CAAC;QAED,OAAO;YACL,OAAO;YACP,IAAI,EAAE,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,sBAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAW,CAAC;SAC7E,CAAA;IACH,CAAC;IAEO,KAAK,CAAC,GAAG,CAAE,OAAe,EAAE,KAAY;QAC9C,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAe,KAAK,EAAE;YAC3D,KAAK,EAAE;gBACL,OAAO;gBACP,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG;aACxB;SACF,CAAC,CAAA;QAEF,IAAI,KAAK,YAAY,KAAK;YACxB,MAAM,IAAI,eAAQ,EAAE,CAAA;QAEtB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;IACxB,CAAC;CACF;AA9HD,sBA8HC"}
|
|
@@ -4,13 +4,13 @@ import type { Output } from '../../io';
|
|
|
4
4
|
import type { Input } from './types';
|
|
5
5
|
export declare class List extends Directive {
|
|
6
6
|
readonly targeted = false;
|
|
7
|
-
private readonly
|
|
7
|
+
private readonly options;
|
|
8
8
|
private readonly discovery;
|
|
9
9
|
private storage;
|
|
10
|
-
constructor(permissions:
|
|
10
|
+
constructor(permissions: Options | null, discovery: Promise<Component>);
|
|
11
11
|
apply(storage: string, input: Input): Promise<Output>;
|
|
12
12
|
private expand;
|
|
13
13
|
}
|
|
14
|
-
export interface
|
|
14
|
+
export interface Options {
|
|
15
15
|
meta?: boolean;
|
|
16
16
|
}
|
|
@@ -30,19 +30,19 @@ const schemas = __importStar(require("./schemas"));
|
|
|
30
30
|
const Directive_1 = require("./Directive");
|
|
31
31
|
class List extends Directive_1.Directive {
|
|
32
32
|
targeted = false;
|
|
33
|
-
|
|
33
|
+
options = { meta: false };
|
|
34
34
|
discovery;
|
|
35
35
|
storage = null;
|
|
36
36
|
constructor(permissions, discovery) {
|
|
37
37
|
super();
|
|
38
38
|
schemas.list.validate(permissions);
|
|
39
|
-
Object.assign(this.
|
|
39
|
+
Object.assign(this.options, permissions);
|
|
40
40
|
this.discovery = discovery;
|
|
41
41
|
}
|
|
42
42
|
async apply(storage, input) {
|
|
43
43
|
this.storage ??= await this.discovery;
|
|
44
44
|
const metadata = input.subtype === 'octets.entries';
|
|
45
|
-
if (metadata && !this.
|
|
45
|
+
if (metadata && !this.options.meta)
|
|
46
46
|
throw new HTTP_1.Forbidden('Metadata is not accessible.');
|
|
47
47
|
const list = await this.storage.invoke('list', {
|
|
48
48
|
input: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.js","sourceRoot":"","sources":["../../../source/directives/octets/List.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAiC;AACjC,qCAAgD;AAChD,mDAAoC;AACpC,2CAAuC;AAQvC,MAAa,IAAK,SAAQ,qBAAS;IACjB,QAAQ,GAAG,KAAK,CAAA;IAEf,
|
|
1
|
+
{"version":3,"file":"List.js","sourceRoot":"","sources":["../../../source/directives/octets/List.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAiC;AACjC,qCAAgD;AAChD,mDAAoC;AACpC,2CAAuC;AAQvC,MAAa,IAAK,SAAQ,qBAAS;IACjB,QAAQ,GAAG,KAAK,CAA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E,EAAE,EAAE,EAAE;YACrC,MAAM,IAAI,GAAG,iBAAK,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;YAEnC,MAAM,KAAK,GAAG;gBACZ,OAAO;gBACP,IAAI;aACL,CAAA;YAED,0FAA0F;YAC1F,OAAO,IAAI,CAAC,OAAQ,CAAC,MAAM,CAAe,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;QAC7D,CAAC,CAAC,CAAA;QAEF,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IACpC,CAAC;CACF;AAxDD,oBAwDC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { Options as FetchOptions } from './Fetch';
|
|
2
|
+
import type { Options as ListOptions } from './List';
|
|
3
3
|
import type { Options as StoreOptions } from './Store';
|
|
4
4
|
import type { Options as DeleteOptions } from './Delete';
|
|
5
5
|
import type { Schema } from '@toa.io/schemas';
|
|
6
6
|
import type { Unit } from './workflows';
|
|
7
7
|
export declare const context: Schema<string>;
|
|
8
8
|
export declare const store: Schema<StoreOptions | null>;
|
|
9
|
-
export declare const fetch: Schema<
|
|
9
|
+
export declare const fetch: Schema<FetchOptions | null>;
|
|
10
10
|
export declare const remove: Schema<DeleteOptions | null>;
|
|
11
|
-
export declare const list: Schema<
|
|
11
|
+
export declare const list: Schema<ListOptions | null>;
|
|
12
12
|
export declare const permute: Schema<null>;
|
|
13
13
|
export declare const workflow: Schema<Unit[] | Unit>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../source/directives/octets/schemas.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAmC;AACnC,8DAAqC;AAQrC,MAAM,IAAI,GAAG,IAAA,mBAAO,EAAC,SAAS,EAAE,yBAAyB,CAAC,CAAA;AAC1D,MAAM,SAAS,GAAG,iBAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;AAE5B,QAAA,OAAO,GAAmB,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;AACrD,QAAA,KAAK,GAAgC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;AAC9D,QAAA,KAAK,
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../source/directives/octets/schemas.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAmC;AACnC,8DAAqC;AAQrC,MAAM,IAAI,GAAG,IAAA,mBAAO,EAAC,SAAS,EAAE,yBAAyB,CAAC,CAAA;AAC1D,MAAM,SAAS,GAAG,iBAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;AAE5B,QAAA,OAAO,GAAmB,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;AACrD,QAAA,KAAK,GAAgC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;AAC9D,QAAA,KAAK,GAAgC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;AAC9D,QAAA,MAAM,GAAiC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AACjE,QAAA,IAAI,GAA+B,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;AAC3D,QAAA,OAAO,GAAiB,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;AACnD,QAAA,QAAQ,GAA0B,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA"}
|
|
@@ -68,10 +68,15 @@ class Execution extends node_stream_1.Readable {
|
|
|
68
68
|
console.error(error);
|
|
69
69
|
}
|
|
70
70
|
async call(endpoint) {
|
|
71
|
+
let task = false;
|
|
72
|
+
if (endpoint.startsWith('task:')) {
|
|
73
|
+
endpoint = endpoint.slice(5);
|
|
74
|
+
task = true;
|
|
75
|
+
}
|
|
71
76
|
const [operation, component, namespace = 'default'] = endpoint.split('.').reverse();
|
|
72
77
|
const key = `${namespace}.${component}`;
|
|
73
78
|
this.components[key] ??= await this.discover(key, namespace, component);
|
|
74
|
-
return this.components[key].invoke(operation, { input: this.context });
|
|
79
|
+
return this.components[key].invoke(operation, { input: this.context, task });
|
|
75
80
|
}
|
|
76
81
|
async discover(key, namespace, component) {
|
|
77
82
|
if (this.discovery[key] === undefined)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Execution.js","sourceRoot":"","sources":["../../../../source/directives/octets/workflows/Execution.ts"],"names":[],"mappings":";;;AAAA,6CAAsC;AAOtC,MAAa,SAAU,SAAQ,sBAAQ;IACpB,KAAK,CAAQ;IACb,OAAO,CAAS;IAChB,OAAO,CAAS;IAChB,UAAU,GAA8B,EAAE,CAAA;IAC1C,SAAS,GAAuC,EAAE,CAAA;IAC3D,WAAW,GAAG,KAAK,CAAA;IAE3B,YAAoB,OAAgB,EAAE,KAAa,EAAE,OAAgB;QACnE,KAAK,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAA;QAE3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QAEtB,KAAK,IAAI,CAAC,GAAG,EAAE,CAAA;IACjB,CAAC;IAEe,KAAK;IACrB,CAAC;IAEO,KAAK,CAAC,GAAG;QACf,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;YAExB,IAAI,IAAI,CAAC,WAAW;gBAClB,MAAK;QACT,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACjB,CAAC;IAEO,KAAK,CAAC,OAAO,CAAE,IAAU;QAC/B,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE;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EAAE,CAAA;QACnF,MAAM,GAAG,GAAG,GAAG,SAAS,IAAI,SAAS,EAAE,CAAA;QAEvC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,CAAC,CAAA;QAEvE,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;IAC9E,CAAC;IAEO,KAAK,CAAC,QAAQ,CAAE,GAAW,EAAE,SAAiB,EAAE,SAAiB;QACvE,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,SAAS;YACnC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;QAEnE,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;IAClC,CAAC;CACF;AAxGD,8BAwGC"}
|
package/transpiled/manifest.js
CHANGED
|
@@ -35,7 +35,7 @@ function manifest(declaration, manifest) {
|
|
|
35
35
|
node_assert_1.default.ok(typeof declaration === 'object' && declaration !== null, 'Exposition declaration must be an object');
|
|
36
36
|
declaration = wrap(declaration, manifest.namespace, manifest.name);
|
|
37
37
|
const node = (0, syntax_1.parse)(declaration, Directive_1.shortcuts);
|
|
38
|
-
|
|
38
|
+
specify(node, manifest);
|
|
39
39
|
schemas.node.validate(node);
|
|
40
40
|
return node;
|
|
41
41
|
}
|
|
@@ -45,21 +45,20 @@ function wrap(declaration, namespace, name) {
|
|
|
45
45
|
'/' + name;
|
|
46
46
|
return { [path]: { protected: true, ...declaration } };
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function specify(node, manifest) {
|
|
49
49
|
for (const route of node.routes) {
|
|
50
50
|
for (const method of route.node.methods)
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
specifyMethod(method, manifest);
|
|
52
|
+
specify(route.node, manifest);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
function
|
|
56
|
-
if (method.mapping === undefined)
|
|
55
|
+
function specifyMethod(method, manifest) {
|
|
56
|
+
if (method.mapping?.endpoint === undefined)
|
|
57
57
|
return;
|
|
58
58
|
const operation = manifest.operations[method.mapping.endpoint];
|
|
59
|
-
|
|
60
|
-
throw new Error(`Operation '${method.mapping.endpoint}' not found`);
|
|
59
|
+
node_assert_1.default.ok(operation !== undefined, `Operation '${method.mapping.endpoint}' not found`);
|
|
61
60
|
if (method.mapping.query === undefined && operation.query !== false)
|
|
62
|
-
method.mapping.query = {};
|
|
61
|
+
method.mapping.query = {};
|
|
63
62
|
method.mapping.namespace = manifest.namespace;
|
|
64
63
|
method.mapping.component = manifest.name;
|
|
65
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../source/manifest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAgC;AAChC,yCAAwE;AACxE,2CAAuC;AACvC,mDAAoC;AAGpC,SAAgB,QAAQ,CAAE,WAAmB,EAAE,QAAkB;IAC/D,qBAAM,CAAC,EAAE,CAAC,OAAO,WAAW,KAAK,QAAQ,IAAI,WAAW,KAAK,IAAI,EAC/D,0CAA0C,CAAC,CAAA;IAE7C,WAAW,GAAG,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAA;IAElE,MAAM,IAAI,GAAG,IAAA,cAAK,EAAC,WAAW,EAAE,qBAAS,CAAC,CAAA;IAE1C,
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../source/manifest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAgC;AAChC,yCAAwE;AACxE,2CAA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