@voxgig/sdkgen 0.16.0 → 0.18.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.
- package/dist/action/feature.js +3 -2
- package/dist/action/feature.js.map +1 -1
- package/dist/action/target.js +11 -6
- package/dist/action/target.js.map +1 -1
- package/dist/cmp/Entity.js +2 -1
- package/dist/cmp/Entity.js.map +1 -1
- package/dist/cmp/Main.js +23 -9
- package/dist/cmp/Main.js.map +1 -1
- package/dist/sdkgen.d.ts +7 -1
- package/dist/sdkgen.js +5 -2
- package/dist/sdkgen.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utility.js +1 -2
- package/dist/utility.js.map +1 -1
- package/model/sdkgen.jsonic +8 -5
- package/package.json +7 -5
- package/project/.sdk/model/feature/limit.jsonic +12 -0
- package/project/.sdk/model/feature/log.jsonic +32 -0
- package/project/.sdk/model/feature/page.jsonic +9 -0
- package/project/.sdk/model/feature/telemetry.jsonic +10 -0
- package/project/.sdk/model/target/go.jsonic +7 -0
- package/project/.sdk/model/target/js.jsonic +23 -0
- package/project/.sdk/model/target/ts.jsonic +25 -0
- package/project/.sdk/src/cmp/js/Config_js.ts +49 -0
- package/project/.sdk/src/cmp/js/Entity_js.ts +92 -0
- package/project/.sdk/src/cmp/js/MainEntity_js.ts +22 -0
- package/project/.sdk/src/cmp/js/Main_js.ts +88 -0
- package/project/.sdk/src/cmp/js/Package_js.ts +58 -0
- package/project/.sdk/src/cmp/js/Quick_js.ts +82 -0
- package/project/.sdk/src/cmp/js/ReadmeInstall_js.ts +19 -0
- package/project/.sdk/src/cmp/js/ReadmeQuick_js.ts +25 -0
- package/project/.sdk/src/cmp/js/TestAcceptEntity_js.ts +13 -0
- package/project/.sdk/src/cmp/js/TestAccept_js.ts +18 -0
- package/project/.sdk/src/cmp/js/TestEntity_js.ts +13 -0
- package/project/.sdk/src/cmp/js/TestMain_js.ts +19 -0
- package/project/.sdk/src/cmp/js/Test_js.ts +24 -0
- package/project/.sdk/src/cmp/js/fragment/Entity.fragment.js +79 -0
- package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +61 -0
- package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +57 -0
- package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +61 -0
- package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +61 -0
- package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +61 -0
- package/project/.sdk/src/cmp/js/fragment/Main.fragment.js +67 -0
- package/project/.sdk/src/cmp/ts/Config_ts.ts +36 -0
- package/project/.sdk/src/cmp/ts/Entity_ts.ts +93 -0
- package/project/.sdk/src/cmp/ts/MainEntity_ts.ts.off +22 -0
- package/project/.sdk/src/cmp/ts/Main_ts.ts +88 -0
- package/project/.sdk/src/cmp/ts/Main_ts.ts~ +88 -0
- package/project/.sdk/src/cmp/ts/Package_ts.ts +63 -0
- package/project/.sdk/src/cmp/ts/Package_ts.ts~ +58 -0
- package/project/.sdk/src/cmp/ts/Quick_ts.ts.off +82 -0
- package/project/.sdk/src/cmp/ts/ReadmeInstall_ts.ts.off +19 -0
- package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts.off +25 -0
- package/project/.sdk/src/cmp/ts/TestAcceptEntity_ts.ts.off +13 -0
- package/project/.sdk/src/cmp/ts/TestAccept_ts.ts.off +18 -0
- package/project/.sdk/src/cmp/ts/TestEntity_ts.ts.off +13 -0
- package/project/.sdk/src/cmp/ts/TestMain_ts.ts.off +19 -0
- package/project/.sdk/src/cmp/ts/Test_ts.ts.off +24 -0
- package/project/.sdk/src/cmp/ts/fragment/Config.fragment.ts +15 -0
- package/project/.sdk/src/cmp/ts/fragment/Entity.fragment.js +79 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.js +61 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.js +57 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.js +61 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.js +61 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.js +61 -0
- package/project/.sdk/src/cmp/ts/fragment/Main.fragment.js +67 -0
- package/project/.sdk/tm/go/LICENSE +22 -0
- package/project/.sdk/tm/js/LICENSE +22 -0
- package/project/.sdk/tm/js/src/feature/log/LogFeature.js +108 -0
- package/project/.sdk/tm/js/src/utility/AuthUtility.js +21 -0
- package/project/.sdk/tm/js/src/utility/BodyUtility.js +29 -0
- package/project/.sdk/tm/js/src/utility/DoneUtility.js +15 -0
- package/project/.sdk/tm/js/src/utility/ErrorUtility.js +33 -0
- package/project/.sdk/tm/js/src/utility/FindparamUtility.js +31 -0
- package/project/.sdk/tm/js/src/utility/FullurlUtility.js +39 -0
- package/project/.sdk/tm/js/src/utility/HeadersUtility.js +13 -0
- package/project/.sdk/tm/js/src/utility/JoinurlUtility.js +14 -0
- package/project/.sdk/tm/js/src/utility/MethodUtility.js +22 -0
- package/project/.sdk/tm/js/src/utility/OperatorUtility.js +44 -0
- package/project/.sdk/tm/js/src/utility/OptionsUtility.js +54 -0
- package/project/.sdk/tm/js/src/utility/ParamsUtility.js +21 -0
- package/project/.sdk/tm/js/src/utility/QueryUtility.js +21 -0
- package/project/.sdk/tm/js/src/utility/ReqformUtility.js +32 -0
- package/project/.sdk/tm/js/src/utility/RequestUtility.js +48 -0
- package/project/.sdk/tm/js/src/utility/ResbasicUtility.js +27 -0
- package/project/.sdk/tm/js/src/utility/ResbodyUtility.js +15 -0
- package/project/.sdk/tm/js/src/utility/ResformUtility.js +34 -0
- package/project/.sdk/tm/js/src/utility/ResheadersUtility.js +19 -0
- package/project/.sdk/tm/js/src/utility/ResponseUtility.js +37 -0
- package/project/.sdk/tm/js/src/utility/ResultUtility.js +28 -0
- package/project/.sdk/tm/js/src/utility/SpecUtility.js +35 -0
- package/project/.sdk/tm/js/src/utility/StructUtility.js +1203 -0
- package/project/.sdk/tm/js/src/utility/Utility.js +74 -0
- package/project/.sdk/tm/js/test/runner.js +171 -0
- package/project/.sdk/tm/js/test/utility/Custom.test.js +85 -0
- package/project/.sdk/tm/js/test/utility/PrimaryUtility.test.js +187 -0
- package/project/.sdk/tm/js/test/utility/StructUtility.test.js +367 -0
- package/project/.sdk/tm/py/LICENSE +22 -0
- package/project/.sdk/tm/ts/LICENSE +22 -0
- package/project/.sdk/tm/ts/src/README.md +1 -0
- package/project/.sdk/tm/ts/src/feature/README.md +1 -0
- package/project/.sdk/tm/ts/src/tsconfig.json +15 -0
- package/project/.sdk/tm/ts/src/utility/README.md +3 -0
- package/project/.sdk/tm/ts/test/README.md +2 -0
- package/project/.sdk/tm/ts/test/README.md~ +2 -0
- package/project/.sdk/tm/ts/test/tsconfig.json +13 -0
- package/src/action/feature.ts +4 -3
- package/src/action/target.ts +12 -6
- package/src/cmp/Entity.ts +3 -1
- package/src/cmp/Main.ts +30 -10
- package/src/sdkgen.ts +15 -5
- package/src/utility.ts +1 -2
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
class EntityOperation { // REMOVED
|
|
2
|
+
|
|
3
|
+
async remove(match) {
|
|
4
|
+
let entity = this
|
|
5
|
+
let client = this.#client
|
|
6
|
+
const utility = this.#utility
|
|
7
|
+
const { operator, spec, request, response, result, error, struct, done } = utility
|
|
8
|
+
|
|
9
|
+
let op = {
|
|
10
|
+
entity: 'Name',
|
|
11
|
+
name: 'remove',
|
|
12
|
+
path: 'PATH',
|
|
13
|
+
params: ['PARAM-LIST'],
|
|
14
|
+
alias: {'ALIAS':'MAP'},
|
|
15
|
+
match,
|
|
16
|
+
data: this.#data,
|
|
17
|
+
state: {},
|
|
18
|
+
reqform: 'REQFORM',
|
|
19
|
+
resform: 'RESFORM',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let ctx = {client, entity, op, utility}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
// #PreOperation-Hook
|
|
26
|
+
|
|
27
|
+
await operator(ctx)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
// #PreSpec-Hook
|
|
31
|
+
|
|
32
|
+
this.#data = op.data
|
|
33
|
+
|
|
34
|
+
await spec(ctx)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
// #PreRequest-Hook
|
|
38
|
+
|
|
39
|
+
await request(ctx)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
// #PreResponse-Hook
|
|
43
|
+
|
|
44
|
+
await response(ctx)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
// #PreResult-Hook
|
|
48
|
+
|
|
49
|
+
await result(ctx)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
// #PostOperation-Hook
|
|
53
|
+
|
|
54
|
+
if(null != ctx.result.resdata) {
|
|
55
|
+
this.#data = ctx.result.resdata
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return done(ctx)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
} // REMOVED
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
class EntityOperation { // REMOVED
|
|
2
|
+
|
|
3
|
+
async update(data) {
|
|
4
|
+
let entity = this
|
|
5
|
+
let client = this.#client
|
|
6
|
+
const utility = this.#utility
|
|
7
|
+
const { operator, spec, request, response, result, error, struct, done } = utility
|
|
8
|
+
|
|
9
|
+
let op = {
|
|
10
|
+
entity: 'Name',
|
|
11
|
+
name: 'update',
|
|
12
|
+
path: 'PATH',
|
|
13
|
+
params: ['PARAM-LIST'],
|
|
14
|
+
alias: {'ALIAS':'MAP'},
|
|
15
|
+
match: this.#match,
|
|
16
|
+
data: null == data ? this.#data : data,
|
|
17
|
+
state: {},
|
|
18
|
+
reqform: 'REQFORM',
|
|
19
|
+
resform: 'RESFORM',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let ctx = {client, entity, op, utility}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
// #PreOperation-Hook
|
|
26
|
+
|
|
27
|
+
await operator(ctx)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
// #PreSpec-Hook
|
|
31
|
+
|
|
32
|
+
this.#data = op.data
|
|
33
|
+
|
|
34
|
+
await spec(ctx)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
// #PreRequest-Hook
|
|
38
|
+
|
|
39
|
+
await request(ctx)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
// #PreResponse-Hook
|
|
43
|
+
|
|
44
|
+
await response(ctx)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
// #PreResult-Hook
|
|
48
|
+
|
|
49
|
+
await result(ctx)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
// #PostOperation-Hook
|
|
53
|
+
|
|
54
|
+
if(null != ctx.result.resdata) {
|
|
55
|
+
this.#data = ctx.result.resdata
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return done(ctx)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
} // REMOVED
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
|
|
2
|
+
const { Config } = require('./Config')
|
|
3
|
+
const { Utility } = require('./utility/Utility')
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class NameSDK {
|
|
7
|
+
#options
|
|
8
|
+
#features
|
|
9
|
+
#utility = Utility
|
|
10
|
+
|
|
11
|
+
constructor(options) {
|
|
12
|
+
|
|
13
|
+
this.#options = this.#utility.options({
|
|
14
|
+
client: this,
|
|
15
|
+
utility: this.#utility,
|
|
16
|
+
config: Config,
|
|
17
|
+
options,
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
// #FeatureOptions
|
|
21
|
+
|
|
22
|
+
this.#features = {
|
|
23
|
+
// #BuildFeature
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// #PostConstruct-Hook
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
options() {
|
|
31
|
+
return { ...this.#options }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
features() {
|
|
35
|
+
return { ...this.#features }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
utility() {
|
|
39
|
+
return { ...this.#utility }
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
static test(opts) {
|
|
44
|
+
return new NameSDK({
|
|
45
|
+
// #TestOptions
|
|
46
|
+
...(opts || {})
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
test(opts) {
|
|
51
|
+
return new NameSDK({
|
|
52
|
+
// #TestOptions
|
|
53
|
+
...(opts || this.#options || {})
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
// <[SLOT]>
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
const SDK = NameSDK
|
|
63
|
+
|
|
64
|
+
module.exports = {
|
|
65
|
+
NameSDK,
|
|
66
|
+
SDK,
|
|
67
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 } } = props
|
|
13
|
+
const { main: { sdk: { entity } } } = model
|
|
14
|
+
|
|
15
|
+
const ff = Path.normalize(__dirname + '/../../../src/cmp/ts/fragment/')
|
|
16
|
+
|
|
17
|
+
File({ name: 'Config.' + target.ext }, () => {
|
|
18
|
+
|
|
19
|
+
Fragment({
|
|
20
|
+
from: ff + 'Config.fragment.ts',
|
|
21
|
+
replace: {
|
|
22
|
+
'// #EntityConfigs': () => each(entity, (entity: any) => {
|
|
23
|
+
Content(`
|
|
24
|
+
${entity.name}: {
|
|
25
|
+
},
|
|
26
|
+
`)
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
Config
|
|
36
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
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
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
const Entity = cmp(function Entity(props: any) {
|
|
52
|
+
const { target, entity, entitySDK } = props
|
|
53
|
+
// console.log('ENTITY', props)
|
|
54
|
+
|
|
55
|
+
const ff = Path.normalize(__dirname + '/../../../src/cmp/ts/fragment/')
|
|
56
|
+
|
|
57
|
+
// Folder({ name: 'src/entity' }, () => {
|
|
58
|
+
|
|
59
|
+
// File({ name: entity.Name + 'Entity.' + target.name }, () => {
|
|
60
|
+
|
|
61
|
+
// const opnames = Object.keys(entity.op)
|
|
62
|
+
|
|
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), {}))
|
|
70
|
+
|
|
71
|
+
// Fragment({
|
|
72
|
+
// from: ff + 'Entity.fragment.js',
|
|
73
|
+
// replace: {
|
|
74
|
+
// Name: entity.Name,
|
|
75
|
+
|
|
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})`)),
|
|
80
|
+
|
|
81
|
+
// ...opfrags,
|
|
82
|
+
// }
|
|
83
|
+
// })
|
|
84
|
+
|
|
85
|
+
// })
|
|
86
|
+
// })
|
|
87
|
+
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
export {
|
|
92
|
+
Entity
|
|
93
|
+
}
|
|
@@ -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,88 @@
|
|
|
1
|
+
|
|
2
|
+
import * as Path from 'node:path'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
cmp, each, names, cmap,
|
|
6
|
+
List, File, Content, Copy, Folder, Fragment, Line, FeatureHook,
|
|
7
|
+
} from '@voxgig/sdkgen'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
import { Package } from './Package_ts'
|
|
11
|
+
import { Config } from './Config_ts'
|
|
12
|
+
//import { MainEntity } from './MainEntity_ts'
|
|
13
|
+
//import { Test } from './Test_ts'
|
|
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
|
+
|
|
23
|
+
Package({ target })
|
|
24
|
+
|
|
25
|
+
// Test({ target })
|
|
26
|
+
|
|
27
|
+
Folder({ name: 'src' }, () => {
|
|
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
|
+
// })
|
|
79
|
+
|
|
80
|
+
Config({ target })
|
|
81
|
+
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
export {
|
|
87
|
+
Main
|
|
88
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
|
|
2
|
+
import * as Path from 'node:path'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
cmp, each, names, cmap,
|
|
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_ts'
|
|
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
|
+
|
|
23
|
+
// Package({ target })
|
|
24
|
+
|
|
25
|
+
// Test({ target })
|
|
26
|
+
|
|
27
|
+
Folder({ name: 'src' }, () => {
|
|
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
|
+
// })
|
|
79
|
+
|
|
80
|
+
Config({ target })
|
|
81
|
+
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
export {
|
|
87
|
+
Main
|
|
88
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
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-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',
|
|
41
|
+
|
|
42
|
+
"watch": "tsc --build src test -w",
|
|
43
|
+
"build": "tsc --build src test",
|
|
44
|
+
"clean": "rm -rf node_modules yarn.lock package-lock.json",
|
|
45
|
+
"reset": "npm run clean && npm i && npm run build && npm test",
|
|
46
|
+
},
|
|
47
|
+
author: `${model.const.Name}`,
|
|
48
|
+
license: 'MIT',
|
|
49
|
+
dependencies: deps.prod,
|
|
50
|
+
peerDependencies: deps.peer,
|
|
51
|
+
devDependencies: deps.dev,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
File({ name: 'package.json' }, () => {
|
|
56
|
+
Content(JSON.stringify(pkg, null, 2))
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
export {
|
|
62
|
+
Package
|
|
63
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
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-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'
|
|
41
|
+
},
|
|
42
|
+
author: `${model.const.Name}`,
|
|
43
|
+
license: 'MIT',
|
|
44
|
+
dependencies: deps.prod,
|
|
45
|
+
peerDependencies: deps.peer,
|
|
46
|
+
devDependencies: deps.dev,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
File({ name: 'package.json' }, () => {
|
|
51
|
+
Content(JSON.stringify(pkg, null, 2))
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
Package
|
|
58
|
+
}
|