@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
package/bin/voxgig-sdkgen
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voxgig/sdkgen",
|
|
3
|
-
"version": "0.34.
|
|
3
|
+
"version": "0.34.1",
|
|
4
4
|
"main": "dist/sdkgen.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"types": "dist/sdkgen.d.ts",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"typescript": "^6.0.2"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@voxgig/apidef": ">=
|
|
51
|
+
"@voxgig/apidef": ">=5",
|
|
52
52
|
"@voxgig/struct": ">=0",
|
|
53
53
|
"@voxgig/util": ">=0",
|
|
54
54
|
"aontu": ">=0",
|
|
@@ -15,12 +15,11 @@ main: kit: feature: log: {
|
|
|
15
15
|
SetMatch: active: true
|
|
16
16
|
GetMatch: active: true
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
PrePoint: active: true
|
|
19
19
|
PreSpec: active: true
|
|
20
20
|
PreRequest: active: true
|
|
21
21
|
PreResponse: active: true
|
|
22
22
|
PreResult: active: true
|
|
23
|
-
PostOperation: active: true
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
|
|
@@ -19,12 +19,11 @@ main: kit: feature: test: {
|
|
|
19
19
|
SetMatch: active: true
|
|
20
20
|
GetMatch: active: true
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
PrePoint: active: true
|
|
23
23
|
PreSpec: active: true
|
|
24
24
|
PreRequest: active: true
|
|
25
25
|
PreResponse: active: true
|
|
26
26
|
PreResult: active: true
|
|
27
|
-
PostOperation: active: true
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
29
|
|
|
@@ -27,15 +27,15 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
27
27
|
const loadOp = entity.op.load
|
|
28
28
|
const listOp = entity.op.list
|
|
29
29
|
|
|
30
|
-
// Get load
|
|
31
|
-
const
|
|
32
|
-
const loadPath =
|
|
33
|
-
const loadParams =
|
|
30
|
+
// Get load point info
|
|
31
|
+
const loadPoint = loadOp?.points?.[0]
|
|
32
|
+
const loadPath = loadPoint ? (loadPoint.parts || []).join('/') : ''
|
|
33
|
+
const loadParams = loadPoint?.args?.params || []
|
|
34
34
|
|
|
35
|
-
// Get list
|
|
36
|
-
const
|
|
37
|
-
const listPath =
|
|
38
|
-
const listParams =
|
|
35
|
+
// Get list point info
|
|
36
|
+
const listPoint = listOp?.points?.[0]
|
|
37
|
+
const listPath = listPoint ? (listPoint.parts || []).join('/') : ''
|
|
38
|
+
const listParams = listPoint?.args?.params || []
|
|
39
39
|
|
|
40
40
|
// Build the ENTID env var name for this entity
|
|
41
41
|
const entidEnvVar = `${PROJECTNAME}_TEST_${entity.Name.toUpperCase().replace(/[^A-Z_]/g, '_')}_ENTID`
|
|
@@ -58,7 +58,7 @@ func Test${entity.Name}Direct(t *testing.T) {
|
|
|
58
58
|
`)
|
|
59
59
|
|
|
60
60
|
// Generate list test first (load needs list results in live mode)
|
|
61
|
-
if (hasList &&
|
|
61
|
+
if (hasList && listPoint) {
|
|
62
62
|
const listParamStr = listParams.length > 0
|
|
63
63
|
? listParams.map((p: any, i: number) =>
|
|
64
64
|
`"${p.name}": "direct0${i + 1}"`).join(', ')
|
|
@@ -160,7 +160,7 @@ func Test${entity.Name}Direct(t *testing.T) {
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
// Generate load test - in live mode, first list to get a real entity ID
|
|
163
|
-
if (hasLoad &&
|
|
163
|
+
if (hasLoad && loadPoint) {
|
|
164
164
|
const loadParamStr = loadParams.length > 0
|
|
165
165
|
? loadParams.map((p: any, i: number) =>
|
|
166
166
|
`"${p.name}": "direct0${i + 1}"`).join(', ')
|
|
@@ -98,10 +98,10 @@ func (e *EntityNameEntity) Match(args ...any) any {
|
|
|
98
98
|
func (e *EntityNameEntity) runOp(ctx *core.Context, postDone func()) (any, error) {
|
|
99
99
|
utility := e.utility
|
|
100
100
|
|
|
101
|
-
// #
|
|
101
|
+
// #PrePoint-Hook
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
ctx.Out["
|
|
103
|
+
point, err := utility.MakePoint(ctx)
|
|
104
|
+
ctx.Out["point"] = point
|
|
105
105
|
if err != nil {
|
|
106
106
|
return utility.MakeError(ctx, err)
|
|
107
107
|
}
|
|
@@ -32,7 +32,7 @@ const EntityOperation = cmp(function Operation(props: any) {
|
|
|
32
32
|
SdkName: model.const.Name,
|
|
33
33
|
EntityName: entity.Name,
|
|
34
34
|
entityname: entity.name,
|
|
35
|
-
"['
|
|
35
|
+
"['POINTS']": formatJson(entop.points, { margin: 6 }).trim(),
|
|
36
36
|
'#Feature-Hook': ({ name, indent }: any) =>
|
|
37
37
|
Content({ indent }, `
|
|
38
38
|
fres = featureHook(ctx, '${name}')
|
|
@@ -121,21 +121,21 @@ function directSetup(mockres) {
|
|
|
121
121
|
|
|
122
122
|
function generateDirectLoad(model: any, entity: any) {
|
|
123
123
|
const loadOp = entity.op.load
|
|
124
|
-
const
|
|
124
|
+
const loadPoint = loadOp.points[0]
|
|
125
125
|
|
|
126
|
-
if (null ==
|
|
126
|
+
if (null == loadPoint) {
|
|
127
127
|
return
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
const loadPath = (
|
|
131
|
-
const loadParams =
|
|
130
|
+
const loadPath = (loadPoint.parts || []).join('/')
|
|
131
|
+
const loadParams = loadPoint.args?.params || []
|
|
132
132
|
|
|
133
133
|
// Get list info for live mode bootstrapping
|
|
134
134
|
const listOp = entity.op.list
|
|
135
|
-
const
|
|
136
|
-
const listPath =
|
|
137
|
-
const listParams =
|
|
138
|
-
const hasList = null !=
|
|
135
|
+
const listPoint = listOp?.points?.[0]
|
|
136
|
+
const listPath = listPoint ? (listPoint.parts || []).join('/') : ''
|
|
137
|
+
const listParams = listPoint?.args?.params || []
|
|
138
|
+
const hasList = null != listPoint
|
|
139
139
|
|
|
140
140
|
// Ancestor params (not 'id') for live mode
|
|
141
141
|
const ancestorParams = loadParams.filter((p: any) => p.name !== 'id')
|
|
@@ -218,14 +218,14 @@ ${paramAsserts} }
|
|
|
218
218
|
|
|
219
219
|
function generateDirectList(model: any, entity: any) {
|
|
220
220
|
const listOp = entity.op.list
|
|
221
|
-
const
|
|
221
|
+
const listPoint = listOp.points[0]
|
|
222
222
|
|
|
223
|
-
if (null ==
|
|
223
|
+
if (null == listPoint) {
|
|
224
224
|
return
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
const listPath = (
|
|
228
|
-
const listParams =
|
|
227
|
+
const listPath = (listPoint.parts || []).join('/')
|
|
228
|
+
const listParams = listPoint.args?.params || []
|
|
229
229
|
|
|
230
230
|
// Build live params
|
|
231
231
|
const liveParams = listParams.map((p: any) => {
|
|
@@ -16,7 +16,7 @@ class EntityOperation {
|
|
|
16
16
|
done,
|
|
17
17
|
error,
|
|
18
18
|
featureHook,
|
|
19
|
-
|
|
19
|
+
makePoint,
|
|
20
20
|
makeRequest,
|
|
21
21
|
makeResponse,
|
|
22
22
|
makeResult,
|
|
@@ -34,11 +34,11 @@ class EntityOperation {
|
|
|
34
34
|
}, this._entctx)
|
|
35
35
|
|
|
36
36
|
try {
|
|
37
|
-
// #
|
|
37
|
+
// #PrePoint-Hook
|
|
38
38
|
|
|
39
|
-
ctx.out.
|
|
40
|
-
if (ctx.out.
|
|
41
|
-
return error(ctx, ctx.out.
|
|
39
|
+
ctx.out.point = makePoint(ctx)
|
|
40
|
+
if (ctx.out.point instanceof Error) {
|
|
41
|
+
return error(ctx, ctx.out.point)
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
|
|
@@ -17,7 +17,7 @@ class EntityOperation {
|
|
|
17
17
|
done,
|
|
18
18
|
error,
|
|
19
19
|
featureHook,
|
|
20
|
-
|
|
20
|
+
makePoint,
|
|
21
21
|
makeRequest,
|
|
22
22
|
makeResponse,
|
|
23
23
|
makeResult,
|
|
@@ -35,11 +35,11 @@ class EntityOperation {
|
|
|
35
35
|
}, this._entctx)
|
|
36
36
|
|
|
37
37
|
try {
|
|
38
|
-
// #
|
|
38
|
+
// #PrePoint-Hook
|
|
39
39
|
|
|
40
|
-
ctx.out.
|
|
41
|
-
if (ctx.out.
|
|
42
|
-
return error(ctx, ctx.out.
|
|
40
|
+
ctx.out.point = makePoint(ctx)
|
|
41
|
+
if (ctx.out.point instanceof Error) {
|
|
42
|
+
return error(ctx, ctx.out.point)
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
|
|
@@ -17,7 +17,7 @@ class EntityOperation {
|
|
|
17
17
|
done,
|
|
18
18
|
error,
|
|
19
19
|
featureHook,
|
|
20
|
-
|
|
20
|
+
makePoint,
|
|
21
21
|
makeRequest,
|
|
22
22
|
makeResponse,
|
|
23
23
|
makeResult,
|
|
@@ -35,11 +35,11 @@ class EntityOperation {
|
|
|
35
35
|
}, this._entctx)
|
|
36
36
|
|
|
37
37
|
try {
|
|
38
|
-
// #
|
|
38
|
+
// #PrePoint-Hook
|
|
39
39
|
|
|
40
|
-
ctx.out.
|
|
41
|
-
if (ctx.out.
|
|
42
|
-
return error(ctx, ctx.out.
|
|
40
|
+
ctx.out.point = makePoint(ctx)
|
|
41
|
+
if (ctx.out.point instanceof Error) {
|
|
42
|
+
return error(ctx, ctx.out.point)
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
|
|
@@ -17,7 +17,7 @@ class EntityOperation {
|
|
|
17
17
|
done,
|
|
18
18
|
error,
|
|
19
19
|
featureHook,
|
|
20
|
-
|
|
20
|
+
makePoint,
|
|
21
21
|
makeRequest,
|
|
22
22
|
makeResponse,
|
|
23
23
|
makeResult,
|
|
@@ -36,11 +36,11 @@ class EntityOperation {
|
|
|
36
36
|
|
|
37
37
|
try {
|
|
38
38
|
|
|
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
|
|
|
@@ -91,7 +91,7 @@ class EntityOperation {
|
|
|
91
91
|
return done(ctx)
|
|
92
92
|
}
|
|
93
93
|
catch (err) {
|
|
94
|
-
// #
|
|
94
|
+
// #PreUnexpected-Hook
|
|
95
95
|
|
|
96
96
|
err = this.#unexpected(ctx, err)
|
|
97
97
|
|
|
@@ -17,7 +17,7 @@ class EntityOperation {
|
|
|
17
17
|
done,
|
|
18
18
|
error,
|
|
19
19
|
featureHook,
|
|
20
|
-
|
|
20
|
+
makePoint,
|
|
21
21
|
makeRequest,
|
|
22
22
|
makeResponse,
|
|
23
23
|
makeResult,
|
|
@@ -36,11 +36,11 @@ class EntityOperation {
|
|
|
36
36
|
|
|
37
37
|
try {
|
|
38
38
|
|
|
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
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
import * as Path from 'node:path'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
cmp,
|
|
6
|
+
File, Folder, Fragment,
|
|
7
|
+
} from '@voxgig/sdkgen'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const EntityBase = cmp(async function EntityBase(props: any) {
|
|
12
|
+
|
|
13
|
+
// Needs type: target object
|
|
14
|
+
const { target } = props
|
|
15
|
+
const { model } = props.ctx$
|
|
16
|
+
|
|
17
|
+
Folder({ name: 'src' }, () => {
|
|
18
|
+
|
|
19
|
+
File({ name: model.const.Name + 'Base.' + target.name }, () => {
|
|
20
|
+
|
|
21
|
+
Fragment(
|
|
22
|
+
{
|
|
23
|
+
from:
|
|
24
|
+
Path.normalize(__dirname + '/../../../src/cmp/ts/fragment/EntityBase.fragment.ts'),
|
|
25
|
+
|
|
26
|
+
replace: {
|
|
27
|
+
...props.ctx$.stdrep,
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
EntityBase
|
|
38
|
+
}
|
|
@@ -32,7 +32,7 @@ const EntityOperation = cmp(function Operation(props: any) {
|
|
|
32
32
|
SdkName: model.const.Name,
|
|
33
33
|
EntityName: entity.Name,
|
|
34
34
|
entityname: entity.name,
|
|
35
|
-
"['
|
|
35
|
+
"['POINTS']": formatJson(entop.points, { margin: 6 }).trim(),
|
|
36
36
|
'#Feature-Hook': ({ name, indent }: any) =>
|
|
37
37
|
Content({ indent }, `
|
|
38
38
|
fres = featureHook(ctx, '${name}')
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
import { Package } from './Package_ts'
|
|
22
22
|
import { Config } from './Config_ts'
|
|
23
23
|
import { MainEntity } from './MainEntity_ts'
|
|
24
|
+
import { EntityBase } from './EntityBase_ts'
|
|
24
25
|
import { SdkError } from './SdkError_ts'
|
|
25
26
|
|
|
26
27
|
|
|
@@ -87,6 +88,7 @@ if (fres instanceof Promise) { await fres }
|
|
|
87
88
|
})
|
|
88
89
|
|
|
89
90
|
Config({ target })
|
|
91
|
+
EntityBase({ target })
|
|
90
92
|
|
|
91
93
|
})
|
|
92
94
|
})
|
|
@@ -121,21 +121,21 @@ function directSetup(mockres?: any) {
|
|
|
121
121
|
|
|
122
122
|
function generateDirectLoad(model: any, entity: any) {
|
|
123
123
|
const loadOp = entity.op.load
|
|
124
|
-
const
|
|
124
|
+
const loadPoint = loadOp.points[0]
|
|
125
125
|
|
|
126
|
-
if (null ==
|
|
126
|
+
if (null == loadPoint) {
|
|
127
127
|
return
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
const loadPath = (
|
|
131
|
-
const loadParams =
|
|
130
|
+
const loadPath = (loadPoint.parts || []).join('/')
|
|
131
|
+
const loadParams = loadPoint.args?.params || []
|
|
132
132
|
|
|
133
133
|
// Get list info for live mode bootstrapping
|
|
134
134
|
const listOp = entity.op.list
|
|
135
|
-
const
|
|
136
|
-
const listPath =
|
|
137
|
-
const listParams =
|
|
138
|
-
const hasList = null !=
|
|
135
|
+
const listPoint = listOp?.points?.[0]
|
|
136
|
+
const listPath = listPoint ? (listPoint.parts || []).join('/') : ''
|
|
137
|
+
const listParams = listPoint?.args?.params || []
|
|
138
|
+
const hasList = null != listPoint
|
|
139
139
|
|
|
140
140
|
// Ancestor params (not 'id') for live mode
|
|
141
141
|
const ancestorParams = loadParams.filter((p: any) => p.name !== 'id')
|
|
@@ -218,14 +218,14 @@ ${paramAsserts} }
|
|
|
218
218
|
|
|
219
219
|
function generateDirectList(model: any, entity: any) {
|
|
220
220
|
const listOp = entity.op.list
|
|
221
|
-
const
|
|
221
|
+
const listPoint = listOp.points[0]
|
|
222
222
|
|
|
223
|
-
if (null ==
|
|
223
|
+
if (null == listPoint) {
|
|
224
224
|
return
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
const listPath = (
|
|
228
|
-
const listParams =
|
|
227
|
+
const listPath = (listPoint.parts || []).join('/')
|
|
228
|
+
const listParams = listPoint.args?.params || []
|
|
229
229
|
|
|
230
230
|
// Build live params
|
|
231
231
|
const liveParams = listParams.map((p: any) => {
|
|
@@ -2,13 +2,10 @@
|
|
|
2
2
|
import { inspect } from 'node:util'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '../
|
|
5
|
+
ProjectNameSDK,
|
|
6
|
+
ProjectNameEntityBase,
|
|
7
|
+
} from '../ProjectNameSDK'
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
Utility
|
|
11
|
-
} from '../utility/Utility'
|
|
12
9
|
|
|
13
10
|
import type {
|
|
14
11
|
Operation,
|
|
@@ -18,95 +15,15 @@ import type {
|
|
|
18
15
|
|
|
19
16
|
|
|
20
17
|
// TODO: needs Entity superclass
|
|
21
|
-
class EntityNameEntity {
|
|
22
|
-
name = 'entityname'
|
|
23
|
-
|
|
24
|
-
#client: SdkNameSDK
|
|
25
|
-
#utility: Utility
|
|
26
|
-
#entopts: any
|
|
27
|
-
#data: any
|
|
28
|
-
#match: any
|
|
29
|
-
|
|
30
|
-
_entctx: Context
|
|
31
|
-
|
|
32
|
-
constructor(client: SdkNameSDK, entopts: any) {
|
|
33
|
-
// super()
|
|
34
|
-
entopts = entopts || {}
|
|
35
|
-
entopts.active = false !== entopts.active
|
|
36
|
-
|
|
37
|
-
this.#client = client
|
|
38
|
-
this.#entopts = entopts
|
|
39
|
-
this.#utility = client.utility()
|
|
40
|
-
this.#data = {}
|
|
41
|
-
this.#match = {}
|
|
42
|
-
|
|
43
|
-
const makeContext = this.#utility.makeContext
|
|
18
|
+
class EntityNameEntity extends ProjectNameEntityBase {
|
|
44
19
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
entopts,
|
|
48
|
-
}, client._rootctx)
|
|
49
|
-
|
|
50
|
-
const featureHook = this.#utility.featureHook
|
|
51
|
-
featureHook(this._entctx, 'PostConstructEntity')
|
|
20
|
+
constructor(client: ProjectNameSDK, entopts: any) {
|
|
21
|
+
super(client, entopts)
|
|
52
22
|
}
|
|
53
23
|
|
|
54
|
-
entopts() {
|
|
55
|
-
return { ...this.#entopts }
|
|
56
|
-
}
|
|
57
24
|
|
|
58
|
-
|
|
59
|
-
return this
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
make() {
|
|
63
|
-
return new EntityNameEntity(this.#client, this.entopts())
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
data(this: any, data?: any) {
|
|
68
|
-
const struct = this.#utility.struct
|
|
69
|
-
const featureHook = this.#utility.featureHook
|
|
70
|
-
|
|
71
|
-
if (null != data) {
|
|
72
|
-
this.#data = struct.clone(data)
|
|
73
|
-
featureHook(this._entctx, 'SetData')
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
featureHook(this._entctx, 'GetData')
|
|
77
|
-
let out = struct.clone(this.#data)
|
|
78
|
-
|
|
79
|
-
return out
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
match(match?: any) {
|
|
84
|
-
const struct = this.#utility.struct
|
|
85
|
-
const featureHook = this.#utility.featureHook
|
|
86
|
-
|
|
87
|
-
if (null != match) {
|
|
88
|
-
this.#match = struct.clone(match)
|
|
89
|
-
featureHook(this._entctx, 'SetMatch')
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
featureHook(this._entctx, 'GetMatch')
|
|
93
|
-
let out = struct.clone(this.#match)
|
|
94
|
-
|
|
95
|
-
return out
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
toJSON() {
|
|
100
|
-
const struct = this.#utility.struct
|
|
101
|
-
return struct.merge([{}, struct.getdef(this.#data, {}), { $entity: 'EntityName' }])
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
toString() {
|
|
105
|
-
return 'EntityName ' + this.#utility.struct.jsonify(this.#data)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
[inspect.custom]() {
|
|
109
|
-
return this.toString()
|
|
25
|
+
make(this: EntityNameEntity) {
|
|
26
|
+
return new EntityNameEntity(this._client, this.entopts())
|
|
110
27
|
}
|
|
111
28
|
|
|
112
29
|
|
|
@@ -120,54 +37,6 @@ class EntityNameEntity {
|
|
|
120
37
|
|
|
121
38
|
// #RemoveOp
|
|
122
39
|
|
|
123
|
-
|
|
124
|
-
#unexpected(this: any, ctx: Context, err: any) {
|
|
125
|
-
const clean = this.#utility.clean
|
|
126
|
-
const struct = this.#utility.struct
|
|
127
|
-
|
|
128
|
-
const delprop = struct.delprop
|
|
129
|
-
const clone = struct.clone
|
|
130
|
-
const merge = struct.merge
|
|
131
|
-
|
|
132
|
-
const ctrl = ctx.ctrl
|
|
133
|
-
|
|
134
|
-
ctrl.err = err
|
|
135
|
-
|
|
136
|
-
if (ctrl.explain) {
|
|
137
|
-
ctx.ctrl.explain = clean(ctx, ctx.ctrl.explain)
|
|
138
|
-
delprop(ctx.ctrl.explain.result, 'err')
|
|
139
|
-
|
|
140
|
-
if (null != ctx.result && null != ctx.result.err) {
|
|
141
|
-
ctrl.explain.err = clean(ctx, merge([
|
|
142
|
-
clone({ err: ctx.result.err }).err,
|
|
143
|
-
{
|
|
144
|
-
message: ctx.result.err.message,
|
|
145
|
-
stack: ctx.result.err.stack,
|
|
146
|
-
}]))
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const cleanerr = clean(ctx, merge([
|
|
150
|
-
clone({ err }).err,
|
|
151
|
-
{
|
|
152
|
-
message: err.message,
|
|
153
|
-
stack: err.stack,
|
|
154
|
-
}]))
|
|
155
|
-
|
|
156
|
-
if (null == ctrl.explain.err) {
|
|
157
|
-
ctrl.explain.err = cleanerr
|
|
158
|
-
}
|
|
159
|
-
else if (ctrl.explain.err.message != cleanerr.message) {
|
|
160
|
-
ctrl.explain.unexpected = cleanerr
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if (false === ctrl.throw) {
|
|
165
|
-
return undefined
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return err
|
|
169
|
-
}
|
|
170
|
-
|
|
171
40
|
}
|
|
172
41
|
|
|
173
42
|
|