@toa.io/core 1.0.0-alpha.19 → 1.0.0-alpha.194
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 -9
- package/src/call.js +6 -0
- package/src/cascade.js +2 -3
- package/src/component.js +15 -18
- package/src/composition.js +1 -1
- package/src/connector.js +3 -8
- package/src/contract/contract.js +22 -0
- package/src/contract/reply.js +26 -9
- package/src/contract/request.js +15 -5
- package/src/contract/schemas/query.yaml +7 -1
- package/src/discovery.js +2 -5
- package/src/effect.js +19 -0
- package/src/entities/changeset.js +5 -8
- package/src/entities/entity.js +47 -23
- package/src/entities/factory.js +11 -3
- package/src/exceptions.js +26 -19
- package/src/exposition.js +3 -2
- package/src/guard.js +17 -0
- package/src/index.js +6 -0
- package/src/observation.js +1 -9
- package/src/operation.js +28 -7
- package/src/query/options.js +3 -2
- package/src/query.js +2 -1
- package/src/receiver.js +13 -10
- package/src/remote.js +5 -7
- package/src/state.js +50 -33
- package/src/transition.js +8 -19
- package/src/transmission.js +12 -3
- package/src/unmanaged.js +11 -0
- package/test/component.test.js +4 -3
- package/test/contract/conditions.test.js +5 -5
- package/test/contract/request.test.js +7 -7
- package/test/entities/entity.test.js +0 -45
- package/test/state.test.js +0 -6
- package/types/bindings.d.ts +7 -5
- package/types/component.d.ts +4 -1
- package/types/extensions.d.ts +4 -3
- package/types/index.ts +1 -0
- package/types/operations.d.ts +6 -0
- package/types/query.d.ts +2 -0
- package/types/remote.d.ts +18 -0
- package/types/request.d.ts +3 -0
- package/types/storages.d.ts +11 -9
- package/src/contract/conditions.js +0 -21
package/types/component.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { Connector } from './connector'
|
|
2
2
|
import { Locator } from './locator'
|
|
3
3
|
import { Request } from './request'
|
|
4
|
+
import { Operation } from './operations'
|
|
4
5
|
|
|
5
|
-
export
|
|
6
|
+
export class Component extends Connector {
|
|
6
7
|
locator: Locator
|
|
7
8
|
|
|
9
|
+
constructor (locator: Locator, operations: Record<string, Operation>)
|
|
10
|
+
|
|
8
11
|
invoke<T = any> (endpoint: string, request: Request): Promise<T>
|
|
9
12
|
}
|
package/types/extensions.d.ts
CHANGED
|
@@ -3,9 +3,10 @@ import * as _component from './component'
|
|
|
3
3
|
import * as _context from './context'
|
|
4
4
|
import * as _storages from './storages'
|
|
5
5
|
import * as _bindings from './bindings'
|
|
6
|
+
import { Manifest } from '@toa.io/norm'
|
|
6
7
|
|
|
7
|
-
export interface Factory{
|
|
8
|
-
tenant? (locator: _core.Locator, manifest: object): _core.Connector
|
|
8
|
+
export interface Factory {
|
|
9
|
+
tenant? (locator: _core.Locator, manifest: object, component: Manifest): _core.Connector
|
|
9
10
|
|
|
10
11
|
aspect? (locator: _core.Locator, manifest: object | null): Aspect | Aspect[]
|
|
11
12
|
|
|
@@ -22,7 +23,7 @@ export interface Factory{
|
|
|
22
23
|
receiver? (receiver: _core.Receiver, locator: _core.Locator): _core.Receiver
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
export interface Aspect extends _core.Connector{
|
|
26
|
+
export interface Aspect extends _core.Connector {
|
|
26
27
|
name: string
|
|
27
28
|
|
|
28
29
|
invoke (...args: any[]): any
|
package/types/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * as bridges from './bridges'
|
|
|
5
5
|
export * as operations from './operations'
|
|
6
6
|
|
|
7
7
|
export type { Component } from './component'
|
|
8
|
+
export type { Remote } from './remote'
|
|
8
9
|
export { Connector } from './connector'
|
|
9
10
|
export type { Context } from './context'
|
|
10
11
|
export type { Exception } from './exception'
|
package/types/operations.d.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
import { Request } from './request'
|
|
2
|
+
|
|
1
3
|
export type type = 'transition' | 'observation' | 'assignment' | 'computation' | 'effect'
|
|
2
4
|
export type scope = 'object' | 'objects' | 'changeset'
|
|
5
|
+
|
|
6
|
+
export class Operation {
|
|
7
|
+
invoke<T = any> (request: Request): Promise<T>
|
|
8
|
+
}
|
package/types/query.d.ts
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Component } from './component'
|
|
2
|
+
|
|
3
|
+
export class Remote extends Component {
|
|
4
|
+
explain (endpoint: string): Promise<Explanation>
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface Explanation {
|
|
8
|
+
input: Schema | null
|
|
9
|
+
output: Schema | null
|
|
10
|
+
errors?: string[]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface Schema {
|
|
14
|
+
type: string
|
|
15
|
+
properties: {
|
|
16
|
+
[key: string]: Schema
|
|
17
|
+
}
|
|
18
|
+
}
|
package/types/request.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { Exception } from './exception'
|
|
|
3
3
|
export interface Query {
|
|
4
4
|
id?: string
|
|
5
5
|
criteria?: string
|
|
6
|
+
search?: string
|
|
7
|
+
sample?: number
|
|
6
8
|
omit?: number
|
|
7
9
|
limit?: number
|
|
8
10
|
sort?: Array<string>
|
|
@@ -14,6 +16,7 @@ export interface Request {
|
|
|
14
16
|
input?: any
|
|
15
17
|
query?: Query
|
|
16
18
|
authentic?: boolean
|
|
19
|
+
task?: boolean
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
export interface Reply {
|
package/types/storages.d.ts
CHANGED
|
@@ -30,36 +30,38 @@ declare namespace toa.core {
|
|
|
30
30
|
id?: string
|
|
31
31
|
version?: number
|
|
32
32
|
criteria?: ast.Node
|
|
33
|
+
search?: string
|
|
34
|
+
sample?: number
|
|
33
35
|
options?: Object
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
interface Migration {
|
|
37
|
-
disconnect(): Promise<void>
|
|
39
|
+
disconnect (): Promise<void>
|
|
38
40
|
|
|
39
|
-
database(name: string): Promise<void>
|
|
41
|
+
database (name: string): Promise<void>
|
|
40
42
|
|
|
41
|
-
table(database: string, locator: Locator, schema: Object, reset?: boolean): Promise<string>
|
|
43
|
+
table (database: string, locator: Locator, schema: Object, reset?: boolean): Promise<string>
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
interface Factory {
|
|
45
|
-
storage(locator: Locator, properties?: object): Storage
|
|
47
|
+
storage (locator: Locator, properties?: object): Storage
|
|
46
48
|
|
|
47
|
-
migration?(driver?: string): Migration
|
|
49
|
+
migration? (driver?: string): Migration
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
interface Storage extends Connector {
|
|
52
54
|
// object observation
|
|
53
|
-
get?(query: storages.Query): Promise<storages.Record | null>
|
|
55
|
+
get? (query: storages.Query): Promise<storages.Record | null>
|
|
54
56
|
|
|
55
57
|
// objects observation
|
|
56
|
-
find?(query: storages.Query): Promise<storages.Record[]>
|
|
58
|
+
find? (query: storages.Query): Promise<storages.Record[]>
|
|
57
59
|
|
|
58
60
|
// commit
|
|
59
|
-
store?(record: storages.Record): Promise<boolean>
|
|
61
|
+
store? (record: storages.Record): Promise<boolean>
|
|
60
62
|
|
|
61
63
|
// assignment
|
|
62
|
-
upsert?(query: storages.Query, changeset: Object, insert: storages.Record): Promise<storages.Record>
|
|
64
|
+
upsert? (query: storages.Query, changeset: Object, insert: storages.Record): Promise<storages.Record>
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { SystemException } = require('../exceptions')
|
|
4
|
-
|
|
5
|
-
class Conditions {
|
|
6
|
-
#schema
|
|
7
|
-
|
|
8
|
-
constructor (schema) {
|
|
9
|
-
this.#schema = schema
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
fit (value) {
|
|
13
|
-
const error = this.#schema.fit(value)
|
|
14
|
-
|
|
15
|
-
if (error !== null) throw new this.constructor.Exception(error)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
static Exception = SystemException
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
exports.Conditions = Conditions
|