@voxgig/sdkgen 0.34.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
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
|
|
2
|
+
import { inspect } from 'node:util'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
SdkNameSDK,
|
|
6
|
+
} from '../SdkNameSDK'
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
Utility
|
|
10
|
+
} from '../utility/Utility'
|
|
11
|
+
|
|
12
|
+
import type {
|
|
13
|
+
Context,
|
|
14
|
+
} from '../types'
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
// TODO: needs Entity superclass
|
|
18
|
+
class ProjectNameEntityBase {
|
|
19
|
+
name = ''
|
|
20
|
+
name_ = ''
|
|
21
|
+
Name = ''
|
|
22
|
+
|
|
23
|
+
_client: SdkNameSDK
|
|
24
|
+
_utility: Utility
|
|
25
|
+
_entopts: any
|
|
26
|
+
_data: any
|
|
27
|
+
_match: any
|
|
28
|
+
_entctx: Context
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
constructor(client: SdkNameSDK, entopts: any) {
|
|
32
|
+
entopts = entopts || {}
|
|
33
|
+
entopts.active = false !== entopts.active
|
|
34
|
+
|
|
35
|
+
this._client = client
|
|
36
|
+
this._entopts = entopts
|
|
37
|
+
this._utility = client.utility()
|
|
38
|
+
this._data = {}
|
|
39
|
+
this._match = {}
|
|
40
|
+
|
|
41
|
+
const makeContext = this._utility.makeContext
|
|
42
|
+
|
|
43
|
+
this._entctx = makeContext({
|
|
44
|
+
entity: this,
|
|
45
|
+
entopts,
|
|
46
|
+
}, client._rootctx)
|
|
47
|
+
|
|
48
|
+
const featureHook = this._utility.featureHook
|
|
49
|
+
featureHook(this._entctx, 'PostConstructEntity')
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
entopts() {
|
|
53
|
+
return this._utility.merge({}, this._entopts, 1)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
client() {
|
|
57
|
+
return this._client
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
data(this: any, data?: any) {
|
|
62
|
+
const struct = this._utility.struct
|
|
63
|
+
const featureHook = this._utility.featureHook
|
|
64
|
+
|
|
65
|
+
if (null != data) {
|
|
66
|
+
this._data = struct.clone(data)
|
|
67
|
+
featureHook(this._entctx, 'SetData')
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
featureHook(this._entctx, 'GetData')
|
|
71
|
+
let out = struct.clone(this._data)
|
|
72
|
+
|
|
73
|
+
return out
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
match(match?: any) {
|
|
78
|
+
const struct = this._utility.struct
|
|
79
|
+
const featureHook = this._utility.featureHook
|
|
80
|
+
|
|
81
|
+
if (null != match) {
|
|
82
|
+
this._match = struct.clone(match)
|
|
83
|
+
featureHook(this._entctx, 'SetMatch')
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
featureHook(this._entctx, 'GetMatch')
|
|
87
|
+
let out = struct.clone(this._match)
|
|
88
|
+
|
|
89
|
+
return out
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
toJSON() {
|
|
94
|
+
const struct = this._utility.struct
|
|
95
|
+
return struct.merge([{}, struct.getdef(this._data, {}), { entity$: this.Name }])
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
toString() {
|
|
100
|
+
return this.Name + ' ' + this._utility.struct.jsonify(this._data)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
[inspect.custom]() {
|
|
105
|
+
return this.toString()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
_unexpected(this: any, ctx: Context, err: any) {
|
|
110
|
+
const clean = this._utility.clean
|
|
111
|
+
const struct = this._utility.struct
|
|
112
|
+
|
|
113
|
+
const delprop = struct.delprop
|
|
114
|
+
const clone = struct.clone
|
|
115
|
+
const merge = struct.merge
|
|
116
|
+
|
|
117
|
+
const ctrl = ctx.ctrl
|
|
118
|
+
|
|
119
|
+
ctrl.err = err
|
|
120
|
+
|
|
121
|
+
if (ctrl.explain) {
|
|
122
|
+
ctx.ctrl.explain = clean(ctx, ctx.ctrl.explain)
|
|
123
|
+
delprop(ctx.ctrl.explain.result, 'err')
|
|
124
|
+
|
|
125
|
+
if (null != ctx.result && null != ctx.result.err) {
|
|
126
|
+
ctrl.explain.err = clean(ctx, merge([
|
|
127
|
+
clone({ err: ctx.result.err }).err,
|
|
128
|
+
{
|
|
129
|
+
message: ctx.result.err.message,
|
|
130
|
+
stack: ctx.result.err.stack,
|
|
131
|
+
}]))
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const cleanerr = clean(ctx, merge([
|
|
135
|
+
clone({ err }).err,
|
|
136
|
+
{
|
|
137
|
+
message: err.message,
|
|
138
|
+
stack: err.stack,
|
|
139
|
+
}]))
|
|
140
|
+
|
|
141
|
+
if (null == ctrl.explain.err) {
|
|
142
|
+
ctrl.explain.err = cleanerr
|
|
143
|
+
}
|
|
144
|
+
else if (ctrl.explain.err.message != cleanerr.message) {
|
|
145
|
+
ctrl.explain.unexpected = cleanerr
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (false === ctrl.throw) {
|
|
150
|
+
return undefined
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return err
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
export {
|
|
160
|
+
ProjectNameEntityBase
|
|
161
|
+
}
|
|
@@ -18,7 +18,7 @@ class EntityOperation {
|
|
|
18
18
|
done,
|
|
19
19
|
error,
|
|
20
20
|
featureHook,
|
|
21
|
-
|
|
21
|
+
makePoint,
|
|
22
22
|
makeRequest,
|
|
23
23
|
makeResponse,
|
|
24
24
|
makeResult,
|
|
@@ -36,11 +36,11 @@ class EntityOperation {
|
|
|
36
36
|
}, this._entctx)
|
|
37
37
|
|
|
38
38
|
try {
|
|
39
|
-
// #
|
|
39
|
+
// #PrePoint-Hook
|
|
40
40
|
|
|
41
|
-
ctx.out.
|
|
42
|
-
if (ctx.out.
|
|
43
|
-
return error(ctx, ctx.out.
|
|
41
|
+
ctx.out.point = makePoint(ctx)
|
|
42
|
+
if (ctx.out.point instanceof Error) {
|
|
43
|
+
return error(ctx, ctx.out.point)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
|
|
@@ -89,7 +89,7 @@ class EntityOperation {
|
|
|
89
89
|
catch (err: any) {
|
|
90
90
|
// #PreUnexpected-Hook
|
|
91
91
|
|
|
92
|
-
err = this
|
|
92
|
+
err = this._unexpected(ctx, err)
|
|
93
93
|
|
|
94
94
|
if (err) {
|
|
95
95
|
throw err
|
|
@@ -103,5 +103,5 @@ class EntityOperation {
|
|
|
103
103
|
// EJECT-END
|
|
104
104
|
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
_unexpected(this: any, ctx: Context, ctrl: any, err: any): any { return err }
|
|
107
107
|
}
|
|
@@ -19,7 +19,7 @@ class EntityOperation {
|
|
|
19
19
|
done,
|
|
20
20
|
error,
|
|
21
21
|
featureHook,
|
|
22
|
-
|
|
22
|
+
makePoint,
|
|
23
23
|
makeRequest,
|
|
24
24
|
makeResponse,
|
|
25
25
|
makeResult,
|
|
@@ -37,11 +37,11 @@ class EntityOperation {
|
|
|
37
37
|
}, this._entctx)
|
|
38
38
|
|
|
39
39
|
try {
|
|
40
|
-
// #
|
|
40
|
+
// #PrePoint-Hook
|
|
41
41
|
|
|
42
|
-
ctx.out.
|
|
43
|
-
if (ctx.out.
|
|
44
|
-
return error(ctx, ctx.out.
|
|
42
|
+
ctx.out.point = makePoint(ctx)
|
|
43
|
+
if (ctx.out.point instanceof Error) {
|
|
44
|
+
return error(ctx, ctx.out.point)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
|
|
@@ -90,7 +90,7 @@ class EntityOperation {
|
|
|
90
90
|
catch (err: any) {
|
|
91
91
|
// #PreUnexpected-Hook
|
|
92
92
|
|
|
93
|
-
err = this
|
|
93
|
+
err = this._unexpected(ctx, err)
|
|
94
94
|
|
|
95
95
|
if (err) {
|
|
96
96
|
throw err
|
|
@@ -104,7 +104,7 @@ class EntityOperation {
|
|
|
104
104
|
// EJECT-END
|
|
105
105
|
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
_unexpected(this: any, _ctx: Context, _ctrl: any, err: any): any { return err }
|
|
108
108
|
|
|
109
109
|
}
|
|
110
110
|
|
|
@@ -19,7 +19,7 @@ class EntityOperation {
|
|
|
19
19
|
done,
|
|
20
20
|
error,
|
|
21
21
|
featureHook,
|
|
22
|
-
|
|
22
|
+
makePoint,
|
|
23
23
|
makeRequest,
|
|
24
24
|
makeResponse,
|
|
25
25
|
makeResult,
|
|
@@ -37,11 +37,11 @@ class EntityOperation {
|
|
|
37
37
|
}, this._entctx)
|
|
38
38
|
|
|
39
39
|
try {
|
|
40
|
-
// #
|
|
40
|
+
// #PrePoint-Hook
|
|
41
41
|
|
|
42
|
-
ctx.out.
|
|
43
|
-
if (ctx.out.
|
|
44
|
-
return error(ctx, ctx.out.
|
|
42
|
+
ctx.out.point = makePoint(ctx)
|
|
43
|
+
if (ctx.out.point instanceof Error) {
|
|
44
|
+
return error(ctx, ctx.out.point)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
|
|
@@ -94,7 +94,7 @@ class EntityOperation {
|
|
|
94
94
|
catch (err: any) {
|
|
95
95
|
// #PreUnexpected-Hook
|
|
96
96
|
|
|
97
|
-
err = this
|
|
97
|
+
err = this._unexpected(ctx, err)
|
|
98
98
|
|
|
99
99
|
if (err) {
|
|
100
100
|
throw err
|
|
@@ -108,6 +108,6 @@ class EntityOperation {
|
|
|
108
108
|
// EJECT-END
|
|
109
109
|
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
_unexpected(this: any, ctx: Context, ctrl: any, err: any): any { return err }
|
|
112
112
|
}
|
|
113
113
|
|
|
@@ -19,7 +19,7 @@ class EntityOperation {
|
|
|
19
19
|
done,
|
|
20
20
|
error,
|
|
21
21
|
featureHook,
|
|
22
|
-
|
|
22
|
+
makePoint,
|
|
23
23
|
makeRequest,
|
|
24
24
|
makeResponse,
|
|
25
25
|
makeResult,
|
|
@@ -38,11 +38,11 @@ class EntityOperation {
|
|
|
38
38
|
|
|
39
39
|
try {
|
|
40
40
|
|
|
41
|
-
// #
|
|
41
|
+
// #PrePoint-Hook
|
|
42
42
|
|
|
43
|
-
ctx.out.
|
|
44
|
-
if (ctx.out.
|
|
45
|
-
return error(ctx, ctx.out.
|
|
43
|
+
ctx.out.point = makePoint(ctx)
|
|
44
|
+
if (ctx.out.point instanceof Error) {
|
|
45
|
+
return error(ctx, ctx.out.point)
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
|
|
@@ -93,9 +93,9 @@ class EntityOperation {
|
|
|
93
93
|
return done(ctx)
|
|
94
94
|
}
|
|
95
95
|
catch (err: any) {
|
|
96
|
-
// #
|
|
96
|
+
// #PreUnexpected-Hook
|
|
97
97
|
|
|
98
|
-
err = this
|
|
98
|
+
err = this._unexpected(ctx, err)
|
|
99
99
|
|
|
100
100
|
if (err) {
|
|
101
101
|
throw err
|
|
@@ -109,7 +109,7 @@ class EntityOperation {
|
|
|
109
109
|
// EJECT-END
|
|
110
110
|
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
_unexpected(this: any, ctx: Context, ctrl: any, err: any): any { return err }
|
|
113
113
|
|
|
114
114
|
}
|
|
115
115
|
|
|
@@ -19,7 +19,7 @@ class EntityOperation {
|
|
|
19
19
|
done,
|
|
20
20
|
error,
|
|
21
21
|
featureHook,
|
|
22
|
-
|
|
22
|
+
makePoint,
|
|
23
23
|
makeRequest,
|
|
24
24
|
makeResponse,
|
|
25
25
|
makeResult,
|
|
@@ -38,11 +38,11 @@ class EntityOperation {
|
|
|
38
38
|
|
|
39
39
|
try {
|
|
40
40
|
|
|
41
|
-
// #
|
|
41
|
+
// #PrePoint-Hook
|
|
42
42
|
|
|
43
|
-
ctx.out.
|
|
44
|
-
if (ctx.out.
|
|
45
|
-
return error(ctx, ctx.out.
|
|
43
|
+
ctx.out.point = makePoint(ctx)
|
|
44
|
+
if (ctx.out.point instanceof Error) {
|
|
45
|
+
return error(ctx, ctx.out.point)
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
|
|
@@ -4,6 +4,7 @@ import { inspect } from 'node:util'
|
|
|
4
4
|
import type { Context, Feature } from './types'
|
|
5
5
|
|
|
6
6
|
import { config } from './Config'
|
|
7
|
+
import { ProjectNameEntityBase } from './ProjectNameEntityBase'
|
|
7
8
|
import { Utility } from './utility/Utility'
|
|
8
9
|
|
|
9
10
|
|
|
@@ -230,7 +231,7 @@ export {
|
|
|
230
231
|
stdutil,
|
|
231
232
|
|
|
232
233
|
BaseFeature,
|
|
233
|
-
|
|
234
|
+
ProjectNameEntityBase,
|
|
234
235
|
|
|
235
236
|
ProjectNameSDK,
|
|
236
237
|
SDK,
|
|
@@ -15,7 +15,7 @@ type Context struct {
|
|
|
15
15
|
Client *ProjectNameSDK
|
|
16
16
|
Utility *Utility
|
|
17
17
|
Op *Operation
|
|
18
|
-
|
|
18
|
+
Point map[string]any
|
|
19
19
|
Config map[string]any
|
|
20
20
|
Entopts map[string]any
|
|
21
21
|
Options map[string]any
|
|
@@ -169,14 +169,14 @@ func NewContext(ctxmap map[string]any, basectx *Context) *Context {
|
|
|
169
169
|
ctx.Reqmatch = map[string]any{}
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
//
|
|
173
|
-
if t := getCtxProp(ctxmap, "
|
|
172
|
+
// Point
|
|
173
|
+
if t := getCtxProp(ctxmap, "point"); t != nil {
|
|
174
174
|
if tm, ok := t.(map[string]any); ok {
|
|
175
|
-
ctx.
|
|
175
|
+
ctx.Point = tm
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
if ctx.
|
|
179
|
-
ctx.
|
|
178
|
+
if ctx.Point == nil && basectx != nil {
|
|
179
|
+
ctx.Point = basectx.Point
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
// Spec
|
|
@@ -240,7 +240,7 @@ func (ctx *Context) resolveOp(opname string) *Operation {
|
|
|
240
240
|
var targets []any
|
|
241
241
|
if opcfg != nil {
|
|
242
242
|
if ocm, ok := opcfg.(map[string]any); ok {
|
|
243
|
-
if t := vs.GetProp(ocm, "
|
|
243
|
+
if t := vs.GetProp(ocm, "points"); t != nil {
|
|
244
244
|
if tl, ok := t.([]any); ok {
|
|
245
245
|
targets = tl
|
|
246
246
|
}
|
|
@@ -255,7 +255,7 @@ func (ctx *Context) resolveOp(opname string) *Operation {
|
|
|
255
255
|
"entity": entname,
|
|
256
256
|
"name": opname,
|
|
257
257
|
"input": input,
|
|
258
|
-
"
|
|
258
|
+
"points": targets,
|
|
259
259
|
})
|
|
260
260
|
|
|
261
261
|
ctx.Opmap[opname] = op
|
|
@@ -8,7 +8,7 @@ type Operation struct {
|
|
|
8
8
|
Entity string
|
|
9
9
|
Name string
|
|
10
10
|
Input string
|
|
11
|
-
|
|
11
|
+
Points []map[string]any
|
|
12
12
|
Alias map[string]any
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -27,15 +27,15 @@ func NewOperation(opmap map[string]any) *Operation {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
var targets []map[string]any
|
|
30
|
-
|
|
31
|
-
if
|
|
32
|
-
if tlist, ok :=
|
|
30
|
+
rawPoints := vs.GetProp(opmap, "points")
|
|
31
|
+
if rawPoints != nil {
|
|
32
|
+
if tlist, ok := rawPoints.([]any); ok {
|
|
33
33
|
for _, t := range tlist {
|
|
34
34
|
if tm, ok := t.(map[string]any); ok {
|
|
35
35
|
targets = append(targets, tm)
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
} else if tlist, ok :=
|
|
38
|
+
} else if tlist, ok := rawPoints.([]map[string]any); ok {
|
|
39
39
|
targets = tlist
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -55,7 +55,7 @@ func NewOperation(opmap map[string]any) *Operation {
|
|
|
55
55
|
Entity: entity,
|
|
56
56
|
Name: name,
|
|
57
57
|
Input: input,
|
|
58
|
-
|
|
58
|
+
Points: targets,
|
|
59
59
|
Alias: alias,
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -4,7 +4,7 @@ import (
|
|
|
4
4
|
vs "github.com/voxgig/struct"
|
|
5
5
|
)
|
|
6
6
|
|
|
7
|
-
type
|
|
7
|
+
type Point struct {
|
|
8
8
|
Args map[string]any
|
|
9
9
|
Rename map[string]any
|
|
10
10
|
Method string
|
|
@@ -18,8 +18,8 @@ type Target struct {
|
|
|
18
18
|
Transform map[string]any
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
func
|
|
22
|
-
t := &
|
|
21
|
+
func NewPoint(altmap map[string]any) *Point {
|
|
22
|
+
t := &Point{}
|
|
23
23
|
|
|
24
24
|
if args := vs.GetProp(altmap, "args"); args != nil {
|
|
25
25
|
if am, ok := args.(map[string]any); ok {
|
|
@@ -13,15 +13,13 @@ type Feature interface {
|
|
|
13
13
|
GetData(ctx *Context)
|
|
14
14
|
GetMatch(ctx *Context)
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
PreSelection(ctx *Context)
|
|
16
|
+
PrePoint(ctx *Context)
|
|
18
17
|
PreSpec(ctx *Context)
|
|
19
18
|
PreRequest(ctx *Context)
|
|
20
19
|
PreResponse(ctx *Context)
|
|
21
20
|
PreResult(ctx *Context)
|
|
22
21
|
PreDone(ctx *Context)
|
|
23
22
|
PreUnexpected(ctx *Context)
|
|
24
|
-
PostOperation(ctx *Context)
|
|
25
23
|
SetMatch(ctx *Context)
|
|
26
24
|
}
|
|
27
25
|
|
|
@@ -14,7 +14,7 @@ type Utility struct {
|
|
|
14
14
|
MakeRequest func(ctx *Context) (*Response, error)
|
|
15
15
|
MakeResponse func(ctx *Context) (*Response, error)
|
|
16
16
|
MakeResult func(ctx *Context) (*Result, error)
|
|
17
|
-
|
|
17
|
+
MakePoint func(ctx *Context) (map[string]any, error)
|
|
18
18
|
MakeSpec func(ctx *Context) (*Spec, error)
|
|
19
19
|
MakeUrl func(ctx *Context) (string, error)
|
|
20
20
|
Param func(ctx *Context, paramdef any) any
|
|
@@ -29,12 +29,10 @@ func (f *BaseFeature) SetData(ctx *core.Context) {}
|
|
|
29
29
|
func (f *BaseFeature) GetData(ctx *core.Context) {}
|
|
30
30
|
func (f *BaseFeature) GetMatch(ctx *core.Context) {}
|
|
31
31
|
func (f *BaseFeature) SetMatch(ctx *core.Context) {}
|
|
32
|
-
func (f *BaseFeature)
|
|
33
|
-
func (f *BaseFeature) PreSelection(ctx *core.Context) {}
|
|
32
|
+
func (f *BaseFeature) PrePoint(ctx *core.Context) {}
|
|
34
33
|
func (f *BaseFeature) PreSpec(ctx *core.Context) {}
|
|
35
34
|
func (f *BaseFeature) PreRequest(ctx *core.Context) {}
|
|
36
35
|
func (f *BaseFeature) PreResponse(ctx *core.Context) {}
|
|
37
36
|
func (f *BaseFeature) PreResult(ctx *core.Context) {}
|
|
38
37
|
func (f *BaseFeature) PreDone(ctx *core.Context) {}
|
|
39
38
|
func (f *BaseFeature) PreUnexpected(ctx *core.Context) {}
|
|
40
|
-
func (f *BaseFeature) PostOperation(ctx *core.Context) {}
|
|
@@ -151,12 +151,12 @@ func (f *TestFeature) Init(ctx *core.Context, options map[string]any) {
|
|
|
151
151
|
func (f *TestFeature) buildArgs(ctx *core.Context, op *core.Operation, args map[string]any) any {
|
|
152
152
|
opname := op.Name
|
|
153
153
|
|
|
154
|
-
// Get last
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
// Get last point from config.
|
|
155
|
+
points := vs.GetPath([]any{"entity", ctx.Entity.GetName(), "op", opname, "points"}, ctx.Config)
|
|
156
|
+
point := vs.GetElem(points, -1)
|
|
157
157
|
|
|
158
158
|
// Get required params.
|
|
159
|
-
paramsPath := vs.GetPath([]any{"args", "params"},
|
|
159
|
+
paramsPath := vs.GetPath([]any{"args", "params"}, point)
|
|
160
160
|
reqdParams := vs.Select(paramsPath, map[string]any{"reqd": true})
|
|
161
161
|
reqd := vs.Transform(reqdParams, []any{"`$EACH`", "", "`$KEY.name`"})
|
|
162
162
|
|
|
@@ -59,8 +59,8 @@ func TestPrimaryUtility(t *testing.T) {
|
|
|
59
59
|
if utility.MakeResult == nil {
|
|
60
60
|
t.Error("MakeResult should not be nil")
|
|
61
61
|
}
|
|
62
|
-
if utility.
|
|
63
|
-
t.Error("
|
|
62
|
+
if utility.MakePoint == nil {
|
|
63
|
+
t.Error("MakePoint should not be nil")
|
|
64
64
|
}
|
|
65
65
|
if utility.MakeSpec == nil {
|
|
66
66
|
t.Error("MakeSpec should not be nil")
|
|
@@ -550,9 +550,9 @@ func TestPrimaryUtility(t *testing.T) {
|
|
|
550
550
|
})
|
|
551
551
|
})
|
|
552
552
|
|
|
553
|
-
t.Run("
|
|
553
|
+
t.Run("makePoint-basic", func(t *testing.T) {
|
|
554
554
|
ctx := makeTestCtx(client, utility, nil)
|
|
555
|
-
|
|
555
|
+
point := map[string]any{
|
|
556
556
|
"parts": []any{"items", "{id}"},
|
|
557
557
|
"args": map[string]any{"params": []any{}},
|
|
558
558
|
"params": []any{},
|
|
@@ -561,15 +561,15 @@ func TestPrimaryUtility(t *testing.T) {
|
|
|
561
561
|
"active": true,
|
|
562
562
|
"transform": map[string]any{},
|
|
563
563
|
}
|
|
564
|
-
ctx.Op.
|
|
564
|
+
ctx.Op.Points = []map[string]any{point}
|
|
565
565
|
|
|
566
|
-
_, err := utility.
|
|
566
|
+
_, err := utility.MakePoint(ctx)
|
|
567
567
|
if err != nil {
|
|
568
568
|
t.Errorf("expected no error, got: %v", err)
|
|
569
569
|
return
|
|
570
570
|
}
|
|
571
|
-
if ctx.
|
|
572
|
-
t.Error("expected
|
|
571
|
+
if ctx.Point == nil {
|
|
572
|
+
t.Error("expected point to be set")
|
|
573
573
|
}
|
|
574
574
|
})
|
|
575
575
|
|
|
@@ -592,7 +592,7 @@ func TestPrimaryUtility(t *testing.T) {
|
|
|
592
592
|
"entity": op.Entity,
|
|
593
593
|
"name": op.Name,
|
|
594
594
|
"input": op.Input,
|
|
595
|
-
"
|
|
595
|
+
"points": op.Points,
|
|
596
596
|
}, nil
|
|
597
597
|
})
|
|
598
598
|
})
|
|
@@ -704,7 +704,7 @@ func TestPrimaryUtility(t *testing.T) {
|
|
|
704
704
|
|
|
705
705
|
t.Run("preparePath-basic", func(t *testing.T) {
|
|
706
706
|
ctx := makeTestFullCtx(client, utility)
|
|
707
|
-
ctx.
|
|
707
|
+
ctx.Point = map[string]any{
|
|
708
708
|
"parts": []any{"api", "planet", "{id}"},
|
|
709
709
|
"args": map[string]any{"params": []any{}},
|
|
710
710
|
}
|
|
@@ -717,7 +717,7 @@ func TestPrimaryUtility(t *testing.T) {
|
|
|
717
717
|
|
|
718
718
|
t.Run("preparePath-single", func(t *testing.T) {
|
|
719
719
|
ctx := makeTestFullCtx(client, utility)
|
|
720
|
-
ctx.
|
|
720
|
+
ctx.Point = map[string]any{
|
|
721
721
|
"parts": []any{"items"},
|
|
722
722
|
"args": map[string]any{"params": []any{}},
|
|
723
723
|
}
|
|
@@ -878,10 +878,10 @@ func makeTestCtx(client *sdk.ProjectNameSDK, utility *sdk.Utility, overrides map
|
|
|
878
878
|
return utility.MakeContext(ctxmap, client.GetRootCtx())
|
|
879
879
|
}
|
|
880
880
|
|
|
881
|
-
// Helper: create full test context with
|
|
881
|
+
// Helper: create full test context with point and match
|
|
882
882
|
func makeTestFullCtx(client *sdk.ProjectNameSDK, utility *sdk.Utility) *sdk.Context {
|
|
883
883
|
ctx := makeTestCtx(client, utility, nil)
|
|
884
|
-
ctx.
|
|
884
|
+
ctx.Point = map[string]any{
|
|
885
885
|
"parts": []any{"items", "{id}"},
|
|
886
886
|
"args": map[string]any{"params": []any{map[string]any{"name": "id", "reqd": true}}},
|
|
887
887
|
"params": []any{"id"},
|
|
@@ -16,7 +16,7 @@ func makeSpecUtil(ctx *core.Context) (*core.Spec, error) {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
point := ctx.Point
|
|
20
20
|
options := ctx.Options
|
|
21
21
|
utility := ctx.Utility
|
|
22
22
|
|
|
@@ -25,7 +25,7 @@ func makeSpecUtil(ctx *core.Context) (*core.Spec, error) {
|
|
|
25
25
|
suffix, _ := vs.GetProp(options, "suffix").(string)
|
|
26
26
|
|
|
27
27
|
var parts []any
|
|
28
|
-
if p := vs.GetProp(
|
|
28
|
+
if p := vs.GetProp(point, "parts"); p != nil {
|
|
29
29
|
if pl, ok := p.([]any); ok {
|
|
30
30
|
parts = pl
|
|
31
31
|
}
|