@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
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
function error(ctx) {
|
|
3
|
-
|
|
4
|
-
const err = new Error('Error: '+ctx.op.name+': '+(ctx.result.err?.message||'unknown'))
|
|
5
|
-
err.result = ctx.result
|
|
6
|
-
err.spec = ctx.spec
|
|
7
|
-
|
|
8
|
-
// TODO: model option to return instead
|
|
9
|
-
throw err
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
module.exports = {
|
|
14
|
-
error
|
|
15
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const { fullurl } = require('./FullurlUtility')
|
|
3
|
-
|
|
4
|
-
// Make HTTP request.
|
|
5
|
-
async function fetch(ctx) {
|
|
6
|
-
const {op, spec} = ctx
|
|
7
|
-
let response = {}
|
|
8
|
-
|
|
9
|
-
try {
|
|
10
|
-
const url = spec.url = fullurl(ctx)
|
|
11
|
-
|
|
12
|
-
const fetchReq = {
|
|
13
|
-
method: spec.method,
|
|
14
|
-
headers: spec.headers,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if(null != spec.body) {
|
|
18
|
-
fetchReq.body =
|
|
19
|
-
'object' === typeof spec.body ? JSON.stringify(spec.body) : spec.body
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
response = global.fetch(url, fetchReq)
|
|
23
|
-
}
|
|
24
|
-
catch(err) {
|
|
25
|
-
response.err = err
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return response
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
module.exports = {
|
|
32
|
-
fetch
|
|
33
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const { joinurl } = require('./JoinurlUtility')
|
|
3
|
-
const { escurl } = require('./EscurlUtility')
|
|
4
|
-
const { escre } = require('./EscreUtility')
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function fullurl(ctx) {
|
|
8
|
-
const { op, spec } = ctx
|
|
9
|
-
const { query, data } = op
|
|
10
|
-
|
|
11
|
-
let url = joinurl(spec.base, spec.prefix, spec.path, spec.suffix)
|
|
12
|
-
|
|
13
|
-
const params = spec.params
|
|
14
|
-
for(let key of op.params) {
|
|
15
|
-
if(null == params[key]) {
|
|
16
|
-
params[key] = 'res' === op.kind ? query[key] : data[key]
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
for(let key in params) {
|
|
21
|
-
const val = spec.params[key]
|
|
22
|
-
if(null != val) {
|
|
23
|
-
url = url.replace(RegExp('{'+escre(key)+'}'), escurl(val))
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
let qsep = '?'
|
|
28
|
-
for(let key in spec.query) {
|
|
29
|
-
const val = spec.query[key]
|
|
30
|
-
if(null != val) {
|
|
31
|
-
url += qsep + escurl(key) + '=' + escurl(val)
|
|
32
|
-
qsep = '&'
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return url
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
module.exports = {
|
|
40
|
-
fullurl
|
|
41
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const { error } = require('./ErrorUtility')
|
|
3
|
-
|
|
4
|
-
function inward(ctx) {
|
|
5
|
-
if (!ctx.result.ok) {
|
|
6
|
-
return undefined
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
try {
|
|
10
|
-
return ctx.op.inward(ctx)
|
|
11
|
-
}
|
|
12
|
-
catch (err) {
|
|
13
|
-
// TDOD: need error codes and err msg text
|
|
14
|
-
ctx.result.ok = false
|
|
15
|
-
ctx.result.err = err
|
|
16
|
-
return error(ctx)
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
module.exports = {
|
|
22
|
-
inward
|
|
23
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// NOTE: duplicated in @voxgig/apidef - dedup to @voxgig/util?
|
|
4
|
-
const OPKIND = {
|
|
5
|
-
create: 'req',
|
|
6
|
-
update: 'req',
|
|
7
|
-
remove: 'req',
|
|
8
|
-
load: 'res',
|
|
9
|
-
list: 'res',
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// Ensure standard operation definition.
|
|
14
|
-
function operator(ctx) {
|
|
15
|
-
const { op } = ctx
|
|
16
|
-
|
|
17
|
-
let out = {
|
|
18
|
-
name: op.name,
|
|
19
|
-
kind: OPKIND[op.name],
|
|
20
|
-
entity: op.entity,
|
|
21
|
-
path: op.path,
|
|
22
|
-
params: op.params || [],
|
|
23
|
-
query: {...op.query} || {},
|
|
24
|
-
data: {...op.data} || {},
|
|
25
|
-
state: op.state,
|
|
26
|
-
inward: op.inward,
|
|
27
|
-
outward: op.outward,
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return out
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
module.exports = {
|
|
35
|
-
operator
|
|
36
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const { empty } = require('./EmptyUtility')
|
|
3
|
-
|
|
4
|
-
function options(ctx) {
|
|
5
|
-
let config = ctx.config || {}
|
|
6
|
-
let copts = config.options || {}
|
|
7
|
-
|
|
8
|
-
let options = { ...(ctx.options||{}) }
|
|
9
|
-
|
|
10
|
-
options.base = empty(options.base) ?
|
|
11
|
-
empty(copts.base) ? 'http://localhost:8000' :
|
|
12
|
-
copts.base : options.base
|
|
13
|
-
|
|
14
|
-
options.prefix = empty(options.prefix) ? '' : options.prefix
|
|
15
|
-
options.suffix = empty(options.suffix) ? '' : options.suffix
|
|
16
|
-
|
|
17
|
-
return options
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
module.exports = {
|
|
21
|
-
options
|
|
22
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const { error } = require('./ErrorUtility')
|
|
3
|
-
|
|
4
|
-
function outward(ctx) {
|
|
5
|
-
if (!ctx.result.ok) {
|
|
6
|
-
return undefined
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
try {
|
|
10
|
-
return ctx.op.outward(ctx)
|
|
11
|
-
}
|
|
12
|
-
catch (err) {
|
|
13
|
-
// TDOD: need error codes and err msg text
|
|
14
|
-
ctx.result.ok = false
|
|
15
|
-
ctx.result.err = err
|
|
16
|
-
return error(ctx)
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
module.exports = {
|
|
22
|
-
outward
|
|
23
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
function resbasic(response, fetchResponse) {
|
|
3
|
-
response.status = fetchResponse.status
|
|
4
|
-
response.statusText = fetchResponse.statusText || 'no-status'
|
|
5
|
-
|
|
6
|
-
// TODO: use spec!
|
|
7
|
-
if(400 <= response.status) {
|
|
8
|
-
response.ok = false
|
|
9
|
-
response.err = new Error(response.status+': '+response.statusText)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return response
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
module.exports = {
|
|
16
|
-
resbasic
|
|
17
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const { auth } = require('./AuthUtility')
|
|
3
|
-
const { body } = require('./BodyUtility')
|
|
4
|
-
const { empty } = require('./EmptyUtility')
|
|
5
|
-
const { error } = require('./ErrorUtility')
|
|
6
|
-
const { escre } = require('./EscreUtility')
|
|
7
|
-
const { escurl } = require('./EscurlUtility')
|
|
8
|
-
const { fetch } = require('./FetchUtility')
|
|
9
|
-
const { fullurl } = require('./FullurlUtility')
|
|
10
|
-
const { headers } = require('./HeadersUtility')
|
|
11
|
-
const { inward } = require('./InwardUtility')
|
|
12
|
-
const { joinurl } = require('./JoinurlUtility')
|
|
13
|
-
const { method } = require('./MethodUtility')
|
|
14
|
-
const { operator } = require('./OperatorUtility')
|
|
15
|
-
const { options } = require('./OptionsUtility')
|
|
16
|
-
const { outward } = require('./outwardUtility')
|
|
17
|
-
const { params } = require('./ParamsUtility')
|
|
18
|
-
const { query } = require('./QueryUtility')
|
|
19
|
-
const { resbasic } = require('./ResbasicUtility')
|
|
20
|
-
const { resbody } = require('./ResbodyUtility')
|
|
21
|
-
const { resheaders } = require('./ResheadersUtility')
|
|
22
|
-
const { response } = require('./ResponseUtility')
|
|
23
|
-
const { spec } = require('./SpecUtility')
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const Utility = {
|
|
27
|
-
auth,
|
|
28
|
-
body,
|
|
29
|
-
empty,
|
|
30
|
-
error,
|
|
31
|
-
escre,
|
|
32
|
-
escurl,
|
|
33
|
-
fetch,
|
|
34
|
-
fullurl,
|
|
35
|
-
headers,
|
|
36
|
-
inward,
|
|
37
|
-
joinurl,
|
|
38
|
-
method,
|
|
39
|
-
operator,
|
|
40
|
-
options,
|
|
41
|
-
outward,
|
|
42
|
-
params,
|
|
43
|
-
query,
|
|
44
|
-
resbasic,
|
|
45
|
-
resbody,
|
|
46
|
-
resheaders,
|
|
47
|
-
response,
|
|
48
|
-
spec,
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
module.exports = {
|
|
53
|
-
Utility
|
|
54
|
-
}
|
|
55
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|