@toa.io/extensions.exposition 0.23.0-dev.0 → 0.24.0-alpha.10
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 +1 -1
- package/components/identity.basic/operations/authenticate.d.ts +9 -0
- package/components/identity.basic/operations/authenticate.js +25 -0
- package/components/identity.basic/operations/authenticate.js.map +1 -0
- package/components/identity.basic/operations/create.d.ts +10 -0
- package/components/identity.basic/operations/create.js +10 -0
- package/components/identity.basic/operations/create.js.map +1 -0
- package/components/identity.basic/operations/transit.d.ts +12 -0
- package/components/identity.basic/operations/transit.js +53 -0
- package/components/identity.basic/operations/transit.js.map +1 -0
- package/components/identity.basic/operations/tsconfig.tsbuildinfo +1 -0
- package/components/identity.basic/operations/types.d.ts +38 -0
- package/components/identity.basic/operations/types.js +3 -0
- package/components/identity.basic/operations/types.js.map +1 -0
- package/components/identity.roles/operations/list.d.ts +5 -0
- package/components/identity.roles/operations/list.js +8 -0
- package/components/identity.roles/operations/list.js.map +1 -0
- package/components/identity.roles/operations/principal.d.ts +15 -0
- package/components/identity.roles/operations/principal.js +8 -0
- package/components/identity.roles/operations/principal.js.map +1 -0
- package/components/identity.roles/operations/tsconfig.tsbuildinfo +1 -0
- package/components/identity.tokens/operations/authenticate.d.ts +9 -0
- package/components/identity.tokens/operations/authenticate.js +32 -0
- package/components/identity.tokens/operations/authenticate.js.map +1 -0
- package/components/identity.tokens/operations/decrypt.d.ts +3 -0
- package/components/identity.tokens/operations/decrypt.js +32 -0
- package/components/identity.tokens/operations/decrypt.js.map +1 -0
- package/components/identity.tokens/operations/encrypt.d.ts +8 -0
- package/components/identity.tokens/operations/encrypt.js +22 -0
- package/components/identity.tokens/operations/encrypt.js.map +1 -0
- package/components/identity.tokens/operations/revoke.d.ts +2 -0
- package/components/identity.tokens/operations/revoke.js +8 -0
- package/components/identity.tokens/operations/revoke.js.map +1 -0
- package/components/identity.tokens/operations/tsconfig.tsbuildinfo +1 -0
- package/components/identity.tokens/operations/types.d.ts +40 -0
- package/components/identity.tokens/operations/types.js +3 -0
- package/components/identity.tokens/operations/types.js.map +1 -0
- package/documentation/access.md +2 -3
- package/documentation/cache.md +42 -0
- package/documentation/components.md +1 -1
- package/documentation/octets.md +3 -3
- package/documentation/tree.md +1 -5
- package/features/cache.feature +160 -0
- package/features/steps/HTTP.ts +13 -80
- package/features/steps/Parameters.ts +1 -2
- package/features/steps/Workspace.ts +5 -3
- package/package.json +15 -12
- package/readme.md +1 -0
- package/source/HTTP/Server.test.ts +5 -3
- package/source/HTTP/Server.ts +30 -18
- package/source/HTTP/messages.ts +4 -4
- package/source/RTD/syntax/parse.ts +2 -1
- package/source/Tenant.ts +5 -0
- package/source/directives/auth/Family.ts +2 -2
- package/source/directives/cache/Control.ts +59 -0
- package/source/directives/cache/Exact.ts +7 -0
- package/source/directives/cache/Family.ts +36 -0
- package/source/directives/cache/index.ts +3 -0
- package/source/directives/cache/types.ts +9 -0
- package/source/directives/index.ts +2 -1
- package/source/directives/octets/Fetch.ts +3 -3
- package/transpiled/Annotation.d.ts +7 -0
- package/transpiled/Annotation.js +3 -0
- package/transpiled/Annotation.js.map +1 -0
- package/transpiled/Branch.d.ts +7 -0
- package/transpiled/Branch.js +3 -0
- package/transpiled/Branch.js.map +1 -0
- package/transpiled/Composition.d.ts +14 -0
- package/transpiled/Composition.js +43 -0
- package/transpiled/Composition.js.map +1 -0
- package/transpiled/Context.d.ts +5 -0
- package/transpiled/Context.js +3 -0
- package/transpiled/Context.js.map +1 -0
- package/transpiled/Directive.d.ts +32 -0
- package/transpiled/Directive.js +76 -0
- package/transpiled/Directive.js.map +1 -0
- package/transpiled/Endpoint.d.ts +20 -0
- package/transpiled/Endpoint.js +45 -0
- package/transpiled/Endpoint.js.map +1 -0
- package/transpiled/Factory.d.ts +10 -0
- package/transpiled/Factory.js +66 -0
- package/transpiled/Factory.js.map +1 -0
- package/transpiled/Gateway.d.ts +19 -0
- package/transpiled/Gateway.js +92 -0
- package/transpiled/Gateway.js.map +1 -0
- package/transpiled/HTTP/Server.d.ts +22 -0
- package/transpiled/HTTP/Server.fixtures.d.ts +11 -0
- package/transpiled/HTTP/Server.fixtures.js +32 -0
- package/transpiled/HTTP/Server.fixtures.js.map +1 -0
- package/transpiled/HTTP/Server.js +131 -0
- package/transpiled/HTTP/Server.js.map +1 -0
- package/transpiled/HTTP/exceptions.d.ts +34 -0
- package/transpiled/HTTP/exceptions.js +71 -0
- package/transpiled/HTTP/exceptions.js.map +1 -0
- package/transpiled/HTTP/formats/index.d.ts +10 -0
- package/transpiled/HTTP/formats/index.js +38 -0
- package/transpiled/HTTP/formats/index.js.map +1 -0
- package/transpiled/HTTP/formats/json.d.ts +6 -0
- package/transpiled/HTTP/formats/json.js +17 -0
- package/transpiled/HTTP/formats/json.js.map +1 -0
- package/transpiled/HTTP/formats/msgpack.d.ts +6 -0
- package/transpiled/HTTP/formats/msgpack.js +38 -0
- package/transpiled/HTTP/formats/msgpack.js.map +1 -0
- package/transpiled/HTTP/formats/text.d.ts +6 -0
- package/transpiled/HTTP/formats/text.js +15 -0
- package/transpiled/HTTP/formats/text.js.map +1 -0
- package/transpiled/HTTP/formats/yaml.d.ts +6 -0
- package/transpiled/HTTP/formats/yaml.js +41 -0
- package/transpiled/HTTP/formats/yaml.js.map +1 -0
- package/transpiled/HTTP/index.d.ts +3 -0
- package/transpiled/HTTP/index.js +20 -0
- package/transpiled/HTTP/index.js.map +1 -0
- package/transpiled/HTTP/messages.d.ts +28 -0
- package/transpiled/HTTP/messages.js +70 -0
- package/transpiled/HTTP/messages.js.map +1 -0
- package/transpiled/Mapping.d.ts +8 -0
- package/transpiled/Mapping.js +38 -0
- package/transpiled/Mapping.js.map +1 -0
- package/transpiled/Query.d.ts +13 -0
- package/transpiled/Query.js +107 -0
- package/transpiled/Query.js.map +1 -0
- package/transpiled/RTD/Context.d.ts +11 -0
- package/transpiled/RTD/Context.js +3 -0
- package/transpiled/RTD/Context.js.map +1 -0
- package/transpiled/RTD/Directives.d.ts +7 -0
- package/transpiled/RTD/Directives.js +3 -0
- package/transpiled/RTD/Directives.js.map +1 -0
- package/transpiled/RTD/Endpoint.d.ts +9 -0
- package/transpiled/RTD/Endpoint.js +3 -0
- package/transpiled/RTD/Endpoint.js.map +1 -0
- package/transpiled/RTD/Match.d.ts +11 -0
- package/transpiled/RTD/Match.js +3 -0
- package/transpiled/RTD/Match.js.map +1 -0
- package/transpiled/RTD/Method.d.ts +9 -0
- package/transpiled/RTD/Method.js +16 -0
- package/transpiled/RTD/Method.js.map +1 -0
- package/transpiled/RTD/Node.d.ts +21 -0
- package/transpiled/RTD/Node.js +61 -0
- package/transpiled/RTD/Node.js.map +1 -0
- package/transpiled/RTD/Route.d.ts +14 -0
- package/transpiled/RTD/Route.js +49 -0
- package/transpiled/RTD/Route.js.map +1 -0
- package/transpiled/RTD/Tree.d.ts +14 -0
- package/transpiled/RTD/Tree.js +40 -0
- package/transpiled/RTD/Tree.js.map +1 -0
- package/transpiled/RTD/factory.d.ts +6 -0
- package/transpiled/RTD/factory.js +36 -0
- package/transpiled/RTD/factory.js.map +1 -0
- package/transpiled/RTD/index.d.ts +8 -0
- package/transpiled/RTD/index.js +38 -0
- package/transpiled/RTD/index.js.map +1 -0
- package/transpiled/RTD/segment.d.ts +8 -0
- package/transpiled/RTD/segment.js +25 -0
- package/transpiled/RTD/segment.js.map +1 -0
- package/transpiled/RTD/syntax/index.d.ts +2 -0
- package/transpiled/RTD/syntax/index.js +19 -0
- package/transpiled/RTD/syntax/index.js.map +1 -0
- package/transpiled/RTD/syntax/parse.d.ts +4 -0
- package/transpiled/RTD/syntax/parse.js +128 -0
- package/transpiled/RTD/syntax/parse.js.map +1 -0
- package/transpiled/RTD/syntax/types.d.ts +41 -0
- package/transpiled/RTD/syntax/types.js +5 -0
- package/transpiled/RTD/syntax/types.js.map +1 -0
- package/transpiled/Remotes.d.ts +9 -0
- package/transpiled/Remotes.js +25 -0
- package/transpiled/Remotes.js.map +1 -0
- package/transpiled/Tenant.d.ts +13 -0
- package/transpiled/Tenant.js +34 -0
- package/transpiled/Tenant.js.map +1 -0
- package/transpiled/deployment.d.ts +3 -0
- package/transpiled/deployment.js +67 -0
- package/transpiled/deployment.js.map +1 -0
- package/transpiled/directives/auth/Anonymous.d.ts +6 -0
- package/transpiled/directives/auth/Anonymous.js +17 -0
- package/transpiled/directives/auth/Anonymous.js.map +1 -0
- package/transpiled/directives/auth/Echo.d.ts +6 -0
- package/transpiled/directives/auth/Echo.js +13 -0
- package/transpiled/directives/auth/Echo.js.map +1 -0
- package/transpiled/directives/auth/Family.d.ts +20 -0
- package/transpiled/directives/auth/Family.js +118 -0
- package/transpiled/directives/auth/Family.js.map +1 -0
- package/transpiled/directives/auth/Id.d.ts +7 -0
- package/transpiled/directives/auth/Id.js +17 -0
- package/transpiled/directives/auth/Id.js.map +1 -0
- package/transpiled/directives/auth/Incept.d.ts +10 -0
- package/transpiled/directives/auth/Incept.js +58 -0
- package/transpiled/directives/auth/Incept.js.map +1 -0
- package/transpiled/directives/auth/Role.d.ts +11 -0
- package/transpiled/directives/auth/Role.js +44 -0
- package/transpiled/directives/auth/Role.js.map +1 -0
- package/transpiled/directives/auth/Rule.d.ts +9 -0
- package/transpiled/directives/auth/Rule.js +22 -0
- package/transpiled/directives/auth/Rule.js.map +1 -0
- package/transpiled/directives/auth/Scheme.d.ts +7 -0
- package/transpiled/directives/auth/Scheme.js +47 -0
- package/transpiled/directives/auth/Scheme.js.map +1 -0
- package/transpiled/directives/auth/index.d.ts +2 -0
- package/transpiled/directives/auth/index.js +7 -0
- package/transpiled/directives/auth/index.js.map +1 -0
- package/transpiled/directives/auth/schemes.d.ts +3 -0
- package/transpiled/directives/auth/schemes.js +9 -0
- package/transpiled/directives/auth/schemes.js.map +1 -0
- package/transpiled/directives/auth/split.d.ts +2 -0
- package/transpiled/directives/auth/split.js +38 -0
- package/transpiled/directives/auth/split.js.map +1 -0
- package/transpiled/directives/auth/types.d.ts +31 -0
- package/transpiled/directives/auth/types.js +3 -0
- package/transpiled/directives/auth/types.js.map +1 -0
- package/transpiled/directives/cache/Control.d.ts +9 -0
- package/transpiled/directives/cache/Control.js +42 -0
- package/transpiled/directives/cache/Control.js.map +1 -0
- package/transpiled/directives/cache/Exact.d.ts +4 -0
- package/transpiled/directives/cache/Exact.js +11 -0
- package/transpiled/directives/cache/Exact.js.map +1 -0
- package/transpiled/directives/cache/Family.d.ts +12 -0
- package/transpiled/directives/cache/Family.js +26 -0
- package/transpiled/directives/cache/Family.js.map +1 -0
- package/transpiled/directives/cache/index.d.ts +2 -0
- package/transpiled/directives/cache/index.js +7 -0
- package/transpiled/directives/cache/index.js.map +1 -0
- package/transpiled/directives/cache/types.d.ts +7 -0
- package/transpiled/directives/cache/types.js +3 -0
- package/transpiled/directives/cache/types.js.map +1 -0
- package/transpiled/directives/dev/Family.d.ts +10 -0
- package/transpiled/directives/dev/Family.js +27 -0
- package/transpiled/directives/dev/Family.js.map +1 -0
- package/transpiled/directives/dev/Stub.d.ts +7 -0
- package/transpiled/directives/dev/Stub.js +14 -0
- package/transpiled/directives/dev/Stub.js.map +1 -0
- package/transpiled/directives/dev/Throw.d.ts +7 -0
- package/transpiled/directives/dev/Throw.js +14 -0
- package/transpiled/directives/dev/Throw.js.map +1 -0
- package/transpiled/directives/dev/index.d.ts +2 -0
- package/transpiled/directives/dev/index.js +7 -0
- package/transpiled/directives/dev/index.js.map +1 -0
- package/transpiled/directives/dev/types.d.ts +4 -0
- package/transpiled/directives/dev/types.js +3 -0
- package/transpiled/directives/dev/types.js.map +1 -0
- package/transpiled/directives/index.d.ts +2 -0
- package/transpiled/directives/index.js +12 -0
- package/transpiled/directives/index.js.map +1 -0
- package/transpiled/directives/octets/Context.d.ts +8 -0
- package/transpiled/directives/octets/Context.js +40 -0
- package/transpiled/directives/octets/Context.js.map +1 -0
- package/transpiled/directives/octets/Delete.d.ts +10 -0
- package/transpiled/directives/octets/Delete.js +47 -0
- package/transpiled/directives/octets/Delete.js.map +1 -0
- package/transpiled/directives/octets/Family.d.ts +12 -0
- package/transpiled/directives/octets/Family.js +49 -0
- package/transpiled/directives/octets/Family.js.map +1 -0
- package/transpiled/directives/octets/Fetch.d.ts +18 -0
- package/transpiled/directives/octets/Fetch.js +77 -0
- package/transpiled/directives/octets/Fetch.js.map +1 -0
- package/transpiled/directives/octets/List.d.ts +10 -0
- package/transpiled/directives/octets/List.js +47 -0
- package/transpiled/directives/octets/List.js.map +1 -0
- package/transpiled/directives/octets/Permute.d.ts +10 -0
- package/transpiled/directives/octets/Permute.js +51 -0
- package/transpiled/directives/octets/Permute.js.map +1 -0
- package/transpiled/directives/octets/Store.d.ts +33 -0
- package/transpiled/directives/octets/Store.js +124 -0
- package/transpiled/directives/octets/Store.js.map +1 -0
- package/transpiled/directives/octets/index.d.ts +2 -0
- package/transpiled/directives/octets/index.js +7 -0
- package/transpiled/directives/octets/index.js.map +1 -0
- package/transpiled/directives/octets/schemas.d.ts +6 -0
- package/transpiled/directives/octets/schemas.js +17 -0
- package/transpiled/directives/octets/schemas.js.map +1 -0
- package/transpiled/directives/octets/types.d.ts +9 -0
- package/transpiled/directives/octets/types.js +3 -0
- package/transpiled/directives/octets/types.js.map +1 -0
- package/transpiled/discovery.d.ts +1 -0
- package/transpiled/discovery.js +3 -0
- package/transpiled/discovery.js.map +1 -0
- package/transpiled/exceptions.d.ts +2 -0
- package/transpiled/exceptions.js +39 -0
- package/transpiled/exceptions.js.map +1 -0
- package/transpiled/index.d.ts +5 -0
- package/transpiled/index.js +12 -0
- package/transpiled/index.js.map +1 -0
- package/transpiled/manifest.d.ts +3 -0
- package/transpiled/manifest.js +61 -0
- package/transpiled/manifest.js.map +1 -0
- package/transpiled/root.d.ts +2 -0
- package/transpiled/root.js +39 -0
- package/transpiled/root.js.map +1 -0
- package/transpiled/schemas.d.ts +3 -0
- package/transpiled/schemas.js +14 -0
- package/transpiled/schemas.js.map +1 -0
- package/transpiled/tsconfig.tsbuildinfo +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/extensions.exposition",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0-alpha.10",
|
|
4
4
|
"description": "Toa Exposition",
|
|
5
5
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/toa-io/toa#readme",
|
|
@@ -17,11 +17,10 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@toa.io/core": "0.
|
|
21
|
-
"@toa.io/generic": "0.
|
|
22
|
-
"@toa.io/
|
|
23
|
-
"@toa.io/
|
|
24
|
-
"@toa.io/streams": "0.23.0-dev.0",
|
|
20
|
+
"@toa.io/core": "0.24.0-alpha.10",
|
|
21
|
+
"@toa.io/generic": "0.24.0-alpha.10",
|
|
22
|
+
"@toa.io/schemas": "0.24.0-alpha.10",
|
|
23
|
+
"@toa.io/streams": "0.24.0-alpha.10",
|
|
25
24
|
"bcryptjs": "2.4.3",
|
|
26
25
|
"cors": "2.8.5",
|
|
27
26
|
"error-value": "0.3.0",
|
|
@@ -38,17 +37,21 @@
|
|
|
38
37
|
},
|
|
39
38
|
"scripts": {
|
|
40
39
|
"test": "jest",
|
|
41
|
-
"transpile": "
|
|
42
|
-
"transpile:basic": "
|
|
43
|
-
"transpile:tokens": "
|
|
40
|
+
"transpile": "npx tsc && npm run transpile:basic && npm run transpile:tokens && npm run transpile:roles",
|
|
41
|
+
"transpile:basic": "npx tsc -p ./components/identity.basic",
|
|
42
|
+
"transpile:tokens": "npx tsc -p ./components/identity.tokens",
|
|
43
|
+
"transpile:roles": "npx tsc -p ./components/identity.roles",
|
|
44
44
|
"features": "npx cucumber-js"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@toa.io/extensions.storages": "0.
|
|
47
|
+
"@toa.io/extensions.storages": "0.24.0-alpha.10",
|
|
48
|
+
"@toa.io/http": "0.24.0-alpha.10",
|
|
48
49
|
"@types/bcryptjs": "2.4.3",
|
|
49
50
|
"@types/cors": "2.8.13",
|
|
50
51
|
"@types/express": "4.17.17",
|
|
51
|
-
"@types/
|
|
52
|
+
"@types/fs-extra": "11.0.4",
|
|
53
|
+
"@types/negotiator": "0.6.1",
|
|
54
|
+
"fs-extra": "11.1.1"
|
|
52
55
|
},
|
|
53
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "c1e7032d6124a5558b7e6a4e70ab4c4a8a77e3e5"
|
|
54
57
|
}
|
package/readme.md
CHANGED
|
@@ -97,7 +97,9 @@ describe('result', () => {
|
|
|
97
97
|
it('should send status code 200 if the result has a value', async () => {
|
|
98
98
|
const req = createRequest()
|
|
99
99
|
|
|
100
|
-
server.attach(async (): Promise<OutgoingMessage> => ({
|
|
100
|
+
server.attach(async (): Promise<OutgoingMessage> => ({
|
|
101
|
+
headers: new Headers(), body: generate()
|
|
102
|
+
}))
|
|
101
103
|
await use(req)
|
|
102
104
|
|
|
103
105
|
expect(res.status).toHaveBeenCalledWith(200)
|
|
@@ -106,7 +108,7 @@ describe('result', () => {
|
|
|
106
108
|
it('should send status code 204 if the result has no value', async () => {
|
|
107
109
|
const req = createRequest()
|
|
108
110
|
|
|
109
|
-
server.attach(async (): Promise<OutgoingMessage> => ({ headers:
|
|
111
|
+
server.attach(async (): Promise<OutgoingMessage> => ({ headers: new Headers() }))
|
|
110
112
|
await use(req)
|
|
111
113
|
|
|
112
114
|
expect(res.status).toHaveBeenCalledWith(204)
|
|
@@ -118,7 +120,7 @@ describe('result', () => {
|
|
|
118
120
|
const buf = Buffer.from(json)
|
|
119
121
|
const req = createRequest({ headers: { accept: 'application/json' } })
|
|
120
122
|
|
|
121
|
-
server.attach(async (): Promise<OutgoingMessage> => ({ headers:
|
|
123
|
+
server.attach(async (): Promise<OutgoingMessage> => ({ headers: new Headers(), body }))
|
|
122
124
|
await use(req)
|
|
123
125
|
|
|
124
126
|
expect(res.end).toHaveBeenCalledWith(buf)
|
package/source/HTTP/Server.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import os from 'node:os'
|
|
1
3
|
import express from 'express'
|
|
2
4
|
import cors from 'cors'
|
|
3
5
|
import { Connector } from '@toa.io/core'
|
|
@@ -22,8 +24,10 @@ export class Server extends Connector {
|
|
|
22
24
|
this.debug = debug
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
public static create (options
|
|
26
|
-
const properties: Properties =
|
|
27
|
+
public static create (options?: Partial<Properties>): Server {
|
|
28
|
+
const properties: Properties = options === undefined
|
|
29
|
+
? DEFAULTS
|
|
30
|
+
: { ...DEFAULTS, ...options }
|
|
27
31
|
|
|
28
32
|
const app = express()
|
|
29
33
|
|
|
@@ -35,7 +39,7 @@ export class Server extends Connector {
|
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
public attach (process: Processing): void {
|
|
38
|
-
this.app.use((request: any, response: Response)
|
|
42
|
+
this.app.use((request: any, response: Response) => {
|
|
39
43
|
this.extend(request)
|
|
40
44
|
.then(process)
|
|
41
45
|
.then(this.success(request, response))
|
|
@@ -84,9 +88,8 @@ export class Server extends Connector {
|
|
|
84
88
|
else if (message.body === undefined) status = 204
|
|
85
89
|
else status = 200
|
|
86
90
|
|
|
87
|
-
response
|
|
88
|
-
|
|
89
|
-
.set(message.headers)
|
|
91
|
+
response.status(status)
|
|
92
|
+
message.headers?.forEach((value, key) => response.set(key, value))
|
|
90
93
|
|
|
91
94
|
if (message.body !== undefined && message.body !== null)
|
|
92
95
|
write(request, response, message)
|
|
@@ -96,7 +99,10 @@ export class Server extends Connector {
|
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
private fail (request: IncomingMessage, response: Response) {
|
|
99
|
-
return (exception: Error) => {
|
|
102
|
+
return async (exception: Error) => {
|
|
103
|
+
if (!request.complete)
|
|
104
|
+
await adam(request)
|
|
105
|
+
|
|
100
106
|
const status = exception instanceof Exception
|
|
101
107
|
? exception.status
|
|
102
108
|
: 500
|
|
@@ -113,10 +119,6 @@ export class Server extends Connector {
|
|
|
113
119
|
write(request, response, { body })
|
|
114
120
|
} else
|
|
115
121
|
response.end()
|
|
116
|
-
|
|
117
|
-
// stop accepting request
|
|
118
|
-
if (!request.complete)
|
|
119
|
-
request.destroy()
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
124
|
}
|
|
@@ -135,16 +137,26 @@ function negotiate (request: Request): Format | null {
|
|
|
135
137
|
return mediaType === undefined ? null : formats[mediaType]
|
|
136
138
|
}
|
|
137
139
|
|
|
140
|
+
// https://github.com/whatwg/fetch/issues/1254
|
|
141
|
+
async function adam (request: Request): Promise<void> {
|
|
142
|
+
const completed = promex()
|
|
143
|
+
const devnull = fs.createWriteStream(os.devNull)
|
|
144
|
+
|
|
145
|
+
request
|
|
146
|
+
.on('end', completed.callback)
|
|
147
|
+
.pipe(devnull)
|
|
148
|
+
|
|
149
|
+
return await completed
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const DEFAULTS = {
|
|
153
|
+
methods: new Set<string>(['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']),
|
|
154
|
+
debug: false
|
|
155
|
+
}
|
|
156
|
+
|
|
138
157
|
interface Properties {
|
|
139
158
|
methods: Set<string>
|
|
140
159
|
debug: boolean
|
|
141
160
|
}
|
|
142
161
|
|
|
143
|
-
function defaults (): Properties {
|
|
144
|
-
return {
|
|
145
|
-
methods: new Set<string>(['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']),
|
|
146
|
-
debug: false
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
162
|
export type Processing = (input: IncomingMessage) => Promise<OutgoingMessage>
|
package/source/HTTP/messages.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type IncomingHttpHeaders
|
|
1
|
+
import { type IncomingHttpHeaders } from 'node:http'
|
|
2
2
|
import { Readable } from 'node:stream'
|
|
3
3
|
import { type Request, type Response } from 'express'
|
|
4
4
|
import { buffer } from '@toa.io/streams'
|
|
@@ -53,7 +53,7 @@ function send (message: OutgoingMessage, request: IncomingMessage, response: Res
|
|
|
53
53
|
|
|
54
54
|
function stream
|
|
55
55
|
(message: OutgoingMessage, request: IncomingMessage, response: Response): void {
|
|
56
|
-
const encoded = message.headers !== undefined && 'content-type'
|
|
56
|
+
const encoded = message.headers !== undefined && message.headers.has('content-type')
|
|
57
57
|
|
|
58
58
|
if (encoded)
|
|
59
59
|
pipe(message, response)
|
|
@@ -67,7 +67,7 @@ function stream
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
function pipe (message: OutgoingMessage, response: Response): void {
|
|
70
|
-
response.set(
|
|
70
|
+
message.headers?.forEach((value, key) => response.set(key, value))
|
|
71
71
|
message.body.pipe(response)
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -101,7 +101,7 @@ export interface IncomingMessage extends Request {
|
|
|
101
101
|
|
|
102
102
|
export interface OutgoingMessage {
|
|
103
103
|
status?: number
|
|
104
|
-
headers?:
|
|
104
|
+
headers?: Headers
|
|
105
105
|
body?: any
|
|
106
106
|
}
|
|
107
107
|
|
package/source/Tenant.ts
CHANGED
|
@@ -30,6 +30,11 @@ export class Tenant extends Connector {
|
|
|
30
30
|
`'${this.branch.namespace}.${this.branch.component}' has started.`)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
public override async dispose (): Promise<void> {
|
|
34
|
+
console.info('Exposition Tenant for ' +
|
|
35
|
+
`'${this.branch.namespace}.${this.branch.component}' has been stopped.`)
|
|
36
|
+
}
|
|
37
|
+
|
|
33
38
|
private async expose (): Promise<void> {
|
|
34
39
|
await this.broadcast.transmit('expose', this.branch)
|
|
35
40
|
}
|
|
@@ -90,9 +90,9 @@ class Authorization implements Family<Directive, Extension> {
|
|
|
90
90
|
const authorization = `Token ${token}`
|
|
91
91
|
|
|
92
92
|
if (response.headers === undefined)
|
|
93
|
-
response.headers =
|
|
93
|
+
response.headers = new Headers()
|
|
94
94
|
|
|
95
|
-
response.headers.authorization
|
|
95
|
+
response.headers.set('authorization', authorization)
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
private async resolve (authorization: string | undefined): Promise<Identity | null> {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { match } from 'matchacho'
|
|
2
|
+
import type { AuthenticatedRequest, Directive } from './types'
|
|
3
|
+
|
|
4
|
+
export class Control implements Directive {
|
|
5
|
+
protected readonly value: string
|
|
6
|
+
private cache: string | null = null
|
|
7
|
+
|
|
8
|
+
public constructor (value: string) {
|
|
9
|
+
this.value = value
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public set (request: AuthenticatedRequest, headers: Headers): void {
|
|
13
|
+
if (!['GET', 'HEAD', 'OPTIONS'].includes(request.method))
|
|
14
|
+
return
|
|
15
|
+
|
|
16
|
+
this.cache ??= this.resolve(request)
|
|
17
|
+
|
|
18
|
+
headers.set('cache-control', this.cache)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
protected resolve (request: AuthenticatedRequest): string {
|
|
22
|
+
if (request.identity === null)
|
|
23
|
+
return this.value
|
|
24
|
+
|
|
25
|
+
const directives = this.mask()
|
|
26
|
+
|
|
27
|
+
if ((directives & (PUBLIC | NO_CACHE)) === PUBLIC)
|
|
28
|
+
return 'no-cache, ' + this.value
|
|
29
|
+
|
|
30
|
+
if ((directives & (PUBLIC | PRIVATE)) === 0)
|
|
31
|
+
return 'private, ' + this.value
|
|
32
|
+
|
|
33
|
+
return this.value
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private mask (): number {
|
|
37
|
+
const directives = this.value.match(DIRECTIVES_RX)
|
|
38
|
+
|
|
39
|
+
if (directives === null)
|
|
40
|
+
return 0
|
|
41
|
+
|
|
42
|
+
let mask = 0
|
|
43
|
+
|
|
44
|
+
for (const directive of directives)
|
|
45
|
+
mask |= match<number>(directive,
|
|
46
|
+
'private', PRIVATE,
|
|
47
|
+
'public', PUBLIC,
|
|
48
|
+
'no-cache', NO_CACHE,
|
|
49
|
+
0)
|
|
50
|
+
|
|
51
|
+
return mask
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const DIRECTIVES_RX = /\b(private|public|no-cache)\b/ig
|
|
56
|
+
|
|
57
|
+
const PUBLIC = 1
|
|
58
|
+
const PRIVATE = 2
|
|
59
|
+
const NO_CACHE = 4
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type Input, type Output, type Family } from '../../Directive'
|
|
2
|
+
import { Control } from './Control'
|
|
3
|
+
import { type Directive } from './types'
|
|
4
|
+
import { Exact } from './Exact'
|
|
5
|
+
import type * as http from '../../HTTP'
|
|
6
|
+
|
|
7
|
+
class Cache implements Family<Directive> {
|
|
8
|
+
public readonly name: string = 'cache'
|
|
9
|
+
public readonly mandatory: boolean = false
|
|
10
|
+
|
|
11
|
+
public create (name: string, value: any): Directive {
|
|
12
|
+
const Class = constructors[name]
|
|
13
|
+
|
|
14
|
+
if (Class === undefined)
|
|
15
|
+
throw new Error(`Directive '${name}' is not provided by the '${this.name}' family.`)
|
|
16
|
+
|
|
17
|
+
return new Class(value)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public preflight (): Output {
|
|
21
|
+
return null
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public async settle
|
|
25
|
+
(directives: Directive[], request: Input, response: http.OutgoingMessage): Promise<void> {
|
|
26
|
+
response.headers ??= new Headers()
|
|
27
|
+
directives[0]?.set(request, response.headers)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const constructors: Record<string, new (value: any) => Directive> = {
|
|
32
|
+
control: Control,
|
|
33
|
+
exact: Exact
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export = new Cache()
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Family } from '../Directive'
|
|
2
2
|
import Dev from './dev'
|
|
3
3
|
import Auth from './auth'
|
|
4
|
+
import Cache from './cache'
|
|
4
5
|
import Octets from './octets'
|
|
5
6
|
|
|
6
|
-
export const families: Family[] = [Auth, Octets, Dev]
|
|
7
|
+
export const families: Family[] = [Auth, Octets, Dev, Cache]
|
|
@@ -48,11 +48,11 @@ export class Fetch implements Directive {
|
|
|
48
48
|
if (result instanceof Error)
|
|
49
49
|
throw new NotFound()
|
|
50
50
|
|
|
51
|
-
const headers = {
|
|
51
|
+
const headers = new Headers({
|
|
52
52
|
'content-type': result.type,
|
|
53
|
-
'content-length': result.size,
|
|
53
|
+
'content-length': result.size.toString(),
|
|
54
54
|
etag: result.checksum
|
|
55
|
-
}
|
|
55
|
+
})
|
|
56
56
|
|
|
57
57
|
return { headers, body: result.stream }
|
|
58
58
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Annotation.js","sourceRoot":"","sources":["../source/Annotation.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Branch.js","sourceRoot":"","sources":["../source/Branch.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Connector } from '@toa.io/core';
|
|
2
|
+
import { type Bootloader } from './Factory';
|
|
3
|
+
export declare class Composition extends Connector {
|
|
4
|
+
private readonly boot;
|
|
5
|
+
constructor(boot: Bootloader);
|
|
6
|
+
protected open(): Promise<void>;
|
|
7
|
+
protected dispose(): void;
|
|
8
|
+
}
|
|
9
|
+
export declare function components(): Components;
|
|
10
|
+
interface Components {
|
|
11
|
+
labels: string[];
|
|
12
|
+
paths: string[];
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.components = exports.Composition = void 0;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const core_1 = require("@toa.io/core");
|
|
7
|
+
class Composition extends core_1.Connector {
|
|
8
|
+
boot;
|
|
9
|
+
constructor(boot) {
|
|
10
|
+
super();
|
|
11
|
+
this.boot = boot;
|
|
12
|
+
}
|
|
13
|
+
async open() {
|
|
14
|
+
const paths = find();
|
|
15
|
+
const composition = await this.boot.composition(paths);
|
|
16
|
+
await composition.connect();
|
|
17
|
+
this.depends(composition);
|
|
18
|
+
console.info('Composition complete.');
|
|
19
|
+
}
|
|
20
|
+
dispose() {
|
|
21
|
+
console.info('Composition shutdown complete.');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.Composition = Composition;
|
|
25
|
+
function find() {
|
|
26
|
+
return entries().map((entry) => (0, node_path_1.resolve)(ROOT, entry.name));
|
|
27
|
+
}
|
|
28
|
+
function entries() {
|
|
29
|
+
const entries = (0, node_fs_1.readdirSync)(ROOT, { withFileTypes: true });
|
|
30
|
+
return entries.filter((entry) => entry.isDirectory());
|
|
31
|
+
}
|
|
32
|
+
function components() {
|
|
33
|
+
const labels = [];
|
|
34
|
+
const paths = [];
|
|
35
|
+
for (const entry of entries()) {
|
|
36
|
+
labels.push(entry.name.replace('.', '-'));
|
|
37
|
+
paths.push((0, node_path_1.resolve)(ROOT, entry.name));
|
|
38
|
+
}
|
|
39
|
+
return { labels, paths };
|
|
40
|
+
}
|
|
41
|
+
exports.components = components;
|
|
42
|
+
const ROOT = (0, node_path_1.resolve)(__dirname, '../components/');
|
|
43
|
+
//# sourceMappingURL=Composition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Composition.js","sourceRoot":"","sources":["../source/Composition.ts"],"names":[],"mappings":";;;AAAA,qCAAkD;AAClD,yCAAmC;AACnC,uCAAwC;AAGxC,MAAa,WAAY,SAAQ,gBAAS;IACvB,IAAI,CAAY;IAEjC,YAAoB,IAAgB;QAClC,KAAK,EAAE,CAAA;QACP,IAAI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E,CAAA;AAC1B,CAAC;AAVD,gCAUC;AAOD,MAAM,IAAI,GAAG,IAAA,mBAAO,EAAC,SAAS,EAAE,gBAAgB,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../source/Context.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type IncomingMessage, type OutgoingMessage } from './HTTP';
|
|
2
|
+
import { type Remotes } from './Remotes';
|
|
3
|
+
import type * as RTD from './RTD';
|
|
4
|
+
export declare class Directives implements RTD.Directives<Directives> {
|
|
5
|
+
private readonly directives;
|
|
6
|
+
constructor(directives: DirectiveSet[]);
|
|
7
|
+
preflight(request: IncomingMessage, parameters: RTD.Parameter[]): Promise<Output>;
|
|
8
|
+
settle(request: IncomingMessage, response: OutgoingMessage): Promise<void>;
|
|
9
|
+
merge(directives: Directives): void;
|
|
10
|
+
}
|
|
11
|
+
export declare class DirectivesFactory implements RTD.DirectivesFactory<Directives> {
|
|
12
|
+
private readonly remtoes;
|
|
13
|
+
private readonly families;
|
|
14
|
+
private readonly mandatory;
|
|
15
|
+
constructor(families: Family[], remotes: Remotes);
|
|
16
|
+
create(declarations: RTD.syntax.Directive[]): Directives;
|
|
17
|
+
}
|
|
18
|
+
export declare const shortcuts: RTD.syntax.Shortcuts;
|
|
19
|
+
export interface Family<TDirective = any, TExtension = any> {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly mandatory: boolean;
|
|
22
|
+
create: (name: string, value: any, remotes: Remotes) => TDirective;
|
|
23
|
+
preflight: (directives: TDirective[], request: IncomingMessage & TExtension, parameters: RTD.Parameter[]) => Output | Promise<Output>;
|
|
24
|
+
settle?: (directives: TDirective[], request: IncomingMessage & TExtension, response: OutgoingMessage) => void | Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
interface DirectiveSet {
|
|
27
|
+
family: Family;
|
|
28
|
+
directives: any[];
|
|
29
|
+
}
|
|
30
|
+
export type Input = IncomingMessage;
|
|
31
|
+
export type Output = OutgoingMessage | null;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shortcuts = exports.DirectivesFactory = exports.Directives = void 0;
|
|
4
|
+
class Directives {
|
|
5
|
+
directives;
|
|
6
|
+
constructor(directives) {
|
|
7
|
+
this.directives = directives;
|
|
8
|
+
}
|
|
9
|
+
async preflight(request, parameters) {
|
|
10
|
+
for (const directive of this.directives) {
|
|
11
|
+
const output = await directive.family.preflight(directive.directives, request, parameters);
|
|
12
|
+
if (output !== null) {
|
|
13
|
+
await this.settle(request, output);
|
|
14
|
+
return output;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
async settle(request, response) {
|
|
20
|
+
for (const directive of this.directives)
|
|
21
|
+
if (directive.family.settle !== undefined)
|
|
22
|
+
await directive.family.settle(directive.directives, request, response);
|
|
23
|
+
}
|
|
24
|
+
merge(directives) {
|
|
25
|
+
this.directives.push(...directives.directives);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.Directives = Directives;
|
|
29
|
+
class DirectivesFactory {
|
|
30
|
+
remtoes;
|
|
31
|
+
families = {};
|
|
32
|
+
mandatory = [];
|
|
33
|
+
constructor(families, remotes) {
|
|
34
|
+
for (const family of families) {
|
|
35
|
+
this.families[family.name] = family;
|
|
36
|
+
if (family.mandatory)
|
|
37
|
+
this.mandatory.push(family.name);
|
|
38
|
+
}
|
|
39
|
+
this.remtoes = remotes;
|
|
40
|
+
}
|
|
41
|
+
create(declarations) {
|
|
42
|
+
const groups = {};
|
|
43
|
+
const mandatory = new Set(this.mandatory);
|
|
44
|
+
declarations.sort((a, b) => (mandatory.has(b.family) ? 1 : 0) - (mandatory.has(a.family) ? 1 : 0));
|
|
45
|
+
for (const declaration of declarations) {
|
|
46
|
+
const family = this.families[declaration.family];
|
|
47
|
+
if (family === undefined)
|
|
48
|
+
throw new Error(`Directive family '${declaration.family}' not found.`);
|
|
49
|
+
const directive = family.create(declaration.name, declaration.value, this.remtoes);
|
|
50
|
+
groups[family.name] ??= [];
|
|
51
|
+
groups[family.name].push(directive);
|
|
52
|
+
mandatory.delete(family.name);
|
|
53
|
+
}
|
|
54
|
+
const sets = [];
|
|
55
|
+
for (const family of mandatory)
|
|
56
|
+
sets.push({
|
|
57
|
+
family: this.families[family],
|
|
58
|
+
directives: []
|
|
59
|
+
});
|
|
60
|
+
for (const [family, directives] of Object.entries(groups))
|
|
61
|
+
sets.push({
|
|
62
|
+
family: this.families[family],
|
|
63
|
+
directives
|
|
64
|
+
});
|
|
65
|
+
return new Directives(sets);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.DirectivesFactory = DirectivesFactory;
|
|
69
|
+
exports.shortcuts = new Map([
|
|
70
|
+
['anonymous', 'auth:anonymous'],
|
|
71
|
+
['id', 'auth:id'],
|
|
72
|
+
['role', 'auth:role'],
|
|
73
|
+
['rule', 'auth:rule'],
|
|
74
|
+
['incept', 'auth:incept']
|
|
75
|
+
]);
|
|
76
|
+
//# sourceMappingURL=Directive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Directive.js","sourceRoot":"","sources":["../source/Directive.ts"],"names":[],"mappings":";;;AAIA,MAAa,UAAU;IACJ,UAAU,CAAgB;IAE3C,YAAoB,UAA0B;QAC5C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;IAEM,KAAK,CAAC,SAAS,CAAE,OAAwB,EAAE,UAA2B;QAC3E,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE;YACvC,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,UAAU,EAAE,OAAO,EAAE,UAAU,CAAC,CAAA;YAE1F,IAAI,MAAM,K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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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Component, type Reply } from '@toa.io/core';
|
|
2
|
+
import { type Remotes } from './Remotes';
|
|
3
|
+
import { Mapping } from './Mapping';
|
|
4
|
+
import { type Context } from './Context';
|
|
5
|
+
import type * as RTD from './RTD';
|
|
6
|
+
import type * as http from './HTTP';
|
|
7
|
+
export declare class Endpoint implements RTD.Endpoint<Endpoint> {
|
|
8
|
+
private readonly endpoint;
|
|
9
|
+
private readonly mapping;
|
|
10
|
+
private readonly discovery;
|
|
11
|
+
private remote;
|
|
12
|
+
constructor(endpoint: string, mapping: Mapping, discovery: Promise<Component>);
|
|
13
|
+
call(body: any, query: http.Query, parameters: RTD.Parameter[]): Promise<Reply>;
|
|
14
|
+
close(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export declare class EndpointsFactory implements RTD.EndpointsFactory<Endpoint> {
|
|
17
|
+
private readonly remotes;
|
|
18
|
+
constructor(remotes: Remotes);
|
|
19
|
+
create(method: RTD.syntax.Method, context: Context): Endpoint;
|
|
20
|
+
}
|