@toa.io/extensions.exposition 1.0.0-alpha.4 → 1.0.0-alpha.5
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/features/cors.feature +2 -2
- package/features/etag.feature +11 -1
- package/package.json +7 -7
- 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/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 +2 -3
- 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 +2 -2
- 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 +1 -1
- package/source/directives/vary/embeddings/Language.ts +1 -1
- 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/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.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.map +1 -1
- 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 +1 -1
- 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/tsconfig.tsbuildinfo +1 -1
|
@@ -3,16 +3,22 @@ import type { Interceptor } from '../../Interception'
|
|
|
3
3
|
|
|
4
4
|
export class CORS implements Interceptor {
|
|
5
5
|
public readonly name = 'cors'
|
|
6
|
-
public readonly mandatory = true
|
|
7
6
|
|
|
8
|
-
private readonly
|
|
7
|
+
private readonly requestHeaders = new Set<string>([
|
|
8
|
+
'accept',
|
|
9
|
+
'authorization',
|
|
10
|
+
'content-type',
|
|
11
|
+
'etag',
|
|
12
|
+
'if-match',
|
|
13
|
+
'if-none-match'
|
|
14
|
+
])
|
|
9
15
|
|
|
10
16
|
private readonly headers = new Headers({
|
|
11
17
|
'access-control-allow-methods': 'GET, POST, PUT, PATCH, DELETE',
|
|
12
18
|
'access-control-allow-credentials': 'true',
|
|
13
|
-
'access-control-allow-headers': Array.from(this.
|
|
19
|
+
'access-control-allow-headers': Array.from(this.requestHeaders).join(', '),
|
|
14
20
|
'access-control-max-age': '3600',
|
|
15
|
-
'cache-control': '
|
|
21
|
+
'cache-control': 'max-age=3600',
|
|
16
22
|
vary: 'origin'
|
|
17
23
|
})
|
|
18
24
|
|
|
@@ -40,9 +46,9 @@ export class CORS implements Interceptor {
|
|
|
40
46
|
return null
|
|
41
47
|
}
|
|
42
48
|
|
|
43
|
-
public
|
|
44
|
-
this.
|
|
45
|
-
this.headers.set('access-control-allow-headers', Array.from(this.
|
|
49
|
+
public allow (header: string): void {
|
|
50
|
+
this.requestHeaders.add(header.toLowerCase())
|
|
51
|
+
this.headers.set('access-control-allow-headers', Array.from(this.requestHeaders).join(', '))
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
private preflightResponse (origin: string): Output {
|
|
@@ -2,13 +2,13 @@ import { Stub } from './Stub'
|
|
|
2
2
|
import { Throw } from './Throw'
|
|
3
3
|
import { type Directive } from './types'
|
|
4
4
|
import type { Input, Output } from '../../io'
|
|
5
|
-
import type {
|
|
5
|
+
import type { DirectiveFamily } from '../../RTD'
|
|
6
6
|
|
|
7
|
-
export class Development implements
|
|
7
|
+
export class Development implements DirectiveFamily<Directive> {
|
|
8
8
|
public readonly name: string = 'dev'
|
|
9
9
|
public readonly mandatory: boolean = false
|
|
10
10
|
|
|
11
|
-
public create (name: string, value:
|
|
11
|
+
public create (name: string, value: unknown): Directive {
|
|
12
12
|
const Class = constructors[name]
|
|
13
13
|
|
|
14
14
|
if (Class === undefined)
|
|
@@ -4,8 +4,8 @@ import { cache } from './cache'
|
|
|
4
4
|
import { octets } from './octets'
|
|
5
5
|
import { cors } from './cors'
|
|
6
6
|
import { vary } from './vary'
|
|
7
|
-
import type {
|
|
7
|
+
import type { DirectiveFamily } from '../RTD'
|
|
8
8
|
import type { Interceptor } from '../Interception'
|
|
9
9
|
|
|
10
|
-
export const families:
|
|
10
|
+
export const families: DirectiveFamily[] = [authorization, cache, octets, vary, dev]
|
|
11
11
|
export const interceptors: Interceptor[] = [cors]
|
|
@@ -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
|
|
|
@@ -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/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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,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,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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AAM,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":";;;;;;;;;;;;;;;;;;;;;;;;;;AAA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I,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,IAAI;YAChB,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAA;QAE3B,MAAM,EACJ,IAAI,EACJ,UAAU,EACX,GAAG,KAAK,CAAA;QAET,IAAI,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC;YAC3C,MAAM,IAAI,IAAI,CAAC,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BAAgB,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"}
|
|
@@ -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 {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare class Method
|
|
4
|
-
readonly endpoint:
|
|
5
|
-
readonly directives:
|
|
6
|
-
constructor(endpoint:
|
|
1
|
+
import type { Endpoint } from './Endpoint';
|
|
2
|
+
import type { Directives } from './Directives';
|
|
3
|
+
export declare class Method {
|
|
4
|
+
readonly endpoint: Endpoint | null;
|
|
5
|
+
readonly directives: Directives;
|
|
6
|
+
constructor(endpoint: Endpoint | null, directives: Directives);
|
|
7
7
|
close(): Promise<void>;
|
|
8
8
|
}
|
|
9
|
-
export type Methods
|
|
9
|
+
export type Methods = Record<string, Method>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Method.js","sourceRoot":"","sources":["../../source/RTD/Method.ts"],"names":[],"mappings":";;;AAGA,MAAa,MAAM;
|
|
1
|
+
{"version":3,"file":"Method.js","sourceRoot":"","sources":["../../source/RTD/Method.ts"],"names":[],"mappings":";;;AAGA,MAAa,MAAM;IACD,QAAQ,CAAiB;IACzB,UAAU,CAAY;IAEtC,YAAoB,QAAyB,EAAE,UAAsB;QACnE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;IAEM,KAAK,CAAC,KAAK;QAChB,MAAM,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAA;IAC9B,CAAC;CACF;AAZD,wBAYC"}
|
package/transpiled/RTD/Node.d.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { type Route } from './Route';
|
|
2
2
|
import { type Methods } from './Method';
|
|
3
3
|
import { type Match, type Parameter } from './Match';
|
|
4
|
-
|
|
5
|
-
import { type Endpoint } from './Endpoint';
|
|
6
|
-
export declare class Node<TEndpoint extends Endpoint<TEndpoint> = any, TDirectives extends Directives<TDirectives> = any> {
|
|
4
|
+
export declare class Node {
|
|
7
5
|
intermediate: boolean;
|
|
8
|
-
methods: Methods
|
|
6
|
+
methods: Methods;
|
|
9
7
|
private readonly protected;
|
|
10
8
|
private routes;
|
|
11
|
-
constructor(routes: Route[], methods: Methods
|
|
9
|
+
constructor(routes: Route[], methods: Methods, properties: Properties);
|
|
12
10
|
match(fragments: string[], parameters?: Parameter[]): Match | null;
|
|
13
|
-
merge(node: Node
|
|
11
|
+
merge(node: Node): void;
|
|
14
12
|
private replace;
|
|
15
13
|
private append;
|
|
16
14
|
private mergeRoute;
|
package/transpiled/RTD/Node.js
CHANGED
|
@@ -34,7 +34,8 @@ class Node {
|
|
|
34
34
|
this.routes = node.routes;
|
|
35
35
|
this.methods = node.methods;
|
|
36
36
|
for (const method of methods)
|
|
37
|
-
void method.close();
|
|
37
|
+
void method.close();
|
|
38
|
+
// race condition is really unlikely
|
|
38
39
|
}
|
|
39
40
|
append(node) {
|
|
40
41
|
for (const route of node.routes)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Node.js","sourceRoot":"","sources":["../../source/RTD/Node.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Node.js","sourceRoot":"","sources":["../../source/RTD/Node.ts"],"names":[],"mappings":";;;AAIA,MAAa,IAAI;IACR,YAAY,CAAS;IACrB,OAAO,CAAS;IACN,SAAS,CAAS;IAC3B,MAAM,CAAS;IAEvB,YACC,MAAe,EAAE,OAAgB,EAAE,UAAsB;QACxD,IAAI,CAAC,MAAM,GAAG,MAAM,CAA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7B,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;QAExB,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;YACvD,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO;gBACtB,OAAO,CAAC,IAAI,CAAC,sCAAsC,IAAI,oBAAoB,CAAC,CAAA;;gBAE5E,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAA;IACjC,CAAC;IAEO,UAAU,CAAE,SAAgB;QAClC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM;YAC7B,IAAI,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC5B,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;gBAEtB,OAAM;YACR,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAC7B,CAAC;IAEO,IAAI;QACV,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC,CAAA;IACvD,CAAC;CACF;AA3ED,oBA2EC"}
|
package/transpiled/RTD/Tree.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import type { Match } from './Match';
|
|
2
|
+
import type { DirectiveFactory } from './Directives';
|
|
3
|
+
import type { EndpointsFactory } from './Endpoint';
|
|
4
4
|
import type * as syntax from './syntax';
|
|
5
|
-
export declare class Tree
|
|
5
|
+
export declare class Tree {
|
|
6
6
|
private readonly root;
|
|
7
7
|
private readonly trunk;
|
|
8
8
|
private readonly endpoints;
|
|
9
9
|
private readonly directives;
|
|
10
|
-
constructor(node: syntax.Node, endpoints: EndpointsFactory, directives:
|
|
11
|
-
match(path: string): Match
|
|
10
|
+
constructor(node: syntax.Node, endpoints: EndpointsFactory, directives: DirectiveFactory);
|
|
11
|
+
match(path: string): Match | null;
|
|
12
12
|
merge(node: syntax.Node, extension: any): void;
|
|
13
13
|
private createNode;
|
|
14
14
|
}
|
package/transpiled/RTD/Tree.js
CHANGED
|
@@ -16,7 +16,10 @@ class Tree {
|
|
|
16
16
|
}
|
|
17
17
|
match(path) {
|
|
18
18
|
if (path === '/')
|
|
19
|
-
return {
|
|
19
|
+
return {
|
|
20
|
+
node: this.trunk,
|
|
21
|
+
parameters: []
|
|
22
|
+
};
|
|
20
23
|
const fragments = (0, segment_1.fragment)(path);
|
|
21
24
|
return this.trunk.match(fragments);
|
|
22
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tree.js","sourceRoot":"","sources":["../../source/RTD/Tree.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Tree.js","sourceRoot":"","sources":["../../source/RTD/Tree.ts"],"names":[],"mappings":";;;AAAA,uCAAsC;AACtC,uCAAoC;AAQpC,MAAa,IAAI;IACE,IAAI,CAAa;IACjB,KAAK,CAAM;IACX,SAAS,CAAkB;IAC3B,UAAU,CAAkB;IAE7C,YACC,IAAiB,EAAE,SAA2B,EAAE,UAA4B;QAC3E,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;QAC7C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAEM,KAAK,CAAE,IAAY;QACxB,IAAI,IAAI,KAAK,GAAG;YACd,OAAO;gBACL,IAAI,EAAE,IAAI,CAAC,KAAK;gBAChB,UAAU,EAAE,EAAE;aACf,CAAA;QAEH,MAAM,SAAS,GAAG,IAAA,kBAAQ,EAAC,IAAI,CAAC,CAAA;QAEhC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;IACpC,CAAC;IAEM,KAAK,CAAE,IAAiB,EAAE,SAAc;QAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;QAE3D,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAC1B,CAAC;IAEO,UAAU,CACjB,IAAiB,EAAE,OAAgB,EAAE,SAAe;QACnD,MAAM,OAAO,GAAY;YACvB,SAAS,EAAE,OAAO;YAClB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,UAAU,EAAE;gBACV,OAAO,EAAE,IAAI,CAAC,UAAU;gBACxB,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,IAAI,EAAE;aACnC;YACD,SAAS;SACV,CAAA;QAED,OAAO,IAAA,oBAAU,EAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAClC,CAAC;CACF;AA9CD,oBA8CC;AAED,MAAM,SAAS,GAAG,IAAI,CAAA"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { Node } from './Node';
|
|
2
|
-
import {
|
|
3
|
-
import { type Endpoint } from './Endpoint';
|
|
4
|
-
import { type Directives } from './Directives';
|
|
2
|
+
import type { Context } from './Context';
|
|
5
3
|
import type * as syntax from './syntax';
|
|
6
|
-
export declare function createNode
|
|
4
|
+
export declare function createNode(node: syntax.Node, context: Context): Node;
|