@toa.io/norm 1.0.0-alpha.182 → 1.0.0-alpha.190
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/norm",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.190",
|
|
4
4
|
"description": "Toa declarations normalization and validation",
|
|
5
5
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/toa-io/toa#readme",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@toa.io/core": "1.0.0-alpha.
|
|
23
|
+
"@toa.io/core": "1.0.0-alpha.190",
|
|
24
24
|
"@toa.io/generic": "1.0.0-alpha.173",
|
|
25
25
|
"@toa.io/schemas": "1.0.0-alpha.182",
|
|
26
26
|
"@toa.io/yaml": "1.0.0-alpha.182"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "494b1c8f05c21f377f1152a9d89df5cbbd1001de"
|
|
29
29
|
}
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
const { directory: { find } } = require('@toa.io/filesystem')
|
|
4
4
|
const { resolve } = require('../shortcuts')
|
|
5
5
|
|
|
6
|
+
const cache = {}
|
|
7
|
+
|
|
6
8
|
const extensions = (manifest) => {
|
|
7
9
|
if (manifest.extensions === undefined)
|
|
8
10
|
manifest.extensions = PREDEFINED
|
|
@@ -17,18 +19,12 @@ const extensions = (manifest) => {
|
|
|
17
19
|
// relative path
|
|
18
20
|
if (key[0] === '.') key = find(key, manifest.path)
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
cache[key] ??= require(key)
|
|
23
|
+
const extension = cache[key]
|
|
21
24
|
|
|
22
25
|
if (extension.manifest !== undefined) {
|
|
23
26
|
declaration = extension.manifest(declaration, manifest)
|
|
24
|
-
|
|
25
|
-
if (declaration === undefined) throw new Error(`Extension '${reference}' hasn't returned manifest`)
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
-
extensions[key] = declaration
|
|
29
|
-
|
|
30
|
-
// shortcut was used
|
|
31
|
-
if (reference !== key) delete extensions[reference]
|
|
32
28
|
}
|
|
33
29
|
}
|
|
34
30
|
|
package/src/.component/merge.js
CHANGED
|
@@ -6,7 +6,8 @@ const bridge = async (root, manifest) => {
|
|
|
6
6
|
await Promise.all([
|
|
7
7
|
define(root, manifest, 'operations'),
|
|
8
8
|
define(root, manifest, 'events'),
|
|
9
|
-
define(root, manifest, 'receivers')
|
|
9
|
+
define(root, manifest, 'receivers'),
|
|
10
|
+
define(root, manifest, 'guards')
|
|
10
11
|
])
|
|
11
12
|
}
|
|
12
13
|
|
|
@@ -19,7 +20,7 @@ const define = async (root, manifest, property) => {
|
|
|
19
20
|
if (item.bridge === undefined || item.bridge === manifest.bridge) continue // default bridge later
|
|
20
21
|
|
|
21
22
|
const bridge = item.bridge || manifest.bridge
|
|
22
|
-
const
|
|
23
|
+
const define = req(bridge).define
|
|
23
24
|
const definition = await define[singular](root, endpoint)
|
|
24
25
|
|
|
25
26
|
merge(item, definition)
|
|
@@ -55,8 +56,16 @@ const define = async (root, manifest, property) => {
|
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
const cache = {}
|
|
60
|
+
|
|
61
|
+
function req(mod) {
|
|
62
|
+
cache[mod] ??= require(mod)
|
|
63
|
+
|
|
64
|
+
return cache[mod]
|
|
65
|
+
}
|
|
66
|
+
|
|
58
67
|
const scan = async (bridge, root, property) => {
|
|
59
|
-
const
|
|
68
|
+
const define = req(bridge).define
|
|
60
69
|
|
|
61
70
|
if (property in define)
|
|
62
71
|
return define[property](root)
|
|
@@ -8,7 +8,7 @@ definitions:
|
|
|
8
8
|
binding:
|
|
9
9
|
type: string
|
|
10
10
|
not:
|
|
11
|
-
const:
|
|
11
|
+
const: "@toa.io/bindings.loop" # loop is for system use only
|
|
12
12
|
|
|
13
13
|
type: object
|
|
14
14
|
properties:
|
|
@@ -17,19 +17,19 @@ properties:
|
|
|
17
17
|
nullable: true
|
|
18
18
|
properties:
|
|
19
19
|
prototype:
|
|
20
|
-
$ref:
|
|
20
|
+
$ref: "#/properties/prototype"
|
|
21
21
|
path:
|
|
22
22
|
type: string
|
|
23
23
|
operations:
|
|
24
24
|
type: object
|
|
25
25
|
propertyNames:
|
|
26
|
-
$ref:
|
|
26
|
+
$ref: "#/definitions/name"
|
|
27
27
|
patternProperties:
|
|
28
|
-
|
|
28
|
+
".*":
|
|
29
29
|
type: object
|
|
30
30
|
properties:
|
|
31
31
|
bridge:
|
|
32
|
-
$ref:
|
|
32
|
+
$ref: "#/properties/bridge"
|
|
33
33
|
|
|
34
34
|
path:
|
|
35
35
|
type: string
|
|
@@ -51,10 +51,10 @@ properties:
|
|
|
51
51
|
namespace:
|
|
52
52
|
type: string
|
|
53
53
|
pattern: ^[a-zA-Z]([a-zA-Z0-9]{1,31})?$
|
|
54
|
-
default:
|
|
54
|
+
default: "default"
|
|
55
55
|
not:
|
|
56
56
|
oneOf:
|
|
57
|
-
- const:
|
|
57
|
+
- const: "system"
|
|
58
58
|
|
|
59
59
|
version:
|
|
60
60
|
type: string
|
|
@@ -72,7 +72,7 @@ properties:
|
|
|
72
72
|
properties:
|
|
73
73
|
storage:
|
|
74
74
|
type: string
|
|
75
|
-
default:
|
|
75
|
+
default: "@toa.io/storages.mongodb"
|
|
76
76
|
schema:
|
|
77
77
|
$ref: https://json-schema.org/draft/2019-09/schema
|
|
78
78
|
type: object
|
|
@@ -84,22 +84,22 @@ properties:
|
|
|
84
84
|
type: object
|
|
85
85
|
propertyNames:
|
|
86
86
|
oneOf:
|
|
87
|
-
- $ref:
|
|
87
|
+
- $ref: "#/definitions/name"
|
|
88
88
|
- enum: [_version, _created, _updated, _deleted]
|
|
89
89
|
unique:
|
|
90
90
|
type: object
|
|
91
91
|
patternProperties:
|
|
92
|
-
|
|
92
|
+
".*":
|
|
93
93
|
type: array
|
|
94
94
|
items:
|
|
95
95
|
type: string
|
|
96
96
|
index:
|
|
97
97
|
type: object
|
|
98
98
|
patternProperties:
|
|
99
|
-
|
|
99
|
+
".*":
|
|
100
100
|
type: object
|
|
101
101
|
patternProperties:
|
|
102
|
-
|
|
102
|
+
".*":
|
|
103
103
|
type: string
|
|
104
104
|
enum: [asc, desc, hash, text]
|
|
105
105
|
associated:
|
|
@@ -115,7 +115,7 @@ properties:
|
|
|
115
115
|
type: array
|
|
116
116
|
uniqueItems: true
|
|
117
117
|
items:
|
|
118
|
-
$ref:
|
|
118
|
+
$ref: "#/definitions/binding"
|
|
119
119
|
|
|
120
120
|
bridge:
|
|
121
121
|
type: string
|
|
@@ -123,28 +123,36 @@ properties:
|
|
|
123
123
|
operations:
|
|
124
124
|
type: object
|
|
125
125
|
propertyNames:
|
|
126
|
-
$ref:
|
|
126
|
+
$ref: "#/definitions/name"
|
|
127
127
|
patternProperties:
|
|
128
|
-
|
|
128
|
+
".*":
|
|
129
129
|
type: object
|
|
130
130
|
properties:
|
|
131
131
|
type:
|
|
132
|
-
enum:
|
|
132
|
+
enum:
|
|
133
|
+
[
|
|
134
|
+
transition,
|
|
135
|
+
observation,
|
|
136
|
+
assignment,
|
|
137
|
+
computation,
|
|
138
|
+
effect,
|
|
139
|
+
unmanaged,
|
|
140
|
+
]
|
|
133
141
|
scope:
|
|
134
142
|
enum: [object, objects, changeset, stream, none]
|
|
135
143
|
concurrency:
|
|
136
144
|
enum: [none, retry]
|
|
137
145
|
forward:
|
|
138
|
-
$ref:
|
|
146
|
+
$ref: "#/definitions/name"
|
|
139
147
|
bridge:
|
|
140
148
|
type: string
|
|
141
149
|
bindings:
|
|
142
|
-
$ref:
|
|
150
|
+
$ref: "#/properties/bindings"
|
|
143
151
|
input:
|
|
144
152
|
$ref: https://json-schema.org/draft/2019-09/schema
|
|
145
153
|
output:
|
|
146
154
|
$ref: https://json-schema.org/draft/2019-09/schema
|
|
147
|
-
default: {
|
|
155
|
+
default: {}
|
|
148
156
|
errors:
|
|
149
157
|
type: array
|
|
150
158
|
items:
|
|
@@ -224,9 +232,9 @@ properties:
|
|
|
224
232
|
events:
|
|
225
233
|
type: object
|
|
226
234
|
propertyNames:
|
|
227
|
-
$ref:
|
|
235
|
+
$ref: "#/definitions/name"
|
|
228
236
|
patternProperties:
|
|
229
|
-
|
|
237
|
+
".*":
|
|
230
238
|
type: object
|
|
231
239
|
properties:
|
|
232
240
|
bridge:
|
|
@@ -234,7 +242,7 @@ properties:
|
|
|
234
242
|
path:
|
|
235
243
|
type: string
|
|
236
244
|
binding:
|
|
237
|
-
$ref:
|
|
245
|
+
$ref: "#/definitions/binding"
|
|
238
246
|
conditioned:
|
|
239
247
|
type: boolean
|
|
240
248
|
default: false
|
|
@@ -247,17 +255,17 @@ properties:
|
|
|
247
255
|
receivers:
|
|
248
256
|
type: object
|
|
249
257
|
patternProperties:
|
|
250
|
-
|
|
258
|
+
".*":
|
|
251
259
|
type: object
|
|
252
260
|
properties:
|
|
253
261
|
operation:
|
|
254
|
-
$ref:
|
|
262
|
+
$ref: "#/definitions/name"
|
|
255
263
|
bridge:
|
|
256
264
|
type: string
|
|
257
265
|
binding:
|
|
258
266
|
type: string
|
|
259
267
|
source:
|
|
260
|
-
$ref:
|
|
268
|
+
$ref: "#/definitions/name"
|
|
261
269
|
not:
|
|
262
270
|
const: context
|
|
263
271
|
path:
|
|
@@ -273,6 +281,17 @@ properties:
|
|
|
273
281
|
required: [operation]
|
|
274
282
|
additionalProperties: false
|
|
275
283
|
|
|
284
|
+
guards:
|
|
285
|
+
type: object
|
|
286
|
+
patternProperties:
|
|
287
|
+
".*":
|
|
288
|
+
type: object
|
|
289
|
+
properties:
|
|
290
|
+
bridge: { type: string }
|
|
291
|
+
path: { type: string }
|
|
292
|
+
required: [bridge, path]
|
|
293
|
+
additionalProperties: false
|
|
294
|
+
|
|
276
295
|
extensions:
|
|
277
296
|
type: object
|
|
278
297
|
|