@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
package/src/utility.ts
CHANGED
|
@@ -4,8 +4,7 @@ import Path from 'node:path'
|
|
|
4
4
|
// TODO: move to @voxgig/util as duplicated with @voxgig/sdkgen
|
|
5
5
|
|
|
6
6
|
const resolvePath = (ctx$: any, path: string): any => {
|
|
7
|
-
|
|
8
|
-
const fullpath = Path.join(ctx$.folder, 'generate', 'dist', path)
|
|
7
|
+
const fullpath = Path.join(ctx$.folder, '.sdk', 'dist', path)
|
|
9
8
|
return fullpath
|
|
10
9
|
}
|
|
11
10
|
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { cmp, camelify, Content } from '@voxgig/sdkgen'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const TestAcceptEntity = cmp(function TestEntity(props: any) {
|
|
6
|
-
const { entity } = props
|
|
7
|
-
|
|
8
|
-
entity.Name = camelify(entity.name)
|
|
9
|
-
|
|
10
|
-
Content(`
|
|
11
|
-
test('${entity.name}-load', async ()=>{
|
|
12
|
-
const client = makeClient()
|
|
13
|
-
const out = await client.${entity.Name}().load({id:'t01'})
|
|
14
|
-
//console.log('${entity.name}-load', 'out', out)
|
|
15
|
-
|
|
16
|
-
// equal(out.status, 200, 'Expected status code 200');
|
|
17
|
-
|
|
18
|
-
// Check out.data is an object
|
|
19
|
-
equal(typeof out.data, 'object', 'Expected data to be an object');
|
|
20
|
-
|
|
21
|
-
// Check out.data has id
|
|
22
|
-
equal(typeof out.data.id, 'string', 'Expected data to have an id');
|
|
23
|
-
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
test('${entity.name}-list', async ()=>{
|
|
27
|
-
const client = makeClient()
|
|
28
|
-
const out = await client.${entity.Name}().list()
|
|
29
|
-
//console.log('${entity.name}-list', 'out', out)
|
|
30
|
-
|
|
31
|
-
// Check out is an array
|
|
32
|
-
equal(Array.isArray(out), true, 'Expected an array');
|
|
33
|
-
|
|
34
|
-
// Check out.data is an object
|
|
35
|
-
equal(typeof out[0], 'object', 'Expected data to be an object');
|
|
36
|
-
|
|
37
|
-
// Check out.data has id
|
|
38
|
-
equal(typeof out[0].data.id, 'string', 'Expected data to have an id');
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
test('${entity.name}-create', async ()=>{
|
|
42
|
-
const client = makeClient()
|
|
43
|
-
const out = await client.${entity.Name}().create(${JSON.stringify(generateObjectFromFields(entity.field))})
|
|
44
|
-
//console.log('${entity.name}-create', 'out', out)
|
|
45
|
-
|
|
46
|
-
// Check out is an object
|
|
47
|
-
equal(typeof out, 'object', 'Expected an object');
|
|
48
|
-
|
|
49
|
-
// Check out.data has id
|
|
50
|
-
equal(typeof out.data.id, 'string', 'Expected data to have an id');
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
test('${entity.name}-save', async ()=>{
|
|
54
|
-
const client = makeClient()
|
|
55
|
-
const out = await client.${entity.Name}().save(${JSON.stringify(generateObjectFromFields(entity.field))})
|
|
56
|
-
//console.log('${entity.name}-save', 'out', out)
|
|
57
|
-
|
|
58
|
-
// Check out is an object
|
|
59
|
-
equal(typeof out, 'object', 'Expected an object');
|
|
60
|
-
|
|
61
|
-
// Check out.data has id
|
|
62
|
-
equal(typeof out.data.id, 'string', 'Expected data to have an id');
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
test('${entity.name}-remove', async ()=>{
|
|
66
|
-
const client = makeClient()
|
|
67
|
-
const out = await client.${entity.Name}().remove({id:'t01'})
|
|
68
|
-
//console.log('${entity.name}-remove', 'out', out)
|
|
69
|
-
|
|
70
|
-
// Check out is an object
|
|
71
|
-
equal(typeof out, 'object', 'Expected an object');
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
`);
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
function generateObjectFromFields(fields: any) {
|
|
78
|
-
const getRandomString = (length: number): string =>
|
|
79
|
-
Array.from({ length }, () => 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.charAt(Math.floor(Math.random() * 62))).join('');
|
|
80
|
-
|
|
81
|
-
const defaultValues: Record<string, any> = {
|
|
82
|
-
number: Math.floor(Math.random() * 100),
|
|
83
|
-
string: getRandomString(5),
|
|
84
|
-
object: { [getRandomString(3)]: getRandomString(3) },
|
|
85
|
-
boolean: Math.random() > 0.5,
|
|
86
|
-
array: Array.from({ length: 3 }, () => getRandomString(3)),
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const result: Record<string, any> = {}
|
|
90
|
-
|
|
91
|
-
for (const key in fields) {
|
|
92
|
-
result[key] = defaultValues[fields[key].type] ?? null;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return result
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
export {
|
|
100
|
-
TestAcceptEntity
|
|
101
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { cmp, each, File, Content } from '@voxgig/sdkgen'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { TestAcceptEntity } from './TestAcceptEntity_js'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const TestAccept = cmp(function TestMain(props: any) {
|
|
9
|
-
const { target } = props
|
|
10
|
-
const { model } = props.ctx$
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
File({ name: model.const.Name + 'SDK.accept.test.' + target.name }, () => {
|
|
14
|
-
|
|
15
|
-
Content(`
|
|
16
|
-
const { test, describe } = require('node:test')
|
|
17
|
-
const { equal, deepEqual } = require('node:assert')
|
|
18
|
-
|
|
19
|
-
const { ${model.const.Name}SDK } = require('../../')
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
describe('${model.const.Name}SDK Acceptance Tests', ()=>{
|
|
23
|
-
test('happy', async ()=>{
|
|
24
|
-
const client = makeClient()
|
|
25
|
-
const out = await client.Geofence().load({id:'gf01'})
|
|
26
|
-
console.log('Geofence.load', out)
|
|
27
|
-
equal(out.data.id,'gf01')
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
`)
|
|
31
|
-
|
|
32
|
-
each(model.main.sdk.entity, (entity: any) => {
|
|
33
|
-
TestAcceptEntity({ model, target, entity })
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
Content(`
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
function makeClient(config) {
|
|
42
|
-
const client = ${model.const.Name}SDK.make({
|
|
43
|
-
endpoint: process.env.${model.NAME}_ENDPOINT,
|
|
44
|
-
apikey: process.env.${model.NAME}_APIKEY,
|
|
45
|
-
...config
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
return client
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
`)
|
|
52
|
-
|
|
53
|
-
})
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
export {
|
|
58
|
-
TestAccept
|
|
59
|
-
}
|
|
60
|
-
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { cmp, camelify, Content } from '@voxgig/sdkgen'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const TestEntity = cmp(function TestEntity(props: any) {
|
|
6
|
-
const { entity } = props
|
|
7
|
-
|
|
8
|
-
entity.Name = camelify(entity.name)
|
|
9
|
-
|
|
10
|
-
Content(`
|
|
11
|
-
test('${entity.name}-load', async ()=>{
|
|
12
|
-
const client = makeClient()
|
|
13
|
-
const out = await client.${entity.Name}().load({id:'t01'})
|
|
14
|
-
console.log('${entity.name}-load', out)
|
|
15
|
-
deepEqual(out.data,{id:'t01',title:'T01'})
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
`)
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
TestEntity
|
|
24
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { cmp, each, File, Content } from '@voxgig/sdkgen'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { TestEntity } from './TestEntity_js'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const TestMain = cmp(function TestMain(props: any) {
|
|
9
|
-
const { target } = props
|
|
10
|
-
const { model } = props.ctx$
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
File({ name: model.const.Name + 'SDK.test.' + target.name }, () => {
|
|
14
|
-
|
|
15
|
-
Content(`
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const { test, describe } = require('node:test')
|
|
19
|
-
const { equal, deepEqual } = require('node:assert')
|
|
20
|
-
|
|
21
|
-
const { ${model.const.Name}SDK } = require('../')
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
describe('${model.const.Name}SDK Unit Tests', ()=>{
|
|
25
|
-
test('make', async ()=>{
|
|
26
|
-
const client = makeClient()
|
|
27
|
-
equal(null == client, false)
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
`)
|
|
31
|
-
|
|
32
|
-
each(model.main.sdk.entity, (entity: any) => {
|
|
33
|
-
TestEntity({ model, target, entity })
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
Content(`
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
function makeClient(config) {
|
|
42
|
-
const client = ${model.const.Name}SDK.make({
|
|
43
|
-
endpoint: 'https://host/api/v1/rest/project_id/plant/stage',
|
|
44
|
-
apikey: 'apikey',
|
|
45
|
-
fetch,
|
|
46
|
-
...config
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
return client
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async function fetch(url, config) {
|
|
53
|
-
const parts = url.split('/')
|
|
54
|
-
const entname = parts[9]
|
|
55
|
-
const entid = parts[10]
|
|
56
|
-
const data = JSON.parse(config.body||'{}')
|
|
57
|
-
const method = config.method || 'GET'
|
|
58
|
-
|
|
59
|
-
const req$ = {
|
|
60
|
-
url,
|
|
61
|
-
parts,
|
|
62
|
-
entname,
|
|
63
|
-
entid,
|
|
64
|
-
method,
|
|
65
|
-
data,
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
console.log('REQ', req$)
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
req$,
|
|
72
|
-
status: 200,
|
|
73
|
-
json: async function() {
|
|
74
|
-
if('PUT'=== method||'POST'===method) {
|
|
75
|
-
return entid ? {
|
|
76
|
-
id: entid,
|
|
77
|
-
title: data.title,
|
|
78
|
-
} :
|
|
79
|
-
{
|
|
80
|
-
id: 'n01',
|
|
81
|
-
title: data.title || 'T01',
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
else if('GET'===method) {
|
|
85
|
-
return entid ? {
|
|
86
|
-
id: entid,
|
|
87
|
-
title: 'T01'
|
|
88
|
-
} :
|
|
89
|
-
{
|
|
90
|
-
name: entname,
|
|
91
|
-
list: [
|
|
92
|
-
{
|
|
93
|
-
id: 'n01',
|
|
94
|
-
title: 'N01'
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
id: 'n01',
|
|
98
|
-
title: 'N01'
|
|
99
|
-
},
|
|
100
|
-
]
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
return {}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
`)
|
|
112
|
-
|
|
113
|
-
})
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
export {
|
|
118
|
-
TestMain
|
|
119
|
-
}
|
|
120
|
-
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
class EntityOperation { // REMOVED
|
|
2
|
-
async create(data) {
|
|
3
|
-
let entity = this
|
|
4
|
-
let client = this.#client
|
|
5
|
-
|
|
6
|
-
let op = {
|
|
7
|
-
entity: 'Name',
|
|
8
|
-
name:'create',
|
|
9
|
-
path: 'PATH',
|
|
10
|
-
params: ['PARAM'],
|
|
11
|
-
query: this.#query,
|
|
12
|
-
data: null == data ? this.#data : data,
|
|
13
|
-
state: {},
|
|
14
|
-
inward: (ctx)=>'INWARD',
|
|
15
|
-
outward: (ctx)=>'OUTWARD',
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
let ctx = {client, entity, op}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// #PreOperation-Hook
|
|
22
|
-
|
|
23
|
-
ctx.op = await this.#utility.operator(ctx)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// #ModifyOp-Hook
|
|
27
|
-
|
|
28
|
-
this.#data = ctx.op.data
|
|
29
|
-
|
|
30
|
-
ctx.spec = await this.#utility.spec(ctx)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// #PreFetch-Hook
|
|
34
|
-
|
|
35
|
-
ctx.response = await this.#utility.fetch(ctx)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// #PostFetch-Hook
|
|
39
|
-
|
|
40
|
-
ctx.result = await this.#utility.response(ctx)
|
|
41
|
-
|
|
42
|
-
// #ModifyResult-Hook
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if(ctx.result.ok) {
|
|
46
|
-
ctx.indata = this.#utility.inward(ctx)
|
|
47
|
-
|
|
48
|
-
if(null != ctx.indata) {
|
|
49
|
-
this.#data = ctx.indata
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
this.#postCreateHook(ctx)
|
|
53
|
-
|
|
54
|
-
return this
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
this.#postCreateHook(ctx)
|
|
58
|
-
|
|
59
|
-
return this.#utility.error(ctx)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
#postCreateHook(ctx) {
|
|
64
|
-
// #PostOperation-Hook
|
|
65
|
-
}
|
|
66
|
-
} // REMOVED
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
class EntityOperation { // REMOVED
|
|
2
|
-
async list(query) {
|
|
3
|
-
let entity = this
|
|
4
|
-
let client = this.#client
|
|
5
|
-
|
|
6
|
-
let op = {
|
|
7
|
-
entity: 'Name',
|
|
8
|
-
name:'load',
|
|
9
|
-
path: 'PATH',
|
|
10
|
-
params: ['PARAM'],
|
|
11
|
-
query,
|
|
12
|
-
data: this.#data,
|
|
13
|
-
state: {},
|
|
14
|
-
inward: (ctx)=>'INWARD',
|
|
15
|
-
outward: (ctx)=>'OUTWARD',
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
let ctx = {client, entity, op}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// #PreOperation-Hook
|
|
22
|
-
|
|
23
|
-
ctx.op = await this.#utility.operator(ctx)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// #ModifyOp-Hook
|
|
27
|
-
|
|
28
|
-
this.#query = ctx.op.query
|
|
29
|
-
|
|
30
|
-
ctx.spec = await this.#utility.spec(ctx)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// #PreFetch-Hook
|
|
34
|
-
|
|
35
|
-
ctx.response = await this.#utility.fetch(ctx)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// #PostFetch-Hook
|
|
39
|
-
|
|
40
|
-
ctx.result = await this.#utility.response(ctx)
|
|
41
|
-
|
|
42
|
-
// #ModifyResult-Hook
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if(ctx.result.ok) {
|
|
46
|
-
ctx.inlist = this.#utility.inward(ctx)
|
|
47
|
-
|
|
48
|
-
const entities = []
|
|
49
|
-
|
|
50
|
-
if(null != ctx.inlist) {
|
|
51
|
-
for(let entry of ctx.inlist) {
|
|
52
|
-
const entity = new NameEntity(this.#client, this.options())
|
|
53
|
-
entity.data(entry)
|
|
54
|
-
entities.push(entity)
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
this.#postListHook(ctx)
|
|
59
|
-
|
|
60
|
-
return entities
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
this.#postListHook(ctx)
|
|
64
|
-
|
|
65
|
-
return this.#utility.error(ctx)
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
#postListHook(ctx) {
|
|
70
|
-
// #PostOperation-Hook
|
|
71
|
-
}
|
|
72
|
-
} // REMOVED
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
class EntityOperation { // REMOVED
|
|
2
|
-
async load(query) {
|
|
3
|
-
let entity = this
|
|
4
|
-
let client = this.#client
|
|
5
|
-
|
|
6
|
-
let op = {
|
|
7
|
-
entity:'Name',
|
|
8
|
-
name:'load',
|
|
9
|
-
path: 'PATH',
|
|
10
|
-
params: ['PARAM'],
|
|
11
|
-
query,
|
|
12
|
-
data: this.#data,
|
|
13
|
-
state: {},
|
|
14
|
-
inward: (ctx)=>'INWARD',
|
|
15
|
-
outward: (ctx)=>'OUTWARD',
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
let ctx = {client, entity, op}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// #PreOperation-Hook
|
|
22
|
-
|
|
23
|
-
ctx.op = await this.#utility.operator(ctx)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// #ModifyOp-Hook
|
|
27
|
-
|
|
28
|
-
this.#query = op.query
|
|
29
|
-
|
|
30
|
-
ctx.spec = await this.#utility.spec(ctx)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// #PreFetch-Hook
|
|
34
|
-
|
|
35
|
-
ctx.response = await this.#utility.fetch(ctx)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// #PostFetch-Hook
|
|
39
|
-
|
|
40
|
-
ctx.result = await this.#utility.response(ctx)
|
|
41
|
-
|
|
42
|
-
// #ModifyResult-Hook
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if(ctx.result.ok) {
|
|
46
|
-
ctx.indata = this.#utility.inward(ctx)
|
|
47
|
-
|
|
48
|
-
if(null != ctx.indata) {
|
|
49
|
-
this.#data = ctx.indata
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
this.#postLoadHook(ctx)
|
|
53
|
-
|
|
54
|
-
return this
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
this.#postLoadHook(ctx)
|
|
58
|
-
|
|
59
|
-
return this.#utility.error(ctx)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
#postLoadHook(ctx) {
|
|
64
|
-
// #PostOperation-Hook
|
|
65
|
-
}
|
|
66
|
-
} // REMOVED
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
class EntityOperation { // REMOVED
|
|
2
|
-
async remove(query) {
|
|
3
|
-
let entity = this
|
|
4
|
-
let client = this.#client
|
|
5
|
-
|
|
6
|
-
let op = {
|
|
7
|
-
entity: 'Name',
|
|
8
|
-
name:'remove',
|
|
9
|
-
path: 'PATH',
|
|
10
|
-
params: ['PARAM'],
|
|
11
|
-
query,
|
|
12
|
-
data: this.#data,
|
|
13
|
-
state: {},
|
|
14
|
-
inward: (ctx)=>'INWARD',
|
|
15
|
-
outward: (ctx)=>'OUTWARD',
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
let ctx = {client, entity, op}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// #PreOperation-Hook
|
|
22
|
-
|
|
23
|
-
ctx.op = await this.#utility.operator(ctx)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// #ModifyOp-Hook
|
|
27
|
-
|
|
28
|
-
this.#query = op.query
|
|
29
|
-
|
|
30
|
-
ctx.spec = await this.#utility.spec(ctx)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// #PreFetch-Hook
|
|
34
|
-
|
|
35
|
-
ctx.response = await this.#utility.fetch(ctx)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// #PostFetch-Hook
|
|
39
|
-
|
|
40
|
-
ctx.result = await this.#utility.response(ctx)
|
|
41
|
-
|
|
42
|
-
// #ModifyResult-Hook
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if(ctx.result.ok) {
|
|
46
|
-
ctx.indata = this.#utility.inward(ctx)
|
|
47
|
-
|
|
48
|
-
if(null != ctx.indata) {
|
|
49
|
-
this.#data = ctx.indata
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
this.#postRemoveHook(ctx)
|
|
53
|
-
|
|
54
|
-
return this
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
this.#postRemoveHook(ctx)
|
|
58
|
-
|
|
59
|
-
return this.#utility.error(ctx)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
#postRemoveHook(ctx) {
|
|
64
|
-
// #PostOperation-Hook
|
|
65
|
-
}
|
|
66
|
-
} // REMOVED
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
class EntityOperation { // REMOVED
|
|
2
|
-
async update(data) {
|
|
3
|
-
let entity = this
|
|
4
|
-
let client = this.#client
|
|
5
|
-
|
|
6
|
-
let op = {
|
|
7
|
-
entity: 'Name',
|
|
8
|
-
name:'create',
|
|
9
|
-
path: 'PATH',
|
|
10
|
-
params: ['PARAM'],
|
|
11
|
-
query: this.#query,
|
|
12
|
-
data: null == data ? this.#data : data,
|
|
13
|
-
state: {},
|
|
14
|
-
inward: (ctx)=>'INWARD',
|
|
15
|
-
outward: (ctx)=>'OUTWARD',
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
let ctx = {client, entity, op}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// #PreOperation-Hook
|
|
22
|
-
|
|
23
|
-
ctx.op = await this.#utility.operator(ctx)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// #ModifyOp-Hook
|
|
27
|
-
|
|
28
|
-
this.#data = op.data
|
|
29
|
-
|
|
30
|
-
ctx.spec = await this.#utility.spec()
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// #PreFetch-Hook
|
|
34
|
-
|
|
35
|
-
ctx.response = await this.#utility.fetch(ctx)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// #PostFetch-Hook
|
|
39
|
-
|
|
40
|
-
ctx.result = await this.#utility.response(ctx)
|
|
41
|
-
|
|
42
|
-
// #ModifyResult-Hook
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if(ctx.result.ok) {
|
|
46
|
-
ctx.indata = this.#utility.inward(ctx)
|
|
47
|
-
|
|
48
|
-
if(null != ctx.indata) {
|
|
49
|
-
this.#data = ctx.indata
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
this.#postUpdateHook(ctx)
|
|
53
|
-
|
|
54
|
-
return this
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
this.#postUpdateHook(ctx)
|
|
58
|
-
|
|
59
|
-
return this.#utility.error(ctx)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
#postUpdateHook(ctx) {
|
|
64
|
-
// #PostOperation-Hook
|
|
65
|
-
}
|
|
66
|
-
} // REMOVED
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const { error } = require('./ErrorUtility')
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function body(ctx) {
|
|
6
|
-
const { op } = ctx
|
|
7
|
-
|
|
8
|
-
let body = undefined
|
|
9
|
-
|
|
10
|
-
if('req' === op.kind) {
|
|
11
|
-
try {
|
|
12
|
-
body = ctx.op.outward(ctx)
|
|
13
|
-
}
|
|
14
|
-
catch (err) {
|
|
15
|
-
// TDOD: need error codes and err msg text
|
|
16
|
-
ctx.result.ok = false
|
|
17
|
-
ctx.result.err = err
|
|
18
|
-
return error(ctx)
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return body
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = {
|
|
26
|
-
body
|
|
27
|
-
}
|