@toa.io/extensions.exposition 1.0.0-alpha.4 → 1.0.0-alpha.6
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/manifest.toa.yaml +2 -0
- package/components/identity.federation/manifest.toa.yaml +0 -6
- package/components/identity.roles/manifest.toa.yaml +1 -0
- package/documentation/io.md +56 -0
- package/documentation/query.md +9 -7
- package/documentation/tree.md +22 -4
- package/features/access.feature +11 -1
- package/features/annotation.feature +1 -0
- package/features/body.feature +1 -0
- package/features/cache.feature +3 -0
- package/features/cors.feature +2 -2
- package/features/directives.feature +2 -0
- package/features/dynamic.feature +14 -7
- package/features/errors.feature +3 -2
- package/features/etag.feature +12 -1
- package/features/identity.basic.feature +23 -0
- package/features/identity.federation.feature +3 -5
- package/features/identity.roles.feature +1 -0
- package/features/identity.tokens.feature +3 -0
- package/features/io.feature +167 -0
- package/features/octets.entries.feature +2 -0
- package/features/octets.feature +2 -0
- package/features/octets.meta.feature +4 -3
- package/features/octets.workflows.feature +1 -0
- package/features/queries.feature +9 -1
- package/features/response.feature +3 -0
- package/features/routes.feature +17 -10
- package/features/steps/components/pots/manifest.toa.yaml +2 -0
- package/features/steps/components/users/manifest.toa.yaml +1 -0
- package/features/steps/components/users.properties/manifest.toa.yaml +1 -0
- package/features/vary.feature +33 -3
- package/package.json +7 -7
- package/schemas/io/input.cos.yaml +3 -0
- package/schemas/io/message.cos.yaml +5 -0
- package/schemas/io/output.cos.yaml +5 -0
- package/source/Context.ts +6 -4
- package/source/Directive.test.ts +4 -4
- package/source/Directive.ts +7 -33
- package/source/Endpoint.ts +41 -6
- package/source/Factory.ts +10 -4
- package/source/Gateway.ts +4 -29
- package/source/HTTP/Server.ts +2 -2
- package/source/RTD/Context.ts +7 -10
- package/source/RTD/Directives.ts +28 -4
- package/source/RTD/Endpoint.ts +6 -4
- package/source/RTD/Match.ts +2 -7
- package/source/RTD/Method.ts +7 -13
- package/source/RTD/Node.ts +13 -14
- package/source/RTD/Tree.ts +17 -16
- package/source/RTD/factory.ts +2 -5
- package/source/directives/auth/Authorization.ts +5 -6
- package/source/directives/cache/Cache.ts +2 -2
- package/source/directives/cors/CORS.ts +13 -7
- package/source/directives/dev/Development.ts +3 -3
- package/source/directives/index.ts +5 -4
- package/source/directives/io/Directive.ts +11 -0
- package/source/directives/io/IO.ts +43 -0
- package/source/directives/io/Input.ts +50 -0
- package/source/directives/io/Message.ts +1 -0
- package/source/directives/io/Output.ts +69 -0
- package/source/directives/io/index.ts +3 -0
- package/source/directives/io/schemas.ts +12 -0
- package/source/directives/octets/Octets.ts +2 -3
- package/source/directives/octets/Store.ts +8 -2
- package/source/directives/vary/Vary.ts +2 -2
- package/source/directives/vary/embeddings/Header.ts +8 -6
- package/source/directives/vary/embeddings/Language.ts +1 -1
- package/source/root.ts +5 -0
- package/transpiled/Context.d.ts +6 -4
- package/transpiled/Directive.d.ts +4 -17
- package/transpiled/Directive.js +0 -3
- package/transpiled/Directive.js.map +1 -1
- package/transpiled/Endpoint.d.ts +5 -3
- package/transpiled/Endpoint.js +29 -4
- package/transpiled/Endpoint.js.map +1 -1
- package/transpiled/Factory.js +5 -1
- package/transpiled/Factory.js.map +1 -1
- package/transpiled/Gateway.d.ts +1 -4
- package/transpiled/Gateway.js +1 -17
- package/transpiled/Gateway.js.map +1 -1
- package/transpiled/HTTP/Server.js +2 -2
- package/transpiled/HTTP/Server.js.map +1 -1
- package/transpiled/RTD/Context.d.ts +7 -6
- package/transpiled/RTD/Directives.d.ts +19 -4
- package/transpiled/RTD/Endpoint.d.ts +6 -4
- package/transpiled/RTD/Match.d.ts +2 -4
- package/transpiled/RTD/Method.d.ts +7 -7
- package/transpiled/RTD/Method.js.map +1 -1
- package/transpiled/RTD/Node.d.ts +4 -6
- package/transpiled/RTD/Node.js +2 -1
- package/transpiled/RTD/Node.js.map +1 -1
- package/transpiled/RTD/Tree.d.ts +6 -6
- package/transpiled/RTD/Tree.js +4 -1
- package/transpiled/RTD/Tree.js.map +1 -1
- package/transpiled/RTD/factory.d.ts +2 -4
- package/transpiled/RTD/factory.js.map +1 -1
- package/transpiled/directives/auth/Authorization.d.ts +2 -3
- package/transpiled/directives/auth/Authorization.js +3 -3
- package/transpiled/directives/auth/Authorization.js.map +1 -1
- package/transpiled/directives/cache/Cache.d.ts +2 -2
- package/transpiled/directives/cors/CORS.d.ts +2 -3
- package/transpiled/directives/cors/CORS.js +13 -7
- package/transpiled/directives/cors/CORS.js.map +1 -1
- package/transpiled/directives/dev/Development.d.ts +3 -3
- package/transpiled/directives/dev/Development.js.map +1 -1
- package/transpiled/directives/index.d.ts +2 -2
- package/transpiled/directives/index.js +4 -3
- package/transpiled/directives/index.js.map +1 -1
- package/transpiled/directives/io/Directive.d.ts +8 -0
- package/transpiled/directives/io/Directive.js +3 -0
- package/transpiled/directives/io/Directive.js.map +1 -0
- package/transpiled/directives/io/IO.d.ts +9 -0
- package/transpiled/directives/io/IO.js +33 -0
- package/transpiled/directives/io/IO.js.map +1 -0
- package/transpiled/directives/io/Input.d.ts +11 -0
- package/transpiled/directives/io/Input.js +63 -0
- package/transpiled/directives/io/Input.js.map +1 -0
- package/transpiled/directives/io/Message.d.ts +1 -0
- package/transpiled/directives/io/Message.js +3 -0
- package/transpiled/directives/io/Message.js.map +1 -0
- package/transpiled/directives/io/Output.d.ts +13 -0
- package/transpiled/directives/io/Output.js +76 -0
- package/transpiled/directives/io/Output.js.map +1 -0
- package/transpiled/directives/io/index.d.ts +2 -0
- package/transpiled/directives/io/index.js +6 -0
- package/transpiled/directives/io/index.js.map +1 -0
- package/transpiled/directives/io/schemas.d.ts +7 -0
- package/transpiled/directives/io/schemas.js +14 -0
- package/transpiled/directives/io/schemas.js.map +1 -0
- package/transpiled/directives/octets/Octets.d.ts +2 -3
- package/transpiled/directives/octets/Octets.js.map +1 -1
- package/transpiled/directives/octets/Store.js +7 -2
- package/transpiled/directives/octets/Store.js.map +1 -1
- package/transpiled/directives/vary/Vary.d.ts +2 -2
- package/transpiled/directives/vary/embeddings/Header.js +8 -6
- package/transpiled/directives/vary/embeddings/Header.js.map +1 -1
- package/transpiled/directives/vary/embeddings/Language.js +1 -1
- package/transpiled/directives/vary/embeddings/Language.js.map +1 -1
- package/transpiled/root.js +5 -0
- package/transpiled/root.js.map +1 -1
- package/transpiled/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { BadRequest } from '../../HTTP'
|
|
2
|
+
import * as schemas from './schemas'
|
|
3
|
+
import type { Message } from './Message'
|
|
4
|
+
import type { Directive } from './Directive'
|
|
5
|
+
import type { Input as Context } from '../../io'
|
|
6
|
+
|
|
7
|
+
export class Input implements Directive {
|
|
8
|
+
private readonly permissions: Permissions
|
|
9
|
+
|
|
10
|
+
public constructor (permissions: Permissions) {
|
|
11
|
+
this.permissions = permissions
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public static validate (permissions: unknown): asserts permissions is Permissions {
|
|
15
|
+
schemas.input.validate(permissions, 'Incorrect \'io:input\' format')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public attach (context: Context): void {
|
|
19
|
+
context.pipelines.body.push((body) => this.check(body))
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
private check (body: unknown): unknown {
|
|
23
|
+
try {
|
|
24
|
+
schemas.message.validate(body)
|
|
25
|
+
} catch {
|
|
26
|
+
throw new BadRequest('Invalid request body.')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const property = this.violation(body)
|
|
30
|
+
|
|
31
|
+
if (property !== undefined)
|
|
32
|
+
throw new BadRequest(`Unexpected input: ${property}.`)
|
|
33
|
+
|
|
34
|
+
return body
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private violation (value: Message | Message[]): string | undefined {
|
|
38
|
+
if (!Array.isArray(value))
|
|
39
|
+
return Object.keys(value).find((key) => !this.permissions.includes(key))
|
|
40
|
+
|
|
41
|
+
for (const item of value) {
|
|
42
|
+
const property = this.violation(item)
|
|
43
|
+
|
|
44
|
+
if (property !== undefined)
|
|
45
|
+
return property
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type Permissions = string[]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Message = Record<string, unknown>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Stream } from 'node:stream'
|
|
2
|
+
import * as schemas from './schemas'
|
|
3
|
+
import type { Message } from './Message'
|
|
4
|
+
import type { Directive } from './Directive'
|
|
5
|
+
import type { Input as Context } from '../../io'
|
|
6
|
+
import type { OutgoingMessage } from '../../HTTP'
|
|
7
|
+
|
|
8
|
+
export class Output implements Directive {
|
|
9
|
+
private readonly disabled: boolean = false
|
|
10
|
+
private readonly omitted: boolean = true
|
|
11
|
+
private readonly permissions: string[] = []
|
|
12
|
+
|
|
13
|
+
public constructor (permissions: Permissions) {
|
|
14
|
+
if (typeof permissions === 'boolean')
|
|
15
|
+
if (permissions)
|
|
16
|
+
this.disabled = true
|
|
17
|
+
else
|
|
18
|
+
this.omitted = false
|
|
19
|
+
|
|
20
|
+
else
|
|
21
|
+
this.permissions = permissions
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public static validate (permissions: unknown): asserts permissions is Permissions {
|
|
25
|
+
schemas.output.validate(permissions, 'Incorrect \'io:output\' format')
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public attach (context: Context): void {
|
|
29
|
+
context.pipelines.response.push(this.restriction(context))
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private restriction (context: Context) {
|
|
33
|
+
return (message: OutgoingMessage): void => {
|
|
34
|
+
const error = message.status !== undefined && message.status >= 300
|
|
35
|
+
const stream = message.body instanceof Stream
|
|
36
|
+
const none = message.body === undefined || message.body === null
|
|
37
|
+
|
|
38
|
+
if (this.disabled || error || stream || none)
|
|
39
|
+
return
|
|
40
|
+
|
|
41
|
+
if (typeof message.body !== 'object' || this.permissions.length === 0) {
|
|
42
|
+
if (this.omitted)
|
|
43
|
+
console.warn('Permissions for \'io:output\' are not specified properly ' +
|
|
44
|
+
`(${context.request.url}). Response omitted.`)
|
|
45
|
+
|
|
46
|
+
delete message.body
|
|
47
|
+
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
schemas.message.validate(message.body,
|
|
52
|
+
'\'io:output\' expects response to be an object or array of objects')
|
|
53
|
+
|
|
54
|
+
if (Array.isArray(message.body))
|
|
55
|
+
message.body = message.body.map((entity) => this.fit(entity))
|
|
56
|
+
else
|
|
57
|
+
message.body = this.fit(message.body)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private fit (message: Message): Message | undefined {
|
|
62
|
+
const entries = Object.entries(message)
|
|
63
|
+
.filter(([key]) => this.permissions.includes(key))
|
|
64
|
+
|
|
65
|
+
return Object.fromEntries(entries)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type Permissions = string[] | boolean
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { resolve } from 'node:path'
|
|
2
|
+
import schemas, { type Schema } from '@toa.io/schemas'
|
|
3
|
+
import type { Permissions as InputPermissions } from './Input'
|
|
4
|
+
import type { Permissions as OutputPermissions } from './Output'
|
|
5
|
+
import type { Message } from './Message'
|
|
6
|
+
|
|
7
|
+
const path = resolve(__dirname, '../../../schemas/io')
|
|
8
|
+
const namespace = schemas.namespace(path)
|
|
9
|
+
|
|
10
|
+
export const message: Schema<Message | Message[]> = namespace.schema('message')
|
|
11
|
+
export const input: Schema<InputPermissions> = namespace.schema('input')
|
|
12
|
+
export const output: Schema<OutputPermissions> = namespace.schema('output')
|
|
@@ -9,11 +9,10 @@ import { WorkflowDirective } from './Workflow'
|
|
|
9
9
|
import type { Output } from '../../io'
|
|
10
10
|
import type { Component } from '@toa.io/core'
|
|
11
11
|
import type { Remotes } from '../../Remotes'
|
|
12
|
-
import type {
|
|
12
|
+
import type { Parameter, DirectiveFamily } from '../../RTD'
|
|
13
13
|
import type { Directive, Input } from './types'
|
|
14
|
-
import type { Parameter } from '../../RTD'
|
|
15
14
|
|
|
16
|
-
export class Octets implements
|
|
15
|
+
export class Octets implements DirectiveFamily<Directive> {
|
|
17
16
|
public readonly name: string = 'octets'
|
|
18
17
|
public readonly mandatory: boolean = false
|
|
19
18
|
|
|
@@ -36,13 +36,19 @@ export class Store implements Directive {
|
|
|
36
36
|
|
|
37
37
|
this.discovery.storage = discovery
|
|
38
38
|
|
|
39
|
-
cors.
|
|
39
|
+
cors.allow('content-meta')
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
public async apply (storage: string, input: Input, parameters: Parameter[]): Promise<Output> {
|
|
43
43
|
this.storage ??= await this.discovery.storage
|
|
44
44
|
|
|
45
|
-
const request: StoreRequest = {
|
|
45
|
+
const request: StoreRequest = {
|
|
46
|
+
input: {
|
|
47
|
+
storage,
|
|
48
|
+
request: input.request
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
46
52
|
const meta = input.request.headers['content-meta']
|
|
47
53
|
|
|
48
54
|
if (this.accept !== undefined)
|
|
@@ -3,10 +3,10 @@ import { properties, Property } from './Properties'
|
|
|
3
3
|
import { Embed } from './Embed'
|
|
4
4
|
import type { Properties } from './Properties'
|
|
5
5
|
import type { Directive } from './Directive'
|
|
6
|
-
import type {
|
|
6
|
+
import type { DirectiveFamily } from '../../RTD'
|
|
7
7
|
import type { Input, Output } from '../../io'
|
|
8
8
|
|
|
9
|
-
export class Vary implements
|
|
9
|
+
export class Vary implements DirectiveFamily {
|
|
10
10
|
public readonly name = 'vary'
|
|
11
11
|
public readonly mandatory = false
|
|
12
12
|
|
|
@@ -6,9 +6,10 @@ export class Header implements Embedding {
|
|
|
6
6
|
private readonly name: string
|
|
7
7
|
|
|
8
8
|
public constructor (name: string) {
|
|
9
|
-
this.name = name
|
|
9
|
+
this.name = name.toLowerCase()
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
if (this.name !== 'host')
|
|
12
|
+
cors.allow(this.name)
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
public resolve (input: Input): string | undefined {
|
|
@@ -17,10 +18,11 @@ export class Header implements Embedding {
|
|
|
17
18
|
if (value === undefined)
|
|
18
19
|
return value
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
response.
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
if (this.name !== 'host')
|
|
22
|
+
input.pipelines.response.push((response) => {
|
|
23
|
+
response.headers ??= new Headers()
|
|
24
|
+
response.headers.append('vary', this.name)
|
|
25
|
+
})
|
|
24
26
|
|
|
25
27
|
if (Array.isArray(value))
|
|
26
28
|
return value.join(', ')
|
|
@@ -7,7 +7,7 @@ import type { Input } from '../../../io'
|
|
|
7
7
|
|
|
8
8
|
export class Language implements Embedding {
|
|
9
9
|
public constructor () {
|
|
10
|
-
cors.
|
|
10
|
+
cors.allow('accept-language')
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
public resolve (input: Input, properties: Properties): string | undefined {
|
package/source/root.ts
CHANGED
package/transpiled/Context.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { type Endpoint } from './Endpoint';
|
|
2
|
-
import { type Directives } from './Directive';
|
|
3
|
-
import { type Branch } from './Branch';
|
|
4
1
|
import type * as RTD from './RTD';
|
|
5
|
-
export type Context = RTD.Context<
|
|
2
|
+
export type Context = RTD.Context<Extension>;
|
|
3
|
+
interface Extension {
|
|
4
|
+
namespace: string;
|
|
5
|
+
component: string;
|
|
6
|
+
}
|
|
7
|
+
export {};
|
|
@@ -2,30 +2,17 @@ import type { Context, OutgoingMessage } from './HTTP';
|
|
|
2
2
|
import type { Remotes } from './Remotes';
|
|
3
3
|
import type { Output } from './io';
|
|
4
4
|
import type * as RTD from './RTD';
|
|
5
|
-
export declare class Directives implements RTD.Directives
|
|
5
|
+
export declare class Directives implements RTD.Directives {
|
|
6
6
|
private readonly sets;
|
|
7
|
-
constructor(sets: DirectiveSet[]);
|
|
7
|
+
constructor(sets: RTD.DirectiveSet[]);
|
|
8
8
|
preflight(context: Context, parameters: RTD.Parameter[]): Promise<Output>;
|
|
9
9
|
settle(context: Context, response: OutgoingMessage): Promise<void>;
|
|
10
|
-
merge(directives: Directives): void;
|
|
11
10
|
}
|
|
12
|
-
export declare class DirectivesFactory implements RTD.
|
|
11
|
+
export declare class DirectivesFactory implements RTD.DirectiveFactory {
|
|
13
12
|
private readonly remotes;
|
|
14
13
|
private readonly families;
|
|
15
14
|
private readonly mandatory;
|
|
16
|
-
constructor(families:
|
|
15
|
+
constructor(families: RTD.DirectiveFamily[], remotes: Remotes);
|
|
17
16
|
create(declarations: RTD.syntax.Directive[]): Directives;
|
|
18
17
|
}
|
|
19
18
|
export declare const shortcuts: RTD.syntax.Shortcuts;
|
|
20
|
-
export interface Family<TDirective = any, TExtension = any> {
|
|
21
|
-
readonly name: string;
|
|
22
|
-
readonly mandatory: boolean;
|
|
23
|
-
create: (name: string, value: any, remotes: Remotes) => TDirective;
|
|
24
|
-
preflight?: (directives: TDirective[], request: Context & TExtension, parameters: RTD.Parameter[]) => Output | Promise<Output>;
|
|
25
|
-
settle?: (directives: TDirective[], request: Context & TExtension, response: OutgoingMessage) => void | Promise<void>;
|
|
26
|
-
}
|
|
27
|
-
interface DirectiveSet {
|
|
28
|
-
family: Family;
|
|
29
|
-
directives: any[];
|
|
30
|
-
}
|
|
31
|
-
export {};
|
package/transpiled/Directive.js
CHANGED
|
@@ -23,9 +23,6 @@ class Directives {
|
|
|
23
23
|
if (set.family.settle !== undefined)
|
|
24
24
|
await set.family.settle(set.directives, context, response);
|
|
25
25
|
}
|
|
26
|
-
merge(directives) {
|
|
27
|
-
this.sets.push(...directives.sets);
|
|
28
|
-
}
|
|
29
26
|
}
|
|
30
27
|
exports.Directives = Directives;
|
|
31
28
|
class DirectivesFactory {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Directive.js","sourceRoot":"","sources":["../source/Directive.ts"],"names":[],"mappings":";;;AAKA,MAAa,UAAU;IACJ,IAAI,
|
|
1
|
+
{"version":3,"file":"Directive.js","sourceRoot":"","sources":["../source/Directive.ts"],"names":[],"mappings":";;;AAKA,MAAa,UAAU;IACJ,IAAI,CAAoB;IAEzC,YAAoB,IAAwB;QAC1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAEM,KAAK,CAAC,SAAS,CAAE,OAAgB,EAAE,UAA2B;QACnE,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC5B,IAAI,GAAG,CAAC,MAAM,CAAC,SAAS,KAAK,SAAS;gBACpC,SAAQ;YAEV,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,UAAU,CAAC,CAAA;YAE9E,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;gBACpB,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;gBAElC,OAAO,MAAM,CAAA;YACf,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,KAAK,CAAC,MAAM,CAAE,OAAgB,EAAE,QAAyB;QAC9D,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI;YACzB,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,KAAK,SAAS;gBACjC,MAAM,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAA;IAChE,CAAC;CACF;AA7BD,gCA6BC;AAED,MAAa,iBAAiB;IACX,OAAO,CAAS;IAChB,QAAQ,GAAwC,EAAE,CAAA;IAClD,SAAS,GAAa,EAAE,CAAA;IAEzC,YAAoB,QAA+B,EAAE,OAAgB;QACnE,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE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M,CAAC,IAAI,CAAC,CAAA;QAC/B,CAAC;QAED,MAAM,IAAI,GAAuB,EAAE,CAAA;QAEnC,KAAK,MAAM,MAAM,IAAI,SAAS;YAC5B,IAAI,CAAC,IAAI,CAAC;gBACR,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;gBAC7B,UAAU,EAAE,EAAE;aACf,CAAC,CAAA;QAEJ,KAAK,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;YACvD,IAAI,CAAC,IAAI,CAAC;gBACR,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;gBAC7B,UAAU;aACX,CAAC,CAAA;QAEJ,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAA;IAC7B,CAAC;CACF;AApDD,8CAoDC;AAEY,QAAA,SAAS,GAAyB,IAAI,GAAG,CAAC;IACrD,CAAC,WAAW,EAAE,gBAAgB,CAAC;IAC/B,CAAC,IAAI,EAAE,SAAS,CAAC;IACjB,CAAC,MAAM,EAAE,WAAW,CAAC;IACrB,CAAC,MAAM,EAAE,WAAW,CAAC;IACrB,CAAC,QAAQ,EAAE,aAAa,CAAC;CAC1B,CAAC,CAAA"}
|
package/transpiled/Endpoint.d.ts
CHANGED
|
@@ -4,16 +4,18 @@ import { Mapping } from './Mapping';
|
|
|
4
4
|
import { type Context } from './Context';
|
|
5
5
|
import * as http from './HTTP';
|
|
6
6
|
import type * as RTD from './RTD';
|
|
7
|
-
export declare class Endpoint implements RTD.Endpoint
|
|
7
|
+
export declare class Endpoint implements RTD.Endpoint {
|
|
8
8
|
private readonly endpoint;
|
|
9
9
|
private readonly mapping;
|
|
10
10
|
private readonly discovery;
|
|
11
11
|
private remote;
|
|
12
12
|
constructor(endpoint: string, mapping: Mapping, discovery: Promise<Component>);
|
|
13
|
-
call(
|
|
13
|
+
call(context: http.Context, parameters: RTD.Parameter[]): Promise<http.OutgoingMessage>;
|
|
14
14
|
close(): Promise<void>;
|
|
15
|
+
private query;
|
|
16
|
+
private version;
|
|
15
17
|
}
|
|
16
|
-
export declare class EndpointsFactory implements RTD.EndpointsFactory
|
|
18
|
+
export declare class EndpointsFactory implements RTD.EndpointsFactory {
|
|
17
19
|
private readonly remotes;
|
|
18
20
|
constructor(remotes: Remotes);
|
|
19
21
|
create(method: RTD.syntax.Method, context: Context): Endpoint;
|
package/transpiled/Endpoint.js
CHANGED
|
@@ -36,24 +36,48 @@ class Endpoint {
|
|
|
36
36
|
this.mapping = mapping;
|
|
37
37
|
this.discovery = discovery;
|
|
38
38
|
}
|
|
39
|
-
async call(
|
|
39
|
+
async call(context, parameters) {
|
|
40
|
+
const body = await context.body();
|
|
41
|
+
const query = this.query(context);
|
|
40
42
|
const request = this.mapping.fit(body, query, parameters);
|
|
41
43
|
this.remote ??= await this.discovery;
|
|
42
44
|
const reply = await this.remote.invoke(this.endpoint, request);
|
|
43
45
|
if (reply instanceof Error)
|
|
44
46
|
throw new http.Conflict(reply);
|
|
45
|
-
const message = {
|
|
47
|
+
const message = {};
|
|
46
48
|
if (typeof reply === 'object' && reply !== null && '_version' in reply) {
|
|
49
|
+
const etag = context.request.headers['if-none-match'];
|
|
47
50
|
message.headers ??= new Headers();
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
if (etag !== undefined && reply._version === this.version(etag)) {
|
|
52
|
+
message.status = 304;
|
|
53
|
+
message.headers.set('etag', etag);
|
|
54
|
+
return message;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
message.headers.set('etag', `"${reply._version.toString()}"`);
|
|
58
|
+
delete reply._version;
|
|
59
|
+
}
|
|
50
60
|
}
|
|
61
|
+
message.body = reply;
|
|
51
62
|
return message;
|
|
52
63
|
}
|
|
53
64
|
async close() {
|
|
54
65
|
this.remote ??= await this.discovery;
|
|
55
66
|
await this.remote.disconnect(INTERRUPT);
|
|
56
67
|
}
|
|
68
|
+
query(context) {
|
|
69
|
+
const query = Object.fromEntries(context.url.searchParams);
|
|
70
|
+
const etag = context.request.headers['if-match'];
|
|
71
|
+
if (etag !== undefined)
|
|
72
|
+
query.version = this.version(etag);
|
|
73
|
+
return query;
|
|
74
|
+
}
|
|
75
|
+
version(etag) {
|
|
76
|
+
const match = etag.match(ETAG);
|
|
77
|
+
if (match === null)
|
|
78
|
+
throw new http.BadRequest('Invalid ETag.');
|
|
79
|
+
return Number.parseInt(match.groups.version);
|
|
80
|
+
}
|
|
57
81
|
}
|
|
58
82
|
exports.Endpoint = Endpoint;
|
|
59
83
|
class EndpointsFactory {
|
|
@@ -74,5 +98,6 @@ class EndpointsFactory {
|
|
|
74
98
|
}
|
|
75
99
|
}
|
|
76
100
|
exports.EndpointsFactory = EndpointsFactory;
|
|
101
|
+
const ETAG = /^"(?<version>\d{1,32})"$/;
|
|
77
102
|
const INTERRUPT = true;
|
|
78
103
|
//# sourceMappingURL=Endpoint.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Endpoint.js","sourceRoot":"","sources":["../source/Endpoint.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,uCAAmC;AAEnC,6CAA8B;AAG9B,MAAa,QAAQ;IACF,QAAQ,CAAQ;IAChB,OAAO,CAAS;IAChB,SAAS,CAAoB;IACtC,MAAM,GAAqB,IAAI,CAAA;IAEvC,YAAoB,QAAgB,EAAE,OAAgB,EAAE,SAA6B;QACnF,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAEM,KAAK,CAAC,IAAI,CAChB,
|
|
1
|
+
{"version":3,"file":"Endpoint.js","sourceRoot":"","sources":["../source/Endpoint.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,uCAAmC;AAEnC,6CAA8B;AAG9B,MAAa,QAAQ;IACF,QAAQ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gB;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAEM,MAAM,CAAE,MAAyB,EAAE,OAAgB;QACxD,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS;YAC9B,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAA;QAE5D,MAAM,OAAO,GAAG,iBAAO,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACpD,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,EAAE,SAAS,CAAA;QAC1E,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,EAAE,SAAS,CAAA;QAE1E,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,SAAS;YACpD,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;QAElE,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;QAE7D,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;IAClE,CAAC;CACF;AAtBD,4CAsBC;AAED,MAAM,IAAI,GAAG,0BAA0B,CAAA;AAEvC,MAAM,SAAS,GAAG,IAAI,CAAA"}
|
package/transpiled/Factory.js
CHANGED
|
@@ -48,7 +48,11 @@ class Factory {
|
|
|
48
48
|
const debug = process.env.TOA_EXPOSITION_DEBUG === '1';
|
|
49
49
|
const trace = process.env.TOA_EXPOSITION_TRACE === '1';
|
|
50
50
|
const broadcast = this.boot.bindings.broadcast(CHANNEL);
|
|
51
|
-
const server = HTTP_1.Server.create({
|
|
51
|
+
const server = HTTP_1.Server.create({
|
|
52
|
+
methods: RTD_1.syntax.verbs,
|
|
53
|
+
debug,
|
|
54
|
+
trace
|
|
55
|
+
});
|
|
52
56
|
const remotes = new Remotes_1.Remotes(this.boot);
|
|
53
57
|
const node = root.resolve();
|
|
54
58
|
const methods = new Endpoint_1.EndpointsFactory(remotes);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Factory.js","sourceRoot":"","sources":["../source/Factory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAiC;AACjC,uCAAmC;AACnC,uCAAmC;AACnC,+BAAoC;AACpC,iCAA+B;AAC/B,
|
|
1
|
+
{"version":3,"file":"Factory.js","sourceRoot":"","sources":["../source/Factory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAiC;AACjC,uCAAmC;AACnC,uCAAmC;AACnC,+BAAoC;AACpC,iCAA+B;AAC/B,yCAA6C;AAC7C,6CAAqD;AACrD,2CAA+C;AAC/C,+CAA2C;AAC3C,6CAA8B;AAC9B,iDAA6C;AAI7C,MAAa,OAAO;IACD,IAAI,CAAY;IAEjC,YAAoB,IAAgB;QAClC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAEM,MAAM,CAAE,OAAgB,EAAE,IAAiB;QAChD,MAAM,SAAS,GAAc,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;QAE9E,OAAO,IAAI,eAAM,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;IAC7C,CAAC;IAEM,OAAO;QACZ,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,KAAK,GAAG,CAAA;QACtD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,KAAK,GAAG,CAAA;QACtD,MAAM,SAAS,GAAc,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;QAElE,MAAM,MAAM,GAAG,aAAM,CAAC,MAAM,CAAC;YAC3B,OAAO,EAAE,YAAM,CAAC,KAAK;YACrB,KAAK;YACL,KAAK;SACN,CAAC,CAAA;QAEF,MAAM,OAAO,GAAG,IAAI,iBAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACtC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAA;QAC3B,MAAM,OAAO,GAAG,IAAI,2BAAgB,CAAC,OAAO,CAAC,CAAA;QAC7C,MAAM,UAAU,GAAG,IAAI,6BAAiB,CAAC,qBAAQ,EAAE,OAAO,CAAC,CAAA;QAC3D,MAAM,YAAY,GAAG,IAAI,2BAAY,CAAC,yBAAY,CAAC,CAAA;QACnD,MAAM,IAAI,GAAG,IAAI,UAAI,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC,CAAA;QAEhD,MAAM,WAAW,GAAG,IAAI,yBAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC9C,MAAM,OAAO,GAAG,IAAI,iBAAO,CAAC,SAAS,EAAE,IAAI,EAAE,YAAY,CAAC,CAAA;QAE1D,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QACxB,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;QAE5B,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QAC5C,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAEvB,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AA1CD,0BA0CC;AAED,MAAM,OAAO,GAAG,YAAY,CAAA"}
|
package/transpiled/Gateway.d.ts
CHANGED
|
@@ -3,18 +3,15 @@ import * as http from './HTTP';
|
|
|
3
3
|
import type { Interception } from './Interception';
|
|
4
4
|
import type { Tree } from './RTD';
|
|
5
5
|
import type { Label } from './discovery';
|
|
6
|
-
import type { Endpoint } from './Endpoint';
|
|
7
|
-
import type { Directives } from './Directive';
|
|
8
6
|
export declare class Gateway extends Connector {
|
|
9
7
|
private readonly broadcast;
|
|
10
8
|
private readonly tree;
|
|
11
9
|
private readonly interceptor;
|
|
12
|
-
constructor(broadcast: Broadcast, tree: Tree
|
|
10
|
+
constructor(broadcast: Broadcast, tree: Tree, interception: Interception);
|
|
13
11
|
process(context: http.Context): Promise<http.OutgoingMessage>;
|
|
14
12
|
protected open(): Promise<void>;
|
|
15
13
|
protected dispose(): void;
|
|
16
14
|
private call;
|
|
17
|
-
private query;
|
|
18
15
|
private discover;
|
|
19
16
|
private merge;
|
|
20
17
|
}
|
package/transpiled/Gateway.js
CHANGED
|
@@ -31,7 +31,6 @@ class Gateway extends core_1.Connector {
|
|
|
31
31
|
broadcast;
|
|
32
32
|
tree;
|
|
33
33
|
interceptor;
|
|
34
|
-
// eslint-disable-next-line max-len
|
|
35
34
|
constructor(broadcast, tree, interception) {
|
|
36
35
|
super();
|
|
37
36
|
this.broadcast = broadcast;
|
|
@@ -70,24 +69,10 @@ class Gateway extends core_1.Connector {
|
|
|
70
69
|
throw new http.NotAcceptable();
|
|
71
70
|
if (method.endpoint === null)
|
|
72
71
|
throw new http.MethodNotAllowed();
|
|
73
|
-
const body = await context.body();
|
|
74
|
-
const query = this.query(context);
|
|
75
72
|
return await method.endpoint
|
|
76
|
-
.call(
|
|
73
|
+
.call(context, parameters)
|
|
77
74
|
.catch(exceptions_1.rethrow);
|
|
78
75
|
}
|
|
79
|
-
query(context) {
|
|
80
|
-
const query = Object.fromEntries(context.url.searchParams);
|
|
81
|
-
const etag = context.request.headers['if-match'];
|
|
82
|
-
if (etag !== undefined) {
|
|
83
|
-
const match = etag.match(ETAG);
|
|
84
|
-
if (match === null)
|
|
85
|
-
throw new http.BadRequest('Invalid ETag.');
|
|
86
|
-
else
|
|
87
|
-
query.version = parseInt(match.groups.version);
|
|
88
|
-
}
|
|
89
|
-
return query;
|
|
90
|
-
}
|
|
91
76
|
async discover() {
|
|
92
77
|
await this.broadcast.receive('expose', this.merge.bind(this));
|
|
93
78
|
await this.broadcast.transmit('ping', null);
|
|
@@ -104,5 +89,4 @@ class Gateway extends core_1.Connector {
|
|
|
104
89
|
}
|
|
105
90
|
}
|
|
106
91
|
exports.Gateway = Gateway;
|
|
107
|
-
const ETAG = /^"(?<version>\d{1,32})"$/;
|
|
108
92
|
//# sourceMappingURL=Gateway.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Gateway.js","sourceRoot":"","sources":["../source/Gateway.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAuD;AACvD,6CAA8B;AAC9B,6CAAsC;
|
|
1
|
+
{"version":3,"file":"Gateway.js","sourceRoot":"","sources":["../source/Gateway.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAuD;AACvD,6CAA8B;AAC9B,6CAAsC;AAMtC,MAAa,OAAQ,SAAQ,gBAAS;IACnB,SAAS,CAAW;IACpB,IAAI,CAAM;IACV,WAAW,CAAc;IAE1C,YAAoB,SAAoB,EAAE,IAAU,EAAE,YAA0B;QAC9E,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,WAAW,GAAG,YAAY,CAAA;QAE/B,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IACzB,CAAC;IAEM,KAAK,CAAC,OAAO,CAAE,OAAqB;QACzC,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAChE,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;QAEtC,IAAI,YAAY,KAAK,IAAI;YACvB,OAAO,YAAY,CAAA;QAErB,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QAEnD,IAAI,KAAK,KAAK,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/D,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,6BAA6B,CAAC,CAAA;QAExD,IAAI,OAAO,CAAC,OAAO,KAAK,IAAI;YAC1B,MAAM,IAAI,IAAI,CAAC,aAAa,EAAE,CAAA;QAEhC,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI;YAC1B,MAAM,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAA;QAEnC,OAAO,MAAM,MAAM,CAAC,QAAQ;aACzB,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC;aACzB,KAAK,CAAC,oBAAO,CAAyB,CAAA;IAC3C,CAAC;IAEO,KAAK,CAAC,QAAQ;QACpB,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAS,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QACrE,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAO,MAAM,EAAE,IAAI,CAAC,CAAA;IACnD,CAAC;IAEO,KAAK,CAAE,MAAc;QAC3B,IAAI,CAAC;YACH,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;YAEpC,OAAO,CAAC,IAAI,CAAC,qBAAqB;gBAChC,IAAI,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS,oBAAoB,CAAC,CAAA;QACjE,CAAC;QAAC,OAAO,SAAS,EAAE,CAAC;YACnB,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;QAC1B,CAAC;IACH,CAAC;CACF;AAzFD,0BAyFC"}
|
|
@@ -101,7 +101,7 @@ class Server extends core_1.Connector {
|
|
|
101
101
|
status = 204;
|
|
102
102
|
else
|
|
103
103
|
status = 200;
|
|
104
|
-
response.statusCode = status;
|
|
104
|
+
response.statusCode = message.status = status;
|
|
105
105
|
(0, messages_1.write)(context, response, message);
|
|
106
106
|
};
|
|
107
107
|
}
|
|
@@ -112,7 +112,7 @@ class Server extends core_1.Connector {
|
|
|
112
112
|
response.statusCode = exception instanceof exceptions_1.Exception
|
|
113
113
|
? exception.status
|
|
114
114
|
: 500;
|
|
115
|
-
const message = {};
|
|
115
|
+
const message = { status: response.statusCode };
|
|
116
116
|
const verbose = exception instanceof exceptions_1.ClientError || this.properties.debug;
|
|
117
117
|
if (verbose)
|
|
118
118
|
message.body = exception instanceof exceptions_1.Exception
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Server.js","sourceRoot":"","sources":["../../source/HTTP/Server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAwB;AACxB,sDAAwB;AACxB,gDAAiC;AACjC,8DAAgC;AAChC,6CAAkC;AAClC,uCAAwC;AACxC,6CAAwC;AACxC,yCAAwD;AACxD,6CAAqD;AACrD,uCAAmC;AAGnC,MAAa,MAAO,SAAQ,gBAAS;IAClB,MAAM,GAAgB,IAAI,CAAC,YAAY,EAAE,CAAA;IACzC,UAAU,CAAY;IAC/B,OAAO,CAAa;IAE5B,YAAqB,UAAsB;QACzC,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAE5B,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;IAClE,CAAC;IAED,IAAW,IAAI;QACb,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC;YAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAA;QAE7B,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAA;QAErC,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ;YACjD,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;QAEvD,OAAO,OAAO,C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,CAAE,OAA6B;IAChD,MAAM,SAAS,GAAG,IAAA,gBAAM,GAAE,CAAA;IAC1B,MAAM,OAAO,GAAG,iBAAE,CAAC,iBAAiB,CAAC,iBAAE,CAAC,OAAO,CAAC,CAAA;IAEhD,OAAO;SACJ,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,QAAQ,CAAC;SAC7B,IAAI,CAAC,OAAO,CAAC,CAAA;IAEhB,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,MAAM,QAAQ,GAAe;IAC3B,OAAO,EAAE,IAAI,GAAG,CAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC9E,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,KAAK;IACZ,IAAI,EAAE,IAAI;CACX,CAAA"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type
|
|
3
|
-
|
|
1
|
+
import { type DirectiveFactory } from './Directives';
|
|
2
|
+
import { type EndpointsFactory } from './Endpoint';
|
|
3
|
+
import type { Directive } from './syntax';
|
|
4
|
+
export interface Context<TExtension = any> {
|
|
4
5
|
readonly protected: boolean;
|
|
5
|
-
readonly endpoints: EndpointsFactory
|
|
6
|
+
readonly endpoints: EndpointsFactory;
|
|
6
7
|
readonly directives: {
|
|
7
|
-
readonly factory:
|
|
8
|
-
stack:
|
|
8
|
+
readonly factory: DirectiveFactory;
|
|
9
|
+
stack: Directive[];
|
|
9
10
|
};
|
|
10
11
|
readonly extension?: TExtension;
|
|
11
12
|
}
|
|
@@ -1,7 +1,22 @@
|
|
|
1
|
+
import type { Parameter } from './Match';
|
|
1
2
|
import type * as syntax from './syntax';
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
import type { Context, OutgoingMessage } from '../HTTP';
|
|
4
|
+
import type { Output } from '../io';
|
|
5
|
+
export interface Directives {
|
|
6
|
+
preflight: (context: Context, parameters: Parameter[]) => Promise<Output>;
|
|
7
|
+
settle: (context: Context, response: OutgoingMessage) => Promise<void>;
|
|
4
8
|
}
|
|
5
|
-
export interface
|
|
6
|
-
create: (directives: syntax.Directive[]) =>
|
|
9
|
+
export interface DirectiveFactory {
|
|
10
|
+
create: (directives: syntax.Directive[]) => Directives;
|
|
11
|
+
}
|
|
12
|
+
export interface DirectiveSet {
|
|
13
|
+
family: DirectiveFamily;
|
|
14
|
+
directives: any[];
|
|
15
|
+
}
|
|
16
|
+
export interface DirectiveFamily<TDirective = any, TExtension = any> {
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly mandatory: boolean;
|
|
19
|
+
create: (name: string, ...rest: any[]) => TDirective;
|
|
20
|
+
preflight?: (directives: TDirective[], request: Context & TExtension, parameters: Parameter[]) => Output | Promise<Output>;
|
|
21
|
+
settle?: (directives: TDirective[], request: Context & TExtension, response: OutgoingMessage) => void | Promise<void>;
|
|
7
22
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type Context } from './Context';
|
|
2
|
+
import type * as http from '../HTTP';
|
|
2
3
|
import type * as syntax from './syntax';
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
import type * as RTD from './index';
|
|
5
|
+
export interface Endpoint {
|
|
6
|
+
call: (context: http.Context, parameters: RTD.Parameter[]) => Promise<http.OutgoingMessage>;
|
|
5
7
|
close: () => Promise<void>;
|
|
6
8
|
}
|
|
7
|
-
export interface EndpointsFactory
|
|
8
|
-
create: (method: syntax.Method, context: Context) =>
|
|
9
|
+
export interface EndpointsFactory {
|
|
10
|
+
create: (method: syntax.Method, context: Context) => Endpoint;
|
|
9
11
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { type Node } from './Node';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export interface Match<TEndpoint extends Endpoint<TEndpoint> = any, TDirectives extends Directives<TDirectives> = any> {
|
|
5
|
-
node: Node<TEndpoint, TDirectives>;
|
|
2
|
+
export interface Match {
|
|
3
|
+
node: Node;
|
|
6
4
|
parameters: Parameter[];
|
|
7
5
|
}
|
|
8
6
|
export interface Parameter {
|