@voxgig/create-sdkgen 0.0.2 → 0.0.3

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 (89) hide show
  1. package/bin/run-create-sdkgen.js~ +1 -0
  2. package/package.json +3 -1
  3. package/tm/standard/.env.local +2 -0
  4. package/tm/standard/build/sdk.js +25 -0
  5. package/tm/standard/def/DEFINITION.md +2 -0
  6. package/tm/standard/model/.model-config/model-config.jsonic +13 -0
  7. package/tm/standard/model/go.jsonic +6 -0
  8. package/tm/standard/model/js.jsonic +6 -0
  9. package/tm/standard/model/php.jsonic +6 -0
  10. package/tm/standard/model/py.jsonic +7 -0
  11. package/tm/standard/model/rb.jsonic +6 -0
  12. package/tm/standard/model/sdk.jsonic.off +60 -0
  13. package/tm/standard/package.json +30 -0
  14. package/tm/standard/src/Root.ts +60 -0
  15. package/tm/standard/src/go/Entity_go.ts +226 -0
  16. package/tm/standard/src/go/MainEntity_go.ts +26 -0
  17. package/tm/standard/src/go/Main_go.ts +168 -0
  18. package/tm/standard/src/go/Quick_go.ts +108 -0
  19. package/tm/standard/src/go/ReadmeInstall_go.ts +19 -0
  20. package/tm/standard/src/go/ReadmeQuick_go.ts +45 -0
  21. package/tm/standard/src/go/TestAcceptEntity_go.ts +219 -0
  22. package/tm/standard/src/go/TestAccept_go.ts +38 -0
  23. package/tm/standard/src/go/TestEntity_go.ts +79 -0
  24. package/tm/standard/src/go/TestMain_go.ts +61 -0
  25. package/tm/standard/src/go/Test_go.ts +20 -0
  26. package/tm/standard/src/js/Entity_js.ts +135 -0
  27. package/tm/standard/src/js/MainEntity_js.ts +22 -0
  28. package/tm/standard/src/js/Main_js.ts +128 -0
  29. package/tm/standard/src/js/Quick_js.ts +72 -0
  30. package/tm/standard/src/js/ReadmeInstall_js.ts +19 -0
  31. package/tm/standard/src/js/ReadmeQuick_js.ts +27 -0
  32. package/tm/standard/src/js/TestAcceptEntity_js.ts +101 -0
  33. package/tm/standard/src/js/TestAccept_js.ts +60 -0
  34. package/tm/standard/src/js/TestEntity_js.ts +24 -0
  35. package/tm/standard/src/js/TestMain_js.ts +123 -0
  36. package/tm/standard/src/js/Test_js.ts +24 -0
  37. package/tm/standard/src/php/Entity_php.ts +97 -0
  38. package/tm/standard/src/php/MainEntity_php.ts +43 -0
  39. package/tm/standard/src/php/Main_php.ts +50 -0
  40. package/tm/standard/src/php/Quick_php.ts +59 -0
  41. package/tm/standard/src/php/TestAcceptEntity_php.ts +81 -0
  42. package/tm/standard/src/php/TestAccept_php.ts +33 -0
  43. package/tm/standard/src/php/TestEntity_php.ts +64 -0
  44. package/tm/standard/src/php/TestMain_php.ts +120 -0
  45. package/tm/standard/src/php/Test_php.ts +21 -0
  46. package/tm/standard/src/py/Entity_py.ts +98 -0
  47. package/tm/standard/src/py/MainEntity_py.ts +19 -0
  48. package/tm/standard/src/py/Main_py.ts +211 -0
  49. package/tm/standard/src/py/Quick_py.ts +133 -0
  50. package/tm/standard/src/py/TestAcceptEntity_py.ts +47 -0
  51. package/tm/standard/src/py/TestAccept_py.ts +77 -0
  52. package/tm/standard/src/py/TestEntity_py.ts +50 -0
  53. package/tm/standard/src/py/TestMain_py.ts +103 -0
  54. package/tm/standard/src/py/Test_py.ts +28 -0
  55. package/tm/standard/src/rb/Client_rb.ts +142 -0
  56. package/tm/standard/src/rb/Entity_rb.ts +153 -0
  57. package/tm/standard/src/rb/Error_rb.ts +56 -0
  58. package/tm/standard/src/rb/MainEntity_rb.ts +16 -0
  59. package/tm/standard/src/rb/Main_rb.ts +55 -0
  60. package/tm/standard/src/rb/Quick_rb.ts +65 -0
  61. package/tm/standard/src/rb/ReadmeInstall_rb.ts +19 -0
  62. package/tm/standard/src/rb/ReadmeQuick_rb.ts +30 -0
  63. package/tm/standard/src/rb/TestAcceptEntity_rb.ts +83 -0
  64. package/tm/standard/src/rb/TestAccept_rb.ts +45 -0
  65. package/tm/standard/src/rb/TestEntity_rb.ts +82 -0
  66. package/tm/standard/src/rb/TestMain_rb.ts +67 -0
  67. package/tm/standard/src/rb/Test_rb.ts +27 -0
  68. package/tm/standard/src/tsconfig.json +15 -0
  69. package/tm/standard/tm/go/.env.example +2 -0
  70. package/tm/standard/tm/go/LICENSE +22 -0
  71. package/tm/standard/tm/go/go.mod +5 -0
  72. package/tm/standard/tm/go/go.sum +2 -0
  73. package/tm/standard/tm/js/LICENSE +22 -0
  74. package/tm/standard/tm/js/package.json +17 -0
  75. package/tm/standard/tm/php/LICENSE +22 -0
  76. package/tm/standard/tm/py/LICENSE +22 -0
  77. package/tm/standard/tm/py/MANIFEST.in +4 -0
  78. package/tm/standard/tm/py/Makefile +14 -0
  79. package/tm/standard/tm/py/pyproject.toml +4 -0
  80. package/tm/standard/tm/py/pytest.ini +3 -0
  81. package/tm/standard/tm/py/requirements.txt +4 -0
  82. package/tm/standard/tm/py/setup.cfg +2 -0
  83. package/tm/standard/tm/py/setup.py +82 -0
  84. package/tm/standard/tm/rb/.rspec +1 -0
  85. package/tm/standard/tm/rb/Gemfile +21 -0
  86. package/tm/standard/tm/rb/LICENSE +22 -0
  87. package/tm/standard/tm/rb/Rakefile +6 -0
  88. package/tm/standard/tm/rb/spec/spec_helper.rb +22 -0
  89. package/tm/standard/tm/rb/tm.gemspec +39 -0
@@ -0,0 +1,19 @@
1
+ import { cmp, each, File, Content } from '@voxgig/sdkgen'
2
+
3
+
4
+ const MainEntity = cmp(async function MainEntity(props: any) {
5
+ const { entity } = props
6
+
7
+ const def = JSON.stringify(entity)
8
+
9
+ Content(`
10
+ def ${entity.Name}(self):
11
+ return ${entity.Name}(self, json.loads('''${def}'''))
12
+ `)
13
+
14
+ })
15
+
16
+
17
+ export {
18
+ MainEntity
19
+ }
@@ -0,0 +1,211 @@
1
+
2
+
3
+ import { cmp, each, camelify, File, Content, Folder, Copy } from '@voxgig/sdkgen'
4
+
5
+ import { MainEntity } from './MainEntity_py'
6
+ import { Test } from './Test_py'
7
+
8
+
9
+ const config_setup_files = [
10
+ 'setup.py',
11
+ 'pyproject.toml',
12
+ 'requirements.txt',
13
+ 'setup.cfg',
14
+ 'MANIFEST.in',
15
+ 'Makefile',
16
+ 'pytest.ini'
17
+ ]
18
+
19
+ const Main = cmp(async function Main(props: any) {
20
+ const { build, ctx$: { model } } = props
21
+
22
+ const entity = model.main.sdk.entity
23
+
24
+
25
+ Test({ build })
26
+
27
+ for (let config_file of config_setup_files) {
28
+ Copy({ from: 'tm/' + build.name + '/' + config_file, name: config_file })
29
+ }
30
+
31
+ File({ name: '.env.test.local' }, () => {
32
+ Content(`
33
+ ${model.Name}_ENDPOINT=example.com
34
+ ${model.Name}_ENDPOINT_PRISM=http://127.0.0.1:4010/a/b/c
35
+ ${model.Name}_APIKEY=pqapikey
36
+ `)
37
+
38
+ })
39
+
40
+ Folder({ name: 'src/' + model.name + '_sdk' }, () => {
41
+
42
+ File({ name: '__init__.py' }, () => {
43
+ Content(`from .${model.Name}SDK import *
44
+ from .Model import Config
45
+ from .Model import Data
46
+ from .Model import Query
47
+
48
+ `)
49
+
50
+ each(entity, (entity: any) => {
51
+ entity.Name = camelify(entity.name)
52
+ // console.log('entity.Name: ', entity)
53
+ Content(`from .${entity.Name} import ${entity.Name}
54
+ `)
55
+
56
+ })
57
+
58
+ Content(`__doc__ = 'An example SDK'
59
+ `)
60
+
61
+
62
+ })
63
+
64
+ File({ name: 'Model.py' }, () => {
65
+ Content(`
66
+ from typing import Any, Callable
67
+
68
+ from pydantic import BaseModel, Field, ConfigDict, ValidationError
69
+
70
+
71
+ class Config(BaseModel):
72
+ endpoint: str = Field(validate_default=True)
73
+ apikey: str = Field(validate_default=True)
74
+ fetch: Callable = Field(validate_default=True)
75
+
76
+ model_config = ConfigDict(extra='allow')
77
+
78
+ class Data(BaseModel):
79
+ id: str = Field(default=None, validate_default=False)
80
+ model_config = ConfigDict(extra='allow')
81
+
82
+ class Query(BaseModel):
83
+ id: str = Field(default=None, validate_default=False)
84
+ model_config = ConfigDict(extra='allow')
85
+
86
+ `)
87
+
88
+ })
89
+
90
+
91
+ File({ name: model.Name + 'SDK.' + build.extension }, () => {
92
+
93
+ /*
94
+ const validate_options = each(build.options)
95
+ .reduce((a: string, opt: any) =>
96
+ a + ('String' === opt.kind ?
97
+ ` required(str, '${opt.name}', options)\n` : ''), '')
98
+ */
99
+
100
+ const imports = `
101
+ import json
102
+
103
+ `
104
+ Content(`${imports}`)
105
+
106
+ each(entity, (entity: any) => {
107
+ entity.Name = camelify(entity.name)
108
+ Content(`from .${entity.Name} import ${entity.Name}
109
+ `)
110
+ })
111
+
112
+
113
+ /*
114
+ // Replaced by pydantic
115
+ Content(`
116
+ def required(type_class, name, options):
117
+ val = options[name]
118
+ if(type_class != type(val)):
119
+ raise Exception('${model.Name}SDK: Invalid option: '+name+'='+val+': must be of type '+ str(type_class))
120
+
121
+ `)
122
+ */
123
+
124
+ Content(`
125
+
126
+ from pydantic import BaseModel
127
+ # from .Model import Data
128
+
129
+ # ${model.Name} ${build.Name} SDK
130
+
131
+
132
+ class ${model.Name}SDK:
133
+ def __init__(self, options):
134
+ self.options = options
135
+
136
+
137
+ @staticmethod
138
+ def make(options):
139
+ return ${model.Name}SDK(options)
140
+
141
+ def endpoint(self, op, ent):
142
+ data = ent.data
143
+ id = None
144
+ # print("ent.data: ", type(ent.data) == Data, isinstance(ent.data, Data), isinstance(ent.data, BaseModel))
145
+ if dict == type(ent.data):
146
+ id = ent.data.get('id')
147
+ elif isinstance(ent.data, BaseModel):
148
+ id = ent.data.id
149
+
150
+ return (
151
+ self.options.endpoint
152
+ + "/"
153
+ + ent.definition.get("name")
154
+ + ((id and (op == 'load' or op == 'delete') and "/" + id) or "")
155
+ )
156
+
157
+ def method(self, op, ent=None):
158
+ key = op
159
+ if (None == ent or None == ent.id) and "save" == op:
160
+ key = "create"
161
+
162
+ if "create" == key:
163
+ return "POST"
164
+ elif "save" == key:
165
+ return "PUT"
166
+ elif "load" == key or "list" == key:
167
+ return "GET"
168
+ elif "remove" == key:
169
+ return "DELETE"
170
+
171
+ def body(self, op, ent):
172
+ # msg = {}
173
+ # msg.update(ent.data)
174
+ # print('body ent.data: ', ent.data)
175
+
176
+ if dict == type(ent.data):
177
+ # return json.dumps(ent.data)
178
+ return ent.data
179
+ elif isinstance(ent.data, BaseModel):
180
+ return ent.data.model_dump(exclude_none=True)
181
+ # return ent.data.model_dump_json(exclude_none=True)
182
+
183
+
184
+ def fetchSpec(self, op, ent):
185
+ method = self.method(op, ent)
186
+ spec = {
187
+ "url": self.endpoint(op, ent),
188
+ "method": method,
189
+ "headers": {
190
+ "content-type": "application/json",
191
+ "authorization": "Bearer " + self.options.apikey,
192
+ },
193
+ "body": ("GET" == method and {}) or self.body(op, ent),
194
+ }
195
+ return spec
196
+
197
+ `)
198
+
199
+ each(entity, (entity: any) => {
200
+ MainEntity({ model, build, entity })
201
+ })
202
+
203
+
204
+ })
205
+ })
206
+ })
207
+
208
+
209
+ export {
210
+ Main
211
+ }
@@ -0,0 +1,133 @@
1
+
2
+ import { cmp, File, Content } from '@voxgig/sdkgen'
3
+
4
+
5
+ const Quick = cmp(function Quick(props: any) {
6
+ const { build } = props
7
+ const { model } = props.ctx$
8
+
9
+ File({ name: 'quick.' + build.extension }, () => {
10
+
11
+ Content(`
12
+ from pathlib import Path
13
+ import sys
14
+ import json
15
+
16
+ import requests
17
+ from dotenv import dotenv_values
18
+
19
+ path_root = str(Path(__file__).parents[1]) + '/src' + '/${model.name}_sdk'
20
+ print('path_root: ', path_root)
21
+ sys.path.append(path_root)
22
+
23
+ import ${model.name}_sdk
24
+ import ${model.name}_sdk.Model as Model
25
+ from ${model.name}_sdk.Model import Data
26
+ from ${model.name}_sdk.Model import Query
27
+
28
+ # from Fetch import fetch
29
+
30
+ config = dotenv_values("../.env.test.local")
31
+
32
+
33
+ print("config: ", config, Model)
34
+
35
+
36
+ print(${model.name}_sdk.${model.Name}SDK)
37
+ print(dir(${model.name}_sdk))
38
+
39
+ def fetch(url, config):
40
+
41
+ method = config.get('method') or 'GET'
42
+ headers = config.get('headers') or {}
43
+ body = config.get('body') or {}
44
+
45
+ res = None
46
+
47
+ if method == 'GET':
48
+ res = requests.get(url, headers=headers)
49
+
50
+ elif method == 'POST':
51
+ res = requests.post(url, headers=headers, json=body)
52
+ elif method == 'PUT':
53
+ res = requests.put(url, headers=headers, json=body)
54
+
55
+
56
+ if res.status_code >= 200 and res.status_code < 300:
57
+ return { "status": res.status_code, "json": res.json(), "res": res }
58
+
59
+ return { "status": res.status_code }
60
+
61
+
62
+ if __name__ == "__main__":
63
+ client = ${model.name}_sdk.${model.Name}SDK.make(Model.Config(
64
+ endpoint=config.get('${model.NAME}_ENDPOINT_PRISM'),
65
+ apikey=config.get('${model.NAME}_APIKEY'),
66
+ fetch=fetch
67
+ ))
68
+
69
+ # load
70
+ out = client.Geofence().load({"id": "CF49B47C-317B-4387-83C3-4A23715B1C45"})
71
+ print("Geofence.load", out)
72
+
73
+ # or
74
+ out = client.Geofence().load(Query(id="CF49B47C-317B-4387-83C3-4A23715B1C45"))
75
+ print("Geofence.load", out)
76
+
77
+ # list
78
+ out = client.Geofence().list()
79
+ print("Geofence.list: ", out)
80
+
81
+ # create
82
+ out = client.Geofence().create(Data(
83
+ id='CF49B47C-317B-4387-83C3-4A23715B1C45',
84
+ name='Geofence 1',
85
+ desc='Geofence 1 description',
86
+ custom={ 'foo': 'bar' },
87
+ extent_id='CF49B47C-317B-4387-83C3-4A23715B1C45'
88
+ ))
89
+
90
+ print('Geofence.create: ', out)
91
+
92
+ # save
93
+ out = client.Geofence().save(Data(
94
+ id='CF49B47C-317B-4387-83C3-4A23715B1C45',
95
+ name='Geofence 1',
96
+ desc='Geofence 1 description',
97
+ custom={ 'foo': 'bar' },
98
+ extent_id='CF49B47C-317B-4387-83C3-4A23715B1C45'
99
+ ))
100
+
101
+ print('Geofence.save: ', out)
102
+
103
+ '''
104
+ # create
105
+ out = client.Geofence().create(Data(
106
+ title="T04",
107
+ area=0,
108
+ ))
109
+ print("Geofence.create: ", out)
110
+
111
+ # or
112
+ out = client.Geofence().create({
113
+ "title": "T05",
114
+ "area": 0
115
+ })
116
+ print("Geofence.create: ", out)
117
+ '''
118
+
119
+ # remove
120
+ out = client.Geofence().remove({"id": "CF49B47C-317B-4387-83C3-4A23715B1C45"})
121
+ print("Geofence.remove: ", out)
122
+
123
+
124
+
125
+ `)
126
+
127
+ })
128
+ })
129
+
130
+
131
+ export {
132
+ Quick
133
+ }
@@ -0,0 +1,47 @@
1
+ import { cmp, camelify, Content } from '@voxgig/sdkgen'
2
+
3
+
4
+ const TestAcceptEntity = cmp(function TestAcceptEntity(props: any) {
5
+ const { entity } = props
6
+
7
+ entity.Name = camelify(entity.name)
8
+
9
+ Content(`
10
+ def test_${entity.name}_load():
11
+ config = dotenv_values('.env.test.local')
12
+ client = makeClient(config)
13
+ out = client.${entity.Name}().load({"id" :'t01'})
14
+
15
+ expectedFormat = {
16
+ 'id': str,
17
+ 'name': str,
18
+ 'desc': str,
19
+ 'custom': dict,
20
+ }
21
+
22
+ print('load', out)
23
+
24
+ for key in expectedFormat:
25
+ assert expectedFormat[key] == type(out[key])
26
+
27
+
28
+ `);
29
+
30
+ Content(`
31
+ def test_${entity.name}_list():
32
+ config = dotenv_values('.env.test.local')
33
+ client = makeClient(config)
34
+ out = client.${entity.Name}().list()
35
+
36
+ print('list', out)
37
+ assert out['name'] == '${entity.name}' and len(out['list']) > 0
38
+
39
+ `);
40
+
41
+
42
+ })
43
+
44
+
45
+ export {
46
+ TestAcceptEntity
47
+ }
@@ -0,0 +1,77 @@
1
+ import { cmp, each, File, Content } from '@voxgig/sdkgen'
2
+
3
+
4
+ import { TestAcceptEntity } from './TestAcceptEntity_py'
5
+
6
+
7
+ const TestAccept = cmp(function TestAccept(props: any) {
8
+ const { build } = props
9
+ const { model } = props.ctx$
10
+
11
+
12
+ File({ name: 'test_accept_' + model.Name + '.' + build.extension }, () => {
13
+
14
+ Content(`
15
+ from pathlib import Path
16
+ import sys
17
+ path_root = str(Path(__file__).parents[1])
18
+ sys.path.append(path_root)
19
+
20
+ import json
21
+
22
+ import requests
23
+ from dotenv import dotenv_values
24
+
25
+ import ${model.name}_sdk
26
+
27
+ from ${model.name}_sdk import Config
28
+
29
+ # from Fetch import fetch
30
+
31
+ def fetch(url, config):
32
+
33
+ method = config.get('method') or 'GET'
34
+ headers = config.get('headers') or {}
35
+ body = config.get('body') or {}
36
+
37
+ res = None
38
+
39
+ if method == 'GET':
40
+ res = requests.get(url, headers=headers)
41
+ elif method == 'POST':
42
+ res = requests.post(url, headers=headers, json=body)
43
+ elif method == 'PUT':
44
+ res = requests.put(url, headers=headers, json=body)
45
+
46
+
47
+ if res.status_code >= 200 and res.status_code < 300:
48
+ return { "status": res.status_code, "json": res.json(), "res": res }
49
+
50
+ return { "status": res.status_code }
51
+
52
+ def makeClient(config = {}):
53
+ client = ${model.name}_sdk.${model.Name}SDK.make(Config(
54
+ endpoint=config.get('${model.NAME}_ENDPOINT_PRISM'),
55
+ apikey=config.get('${model.NAME}_APIKEY') or 'abc123',
56
+ fetch=fetch
57
+ ))
58
+ return client
59
+
60
+
61
+ def test_happy():
62
+ config = dotenv_values('.env.test.local')
63
+ client = makeClient(config)
64
+ `)
65
+
66
+ each(model.main.sdk.entity, (entity: any) => {
67
+ TestAcceptEntity({ model, build, entity })
68
+ })
69
+
70
+ })
71
+ })
72
+
73
+
74
+ export {
75
+ TestAccept
76
+ }
77
+
@@ -0,0 +1,50 @@
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
+ // console.log(entity.op)
11
+
12
+ // TODO: refactor via loop
13
+ for (let key in entity.op) {
14
+ // console.log(key)
15
+ }
16
+
17
+ Content(`
18
+ def test_${entity.name}():
19
+ config = dotenv_values('.env.test.local')
20
+ client = makeClient(config)
21
+
22
+ # create
23
+ out = client.${entity.Name}().create({ 'title': 'T03' })
24
+ print('create', out)
25
+ assert out == {'id': 'n03', 'title': 'T03'}
26
+
27
+ # save
28
+ out = client.${entity.Name}().save({ 'id': 'n03', 'title': 'T03_3'})
29
+ print('save', out)
30
+ assert out == { 'id': 'n03', 'title': 'T03_3' }
31
+
32
+ # load
33
+ out = client.${entity.Name}().load({ 'id': 't01' })
34
+ print('load', out)
35
+ assert out == {'id': 't01', 'title': 'T01'}
36
+
37
+ # list
38
+ out = client.${entity.Name}().list()
39
+ assert out['list'] != None and len(out['list']) != 0
40
+ assert out['name'] == "${entity.name}"
41
+ print('list', out)
42
+ # raise Exception('4')
43
+
44
+ `)
45
+ })
46
+
47
+
48
+ export {
49
+ TestEntity
50
+ }
@@ -0,0 +1,103 @@
1
+
2
+ import { cmp, each, File, Content } from '@voxgig/sdkgen'
3
+
4
+
5
+ import { TestEntity } from './TestEntity_py'
6
+
7
+
8
+ const TestMain = cmp(function TestMain(props: any) {
9
+ const { build } = props
10
+ const { model } = props.ctx$
11
+
12
+ File({ name: 'Fetch.' + build.extension }, () => {
13
+
14
+ Content(`
15
+ import json
16
+
17
+ def fetch(url, config):
18
+ parts = url.split("/")
19
+ # print('parts: ', parts)
20
+ entname = None
21
+ entid = None
22
+
23
+ try:
24
+ # TODO: PARTS DEPEND ON THE SWAGGERS: add logic
25
+ # A utility for url parsing is needed
26
+ entname = parts[1]
27
+ entid = parts[2]
28
+ except IndexError:
29
+ pass
30
+
31
+ data = config.get("body") or {}
32
+ method = config.get("method") or "GET"
33
+
34
+ req = {
35
+ "url": url,
36
+ "parts": parts,
37
+ "entname": entname,
38
+ "entid": entid,
39
+ "method": method,
40
+ "data": data,
41
+ }
42
+
43
+ json_data = None
44
+ if "GET" == method:
45
+ if None != entid:
46
+ json_data = {"id": entid, "title": "T01"}
47
+ else:
48
+ json_data = {
49
+ "name": entname,
50
+ "list": [{"id": "n01", "title": "N01"}, {"id": "n02", "title": "N02"}],
51
+ }
52
+ elif "PUT" == method or "POST" == method:
53
+ if None != entid:
54
+ json_data = { "id": entid, "title": data.get('title') }
55
+ else:
56
+ json_data = { "id": "n03", "title": data.get('title') or "T03" }
57
+
58
+ return {"req": req, "status": 200, "json": json_data}
59
+ `)
60
+
61
+ })
62
+
63
+ File({ name: 'test_' + model.name + '_sdk.' + build.extension }, () => {
64
+
65
+ Content(`
66
+ import json
67
+
68
+ from dotenv import dotenv_values
69
+
70
+ import ${model.name}_sdk
71
+
72
+ from ${model.name}_sdk import Config
73
+
74
+ from Fetch import fetch
75
+
76
+
77
+ def makeClient(config = {}):
78
+ client = ${model.name}_sdk.${model.Name}SDK.make(Config(
79
+ endpoint=config.get('${model.NAME}_ENDPOINT'),
80
+ apikey=config.get('${model.NAME}_APIKEY'),
81
+ fetch=fetch
82
+ ))
83
+ return client
84
+
85
+ `)
86
+ Content(`
87
+ def test_happy():
88
+ config = dotenv_values('.env.test.local')
89
+ client = makeClient(config)
90
+ `)
91
+ each(model.main.sdk.entity, (entity: any) => {
92
+ TestEntity({ model, build, entity })
93
+ })
94
+
95
+
96
+ })
97
+ })
98
+
99
+
100
+ export {
101
+ TestMain
102
+ }
103
+
@@ -0,0 +1,28 @@
1
+ import { cmp, File, Content, Folder } from '@voxgig/sdkgen'
2
+
3
+
4
+ import { Quick } from './Quick_py'
5
+ import { TestMain } from './TestMain_py'
6
+ import { TestAccept } from './TestAccept_py'
7
+
8
+
9
+ const Test = cmp(function Test_(props: any) {
10
+ const { build } = props
11
+
12
+ Folder({ name: 'tests' }, () => {
13
+
14
+ Quick({ build })
15
+ TestMain({ build })
16
+
17
+ Folder({ name: 'accept' }, () => {
18
+ TestAccept({ build })
19
+ })
20
+
21
+ })
22
+
23
+ })
24
+
25
+
26
+ export {
27
+ Test
28
+ }