@voxgig/create-sdkgen 0.0.3 → 0.0.6
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-create-sdkgen +196 -0
- package/dist/create-sdkgen.d.ts +11 -8
- package/dist/create-sdkgen.js +61 -63
- package/dist/create-sdkgen.js.map +1 -1
- package/dist/standard/ModelSdk.js +8 -61
- package/dist/standard/ModelSdk.js.map +1 -1
- package/dist/standard/Root.js +58 -57
- package/dist/standard/Root.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -10
- package/src/create-sdkgen.ts +56 -74
- package/src/standard/ModelSdk.ts +9 -71
- package/src/standard/Root.ts +26 -68
- package/bin/run-create-sdkgen.js +0 -269
- package/bin/run-create-sdkgen.js~ +0 -1
- package/src/standard/ModelSdk.ts~ +0 -1
- package/src/standard/Root.ts~ +0 -3
- package/src/utility.ts +0 -8
- package/tm/standard/.env.local +0 -2
- package/tm/standard/build/sdk.js +0 -25
- package/tm/standard/def/DEFINITION.md +0 -2
- package/tm/standard/model/.model-config/model-config.jsonic +0 -13
- package/tm/standard/model/go.jsonic +0 -6
- package/tm/standard/model/js.jsonic +0 -6
- package/tm/standard/model/php.jsonic +0 -6
- package/tm/standard/model/py.jsonic +0 -7
- package/tm/standard/model/rb.jsonic +0 -6
- package/tm/standard/model/sdk.jsonic.off +0 -60
- package/tm/standard/package.json +0 -30
- package/tm/standard/src/Root.ts +0 -60
- package/tm/standard/src/go/Entity_go.ts +0 -226
- package/tm/standard/src/go/MainEntity_go.ts +0 -26
- package/tm/standard/src/go/Main_go.ts +0 -168
- package/tm/standard/src/go/Quick_go.ts +0 -108
- package/tm/standard/src/go/ReadmeInstall_go.ts +0 -19
- package/tm/standard/src/go/ReadmeQuick_go.ts +0 -45
- package/tm/standard/src/go/TestAcceptEntity_go.ts +0 -219
- package/tm/standard/src/go/TestAccept_go.ts +0 -38
- package/tm/standard/src/go/TestEntity_go.ts +0 -79
- package/tm/standard/src/go/TestMain_go.ts +0 -61
- package/tm/standard/src/go/Test_go.ts +0 -20
- package/tm/standard/src/js/Entity_js.ts +0 -135
- package/tm/standard/src/js/MainEntity_js.ts +0 -22
- package/tm/standard/src/js/Main_js.ts +0 -128
- package/tm/standard/src/js/Quick_js.ts +0 -72
- package/tm/standard/src/js/ReadmeInstall_js.ts +0 -19
- package/tm/standard/src/js/ReadmeQuick_js.ts +0 -27
- package/tm/standard/src/js/TestAcceptEntity_js.ts +0 -101
- package/tm/standard/src/js/TestAccept_js.ts +0 -60
- package/tm/standard/src/js/TestEntity_js.ts +0 -24
- package/tm/standard/src/js/TestMain_js.ts +0 -123
- package/tm/standard/src/js/Test_js.ts +0 -24
- package/tm/standard/src/php/Entity_php.ts +0 -97
- package/tm/standard/src/php/MainEntity_php.ts +0 -43
- package/tm/standard/src/php/Main_php.ts +0 -50
- package/tm/standard/src/php/Quick_php.ts +0 -59
- package/tm/standard/src/php/TestAcceptEntity_php.ts +0 -81
- package/tm/standard/src/php/TestAccept_php.ts +0 -33
- package/tm/standard/src/php/TestEntity_php.ts +0 -64
- package/tm/standard/src/php/TestMain_php.ts +0 -120
- package/tm/standard/src/php/Test_php.ts +0 -21
- package/tm/standard/src/py/Entity_py.ts +0 -98
- package/tm/standard/src/py/MainEntity_py.ts +0 -19
- package/tm/standard/src/py/Main_py.ts +0 -211
- package/tm/standard/src/py/Quick_py.ts +0 -133
- package/tm/standard/src/py/TestAcceptEntity_py.ts +0 -47
- package/tm/standard/src/py/TestAccept_py.ts +0 -77
- package/tm/standard/src/py/TestEntity_py.ts +0 -50
- package/tm/standard/src/py/TestMain_py.ts +0 -103
- package/tm/standard/src/py/Test_py.ts +0 -28
- package/tm/standard/src/rb/Client_rb.ts +0 -142
- package/tm/standard/src/rb/Entity_rb.ts +0 -153
- package/tm/standard/src/rb/Error_rb.ts +0 -56
- package/tm/standard/src/rb/MainEntity_rb.ts +0 -16
- package/tm/standard/src/rb/Main_rb.ts +0 -55
- package/tm/standard/src/rb/Quick_rb.ts +0 -65
- package/tm/standard/src/rb/ReadmeInstall_rb.ts +0 -19
- package/tm/standard/src/rb/ReadmeQuick_rb.ts +0 -30
- package/tm/standard/src/rb/TestAcceptEntity_rb.ts +0 -83
- package/tm/standard/src/rb/TestAccept_rb.ts +0 -45
- package/tm/standard/src/rb/TestEntity_rb.ts +0 -82
- package/tm/standard/src/rb/TestMain_rb.ts +0 -67
- package/tm/standard/src/rb/Test_rb.ts +0 -27
- package/tm/standard/src/tsconfig.json +0 -15
- package/tm/standard/tm/go/.env.example +0 -2
- package/tm/standard/tm/go/LICENSE +0 -22
- package/tm/standard/tm/go/go.mod +0 -5
- package/tm/standard/tm/go/go.sum +0 -2
- package/tm/standard/tm/js/LICENSE +0 -22
- package/tm/standard/tm/js/package.json +0 -17
- package/tm/standard/tm/php/LICENSE +0 -22
- package/tm/standard/tm/py/LICENSE +0 -22
- package/tm/standard/tm/py/MANIFEST.in +0 -4
- package/tm/standard/tm/py/Makefile +0 -14
- package/tm/standard/tm/py/pyproject.toml +0 -4
- package/tm/standard/tm/py/pytest.ini +0 -3
- package/tm/standard/tm/py/requirements.txt +0 -4
- package/tm/standard/tm/py/setup.cfg +0 -2
- package/tm/standard/tm/py/setup.py +0 -82
- package/tm/standard/tm/rb/.rspec +0 -1
- package/tm/standard/tm/rb/Gemfile +0 -21
- package/tm/standard/tm/rb/LICENSE +0 -22
- package/tm/standard/tm/rb/Rakefile +0 -6
- package/tm/standard/tm/rb/spec/spec_helper.rb +0 -22
- package/tm/standard/tm/rb/tm.gemspec +0 -39
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { names, getx, cmp, File, Content } from '@voxgig/sdkgen'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const Quick = cmp(function Quick(props: any) {
|
|
6
|
-
const { build } = props
|
|
7
|
-
const { model, meta: { spec } } = props.ctx$
|
|
8
|
-
|
|
9
|
-
// get quick entity from build config
|
|
10
|
-
|
|
11
|
-
// console.log('CONFIG 2')
|
|
12
|
-
// console.dir(spec.config, { depth: null })
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const ent = getx(spec.config, 'entity *').find((ent: any) => ent.test.quick.active)
|
|
16
|
-
names(ent, ent.key$)
|
|
17
|
-
|
|
18
|
-
console.log('ENT 3', ent)
|
|
19
|
-
|
|
20
|
-
File({ name: 'quick.' + build.name }, () => {
|
|
21
|
-
|
|
22
|
-
Content(`
|
|
23
|
-
// ENT 3
|
|
24
|
-
require('dotenv').config({ path: ['../../.env.local']})
|
|
25
|
-
|
|
26
|
-
const { ${model.Name}SDK } = require('../')
|
|
27
|
-
|
|
28
|
-
run()
|
|
29
|
-
|
|
30
|
-
async function run() {
|
|
31
|
-
const client = ${model.Name}SDK.make({
|
|
32
|
-
endpoint: process.env.${model.NAME}_ENDPOINT,
|
|
33
|
-
apikey: process.env.${model.NAME}_APIKEY,
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
let out
|
|
37
|
-
|
|
38
|
-
`)
|
|
39
|
-
|
|
40
|
-
if (ent.test.quick.create) {
|
|
41
|
-
Content(`
|
|
42
|
-
out = await client.${ent.Name}().create(${JSON.stringify(ent.test.quick.create)})
|
|
43
|
-
console.log('${ent.Name}.load', out)
|
|
44
|
-
`)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (ent.test.quick.load) {
|
|
48
|
-
Content(`
|
|
49
|
-
out = await client.${ent.Name}().load(${JSON.stringify(ent.test.quick.load)})
|
|
50
|
-
console.log('${ent.Name}.load', out)
|
|
51
|
-
`)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (ent.test.quick.list) {
|
|
55
|
-
Content(`
|
|
56
|
-
out = await client.${ent.Name}().list(${JSON.stringify(ent.test.quick.list)})
|
|
57
|
-
console.log('${ent.Name}.list', out)
|
|
58
|
-
`)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
Content(`
|
|
62
|
-
}
|
|
63
|
-
`)
|
|
64
|
-
|
|
65
|
-
})
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
export {
|
|
70
|
-
Quick
|
|
71
|
-
}
|
|
72
|
-
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { cmp, Content } from '@voxgig/sdkgen'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const ReadmeInstall = cmp(function ReadmeInstall(props: any) {
|
|
6
|
-
const { build } = props
|
|
7
|
-
|
|
8
|
-
Content('```js')
|
|
9
|
-
Content(`
|
|
10
|
-
npm install ${build.module.name}
|
|
11
|
-
`)
|
|
12
|
-
Content('```')
|
|
13
|
-
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export {
|
|
18
|
-
ReadmeInstall
|
|
19
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { cmp, Content } from '@voxgig/sdkgen'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const ReadmeQuick = cmp(function ReadmeQuick(props: any) {
|
|
6
|
-
const { build, ctx$: { model } } = props
|
|
7
|
-
|
|
8
|
-
Content('```js')
|
|
9
|
-
Content(`
|
|
10
|
-
const { ${model.Name}SDK } = require('${build.module.name}')
|
|
11
|
-
|
|
12
|
-
const client = ${model.Name}SDK.make({
|
|
13
|
-
endpoint: process.env.${model.NAME}_ENDPOINT,
|
|
14
|
-
apikey: process.env.${model.NAME}_APIKEY,
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
let buildings = await client.Building().list()
|
|
18
|
-
console.log('Buildings', buildings)
|
|
19
|
-
`)
|
|
20
|
-
Content('```')
|
|
21
|
-
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export {
|
|
26
|
-
ReadmeQuick
|
|
27
|
-
}
|
|
@@ -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 { build } = props
|
|
10
|
-
const { model } = props.ctx$
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
File({ name: model.Name + 'SDK.accept.test.' + build.name }, () => {
|
|
14
|
-
|
|
15
|
-
Content(`
|
|
16
|
-
const { test, describe } = require('node:test')
|
|
17
|
-
const { equal, deepEqual } = require('node:assert')
|
|
18
|
-
|
|
19
|
-
const { ${model.Name}SDK } = require('../../')
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
describe('${model.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, build, entity })
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
Content(`
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
function makeClient(config) {
|
|
42
|
-
const client = ${model.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,123 +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 { build } = props
|
|
10
|
-
const { model } = props.ctx$
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
File({ name: model.Name + 'SDK.test.' + build.name }, () => {
|
|
14
|
-
|
|
15
|
-
Content(`
|
|
16
|
-
|
|
17
|
-
// 1
|
|
18
|
-
|
|
19
|
-
const { test, describe } = require('node:test')
|
|
20
|
-
const { equal, deepEqual } = require('node:assert')
|
|
21
|
-
|
|
22
|
-
const { ${model.Name}SDK } = require('../')
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
describe('${model.Name}SDK Unit Tests', ()=>{
|
|
26
|
-
test('happy', async ()=>{
|
|
27
|
-
const client = makeClient()
|
|
28
|
-
const out = await client.Geofence().load({id:'gf01'})
|
|
29
|
-
console.log('Geofence-load', out)
|
|
30
|
-
equal(out.data.id,'gf01')
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
`)
|
|
34
|
-
|
|
35
|
-
each(model.main.sdk.entity, (entity: any) => {
|
|
36
|
-
TestEntity({ model, build, entity })
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
Content(`
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
function makeClient(config) {
|
|
45
|
-
const client = ${model.Name}SDK.make({
|
|
46
|
-
endpoint: 'https://host/api/v1/rest/project_id/plant/stage',
|
|
47
|
-
apikey: 'apikey',
|
|
48
|
-
fetch,
|
|
49
|
-
...config
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
return client
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async function fetch(url, config) {
|
|
56
|
-
const parts = url.split('/')
|
|
57
|
-
const entname = parts[9]
|
|
58
|
-
const entid = parts[10]
|
|
59
|
-
const data = JSON.parse(config.body||'{}')
|
|
60
|
-
const method = config.method || 'GET'
|
|
61
|
-
|
|
62
|
-
const req$ = {
|
|
63
|
-
url,
|
|
64
|
-
parts,
|
|
65
|
-
entname,
|
|
66
|
-
entid,
|
|
67
|
-
method,
|
|
68
|
-
data,
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
console.log('REQ', req$)
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
req$,
|
|
75
|
-
status: 200,
|
|
76
|
-
json: async function() {
|
|
77
|
-
if('PUT'=== method||'POST'===method) {
|
|
78
|
-
return entid ? {
|
|
79
|
-
id: entid,
|
|
80
|
-
title: data.title,
|
|
81
|
-
} :
|
|
82
|
-
{
|
|
83
|
-
id: 'n01',
|
|
84
|
-
title: data.title || 'T01',
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
else if('GET'===method) {
|
|
88
|
-
return entid ? {
|
|
89
|
-
id: entid,
|
|
90
|
-
title: 'T01'
|
|
91
|
-
} :
|
|
92
|
-
{
|
|
93
|
-
name: entname,
|
|
94
|
-
list: [
|
|
95
|
-
{
|
|
96
|
-
id: 'n01',
|
|
97
|
-
title: 'N01'
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
id: 'n01',
|
|
101
|
-
title: 'N01'
|
|
102
|
-
},
|
|
103
|
-
]
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
return {}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
`)
|
|
115
|
-
|
|
116
|
-
})
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
export {
|
|
121
|
-
TestMain
|
|
122
|
-
}
|
|
123
|
-
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { cmp, File, Content, Folder } from '@voxgig/sdkgen'
|
|
3
|
-
|
|
4
|
-
import { Quick } from './Quick_js'
|
|
5
|
-
import { TestMain } from './TestMain_js'
|
|
6
|
-
import { TestAccept } from './TestAccept_js'
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const Test = cmp(function Test(props: any) {
|
|
10
|
-
const { build } = props
|
|
11
|
-
|
|
12
|
-
Folder({ name: 'test' }, () => {
|
|
13
|
-
Quick({ build })
|
|
14
|
-
TestMain({ build })
|
|
15
|
-
Folder({ name: 'accept' }, () => {
|
|
16
|
-
TestAccept({ build })
|
|
17
|
-
})
|
|
18
|
-
})
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
Test
|
|
24
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { cmp, File, Content, Folder } from '@voxgig/sdkgen'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const Entity = cmp(function Entity(props: any) {
|
|
6
|
-
const { build, entity } = props
|
|
7
|
-
const { model } = props.ctx$
|
|
8
|
-
|
|
9
|
-
entity.name = entity.Name.toLowerCase()
|
|
10
|
-
|
|
11
|
-
Folder({ name: 'src' }, () => {
|
|
12
|
-
|
|
13
|
-
File({ name: entity.Name + '.' + build.name }, () => {
|
|
14
|
-
|
|
15
|
-
Content(`<?php
|
|
16
|
-
// ${model.Name} ${build.Name} ${entity.Name}
|
|
17
|
-
|
|
18
|
-
class ${entity.Name} {
|
|
19
|
-
private $sdk;
|
|
20
|
-
private $data = [];
|
|
21
|
-
|
|
22
|
-
public function __construct($sdk, $data = []) {
|
|
23
|
-
$this->sdk = $sdk;
|
|
24
|
-
$this->data = $data;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
private function handleResult($op, $response, $handler) {
|
|
28
|
-
$statusContent = $response['status'];
|
|
29
|
-
|
|
30
|
-
if ($statusContent == 200) {
|
|
31
|
-
$json = $response['json'];
|
|
32
|
-
return $handler($json);
|
|
33
|
-
} else {
|
|
34
|
-
throw new Exception('HTTP-ERROR: ' . $op . ': ${entity.name}: ' . $statusContent);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public function save($data) {
|
|
39
|
-
$op = 'save';
|
|
40
|
-
$this->data = $data;
|
|
41
|
-
|
|
42
|
-
$spec = $this->sdk->fetchSpec($op, $this->data, $this->def);
|
|
43
|
-
$response = $this->sdk->fetch($spec['url'], $spec);
|
|
44
|
-
|
|
45
|
-
return $this->handleResult($op, $response, function($json) {
|
|
46
|
-
$this->data = $json['ent'];
|
|
47
|
-
return $this;
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
public function load($data) {
|
|
52
|
-
$op = 'load';
|
|
53
|
-
$this->data = $data;
|
|
54
|
-
|
|
55
|
-
$spec = $this->sdk->fetchSpec($op, $this->data, $this->def);
|
|
56
|
-
$response = $this->sdk->fetch($spec['url'], $spec);
|
|
57
|
-
|
|
58
|
-
return $this->handleResult($op, $response, function($json) {
|
|
59
|
-
$this->data = $json;
|
|
60
|
-
return $this;
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public function list($data = []) {
|
|
65
|
-
$op = 'list';
|
|
66
|
-
$this->data = $data;
|
|
67
|
-
|
|
68
|
-
$spec = $this->sdk->fetchSpec($op, $this->data, $this->def);
|
|
69
|
-
$response = $this->sdk->fetch($spec['url'], $spec);
|
|
70
|
-
|
|
71
|
-
return $this->handleResult($op, $response, function($json) {
|
|
72
|
-
$this->data = $json;
|
|
73
|
-
return $this;
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
public function remove($data) {
|
|
78
|
-
$op = 'remove';
|
|
79
|
-
$this->data = $data;
|
|
80
|
-
|
|
81
|
-
$spec = $this->sdk->fetchSpec($op, $this->data, $this->def);
|
|
82
|
-
$response = $this->sdk->fetch($spec['url'], $spec);
|
|
83
|
-
|
|
84
|
-
return $this->handleResult($op, $response, function($json) {
|
|
85
|
-
$this->data = $json;
|
|
86
|
-
return $this;
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
`)
|
|
91
|
-
})
|
|
92
|
-
})
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
export {
|
|
96
|
-
Entity
|
|
97
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { cmp, File, Content, Folder } from '@voxgig/sdkgen'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const MainEntity = cmp(function MainEntity(props: any) {
|
|
6
|
-
const { build, entity, model } = props
|
|
7
|
-
|
|
8
|
-
Folder({ name: 'src' }, () => {
|
|
9
|
-
|
|
10
|
-
File({ name: entity.Name + 'Main.' + build.name }, () => {
|
|
11
|
-
|
|
12
|
-
Content(`<?php
|
|
13
|
-
// ${model.Name} ${build.Name} ${entity.Name} Main
|
|
14
|
-
|
|
15
|
-
require_once __DIR__ . '../../sdk/php/src/${model.Name}SDK.php';
|
|
16
|
-
require_once __DIR__ . '../../sdk/php/src/${entity.Name}.php';
|
|
17
|
-
|
|
18
|
-
use ${model.Name}SDK\\${model.Name}SDK;
|
|
19
|
-
use ${model.Name}SDK\\${entity.Name};
|
|
20
|
-
|
|
21
|
-
// Initialize the SDK
|
|
22
|
-
\$options = [
|
|
23
|
-
'apikey' => 'your_api_key',
|
|
24
|
-
'endpoint' => 'https://api.${model.name}.com'
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
\$sdk = new ${model.Name}SDK(\$options);
|
|
28
|
-
|
|
29
|
-
// Example usage
|
|
30
|
-
\$${entity.Name.toLowerCase()} = new ${entity.Name}(\$sdk);
|
|
31
|
-
\$${entity.Name.toLowerCase()}->save(['name' => 'New ${entity.Name}']);
|
|
32
|
-
\$${entity.Name.toLowerCase()}->load(['id' => '123']);
|
|
33
|
-
\$${entity.Name.toLowerCase()}->list();
|
|
34
|
-
\$${entity.Name.toLowerCase()}->remove(['id' => '123']);
|
|
35
|
-
|
|
36
|
-
?>`)
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
export {
|
|
42
|
-
MainEntity
|
|
43
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { cmp, File, Content, Folder } from '@voxgig/sdkgen'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const Main = cmp(function Main(props: any) {
|
|
6
|
-
const { build, model } = props
|
|
7
|
-
|
|
8
|
-
Folder({ name: 'src' }, () => {
|
|
9
|
-
|
|
10
|
-
File({ name: 'Main.' + build.name }, () => {
|
|
11
|
-
|
|
12
|
-
Content(`<?php
|
|
13
|
-
// ${model.Name} Main
|
|
14
|
-
|
|
15
|
-
require_once __DIR__ . '../../sdk/php/src/${model.Name}SDK.php';
|
|
16
|
-
require_once __DIR__ . '../../sdk/php/src/Asset.php';
|
|
17
|
-
require_once __DIR__ . '../../sdk/php/src/Geofence.php';
|
|
18
|
-
require_once __DIR__ . '../../sdk/php/src/Room.php';
|
|
19
|
-
|
|
20
|
-
use ${model.Name}SDK\\${model.Name}SDK;
|
|
21
|
-
use ${model.Name}SDK\\Asset;
|
|
22
|
-
use ${model.Name}SDK\\Geofence;
|
|
23
|
-
use ${model.Name}SDK\\Room;
|
|
24
|
-
|
|
25
|
-
// Initialize the SDK
|
|
26
|
-
\$options = [
|
|
27
|
-
'apikey' => 'your_api_key',
|
|
28
|
-
'endpoint' => 'https://api.${model.name}.com'
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
\$sdk = new ${model.Name}SDK(\$options);
|
|
32
|
-
|
|
33
|
-
// Example usage
|
|
34
|
-
\$asset = new Asset(\$sdk);
|
|
35
|
-
\$asset->save(['name' => 'New Asset']);
|
|
36
|
-
|
|
37
|
-
\$geofence = new Geofence(\$sdk);
|
|
38
|
-
\$geofence->save(['name' => 'New Geofence']);
|
|
39
|
-
|
|
40
|
-
\$room = new Room(\$sdk);
|
|
41
|
-
\$room->save(['name' => 'New Room']);
|
|
42
|
-
|
|
43
|
-
?>`)
|
|
44
|
-
})
|
|
45
|
-
})
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
export {
|
|
49
|
-
Main
|
|
50
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { cmp, File, Content, Folder } from '@voxgig/sdkgen'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const Quick = cmp(function Quick(props: any) {
|
|
6
|
-
const { build, ctx$: { model } } = props
|
|
7
|
-
|
|
8
|
-
Folder({ name: 'src' }, () => {
|
|
9
|
-
|
|
10
|
-
File({ name: 'QuickStart.' + build.name }, () => {
|
|
11
|
-
|
|
12
|
-
Content(`<?php
|
|
13
|
-
// ${model.Name} QuickStart
|
|
14
|
-
|
|
15
|
-
require_once __DIR__ . '../../sdk/php/src/${model.Name}SDK.php';
|
|
16
|
-
require_once __DIR__ . '../../sdk/php/src/Asset.php';
|
|
17
|
-
require_once __DIR__ . '../../sdk/php/src/Geofence.php';
|
|
18
|
-
require_once __DIR__ . '../../sdk/php/src/Room.php';
|
|
19
|
-
|
|
20
|
-
use ${model.Name}SDK\\${model.Name}SDK;
|
|
21
|
-
use ${model.Name}SDK\\Asset;
|
|
22
|
-
use ${model.Name}SDK\\Geofence;
|
|
23
|
-
use ${model.Name}SDK\\Room;
|
|
24
|
-
|
|
25
|
-
// Initialize the SDK
|
|
26
|
-
\$options = [
|
|
27
|
-
'apikey' => 'your_api_key',
|
|
28
|
-
'endpoint' => 'https://api.${model.name}.com'
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
\$sdk = new ${model.Name}SDK(\$options);
|
|
32
|
-
|
|
33
|
-
// Quick example usage
|
|
34
|
-
\$asset = new Asset(\$sdk);
|
|
35
|
-
\$asset->save(['name' => 'New Asset']);
|
|
36
|
-
\$asset->load(['id' => '123']);
|
|
37
|
-
\$asset->list();
|
|
38
|
-
\$asset->remove(['id' => '123']);
|
|
39
|
-
|
|
40
|
-
\$geofence = new Geofence(\$sdk);
|
|
41
|
-
\$geofence->save(['name' => 'New Geofence']);
|
|
42
|
-
\$geofence->load(['id' => '456']);
|
|
43
|
-
\$geofence->list();
|
|
44
|
-
\$geofence->remove(['id' => '456']);
|
|
45
|
-
|
|
46
|
-
\$room = new Room(\$sdk);
|
|
47
|
-
\$room->save(['name' => 'New Room']);
|
|
48
|
-
\$room->load(['id' => '789']);
|
|
49
|
-
\$room->list();
|
|
50
|
-
\$room->remove(['id' => '789']);
|
|
51
|
-
|
|
52
|
-
?>`)
|
|
53
|
-
})
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
export {
|
|
58
|
-
Quick
|
|
59
|
-
}
|