@voxgig/sdkgen 0.36.0 → 0.37.0
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/dist/cmp/Main.js +0 -12
- package/dist/cmp/Main.js.map +1 -1
- package/package.json +1 -1
- package/project/.sdk/src/cmp/go/Config_go.ts +6 -2
- package/project/.sdk/src/cmp/js/EntityBase_js.ts +34 -0
- package/project/.sdk/src/cmp/js/Main_js.ts +10 -0
- package/project/.sdk/src/cmp/js/ReadmeExplanation_js.ts +33 -0
- package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +123 -0
- package/project/.sdk/src/cmp/js/ReadmeModel_js.ts +152 -0
- package/project/.sdk/src/cmp/js/ReadmeTopHowto_js.ts +25 -0
- package/project/.sdk/src/cmp/js/ReadmeTopQuick_js.ts +65 -0
- package/project/.sdk/src/cmp/js/ReadmeTopTest_js.ts +36 -0
- package/project/.sdk/src/cmp/js/TestDirect_js.ts +53 -5
- package/project/.sdk/src/cmp/js/TestEntity_js.ts +114 -20
- package/project/.sdk/src/cmp/js/fragment/Entity.fragment.js +7 -139
- package/project/.sdk/src/cmp/js/fragment/EntityBase.fragment.js +149 -0
- package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +6 -10
- package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +6 -10
- package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +7 -11
- package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +7 -11
- package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +7 -11
- package/project/.sdk/src/cmp/js/fragment/Main.fragment.js +2 -0
- package/project/.sdk/src/cmp/js/fragment/SdkError.fragment.js +0 -2
- package/project/.sdk/src/cmp/lua/Config_lua.ts +6 -2
- package/project/.sdk/src/cmp/lua/TestEntity_lua.ts +3 -1
- package/project/.sdk/src/cmp/php/Config_php.ts +6 -2
- package/project/.sdk/src/cmp/php/TestDirect_php.ts +2 -2
- package/project/.sdk/src/cmp/php/TestEntity_php.ts +10 -15
- package/project/.sdk/src/cmp/py/Config_py.ts +6 -2
- package/project/.sdk/src/cmp/py/TestEntity_py.ts +3 -1
- package/project/.sdk/src/cmp/rb/Config_rb.ts +6 -2
- package/project/.sdk/src/cmp/ts/Main_ts.ts +7 -0
- package/project/.sdk/tm/go/feature/log_feature.go +1 -1
- package/project/.sdk/tm/go/test/runner_test.go +16 -2
- package/project/.sdk/tm/js/src/Context.js +142 -0
- package/project/.sdk/tm/js/src/Control.js +16 -0
- package/project/.sdk/tm/js/src/Operation.js +19 -0
- package/project/.sdk/tm/js/src/Point.js +24 -0
- package/project/.sdk/tm/js/src/README.md +1 -0
- package/project/.sdk/tm/js/src/Response.js +19 -0
- package/project/.sdk/tm/js/src/Result.js +21 -0
- package/project/.sdk/tm/js/src/Spec.js +26 -0
- package/project/.sdk/tm/js/src/feature/README.md +1 -0
- package/project/.sdk/tm/js/src/feature/base/BaseFeature.js +45 -0
- package/project/.sdk/tm/js/src/feature/log/LogFeature.js +46 -47
- package/project/.sdk/tm/js/src/feature/test/TestFeature.js +207 -0
- package/project/.sdk/tm/js/src/types.js +22 -0
- package/project/.sdk/tm/js/src/utility/CleanUtility.js +31 -0
- package/project/.sdk/tm/js/src/utility/DoneUtility.js +11 -4
- package/project/.sdk/tm/js/src/utility/FeatureAddUtility.js +42 -0
- package/project/.sdk/tm/js/src/utility/FeatureHookUtility.js +25 -0
- package/project/.sdk/tm/js/src/utility/FeatureInitUtility.js +11 -0
- package/project/.sdk/tm/js/src/utility/FetcherUtility.js +28 -0
- package/project/.sdk/tm/js/src/utility/MakeContextUtility.js +11 -0
- package/project/.sdk/tm/js/src/utility/MakeErrorUtility.js +55 -0
- package/project/.sdk/tm/js/src/utility/MakeFetchDefUtility.js +44 -0
- package/project/.sdk/tm/js/src/utility/MakeOptionsUtility.js +93 -0
- package/project/.sdk/tm/js/src/utility/MakePointUtility.js +77 -0
- package/project/.sdk/tm/js/src/utility/MakeRequestUtility.js +63 -0
- package/project/.sdk/tm/js/src/utility/MakeResponseUtility.js +55 -0
- package/project/.sdk/tm/js/src/utility/MakeResultUtility.js +54 -0
- package/project/.sdk/tm/js/src/utility/MakeSpecUtility.js +58 -0
- package/project/.sdk/tm/js/src/utility/MakeUrlUtility.js +40 -0
- package/project/.sdk/tm/js/src/utility/ParamUtility.js +61 -0
- package/project/.sdk/tm/js/src/utility/PrepareAuthUtility.js +41 -0
- package/project/.sdk/tm/js/src/utility/PrepareBodyUtility.js +25 -0
- package/project/.sdk/tm/js/src/utility/PrepareHeadersUtility.js +18 -0
- package/project/.sdk/tm/js/src/utility/{MethodUtility.js → PrepareMethodUtility.js} +7 -7
- package/project/.sdk/tm/js/src/utility/PrepareParamsUtility.js +25 -0
- package/project/.sdk/tm/js/src/utility/PreparePathUtility.js +13 -0
- package/project/.sdk/tm/js/src/utility/PrepareQueryUtility.js +26 -0
- package/project/.sdk/tm/js/src/utility/README.md +1 -0
- package/project/.sdk/tm/js/src/utility/ResultBasicUtility.js +34 -0
- package/project/.sdk/tm/js/src/utility/ResultBodyUtility.js +18 -0
- package/project/.sdk/tm/js/src/utility/ResultHeadersUtility.js +22 -0
- package/project/.sdk/tm/js/src/utility/StructUtility.js +2219 -1078
- package/project/.sdk/tm/js/src/utility/TransformRequestUtility.js +28 -0
- package/project/.sdk/tm/js/src/utility/TransformResponseUtility.js +31 -0
- package/project/.sdk/tm/js/src/utility/Utility.js +61 -61
- package/project/.sdk/tm/js/test/README.md +1 -0
- package/project/.sdk/tm/js/test/exists.test.js +16 -0
- package/project/.sdk/tm/js/test/runner.js +323 -107
- package/project/.sdk/tm/js/test/utility/Custom.test.js +41 -63
- package/project/.sdk/tm/js/test/utility/PrimaryUtility.test.js +390 -116
- package/project/.sdk/tm/js/test/utility/StructUtility.test.js +728 -175
- package/project/.sdk/tm/js/test/utility/index.js +9 -0
- package/project/.sdk/tm/js/test/utility.js +72 -0
- package/project/.sdk/tm/lua/test/primary_utility_test.lua +1213 -0
- package/project/.sdk/tm/lua/test/runner.lua +2 -2
- package/project/.sdk/tm/lua/test/struct_runner.lua +602 -0
- package/project/.sdk/tm/lua/test/struct_utility_test.lua +959 -0
- package/project/.sdk/tm/lua/utility/struct/struct.lua +10 -0
- package/project/.sdk/tm/php/feature/TestFeature.php +59 -96
- package/project/.sdk/tm/php/test/PrimaryUtilityTest.php +1309 -0
- package/project/.sdk/tm/php/test/Runner.php +24 -1
- package/project/.sdk/tm/php/test/StructRunner.php +275 -0
- package/project/.sdk/tm/php/test/StructUtilityTest.php +1336 -0
- package/project/.sdk/tm/php/utility/Fetcher.php +6 -2
- package/project/.sdk/tm/php/utility/MakeOptions.php +5 -1
- package/project/.sdk/tm/php/utility/MakeResult.php +3 -0
- package/project/.sdk/tm/php/utility/Param.php +9 -7
- package/project/.sdk/tm/php/utility/struct/Struct.php +312 -208
- package/project/.sdk/tm/py/test/runner.py +13 -0
- package/project/.sdk/tm/py/test/struct_runner.py +411 -0
- package/project/.sdk/tm/py/test/test_primary_utility.py +1101 -0
- package/project/.sdk/tm/py/test/test_struct_utility.py +751 -0
- package/project/.sdk/tm/rb/test/primary_utility_test.rb +1083 -0
- package/project/.sdk/tm/rb/test/runner.rb +5 -0
- package/project/.sdk/tm/rb/test/struct_runner.rb +309 -0
- package/project/.sdk/tm/rb/test/struct_utility_test.rb +670 -0
- package/src/cmp/Main.ts +1 -16
- package/project/.sdk/src/cmp/js/Quick_js.ts +0 -78
- package/project/.sdk/src/cmp/js/TestAcceptEntity_js.ts +0 -13
- package/project/.sdk/src/cmp/js/TestAccept_js.ts +0 -18
- package/project/.sdk/tm/js/src/utility/AuthUtility.js +0 -21
- package/project/.sdk/tm/js/src/utility/BodyUtility.js +0 -29
- package/project/.sdk/tm/js/src/utility/ErrorUtility.js +0 -33
- package/project/.sdk/tm/js/src/utility/FindparamUtility.js +0 -31
- package/project/.sdk/tm/js/src/utility/FullurlUtility.js +0 -39
- package/project/.sdk/tm/js/src/utility/HeadersUtility.js +0 -13
- package/project/.sdk/tm/js/src/utility/JoinurlUtility.js +0 -14
- package/project/.sdk/tm/js/src/utility/OperatorUtility.js +0 -44
- package/project/.sdk/tm/js/src/utility/OptionsUtility.js +0 -54
- package/project/.sdk/tm/js/src/utility/ParamsUtility.js +0 -21
- package/project/.sdk/tm/js/src/utility/QueryUtility.js +0 -21
- package/project/.sdk/tm/js/src/utility/ReqformUtility.js +0 -32
- package/project/.sdk/tm/js/src/utility/RequestUtility.js +0 -48
- package/project/.sdk/tm/js/src/utility/ResbasicUtility.js +0 -27
- package/project/.sdk/tm/js/src/utility/ResbodyUtility.js +0 -15
- package/project/.sdk/tm/js/src/utility/ResformUtility.js +0 -34
- package/project/.sdk/tm/js/src/utility/ResheadersUtility.js +0 -19
- package/project/.sdk/tm/js/src/utility/ResponseUtility.js +0 -37
- package/project/.sdk/tm/js/src/utility/ResultUtility.js +0 -28
- package/project/.sdk/tm/js/src/utility/SpecUtility.js +0 -35
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
class EntityOperation {
|
|
3
3
|
|
|
4
|
-
#match
|
|
5
|
-
#data
|
|
6
|
-
#utility
|
|
7
|
-
|
|
8
4
|
|
|
9
5
|
// EJECT-START
|
|
10
6
|
|
|
11
7
|
async load(reqmatch, ctrl) {
|
|
12
8
|
|
|
13
|
-
const utility = this
|
|
9
|
+
const utility = this._utility
|
|
14
10
|
|
|
15
11
|
const {
|
|
16
12
|
makeContext,
|
|
@@ -29,8 +25,8 @@ class EntityOperation {
|
|
|
29
25
|
let ctx = makeContext({
|
|
30
26
|
opname: 'load',
|
|
31
27
|
ctrl,
|
|
32
|
-
match: this
|
|
33
|
-
data: this
|
|
28
|
+
match: this._match,
|
|
29
|
+
data: this._data,
|
|
34
30
|
reqmatch
|
|
35
31
|
}, this._entctx)
|
|
36
32
|
|
|
@@ -79,11 +75,11 @@ class EntityOperation {
|
|
|
79
75
|
|
|
80
76
|
if (null != ctx.result) {
|
|
81
77
|
if (null != ctx.result.resmatch) {
|
|
82
|
-
this
|
|
78
|
+
this._match = ctx.result.resmatch
|
|
83
79
|
}
|
|
84
80
|
|
|
85
81
|
if (null != ctx.result.resdata) {
|
|
86
|
-
this
|
|
82
|
+
this._data = ctx.result.resdata
|
|
87
83
|
}
|
|
88
84
|
}
|
|
89
85
|
|
|
@@ -92,7 +88,7 @@ class EntityOperation {
|
|
|
92
88
|
catch (err) {
|
|
93
89
|
// #PreUnexpected-Hook
|
|
94
90
|
|
|
95
|
-
err = this
|
|
91
|
+
err = this._unexpected(ctx, err)
|
|
96
92
|
|
|
97
93
|
if (err) {
|
|
98
94
|
throw err
|
|
@@ -106,6 +102,6 @@ class EntityOperation {
|
|
|
106
102
|
// EJECT-END
|
|
107
103
|
|
|
108
104
|
|
|
109
|
-
|
|
105
|
+
_unexpected(ctx, err) { return err }
|
|
110
106
|
}
|
|
111
107
|
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
class EntityOperation {
|
|
3
3
|
|
|
4
|
-
#match
|
|
5
|
-
#data
|
|
6
|
-
#utility
|
|
7
|
-
|
|
8
4
|
|
|
9
5
|
// EJECT-START
|
|
10
6
|
|
|
11
7
|
async remove(reqmatch, ctrl) {
|
|
12
8
|
|
|
13
|
-
const utility = this
|
|
9
|
+
const utility = this._utility
|
|
14
10
|
|
|
15
11
|
const {
|
|
16
12
|
makeContext,
|
|
@@ -29,8 +25,8 @@ class EntityOperation {
|
|
|
29
25
|
let ctx = makeContext({
|
|
30
26
|
opname: 'remove',
|
|
31
27
|
ctrl,
|
|
32
|
-
match: this
|
|
33
|
-
data: this
|
|
28
|
+
match: this._match,
|
|
29
|
+
data: this._data,
|
|
34
30
|
reqmatch
|
|
35
31
|
}, this._entctx)
|
|
36
32
|
|
|
@@ -80,11 +76,11 @@ class EntityOperation {
|
|
|
80
76
|
|
|
81
77
|
if (null != ctx.result) {
|
|
82
78
|
if (null != ctx.result.resmatch) {
|
|
83
|
-
this
|
|
79
|
+
this._match = ctx.result.resmatch
|
|
84
80
|
}
|
|
85
81
|
|
|
86
82
|
if (null != ctx.result.resdata) {
|
|
87
|
-
this
|
|
83
|
+
this._data = ctx.result.resdata
|
|
88
84
|
}
|
|
89
85
|
}
|
|
90
86
|
|
|
@@ -93,7 +89,7 @@ class EntityOperation {
|
|
|
93
89
|
catch (err) {
|
|
94
90
|
// #PreUnexpected-Hook
|
|
95
91
|
|
|
96
|
-
err = this
|
|
92
|
+
err = this._unexpected(ctx, err)
|
|
97
93
|
|
|
98
94
|
if (err) {
|
|
99
95
|
throw err
|
|
@@ -107,7 +103,7 @@ class EntityOperation {
|
|
|
107
103
|
// EJECT-END
|
|
108
104
|
|
|
109
105
|
|
|
110
|
-
|
|
106
|
+
_unexpected(ctx, err) { return err }
|
|
111
107
|
|
|
112
108
|
}
|
|
113
109
|
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
class EntityOperation {
|
|
3
3
|
|
|
4
|
-
#match
|
|
5
|
-
#data
|
|
6
|
-
#utility
|
|
7
|
-
|
|
8
4
|
|
|
9
5
|
// EJECT-START
|
|
10
6
|
|
|
11
7
|
async update(reqdata, ctrl) {
|
|
12
8
|
|
|
13
|
-
const utility = this
|
|
9
|
+
const utility = this._utility
|
|
14
10
|
|
|
15
11
|
const {
|
|
16
12
|
makeContext,
|
|
@@ -29,8 +25,8 @@ class EntityOperation {
|
|
|
29
25
|
let ctx = makeContext({
|
|
30
26
|
opname: 'update',
|
|
31
27
|
ctrl,
|
|
32
|
-
match: this
|
|
33
|
-
data: this
|
|
28
|
+
match: this._match,
|
|
29
|
+
data: this._data,
|
|
34
30
|
reqdata
|
|
35
31
|
}, this._entctx)
|
|
36
32
|
|
|
@@ -80,11 +76,11 @@ class EntityOperation {
|
|
|
80
76
|
|
|
81
77
|
if (null != ctx.result) {
|
|
82
78
|
if (null != ctx.result.resmatch) {
|
|
83
|
-
this
|
|
79
|
+
this._match = ctx.result.resmatch
|
|
84
80
|
}
|
|
85
81
|
|
|
86
82
|
if (null != ctx.result.resdata) {
|
|
87
|
-
this
|
|
83
|
+
this._data = ctx.result.resdata
|
|
88
84
|
}
|
|
89
85
|
}
|
|
90
86
|
|
|
@@ -93,7 +89,7 @@ class EntityOperation {
|
|
|
93
89
|
catch (err) {
|
|
94
90
|
// #PreUnexpected-Hook
|
|
95
91
|
|
|
96
|
-
err = this
|
|
92
|
+
err = this._unexpected(ctx, err)
|
|
97
93
|
|
|
98
94
|
if (err) {
|
|
99
95
|
throw err
|
|
@@ -107,7 +103,7 @@ class EntityOperation {
|
|
|
107
103
|
// EJECT-END
|
|
108
104
|
|
|
109
105
|
|
|
110
|
-
|
|
106
|
+
_unexpected(ctx, err) { return err }
|
|
111
107
|
|
|
112
108
|
}
|
|
113
109
|
|
|
@@ -3,6 +3,7 @@ const { inspect } = require('node:util')
|
|
|
3
3
|
|
|
4
4
|
const { config } = require('./Config')
|
|
5
5
|
const { Utility } = require('./utility/Utility')
|
|
6
|
+
const { ProjectNameEntityBase } = require('./ProjectNameEntityBase')
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
const { BaseFeature } = require('./feature/base/BaseFeature')
|
|
@@ -225,6 +226,7 @@ module.exports = {
|
|
|
225
226
|
stdutil,
|
|
226
227
|
|
|
227
228
|
BaseFeature,
|
|
229
|
+
ProjectNameEntityBase,
|
|
228
230
|
|
|
229
231
|
ProjectNameSDK,
|
|
230
232
|
SDK,
|
|
@@ -36,8 +36,12 @@ const Config = cmp(async function Config(props: any) {
|
|
|
36
36
|
const feature = getModelPath(model, `main.${KIT}.feature`)
|
|
37
37
|
|
|
38
38
|
const headers = getModelPath(model, `main.${KIT}.config.headers`) || {}
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
|
|
40
|
+
let authPrefix = ''
|
|
41
|
+
try { authPrefix = getModelPath(model, `main.${KIT}.config.auth.prefix`) } catch (_e) { }
|
|
42
|
+
|
|
43
|
+
let baseUrl = ''
|
|
44
|
+
try { baseUrl = getModelPath(model, `main.${KIT}.info.servers.0.url`) } catch (_e) { }
|
|
41
45
|
|
|
42
46
|
File({ name: 'config.' + target.ext }, () => {
|
|
43
47
|
|
|
@@ -75,6 +75,8 @@ local sdk = require("${model.name}_sdk")
|
|
|
75
75
|
local helpers = require("core.helpers")
|
|
76
76
|
local runner = require("test.runner")
|
|
77
77
|
|
|
78
|
+
local _test_dir = debug.getinfo(1, "S").source:match("^@(.+/)") or "./"
|
|
79
|
+
|
|
78
80
|
describe("${entity.Name}Entity", function()
|
|
79
81
|
it("should create instance", function()
|
|
80
82
|
local testsdk = sdk.test(nil, nil)
|
|
@@ -120,7 +122,7 @@ end)
|
|
|
120
122
|
Content(`function ${entity.name}_basic_setup(extra)
|
|
121
123
|
runner.load_env_local()
|
|
122
124
|
|
|
123
|
-
local entity_data_file = "../../.sdk/test/entity/${entity.name}/${entity.Name}TestData.json"
|
|
125
|
+
local entity_data_file = _test_dir .. "../../.sdk/test/entity/${entity.name}/${entity.Name}TestData.json"
|
|
124
126
|
local f = io.open(entity_data_file, "r")
|
|
125
127
|
if f == nil then
|
|
126
128
|
error("failed to read ${entity.name} test data: " .. entity_data_file)
|
|
@@ -36,8 +36,12 @@ const Config = cmp(async function Config(props: any) {
|
|
|
36
36
|
const feature = getModelPath(model, `main.${KIT}.feature`)
|
|
37
37
|
|
|
38
38
|
const headers = getModelPath(model, `main.${KIT}.config.headers`) || {}
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
|
|
40
|
+
let authPrefix = ''
|
|
41
|
+
try { authPrefix = getModelPath(model, `main.${KIT}.config.auth.prefix`) } catch (_e) { }
|
|
42
|
+
|
|
43
|
+
let baseUrl = ''
|
|
44
|
+
try { baseUrl = getModelPath(model, `main.${KIT}.info.servers.0.url`) } catch (_e) { }
|
|
41
45
|
|
|
42
46
|
File({ name: 'config.' + target.ext }, () => {
|
|
43
47
|
|
|
@@ -204,7 +204,7 @@ function ${entity.name}_direct_setup($mockres)
|
|
|
204
204
|
{
|
|
205
205
|
Runner::load_env_local();
|
|
206
206
|
|
|
207
|
-
$calls =
|
|
207
|
+
$calls = new \\ArrayObject();
|
|
208
208
|
|
|
209
209
|
$env = Runner::env_override([
|
|
210
210
|
"${entidEnvVar}" => [],
|
|
@@ -227,7 +227,7 @@ function ${entity.name}_direct_setup($mockres)
|
|
|
227
227
|
];
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
$mock_fetch = function ($url, $init) use (
|
|
230
|
+
$mock_fetch = function ($url, $init) use ($calls, $mockres) {
|
|
231
231
|
$calls[] = ["url" => $url, "init" => $init];
|
|
232
232
|
return [
|
|
233
233
|
[
|
|
@@ -138,17 +138,12 @@ class ${entity.Name}EntityTest extends TestCase
|
|
|
138
138
|
|
|
139
139
|
`)
|
|
140
140
|
|
|
141
|
-
// Generate idmap
|
|
142
|
-
Content(` // Generate idmap
|
|
143
|
-
$idmap =
|
|
144
|
-
|
|
145
|
-
[
|
|
146
|
-
|
|
147
|
-
"\`\\$KEY\`" => "\`\\$COPY\`",
|
|
148
|
-
"\`\\$VAL\`" => ["\`\\$FORMAT\`", "upper", "\`\\$COPY\`"],
|
|
149
|
-
]],
|
|
150
|
-
]
|
|
151
|
-
);
|
|
141
|
+
// Generate idmap: key => UPPER(key)
|
|
142
|
+
Content(` // Generate idmap.
|
|
143
|
+
$idmap = [];
|
|
144
|
+
foreach ([${idnamesStr}] as $k) {
|
|
145
|
+
$idmap[$k] = strtoupper($k);
|
|
146
|
+
}
|
|
152
147
|
|
|
153
148
|
`)
|
|
154
149
|
|
|
@@ -307,18 +302,18 @@ const generateList: OpGen = (ctx, step, index) => {
|
|
|
307
302
|
if ('ItemExists' === validator.apply && hasRefData) {
|
|
308
303
|
const refDataVar = validRef + '_data'
|
|
309
304
|
Content(`
|
|
310
|
-
$found_item =
|
|
305
|
+
$found_item = sdk_select(
|
|
311
306
|
Runner::entity_list_to_data($${listvar}_result),
|
|
312
307
|
["id" => $${refDataVar}["id"]]);
|
|
313
|
-
$this->
|
|
308
|
+
$this->assertNotEmpty($found_item);
|
|
314
309
|
`)
|
|
315
310
|
} else if ('ItemNotExists' === validator.apply && hasRefData) {
|
|
316
311
|
const refDataVar = validRef + '_data'
|
|
317
312
|
Content(`
|
|
318
|
-
$not_found_item =
|
|
313
|
+
$not_found_item = sdk_select(
|
|
319
314
|
Runner::entity_list_to_data($${listvar}_result),
|
|
320
315
|
["id" => $${refDataVar}["id"]]);
|
|
321
|
-
$this->
|
|
316
|
+
$this->assertEmpty($not_found_item);
|
|
322
317
|
`)
|
|
323
318
|
}
|
|
324
319
|
}
|
|
@@ -36,8 +36,12 @@ const Config = cmp(async function Config(props: any) {
|
|
|
36
36
|
const feature = getModelPath(model, `main.${KIT}.feature`)
|
|
37
37
|
|
|
38
38
|
const headers = getModelPath(model, `main.${KIT}.config.headers`) || {}
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
|
|
40
|
+
let authPrefix = ''
|
|
41
|
+
try { authPrefix = getModelPath(model, `main.${KIT}.config.auth.prefix`) } catch (_e) { }
|
|
42
|
+
|
|
43
|
+
let baseUrl = ''
|
|
44
|
+
try { baseUrl = getModelPath(model, `main.${KIT}.info.servers.0.url`) } catch (_e) { }
|
|
41
45
|
|
|
42
46
|
File({ name: 'config.' + target.ext }, () => {
|
|
43
47
|
|
|
@@ -78,6 +78,8 @@ import pytest
|
|
|
78
78
|
from utility.voxgig_struct import voxgig_struct as vs
|
|
79
79
|
from ${model.name}_sdk import ${model.const.Name}SDK
|
|
80
80
|
from core import helpers
|
|
81
|
+
|
|
82
|
+
_TEST_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
81
83
|
from test import runner
|
|
82
84
|
|
|
83
85
|
|
|
@@ -121,7 +123,7 @@ class Test${entity.Name}Entity:
|
|
|
121
123
|
def ${entity.name}_basic_setup(extra):
|
|
122
124
|
runner.load_env_local()
|
|
123
125
|
|
|
124
|
-
entity_data_file = "../../.sdk/test/entity/${entity.name}/${entity.Name}TestData.json"
|
|
126
|
+
entity_data_file = os.path.join(_TEST_DIR, "../../.sdk/test/entity/${entity.name}/${entity.Name}TestData.json")
|
|
125
127
|
with open(entity_data_file, "r") as f:
|
|
126
128
|
entity_data_source = f.read()
|
|
127
129
|
|
|
@@ -36,8 +36,12 @@ const Config = cmp(async function Config(props: any) {
|
|
|
36
36
|
const feature = getModelPath(model, `main.${KIT}.feature`)
|
|
37
37
|
|
|
38
38
|
const headers = getModelPath(model, `main.${KIT}.config.headers`) || {}
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
|
|
40
|
+
let authPrefix = ''
|
|
41
|
+
try { authPrefix = getModelPath(model, `main.${KIT}.config.auth.prefix`) } catch (_e) { }
|
|
42
|
+
|
|
43
|
+
let baseUrl = ''
|
|
44
|
+
try { baseUrl = getModelPath(model, `main.${KIT}.info.servers.0.url`) } catch (_e) { }
|
|
41
45
|
|
|
42
46
|
File({ name: 'config.' + target.ext }, () => {
|
|
43
47
|
|
|
@@ -117,7 +117,7 @@ func (f *LogFeature) loghook(hook string, ctx *core.Context, level string) {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
if ctx.Spec != nil {
|
|
120
|
-
attrs = append(attrs, "spec", ctx.Spec.
|
|
120
|
+
attrs = append(attrs, "spec", ctx.Spec.Method+" "+ctx.Spec.Path)
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
switch level {
|
|
@@ -6,6 +6,7 @@ import (
|
|
|
6
6
|
"os"
|
|
7
7
|
"path/filepath"
|
|
8
8
|
"reflect"
|
|
9
|
+
"regexp"
|
|
9
10
|
"runtime"
|
|
10
11
|
"strings"
|
|
11
12
|
"sync"
|
|
@@ -140,7 +141,7 @@ func runset(t *testing.T, testspec map[string]any, subject RunSubject) {
|
|
|
140
141
|
if expectedErr != nil {
|
|
141
142
|
errMsg := err.Error()
|
|
142
143
|
if expStr, ok := expectedErr.(string); ok {
|
|
143
|
-
if !
|
|
144
|
+
if !matchString(expStr, errMsg) {
|
|
144
145
|
t.Errorf("entry %d%s: error mismatch: got %q, want contains %q",
|
|
145
146
|
i, mark, errMsg, expStr)
|
|
146
147
|
}
|
|
@@ -272,7 +273,7 @@ func matchDeep(t *testing.T, entryIdx int, mark string, check any, base any, pat
|
|
|
272
273
|
if !reflect.DeepEqual(normCheck, normBase) {
|
|
273
274
|
if isStr && checkStr != "" {
|
|
274
275
|
baseStr := vs.Stringify(base)
|
|
275
|
-
if
|
|
276
|
+
if matchString(checkStr, baseStr) {
|
|
276
277
|
return
|
|
277
278
|
}
|
|
278
279
|
}
|
|
@@ -282,6 +283,19 @@ func matchDeep(t *testing.T, entryIdx int, mark string, check any, base any, pat
|
|
|
282
283
|
}
|
|
283
284
|
}
|
|
284
285
|
|
|
286
|
+
// matchString checks if val matches pattern. If pattern is /regex/, use regexp;
|
|
287
|
+
// otherwise do case-insensitive contains.
|
|
288
|
+
func matchString(pattern string, val string) bool {
|
|
289
|
+
if len(pattern) >= 2 && pattern[0] == '/' && pattern[len(pattern)-1] == '/' {
|
|
290
|
+
re, err := regexp.Compile(pattern[1 : len(pattern)-1])
|
|
291
|
+
if err != nil {
|
|
292
|
+
return false
|
|
293
|
+
}
|
|
294
|
+
return re.MatchString(val)
|
|
295
|
+
}
|
|
296
|
+
return strings.Contains(strings.ToLower(val), strings.ToLower(pattern))
|
|
297
|
+
}
|
|
298
|
+
|
|
285
299
|
// makeCtxFromMap creates a Context from a JSON test entry's ctx or args map.
|
|
286
300
|
func makeCtxFromMap(ctxmap map[string]any, client *sdk.ProjectNameSDK, utility *sdk.Utility) *sdk.Context {
|
|
287
301
|
if ctxmap == nil {
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
|
|
2
|
+
const { inspect } = require('node:util')
|
|
3
|
+
|
|
4
|
+
const { ProjectNameError } = require('./ProjectNameError')
|
|
5
|
+
|
|
6
|
+
const { getprop, setprop, getpath } = require('./utility/StructUtility')
|
|
7
|
+
|
|
8
|
+
const { Operation } = require('./Operation')
|
|
9
|
+
const { Response } = require('./Response')
|
|
10
|
+
const { Result } = require('./Result')
|
|
11
|
+
const { Spec } = require('./Spec')
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
// TODO: move to own file
|
|
15
|
+
class Context {
|
|
16
|
+
|
|
17
|
+
id = 'C' + ('' + Math.random()).substring(2, 10)
|
|
18
|
+
|
|
19
|
+
// Store the output of each operation step.
|
|
20
|
+
out = {}
|
|
21
|
+
|
|
22
|
+
// Store for the current operation.
|
|
23
|
+
current = new WeakMap()
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
ctrl = {}
|
|
27
|
+
meta = {}
|
|
28
|
+
|
|
29
|
+
client
|
|
30
|
+
utility
|
|
31
|
+
|
|
32
|
+
op
|
|
33
|
+
point
|
|
34
|
+
|
|
35
|
+
config
|
|
36
|
+
entopts
|
|
37
|
+
options
|
|
38
|
+
|
|
39
|
+
opmap
|
|
40
|
+
|
|
41
|
+
response
|
|
42
|
+
result
|
|
43
|
+
spec
|
|
44
|
+
|
|
45
|
+
data
|
|
46
|
+
reqdata
|
|
47
|
+
match
|
|
48
|
+
reqmatch
|
|
49
|
+
|
|
50
|
+
entity
|
|
51
|
+
|
|
52
|
+
// Shared persistent store.
|
|
53
|
+
shared
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
constructor(ctxmap, basectx) {
|
|
57
|
+
this.client = getprop(ctxmap, 'client', getprop(basectx, 'client'))
|
|
58
|
+
this.utility = getprop(ctxmap, 'utility', getprop(basectx, 'utility'))
|
|
59
|
+
|
|
60
|
+
this.ctrl = getprop(ctxmap, 'ctrl', getprop(basectx, 'ctrl', this.ctrl))
|
|
61
|
+
this.meta = getprop(ctxmap, 'meta', getprop(basectx, 'meta', this.meta))
|
|
62
|
+
|
|
63
|
+
this.config = getprop(ctxmap, 'config', getprop(basectx, 'config'))
|
|
64
|
+
this.entopts = getprop(ctxmap, 'entopts', getprop(basectx, 'entopts'))
|
|
65
|
+
this.options = getprop(ctxmap, 'options', getprop(basectx, 'options'))
|
|
66
|
+
|
|
67
|
+
this.entity = getprop(ctxmap, 'entity', getprop(basectx, 'entity'))
|
|
68
|
+
this.shared = getprop(ctxmap, 'shared', getprop(basectx, 'shared'))
|
|
69
|
+
this.opmap = getprop(ctxmap, 'opmap', getprop(basectx, 'opmap'))
|
|
70
|
+
|
|
71
|
+
this.data = getprop(ctxmap, 'data', {})
|
|
72
|
+
this.reqdata = getprop(ctxmap, 'reqdata', {})
|
|
73
|
+
this.match = getprop(ctxmap, 'match', {})
|
|
74
|
+
this.reqmatch = getprop(ctxmap, 'reqmatch', {})
|
|
75
|
+
|
|
76
|
+
this.point = getprop(ctxmap, 'point', getprop(basectx, 'point'))
|
|
77
|
+
this.spec = getprop(ctxmap, 'spec', getprop(basectx, 'spec'))
|
|
78
|
+
this.result = getprop(ctxmap, 'result', getprop(basectx, 'result'))
|
|
79
|
+
this.response = getprop(ctxmap, 'response', getprop(basectx, 'response'))
|
|
80
|
+
|
|
81
|
+
const opname = getprop(ctxmap, 'opname')
|
|
82
|
+
this.op = this.resolveOp(opname)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
resolveOp(opname) {
|
|
87
|
+
let op = getprop(this.opmap, opname)
|
|
88
|
+
|
|
89
|
+
if (null == op && null != opname) {
|
|
90
|
+
const entname = getprop(this.entity, 'name', '')
|
|
91
|
+
const opcfg = getpath(this.config, ['entity', entname, 'op', opname])
|
|
92
|
+
let input = 'match'
|
|
93
|
+
|
|
94
|
+
if ('update' === opname || 'create' === opname) {
|
|
95
|
+
input = 'data'
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
op = new Operation({
|
|
99
|
+
entity: entname,
|
|
100
|
+
name: opname,
|
|
101
|
+
input,
|
|
102
|
+
points: getprop(opcfg, 'points', [])
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
setprop(this.opmap, opname, op)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return op
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
error(code, msg) {
|
|
113
|
+
return new ProjectNameError(code, msg, this)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
toJSON() {
|
|
118
|
+
return {
|
|
119
|
+
id: this.id,
|
|
120
|
+
op: this.op,
|
|
121
|
+
spec: this.spec,
|
|
122
|
+
entity: this.entity,
|
|
123
|
+
result: this.result,
|
|
124
|
+
response: this.response,
|
|
125
|
+
meta: this.meta,
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
toString() {
|
|
130
|
+
return 'Context ' + this.utility?.struct.jsonify(this.toJSON())
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
[inspect.custom]() {
|
|
134
|
+
return this.toString()
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
module.exports = {
|
|
141
|
+
Context,
|
|
142
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
const { getprop } = require('./utility/StructUtility')
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Control {
|
|
6
|
+
constructor(ctrlmap) {
|
|
7
|
+
this.throw = getprop(ctrlmap, 'throw')
|
|
8
|
+
this.err = getprop(ctrlmap, 'err')
|
|
9
|
+
this.explain = getprop(ctrlmap, 'explain')
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
Control,
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
const { getprop } = require('./utility/StructUtility')
|
|
3
|
+
|
|
4
|
+
const { Point } = require('./Point')
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Operation {
|
|
8
|
+
constructor(opmap) {
|
|
9
|
+
this.entity = getprop(opmap, 'entity', '_')
|
|
10
|
+
this.name = getprop(opmap, 'name', '_')
|
|
11
|
+
this.input = getprop(opmap, 'input', '_')
|
|
12
|
+
this.points = getprop(opmap, 'points', [])
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
module.exports = {
|
|
18
|
+
Operation,
|
|
19
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
const { getprop } = require('./utility/StructUtility')
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Point {
|
|
6
|
+
constructor(altmap) {
|
|
7
|
+
this.args = getprop(altmap, 'args', { params: [] })
|
|
8
|
+
this.rename = getprop(altmap, 'rename', { params: {} })
|
|
9
|
+
this.method = getprop(altmap, 'method', '')
|
|
10
|
+
this.orig = getprop(altmap, 'orig', '')
|
|
11
|
+
this.parts = getprop(altmap, 'parts', [])
|
|
12
|
+
this.params = getprop(altmap, 'params', [])
|
|
13
|
+
this.select = getprop(altmap, 'select')
|
|
14
|
+
this.active = getprop(altmap, 'active', false)
|
|
15
|
+
this.relations = getprop(altmap, 'relations', [])
|
|
16
|
+
this.alias = getprop(altmap, 'alias', {})
|
|
17
|
+
this.transform = getprop(altmap, 'transform', { req: undefined, res: undefined })
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
module.exports = {
|
|
23
|
+
Point,
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# src
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
const { getprop } = require('./utility/StructUtility')
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Response {
|
|
6
|
+
constructor(resmap) {
|
|
7
|
+
this.status = getprop(resmap, 'status', -1)
|
|
8
|
+
this.statusText = getprop(resmap, 'statusText', '')
|
|
9
|
+
this.headers = getprop(resmap, 'headers')
|
|
10
|
+
this.json = resmap.json ? resmap.json.bind(resmap) : async () => undefined
|
|
11
|
+
this.body = getprop(resmap, 'body')
|
|
12
|
+
this.err = getprop(resmap, 'err')
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
module.exports = {
|
|
18
|
+
Response,
|
|
19
|
+
}
|