@voxgig/sdkgen 0.22.0 → 0.23.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 +12 -4
- package/dist/action/action.d.ts +4 -0
- package/dist/action/action.js +35 -0
- package/dist/action/action.js.map +1 -0
- package/dist/action/feature.d.ts +4 -2
- package/dist/action/feature.js +57 -38
- package/dist/action/feature.js.map +1 -1
- package/dist/action/target.d.ts +4 -2
- package/dist/action/target.js +136 -45
- package/dist/action/target.js.map +1 -1
- package/dist/cmp/Entity.js +5 -0
- package/dist/cmp/Entity.js.map +1 -1
- package/dist/cmp/Feature.js +5 -0
- package/dist/cmp/Feature.js.map +1 -1
- package/dist/cmp/Main.js +4 -1
- package/dist/cmp/Main.js.map +1 -1
- package/dist/cmp/Top.d.ts +2 -0
- package/dist/cmp/Top.js +23 -0
- package/dist/cmp/Top.js.map +1 -0
- package/dist/sdkgen.d.ts +10 -3
- package/dist/sdkgen.js +53 -8
- package/dist/sdkgen.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +16 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utility.d.ts +3 -3
- package/dist/utility.js +7 -8
- package/dist/utility.js.map +1 -1
- package/package.json +6 -10
- package/project/.sdk/model/feature/README.md +2 -0
- package/project/.sdk/model/feature/log.jsonic +7 -4
- package/project/.sdk/model/feature/test.jsonic +26 -0
- package/project/.sdk/model/target/ts.jsonic +1 -0
- package/project/.sdk/src/cmp/ts/Config_ts.ts +7 -2
- package/project/.sdk/src/cmp/ts/EntityOperation_ts.ts +67 -0
- package/project/.sdk/src/cmp/ts/EntityTest_ts.ts +180 -0
- package/project/.sdk/src/cmp/ts/Entity_ts.ts +41 -66
- package/project/.sdk/src/cmp/ts/MainEntity_ts.ts +22 -0
- package/project/.sdk/src/cmp/ts/Main_ts.ts +52 -53
- package/project/.sdk/src/cmp/ts/Package_ts.ts +12 -7
- package/project/.sdk/src/cmp/ts/ReadmeInstall_ts.ts +19 -0
- package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +24 -0
- package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +13 -0
- package/project/.sdk/src/cmp/ts/TestMain_ts.ts +19 -0
- package/project/.sdk/src/cmp/ts/Test_ts.ts +20 -0
- package/project/.sdk/src/cmp/ts/fragment/Config.fragment.ts +8 -1
- package/project/.sdk/src/cmp/ts/fragment/Entity.fragment.ts +164 -0
- package/project/.sdk/src/cmp/ts/fragment/Entity.test.fragment.ts +37 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.ts +91 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.ts +92 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.ts +96 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.ts +96 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.ts +95 -0
- package/project/.sdk/src/cmp/ts/fragment/Main.fragment.ts +107 -0
- package/project/.sdk/src/cmp/ts/utility_ts.ts +10 -0
- package/project/.sdk/tm/ts/src/feature/base/BaseFeature.ts +43 -0
- package/project/.sdk/tm/ts/src/feature/log/LogFeature.ts +109 -0
- package/project/.sdk/tm/ts/src/feature/test/TestFeature.ts +159 -0
- package/project/.sdk/tm/ts/src/tsconfig.json +1 -1
- package/project/.sdk/tm/ts/src/types.ts +114 -0
- package/project/.sdk/tm/ts/src/utility/AddfeatureUtility.ts +47 -0
- package/project/.sdk/tm/ts/src/utility/AuthUtility.ts +42 -0
- package/project/.sdk/tm/ts/src/utility/BodyUtility.ts +29 -0
- package/project/.sdk/tm/ts/src/utility/CleanUtility.ts +50 -0
- package/project/.sdk/tm/ts/src/utility/ContextUtility.ts +67 -0
- package/project/.sdk/tm/ts/src/utility/DoneUtility.ts +28 -0
- package/project/.sdk/tm/ts/src/utility/ErrorUtility.ts +59 -0
- package/project/.sdk/tm/ts/src/utility/FeaturehookUtility.ts +26 -0
- package/project/.sdk/tm/ts/src/utility/FetcherUtility.ts +17 -0
- package/project/.sdk/tm/ts/src/utility/FindparamUtility.ts +54 -0
- package/project/.sdk/tm/ts/src/utility/FullurlUtility.ts +46 -0
- package/project/.sdk/tm/ts/src/utility/HeadersUtility.ts +24 -0
- package/project/.sdk/tm/ts/src/utility/InitfeatureUtility.ts +13 -0
- package/project/.sdk/tm/ts/src/utility/JoinurlUtility.ts +15 -0
- package/project/.sdk/tm/ts/src/utility/MethodUtility.ts +25 -0
- package/project/.sdk/tm/ts/src/utility/OperatorUtility.ts +90 -0
- package/project/.sdk/tm/ts/src/utility/OptionsUtility.ts +72 -0
- package/project/.sdk/tm/ts/src/utility/ParamsUtility.ts +37 -0
- package/project/.sdk/tm/ts/src/utility/QueryUtility.ts +27 -0
- package/project/.sdk/tm/ts/src/utility/ReqformUtility.ts +33 -0
- package/project/.sdk/tm/ts/src/utility/RequestUtility.ts +66 -0
- package/project/.sdk/tm/ts/src/utility/ResbasicUtility.ts +34 -0
- package/project/.sdk/tm/ts/src/utility/ResbodyUtility.ts +19 -0
- package/project/.sdk/tm/ts/src/utility/ResformUtility.ts +36 -0
- package/project/.sdk/tm/ts/src/utility/ResheadersUtility.ts +23 -0
- package/project/.sdk/tm/ts/src/utility/ResponseUtility.ts +30 -0
- package/project/.sdk/tm/ts/src/utility/ResultUtility.ts +36 -0
- package/project/.sdk/tm/ts/src/utility/SpecUtility.ts +61 -0
- package/project/.sdk/tm/ts/src/utility/StructUtility.ts +2499 -0
- package/project/.sdk/tm/ts/src/utility/Utility.ts +88 -0
- package/project/.sdk/tm/ts/test/exists.test.ts +17 -0
- package/project/.sdk/tm/ts/test/runner.ts +402 -0
- package/project/.sdk/tm/ts/test/tsconfig.json +1 -1
- package/project/.sdk/tm/ts/test/utility/Custom.test.ts +62 -0
- package/project/.sdk/tm/ts/test/utility/PrimaryUtility.test.ts +244 -0
- package/project/.sdk/tm/ts/test/utility/StructUtility.test.ts +678 -0
- package/project/.sdk/tm/ts/test/utility/index.ts +9 -0
- package/project/.sdk/tm/ts/test/utility.ts +86 -0
- package/src/action/action.ts +54 -0
- package/src/action/feature.ts +83 -47
- package/src/action/target.ts +173 -53
- package/src/cmp/Entity.ts +6 -0
- package/src/cmp/Feature.ts +6 -3
- package/src/cmp/Main.ts +4 -1
- package/src/sdkgen.ts +86 -11
- package/src/types.ts +33 -0
- package/src/utility.ts +5 -3
- package/project/.sdk/model/feature/limit.jsonic +0 -12
- package/project/.sdk/model/feature/page.jsonic +0 -9
- package/project/.sdk/model/feature/telemetry.jsonic +0 -10
- package/project/.sdk/src/cmp/ts/fragment/Entity.fragment.js +0 -79
- package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.js +0 -61
- package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.js +0 -57
- package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.js +0 -61
- package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.js +0 -61
- package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.js +0 -61
- package/project/.sdk/src/cmp/ts/fragment/Main.fragment.js +0 -67
- package/project/.sdk/tm/ts/test/README.md~ +0 -2
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
|
|
2
|
+
import { Context } from '../types'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
async function request(ctx: Context) {
|
|
6
|
+
const { spec, utility } = ctx
|
|
7
|
+
const { fullurl, fetcher } = utility
|
|
8
|
+
|
|
9
|
+
let response: any = {}
|
|
10
|
+
|
|
11
|
+
let result = {
|
|
12
|
+
ok: false,
|
|
13
|
+
status: -1,
|
|
14
|
+
statusText: '',
|
|
15
|
+
headers: {},
|
|
16
|
+
body: undefined,
|
|
17
|
+
err: undefined,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
ctx.result = result
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
spec.step = 'prepare'
|
|
25
|
+
|
|
26
|
+
const url = spec.url = fullurl(ctx)
|
|
27
|
+
|
|
28
|
+
const fetchdef: any = {
|
|
29
|
+
method: spec.method,
|
|
30
|
+
headers: spec.headers,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (null != spec.body) {
|
|
34
|
+
fetchdef.body =
|
|
35
|
+
'object' === typeof spec.body ? JSON.stringify(spec.body) : spec.body
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (ctx.ctrl.explain) {
|
|
39
|
+
ctx.ctrl.explain.fetchdef = fetchdef
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
spec.step = 'prerequest'
|
|
43
|
+
|
|
44
|
+
// TODO: see js code, use `native` prop here
|
|
45
|
+
response = await fetcher(ctx, url, fetchdef)
|
|
46
|
+
|
|
47
|
+
if (null == response) {
|
|
48
|
+
response = { err: new Error('response: undefined') }
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
response = response || {}
|
|
53
|
+
response.err = err
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
spec.step = 'postrequest'
|
|
57
|
+
|
|
58
|
+
ctx.response = response
|
|
59
|
+
|
|
60
|
+
return response
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
export {
|
|
65
|
+
request
|
|
66
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
import { Context } from '../types'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function resbasic(ctx: Context) {
|
|
6
|
+
const { response, result } = ctx
|
|
7
|
+
|
|
8
|
+
if (null != response) {
|
|
9
|
+
result.status = response.status || -1
|
|
10
|
+
result.statusText = response.statusText || 'no-status'
|
|
11
|
+
|
|
12
|
+
// TODO: use spec!
|
|
13
|
+
if (400 <= result.status) {
|
|
14
|
+
const msg = 'request: ' + result.status + ': ' + result.statusText
|
|
15
|
+
if (result.err) {
|
|
16
|
+
const prevmsg = null == result.err.message ? '' : result.err.message
|
|
17
|
+
result.err.message = prevmsg + ': ' + msg
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
result.err = new Error(msg)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
else if (response.err) {
|
|
24
|
+
result.err = response.err
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return result
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
resbasic
|
|
34
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
import { Context } from '../types'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
async function resbody(ctx: Context) {
|
|
6
|
+
const { response, result } = ctx
|
|
7
|
+
|
|
8
|
+
if (response && response.json) {
|
|
9
|
+
const json = await response.json()
|
|
10
|
+
result.body = json
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return result
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
resbody
|
|
19
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
import { Context } from '../types'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/* Convert data from respnse into a structure suitable for use as entity data.
|
|
6
|
+
*
|
|
7
|
+
* The operation (op) property `resform` is used to perform the data extraction.
|
|
8
|
+
*/
|
|
9
|
+
function resform(ctx: Context) {
|
|
10
|
+
const { spec, result, utility } = ctx
|
|
11
|
+
const { struct, error } = utility
|
|
12
|
+
const { isfunc, transform } = struct
|
|
13
|
+
|
|
14
|
+
if (spec) {
|
|
15
|
+
spec.step = 'resform'
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (!result.ok) {
|
|
19
|
+
return undefined
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
const resform = ctx.op.resform
|
|
24
|
+
const resdata = isfunc(resform) ? resform(ctx) : transform(ctx.result, resform)
|
|
25
|
+
result.resdata = resdata
|
|
26
|
+
return resdata
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
return error(ctx, err)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
resform
|
|
36
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
import { Context } from '../types'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function resheaders(ctx: Context) {
|
|
6
|
+
const { response, result } = ctx
|
|
7
|
+
|
|
8
|
+
if (response && response.headers && response.headers.forEach) {
|
|
9
|
+
const headers: any = {}
|
|
10
|
+
response.headers.forEach((v: any, k: any) => headers[k] = v)
|
|
11
|
+
result.headers = headers
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
result.headers = {}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return result
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
resheaders
|
|
23
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
|
|
2
|
+
import { Context } from '../types'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
async function response(ctx: Context) {
|
|
6
|
+
let { result, spec, utility } = ctx
|
|
7
|
+
|
|
8
|
+
const { resheaders, resbasic, resbody, resform } = utility
|
|
9
|
+
|
|
10
|
+
spec.step = 'response'
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
resbasic(ctx)
|
|
14
|
+
resheaders(ctx)
|
|
15
|
+
await resbody(ctx)
|
|
16
|
+
resform(ctx)
|
|
17
|
+
|
|
18
|
+
if (null == result.err) {
|
|
19
|
+
result.ok = true
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
result.err = err
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
response
|
|
30
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
import { Context } from '../types'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
async function result(ctx: Context) {
|
|
6
|
+
let { op, spec, utility, entity, result } = ctx
|
|
7
|
+
|
|
8
|
+
const { resform } = utility
|
|
9
|
+
|
|
10
|
+
spec.step = 'result'
|
|
11
|
+
|
|
12
|
+
resform(ctx)
|
|
13
|
+
|
|
14
|
+
if ('list' == op.name) {
|
|
15
|
+
const resdata = result.resdata
|
|
16
|
+
result.resdata = []
|
|
17
|
+
|
|
18
|
+
if (null != resdata && 0 < resdata.length) {
|
|
19
|
+
for (let entry of resdata) {
|
|
20
|
+
const ent = entity.make()
|
|
21
|
+
ent.data(entry)
|
|
22
|
+
result.resdata.push(ent)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (ctx.ctrl.explain) {
|
|
28
|
+
ctx.ctrl.explain.result = result
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
result
|
|
36
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
|
|
2
|
+
import { Context } from '../types'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
// Create request specificaton.
|
|
6
|
+
function spec(ctx: Context) {
|
|
7
|
+
const { client, op, utility } = ctx
|
|
8
|
+
const struct = utility.struct
|
|
9
|
+
const size = struct.size
|
|
10
|
+
const select = struct.select
|
|
11
|
+
const { method, params, query, headers, body, auth } = utility
|
|
12
|
+
|
|
13
|
+
let options = client.options()
|
|
14
|
+
|
|
15
|
+
ctx.spec = {
|
|
16
|
+
base: options.base, // string, URL endpoint base prefix,
|
|
17
|
+
prefix: options.prefix,
|
|
18
|
+
path: op.path,
|
|
19
|
+
suffix: options.suffix,
|
|
20
|
+
method: 'get',
|
|
21
|
+
params: {},
|
|
22
|
+
query: {},
|
|
23
|
+
headers: {},
|
|
24
|
+
body: undefined,
|
|
25
|
+
step: 'start',
|
|
26
|
+
alias: {}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
ctx.spec.method = method(ctx)
|
|
30
|
+
ctx.spec.params = params(ctx)
|
|
31
|
+
ctx.spec.query = query(ctx)
|
|
32
|
+
ctx.spec.headers = headers(ctx)
|
|
33
|
+
ctx.spec.body = body(ctx)
|
|
34
|
+
|
|
35
|
+
if (1 < size(op.pathalt)) {
|
|
36
|
+
let hasQuery = false
|
|
37
|
+
const paramQuery: any = {}
|
|
38
|
+
for (let paramName of op.params) {
|
|
39
|
+
paramQuery[paramName] = null == ctx.spec.params[paramName] ? undefined : true
|
|
40
|
+
hasQuery = true
|
|
41
|
+
}
|
|
42
|
+
if (hasQuery) {
|
|
43
|
+
const foundParamAlts = select(op.pathalt, paramQuery)
|
|
44
|
+
console.log('PQ', paramQuery, foundParamAlts)
|
|
45
|
+
if (0 < size(foundParamAlts)) {
|
|
46
|
+
ctx.spec.path = foundParamAlts[0].path
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (ctx.ctrl.explain) {
|
|
52
|
+
ctx.ctrl.explain.spec = ctx.spec
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
auth(ctx)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
export {
|
|
60
|
+
spec
|
|
61
|
+
}
|