@voxgig/sdkgen 0.33.0 → 0.34.1
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/bin/voxgig-sdkgen +1 -1
- package/package.json +2 -2
- package/project/.sdk/model/feature/log.jsonic +1 -2
- package/project/.sdk/model/feature/test.jsonic +1 -2
- package/project/.sdk/src/cmp/go/TestDirect_go.ts +10 -10
- package/project/.sdk/src/cmp/go/fragment/Entity.fragment.go +3 -3
- package/project/.sdk/src/cmp/js/EntityOperation_js.ts +1 -1
- package/project/.sdk/src/cmp/js/TestDirect_js.ts +12 -12
- package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +5 -5
- package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +5 -5
- package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +5 -5
- package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +6 -6
- package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +5 -5
- package/project/.sdk/src/cmp/ts/EntityBase_ts.ts +38 -0
- package/project/.sdk/src/cmp/ts/EntityOperation_ts.ts +1 -1
- package/project/.sdk/src/cmp/ts/Main_ts.ts +2 -0
- package/project/.sdk/src/cmp/ts/TestDirect_ts.ts +12 -12
- package/project/.sdk/src/cmp/ts/fragment/Entity.fragment.ts +8 -139
- package/project/.sdk/src/cmp/ts/fragment/EntityBase.fragment.ts +161 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.ts +7 -7
- package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.ts +7 -7
- package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.ts +7 -7
- package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.ts +8 -8
- package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.ts +5 -5
- package/project/.sdk/src/cmp/ts/fragment/Main.fragment.ts +2 -1
- package/project/.sdk/tm/go/core/context.go +8 -8
- package/project/.sdk/tm/go/core/operation.go +6 -6
- package/project/.sdk/tm/go/core/target.go +3 -3
- package/project/.sdk/tm/go/core/types.go +1 -3
- package/project/.sdk/tm/go/core/utility_type.go +1 -1
- package/project/.sdk/tm/go/feature/base_feature.go +1 -3
- package/project/.sdk/tm/go/feature/test_feature.go +4 -4
- package/project/.sdk/tm/go/test/primary_utility_test.go +13 -13
- package/project/.sdk/tm/go/utility/make_spec.go +2 -2
- package/project/.sdk/tm/go/utility/make_target.go +18 -18
- package/project/.sdk/tm/go/utility/param.go +3 -3
- package/project/.sdk/tm/go/utility/prepare_params.go +2 -2
- package/project/.sdk/tm/go/utility/prepare_path.go +2 -2
- package/project/.sdk/tm/go/utility/prepare_query.go +3 -3
- package/project/.sdk/tm/go/utility/register.go +1 -1
- package/project/.sdk/tm/go/utility/transform_request.go +2 -2
- package/project/.sdk/tm/go/utility/transform_response.go +2 -2
- package/project/.sdk/tm/js/src/feature/log/LogFeature.js +2 -7
- package/project/.sdk/tm/ts/src/Context.ts +3 -3
- package/project/.sdk/tm/ts/src/Operation.ts +3 -3
- package/project/.sdk/tm/ts/src/{Target.ts → Point.ts} +2 -2
- package/project/.sdk/tm/ts/src/feature/base/BaseFeature.ts +7 -2
- package/project/.sdk/tm/ts/src/feature/log/LogFeature.ts +2 -7
- package/project/.sdk/tm/ts/src/feature/test/TestFeature.ts +3 -3
- package/project/.sdk/tm/ts/src/types.ts +18 -15
- package/project/.sdk/tm/ts/src/utility/{MakeTargetUtility.ts → MakePointUtility.ts} +18 -18
- package/project/.sdk/tm/ts/src/utility/MakeSpecUtility.ts +2 -2
- package/project/.sdk/tm/ts/src/utility/ParamUtility.ts +2 -2
- package/project/.sdk/tm/ts/src/utility/PrepareBodyUtility.ts +1 -1
- package/project/.sdk/tm/ts/src/utility/PrepareParamsUtility.ts +3 -3
- package/project/.sdk/tm/ts/src/utility/PreparePathUtility.ts +2 -2
- package/project/.sdk/tm/ts/src/utility/PrepareQueryUtility.ts +2 -2
- package/project/.sdk/tm/ts/src/utility/TransformRequestUtility.ts +2 -2
- package/project/.sdk/tm/ts/src/utility/TransformResponseUtility.ts +2 -2
- package/project/.sdk/tm/ts/src/utility/Utility.ts +2 -2
- package/project/.sdk/tm/ts/test/utility/PrimaryUtility.test.ts +8 -8
|
@@ -8,10 +8,10 @@ import (
|
|
|
8
8
|
"GOMODULE/core"
|
|
9
9
|
)
|
|
10
10
|
|
|
11
|
-
func
|
|
12
|
-
if ctx.Out["
|
|
13
|
-
if tm, ok := ctx.Out["
|
|
14
|
-
ctx.
|
|
11
|
+
func makePointUtil(ctx *core.Context) (map[string]any, error) {
|
|
12
|
+
if ctx.Out["point"] != nil {
|
|
13
|
+
if tm, ok := ctx.Out["point"].(map[string]any); ok {
|
|
14
|
+
ctx.Point = tm
|
|
15
15
|
return tm, nil
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -21,13 +21,13 @@ func makeTargetUtil(ctx *core.Context) (map[string]any, error) {
|
|
|
21
21
|
|
|
22
22
|
allowOp, _ := vs.GetPath([]any{"allow", "op"}, options).(string)
|
|
23
23
|
if !strings.Contains(allowOp, op.Name) {
|
|
24
|
-
return nil, ctx.MakeError("
|
|
24
|
+
return nil, ctx.MakeError("point_op_allow",
|
|
25
25
|
"Operation \""+op.Name+
|
|
26
26
|
"\" not allowed by SDK option allow.op value: \""+allowOp+"\"")
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
if len(op.
|
|
30
|
-
ctx.
|
|
29
|
+
if len(op.Points) == 1 {
|
|
30
|
+
ctx.Point = op.Points[0]
|
|
31
31
|
} else {
|
|
32
32
|
var reqselector map[string]any
|
|
33
33
|
var selector map[string]any
|
|
@@ -40,10 +40,10 @@ func makeTargetUtil(ctx *core.Context) (map[string]any, error) {
|
|
|
40
40
|
selector = ctx.Match
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
var
|
|
44
|
-
for i := 0; i < len(op.
|
|
45
|
-
|
|
46
|
-
selectDef := core.ToMapAny(vs.GetProp(
|
|
43
|
+
var point map[string]any
|
|
44
|
+
for i := 0; i < len(op.Points); i++ {
|
|
45
|
+
point = op.Points[i]
|
|
46
|
+
selectDef := core.ToMapAny(vs.GetProp(point, "select"))
|
|
47
47
|
found := true
|
|
48
48
|
|
|
49
49
|
if selector != nil && selectDef != nil {
|
|
@@ -77,19 +77,19 @@ func makeTargetUtil(ctx *core.Context) (map[string]any, error) {
|
|
|
77
77
|
|
|
78
78
|
if reqselector != nil {
|
|
79
79
|
reqAction := vs.GetProp(reqselector, "$action")
|
|
80
|
-
if reqAction != nil &&
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if reqAction !=
|
|
84
|
-
return nil, ctx.MakeError("
|
|
80
|
+
if reqAction != nil && point != nil {
|
|
81
|
+
pointSelect := core.ToMapAny(vs.GetProp(point, "select"))
|
|
82
|
+
pointAction := vs.GetProp(pointSelect, "$action")
|
|
83
|
+
if reqAction != pointAction {
|
|
84
|
+
return nil, ctx.MakeError("point_action_invalid",
|
|
85
85
|
"Operation \""+op.Name+
|
|
86
86
|
"\" action \""+vs.Stringify(reqAction)+"\" is not valid.")
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
ctx.
|
|
91
|
+
ctx.Point = point
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
return ctx.
|
|
94
|
+
return ctx.Point, nil
|
|
95
95
|
}
|
|
@@ -7,7 +7,7 @@ import (
|
|
|
7
7
|
)
|
|
8
8
|
|
|
9
9
|
func paramUtil(ctx *core.Context, paramdef any) any {
|
|
10
|
-
|
|
10
|
+
point := ctx.Point
|
|
11
11
|
spec := ctx.Spec
|
|
12
12
|
match := ctx.Match
|
|
13
13
|
reqmatch := ctx.Reqmatch
|
|
@@ -25,8 +25,8 @@ func paramUtil(ctx *core.Context, paramdef any) any {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
var akey string
|
|
28
|
-
if
|
|
29
|
-
alias := core.ToMapAny(vs.GetProp(
|
|
28
|
+
if point != nil {
|
|
29
|
+
alias := core.ToMapAny(vs.GetProp(point, "alias"))
|
|
30
30
|
if alias != nil {
|
|
31
31
|
if ak := vs.GetProp(alias, key); ak != nil {
|
|
32
32
|
akey, _ = ak.(string)
|
|
@@ -8,10 +8,10 @@ import (
|
|
|
8
8
|
|
|
9
9
|
func prepareParamsUtil(ctx *core.Context) map[string]any {
|
|
10
10
|
utility := ctx.Utility
|
|
11
|
-
|
|
11
|
+
point := ctx.Point
|
|
12
12
|
|
|
13
13
|
var params []any
|
|
14
|
-
if args := vs.GetProp(
|
|
14
|
+
if args := vs.GetProp(point, "args"); args != nil {
|
|
15
15
|
if argsMap, ok := args.(map[string]any); ok {
|
|
16
16
|
if p := vs.GetProp(argsMap, "params"); p != nil {
|
|
17
17
|
if pl, ok := p.([]any); ok {
|
|
@@ -7,10 +7,10 @@ import (
|
|
|
7
7
|
)
|
|
8
8
|
|
|
9
9
|
func preparePathUtil(ctx *core.Context) string {
|
|
10
|
-
|
|
10
|
+
point := ctx.Point
|
|
11
11
|
|
|
12
12
|
var parts []any
|
|
13
|
-
if p := vs.GetProp(
|
|
13
|
+
if p := vs.GetProp(point, "parts"); p != nil {
|
|
14
14
|
if pl, ok := p.([]any); ok {
|
|
15
15
|
parts = pl
|
|
16
16
|
}
|
|
@@ -7,15 +7,15 @@ import (
|
|
|
7
7
|
)
|
|
8
8
|
|
|
9
9
|
func prepareQueryUtil(ctx *core.Context) map[string]any {
|
|
10
|
-
|
|
10
|
+
point := ctx.Point
|
|
11
11
|
reqmatch := ctx.Reqmatch
|
|
12
12
|
if reqmatch == nil {
|
|
13
13
|
reqmatch = map[string]any{}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
var params []any
|
|
17
|
-
if
|
|
18
|
-
if p := vs.GetProp(
|
|
17
|
+
if point != nil {
|
|
18
|
+
if p := vs.GetProp(point, "params"); p != nil {
|
|
19
19
|
if pl, ok := p.([]any); ok {
|
|
20
20
|
params = pl
|
|
21
21
|
}
|
|
@@ -20,7 +20,7 @@ func registerAll(u *core.Utility) {
|
|
|
20
20
|
u.MakeRequest = makeRequestUtil
|
|
21
21
|
u.MakeResponse = makeResponseUtil
|
|
22
22
|
u.MakeResult = makeResultUtil
|
|
23
|
-
u.
|
|
23
|
+
u.MakePoint = makePointUtil
|
|
24
24
|
u.MakeSpec = makeSpecUtil
|
|
25
25
|
u.MakeUrl = makeUrlUtil
|
|
26
26
|
u.Param = paramUtil
|
|
@@ -8,13 +8,13 @@ import (
|
|
|
8
8
|
|
|
9
9
|
func transformRequestUtil(ctx *core.Context) any {
|
|
10
10
|
spec := ctx.Spec
|
|
11
|
-
|
|
11
|
+
point := ctx.Point
|
|
12
12
|
|
|
13
13
|
if spec != nil {
|
|
14
14
|
spec.Step = "reqform"
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
transform := core.ToMapAny(vs.GetProp(
|
|
17
|
+
transform := core.ToMapAny(vs.GetProp(point, "transform"))
|
|
18
18
|
if transform == nil {
|
|
19
19
|
return ctx.Reqdata
|
|
20
20
|
}
|
|
@@ -9,7 +9,7 @@ import (
|
|
|
9
9
|
func transformResponseUtil(ctx *core.Context) any {
|
|
10
10
|
spec := ctx.Spec
|
|
11
11
|
result := ctx.Result
|
|
12
|
-
|
|
12
|
+
point := ctx.Point
|
|
13
13
|
|
|
14
14
|
if spec != nil {
|
|
15
15
|
spec.Step = "resform"
|
|
@@ -19,7 +19,7 @@ func transformResponseUtil(ctx *core.Context) any {
|
|
|
19
19
|
return nil
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
transform := core.ToMapAny(vs.GetProp(
|
|
22
|
+
transform := core.ToMapAny(vs.GetProp(point, "transform"))
|
|
23
23
|
if transform == nil {
|
|
24
24
|
return nil
|
|
25
25
|
}
|
|
@@ -69,8 +69,8 @@ class LogFeature {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
this.#loghook('
|
|
72
|
+
PrePoint(ctx) {
|
|
73
|
+
this.#loghook('PrePoint', ctx)
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
PreSpec(ctx) {
|
|
@@ -89,11 +89,6 @@ class LogFeature {
|
|
|
89
89
|
this.#loghook('PreResult', ctx)
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
PostOperation(ctx) {
|
|
93
|
-
this.#loghook('PostOperation', ctx)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
92
|
#loghook(hook, ctx, level) {
|
|
98
93
|
level = level || 'info'
|
|
99
94
|
if(this.#logger) {
|
|
@@ -32,7 +32,7 @@ class Context {
|
|
|
32
32
|
utility: Utility
|
|
33
33
|
|
|
34
34
|
op: Operation
|
|
35
|
-
|
|
35
|
+
point: any
|
|
36
36
|
|
|
37
37
|
config: Record<string, any>
|
|
38
38
|
entopts: Record<string, any>
|
|
@@ -75,7 +75,7 @@ class Context {
|
|
|
75
75
|
this.match = getprop(ctxmap, 'match', {})
|
|
76
76
|
this.reqmatch = getprop(ctxmap, 'reqmatch', {})
|
|
77
77
|
|
|
78
|
-
this.
|
|
78
|
+
this.point = getprop(ctxmap, 'point', getprop(basectx, 'point'))
|
|
79
79
|
this.spec = getprop(ctxmap, 'spec', getprop(basectx, 'spec'))
|
|
80
80
|
this.result = getprop(ctxmap, 'result', getprop(basectx, 'result'))
|
|
81
81
|
this.response = getprop(ctxmap, 'response', getprop(basectx, 'response'))
|
|
@@ -101,7 +101,7 @@ class Context {
|
|
|
101
101
|
entity: entname,
|
|
102
102
|
name: opname,
|
|
103
103
|
input,
|
|
104
|
-
|
|
104
|
+
points: getprop(opcfg, 'points', [])
|
|
105
105
|
})
|
|
106
106
|
|
|
107
107
|
setprop(this.opmap, opname, op)
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
|
|
2
2
|
import { getprop } from './utility/StructUtility'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { Point } from './Point'
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class Operation {
|
|
8
8
|
entity: string
|
|
9
9
|
name: string
|
|
10
10
|
input: string
|
|
11
|
-
|
|
11
|
+
points: Point[]
|
|
12
12
|
|
|
13
13
|
constructor(opmap: Record<string, any>) {
|
|
14
14
|
this.entity = getprop(opmap, 'entity', '_')
|
|
15
15
|
this.name = getprop(opmap, 'name', '_')
|
|
16
16
|
this.input = getprop(opmap, 'input', '_')
|
|
17
|
-
this.
|
|
17
|
+
this.points = getprop(opmap, 'points', [])
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { getprop } from './utility/StructUtility'
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
class
|
|
5
|
+
class Point {
|
|
6
6
|
args: { params: any[] }
|
|
7
7
|
rename: { params: Record<string, string> }
|
|
8
8
|
method: string
|
|
@@ -32,5 +32,5 @@ class Target {
|
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
export {
|
|
35
|
-
|
|
35
|
+
Point,
|
|
36
36
|
}
|
|
@@ -16,14 +16,17 @@ class BaseFeature implements Feature {
|
|
|
16
16
|
|
|
17
17
|
PostConstructEntity(this: any, _ctx: any) { }
|
|
18
18
|
|
|
19
|
+
|
|
19
20
|
SetData(this: any, _ctx: any) { }
|
|
20
21
|
|
|
21
22
|
GetData(this: any, _ctx: any) { }
|
|
22
23
|
|
|
24
|
+
SetMatch(this: any, _ctx: any) { }
|
|
25
|
+
|
|
23
26
|
GetMatch(this: any, _ctx: any) { }
|
|
24
27
|
|
|
25
28
|
|
|
26
|
-
|
|
29
|
+
PrePoint(this: any, _ctx: any) { }
|
|
27
30
|
|
|
28
31
|
PreSpec(this: any, _ctx: any) { }
|
|
29
32
|
|
|
@@ -33,7 +36,9 @@ class BaseFeature implements Feature {
|
|
|
33
36
|
|
|
34
37
|
PreResult(this: any, _ctx: any) { }
|
|
35
38
|
|
|
36
|
-
|
|
39
|
+
PreDone(this: any, _ctx: any) { }
|
|
40
|
+
|
|
41
|
+
PreUnexpected(this: any, _ctx: any) { }
|
|
37
42
|
|
|
38
43
|
}
|
|
39
44
|
|
|
@@ -65,8 +65,8 @@ class LogFeature extends BaseFeature {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
this._loghook('
|
|
68
|
+
PrePoint(this: any, ctx: any) {
|
|
69
|
+
this._loghook('PrePoint', ctx)
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
PreSpec(this: any, ctx: any) {
|
|
@@ -85,11 +85,6 @@ class LogFeature extends BaseFeature {
|
|
|
85
85
|
this._loghook('PreResult', ctx)
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
PostOperation(this: any, ctx: any) {
|
|
89
|
-
this._loghook('PostOperation', ctx)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
88
|
_loghook(this: any, hook: any, ctx: any, level: any) {
|
|
94
89
|
level = level || 'info'
|
|
95
90
|
if (this._logger) {
|
|
@@ -168,12 +168,12 @@ class TestFeature extends BaseFeature {
|
|
|
168
168
|
const isempty = struct.isempty
|
|
169
169
|
|
|
170
170
|
const opname = getprop(op, 'name')
|
|
171
|
-
const
|
|
171
|
+
const point =
|
|
172
172
|
getelem(getpath(ctx.config, [
|
|
173
|
-
'entity', getprop(ctx.entity, 'name'), 'op', opname, '
|
|
173
|
+
'entity', getprop(ctx.entity, 'name'), 'op', opname, 'points']), -1)
|
|
174
174
|
|
|
175
175
|
const reqd = transform(
|
|
176
|
-
select(getpath(
|
|
176
|
+
select(getpath(point, ['args', 'params']), { reqd: true }),
|
|
177
177
|
['`$EACH`', '', '`$KEY.name`']
|
|
178
178
|
)
|
|
179
179
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { ProjectNameEntityBase } from './ProjectNameEntityBase'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { Point } from './Point'
|
|
5
5
|
import { Context } from './Context'
|
|
6
6
|
import { Control } from './Control'
|
|
7
7
|
import { Operation } from './Operation'
|
|
@@ -22,29 +22,32 @@ interface Feature {
|
|
|
22
22
|
|
|
23
23
|
init: (ctx: Context, options: FeatureOptions) => void | Promise<any>
|
|
24
24
|
|
|
25
|
-
PostConstruct: (
|
|
26
|
-
PostConstructEntity: (
|
|
27
|
-
SetData: (
|
|
28
|
-
GetData: (
|
|
29
|
-
GetMatch: (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
PreSpec: (
|
|
33
|
-
PreRequest: (
|
|
34
|
-
PreResponse: (
|
|
35
|
-
PreResult: (
|
|
36
|
-
|
|
25
|
+
PostConstruct: (ctx: Context) => void | Promise<any>
|
|
26
|
+
PostConstructEntity: (ctx: Context) => void | Promise<any>
|
|
27
|
+
SetData: (ctx: Context) => void | Promise<any>
|
|
28
|
+
GetData: (ctx: Context) => void | Promise<any>
|
|
29
|
+
GetMatch: (ctx: Context) => void | Promise<any>
|
|
30
|
+
|
|
31
|
+
PrePoint: (ctx: Context) => void | Promise<any>
|
|
32
|
+
PreSpec: (ctx: Context) => void | Promise<any>
|
|
33
|
+
PreRequest: (ctx: Context) => void | Promise<any>
|
|
34
|
+
PreResponse: (ctx: Context) => void | Promise<any>
|
|
35
|
+
PreResult: (ctx: Context) => void | Promise<any>
|
|
36
|
+
PreDone: (ctx: Context) => void | Promise<any>
|
|
37
|
+
PreUnexpected: (ctx: Context) => void | Promise<any>
|
|
38
|
+
SetMatch: (ctx: Context) => void | Promise<any>
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
|
|
40
42
|
export {
|
|
41
|
-
|
|
43
|
+
Point,
|
|
42
44
|
Context,
|
|
43
45
|
Control,
|
|
44
46
|
Operation,
|
|
45
47
|
Response,
|
|
46
48
|
Result,
|
|
47
49
|
Spec,
|
|
50
|
+
ProjectNameEntityBase,
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
|
|
2
|
-
import { Context,
|
|
2
|
+
import { Context, Point } from '../types'
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
function
|
|
6
|
-
if (ctx.out.
|
|
7
|
-
return ctx.
|
|
5
|
+
function makePoint(ctx: Context): Point | Error {
|
|
6
|
+
if (ctx.out.point) {
|
|
7
|
+
return ctx.point = ctx.out.point
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
const getprop = ctx.utility.struct.getprop
|
|
@@ -12,23 +12,23 @@ function makeTarget(ctx: Context): Target | Error {
|
|
|
12
12
|
const options = ctx.options
|
|
13
13
|
|
|
14
14
|
if (!options.allow.op.includes(op.name)) {
|
|
15
|
-
ctx.error('
|
|
15
|
+
return ctx.error('point_op_allow', 'Operation "' + op.name +
|
|
16
16
|
'" not allowed by SDK option allow.op value: "' + options.allow.op + '"')
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
// Choose the appropriate
|
|
20
|
-
if (1 === op.
|
|
21
|
-
ctx.
|
|
19
|
+
// Choose the appropriate point based on the match or data.
|
|
20
|
+
if (1 === op.points.length) {
|
|
21
|
+
ctx.point = op.points[0]
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
24
|
// Operation argument has priority, but also look in current data or match.
|
|
25
25
|
const reqselector = getprop(ctx, 'req' + op.input)
|
|
26
26
|
const selector = getprop(ctx, op.input)
|
|
27
27
|
|
|
28
|
-
let
|
|
29
|
-
for (let i = 0; i < op.
|
|
30
|
-
|
|
31
|
-
const select =
|
|
28
|
+
let point
|
|
29
|
+
for (let i = 0; i < op.points.length; i++) {
|
|
30
|
+
point = op.points[i]
|
|
31
|
+
const select = point.select
|
|
32
32
|
let found = true
|
|
33
33
|
|
|
34
34
|
if (selector && select.exist) {
|
|
@@ -57,20 +57,20 @@ function makeTarget(ctx: Context): Target | Error {
|
|
|
57
57
|
|
|
58
58
|
if (
|
|
59
59
|
null != reqselector.$action &&
|
|
60
|
-
null !=
|
|
61
|
-
reqselector.$action !==
|
|
60
|
+
null != point &&
|
|
61
|
+
reqselector.$action !== point.select.$action
|
|
62
62
|
) {
|
|
63
|
-
return ctx.error('
|
|
63
|
+
return ctx.error('point_action_invalid', 'Operation "' + op.name +
|
|
64
64
|
'" action "' + reqselector.$action + '" is not valid.')
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
ctx.
|
|
67
|
+
ctx.point = point
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
return ctx.
|
|
70
|
+
return ctx.point
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
|
|
74
74
|
export {
|
|
75
|
-
|
|
75
|
+
makePoint,
|
|
76
76
|
}
|
|
@@ -8,7 +8,7 @@ function makeSpec(ctx: Context): Spec | Error {
|
|
|
8
8
|
return ctx.spec = ctx.out.spec
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const point = ctx.point
|
|
12
12
|
const options = ctx.options
|
|
13
13
|
const utility = ctx.utility
|
|
14
14
|
|
|
@@ -23,7 +23,7 @@ function makeSpec(ctx: Context): Spec | Error {
|
|
|
23
23
|
ctx.spec = new Spec({
|
|
24
24
|
base: options.base, // string, URL endpoint base prefix,
|
|
25
25
|
prefix: options.prefix,
|
|
26
|
-
parts:
|
|
26
|
+
parts: point.parts,
|
|
27
27
|
suffix: options.suffix,
|
|
28
28
|
step: 'start',
|
|
29
29
|
})
|
|
@@ -9,7 +9,7 @@ import { Context } from '../types'
|
|
|
9
9
|
* This function returns `undefined` rather than failing.
|
|
10
10
|
*/
|
|
11
11
|
function param(ctx: Context, paramdef: any) {
|
|
12
|
-
const
|
|
12
|
+
const point = ctx.point
|
|
13
13
|
const spec = ctx.spec
|
|
14
14
|
const match = ctx.match
|
|
15
15
|
const reqmatch = ctx.reqmatch
|
|
@@ -31,7 +31,7 @@ function param(ctx: Context, paramdef: any) {
|
|
|
31
31
|
|
|
32
32
|
const key = 0 < (T_string & pt) ? paramdef : getprop(paramdef, 'name')
|
|
33
33
|
|
|
34
|
-
let akey = getprop(
|
|
34
|
+
let akey = getprop(point.alias, key)
|
|
35
35
|
|
|
36
36
|
let val = getprop(reqmatch, key)
|
|
37
37
|
|
|
@@ -9,9 +9,9 @@ function prepareParams(ctx: Context) {
|
|
|
9
9
|
// const struct = utility.struct
|
|
10
10
|
// const validate = struct.validate
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const point = ctx.point
|
|
13
13
|
|
|
14
|
-
let params =
|
|
14
|
+
let params = point.args.params
|
|
15
15
|
// let reqmatch = ctx.reqmatch
|
|
16
16
|
|
|
17
17
|
params = params || []
|
|
@@ -26,7 +26,7 @@ function prepareParams(ctx: Context) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
// TODO: review
|
|
29
|
-
// out = validate(out,
|
|
29
|
+
// out = validate(out, point.validate.params)
|
|
30
30
|
|
|
31
31
|
return out
|
|
32
32
|
}
|
|
@@ -4,9 +4,9 @@ import { Context } from '../types'
|
|
|
4
4
|
|
|
5
5
|
function preparePath(ctx: Context) {
|
|
6
6
|
const join = ctx.utility.struct.join
|
|
7
|
-
const
|
|
7
|
+
const point = ctx.point
|
|
8
8
|
|
|
9
|
-
const path = join(
|
|
9
|
+
const path = join(point.parts, '/', true)
|
|
10
10
|
|
|
11
11
|
return path
|
|
12
12
|
}
|
|
@@ -7,8 +7,8 @@ function prepareQuery(ctx: Context) {
|
|
|
7
7
|
const struct = utility.struct
|
|
8
8
|
const items = struct.items
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
let params =
|
|
10
|
+
const point = ctx.point
|
|
11
|
+
let params = point.params
|
|
12
12
|
let reqmatch = ctx.reqmatch
|
|
13
13
|
|
|
14
14
|
params = params || []
|
|
@@ -8,7 +8,7 @@ import { Context } from '../types'
|
|
|
8
8
|
function transformRequest(ctx: Context) {
|
|
9
9
|
const spec = ctx.spec
|
|
10
10
|
const utility = ctx.utility
|
|
11
|
-
const
|
|
11
|
+
const point = ctx.point
|
|
12
12
|
const isfunc = utility.struct.isfunc
|
|
13
13
|
const transform = utility.struct.transform
|
|
14
14
|
|
|
@@ -17,7 +17,7 @@ function transformRequest(ctx: Context) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
try {
|
|
20
|
-
const reqform =
|
|
20
|
+
const reqform = point.transform.req
|
|
21
21
|
const reqdata = isfunc(reqform) ? reqform(ctx) : transform({
|
|
22
22
|
reqdata: ctx.reqdata
|
|
23
23
|
}, reqform)
|
|
@@ -10,7 +10,7 @@ function transformResponse(ctx: Context) {
|
|
|
10
10
|
const spec = ctx.spec
|
|
11
11
|
const result = ctx.result
|
|
12
12
|
const utility = ctx.utility
|
|
13
|
-
const
|
|
13
|
+
const point = ctx.point
|
|
14
14
|
const isfunc = utility.struct.isfunc
|
|
15
15
|
const transform = utility.struct.transform
|
|
16
16
|
|
|
@@ -23,7 +23,7 @@ function transformResponse(ctx: Context) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
try {
|
|
26
|
-
const resform =
|
|
26
|
+
const resform = point.transform.res
|
|
27
27
|
const resdata = isfunc(resform) ? resform(ctx) : transform(ctx.result, resform)
|
|
28
28
|
result.resdata = resdata
|
|
29
29
|
return resdata
|
|
@@ -13,7 +13,7 @@ import { makeOptions } from './MakeOptionsUtility'
|
|
|
13
13
|
import { makeRequest } from './MakeRequestUtility'
|
|
14
14
|
import { makeResponse } from './MakeResponseUtility'
|
|
15
15
|
import { makeResult } from './MakeResultUtility'
|
|
16
|
-
import {
|
|
16
|
+
import { makePoint } from './MakePointUtility'
|
|
17
17
|
import { makeSpec } from './MakeSpecUtility'
|
|
18
18
|
import { makeUrl } from './MakeUrlUtility'
|
|
19
19
|
import { param } from './ParamUtility'
|
|
@@ -48,7 +48,7 @@ class Utility {
|
|
|
48
48
|
makeRequest = makeRequest
|
|
49
49
|
makeResponse = makeResponse
|
|
50
50
|
makeResult = makeResult
|
|
51
|
-
|
|
51
|
+
makePoint = makePoint
|
|
52
52
|
makeSpec = makeSpec
|
|
53
53
|
makeUrl = makeUrl
|
|
54
54
|
param = param
|