@voxgig/sdkgen 0.17.0 → 0.18.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/dist/action/feature.js +3 -2
- package/dist/action/feature.js.map +1 -1
- package/dist/action/target.js +11 -6
- package/dist/action/target.js.map +1 -1
- package/dist/cmp/Entity.js +2 -1
- package/dist/cmp/Entity.js.map +1 -1
- package/dist/cmp/Main.js +23 -9
- package/dist/cmp/Main.js.map +1 -1
- package/dist/sdkgen.d.ts +7 -1
- package/dist/sdkgen.js +5 -2
- package/dist/sdkgen.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utility.js +1 -2
- package/dist/utility.js.map +1 -1
- package/model/sdkgen.jsonic +8 -5
- package/package.json +5 -5
- package/project/{generate → .sdk}/model/feature/log.jsonic +5 -1
- package/project/{generate → .sdk}/model/target/js.jsonic +0 -1
- package/project/.sdk/model/target/ts.jsonic +25 -0
- package/project/{generate → .sdk}/src/cmp/js/Config_js.ts +17 -2
- package/project/{generate → .sdk}/src/cmp/js/Entity_js.ts +16 -15
- package/project/{generate → .sdk}/src/cmp/js/Main_js.ts +22 -16
- package/project/{generate → .sdk}/src/cmp/js/Package_js.ts +2 -1
- package/project/.sdk/src/cmp/js/TestAcceptEntity_js.ts +13 -0
- package/project/.sdk/src/cmp/js/TestAccept_js.ts +18 -0
- package/project/.sdk/src/cmp/js/TestEntity_js.ts +13 -0
- package/project/.sdk/src/cmp/js/TestMain_js.ts +19 -0
- package/project/{generate → .sdk}/src/cmp/js/fragment/Entity.fragment.js +15 -7
- package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +61 -0
- package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +57 -0
- package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +61 -0
- package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +61 -0
- package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +61 -0
- package/project/{generate → .sdk}/src/cmp/js/fragment/Main.fragment.js +26 -3
- package/project/.sdk/src/cmp/ts/Config_ts.ts +36 -0
- package/project/.sdk/src/cmp/ts/Entity_ts.ts +93 -0
- package/project/.sdk/src/cmp/ts/MainEntity_ts.ts.off +22 -0
- package/project/.sdk/src/cmp/ts/Main_ts.ts +88 -0
- package/project/.sdk/src/cmp/ts/Main_ts.ts~ +88 -0
- package/project/.sdk/src/cmp/ts/Package_ts.ts +63 -0
- package/project/.sdk/src/cmp/ts/Package_ts.ts~ +58 -0
- package/project/.sdk/src/cmp/ts/Quick_ts.ts.off +82 -0
- package/project/.sdk/src/cmp/ts/ReadmeInstall_ts.ts.off +19 -0
- package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts.off +25 -0
- package/project/.sdk/src/cmp/ts/TestAcceptEntity_ts.ts.off +13 -0
- package/project/.sdk/src/cmp/ts/TestAccept_ts.ts.off +18 -0
- package/project/.sdk/src/cmp/ts/TestEntity_ts.ts.off +13 -0
- package/project/.sdk/src/cmp/ts/TestMain_ts.ts.off +19 -0
- package/project/.sdk/src/cmp/ts/Test_ts.ts.off +24 -0
- package/project/.sdk/src/cmp/ts/fragment/Config.fragment.ts +15 -0
- package/project/.sdk/src/cmp/ts/fragment/Entity.fragment.js +79 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.js +61 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.js +57 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.js +61 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.js +61 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.js +61 -0
- package/project/.sdk/src/cmp/ts/fragment/Main.fragment.js +67 -0
- package/project/{generate → .sdk}/tm/js/src/feature/log/LogFeature.js +14 -10
- package/project/.sdk/tm/js/src/utility/AuthUtility.js +21 -0
- package/project/.sdk/tm/js/src/utility/BodyUtility.js +29 -0
- package/project/.sdk/tm/js/src/utility/DoneUtility.js +15 -0
- package/project/.sdk/tm/js/src/utility/ErrorUtility.js +33 -0
- package/project/.sdk/tm/js/src/utility/FindparamUtility.js +31 -0
- package/project/.sdk/tm/js/src/utility/FullurlUtility.js +39 -0
- package/project/{generate → .sdk}/tm/js/src/utility/HeadersUtility.js +2 -1
- package/project/.sdk/tm/js/src/utility/JoinurlUtility.js +14 -0
- package/project/{generate → .sdk}/tm/js/src/utility/MethodUtility.js +2 -1
- package/project/.sdk/tm/js/src/utility/OperatorUtility.js +44 -0
- package/project/.sdk/tm/js/src/utility/OptionsUtility.js +54 -0
- package/project/{generate → .sdk}/tm/js/src/utility/ParamsUtility.js +5 -4
- package/project/{generate → .sdk}/tm/js/src/utility/QueryUtility.js +6 -4
- package/project/.sdk/tm/js/src/utility/ReqformUtility.js +32 -0
- package/project/.sdk/tm/js/src/utility/RequestUtility.js +48 -0
- package/project/.sdk/tm/js/src/utility/ResbasicUtility.js +27 -0
- package/project/.sdk/tm/js/src/utility/ResbodyUtility.js +15 -0
- package/project/.sdk/tm/js/src/utility/ResformUtility.js +34 -0
- package/project/.sdk/tm/js/src/utility/ResheadersUtility.js +19 -0
- package/project/{generate → .sdk}/tm/js/src/utility/ResponseUtility.js +11 -10
- package/project/.sdk/tm/js/src/utility/ResultUtility.js +28 -0
- package/project/{generate → .sdk}/tm/js/src/utility/SpecUtility.js +6 -12
- package/project/.sdk/tm/js/src/utility/StructUtility.js +1203 -0
- package/project/.sdk/tm/js/src/utility/Utility.js +74 -0
- package/project/.sdk/tm/js/test/runner.js +171 -0
- package/project/.sdk/tm/js/test/utility/Custom.test.js +85 -0
- package/project/.sdk/tm/js/test/utility/PrimaryUtility.test.js +187 -0
- package/project/.sdk/tm/js/test/utility/StructUtility.test.js +367 -0
- package/project/.sdk/tm/py/LICENSE +22 -0
- package/project/.sdk/tm/ts/LICENSE +22 -0
- package/project/.sdk/tm/ts/src/README.md +1 -0
- package/project/.sdk/tm/ts/src/feature/README.md +1 -0
- package/project/.sdk/tm/ts/src/tsconfig.json +15 -0
- package/project/.sdk/tm/ts/src/utility/README.md +3 -0
- package/project/.sdk/tm/ts/test/README.md +2 -0
- package/project/.sdk/tm/ts/test/README.md~ +2 -0
- package/project/.sdk/tm/ts/test/tsconfig.json +13 -0
- package/src/action/feature.ts +4 -3
- package/src/action/target.ts +12 -6
- package/src/cmp/Entity.ts +3 -1
- package/src/cmp/Main.ts +30 -10
- package/src/sdkgen.ts +15 -5
- package/src/utility.ts +1 -2
- package/project/generate/src/cmp/js/TestAcceptEntity_js.ts +0 -101
- package/project/generate/src/cmp/js/TestAccept_js.ts +0 -60
- package/project/generate/src/cmp/js/TestEntity_js.ts +0 -24
- package/project/generate/src/cmp/js/TestMain_js.ts +0 -120
- package/project/generate/src/cmp/js/fragment/EntityCreateOp.fragment.js +0 -66
- package/project/generate/src/cmp/js/fragment/EntityListOp.fragment.js +0 -72
- package/project/generate/src/cmp/js/fragment/EntityLoadOp.fragment.js +0 -66
- package/project/generate/src/cmp/js/fragment/EntityRemoveOp.fragment.js +0 -66
- package/project/generate/src/cmp/js/fragment/EntityUpdateOp.fragment.js +0 -66
- package/project/generate/tm/js/src/utility/AuthUtility.js +0 -16
- package/project/generate/tm/js/src/utility/BodyUtility.js +0 -27
- package/project/generate/tm/js/src/utility/EmptyUtility.js +0 -8
- package/project/generate/tm/js/src/utility/ErrorUtility.js +0 -15
- package/project/generate/tm/js/src/utility/EscreUtility.js +0 -8
- package/project/generate/tm/js/src/utility/EscurlUtility.js +0 -8
- package/project/generate/tm/js/src/utility/FetchUtility.js +0 -33
- package/project/generate/tm/js/src/utility/FullurlUtility.js +0 -41
- package/project/generate/tm/js/src/utility/InwardUtility.js +0 -23
- package/project/generate/tm/js/src/utility/JoinurlUtility.js +0 -12
- package/project/generate/tm/js/src/utility/OperatorUtility.js +0 -36
- package/project/generate/tm/js/src/utility/OptionsUtility.js +0 -22
- package/project/generate/tm/js/src/utility/OutwardUtility.js +0 -23
- package/project/generate/tm/js/src/utility/ResbasicUtility.js +0 -17
- package/project/generate/tm/js/src/utility/ResbodyUtility.js +0 -10
- package/project/generate/tm/js/src/utility/ResheadersUtility.js +0 -11
- package/project/generate/tm/js/src/utility/Utility.js +0 -55
- /package/project/{generate → .sdk}/model/feature/limit.jsonic +0 -0
- /package/project/{generate → .sdk}/model/feature/page.jsonic +0 -0
- /package/project/{generate → .sdk}/model/feature/telemetry.jsonic +0 -0
- /package/project/{generate → .sdk}/model/target/go.jsonic +0 -0
- /package/project/{generate → .sdk}/src/cmp/js/MainEntity_js.ts +0 -0
- /package/project/{generate → .sdk}/src/cmp/js/Quick_js.ts +0 -0
- /package/project/{generate → .sdk}/src/cmp/js/ReadmeInstall_js.ts +0 -0
- /package/project/{generate → .sdk}/src/cmp/js/ReadmeQuick_js.ts +0 -0
- /package/project/{generate → .sdk}/src/cmp/js/Test_js.ts +0 -0
- /package/project/{generate → .sdk}/tm/go/LICENSE +0 -0
- /package/project/{generate → .sdk}/tm/js/LICENSE +0 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
async function request(ctx) {
|
|
4
|
+
const { spec, utility, client } = ctx
|
|
5
|
+
const { fullurl, error } = utility
|
|
6
|
+
|
|
7
|
+
let response = {}
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
spec.step = 'prepare'
|
|
11
|
+
|
|
12
|
+
const options = client.options()
|
|
13
|
+
const url = spec.url = fullurl(ctx)
|
|
14
|
+
|
|
15
|
+
const fetch = options.system.fetch
|
|
16
|
+
|
|
17
|
+
const fetchdef = {
|
|
18
|
+
method: spec.method,
|
|
19
|
+
headers: spec.headers,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if(null != spec.body) {
|
|
23
|
+
fetchdef.body =
|
|
24
|
+
'object' === typeof spec.body ? JSON.stringify(spec.body) : spec.body
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
spec.step = 'prerequest'
|
|
28
|
+
response = await fetch(url, fetchdef)
|
|
29
|
+
|
|
30
|
+
if(null == response) {
|
|
31
|
+
response = { err: new Error('response: undefined') }
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch(err) {
|
|
35
|
+
response = response || {}
|
|
36
|
+
response.err = err
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
spec.step = 'postrequest'
|
|
40
|
+
|
|
41
|
+
ctx.response = response
|
|
42
|
+
|
|
43
|
+
return response
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = {
|
|
47
|
+
request
|
|
48
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
|
|
2
|
+
function resbasic(ctx) {
|
|
3
|
+
const { response, result } = ctx
|
|
4
|
+
|
|
5
|
+
if(null != response) {
|
|
6
|
+
result.status = response.status || -1
|
|
7
|
+
result.statusText = response.statusText || 'no-status'
|
|
8
|
+
|
|
9
|
+
// TODO: use spec!
|
|
10
|
+
if(400 <= result.status) {
|
|
11
|
+
const msg = 'request: '+result.status+': '+result.statusText
|
|
12
|
+
if(result.err) {
|
|
13
|
+
const prevmsg = null == result.err.message ? '' : result.err.message
|
|
14
|
+
result.err.message = prevmsg+': '+msg
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
result.err = new Error(msg)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return result
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = {
|
|
26
|
+
resbasic
|
|
27
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
/* Convert data from respnse into a structure suitable for use as entity data.
|
|
3
|
+
*
|
|
4
|
+
* The operation (op) property `resform` is used to perform the data extraction.
|
|
5
|
+
*/
|
|
6
|
+
function resform(ctx) {
|
|
7
|
+
const { op, spec, result, utility } = ctx
|
|
8
|
+
const { struct, error } = utility
|
|
9
|
+
const { isfunc, transform } = struct
|
|
10
|
+
|
|
11
|
+
if(spec) {
|
|
12
|
+
spec.step = 'resform'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (!result.ok) {
|
|
16
|
+
return undefined
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
const resform = ctx.op.resform
|
|
21
|
+
const resdata = isfunc(resform) ? resform(ctx) : transform(ctx.result, resform)
|
|
22
|
+
result.resdata = resdata
|
|
23
|
+
|
|
24
|
+
return resdata
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
return error(ctx, err)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
module.exports = {
|
|
33
|
+
resform
|
|
34
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
function resheaders(ctx) {
|
|
3
|
+
const { response, result } = ctx
|
|
4
|
+
|
|
5
|
+
if(response && response.headers && response.headers.forEach) {
|
|
6
|
+
const headers = {}
|
|
7
|
+
response.headers.forEach((v,k)=>headers[k]=v)
|
|
8
|
+
result.headers = headers
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
result.headers = {}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return result
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = {
|
|
18
|
+
resheaders
|
|
19
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
|
|
2
|
-
const { resheaders } = require('./ResheadersUtility')
|
|
3
|
-
const { resbasic } = require('./ResbasicUtility')
|
|
4
|
-
const { resbody } = require('./ResbodyUtility')
|
|
5
|
-
|
|
6
2
|
async function response(ctx) {
|
|
7
|
-
let { response } = ctx
|
|
3
|
+
let { response, spec, utility } = ctx
|
|
8
4
|
|
|
5
|
+
const { resheaders, resbasic, resbody, resform } = utility
|
|
6
|
+
|
|
7
|
+
spec.step = 'response'
|
|
8
|
+
|
|
9
9
|
let result = {
|
|
10
10
|
ok: false,
|
|
11
11
|
status: -1,
|
|
@@ -15,10 +15,13 @@ async function response(ctx) {
|
|
|
15
15
|
err: response.err,
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
ctx.result = result
|
|
19
|
+
|
|
18
20
|
try {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
resbasic(ctx)
|
|
22
|
+
resheaders(ctx)
|
|
23
|
+
await resbody(ctx)
|
|
24
|
+
resform(ctx)
|
|
22
25
|
|
|
23
26
|
if(null == result.err) {
|
|
24
27
|
result.ok = true
|
|
@@ -27,8 +30,6 @@ async function response(ctx) {
|
|
|
27
30
|
catch(err) {
|
|
28
31
|
result.err = err
|
|
29
32
|
}
|
|
30
|
-
|
|
31
|
-
return result
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
module.exports = {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
async function result(ctx) {
|
|
3
|
+
let { op, response, spec, utility } = ctx
|
|
4
|
+
|
|
5
|
+
const { resheaders, resbasic, resbody, resform } = utility
|
|
6
|
+
|
|
7
|
+
spec.step = 'result'
|
|
8
|
+
|
|
9
|
+
resform(ctx)
|
|
10
|
+
|
|
11
|
+
if('list' == op.name) {
|
|
12
|
+
let resdata = ctx.result.resdata
|
|
13
|
+
ctx.resdata = []
|
|
14
|
+
|
|
15
|
+
if(null != resdata && 0 < resdata.length) {
|
|
16
|
+
for(let entry of resdata) {
|
|
17
|
+
const entity = entity.make()
|
|
18
|
+
entity.data(entry)
|
|
19
|
+
ctx.resdata.push(entity)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
module.exports = {
|
|
27
|
+
result
|
|
28
|
+
}
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
const { method } = require('./MethodUtility')
|
|
3
|
-
const { params } = require('./ParamsUtility')
|
|
4
|
-
const { query } = require('./QueryUtility')
|
|
5
|
-
const { headers } = require('./HeadersUtility')
|
|
6
|
-
const { body } = require('./BodyUtility')
|
|
7
|
-
const { auth } = require('./AuthUtility')
|
|
8
|
-
|
|
9
2
|
// Create request specificaton.
|
|
10
3
|
function spec(ctx) {
|
|
11
|
-
const {client, op} = ctx
|
|
4
|
+
const { client, op, utility } = ctx
|
|
5
|
+
const { method, params, query, headers, body, auth } = utility
|
|
12
6
|
|
|
13
7
|
let options = client.options()
|
|
14
8
|
|
|
@@ -18,7 +12,7 @@ function spec(ctx) {
|
|
|
18
12
|
const reqHeaders = headers(ctx)
|
|
19
13
|
const reqBody = body(ctx)
|
|
20
14
|
|
|
21
|
-
|
|
15
|
+
ctx.spec = {
|
|
22
16
|
base: options.base, // string, URL endpoint base prefix,
|
|
23
17
|
prefix: options.prefix,
|
|
24
18
|
path: op.path,
|
|
@@ -28,11 +22,11 @@ function spec(ctx) {
|
|
|
28
22
|
query: reqQuery,
|
|
29
23
|
headers: reqHeaders,
|
|
30
24
|
body: reqBody,
|
|
25
|
+
step: 'start',
|
|
26
|
+
alias: {}
|
|
31
27
|
}
|
|
32
28
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return spec
|
|
29
|
+
auth(ctx)
|
|
36
30
|
}
|
|
37
31
|
|
|
38
32
|
|