@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,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_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
|
+
|
|
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,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
|
+
}
|
|
@@ -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,18 @@
|
|
|
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
|
+
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
TestAccept
|
|
17
|
+
}
|
|
18
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
import { cmp, each, File, Content } from '@voxgig/sdkgen'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
import { TestEntity } from './TestEntity_js'
|
|
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,24 @@
|
|
|
1
|
+
|
|
2
|
+
import { cmp, File, Content, Folder } from '@voxgig/sdkgen'
|
|
3
|
+
|
|
4
|
+
import { Quick } from './Quick_js'
|
|
5
|
+
import { TestMain } from './TestMain_js'
|
|
6
|
+
import { TestAccept } from './TestAccept_js'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
const Test = cmp(function Test(props: any) {
|
|
10
|
+
const { target } = props
|
|
11
|
+
|
|
12
|
+
Folder({ name: 'test' }, () => {
|
|
13
|
+
Quick({ target })
|
|
14
|
+
TestMain({ target })
|
|
15
|
+
Folder({ name: 'accept' }, () => {
|
|
16
|
+
TestAccept({ target })
|
|
17
|
+
})
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
Test
|
|
24
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
|
|
2
|
+
class NameEntity {
|
|
3
|
+
#client
|
|
4
|
+
#options
|
|
5
|
+
#features
|
|
6
|
+
#utility
|
|
7
|
+
#data
|
|
8
|
+
#match
|
|
9
|
+
|
|
10
|
+
constructor(client, options) {
|
|
11
|
+
options = options || {}
|
|
12
|
+
options.active = false !== options.active
|
|
13
|
+
|
|
14
|
+
this.#client = client
|
|
15
|
+
this.#options = options
|
|
16
|
+
this.#features = client.features()
|
|
17
|
+
this.#utility = client.utility()
|
|
18
|
+
this.#data = {}
|
|
19
|
+
this.#match = {}
|
|
20
|
+
|
|
21
|
+
// #PostConstructEntity-Hook
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
options() {
|
|
25
|
+
return { ...this.#options }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
client() {
|
|
29
|
+
return this.#client
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
make() {
|
|
33
|
+
return new NameEntity(this.#client, this.options())
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
data(data) {
|
|
38
|
+
// NOTE: data can be mutated.
|
|
39
|
+
if(null != data) {
|
|
40
|
+
|
|
41
|
+
// #SetData-Hook
|
|
42
|
+
|
|
43
|
+
this.#data = { ...data }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let out = { ...this.#data }
|
|
47
|
+
|
|
48
|
+
// #GetData-Hook
|
|
49
|
+
|
|
50
|
+
return out
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
match() {
|
|
55
|
+
// NOTE: match cannot be mutated.
|
|
56
|
+
let out = { ...this.#match }
|
|
57
|
+
|
|
58
|
+
// #GetMatch-Hook
|
|
59
|
+
|
|
60
|
+
return out
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
// #LoadOp
|
|
65
|
+
|
|
66
|
+
// #ListOp
|
|
67
|
+
|
|
68
|
+
// #CreateOp
|
|
69
|
+
|
|
70
|
+
// #UpdateOp
|
|
71
|
+
|
|
72
|
+
// #RemoveOp
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
module.exports = {
|
|
78
|
+
NameEntity
|
|
79
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
class EntityOperation { // REMOVED
|
|
2
|
+
|
|
3
|
+
async create(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: 'create',
|
|
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, op, utility, entity }
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
// #PreOperation-Hook
|
|
26
|
+
|
|
27
|
+
await operator(ctx)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
// #PreSpec-Hook
|
|
31
|
+
|
|
32
|
+
this.#data = ctx.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,57 @@
|
|
|
1
|
+
class EntityOperation { // REMOVED
|
|
2
|
+
|
|
3
|
+
async list(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: 'list',
|
|
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.#match = ctx.op.match
|
|
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
|
+
return done(ctx)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
} // REMOVED
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
class EntityOperation { // REMOVED
|
|
2
|
+
|
|
3
|
+
async load(match) {
|
|
4
|
+
const entity = this
|
|
5
|
+
const client = this.#client
|
|
6
|
+
const utility = this.#utility
|
|
7
|
+
const { operator, spec, request, response, result, error, struct, done } = utility
|
|
8
|
+
|
|
9
|
+
const op = {
|
|
10
|
+
entity: 'Name',
|
|
11
|
+
name: 'load',
|
|
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.#match = op.match
|
|
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
|