@voxgig/sdkgen 0.16.0 → 0.17.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.
Files changed (53) hide show
  1. package/package.json +3 -1
  2. package/project/generate/model/feature/limit.jsonic +12 -0
  3. package/project/generate/model/feature/log.jsonic +28 -0
  4. package/project/generate/model/feature/page.jsonic +9 -0
  5. package/project/generate/model/feature/telemetry.jsonic +10 -0
  6. package/project/generate/model/target/go.jsonic +7 -0
  7. package/project/generate/model/target/js.jsonic +24 -0
  8. package/project/generate/src/cmp/js/Config_js.ts +34 -0
  9. package/project/generate/src/cmp/js/Entity_js.ts +91 -0
  10. package/project/generate/src/cmp/js/MainEntity_js.ts +22 -0
  11. package/project/generate/src/cmp/js/Main_js.ts +82 -0
  12. package/project/generate/src/cmp/js/Package_js.ts +57 -0
  13. package/project/generate/src/cmp/js/Quick_js.ts +82 -0
  14. package/project/generate/src/cmp/js/ReadmeInstall_js.ts +19 -0
  15. package/project/generate/src/cmp/js/ReadmeQuick_js.ts +25 -0
  16. package/project/generate/src/cmp/js/TestAcceptEntity_js.ts +101 -0
  17. package/project/generate/src/cmp/js/TestAccept_js.ts +60 -0
  18. package/project/generate/src/cmp/js/TestEntity_js.ts +24 -0
  19. package/project/generate/src/cmp/js/TestMain_js.ts +120 -0
  20. package/project/generate/src/cmp/js/Test_js.ts +24 -0
  21. package/project/generate/src/cmp/js/fragment/Entity.fragment.js +71 -0
  22. package/project/generate/src/cmp/js/fragment/EntityCreateOp.fragment.js +66 -0
  23. package/project/generate/src/cmp/js/fragment/EntityListOp.fragment.js +72 -0
  24. package/project/generate/src/cmp/js/fragment/EntityLoadOp.fragment.js +66 -0
  25. package/project/generate/src/cmp/js/fragment/EntityRemoveOp.fragment.js +66 -0
  26. package/project/generate/src/cmp/js/fragment/EntityUpdateOp.fragment.js +66 -0
  27. package/project/generate/src/cmp/js/fragment/Main.fragment.js +44 -0
  28. package/project/generate/tm/go/LICENSE +22 -0
  29. package/project/generate/tm/js/LICENSE +22 -0
  30. package/project/generate/tm/js/src/feature/log/LogFeature.js +104 -0
  31. package/project/generate/tm/js/src/utility/AuthUtility.js +16 -0
  32. package/project/generate/tm/js/src/utility/BodyUtility.js +27 -0
  33. package/project/generate/tm/js/src/utility/EmptyUtility.js +8 -0
  34. package/project/generate/tm/js/src/utility/ErrorUtility.js +15 -0
  35. package/project/generate/tm/js/src/utility/EscreUtility.js +8 -0
  36. package/project/generate/tm/js/src/utility/EscurlUtility.js +8 -0
  37. package/project/generate/tm/js/src/utility/FetchUtility.js +33 -0
  38. package/project/generate/tm/js/src/utility/FullurlUtility.js +41 -0
  39. package/project/generate/tm/js/src/utility/HeadersUtility.js +12 -0
  40. package/project/generate/tm/js/src/utility/InwardUtility.js +23 -0
  41. package/project/generate/tm/js/src/utility/JoinurlUtility.js +12 -0
  42. package/project/generate/tm/js/src/utility/MethodUtility.js +21 -0
  43. package/project/generate/tm/js/src/utility/OperatorUtility.js +36 -0
  44. package/project/generate/tm/js/src/utility/OptionsUtility.js +22 -0
  45. package/project/generate/tm/js/src/utility/OutwardUtility.js +23 -0
  46. package/project/generate/tm/js/src/utility/ParamsUtility.js +20 -0
  47. package/project/generate/tm/js/src/utility/QueryUtility.js +19 -0
  48. package/project/generate/tm/js/src/utility/ResbasicUtility.js +17 -0
  49. package/project/generate/tm/js/src/utility/ResbodyUtility.js +10 -0
  50. package/project/generate/tm/js/src/utility/ResheadersUtility.js +11 -0
  51. package/project/generate/tm/js/src/utility/ResponseUtility.js +36 -0
  52. package/project/generate/tm/js/src/utility/SpecUtility.js +41 -0
  53. package/project/generate/tm/js/src/utility/Utility.js +55 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voxgig/sdkgen",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "main": "dist/sdkgen.js",
5
5
  "type": "commonjs",
6
6
  "types": "dist/sdkgen.d.ts",
@@ -32,6 +32,8 @@
32
32
  },
33
33
  "license": "MIT",
34
34
  "files": [
35
+ "bin",
36
+ "project",
35
37
  "model",
36
38
  "src",
37
39
  "dist",
@@ -0,0 +1,12 @@
1
+
2
+ title: Limiter
3
+ active: true
4
+
5
+
6
+ hook: {
7
+ PreFetch: {
8
+ active: true
9
+ await: true
10
+ }
11
+ }
12
+
@@ -0,0 +1,28 @@
1
+
2
+ main: sdk: feature: log: {
3
+
4
+ name: .$KEY
5
+ title: Log
6
+ version: '0.0.1'
7
+ active: true
8
+
9
+
10
+ hook: {
11
+ PostConstruct: active: true
12
+ PreOperation: active: true
13
+ ModifyOp: active: true
14
+ PreFetch: active: true
15
+ PostFetch: active: true
16
+ ModifyResult: active: true
17
+ PostOperation: active: true
18
+ }
19
+
20
+
21
+ target: js: deps: {
22
+ 'pino': { active: true, version: '>=9', kind: peer }
23
+ 'pino-pretty': { active: true, version: '>=13', kind: peer }
24
+ }
25
+
26
+ }
27
+
28
+
@@ -0,0 +1,9 @@
1
+
2
+ title: Paging
3
+ active: true
4
+
5
+
6
+ hook: {
7
+ PreFetch: active: true
8
+ }
9
+
@@ -0,0 +1,10 @@
1
+
2
+ title: Telemetry
3
+ active: true
4
+
5
+ hook: {
6
+ PostConstruct: active: true
7
+ PreFetch: active: true
8
+ PostFetch: active: true
9
+ }
10
+
@@ -0,0 +1,7 @@
1
+
2
+ title: Golang
3
+ ext: go
4
+ comment: line: "//"
5
+ module: name: $$name$$
6
+
7
+
@@ -0,0 +1,24 @@
1
+
2
+ main: sdk: target: js: {
3
+
4
+ title: JavaScript
5
+ ext: js
6
+ comment: line: "//"
7
+ module: name: $$name$$
8
+
9
+ deps: &: {
10
+ # TODO: fix aontu disjunctions!
11
+ kind: *'prod' | string # 'peer' |'dev'
12
+ }
13
+
14
+ deps: {
15
+ '@hapi/code': { active: true, version: '^9.0.3', kind: dev }
16
+ 'dotenv': { active: true, version: '^16.4.5', kind: dev }
17
+ }
18
+ }
19
+
20
+
21
+ main: sdk: feature: &: target: js: deps: &: {
22
+ # TODO: fix aontu disjunctions!
23
+ kind: *'prod' | string # 'peer' |'dev'
24
+ }
@@ -0,0 +1,34 @@
1
+
2
+ import * as Path from 'node:path'
3
+
4
+ import {
5
+ cmp, each, names,
6
+ List, File, Content, Copy, Folder, Fragment, Line, FeatureHook,
7
+ } from '@voxgig/sdkgen'
8
+
9
+
10
+
11
+ const Config = cmp(async function Config(props: any) {
12
+ const { target, ctx$: { model: { main: { def } } } } = props
13
+
14
+ File({ name: 'Config.' + target.ext }, () => {
15
+ Content(`
16
+
17
+ const Config = {
18
+ options: {
19
+ base: '${def.servers[0].url}'
20
+ }
21
+ }
22
+
23
+
24
+ module.exports = {
25
+ Config
26
+ }
27
+ `)
28
+ })
29
+ })
30
+
31
+
32
+ export {
33
+ Config
34
+ }
@@ -0,0 +1,91 @@
1
+
2
+ import * as Path from 'node:path'
3
+
4
+ import {
5
+ cmp, each, camelify,
6
+ File, Content, Folder, Fragment, Line, FeatureHook,
7
+ } from '@voxgig/sdkgen'
8
+
9
+
10
+
11
+ const Operation = cmp(function Operation(props: any) {
12
+ // console.log('OP', props)
13
+
14
+ const { ff, opname, indent, entity } = props
15
+
16
+ const entop = entity.op[opname]
17
+ const path = entop.path
18
+ // console.log('ENTOP', entop)
19
+
20
+ // TODO: move up to to common Entity
21
+ const params = JSON.stringify(path
22
+ .match(/\{[^}]+\}/g)
23
+ .map((p: string) => p.substring(1, p.length - 1))
24
+ .filter((p: string) => null != p && '' !== p))
25
+
26
+ const hasp = '' != entop.place
27
+
28
+ Fragment({
29
+ from: ff + '/Entity' + camelify(opname) + 'Op.fragment.js',
30
+ indent,
31
+ replace: {
32
+ Name: entity.Name,
33
+ PATH: entop.path,
34
+ "['PARAM']": params,
35
+ "'INWARD'":
36
+ entop.inward ||
37
+ 'ctx.result.body' + ('' === entop.place ? '' : '.' + entop.place),
38
+ "'OUTWARD'":
39
+ entop.outward ||
40
+ (hasp ? '({' + entop.place + ': ' : '') + 'ctx.op.data' + (hasp ? '})' : ''),
41
+
42
+ 'class EntityOperation { // REMOVED': '',
43
+ '} // REMOVED': '',
44
+
45
+ '#Feature-Hook': ({ name, indent }: any) =>
46
+ FeatureHook({ name }, (f: any) =>
47
+ Line({ indent },
48
+ `${f.await ? 'await ' : ''}this.#features.${f.name}.${name}(ctx)`)),
49
+ }
50
+ })
51
+ })
52
+
53
+
54
+
55
+ const Entity = cmp(function Entity(props: any) {
56
+ const { target, entity } = props
57
+ // const { model } = props.ctx$
58
+
59
+ const ff = Path.normalize(__dirname + '/../../../src/cmp/js/fragment')
60
+
61
+ Folder({ name: 'src/entity' }, () => {
62
+
63
+ File({ name: entity.Name + 'Entity.' + target.name }, () => {
64
+
65
+ const opnames = Object.keys(entity.op)
66
+
67
+ const opfrags =
68
+ (['load', 'list', 'create', 'update', 'remove']
69
+ .reduce((a: any, opname: string) =>
70
+ (a['#' + camelify(opname) + 'Op'] =
71
+ !opnames.includes(opname) ? '' : ({ indent }: any) => {
72
+ Operation({ ff, opname, indent, entity })
73
+ }, a), {}))
74
+
75
+ Fragment({
76
+ from: ff + '/Entity.fragment.js',
77
+ replace: {
78
+ Name: entity.Name,
79
+
80
+ ...opfrags,
81
+ }
82
+ })
83
+
84
+ })
85
+ })
86
+ })
87
+
88
+
89
+ export {
90
+ Entity
91
+ }
@@ -0,0 +1,22 @@
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}Entity(self,data)
13
+ }
14
+
15
+ `)
16
+
17
+ })
18
+
19
+
20
+ export {
21
+ MainEntity
22
+ }
@@ -0,0 +1,82 @@
1
+
2
+ import * as Path from 'node:path'
3
+
4
+ import {
5
+ cmp, each, names,
6
+ List, File, Content, Copy, Folder, Fragment, Line, FeatureHook,
7
+ } from '@voxgig/sdkgen'
8
+
9
+
10
+ import { Package } from './Package_js'
11
+ import { Config } from './Config_js'
12
+ import { MainEntity } from './MainEntity_js'
13
+ import { Test } from './Test_js'
14
+
15
+
16
+ const Main = cmp(async function Main(props: any) {
17
+ const { target } = props
18
+ const { model } = props.ctx$
19
+
20
+ const { entity } = model.main.api
21
+ const { feature } = model.main.sdk
22
+ const { utility } = model.main.sdk
23
+
24
+ Package({ target })
25
+
26
+ Test({ target })
27
+
28
+ Folder({ name: 'src' }, () => {
29
+
30
+ File({ name: model.const.Name + 'SDK.' + target.name }, () => {
31
+
32
+ Line(`// ${model.const.Name} ${target.Name} SDK\n`)
33
+
34
+ List({ item: feature }, ({ item }: any) =>
35
+ Line(`const { ${item.Name + 'Feature'} } = ` +
36
+ `require('./feature/${item.name}/${item.Name}Feature')`))
37
+
38
+ List({ item: entity }, ({ item }: any) =>
39
+ Line(`const { ${item.Name}Entity } = require('./entity/${item.Name}Entity')`))
40
+
41
+ each(utility, (u: any) =>
42
+ Line(`const { ${u.name} } = require('./utility/${u.Name}Utility')`))
43
+ Line('')
44
+
45
+ Fragment({
46
+ from: Path.normalize(__dirname + '/../../../src/cmp/js/fragment/Main.fragment.js'),
47
+ replace: {
48
+ Name: model.const.Name,
49
+
50
+ '#BuildFeature': ({ indent }: any) =>
51
+ List({ item: feature, line: false }, ({ item }: any) =>
52
+ Line({ indent }, `${item.name}: ` +
53
+ `new ${item.Name}Feature(this, this.#options.feature.${item.name}, ` +
54
+ `${JSON.stringify(item.config || {})}), `)),
55
+
56
+ '#CustomUtility': ({ indent }: any) =>
57
+ each(utility, (u: any) =>
58
+ Line({ indent }, `this.#utility.${u.name} = ${u.name}`)),
59
+
60
+ '#Feature-Hook': ({ name, indent }: any) =>
61
+ FeatureHook({ name }, (f: any) =>
62
+ Line({ indent },
63
+ `${f.await ? 'await ' : ''}this.#features.${f.name}.${name}({ client: this })`)),
64
+ }
65
+ }, () => {
66
+
67
+ each(entity, (entity: any) => {
68
+ MainEntity({ model, target, entity })
69
+ })
70
+
71
+ })
72
+ })
73
+
74
+ Config({ target })
75
+
76
+ })
77
+ })
78
+
79
+
80
+ export {
81
+ Main
82
+ }
@@ -0,0 +1,57 @@
1
+
2
+ import {
3
+ cmp, omap, each, cmap,
4
+ File, Content,
5
+ } from '@voxgig/sdkgen'
6
+
7
+
8
+
9
+ const Package = cmp(async function Package(props: any) {
10
+ const { target, ctx$: { model } } = props
11
+ const { main: { sdk: { feature } } } = model
12
+
13
+ const only = (kind: string, deps: any) =>
14
+ omap(deps, ([k, v]: any) => [v.active && kind === v.kind ? k : undefined, v.version])
15
+
16
+ // merge target and feature deps, by kind
17
+ const deps =
18
+ each(feature, (feature: any) =>
19
+ omap(feature.deps[target.name], ([k, v]: any) =>
20
+ [v.active ? k : undefined, v]))
21
+ // TODO: sort by version; rules for version choice?
22
+ .reduce((a: any, deps: any) => (each(deps, (dep: any) =>
23
+ a[dep.kind][dep.key$] = dep.version), a),
24
+ {
25
+ prod: only('prod', target.deps),
26
+ peer: only('peer', target.deps),
27
+ dev: only('dev', target.deps),
28
+ })
29
+
30
+ // TODO: complete SDK meta data in model and use here
31
+ const pkg = {
32
+ name: `${model.const.name}-sdk`,
33
+ version: `0.0.1`,
34
+ description: 'DESCRIPTION',
35
+ main: `src/${model.const.Name}SDK.js`,
36
+ scripts: {
37
+ 'test': 'node --test test/*.test.js',
38
+ 'test-accept': 'node --test test/accept/*.test.js',
39
+ 'test-all': 'npm run test && npm run test-accept'
40
+ },
41
+ author: `${model.const.Name}`,
42
+ license: 'MIT',
43
+ dependencies: deps.prod,
44
+ peerDependencies: deps.peer,
45
+ devDependencies: deps.dev,
46
+ }
47
+
48
+
49
+ File({ name: 'package.json' }, () => {
50
+ Content(JSON.stringify(pkg, null, 2))
51
+ })
52
+ })
53
+
54
+
55
+ export {
56
+ Package
57
+ }
@@ -0,0 +1,82 @@
1
+
2
+ import { names, getx, each, cmp, File, Content } from '@voxgig/sdkgen'
3
+
4
+
5
+ const Quick = cmp(function Quick(props: any) {
6
+ const { target } = props
7
+ const { model, meta: { spec } } = props.ctx$
8
+
9
+ // get quick entity from target config
10
+
11
+ let ent: any
12
+ let entmap = getx(spec.config.guideModel, 'guide entity?test:quick:active=true')
13
+
14
+ if (entmap) {
15
+ ent = Object.values(entmap)[0]
16
+ ent.name = Object.keys(entmap)[0]
17
+ }
18
+
19
+ ent = ent || { name: 'Entity' }
20
+ names(ent, ent.name)// , ent.key$ || 'name')
21
+
22
+ // TODO: selected features should be active by default!
23
+
24
+ const featureOptions = each(model.main.sdk.feature)
25
+ .filter((f: any) => f.active)
26
+ .reduce((a: any, f: any) => a + `\n ${f.name}: { active: true },`, '')
27
+
28
+ // console.log('QUICK', ent, featureOptions)
29
+
30
+
31
+ File({ name: 'quick.' + target.name }, () => {
32
+
33
+ Content(`
34
+ // ENT 3
35
+ require('dotenv').config({ path: ['../../.env.local']})
36
+
37
+ const { ${model.const.Name}SDK } = require('../')
38
+
39
+ run()
40
+
41
+ async function run() {
42
+ const client = new ${model.const.Name}SDK({
43
+ endpoint: process.env.${model.NAME}_ENDPOINT,
44
+ apikey: process.env.${model.NAME}_APIKEY,
45
+ ${featureOptions}
46
+ })
47
+
48
+ `)
49
+
50
+ if (ent.test?.quick.create) {
51
+ Content(`
52
+ out = await client.${ent.Name}().create(${JSON.stringify(ent.test?.quick.create)})
53
+ console.log('${ent.Name}.load', out)
54
+ `)
55
+ }
56
+
57
+ if (ent.test?.quick.load) {
58
+ Content(`
59
+ out = await client.${ent.Name}().load(${JSON.stringify(ent.test?.quick.load)})
60
+ console.log('${ent.Name}.load', out)
61
+ `)
62
+ }
63
+
64
+ if (ent.test?.quick.list) {
65
+ Content(`
66
+ out = await client.${ent.Name}().list(${JSON.stringify(ent.test?.quick.list)})
67
+ console.log('${ent.Name}.list', out)
68
+ `)
69
+ }
70
+
71
+ Content(`
72
+ }
73
+ `)
74
+
75
+ })
76
+ })
77
+
78
+
79
+ export {
80
+ Quick
81
+ }
82
+
@@ -0,0 +1,19 @@
1
+
2
+ import { cmp, Content } from '@voxgig/sdkgen'
3
+
4
+
5
+ const ReadmeInstall = cmp(function ReadmeInstall(props: any) {
6
+ const { target } = props
7
+
8
+ Content('```js')
9
+ Content(`
10
+ npm install ${target.module.name}
11
+ `)
12
+ Content('```')
13
+
14
+ })
15
+
16
+
17
+ export {
18
+ ReadmeInstall
19
+ }
@@ -0,0 +1,25 @@
1
+
2
+ import { cmp, Content } from '@voxgig/sdkgen'
3
+
4
+
5
+ const ReadmeQuick = cmp(function ReadmeQuick(props: any) {
6
+ const { target, ctx$: { model } } = props
7
+
8
+ Content('```js')
9
+ Content(`
10
+ const { ${model.const.Name}SDK } = require('${target.module.name}')
11
+
12
+ const client = ${model.const.Name}SDK.make({
13
+ endpoint: process.env.${model.NAME}_ENDPOINT,
14
+ apikey: process.env.${model.NAME}_APIKEY,
15
+ })
16
+
17
+ `)
18
+ Content('```')
19
+
20
+ })
21
+
22
+
23
+ export {
24
+ ReadmeQuick
25
+ }
@@ -0,0 +1,101 @@
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
+ }
@@ -0,0 +1,60 @@
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
+