@voxgig/sdkgen 0.15.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.
- package/bin/voxgig-sdkgen +135 -0
- package/dist/action/feature.d.ts +2 -0
- package/dist/action/feature.js +76 -0
- package/dist/action/feature.js.map +1 -0
- package/dist/action/lang.d.ts +2 -0
- package/dist/action/lang.js +68 -0
- package/dist/action/lang.js.map +1 -0
- package/dist/action/target.d.ts +2 -0
- package/dist/action/target.js +82 -0
- package/dist/action/target.js.map +1 -0
- package/dist/cmp/Entity.js +3 -3
- package/dist/cmp/Entity.js.map +1 -1
- package/dist/cmp/Feature.js +10 -3
- package/dist/cmp/Feature.js.map +1 -1
- package/dist/cmp/FeatureHook.d.ts +2 -0
- package/dist/cmp/FeatureHook.js +17 -0
- package/dist/cmp/FeatureHook.js.map +1 -0
- package/dist/cmp/Hook.d.ts +2 -0
- package/dist/cmp/Hook.js +10 -0
- package/dist/cmp/Hook.js.map +1 -0
- package/dist/cmp/Main.js +12 -5
- package/dist/cmp/Main.js.map +1 -1
- package/dist/cmp/Readme.js +8 -8
- package/dist/cmp/Readme.js.map +1 -1
- package/dist/cmp/ReadmeInstall.js +3 -3
- package/dist/cmp/ReadmeInstall.js.map +1 -1
- package/dist/cmp/ReadmeOptions.js +2 -2
- package/dist/cmp/ReadmeOptions.js.map +1 -1
- package/dist/cmp/ReadmeQuick.js +3 -3
- package/dist/cmp/ReadmeQuick.js.map +1 -1
- package/dist/sdkgen.d.ts +15 -4
- package/dist/sdkgen.js +106 -35
- package/dist/sdkgen.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utility.d.ts +4 -1
- package/dist/utility.js +11 -2
- package/dist/utility.js.map +1 -1
- package/model/sdkgen.jsonic +58 -6
- package/package.json +12 -12
- package/project/generate/model/feature/limit.jsonic +12 -0
- package/project/generate/model/feature/log.jsonic +28 -0
- package/project/generate/model/feature/page.jsonic +9 -0
- package/project/generate/model/feature/telemetry.jsonic +10 -0
- package/project/generate/model/target/go.jsonic +7 -0
- package/project/generate/model/target/js.jsonic +24 -0
- package/project/generate/src/cmp/js/Config_js.ts +34 -0
- package/project/generate/src/cmp/js/Entity_js.ts +91 -0
- package/project/generate/src/cmp/js/MainEntity_js.ts +22 -0
- package/project/generate/src/cmp/js/Main_js.ts +82 -0
- package/project/generate/src/cmp/js/Package_js.ts +57 -0
- package/project/generate/src/cmp/js/Quick_js.ts +82 -0
- package/project/generate/src/cmp/js/ReadmeInstall_js.ts +19 -0
- package/project/generate/src/cmp/js/ReadmeQuick_js.ts +25 -0
- package/project/generate/src/cmp/js/TestAcceptEntity_js.ts +101 -0
- package/project/generate/src/cmp/js/TestAccept_js.ts +60 -0
- package/project/generate/src/cmp/js/TestEntity_js.ts +24 -0
- package/project/generate/src/cmp/js/TestMain_js.ts +120 -0
- package/project/generate/src/cmp/js/Test_js.ts +24 -0
- package/project/generate/src/cmp/js/fragment/Entity.fragment.js +71 -0
- package/project/generate/src/cmp/js/fragment/EntityCreateOp.fragment.js +66 -0
- package/project/generate/src/cmp/js/fragment/EntityListOp.fragment.js +72 -0
- package/project/generate/src/cmp/js/fragment/EntityLoadOp.fragment.js +66 -0
- package/project/generate/src/cmp/js/fragment/EntityRemoveOp.fragment.js +66 -0
- package/project/generate/src/cmp/js/fragment/EntityUpdateOp.fragment.js +66 -0
- package/project/generate/src/cmp/js/fragment/Main.fragment.js +44 -0
- package/project/generate/tm/go/LICENSE +22 -0
- package/project/generate/tm/js/LICENSE +22 -0
- package/project/generate/tm/js/src/feature/log/LogFeature.js +104 -0
- package/project/generate/tm/js/src/utility/AuthUtility.js +16 -0
- package/project/generate/tm/js/src/utility/BodyUtility.js +27 -0
- package/project/generate/tm/js/src/utility/EmptyUtility.js +8 -0
- package/project/generate/tm/js/src/utility/ErrorUtility.js +15 -0
- package/project/generate/tm/js/src/utility/EscreUtility.js +8 -0
- package/project/generate/tm/js/src/utility/EscurlUtility.js +8 -0
- package/project/generate/tm/js/src/utility/FetchUtility.js +33 -0
- package/project/generate/tm/js/src/utility/FullurlUtility.js +41 -0
- package/project/generate/tm/js/src/utility/HeadersUtility.js +12 -0
- package/project/generate/tm/js/src/utility/InwardUtility.js +23 -0
- package/project/generate/tm/js/src/utility/JoinurlUtility.js +12 -0
- package/project/generate/tm/js/src/utility/MethodUtility.js +21 -0
- package/project/generate/tm/js/src/utility/OperatorUtility.js +36 -0
- package/project/generate/tm/js/src/utility/OptionsUtility.js +22 -0
- package/project/generate/tm/js/src/utility/OutwardUtility.js +23 -0
- package/project/generate/tm/js/src/utility/ParamsUtility.js +20 -0
- package/project/generate/tm/js/src/utility/QueryUtility.js +19 -0
- package/project/generate/tm/js/src/utility/ResbasicUtility.js +17 -0
- package/project/generate/tm/js/src/utility/ResbodyUtility.js +10 -0
- package/project/generate/tm/js/src/utility/ResheadersUtility.js +11 -0
- package/project/generate/tm/js/src/utility/ResponseUtility.js +36 -0
- package/project/generate/tm/js/src/utility/SpecUtility.js +41 -0
- package/project/generate/tm/js/src/utility/Utility.js +55 -0
- package/src/action/feature.ts +120 -0
- package/src/action/target.ts +127 -0
- package/src/cmp/Entity.ts +6 -4
- package/src/cmp/Feature.ts +11 -4
- package/src/cmp/FeatureHook.ts +23 -0
- package/src/cmp/Main.ts +14 -6
- package/src/cmp/Readme.ts +8 -8
- package/src/cmp/ReadmeInstall.ts +3 -3
- package/src/cmp/ReadmeOptions.ts +2 -2
- package/src/cmp/ReadmeQuick.ts +3 -3
- package/src/sdkgen.ts +116 -34
- package/src/utility.ts +11 -1
- package/src/prepare-openapi.ts +0 -59
|
@@ -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,71 @@
|
|
|
1
|
+
|
|
2
|
+
class NameEntity {
|
|
3
|
+
#client
|
|
4
|
+
#options
|
|
5
|
+
#features
|
|
6
|
+
#utility
|
|
7
|
+
#data
|
|
8
|
+
#query
|
|
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.#query = {}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
options() {
|
|
23
|
+
return { ...this.#options }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
client() {
|
|
27
|
+
return this.#client
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
data(data) {
|
|
31
|
+
// NOTE: query cannot be mutated.
|
|
32
|
+
if(null != data) {
|
|
33
|
+
|
|
34
|
+
// #SetData-Hook
|
|
35
|
+
|
|
36
|
+
this.#data = { ...data }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let out = { ...this.#data }
|
|
40
|
+
|
|
41
|
+
// #GetData-Hook
|
|
42
|
+
|
|
43
|
+
return out
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
query() {
|
|
47
|
+
// NOTE: query cannot be mutated.
|
|
48
|
+
let out = { ...this.#query }
|
|
49
|
+
|
|
50
|
+
// #GetQuery-Hook
|
|
51
|
+
|
|
52
|
+
return out
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
// #LoadOp
|
|
57
|
+
|
|
58
|
+
// #ListOp
|
|
59
|
+
|
|
60
|
+
// #CreateOp
|
|
61
|
+
|
|
62
|
+
// #UpdateOp
|
|
63
|
+
|
|
64
|
+
// #RemoveOp
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
module.exports = {
|
|
70
|
+
NameEntity
|
|
71
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
class EntityOperation { // REMOVED
|
|
2
|
+
async create(data) {
|
|
3
|
+
let entity = this
|
|
4
|
+
let client = this.#client
|
|
5
|
+
|
|
6
|
+
let op = {
|
|
7
|
+
entity: 'Name',
|
|
8
|
+
name:'create',
|
|
9
|
+
path: 'PATH',
|
|
10
|
+
params: ['PARAM'],
|
|
11
|
+
query: this.#query,
|
|
12
|
+
data: null == data ? this.#data : data,
|
|
13
|
+
state: {},
|
|
14
|
+
inward: (ctx)=>'INWARD',
|
|
15
|
+
outward: (ctx)=>'OUTWARD',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let ctx = {client, entity, op}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
// #PreOperation-Hook
|
|
22
|
+
|
|
23
|
+
ctx.op = await this.#utility.operator(ctx)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// #ModifyOp-Hook
|
|
27
|
+
|
|
28
|
+
this.#data = ctx.op.data
|
|
29
|
+
|
|
30
|
+
ctx.spec = await this.#utility.spec(ctx)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
// #PreFetch-Hook
|
|
34
|
+
|
|
35
|
+
ctx.response = await this.#utility.fetch(ctx)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
// #PostFetch-Hook
|
|
39
|
+
|
|
40
|
+
ctx.result = await this.#utility.response(ctx)
|
|
41
|
+
|
|
42
|
+
// #ModifyResult-Hook
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if(ctx.result.ok) {
|
|
46
|
+
ctx.indata = this.#utility.inward(ctx)
|
|
47
|
+
|
|
48
|
+
if(null != ctx.indata) {
|
|
49
|
+
this.#data = ctx.indata
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
this.#postCreateHook(ctx)
|
|
53
|
+
|
|
54
|
+
return this
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.#postCreateHook(ctx)
|
|
58
|
+
|
|
59
|
+
return this.#utility.error(ctx)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
#postCreateHook(ctx) {
|
|
64
|
+
// #PostOperation-Hook
|
|
65
|
+
}
|
|
66
|
+
} // REMOVED
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
class EntityOperation { // REMOVED
|
|
2
|
+
async list(query) {
|
|
3
|
+
let entity = this
|
|
4
|
+
let client = this.#client
|
|
5
|
+
|
|
6
|
+
let op = {
|
|
7
|
+
entity: 'Name',
|
|
8
|
+
name:'load',
|
|
9
|
+
path: 'PATH',
|
|
10
|
+
params: ['PARAM'],
|
|
11
|
+
query,
|
|
12
|
+
data: this.#data,
|
|
13
|
+
state: {},
|
|
14
|
+
inward: (ctx)=>'INWARD',
|
|
15
|
+
outward: (ctx)=>'OUTWARD',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let ctx = {client, entity, op}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
// #PreOperation-Hook
|
|
22
|
+
|
|
23
|
+
ctx.op = await this.#utility.operator(ctx)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// #ModifyOp-Hook
|
|
27
|
+
|
|
28
|
+
this.#query = ctx.op.query
|
|
29
|
+
|
|
30
|
+
ctx.spec = await this.#utility.spec(ctx)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
// #PreFetch-Hook
|
|
34
|
+
|
|
35
|
+
ctx.response = await this.#utility.fetch(ctx)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
// #PostFetch-Hook
|
|
39
|
+
|
|
40
|
+
ctx.result = await this.#utility.response(ctx)
|
|
41
|
+
|
|
42
|
+
// #ModifyResult-Hook
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if(ctx.result.ok) {
|
|
46
|
+
ctx.inlist = this.#utility.inward(ctx)
|
|
47
|
+
|
|
48
|
+
const entities = []
|
|
49
|
+
|
|
50
|
+
if(null != ctx.inlist) {
|
|
51
|
+
for(let entry of ctx.inlist) {
|
|
52
|
+
const entity = new NameEntity(this.#client, this.options())
|
|
53
|
+
entity.data(entry)
|
|
54
|
+
entities.push(entity)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
this.#postListHook(ctx)
|
|
59
|
+
|
|
60
|
+
return entities
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
this.#postListHook(ctx)
|
|
64
|
+
|
|
65
|
+
return this.#utility.error(ctx)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
#postListHook(ctx) {
|
|
70
|
+
// #PostOperation-Hook
|
|
71
|
+
}
|
|
72
|
+
} // REMOVED
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
class EntityOperation { // REMOVED
|
|
2
|
+
async load(query) {
|
|
3
|
+
let entity = this
|
|
4
|
+
let client = this.#client
|
|
5
|
+
|
|
6
|
+
let op = {
|
|
7
|
+
entity:'Name',
|
|
8
|
+
name:'load',
|
|
9
|
+
path: 'PATH',
|
|
10
|
+
params: ['PARAM'],
|
|
11
|
+
query,
|
|
12
|
+
data: this.#data,
|
|
13
|
+
state: {},
|
|
14
|
+
inward: (ctx)=>'INWARD',
|
|
15
|
+
outward: (ctx)=>'OUTWARD',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let ctx = {client, entity, op}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
// #PreOperation-Hook
|
|
22
|
+
|
|
23
|
+
ctx.op = await this.#utility.operator(ctx)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// #ModifyOp-Hook
|
|
27
|
+
|
|
28
|
+
this.#query = op.query
|
|
29
|
+
|
|
30
|
+
ctx.spec = await this.#utility.spec(ctx)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
// #PreFetch-Hook
|
|
34
|
+
|
|
35
|
+
ctx.response = await this.#utility.fetch(ctx)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
// #PostFetch-Hook
|
|
39
|
+
|
|
40
|
+
ctx.result = await this.#utility.response(ctx)
|
|
41
|
+
|
|
42
|
+
// #ModifyResult-Hook
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if(ctx.result.ok) {
|
|
46
|
+
ctx.indata = this.#utility.inward(ctx)
|
|
47
|
+
|
|
48
|
+
if(null != ctx.indata) {
|
|
49
|
+
this.#data = ctx.indata
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
this.#postLoadHook(ctx)
|
|
53
|
+
|
|
54
|
+
return this
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.#postLoadHook(ctx)
|
|
58
|
+
|
|
59
|
+
return this.#utility.error(ctx)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
#postLoadHook(ctx) {
|
|
64
|
+
// #PostOperation-Hook
|
|
65
|
+
}
|
|
66
|
+
} // REMOVED
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
class EntityOperation { // REMOVED
|
|
2
|
+
async remove(query) {
|
|
3
|
+
let entity = this
|
|
4
|
+
let client = this.#client
|
|
5
|
+
|
|
6
|
+
let op = {
|
|
7
|
+
entity: 'Name',
|
|
8
|
+
name:'remove',
|
|
9
|
+
path: 'PATH',
|
|
10
|
+
params: ['PARAM'],
|
|
11
|
+
query,
|
|
12
|
+
data: this.#data,
|
|
13
|
+
state: {},
|
|
14
|
+
inward: (ctx)=>'INWARD',
|
|
15
|
+
outward: (ctx)=>'OUTWARD',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let ctx = {client, entity, op}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
// #PreOperation-Hook
|
|
22
|
+
|
|
23
|
+
ctx.op = await this.#utility.operator(ctx)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// #ModifyOp-Hook
|
|
27
|
+
|
|
28
|
+
this.#query = op.query
|
|
29
|
+
|
|
30
|
+
ctx.spec = await this.#utility.spec(ctx)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
// #PreFetch-Hook
|
|
34
|
+
|
|
35
|
+
ctx.response = await this.#utility.fetch(ctx)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
// #PostFetch-Hook
|
|
39
|
+
|
|
40
|
+
ctx.result = await this.#utility.response(ctx)
|
|
41
|
+
|
|
42
|
+
// #ModifyResult-Hook
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if(ctx.result.ok) {
|
|
46
|
+
ctx.indata = this.#utility.inward(ctx)
|
|
47
|
+
|
|
48
|
+
if(null != ctx.indata) {
|
|
49
|
+
this.#data = ctx.indata
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
this.#postRemoveHook(ctx)
|
|
53
|
+
|
|
54
|
+
return this
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.#postRemoveHook(ctx)
|
|
58
|
+
|
|
59
|
+
return this.#utility.error(ctx)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
#postRemoveHook(ctx) {
|
|
64
|
+
// #PostOperation-Hook
|
|
65
|
+
}
|
|
66
|
+
} // REMOVED
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
class EntityOperation { // REMOVED
|
|
2
|
+
async update(data) {
|
|
3
|
+
let entity = this
|
|
4
|
+
let client = this.#client
|
|
5
|
+
|
|
6
|
+
let op = {
|
|
7
|
+
entity: 'Name',
|
|
8
|
+
name:'create',
|
|
9
|
+
path: 'PATH',
|
|
10
|
+
params: ['PARAM'],
|
|
11
|
+
query: this.#query,
|
|
12
|
+
data: null == data ? this.#data : data,
|
|
13
|
+
state: {},
|
|
14
|
+
inward: (ctx)=>'INWARD',
|
|
15
|
+
outward: (ctx)=>'OUTWARD',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let ctx = {client, entity, op}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
// #PreOperation-Hook
|
|
22
|
+
|
|
23
|
+
ctx.op = await this.#utility.operator(ctx)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// #ModifyOp-Hook
|
|
27
|
+
|
|
28
|
+
this.#data = op.data
|
|
29
|
+
|
|
30
|
+
ctx.spec = await this.#utility.spec()
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
// #PreFetch-Hook
|
|
34
|
+
|
|
35
|
+
ctx.response = await this.#utility.fetch(ctx)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
// #PostFetch-Hook
|
|
39
|
+
|
|
40
|
+
ctx.result = await this.#utility.response(ctx)
|
|
41
|
+
|
|
42
|
+
// #ModifyResult-Hook
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if(ctx.result.ok) {
|
|
46
|
+
ctx.indata = this.#utility.inward(ctx)
|
|
47
|
+
|
|
48
|
+
if(null != ctx.indata) {
|
|
49
|
+
this.#data = ctx.indata
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
this.#postUpdateHook(ctx)
|
|
53
|
+
|
|
54
|
+
return this
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.#postUpdateHook(ctx)
|
|
58
|
+
|
|
59
|
+
return this.#utility.error(ctx)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
#postUpdateHook(ctx) {
|
|
64
|
+
// #PostOperation-Hook
|
|
65
|
+
}
|
|
66
|
+
} // REMOVED
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
// # CustomUtility
|
|
14
|
+
|
|
15
|
+
this.#options = this.#utility.options({self:this, options, config:Config})
|
|
16
|
+
|
|
17
|
+
this.#features = {
|
|
18
|
+
// #BuildFeature
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// #PostConstruct-Hook
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
options() {
|
|
26
|
+
return { ...this.#options }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
features() {
|
|
30
|
+
return { ...this.#features }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
utility() {
|
|
34
|
+
return { ...this.#utility }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
// <[SLOT]>
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
module.exports = {
|
|
43
|
+
NameSDK
|
|
44
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) $$const.year$$ $$const.Name$$
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) $$const.year$$ $$const.Name$$
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
const Pino = require('pino')
|
|
4
|
+
const PinoPretty = require('pino-pretty')
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class LogFeature {
|
|
8
|
+
version = 'FEATURE_VERSION'
|
|
9
|
+
|
|
10
|
+
#client // SDK client instance
|
|
11
|
+
#options // SDK client feature options
|
|
12
|
+
#config // Feature config from model
|
|
13
|
+
#logger // Pino-style interface
|
|
14
|
+
|
|
15
|
+
constructor(client, options, config) {
|
|
16
|
+
// TOOD: make this a default for all features
|
|
17
|
+
options = options || {}
|
|
18
|
+
options.active = false !== options.active
|
|
19
|
+
|
|
20
|
+
this.#client = client
|
|
21
|
+
this.#options = options
|
|
22
|
+
this.#config = config
|
|
23
|
+
|
|
24
|
+
if(options.active) {
|
|
25
|
+
let logger = options.logger
|
|
26
|
+
|
|
27
|
+
if(null ==logger) {
|
|
28
|
+
let pretty = PinoPretty({
|
|
29
|
+
sync: true,
|
|
30
|
+
ignore: 'ctx',
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
let name = options.name || 'FEATURE_Name'
|
|
34
|
+
let level = options.level || 'info'
|
|
35
|
+
|
|
36
|
+
logger = Pino({ name, level }, pretty)
|
|
37
|
+
}
|
|
38
|
+
this.#logger = logger
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
options() {
|
|
43
|
+
return { ...this.#options }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
client() {
|
|
47
|
+
return this.#client
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
PostConstruct(ctx) {
|
|
52
|
+
this.#loghook('PostConstruct', ctx)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
SetData(ctx) {
|
|
56
|
+
this.#loghook('SetData', ctx)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
GetData(ctx) {
|
|
60
|
+
this.#loghook('GetData', ctx)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
GetQuery(ctx) {
|
|
64
|
+
this.#loghook('GetQuery', ctx)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
PreOperation(ctx) {
|
|
69
|
+
this.#loghook('PreOperation', ctx)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
ModifyOp(ctx) {
|
|
73
|
+
this.#loghook('ModifyOp', ctx)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
PreFetch(ctx) {
|
|
77
|
+
this.#loghook('PreFetch', ctx)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
PostFetch(ctx) {
|
|
81
|
+
this.#loghook('PostFetch', ctx)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
ModifyResult(ctx) {
|
|
85
|
+
this.#loghook('ModifyResult', ctx)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
PostOperation(ctx) {
|
|
89
|
+
this.#loghook('PostOperation', ctx)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
#loghook(hook, ctx, level) {
|
|
94
|
+
level = level || 'info'
|
|
95
|
+
if(this.#logger) {
|
|
96
|
+
this.#logger[level]({hook,op:ctx.op,spec:ctx.spec,ctx})
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
module.exports = {
|
|
103
|
+
LogFeature
|
|
104
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
|
|
2
|
+
const { error } = require('./ErrorUtility')
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function body(ctx) {
|
|
6
|
+
const { op } = ctx
|
|
7
|
+
|
|
8
|
+
let body = undefined
|
|
9
|
+
|
|
10
|
+
if('req' === op.kind) {
|
|
11
|
+
try {
|
|
12
|
+
body = ctx.op.outward(ctx)
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
// TDOD: need error codes and err msg text
|
|
16
|
+
ctx.result.ok = false
|
|
17
|
+
ctx.result.err = err
|
|
18
|
+
return error(ctx)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return body
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = {
|
|
26
|
+
body
|
|
27
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
function error(ctx) {
|
|
3
|
+
|
|
4
|
+
const err = new Error('Error: '+ctx.op.name+': '+(ctx.result.err?.message||'unknown'))
|
|
5
|
+
err.result = ctx.result
|
|
6
|
+
err.spec = ctx.spec
|
|
7
|
+
|
|
8
|
+
// TODO: model option to return instead
|
|
9
|
+
throw err
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
module.exports = {
|
|
14
|
+
error
|
|
15
|
+
}
|