@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.
Files changed (105) hide show
  1. package/bin/voxgig-create-sdkgen +196 -0
  2. package/dist/create-sdkgen.d.ts +11 -8
  3. package/dist/create-sdkgen.js +61 -63
  4. package/dist/create-sdkgen.js.map +1 -1
  5. package/dist/standard/ModelSdk.js +8 -61
  6. package/dist/standard/ModelSdk.js.map +1 -1
  7. package/dist/standard/Root.js +58 -57
  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 +56 -74
  12. package/src/standard/ModelSdk.ts +9 -71
  13. package/src/standard/Root.ts +26 -68
  14. package/bin/run-create-sdkgen.js +0 -269
  15. package/bin/run-create-sdkgen.js~ +0 -1
  16. package/src/standard/ModelSdk.ts~ +0 -1
  17. package/src/standard/Root.ts~ +0 -3
  18. package/src/utility.ts +0 -8
  19. package/tm/standard/.env.local +0 -2
  20. package/tm/standard/build/sdk.js +0 -25
  21. package/tm/standard/def/DEFINITION.md +0 -2
  22. package/tm/standard/model/.model-config/model-config.jsonic +0 -13
  23. package/tm/standard/model/go.jsonic +0 -6
  24. package/tm/standard/model/js.jsonic +0 -6
  25. package/tm/standard/model/php.jsonic +0 -6
  26. package/tm/standard/model/py.jsonic +0 -7
  27. package/tm/standard/model/rb.jsonic +0 -6
  28. package/tm/standard/model/sdk.jsonic.off +0 -60
  29. package/tm/standard/package.json +0 -30
  30. package/tm/standard/src/Root.ts +0 -60
  31. package/tm/standard/src/go/Entity_go.ts +0 -226
  32. package/tm/standard/src/go/MainEntity_go.ts +0 -26
  33. package/tm/standard/src/go/Main_go.ts +0 -168
  34. package/tm/standard/src/go/Quick_go.ts +0 -108
  35. package/tm/standard/src/go/ReadmeInstall_go.ts +0 -19
  36. package/tm/standard/src/go/ReadmeQuick_go.ts +0 -45
  37. package/tm/standard/src/go/TestAcceptEntity_go.ts +0 -219
  38. package/tm/standard/src/go/TestAccept_go.ts +0 -38
  39. package/tm/standard/src/go/TestEntity_go.ts +0 -79
  40. package/tm/standard/src/go/TestMain_go.ts +0 -61
  41. package/tm/standard/src/go/Test_go.ts +0 -20
  42. package/tm/standard/src/js/Entity_js.ts +0 -135
  43. package/tm/standard/src/js/MainEntity_js.ts +0 -22
  44. package/tm/standard/src/js/Main_js.ts +0 -128
  45. package/tm/standard/src/js/Quick_js.ts +0 -72
  46. package/tm/standard/src/js/ReadmeInstall_js.ts +0 -19
  47. package/tm/standard/src/js/ReadmeQuick_js.ts +0 -27
  48. package/tm/standard/src/js/TestAcceptEntity_js.ts +0 -101
  49. package/tm/standard/src/js/TestAccept_js.ts +0 -60
  50. package/tm/standard/src/js/TestEntity_js.ts +0 -24
  51. package/tm/standard/src/js/TestMain_js.ts +0 -123
  52. package/tm/standard/src/js/Test_js.ts +0 -24
  53. package/tm/standard/src/php/Entity_php.ts +0 -97
  54. package/tm/standard/src/php/MainEntity_php.ts +0 -43
  55. package/tm/standard/src/php/Main_php.ts +0 -50
  56. package/tm/standard/src/php/Quick_php.ts +0 -59
  57. package/tm/standard/src/php/TestAcceptEntity_php.ts +0 -81
  58. package/tm/standard/src/php/TestAccept_php.ts +0 -33
  59. package/tm/standard/src/php/TestEntity_php.ts +0 -64
  60. package/tm/standard/src/php/TestMain_php.ts +0 -120
  61. package/tm/standard/src/php/Test_php.ts +0 -21
  62. package/tm/standard/src/py/Entity_py.ts +0 -98
  63. package/tm/standard/src/py/MainEntity_py.ts +0 -19
  64. package/tm/standard/src/py/Main_py.ts +0 -211
  65. package/tm/standard/src/py/Quick_py.ts +0 -133
  66. package/tm/standard/src/py/TestAcceptEntity_py.ts +0 -47
  67. package/tm/standard/src/py/TestAccept_py.ts +0 -77
  68. package/tm/standard/src/py/TestEntity_py.ts +0 -50
  69. package/tm/standard/src/py/TestMain_py.ts +0 -103
  70. package/tm/standard/src/py/Test_py.ts +0 -28
  71. package/tm/standard/src/rb/Client_rb.ts +0 -142
  72. package/tm/standard/src/rb/Entity_rb.ts +0 -153
  73. package/tm/standard/src/rb/Error_rb.ts +0 -56
  74. package/tm/standard/src/rb/MainEntity_rb.ts +0 -16
  75. package/tm/standard/src/rb/Main_rb.ts +0 -55
  76. package/tm/standard/src/rb/Quick_rb.ts +0 -65
  77. package/tm/standard/src/rb/ReadmeInstall_rb.ts +0 -19
  78. package/tm/standard/src/rb/ReadmeQuick_rb.ts +0 -30
  79. package/tm/standard/src/rb/TestAcceptEntity_rb.ts +0 -83
  80. package/tm/standard/src/rb/TestAccept_rb.ts +0 -45
  81. package/tm/standard/src/rb/TestEntity_rb.ts +0 -82
  82. package/tm/standard/src/rb/TestMain_rb.ts +0 -67
  83. package/tm/standard/src/rb/Test_rb.ts +0 -27
  84. package/tm/standard/src/tsconfig.json +0 -15
  85. package/tm/standard/tm/go/.env.example +0 -2
  86. package/tm/standard/tm/go/LICENSE +0 -22
  87. package/tm/standard/tm/go/go.mod +0 -5
  88. package/tm/standard/tm/go/go.sum +0 -2
  89. package/tm/standard/tm/js/LICENSE +0 -22
  90. package/tm/standard/tm/js/package.json +0 -17
  91. package/tm/standard/tm/php/LICENSE +0 -22
  92. package/tm/standard/tm/py/LICENSE +0 -22
  93. package/tm/standard/tm/py/MANIFEST.in +0 -4
  94. package/tm/standard/tm/py/Makefile +0 -14
  95. package/tm/standard/tm/py/pyproject.toml +0 -4
  96. package/tm/standard/tm/py/pytest.ini +0 -3
  97. package/tm/standard/tm/py/requirements.txt +0 -4
  98. package/tm/standard/tm/py/setup.cfg +0 -2
  99. package/tm/standard/tm/py/setup.py +0 -82
  100. package/tm/standard/tm/rb/.rspec +0 -1
  101. package/tm/standard/tm/rb/Gemfile +0 -21
  102. package/tm/standard/tm/rb/LICENSE +0 -22
  103. package/tm/standard/tm/rb/Rakefile +0 -6
  104. package/tm/standard/tm/rb/spec/spec_helper.rb +0 -22
  105. package/tm/standard/tm/rb/tm.gemspec +0 -39
@@ -1,269 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const Path = require('node:path')
4
- const { statSync } = require('node:fs')
5
- const { parseArgs } = require('node:util')
6
-
7
- const { Gubu, Fault } = require('gubu')
8
-
9
- const Pkg = require('../package.json')
10
-
11
- const { CreateSdkGen } = require('../dist/create-sdkgen.js')
12
-
13
- // const { Root } = require('../dist/standard/Root')
14
- const rootpath = require.resolve('../dist/standard/Root')
15
-
16
- let DEBUG = false
17
- let CONSOLE = console
18
-
19
-
20
- try {
21
- let options = resolveOptions()
22
-
23
- if(options.debug) {
24
- DEBUG = true
25
- }
26
-
27
- if(options.version) {
28
- version()
29
- }
30
-
31
- if(options.help) {
32
- help()
33
- }
34
-
35
- if(options.version || options.help) {
36
- exit()
37
- }
38
-
39
- options = validateOptions(options)
40
-
41
- generate(options)
42
-
43
- }
44
- catch(err) {
45
- handleError(err)
46
- }
47
-
48
-
49
-
50
- function exit(err) {
51
- let code = 0
52
- if(err) {
53
- code = 1
54
- }
55
- process.exit(code)
56
- }
57
-
58
-
59
- function generate(options) {
60
- const createSdkGen = CreateSdkGen({
61
- folder: options.folder,
62
- rootpath
63
- })
64
-
65
-
66
- // TODO: load model
67
-
68
- const model = {
69
- name: options.name,
70
- year: new Date().getFullYear(),
71
- def: {
72
- filepath: options.def || 'def.yml'
73
- }
74
- }
75
-
76
- model.def.filename = Path.basename(model.def.filepath)
77
-
78
- const spec = {
79
- // TODO: move to CreateSdkGen options
80
- spec: options.spec,
81
- model,
82
- // root: Root,
83
- }
84
-
85
- if(options.watch) {
86
- spec.watch = [
87
- '../tm',
88
- '../dist',
89
- ]
90
- createSdkGen.watch(spec)
91
- }
92
- else {
93
- createSdkGen.generate(spec)
94
- }
95
-
96
- }
97
-
98
-
99
- function resolveOptions() {
100
-
101
- const args = parseArgs({
102
- allowPositionals: true,
103
- options: {
104
- folder: {
105
- type: 'string',
106
- short: 'f',
107
- default: '',
108
- },
109
-
110
- def: {
111
- type: 'string',
112
- short: 'd',
113
- default: '',
114
- },
115
-
116
- model: {
117
- type: 'string',
118
- short: 'm',
119
- default: '',
120
- },
121
-
122
- watch: {
123
- type: 'boolean',
124
- short: 'w',
125
- },
126
-
127
- debug: {
128
- type: 'boolean',
129
- short: 'g',
130
- },
131
-
132
- help: {
133
- type: 'boolean',
134
- short: 'h',
135
- },
136
-
137
- version: {
138
- type: 'boolean',
139
- short: 'v',
140
- },
141
-
142
- }
143
- })
144
-
145
- const options = {
146
- name: args.positionals[0],
147
- folder: '' === args.values.folder ? args.positionals[0] : args.values.folder,
148
- def: args.values.def,
149
- model: args.values.model,
150
- watch: !!args.values.watch,
151
- debug: !!args.values.debug,
152
- help: !!args.values.help,
153
- version: !!args.values.version,
154
- }
155
-
156
- return options
157
- }
158
-
159
-
160
- function validateOptions(rawOptions) {
161
- const optShape = Gubu({
162
- name: Fault('The first argument should be the project name.', String),
163
- folder: String,
164
- def: '',
165
- model: '',
166
- watch: Boolean,
167
- debug: Boolean,
168
- help: Boolean,
169
- version: Boolean,
170
- })
171
-
172
- const err = []
173
- const options = optShape(rawOptions,{err})
174
-
175
- if(err[0]) {
176
- throw new Error(err[0].text)
177
- }
178
-
179
- if('' !== options.def) {
180
- options.def = Path.resolve(options.def)
181
- const stat = statSync(options.def, {throwIfNoEntry:false})
182
- if(null == stat) {
183
- throw new Error('Definition file not found: '+options.def)
184
- }
185
- }
186
-
187
- if('' !== options.model) {
188
- options.model = Path.resolve(options.model)
189
- const stat = statSync(options.model, {throwIfNoEntry:false})
190
- if(null == stat) {
191
- throw new Error('Model file not found: '+options.model)
192
- }
193
- }
194
-
195
- return options
196
- }
197
-
198
-
199
- function handleError(err) {
200
- CONSOLE.log('Voxgig SDK Generator Error:')
201
-
202
- if(DEBUG) {
203
- CONSOLE.log(err)
204
- }
205
- else {
206
- CONSOLE.log(err.message)
207
- }
208
-
209
- exit(err)
210
- }
211
-
212
-
213
- function version() {
214
- CONSOLE.log(Pkg.version)
215
- }
216
-
217
-
218
- function help() {
219
- let s = `
220
- Create a Voxgig SDK Generator project.
221
-
222
- Usage: npm create @voxgig/sdkgen@latest <name> <args>
223
-
224
- where <name> is the name of the SDK project. This is also used to
225
- create a project folder if one is not explictly defined using the -f
226
- argument. If run against an existing folder generated files will be
227
- overwritten.
228
-
229
- <args> are the command arguments:
230
-
231
- --folder <folder> Specific the folder for the SDK project. Optional.
232
- -f <folder> Default: <name> in current folder.
233
-
234
- --def <file> Specify the API definition file (OpenAPI, Swagger, etc)
235
- -d that defines the SDK. Optional.
236
-
237
- --model <file> Specify the SDK model file to customize the SDK. Optional.
238
- -m
239
-
240
- --watch Run in watch mode. The SDK project will be updated if any of the
241
- -w project inputs (such as the spec file) change.
242
-
243
- --debug Print verbose logging.
244
- -d
245
-
246
- --help Print this help message.
247
- -h
248
-
249
- --version Print version number.
250
- -v
251
-
252
-
253
- Examples:
254
-
255
- # Basic usage
256
- > npm create @voxgig/sdkgen@latest foo
257
- # Creates the SDK Project in the folder ./foo
258
-
259
-
260
- # Custom project folder
261
- > npm create @voxgig/sdkgen@latest foo -f ~/Projects/Foo
262
- # Creates the SDK Project in the folder ~/Projects/Foo
263
-
264
-
265
- See also: https://voxgig.com/sdkgen
266
- `
267
-
268
- CONSOLE.log(s)
269
- }
@@ -1 +0,0 @@
1
-
@@ -1 +0,0 @@
1
-
@@ -1,3 +0,0 @@
1
-
2
-
3
-
package/src/utility.ts DELETED
@@ -1,8 +0,0 @@
1
-
2
-
3
- function foo() { }
4
-
5
-
6
- export {
7
- foo
8
- }
@@ -1,2 +0,0 @@
1
- $$NAME$$_ENDPOINT=https://api.example.com
2
- $$NAME$$_APIKEY=apikey
@@ -1,25 +0,0 @@
1
-
2
- const { SdkGen } = require('@voxgig/sdkgen')
3
- const { Root } = require('../dist/Root')
4
-
5
-
6
- try {
7
- const config = {
8
- folder: __dirname+'/../sdk',
9
- def: __dirname+'/../def/$$def.filename$$',
10
- meta: {
11
- name: '$$name$$'
12
- },
13
- model: {
14
- folder: __dirname+'/../model',
15
-
16
- entity: {}
17
- },
18
- }
19
-
20
- module.exports = SdkGen.makeBuild(Root, config)
21
-
22
- }
23
- catch(e) {
24
- console.log('SDK ERROR', e)
25
- }
@@ -1,2 +0,0 @@
1
- # API Definition
2
- API definition (OpenAPI etc) files live here.
@@ -1,13 +0,0 @@
1
-
2
-
3
- @'@voxgig/model/model/.model-config/model-config.jsonic'
4
-
5
- sys: model: builders: {
6
- sdk: load: 'build/sdk.js'
7
- }
8
-
9
- sys: model: watch: {
10
- 'build': {}
11
- 'dist': {}
12
- 'tm': {}
13
- }
@@ -1,6 +0,0 @@
1
-
2
- title: Go
3
-
4
- module: name: '$ModuleName'
5
-
6
- options: $.main.sdk.options
@@ -1,6 +0,0 @@
1
-
2
- title: JavaScript
3
-
4
- module: name: '$ModuleName'
5
-
6
- options: $.main.sdk.options
@@ -1,6 +0,0 @@
1
-
2
- title: PHP
3
-
4
- module: name: '$ModuleName'
5
-
6
- options: $.main.sdk.options
@@ -1,7 +0,0 @@
1
- title: Python
2
-
3
- extension: py
4
-
5
- module: name: '$ModuleName'
6
-
7
- options: $.main.sdk.options
@@ -1,6 +0,0 @@
1
-
2
- title: Ruby
3
-
4
- module: name: '$ModuleName'
5
-
6
- options: $.main.sdk.options
@@ -1,60 +0,0 @@
1
-
2
- name: '$$name$$'
3
-
4
- @"api.jsonic"
5
- @"def.jsonic"
6
-
7
- main: sdk: build: &: { name: .$KEY }
8
-
9
- main: sdk: build: js: @"js.jsonic"
10
-
11
- main: sdk: build: rb: @"rb.jsonic"
12
-
13
- main: sdk: build: py: @"py.jsonic"
14
-
15
- main: sdk: build: php: @"php.jsonic"
16
-
17
- main: sdk: build: go: @"go.jsonic"
18
-
19
-
20
-
21
- main: sdk: test: quick: entity: name: $$test.quick.entity.name$$
22
-
23
-
24
- main: sdk: entity: $.main.api.entity
25
-
26
-
27
- main: sdk: entity: &: {
28
- name: .$KEY
29
- publish: *true | boolean
30
- }
31
-
32
-
33
-
34
- main: sdk: options: &: {
35
- name: .$KEY
36
- publish: *true | boolean
37
- }
38
-
39
-
40
- main: sdk: options: {
41
-
42
- endpoint: {
43
- kind: *String | string
44
- short: "$$Name$$ API URL"
45
- }
46
-
47
- apikey: {
48
- kind: *String | string
49
- short: "$$Name$$ API Key"
50
- }
51
-
52
- fetch: {
53
- kind: *Any | string
54
- publish: false
55
- }
56
- }
57
-
58
-
59
-
60
-
@@ -1,30 +0,0 @@
1
- {
2
- "name": "build-$$name$$-sdk",
3
- "version": "0.0.1",
4
- "description": "",
5
- "main": "QQQindex.js",
6
- "scripts": {
7
- "model": "voxgig-model model/sdk.jsonic",
8
- "watch": "tsc --build src -w",
9
- "build": "tsc --build src",
10
- "test": "echo no-test",
11
- "clean": "rm -rf node_modules yarn.lock package-lock.json",
12
- "reset": "npm run clean && npm i && npm run build && npm test",
13
- "mock-server": "prism mock def/$DefinitionFile"
14
- },
15
- "author": "",
16
- "license": "MIT",
17
- "overrides": {
18
- "@stoplight/prism-cli": {
19
- "@stoplight/json": "3.21.0"
20
- }
21
- },
22
- "devDependencies": {
23
- "@voxgig/model": "^3.2.0",
24
- "@voxgig/sdkgen": "^0.6.0",
25
- "@voxgig/util": "^0.0.3",
26
- "@types/node": "22.5.4",
27
- "@stoplight/prism-cli": "^5.9.0",
28
- "typescript": "^5.5.4"
29
- }
30
- }
@@ -1,60 +0,0 @@
1
-
2
- import {
3
- names,
4
- cmp,
5
- each,
6
-
7
- Project,
8
- Folder,
9
-
10
- Main,
11
- Entity,
12
- Readme,
13
-
14
- } from '@voxgig/sdkgen'
15
-
16
- // import { Readme } from './Readme'
17
- // import { Main } from './Main'
18
- // import { Entity } from './Entity'
19
-
20
-
21
- const Root = cmp(function Root(props: any) {
22
- const { model, ctx$ } = props
23
-
24
- names(model, model.name)
25
-
26
- // console.dir(model, { depth: null })
27
-
28
- ctx$.model = model
29
-
30
- const build = model.main.sdk.build
31
- const entity = model.main.sdk.entity
32
-
33
- Project({}, () => {
34
-
35
- each(build, (build: any) => {
36
- names(build, build.name)
37
- // console.log('BUILD', build.name)
38
-
39
- Folder({ name: build.name }, () => {
40
-
41
- each(entity, (entity: any) => {
42
- names(entity, entity.name)
43
- // console.log('ENTITY', entity.name)
44
-
45
- Entity({ build, entity })
46
- })
47
-
48
- Main({ build })
49
-
50
- Readme({ build })
51
- })
52
- })
53
- })
54
- })
55
-
56
-
57
- export {
58
- Root
59
- }
60
-