@toa.io/core 0.24.0-alpha.21 → 0.24.0-alpha.23
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/package.json +6 -6
- package/src/contract/request.js +6 -5
- package/test/contract/request.test.js +1 -2
- package/types/bridges.ts +30 -0
- package/types/context.d.ts +12 -18
- package/types/{index.d.ts → index.ts} +6 -6
- package/types/bridges.d.ts +0 -41
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/core",
|
|
3
|
-
"version": "0.24.0-alpha.
|
|
3
|
+
"version": "0.24.0-alpha.23",
|
|
4
4
|
"description": "Toa Core",
|
|
5
5
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/toa-io/toa#readme",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"url": "https://github.com/toa-io/toa/issues"
|
|
13
13
|
},
|
|
14
14
|
"main": "src/index.js",
|
|
15
|
-
"types": "types/index.
|
|
15
|
+
"types": "types/index.ts",
|
|
16
16
|
"publishConfig": {
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@rsql/parser": "1.2.4",
|
|
24
|
-
"@toa.io/console": "0.24.0-alpha.
|
|
25
|
-
"@toa.io/generic": "0.24.0-alpha.
|
|
26
|
-
"@toa.io/yaml": "0.24.0-alpha.
|
|
24
|
+
"@toa.io/console": "0.24.0-alpha.23",
|
|
25
|
+
"@toa.io/generic": "0.24.0-alpha.23",
|
|
26
|
+
"@toa.io/yaml": "0.24.0-alpha.23",
|
|
27
27
|
"error-value": "0.3.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"clone-deep": "4.0.1"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "df9de3cbb530e8f985a660bca0bf65bd027dbb01"
|
|
33
33
|
}
|
package/src/contract/request.js
CHANGED
|
@@ -29,11 +29,11 @@ class Request extends Conditions {
|
|
|
29
29
|
if (entity === undefined)
|
|
30
30
|
definition.query = false
|
|
31
31
|
|
|
32
|
-
if (definition.query === true)
|
|
32
|
+
if (definition.query === true)
|
|
33
|
+
required.push('query')
|
|
33
34
|
|
|
34
|
-
if (definition.query === false)
|
|
35
|
-
schema.
|
|
36
|
-
}
|
|
35
|
+
if (definition.query === false)
|
|
36
|
+
schema.properties.query = { type: 'null' }
|
|
37
37
|
|
|
38
38
|
if (definition.query !== false) {
|
|
39
39
|
const query = structuredClone(schemas.query)
|
|
@@ -57,7 +57,8 @@ class Request extends Conditions {
|
|
|
57
57
|
schema.properties.query = query
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
if (required.length > 0)
|
|
60
|
+
if (required.length > 0)
|
|
61
|
+
schema.required = required
|
|
61
62
|
|
|
62
63
|
return schema
|
|
63
64
|
}
|
|
@@ -58,8 +58,7 @@ describe('schema', () => {
|
|
|
58
58
|
})
|
|
59
59
|
|
|
60
60
|
it('should not contain query if declaration.query is false', () => {
|
|
61
|
-
|
|
62
|
-
schema.not = { required: ['query'] }
|
|
61
|
+
schema.properties.query = { type: 'null' }
|
|
63
62
|
expect(Request.schema({ query: false }, dummy)).toStrictEqual(schema)
|
|
64
63
|
})
|
|
65
64
|
|
package/types/bridges.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Request, Reply } from './request'
|
|
2
|
+
import type { Context } from './context'
|
|
3
|
+
|
|
4
|
+
export interface Algorithm {
|
|
5
|
+
mount: (context?: Context) => Promise<void>
|
|
6
|
+
|
|
7
|
+
execute: ((input: any, scope: object | object[]) => Promise<Reply>) |
|
|
8
|
+
((input: any) => Promise<Reply>) |
|
|
9
|
+
(() => Promise<Reply>)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface Event {
|
|
13
|
+
condition: (object: object) => Promise<boolean>
|
|
14
|
+
|
|
15
|
+
payload: (object: object) => Promise<object>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface Receiver {
|
|
19
|
+
condition: (object: object) => Promise<boolean>
|
|
20
|
+
|
|
21
|
+
request: (object: object) => Promise<Request>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface Factory {
|
|
25
|
+
algorithm?: (path: string, name: string, context: Context) => Algorithm
|
|
26
|
+
|
|
27
|
+
event?: (path: string, label: string) => Event
|
|
28
|
+
|
|
29
|
+
receiver?: (path: string, label: string) => Receiver
|
|
30
|
+
}
|
package/types/context.d.ts
CHANGED
|
@@ -3,25 +3,19 @@ import * as _reply from './reply'
|
|
|
3
3
|
import * as _extensions from './extensions'
|
|
4
4
|
import * as _connector from './connector'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
export interface Context extends _connector.Connector{
|
|
7
|
+
aspects: _extensions.Aspect[]
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Calls local endpoint
|
|
11
|
+
*/
|
|
12
|
+
apply (endpoint: string, request: _request.Request): Promise<_reply.Reply>
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Calls remote endpoint
|
|
18
|
-
*/
|
|
19
|
-
call(namespace: string, name: string, endpoint: string, request: _request.Request): Promise<_reply.Reply>
|
|
20
|
-
|
|
21
|
-
// shortcuts
|
|
22
|
-
[key: string]: any
|
|
23
|
-
}
|
|
14
|
+
/**
|
|
15
|
+
* Calls remote endpoint
|
|
16
|
+
*/
|
|
17
|
+
call (namespace: string, name: string, endpoint: string, request: _request.Request): Promise<_reply.Reply>
|
|
24
18
|
|
|
19
|
+
// shortcuts
|
|
20
|
+
[key: string]: any
|
|
25
21
|
}
|
|
26
|
-
|
|
27
|
-
export type Context = toa.core.Context
|
|
@@ -4,11 +4,11 @@ export * as storages from './storages'
|
|
|
4
4
|
export * as bridges from './bridges'
|
|
5
5
|
export * as operations from './operations'
|
|
6
6
|
|
|
7
|
-
export { Component } from './component'
|
|
7
|
+
export type { Component } from './component'
|
|
8
8
|
export { Connector } from './connector'
|
|
9
|
-
export { Context } from './context'
|
|
10
|
-
export { Exception } from './exception'
|
|
9
|
+
export type { Context } from './context'
|
|
10
|
+
export type { Exception } from './exception'
|
|
11
11
|
export { Locator } from './locator'
|
|
12
|
-
export { Receiver } from './receiver'
|
|
13
|
-
export { Message } from './message'
|
|
14
|
-
export { Request, Query, Reply } from './request'
|
|
12
|
+
export type { Receiver } from './receiver'
|
|
13
|
+
export type { Message } from './message'
|
|
14
|
+
export type { Request, Query, Reply } from './request'
|
package/types/bridges.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import * as _core from '@toa.io/core/types'
|
|
2
|
-
import type * as reply from './reply'
|
|
3
|
-
import type * as context from './context'
|
|
4
|
-
import type * as connector from './connector'
|
|
5
|
-
|
|
6
|
-
declare namespace toa.core.bridges {
|
|
7
|
-
|
|
8
|
-
interface Algorithm extends connector.Connector {
|
|
9
|
-
mount(context?: context.Context): Promise<void>
|
|
10
|
-
|
|
11
|
-
execute(input: any, scope: object | object[]): Promise<reply.Reply>
|
|
12
|
-
|
|
13
|
-
execute(input: any): Promise<reply.Reply>
|
|
14
|
-
|
|
15
|
-
execute(): Promise<reply.Reply>
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface Event {
|
|
19
|
-
condition(object): Promise<boolean>
|
|
20
|
-
|
|
21
|
-
payload(object): Promise<object>
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
interface Receiver {
|
|
25
|
-
condition(object): Promise<boolean>
|
|
26
|
-
|
|
27
|
-
request(object): Promise<_core.Request>
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
interface Factory {
|
|
31
|
-
algorithm(path: string, name: string, context: context.Context): Algorithm
|
|
32
|
-
|
|
33
|
-
event(path: string, label: string): Event
|
|
34
|
-
|
|
35
|
-
receiver(path: string, label: string): Receiver
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export type Algorithm = toa.core.bridges.Algorithm
|
|
41
|
-
export type Factory = toa.core.bridges.Factory
|