@voxgig/sdkgen 0.22.0 → 0.23.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 (119) hide show
  1. package/bin/voxgig-sdkgen +12 -4
  2. package/dist/action/action.d.ts +4 -0
  3. package/dist/action/action.js +35 -0
  4. package/dist/action/action.js.map +1 -0
  5. package/dist/action/feature.d.ts +4 -2
  6. package/dist/action/feature.js +57 -38
  7. package/dist/action/feature.js.map +1 -1
  8. package/dist/action/target.d.ts +4 -2
  9. package/dist/action/target.js +136 -45
  10. package/dist/action/target.js.map +1 -1
  11. package/dist/cmp/Entity.js +5 -0
  12. package/dist/cmp/Entity.js.map +1 -1
  13. package/dist/cmp/Feature.js +5 -0
  14. package/dist/cmp/Feature.js.map +1 -1
  15. package/dist/cmp/Main.js +4 -1
  16. package/dist/cmp/Main.js.map +1 -1
  17. package/dist/cmp/Top.d.ts +2 -0
  18. package/dist/cmp/Top.js +23 -0
  19. package/dist/cmp/Top.js.map +1 -0
  20. package/dist/sdkgen.d.ts +10 -3
  21. package/dist/sdkgen.js +53 -8
  22. package/dist/sdkgen.js.map +1 -1
  23. package/dist/tsconfig.tsbuildinfo +1 -1
  24. package/dist/types.d.ts +16 -0
  25. package/dist/types.js +3 -0
  26. package/dist/types.js.map +1 -0
  27. package/dist/utility.d.ts +3 -3
  28. package/dist/utility.js +7 -8
  29. package/dist/utility.js.map +1 -1
  30. package/package.json +6 -10
  31. package/project/.sdk/model/feature/README.md +2 -0
  32. package/project/.sdk/model/feature/log.jsonic +7 -4
  33. package/project/.sdk/model/feature/test.jsonic +26 -0
  34. package/project/.sdk/model/target/ts.jsonic +1 -0
  35. package/project/.sdk/src/cmp/ts/Config_ts.ts +7 -2
  36. package/project/.sdk/src/cmp/ts/EntityOperation_ts.ts +67 -0
  37. package/project/.sdk/src/cmp/ts/EntityTest_ts.ts +180 -0
  38. package/project/.sdk/src/cmp/ts/Entity_ts.ts +41 -66
  39. package/project/.sdk/src/cmp/ts/MainEntity_ts.ts +22 -0
  40. package/project/.sdk/src/cmp/ts/Main_ts.ts +52 -53
  41. package/project/.sdk/src/cmp/ts/Package_ts.ts +12 -7
  42. package/project/.sdk/src/cmp/ts/ReadmeInstall_ts.ts +19 -0
  43. package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +24 -0
  44. package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +13 -0
  45. package/project/.sdk/src/cmp/ts/TestMain_ts.ts +19 -0
  46. package/project/.sdk/src/cmp/ts/Test_ts.ts +20 -0
  47. package/project/.sdk/src/cmp/ts/fragment/Config.fragment.ts +8 -1
  48. package/project/.sdk/src/cmp/ts/fragment/Entity.fragment.ts +164 -0
  49. package/project/.sdk/src/cmp/ts/fragment/Entity.test.fragment.ts +37 -0
  50. package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.ts +91 -0
  51. package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.ts +92 -0
  52. package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.ts +96 -0
  53. package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.ts +96 -0
  54. package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.ts +95 -0
  55. package/project/.sdk/src/cmp/ts/fragment/Main.fragment.ts +107 -0
  56. package/project/.sdk/src/cmp/ts/utility_ts.ts +10 -0
  57. package/project/.sdk/tm/ts/src/feature/base/BaseFeature.ts +43 -0
  58. package/project/.sdk/tm/ts/src/feature/log/LogFeature.ts +109 -0
  59. package/project/.sdk/tm/ts/src/feature/test/TestFeature.ts +159 -0
  60. package/project/.sdk/tm/ts/src/tsconfig.json +1 -1
  61. package/project/.sdk/tm/ts/src/types.ts +114 -0
  62. package/project/.sdk/tm/ts/src/utility/AddfeatureUtility.ts +47 -0
  63. package/project/.sdk/tm/ts/src/utility/AuthUtility.ts +42 -0
  64. package/project/.sdk/tm/ts/src/utility/BodyUtility.ts +29 -0
  65. package/project/.sdk/tm/ts/src/utility/CleanUtility.ts +50 -0
  66. package/project/.sdk/tm/ts/src/utility/ContextUtility.ts +67 -0
  67. package/project/.sdk/tm/ts/src/utility/DoneUtility.ts +28 -0
  68. package/project/.sdk/tm/ts/src/utility/ErrorUtility.ts +59 -0
  69. package/project/.sdk/tm/ts/src/utility/FeaturehookUtility.ts +26 -0
  70. package/project/.sdk/tm/ts/src/utility/FetcherUtility.ts +17 -0
  71. package/project/.sdk/tm/ts/src/utility/FindparamUtility.ts +54 -0
  72. package/project/.sdk/tm/ts/src/utility/FullurlUtility.ts +46 -0
  73. package/project/.sdk/tm/ts/src/utility/HeadersUtility.ts +24 -0
  74. package/project/.sdk/tm/ts/src/utility/InitfeatureUtility.ts +13 -0
  75. package/project/.sdk/tm/ts/src/utility/JoinurlUtility.ts +15 -0
  76. package/project/.sdk/tm/ts/src/utility/MethodUtility.ts +25 -0
  77. package/project/.sdk/tm/ts/src/utility/OperatorUtility.ts +90 -0
  78. package/project/.sdk/tm/ts/src/utility/OptionsUtility.ts +72 -0
  79. package/project/.sdk/tm/ts/src/utility/ParamsUtility.ts +37 -0
  80. package/project/.sdk/tm/ts/src/utility/QueryUtility.ts +27 -0
  81. package/project/.sdk/tm/ts/src/utility/ReqformUtility.ts +33 -0
  82. package/project/.sdk/tm/ts/src/utility/RequestUtility.ts +66 -0
  83. package/project/.sdk/tm/ts/src/utility/ResbasicUtility.ts +34 -0
  84. package/project/.sdk/tm/ts/src/utility/ResbodyUtility.ts +19 -0
  85. package/project/.sdk/tm/ts/src/utility/ResformUtility.ts +36 -0
  86. package/project/.sdk/tm/ts/src/utility/ResheadersUtility.ts +23 -0
  87. package/project/.sdk/tm/ts/src/utility/ResponseUtility.ts +30 -0
  88. package/project/.sdk/tm/ts/src/utility/ResultUtility.ts +36 -0
  89. package/project/.sdk/tm/ts/src/utility/SpecUtility.ts +61 -0
  90. package/project/.sdk/tm/ts/src/utility/StructUtility.ts +2499 -0
  91. package/project/.sdk/tm/ts/src/utility/Utility.ts +88 -0
  92. package/project/.sdk/tm/ts/test/exists.test.ts +17 -0
  93. package/project/.sdk/tm/ts/test/runner.ts +402 -0
  94. package/project/.sdk/tm/ts/test/tsconfig.json +1 -1
  95. package/project/.sdk/tm/ts/test/utility/Custom.test.ts +62 -0
  96. package/project/.sdk/tm/ts/test/utility/PrimaryUtility.test.ts +244 -0
  97. package/project/.sdk/tm/ts/test/utility/StructUtility.test.ts +678 -0
  98. package/project/.sdk/tm/ts/test/utility/index.ts +9 -0
  99. package/project/.sdk/tm/ts/test/utility.ts +86 -0
  100. package/src/action/action.ts +54 -0
  101. package/src/action/feature.ts +83 -47
  102. package/src/action/target.ts +173 -53
  103. package/src/cmp/Entity.ts +6 -0
  104. package/src/cmp/Feature.ts +6 -3
  105. package/src/cmp/Main.ts +4 -1
  106. package/src/sdkgen.ts +86 -11
  107. package/src/types.ts +33 -0
  108. package/src/utility.ts +5 -3
  109. package/project/.sdk/model/feature/limit.jsonic +0 -12
  110. package/project/.sdk/model/feature/page.jsonic +0 -9
  111. package/project/.sdk/model/feature/telemetry.jsonic +0 -10
  112. package/project/.sdk/src/cmp/ts/fragment/Entity.fragment.js +0 -79
  113. package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.js +0 -61
  114. package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.js +0 -57
  115. package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.js +0 -61
  116. package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.js +0 -61
  117. package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.js +0 -61
  118. package/project/.sdk/src/cmp/ts/fragment/Main.fragment.js +0 -67
  119. package/project/.sdk/tm/ts/test/README.md~ +0 -2
@@ -0,0 +1,180 @@
1
+
2
+ import {
3
+ cmp,
4
+ File, Content, Folder, Fragment, Slot
5
+ } from '@voxgig/sdkgen'
6
+
7
+ import { jsonify } from '@voxgig/struct'
8
+
9
+
10
+
11
+
12
+ const EntityTest = cmp(function EntityTest(props: any) {
13
+ const ctx$ = props.ctx$
14
+ const { model } = props.ctx$
15
+ const { target, entity, entrep, ff } = props
16
+
17
+ Folder({ name: 'test/entity' }, () => {
18
+
19
+ File({ name: entity.Name + 'Entity.test.' + target.name }, () => {
20
+
21
+ Fragment({
22
+ from: ff + 'Entity.test.fragment.ts',
23
+ replace: {
24
+ ...entrep
25
+ }
26
+ }, () => {
27
+
28
+ // TODO: should be EntityFlow
29
+ const basicflow = model?.main?.sdk?.flow?.['Basic' + entity.Name + 'Flow']
30
+
31
+ const dobasic = basicflow && true === basicflow.active
32
+
33
+ if (!dobasic) {
34
+ return;
35
+ }
36
+
37
+ let indent = 2
38
+
39
+ Slot({ name: 'basicSetup' }, () => {
40
+ Content(`
41
+ function basicSetup(extra?: any) {
42
+ extra = extra || {}
43
+
44
+ const options = ${jsonify(basicflow.test, { offset: indent - 2 })}
45
+
46
+ const setup: any = {
47
+ dm: {
48
+ p: envOverride(${jsonify(basicflow.param, { offset: 2 + indent })}),
49
+ s: {},
50
+ },
51
+ options,
52
+ }
53
+
54
+ const { merge } = utility.struct
55
+
56
+ let client = ${model.Name}SDK.test(options, extra)
57
+ if ('TRUE' === setup.dm.p.${model.NAME}_TEST_LIVE) {
58
+ client = new ${model.Name}SDK(merge([
59
+ {
60
+ apikey: process.env.${model.Name}_APIKEY,
61
+ },
62
+ extra])
63
+ )
64
+ }
65
+
66
+ setup.client = client
67
+ setup.struct = client.utility().struct
68
+ setup.explain = 'TRUE' === setup.dm.p.${model.Name}_TEST_EXPLAIN
69
+
70
+ return setup
71
+ }
72
+ `)
73
+ })
74
+
75
+
76
+ indent = 6
77
+ Slot({ name: 'basic' }, () => {
78
+ Content(`
79
+ const setup = basicSetup()
80
+ const { dm, options, client, struct, explain } = setup
81
+ const { validate, transform } = struct
82
+ let ctrl: any = {}
83
+
84
+ try {
85
+ `)
86
+
87
+ ctx$.util.makeFlow(basicflow, {
88
+ indent: indent,
89
+ model,
90
+ }, {
91
+ FlowStep:
92
+ '\n// Step: $$__stepdef.name$$ - $$__stepdef.action$$ $$__stepdef.entity$$\n',
93
+
94
+ GetEntity: [
95
+ 'const $$__stepdef.name$$ = makeStepData(dm, \'$$__stepdef.name$$\')\n',
96
+ (stepdef: any, pctx: any) => pctx.data.step[stepdef.name] = stepdef,
97
+ [
98
+ '__stepdef._ref',
99
+ '$$__stepdef.name$$.entity = $$__stepdef._ref$$.entity\n',
100
+ '$$__stepdef.name$$.entity = client.$$__stepdef.Entity$$()\n',
101
+ ],
102
+ ],
103
+
104
+ EntityMatch: [
105
+ (stepdef: any) => stepdef.match_JSON = jsonify(stepdef.match),
106
+ [
107
+ '__stepdef.match',
108
+ '$$__stepdef.name$$.match = makeMatch(dm, transform, $$__stepdef.match_JSON$$)\n'
109
+ ]
110
+ ],
111
+
112
+ EntityData: [
113
+ (stepdef: any) => stepdef.reqdata_JSON = jsonify(stepdef.reqdata),
114
+ [
115
+ '__stepdef.reqdata',
116
+ '$$__stepdef.name$$.reqdata = ' +
117
+ 'makeReqdata(dm, transform, $$__stepdef.reqdata_JSON$$)\n'
118
+ ]
119
+ ],
120
+
121
+ EntityAction: [
122
+ // 'ctrl = explain ? { explain: {} } : undefined\n',
123
+ [
124
+ { __stepdef: { action: { '`$OR`': ['update', 'create', 'remove'] } } },
125
+ '$$__stepdef.name$$.resdata =\n' +
126
+ ' await $$__stepdef.name$$.entity.$$__stepdef.action$$(' +
127
+ '$$__stepdef.name$$.reqdata, ctrl = makeCtrl(explain))\n'
128
+ ],
129
+ [
130
+ { __stepdef: { action: 'load' } },
131
+ '$$__stepdef.name$$.resdata =\n' +
132
+ ' await $$__stepdef.name$$.entity.load($$__stepdef.name$$.match, ctrl = makeCtrl(explain))\n'
133
+ ],
134
+ [
135
+ { __stepdef: { action: 'list' } },
136
+ '$$__stepdef.name$$.reslist =\n' +
137
+ ' await $$__stepdef.name$$.entity.list($$__stepdef.name$$.match, ctrl = makeCtrl(explain))\n'
138
+ ],
139
+ ],
140
+
141
+ ExplainAction:
142
+ 'if( explain ) { console.log(\'$$__stepdef.name$$: \', ctrl.explain) }\n',
143
+
144
+ ValidateAction: [
145
+ (stepdef: any) => {
146
+ stepdef.valid_JSON = jsonify(stepdef.valid)
147
+ stepdef.reslist_DATA =
148
+ null == stepdef.reslist ? [] : stepdef.reslist.map((ent: any) => ent.data())
149
+ },
150
+ [
151
+ { __stepdef: { action: { '`$OR`': ['load', 'update', 'create', 'remove'] } } },
152
+ 'makeValid(dm, validate, $$__stepdef.name$$.resdata, ' +
153
+ '$$__stepdef.valid_JSON$$)\n'
154
+ ],
155
+ [
156
+ { __stepdef: { action: 'list' } },
157
+ 'makeValid(dm, validate, $$__stepdef.name$$.reslist_DATA, ' +
158
+ '$$__stepdef.valid_JSON$)\n'
159
+ ],
160
+ ]
161
+ })
162
+
163
+ Content(`
164
+ }
165
+ catch(err: any) {
166
+ console.dir(dm, {depth: null})
167
+ if( explain ) { console.dir(ctrl.explain, {depth: null}) }
168
+ throw err
169
+ }
170
+ `)
171
+ })
172
+ })
173
+ })
174
+ })
175
+ })
176
+
177
+
178
+ export {
179
+ EntityTest
180
+ }
@@ -2,92 +2,67 @@
2
2
  import * as Path from 'node:path'
3
3
 
4
4
  import {
5
- cmp, each, camelify,
6
- File, Content, Folder, Fragment, Line, FeatureHook,
5
+ cmp, each, camelify, names,
6
+ File, Content, Folder, Fragment, Line, FeatureHook, Slot
7
7
  } from '@voxgig/sdkgen'
8
8
 
9
+ import { EntityOperation } from './EntityOperation_ts'
10
+ import { EntityTest } from './EntityTest_ts'
9
11
 
10
12
 
11
- const Operation = cmp(function Operation(props: any) {
12
- const { ff, opname, indent, entity, entitySDK } = props
13
-
14
- const entop = entity.op[opname]
15
- const path = entop.path
16
- // console.log('ENTOP', entop)
17
-
18
- // TODO: move up to to common Entity
19
- const params = JSON.stringify(path
20
- .match(/\{[^}]+\}/g)
21
- .map((p: string) => p.substring(1, p.length - 1))
22
- .filter((p: string) => null != p && '' !== p))
23
-
24
- const aliasmap = JSON.stringify(entitySDK.alias.field)
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-LIST']": params,
35
- "{'ALIAS':'MAP'}": aliasmap,
36
- "'REQFORM'": JSON.stringify(entop.reqform),
37
- "'RESFORM'": JSON.stringify(entop.resform),
38
- 'class EntityOperation { // REMOVED': '',
39
- '} // REMOVED': '',
40
-
41
- '#Feature-Hook': ({ name, indent }: any) =>
42
- FeatureHook({ name }, (f: any) =>
43
- Line({ indent },
44
- `${f.await ? 'await ' : ''}this.#features.${f.name}.${name}(ctx)`)),
45
- }
46
- })
47
- })
48
-
13
+ const Entity = cmp(function Entity(props: any) {
14
+ const { model, stdrep } = props.ctx$
15
+ const { target, entity } = props
49
16
 
17
+ const entrep = {
18
+ ...stdrep,
19
+ }
50
20
 
51
- const Entity = cmp(function Entity(props: any) {
52
- const { target, entity, entitySDK } = props
53
- // console.log('ENTITY', props)
21
+ names(entrep, entity.Name, 'EntityName')
22
+ // console.log('ENTREP', entrep)
54
23
 
55
24
  const ff = Path.normalize(__dirname + '/../../../src/cmp/ts/fragment/')
56
25
 
57
- // Folder({ name: 'src/entity' }, () => {
26
+ Folder({ name: 'src/entity' }, () => {
58
27
 
59
- // File({ name: entity.Name + 'Entity.' + target.name }, () => {
28
+ File({ name: entity.Name + 'Entity.' + target.name }, () => {
60
29
 
61
- // const opnames = Object.keys(entity.op)
30
+ const opnames = Object.keys(entity.op)
62
31
 
63
- // const opfrags =
64
- // (['load', 'list', 'create', 'update', 'remove']
65
- // .reduce((a: any, opname: string) =>
66
- // (a['#' + camelify(opname) + 'Op'] =
67
- // !opnames.includes(opname) ? '' : ({ indent }: any) => {
68
- // Operation({ ff, opname, indent, entity, entitySDK })
69
- // }, a), {}))
32
+ const opfrags =
33
+ (['load', 'list', 'create', 'update', 'remove']
34
+ .reduce((a: any, opname: string) =>
35
+ (a['#' + camelify(opname) + 'Op'] =
36
+ !opnames.includes(opname) ? '' : ({ indent }: any) => {
37
+ EntityOperation({ ff, opname, indent, entity, entrep })
38
+ }, a), {}))
70
39
 
71
- // Fragment({
72
- // from: ff + 'Entity.fragment.js',
73
- // replace: {
74
- // Name: entity.Name,
40
+ Fragment({
41
+ from: ff + 'Entity.fragment.ts',
42
+ replace: {
43
+ ...entrep,
44
+ SdkName: model.const.Name,
45
+ EntityName: entity.Name,
75
46
 
76
- // '#Feature-Hook': ({ name, indent }: any) =>
77
- // FeatureHook({ name }, (f: any) =>
78
- // Line({ indent },
79
- // `${f.await ? 'await ' : ''}this.#features.${f.name}.${name}({entity:this})`)),
47
+ '#Feature-Hook': ({ name, indent }: any) =>
48
+ Content({ indent }, `
49
+ fres = featurehook(ctx, '${name}')
50
+ if (fres instanceof Promise) { await fres }
51
+ `.trim()),
80
52
 
81
- // ...opfrags,
82
- // }
83
- // })
53
+ ...opfrags,
54
+ }
55
+ })
56
+
57
+ })
58
+ })
84
59
 
85
- // })
86
- // })
87
60
 
61
+ EntityTest({ target, entity, entrep, ff })
88
62
  })
89
63
 
90
64
 
65
+
91
66
  export {
92
67
  Entity
93
68
  }
@@ -0,0 +1,22 @@
1
+
2
+
3
+ import { cmp, 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?: any) {
11
+ const self = this
12
+ return new ${entity.Name}Entity(self,data)
13
+ }
14
+
15
+ `)
16
+
17
+ })
18
+
19
+
20
+ export {
21
+ MainEntity
22
+ }
@@ -9,8 +9,8 @@ import {
9
9
 
10
10
  import { Package } from './Package_ts'
11
11
  import { Config } from './Config_ts'
12
- //import { MainEntity } from './MainEntity_ts'
13
- //import { Test } from './Test_ts'
12
+ import { MainEntity } from './MainEntity_ts'
13
+ import { Test } from './Test_ts'
14
14
 
15
15
 
16
16
  const Main = cmp(async function Main(props: any) {
@@ -22,60 +22,59 @@ const Main = cmp(async function Main(props: any) {
22
22
 
23
23
  Package({ target })
24
24
 
25
- // Test({ target })
25
+ Test({ target })
26
26
 
27
27
  Folder({ name: 'src' }, () => {
28
28
 
29
- // File({ name: model.const.Name + 'SDK.' + target.name }, () => {
30
-
31
- // Line(`// ${model.const.Name} ${target.Name} SDK\n`)
32
-
33
- // List({ item: feature }, ({ item }: any) =>
34
- // Line(`const { ${item.Name + 'Feature'} } = ` +
35
- // `require('./feature/${item.name}/${item.Name}Feature')`))
36
-
37
- // List({ item: entity }, ({ item }: any) =>
38
- // Line(`const { ${item.Name}Entity } = require('./entity/${item.Name}Entity')`))
39
-
40
- // Fragment({
41
- // from: Path.normalize(__dirname + '/../../../src/cmp/js/fragment/Main.fragment.js'),
42
- // replace: {
43
- // Name: model.const.Name,
44
-
45
-
46
- // '#FeatureOptions': ({ indent }: any) =>
47
- // Line({ indent }, `const fopts = this.#options.feature || {}`),
48
-
49
- // '#BuildFeature': ({ indent }: any) => {
50
- // List({ item: feature, line: false }, ({ item }: any) =>
51
- // Line({ indent }, `${item.name}: ` +
52
- // `new ${item.Name}Feature(this, fopts.${item.name}, ` +
53
- // `${JSON.stringify(item.config || {})}), `))
54
- // },
55
-
56
- // '#Feature-Hook': ({ name, indent }: any) =>
57
- // FeatureHook({ name }, (f: any) =>
58
- // Line({ indent },
59
- // `${f.await ? 'await ' : ''}this.#features.${f.name}.${name}({ client: this })`)),
60
-
61
- // '#TestOptions': ({ indent }: any) => {
62
- // const topts = {
63
- // feature: cmap(feature, {
64
- // active: false
65
- // }),
66
- // }
67
- // Content({ indent },
68
- // JSON.stringify(topts, null, 2)
69
- // .replace(/^{\n /, '').replace(/\n}$/, ',\n').replace(/\n /g, '\n'))
70
- // }
71
- // }
72
- // }, () => {
73
- // each(entity, (entity: any) => {
74
- // // console.log('ENTITY', entity.name)
75
- // MainEntity({ target, entity, entitySDK: model.main.sdk.entity[entity.name] })
76
- // })
77
- // })
78
- // })
29
+ File({ name: model.const.Name + 'SDK.' + target.name }, () => {
30
+
31
+ Line(`// ${model.const.Name} ${target.Name} SDK\n`)
32
+
33
+ List({ item: feature }, ({ item }: any) =>
34
+ Line(`import { ${item.Name + 'Feature'} } ` +
35
+ `from './feature/${item.name}/${item.Name}Feature'`))
36
+
37
+ List({ item: entity }, ({ item }: any) =>
38
+ Line(`import { ${item.Name}Entity } from './entity/${item.Name}Entity'`))
39
+
40
+ Fragment(
41
+ {
42
+ from: Path.normalize(__dirname + '/../../../src/cmp/ts/fragment/Main.fragment.ts'),
43
+ replace: {
44
+ ...props.ctx$.stdrep,
45
+
46
+ '#BuildFeatures': ({ indent }: any) => {
47
+ List({ item: feature, line: false }, ({ item }: any) =>
48
+ Line({ indent },
49
+ `addfeature(ctx, new ${item.Name}Feature())`))
50
+ },
51
+
52
+ '#Feature-Hook': ({ name, indent }: any) => Content({ indent }, `
53
+ fres = featurehook(ctx, '${name}')
54
+ if (fres instanceof Promise) { await fres }
55
+ `),
56
+
57
+ '#TestOptions': ({ indent }: any) => {
58
+ const topts = {
59
+ feature: cmap(feature, {
60
+ active: false
61
+ }),
62
+ }
63
+ Content({ indent },
64
+ JSON.stringify(topts, null, 2)
65
+ .replace(/^{\n /, '').replace(/\n}$/, ',\n').replace(/\n /g, '\n'))
66
+ }
67
+ }
68
+ },
69
+
70
+ // Entities
71
+ () => {
72
+ each(entity, (entity: any) => {
73
+ const entprops = { target, entity, entitySDK: model.main.api.entity[entity.name] }
74
+ MainEntity(entprops)
75
+ })
76
+ })
77
+ })
79
78
 
80
79
  Config({ target })
81
80
 
@@ -16,7 +16,7 @@ const Package = cmp(async function Package(props: any) {
16
16
  // merge target and feature deps, by kind
17
17
  const deps =
18
18
  each(feature, (feature: any) =>
19
- omap(feature.deps[target.name], ([k, v]: any) =>
19
+ omap(feature.deps?.[target.name], ([k, v]: any) =>
20
20
  [v.active ? k : undefined, v]))
21
21
  // TODO: sort by version; rules for version choice?
22
22
  .reduce((a: any, deps: any) => (each(deps, (dep: any) =>
@@ -27,17 +27,22 @@ const Package = cmp(async function Package(props: any) {
27
27
  dev: only('dev', target.deps),
28
28
  })
29
29
 
30
+ const sdkname = model.name
31
+ const origin = null == model.origin ? '' : `@${model.origin}/`
32
+
30
33
  // TODO: complete SDK meta data in model and use here
31
34
  const pkg = {
32
- name: `${model.const.name}-sdk`,
35
+ name: `${origin}${sdkname}-sdk`,
33
36
  version: `0.0.1`,
34
37
  description: 'DESCRIPTION',
35
- main: `src/${model.const.Name}SDK.js`,
38
+ main: `dist/${model.const.Name}SDK.js`,
39
+ type: 'commonjs',
40
+ types: `dist/${model.const.Name}SDK.d.ts`,
36
41
  scripts: {
37
- 'test': 'node --test test/*.test.js',
38
- 'test-utility': 'node --test test/utility/*.test.js',
39
- 'test-accept': 'node --test test/accept/*.test.js',
40
- 'test-all': 'npm run test && npm run test-utility',
42
+ 'test': 'node --enable-source-maps --test dist-test/**/*.test.js',
43
+ 'test-some': 'node --enable-source-maps ' +
44
+ '--test-name-pattern=\"$npm_config_pattern\" --test dist-test/**/*.test.js',
45
+ 'test-utility': 'node --enable-source-maps --test test/utility/*.test.ts',
41
46
 
42
47
  "watch": "tsc --build src test -w",
43
48
  "build": "tsc --build src test",
@@ -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('```ts')
9
+ Content(`
10
+ npm install ${target.module.name}
11
+ `)
12
+ Content('```')
13
+
14
+ })
15
+
16
+
17
+ export {
18
+ ReadmeInstall
19
+ }
@@ -0,0 +1,24 @@
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('```ts')
9
+ Content(`
10
+ const { ${model.const.Name}SDK } = require('${target.module.name}')
11
+
12
+ const client = ${model.const.Name}SDK.make({
13
+ apikey: process.env.${model.NAME}_APIKEY,
14
+ })
15
+
16
+ `)
17
+ Content('```')
18
+
19
+ })
20
+
21
+
22
+ export {
23
+ ReadmeQuick
24
+ }
@@ -0,0 +1,13 @@
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
+ })
9
+
10
+
11
+ export {
12
+ TestEntity
13
+ }
@@ -0,0 +1,19 @@
1
+
2
+ import { cmp, each, File, Content } from '@voxgig/sdkgen'
3
+
4
+
5
+ import { TestEntity } from './TestEntity_ts'
6
+
7
+
8
+ const TestMain = cmp(function TestMain(props: any) {
9
+ const { target } = props
10
+ const { model } = props.ctx$
11
+
12
+
13
+ })
14
+
15
+
16
+ export {
17
+ TestMain
18
+ }
19
+
@@ -0,0 +1,20 @@
1
+
2
+ import { cmp, Folder } from '@voxgig/sdkgen'
3
+
4
+ // import { Quick } from './Quick_ts'
5
+ import { TestMain } from './TestMain_ts'
6
+
7
+
8
+ const Test = cmp(function Test(props: any) {
9
+ const { target } = props
10
+
11
+ Folder({ name: 'test' }, () => {
12
+ // Quick({ target })
13
+ TestMain({ target })
14
+ })
15
+ })
16
+
17
+
18
+ export {
19
+ Test
20
+ }
@@ -1,7 +1,14 @@
1
1
 
2
2
  const Config = {
3
+
3
4
  options: {
4
- base: '${def.servers[0].url}',
5
+ base: '$$main.def.servers.0.url$$',
6
+
7
+ auth: {
8
+ prefix: '$$main.sdk.config.auth.prefix$$',
9
+ },
10
+
11
+ headers: 'HEADERS',
5
12
 
6
13
  entity: {
7
14
  // #EntityConfigs