@voxgig/create-sdkgen 0.0.5 → 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.
Files changed (104) hide show
  1. package/bin/voxgig-create-sdkgen +196 -0
  2. package/dist/create-sdkgen.d.ts +8 -8
  3. package/dist/create-sdkgen.js +60 -70
  4. package/dist/create-sdkgen.js.map +1 -1
  5. package/dist/standard/ModelSdk.js +7 -67
  6. package/dist/standard/ModelSdk.js.map +1 -1
  7. package/dist/standard/Root.js +54 -19
  8. package/dist/standard/Root.js.map +1 -1
  9. package/dist/tsconfig.tsbuildinfo +1 -1
  10. package/package.json +13 -10
  11. package/src/create-sdkgen.ts +50 -85
  12. package/src/standard/ModelSdk.ts +8 -85
  13. package/src/standard/Root.ts +22 -25
  14. package/bin/run-create-sdkgen.js +0 -330
  15. package/bin/run-create-sdkgen.js~ +0 -1
  16. package/src/utility.ts +0 -8
  17. package/tm/standard/.env.local +0 -2
  18. package/tm/standard/build/doc.js +0 -23
  19. package/tm/standard/build/sdk.js +0 -22
  20. package/tm/standard/def/DEFINITION.md +0 -4
  21. package/tm/standard/model/.model-config/model-config.jsonic +0 -15
  22. package/tm/standard/model/go.jsonic +0 -6
  23. package/tm/standard/model/js.jsonic +0 -6
  24. package/tm/standard/model/php.jsonic +0 -6
  25. package/tm/standard/model/py.jsonic +0 -7
  26. package/tm/standard/model/rb.jsonic +0 -6
  27. package/tm/standard/package.json +0 -31
  28. package/tm/standard/src/DocStaticRoot.ts +0 -32
  29. package/tm/standard/src/Root.ts +0 -62
  30. package/tm/standard/src/go/Entity_go.ts +0 -226
  31. package/tm/standard/src/go/MainEntity_go.ts +0 -26
  32. package/tm/standard/src/go/Main_go.ts +0 -168
  33. package/tm/standard/src/go/Quick_go.ts +0 -108
  34. package/tm/standard/src/go/ReadmeInstall_go.ts +0 -19
  35. package/tm/standard/src/go/ReadmeQuick_go.ts +0 -45
  36. package/tm/standard/src/go/TestAcceptEntity_go.ts +0 -219
  37. package/tm/standard/src/go/TestAccept_go.ts +0 -38
  38. package/tm/standard/src/go/TestEntity_go.ts +0 -79
  39. package/tm/standard/src/go/TestMain_go.ts +0 -61
  40. package/tm/standard/src/go/Test_go.ts +0 -20
  41. package/tm/standard/src/js/Entity_js.ts +0 -196
  42. package/tm/standard/src/js/MainEntity_js.ts +0 -22
  43. package/tm/standard/src/js/Main_js.ts +0 -154
  44. package/tm/standard/src/js/Quick_js.ts +0 -81
  45. package/tm/standard/src/js/ReadmeInstall_js.ts +0 -19
  46. package/tm/standard/src/js/ReadmeQuick_js.ts +0 -27
  47. package/tm/standard/src/js/TestAcceptEntity_js.ts +0 -101
  48. package/tm/standard/src/js/TestAccept_js.ts +0 -60
  49. package/tm/standard/src/js/TestEntity_js.ts +0 -24
  50. package/tm/standard/src/js/TestMain_js.ts +0 -123
  51. package/tm/standard/src/js/Test_js.ts +0 -24
  52. package/tm/standard/src/php/Entity_php.ts +0 -97
  53. package/tm/standard/src/php/MainEntity_php.ts +0 -43
  54. package/tm/standard/src/php/Main_php.ts +0 -50
  55. package/tm/standard/src/php/Quick_php.ts +0 -59
  56. package/tm/standard/src/php/TestAcceptEntity_php.ts +0 -81
  57. package/tm/standard/src/php/TestAccept_php.ts +0 -33
  58. package/tm/standard/src/php/TestEntity_php.ts +0 -64
  59. package/tm/standard/src/php/TestMain_php.ts +0 -120
  60. package/tm/standard/src/php/Test_php.ts +0 -21
  61. package/tm/standard/src/py/Entity_py.ts +0 -98
  62. package/tm/standard/src/py/MainEntity_py.ts +0 -19
  63. package/tm/standard/src/py/Main_py.ts +0 -211
  64. package/tm/standard/src/py/Quick_py.ts +0 -133
  65. package/tm/standard/src/py/TestAcceptEntity_py.ts +0 -47
  66. package/tm/standard/src/py/TestAccept_py.ts +0 -77
  67. package/tm/standard/src/py/TestEntity_py.ts +0 -50
  68. package/tm/standard/src/py/TestMain_py.ts +0 -103
  69. package/tm/standard/src/py/Test_py.ts +0 -28
  70. package/tm/standard/src/rb/Client_rb.ts +0 -142
  71. package/tm/standard/src/rb/Entity_rb.ts +0 -153
  72. package/tm/standard/src/rb/Error_rb.ts +0 -56
  73. package/tm/standard/src/rb/MainEntity_rb.ts +0 -16
  74. package/tm/standard/src/rb/Main_rb.ts +0 -55
  75. package/tm/standard/src/rb/Quick_rb.ts +0 -65
  76. package/tm/standard/src/rb/ReadmeInstall_rb.ts +0 -19
  77. package/tm/standard/src/rb/ReadmeQuick_rb.ts +0 -30
  78. package/tm/standard/src/rb/TestAcceptEntity_rb.ts +0 -83
  79. package/tm/standard/src/rb/TestAccept_rb.ts +0 -45
  80. package/tm/standard/src/rb/TestEntity_rb.ts +0 -82
  81. package/tm/standard/src/rb/TestMain_rb.ts +0 -67
  82. package/tm/standard/src/rb/Test_rb.ts +0 -27
  83. package/tm/standard/src/tsconfig.json +0 -15
  84. package/tm/standard/tm/go/.env.example +0 -2
  85. package/tm/standard/tm/go/LICENSE +0 -22
  86. package/tm/standard/tm/go/go.mod +0 -5
  87. package/tm/standard/tm/go/go.sum +0 -2
  88. package/tm/standard/tm/js/LICENSE +0 -22
  89. package/tm/standard/tm/js/package.json +0 -17
  90. package/tm/standard/tm/php/LICENSE +0 -22
  91. package/tm/standard/tm/py/LICENSE +0 -22
  92. package/tm/standard/tm/py/MANIFEST.in +0 -4
  93. package/tm/standard/tm/py/Makefile +0 -14
  94. package/tm/standard/tm/py/pyproject.toml +0 -4
  95. package/tm/standard/tm/py/pytest.ini +0 -3
  96. package/tm/standard/tm/py/requirements.txt +0 -4
  97. package/tm/standard/tm/py/setup.cfg +0 -2
  98. package/tm/standard/tm/py/setup.py +0 -82
  99. package/tm/standard/tm/rb/.rspec +0 -1
  100. package/tm/standard/tm/rb/Gemfile +0 -21
  101. package/tm/standard/tm/rb/LICENSE +0 -22
  102. package/tm/standard/tm/rb/Rakefile +0 -6
  103. package/tm/standard/tm/rb/spec/spec_helper.rb +0 -22
  104. package/tm/standard/tm/rb/tm.gemspec +0 -39
@@ -1,196 +0,0 @@
1
-
2
- // Entity 1
3
-
4
- import { cmp, each, File, Content, Folder } from '@voxgig/sdkgen'
5
-
6
-
7
- const Entity = cmp(function Entity(props: any) {
8
- const { build, entity } = props
9
- const { model } = props.ctx$
10
-
11
-
12
- Folder({ name: 'src' }, () => {
13
-
14
- File({ name: entity.Name + '.' + build.name }, () => {
15
-
16
- const modifyRequest = each(model.main.sdk.feature).map((feature: any) => {
17
- if(feature.name == 'ratelimiter') {
18
- return `
19
- await this.sdk().features.${feature.name}.tryAcquire()`
20
-
21
- }
22
- return `
23
- spec = this.sdk().features.${feature.name}.modifyRequest(ctx)
24
- `
25
- }).join('')
26
-
27
- const modifyResult = each(model.main.sdk.feature).map((feature: any) => {
28
- if(feature.name == 'ratelimiter') {
29
- return ''
30
- }
31
- return `
32
- ctx.result = this.sdk().features.${feature.name}.modifyResult(ctx)
33
- `
34
- }).join('')
35
-
36
- Content(`
37
- // ${model.Name} ${build.Name} ${entity.Name} 1
38
-
39
- class ${entity.Name} {
40
- def
41
- sdk
42
- data
43
- query
44
-
45
- constructor(sdk,data) {
46
- this.sdk = ()=>sdk
47
- this.def = {
48
- name: '${entity.name}'
49
- }
50
- // data is optional
51
- this.data = data
52
- }
53
-
54
-
55
- async handleResult(ctx, res, spec, handler) {
56
- const status = res.status
57
-
58
- if(200 === status) {
59
- ctx.result = await res.json()
60
- // TODO: error
61
-
62
- ${modifyResult}
63
- return handler(ctx.result)
64
- }
65
- else {
66
- throw new Error('HTTP-ERROR: '+ctx.op+': ${entity.name}: '+status)
67
- }
68
- }
69
- `)
70
-
71
- Content(`
72
- async save(data) {
73
- const ctx = {op:'save',entity:this}
74
- this.data = data
75
- this.query = {}
76
- // TODO: validate data
77
-
78
- let spec = ctx.spec = this.sdk().fetchSpec(ctx,this)
79
- ${modifyRequest}
80
- const res = await this.sdk().options.fetch(spec.url,spec)
81
-
82
- return this.handleResult(ctx, res, spec, (json)=>{
83
- this.data = json
84
- return this
85
- })
86
- }
87
-
88
- `)
89
-
90
- Content(`
91
- async create(data) {
92
- const ctx = {op:'create',entity:this}
93
- this.data = data
94
- this.query = {}
95
- // TODO: validate data
96
-
97
- let spec = ctx.spec = this.sdk().fetchSpec(ctx,this)
98
- ${modifyRequest}
99
-
100
- if(this.sdk().options.debug) {
101
- console.log('FETCH-create', spec)
102
- }
103
-
104
- const res = await this.sdk().options.fetch(spec.url,spec)
105
-
106
- return this.handleResult(ctx, res, spec, (json)=>{
107
- this.data = json
108
- return this
109
- })
110
- }
111
-
112
-
113
- `)
114
-
115
- Content(`
116
- async load(query) {
117
- const ctx = {op:'load',entity:this}
118
- this.data = {}
119
- this.query = query || {}
120
-
121
- let spec = ctx.spec = this.sdk().fetchSpec(ctx,this)
122
- ${modifyRequest}
123
-
124
- if(this.sdk().options.debug) {
125
- console.log('FETCH-load', spec)
126
- }
127
-
128
- const res = await this.sdk().options.fetch(spec.url,spec)
129
-
130
- return this.handleResult(ctx, res, spec, (json)=>{
131
- this.data = json
132
- return this
133
- })
134
- }
135
-
136
-
137
- `)
138
-
139
- Content(`
140
- async remove(query) {
141
- const ctx = {op:'remove',entity:this}
142
- this.data = {}
143
- this.query = query || {}
144
-
145
- let spec = ctx.spec = this.sdk().fetchSpec(ctx,this)
146
- ${modifyRequest}
147
- const res = await this.sdk().options.fetch(spec.url,spec)
148
-
149
- return this.handleResult(ctx, res, spec, (json)=>{
150
- this.data = json
151
- return null
152
- })
153
- }
154
-
155
- `)
156
-
157
- Content(`
158
- async list(query) {
159
- const ctx = {op:'list',entity:this}
160
- this.data = {}
161
- this.query = query || {}
162
-
163
- let spec = ctx.spec = this.sdk().fetchSpec(ctx,this)
164
- ${modifyRequest}
165
-
166
- if(this.sdk().options.debug) {
167
- console.log('FETCH-load', spec)
168
- }
169
-
170
- const res = await this.sdk().options.fetch(spec.url,spec)
171
-
172
- return this.handleResult(ctx, res, spec, (json)=>{
173
- return json.list.map(data=>this.sdk().${entity.Name}(data))
174
- })
175
- }
176
-
177
- `)
178
-
179
- Content(`
180
-
181
- }
182
-
183
-
184
- module.exports = {
185
- ${entity.Name}
186
- }
187
-
188
- `)
189
- })
190
- })
191
- })
192
-
193
-
194
- export {
195
- Entity
196
- }
@@ -1,22 +0,0 @@
1
-
2
-
3
- import { cmp, each, File, Content } from '@voxgig/sdkgen'
4
-
5
-
6
- const MainEntity = cmp(async function MainEntity(props: any) {
7
- const { entity } = props
8
-
9
- Content(`
10
- ${entity.Name}(data) {
11
- const self = this
12
- return new ${entity.Name}(self,data)
13
- }
14
-
15
- `)
16
-
17
- })
18
-
19
-
20
- export {
21
- MainEntity
22
- }
@@ -1,154 +0,0 @@
1
-
2
-
3
- import { cmp, each, names, File, Content, Copy, Folder } from '@voxgig/sdkgen'
4
-
5
-
6
- import { MainEntity } from './MainEntity_js'
7
- import { Test } from './Test_js'
8
-
9
-
10
- const Main = cmp(async function Main(props: any) {
11
- const { build } = props
12
- const { model } = props.ctx$
13
-
14
- const { entity, feature } = model.main.sdk
15
-
16
- Copy({ from: 'tm/' + build.name + '/package.json', name: 'package.json' })
17
-
18
- Test({ build })
19
-
20
- Folder({ name: 'src' }, () => {
21
-
22
- File({ name: model.Name + 'SDK.' + build.name }, () => {
23
-
24
- Content(`
25
- // ${model.Name} ${build.Name} SDK
26
- `)
27
-
28
- each(feature, (feature: any) => {
29
- names(feature, feature.name)
30
- Content(`
31
- const { ${feature.Name + 'Feature'} } = require('./${feature.name}/${feature.Name}Feature')
32
- `)
33
- })
34
-
35
-
36
- each(entity, (entity: any) => {
37
- names(entity, entity.name)
38
- Content(`
39
- const { ${entity.Name} } = require('./${entity.Name}')
40
- `)
41
- })
42
-
43
-
44
- const validate_options = each(build.options)
45
- .reduce((a: string, opt: any) =>
46
- a + ('String' === opt.kind ?
47
- ` required('string','${opt.name}',options)\n` : ''), '')
48
-
49
- const features = each(feature).map((feature: any) => `
50
- ${feature.name}: new ${feature.Name}Feature(this, ${JSON.stringify(feature.config || {})})
51
- `).join(',\n')
52
-
53
-
54
- Content(`
55
-
56
- class ${model.Name}SDK {
57
- options
58
- features
59
-
60
- static make(options) {
61
- return new ${model.Name}SDK(options)
62
- }
63
-
64
-
65
- constructor(options) {
66
- this.options = options
67
-
68
- ${validate_options}
69
-
70
- this.options.fetch = this.options.fetch || fetch
71
-
72
- this.features = {
73
- ${features}
74
- }
75
- }
76
-
77
-
78
- endpoint(op,ent) {
79
- let data = ent.data || {}
80
- let def = ent.def
81
- // Make this code depend on openapi spec
82
- return this.options.endpoint + '/' + def.name + ((op === 'load' || op === 'remove') && data.id ? '/' + data.id : '')
83
- }
84
-
85
- method(op,ent) {
86
- let key = (null == ent || null === ent.id) && 'save' === op ? 'create' : op
87
- return ({
88
- create: 'POST',
89
- save: 'PUT',
90
- load: 'GET',
91
- list: 'GET',
92
- remove: 'DELETE',
93
- })[op]
94
- }
95
-
96
- body(op,ent) {
97
- const msg = { ...ent.data }
98
- return JSON.stringify(msg)
99
- }
100
-
101
- fetchSpec(ctx) {
102
- const { op } = ctx
103
- const method = this.method(op, ctx.entity)
104
-
105
- let qpairs = Object.entries(ctx.entity.query)
106
- .filter(entry=>!entry[0].includes('$'))
107
- .reduce((qp,entry)=>
108
- (qp.push(encodeURIComponent(entry[0])+'='+encodeURIComponent(entry[1])),qp),[])
109
-
110
- let query = 0===qpairs.length?'':'?'+(qpairs.join('&'))
111
-
112
- const spec = {
113
- url: this.endpoint(op, ctx.entity)+query,
114
- method,
115
- headers: {
116
- 'content-type': 'application/json',
117
- 'authorization': 'Bearer '+this.options.apikey
118
- },
119
- body: 'GET' === method || 'DELETE' === method ? undefined : this.body(op, ctx.entity),
120
- }
121
- return spec
122
- }
123
-
124
- `)
125
-
126
- each(entity, (entity: any) => {
127
- MainEntity({ model, build, entity })
128
- })
129
-
130
- Content(`
131
- }
132
-
133
-
134
- function required(type,name,options) {
135
- const val = options[name]
136
- if(type !== typeof val) {
137
- throw new Error('${model.Name}SDK: Invalid option: '+name+'='+val+': must be of type '+type)
138
- }
139
- }
140
-
141
- module.exports = {
142
- ${model.Name}SDK
143
- }
144
-
145
- `)
146
-
147
- })
148
- })
149
- })
150
-
151
-
152
- export {
153
- Main
154
- }
@@ -1,81 +0,0 @@
1
-
2
- import { names, getx, each, 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
-
12
- let entmap = getx(spec.config.guideModel, 'guide entity?test:quick:active=true')
13
- let ent: any = Object.values(entmap)[0]
14
- ent.name = Object.keys(entmap)[0]
15
-
16
- ent = ent || {}
17
- names(ent, ent.name)// , ent.key$ || 'name')
18
-
19
- // TODO: selected features should be active by default!
20
-
21
- const featureOptions = each(model.main.sdk.feature)
22
- .filter((f: any) => f.active)
23
- .reduce((a: any, f: any) => a + `\n ${f.name}: { active: true },`, '')
24
-
25
- // console.log('QUICK', ent, featureOptions)
26
-
27
-
28
- File({ name: 'quick.' + build.name }, () => {
29
-
30
- Content(`
31
- // ENT 3
32
- require('dotenv').config({ path: ['../../.env.local']})
33
-
34
- const { ${model.Name}SDK } = require('../')
35
-
36
- run()
37
-
38
- async function run() {
39
- const client = ${model.Name}SDK.make({
40
- endpoint: process.env.${model.NAME}_ENDPOINT,
41
- apikey: process.env.${model.NAME}_APIKEY,
42
- ${featureOptions}
43
- })
44
-
45
- let out
46
-
47
- `)
48
-
49
- if (ent.test?.quick.create) {
50
- Content(`
51
- out = await client.${ent.Name}().create(${JSON.stringify(ent.test?.quick.create)})
52
- console.log('${ent.Name}.load', out)
53
- `)
54
- }
55
-
56
- if (ent.test?.quick.load) {
57
- Content(`
58
- out = await client.${ent.Name}().load(${JSON.stringify(ent.test?.quick.load)})
59
- console.log('${ent.Name}.load', out)
60
- `)
61
- }
62
-
63
- if (ent.test?.quick.list) {
64
- Content(`
65
- out = await client.${ent.Name}().list(${JSON.stringify(ent.test?.quick.list)})
66
- console.log('${ent.Name}.list', out)
67
- `)
68
- }
69
-
70
- Content(`
71
- }
72
- `)
73
-
74
- })
75
- })
76
-
77
-
78
- export {
79
- Quick
80
- }
81
-
@@ -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
- }