@voxgig/sdkgen 0.21.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.
- package/bin/voxgig-sdkgen +12 -4
- package/dist/action/action.d.ts +4 -0
- package/dist/action/action.js +35 -0
- package/dist/action/action.js.map +1 -0
- package/dist/action/feature.d.ts +4 -2
- package/dist/action/feature.js +57 -38
- package/dist/action/feature.js.map +1 -1
- package/dist/action/target.d.ts +4 -2
- package/dist/action/target.js +136 -45
- package/dist/action/target.js.map +1 -1
- package/dist/cmp/Entity.js +5 -0
- package/dist/cmp/Entity.js.map +1 -1
- package/dist/cmp/Feature.js +5 -0
- package/dist/cmp/Feature.js.map +1 -1
- package/dist/cmp/Main.js +6 -6
- package/dist/cmp/Main.js.map +1 -1
- package/dist/cmp/ReadmeIntro.js.map +1 -1
- package/dist/cmp/Top.d.ts +2 -0
- package/dist/cmp/Top.js +23 -0
- package/dist/cmp/Top.js.map +1 -0
- package/dist/sdkgen.d.ts +10 -4
- package/dist/sdkgen.js +54 -10
- package/dist/sdkgen.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +16 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utility.d.ts +3 -3
- package/dist/utility.js +7 -8
- package/dist/utility.js.map +1 -1
- package/package.json +6 -10
- package/project/.sdk/model/feature/README.md +2 -0
- package/project/.sdk/model/feature/log.jsonic +7 -4
- package/project/.sdk/model/feature/test.jsonic +26 -0
- package/project/.sdk/model/target/ts.jsonic +1 -0
- package/project/.sdk/src/cmp/ts/Config_ts.ts +7 -2
- package/project/.sdk/src/cmp/ts/EntityOperation_ts.ts +67 -0
- package/project/.sdk/src/cmp/ts/EntityTest_ts.ts +180 -0
- package/project/.sdk/src/cmp/ts/Entity_ts.ts +41 -66
- package/project/.sdk/src/cmp/ts/{MainEntity_ts.ts.off → MainEntity_ts.ts} +2 -2
- package/project/.sdk/src/cmp/ts/Main_ts.ts +52 -53
- package/project/.sdk/src/cmp/ts/Package_ts.ts +12 -7
- package/project/.sdk/src/cmp/ts/{ReadmeInstall_ts.ts.off → ReadmeInstall_ts.ts} +1 -1
- package/project/.sdk/src/cmp/ts/{ReadmeQuick_ts.ts.off → ReadmeQuick_ts.ts} +1 -2
- package/project/.sdk/src/cmp/ts/{TestMain_ts.ts.off → TestMain_ts.ts} +1 -1
- package/project/.sdk/src/cmp/ts/Test_ts.ts +20 -0
- package/project/.sdk/src/cmp/ts/fragment/Config.fragment.ts +8 -1
- package/project/.sdk/src/cmp/ts/fragment/Entity.fragment.ts +164 -0
- package/project/.sdk/src/cmp/ts/fragment/Entity.test.fragment.ts +37 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.ts +91 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.ts +92 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.ts +96 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.ts +96 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.ts +95 -0
- package/project/.sdk/src/cmp/ts/fragment/Main.fragment.ts +107 -0
- package/project/.sdk/src/cmp/ts/utility_ts.ts +10 -0
- package/project/.sdk/tm/ts/src/feature/base/BaseFeature.ts +43 -0
- package/project/.sdk/tm/ts/src/feature/log/LogFeature.ts +109 -0
- package/project/.sdk/tm/ts/src/feature/test/TestFeature.ts +159 -0
- package/project/.sdk/tm/ts/src/tsconfig.json +1 -1
- package/project/.sdk/tm/ts/src/types.ts +114 -0
- package/project/.sdk/tm/ts/src/utility/AddfeatureUtility.ts +47 -0
- package/project/.sdk/tm/ts/src/utility/AuthUtility.ts +42 -0
- package/project/.sdk/tm/ts/src/utility/BodyUtility.ts +29 -0
- package/project/.sdk/tm/ts/src/utility/CleanUtility.ts +50 -0
- package/project/.sdk/tm/ts/src/utility/ContextUtility.ts +67 -0
- package/project/.sdk/tm/ts/src/utility/DoneUtility.ts +28 -0
- package/project/.sdk/tm/ts/src/utility/ErrorUtility.ts +59 -0
- package/project/.sdk/tm/ts/src/utility/FeaturehookUtility.ts +26 -0
- package/project/.sdk/tm/ts/src/utility/FetcherUtility.ts +17 -0
- package/project/.sdk/tm/ts/src/utility/FindparamUtility.ts +54 -0
- package/project/.sdk/tm/ts/src/utility/FullurlUtility.ts +46 -0
- package/project/.sdk/tm/ts/src/utility/HeadersUtility.ts +24 -0
- package/project/.sdk/tm/ts/src/utility/InitfeatureUtility.ts +13 -0
- package/project/.sdk/tm/ts/src/utility/JoinurlUtility.ts +15 -0
- package/project/.sdk/tm/ts/src/utility/MethodUtility.ts +25 -0
- package/project/.sdk/tm/ts/src/utility/OperatorUtility.ts +90 -0
- package/project/.sdk/tm/ts/src/utility/OptionsUtility.ts +72 -0
- package/project/.sdk/tm/ts/src/utility/ParamsUtility.ts +37 -0
- package/project/.sdk/tm/ts/src/utility/QueryUtility.ts +27 -0
- package/project/.sdk/tm/ts/src/utility/ReqformUtility.ts +33 -0
- package/project/.sdk/tm/ts/src/utility/RequestUtility.ts +66 -0
- package/project/.sdk/tm/ts/src/utility/ResbasicUtility.ts +34 -0
- package/project/.sdk/tm/ts/src/utility/ResbodyUtility.ts +19 -0
- package/project/.sdk/tm/ts/src/utility/ResformUtility.ts +36 -0
- package/project/.sdk/tm/ts/src/utility/ResheadersUtility.ts +23 -0
- package/project/.sdk/tm/ts/src/utility/ResponseUtility.ts +30 -0
- package/project/.sdk/tm/ts/src/utility/ResultUtility.ts +36 -0
- package/project/.sdk/tm/ts/src/utility/SpecUtility.ts +61 -0
- package/project/.sdk/tm/ts/src/utility/StructUtility.ts +2499 -0
- package/project/.sdk/tm/ts/src/utility/Utility.ts +88 -0
- package/project/.sdk/tm/ts/test/exists.test.ts +17 -0
- package/project/.sdk/tm/ts/test/runner.ts +402 -0
- package/project/.sdk/tm/ts/test/tsconfig.json +1 -1
- package/project/.sdk/tm/ts/test/utility/Custom.test.ts +62 -0
- package/project/.sdk/tm/ts/test/utility/PrimaryUtility.test.ts +244 -0
- package/project/.sdk/tm/ts/test/utility/StructUtility.test.ts +678 -0
- package/project/.sdk/tm/ts/test/utility/index.ts +9 -0
- package/project/.sdk/tm/ts/test/utility.ts +86 -0
- package/src/action/action.ts +54 -0
- package/src/action/feature.ts +83 -47
- package/src/action/target.ts +173 -53
- package/src/cmp/Entity.ts +6 -0
- package/src/cmp/Feature.ts +6 -3
- package/src/cmp/Main.ts +7 -8
- package/src/cmp/ReadmeIntro.ts +1 -1
- package/src/sdkgen.ts +86 -12
- package/src/types.ts +33 -0
- package/src/utility.ts +5 -3
- package/project/.sdk/model/feature/limit.jsonic +0 -12
- package/project/.sdk/model/feature/page.jsonic +0 -9
- package/project/.sdk/model/feature/telemetry.jsonic +0 -10
- package/project/.sdk/src/cmp/ts/Main_ts.ts~ +0 -88
- package/project/.sdk/src/cmp/ts/Package_ts.ts~ +0 -58
- package/project/.sdk/src/cmp/ts/Quick_ts.ts.off +0 -82
- package/project/.sdk/src/cmp/ts/TestAcceptEntity_ts.ts.off +0 -13
- package/project/.sdk/src/cmp/ts/TestAccept_ts.ts.off +0 -18
- package/project/.sdk/src/cmp/ts/Test_ts.ts.off +0 -24
- package/project/.sdk/src/cmp/ts/fragment/Entity.fragment.js +0 -79
- package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.js +0 -61
- package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.js +0 -57
- package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.js +0 -61
- package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.js +0 -61
- package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.js +0 -61
- package/project/.sdk/src/cmp/ts/fragment/Main.fragment.js +0 -67
- package/project/.sdk/tm/ts/test/README.md~ +0 -2
- /package/project/.sdk/src/cmp/ts/{TestEntity_ts.ts.off → TestEntity_ts.ts} +0 -0
package/src/cmp/Main.ts
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, names, Copy
|
|
2
|
+
import { cmp, names, Copy } from 'jostraca'
|
|
3
3
|
|
|
4
4
|
import { requirePath } from '../utility'
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
const Main = cmp(function Main(props: any) {
|
|
8
8
|
const { target, ctx$ } = props
|
|
9
|
-
const { model } = ctx$
|
|
10
|
-
|
|
11
|
-
names(model, model.name)
|
|
12
|
-
// console.log('MODEL name', model.name, model.Name)
|
|
9
|
+
const { model, stdrep, log } = ctx$
|
|
13
10
|
|
|
14
11
|
Copy({
|
|
12
|
+
// This folder is relative to the .sdk folder in the project, as that is where
|
|
13
|
+
// the sdk is generated from.
|
|
15
14
|
from: 'tm/' + target.name,
|
|
16
15
|
replace: {
|
|
17
|
-
|
|
16
|
+
...stdrep,
|
|
18
17
|
}
|
|
19
18
|
})
|
|
20
19
|
|
|
21
|
-
// const Main_sdk = require(resolvePath(ctx$, `cmp/${target.name}/Main_${target.name}`))
|
|
22
20
|
const Main_sdk = requirePath(ctx$, `cmp/${target.name}/Main_${target.name}`)
|
|
23
21
|
|
|
24
|
-
Main_sdk['Main']({ model, target })
|
|
22
|
+
Main_sdk['Main']({ model, target, stdrep })
|
|
25
23
|
|
|
24
|
+
log.info({ point: 'generate-main', target, note: 'target:' + target.name })
|
|
26
25
|
})
|
|
27
26
|
|
|
28
27
|
|
package/src/cmp/ReadmeIntro.ts
CHANGED
package/src/sdkgen.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* Copyright (c) 2024 Richard Rodger, MIT License */
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import Fs from 'node:fs'
|
|
4
|
+
import Path from 'node:path'
|
|
4
5
|
|
|
5
6
|
import { prettyPino, Pino } from '@voxgig/util'
|
|
6
7
|
|
|
@@ -8,6 +9,16 @@ import { Jsonic } from 'jsonic'
|
|
|
8
9
|
import * as JostracaModule from 'jostraca'
|
|
9
10
|
import { Aontu, Context } from 'aontu'
|
|
10
11
|
|
|
12
|
+
import {
|
|
13
|
+
showChanges,
|
|
14
|
+
getdlog,
|
|
15
|
+
} from '@voxgig/util'
|
|
16
|
+
|
|
17
|
+
import type {
|
|
18
|
+
ActionContext,
|
|
19
|
+
ActionResult,
|
|
20
|
+
} from './types'
|
|
21
|
+
|
|
11
22
|
import { SdkGenError, requirePath } from './utility'
|
|
12
23
|
|
|
13
24
|
import { Main } from './cmp/Main'
|
|
@@ -19,8 +30,17 @@ import { ReadmeOptions } from './cmp/ReadmeOptions'
|
|
|
19
30
|
import { ReadmeEntity } from './cmp/ReadmeEntity'
|
|
20
31
|
import { FeatureHook } from './cmp/FeatureHook'
|
|
21
32
|
|
|
22
|
-
|
|
23
|
-
import {
|
|
33
|
+
|
|
34
|
+
import {
|
|
35
|
+
action_target,
|
|
36
|
+
target_add,
|
|
37
|
+
} from './action/target'
|
|
38
|
+
|
|
39
|
+
import {
|
|
40
|
+
action_feature,
|
|
41
|
+
feature_add,
|
|
42
|
+
} from './action/feature'
|
|
43
|
+
|
|
24
44
|
|
|
25
45
|
|
|
26
46
|
// TODO: use shape
|
|
@@ -37,7 +57,7 @@ type SdkGenOptions = {
|
|
|
37
57
|
name: string
|
|
38
58
|
}
|
|
39
59
|
debug?: boolean | string
|
|
40
|
-
pino?: ReturnType<typeof Pino>
|
|
60
|
+
pino?: any, // ReturnType<typeof Pino>
|
|
41
61
|
now?: () => number
|
|
42
62
|
|
|
43
63
|
// TODO: match Jostraca
|
|
@@ -45,6 +65,8 @@ type SdkGenOptions = {
|
|
|
45
65
|
txt?: any
|
|
46
66
|
bin?: any
|
|
47
67
|
}
|
|
68
|
+
|
|
69
|
+
dryrun?: boolean
|
|
48
70
|
}
|
|
49
71
|
|
|
50
72
|
|
|
@@ -57,12 +79,27 @@ const ACTION_MAP: any = {
|
|
|
57
79
|
}
|
|
58
80
|
|
|
59
81
|
|
|
82
|
+
const dlog = getdlog('sdkgen', __filename)
|
|
83
|
+
|
|
84
|
+
|
|
60
85
|
function SdkGen(opts: SdkGenOptions) {
|
|
61
86
|
const fs = opts.fs || Fs
|
|
62
87
|
const folder = opts.folder || '../'
|
|
63
88
|
const now = opts.now || (() => Date.now())
|
|
64
89
|
|
|
65
|
-
const
|
|
90
|
+
const jopts = {
|
|
91
|
+
now,
|
|
92
|
+
control: {
|
|
93
|
+
dryrun: opts.dryrun
|
|
94
|
+
},
|
|
95
|
+
existing: {
|
|
96
|
+
txt: {
|
|
97
|
+
merge: true
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const jostraca = Jostraca(jopts)
|
|
66
103
|
|
|
67
104
|
const pino = prettyPino('sdkgen', opts)
|
|
68
105
|
const log = pino.child({ cmp: 'sdkgen' })
|
|
@@ -72,7 +109,7 @@ function SdkGen(opts: SdkGenOptions) {
|
|
|
72
109
|
const start = Date.now()
|
|
73
110
|
const { model, config } = spec
|
|
74
111
|
|
|
75
|
-
log.info({ point: 'generate-start', start })
|
|
112
|
+
log.info({ point: 'generate-start', start, note: opts.dryrun ? '** DRY RUN **' : '' })
|
|
76
113
|
log.debug({ point: 'generate-spec', spec })
|
|
77
114
|
|
|
78
115
|
let Root = spec.root
|
|
@@ -89,10 +126,19 @@ function SdkGen(opts: SdkGenOptions) {
|
|
|
89
126
|
log: log.child({ cmp: 'jostraca' }),
|
|
90
127
|
meta: { spec },
|
|
91
128
|
debug: opts.debug,
|
|
92
|
-
existing: opts.existing
|
|
129
|
+
existing: opts.existing,
|
|
93
130
|
}
|
|
94
131
|
|
|
95
|
-
await jostraca.generate(jopts, () => Root({ model }))
|
|
132
|
+
const jres = await jostraca.generate(jopts, () => Root({ model }))
|
|
133
|
+
|
|
134
|
+
showChanges(jopts.log, 'generate-result', jres, Path.dirname(process.cwd()))
|
|
135
|
+
|
|
136
|
+
const dlogs = dlog.log()
|
|
137
|
+
if (0 < dlogs.length) {
|
|
138
|
+
for (let dlogentry of dlogs) {
|
|
139
|
+
log.debug({ point: 'generate-warning', dlogentry, note: String(dlogentry) })
|
|
140
|
+
}
|
|
141
|
+
}
|
|
96
142
|
|
|
97
143
|
log.info({ point: 'generate-end' })
|
|
98
144
|
|
|
@@ -110,17 +156,28 @@ function SdkGen(opts: SdkGenOptions) {
|
|
|
110
156
|
throw new SdkGenError('Unknown action: ' + actname)
|
|
111
157
|
}
|
|
112
158
|
|
|
159
|
+
const ctx = resolveActionContext()
|
|
160
|
+
|
|
161
|
+
await action(pargs, ctx)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
function resolveActionContext(): ActionContext {
|
|
166
|
+
|
|
167
|
+
// TODO: use AsyncLocalStorage to avoid reloading model
|
|
113
168
|
const { model, tree } = resolveModel()
|
|
114
169
|
|
|
115
|
-
const ctx = {
|
|
170
|
+
const ctx: ActionContext = {
|
|
116
171
|
fs: () => fs,
|
|
117
172
|
log,
|
|
118
173
|
folder: '.', // The `generate` folder,
|
|
119
174
|
model,
|
|
120
175
|
tree,
|
|
176
|
+
jostraca,
|
|
177
|
+
opts,
|
|
121
178
|
}
|
|
122
179
|
|
|
123
|
-
|
|
180
|
+
return ctx
|
|
124
181
|
}
|
|
125
182
|
|
|
126
183
|
|
|
@@ -179,10 +236,28 @@ function SdkGen(opts: SdkGenOptions) {
|
|
|
179
236
|
}
|
|
180
237
|
|
|
181
238
|
|
|
239
|
+
const target = {
|
|
240
|
+
add: async (targets: string[]): Promise<ActionResult> => {
|
|
241
|
+
const ctx = resolveActionContext()
|
|
242
|
+
return target_add(targets, ctx)
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const feature = {
|
|
247
|
+
add: async (features: string[]): Promise<ActionResult> => {
|
|
248
|
+
const ctx = resolveActionContext()
|
|
249
|
+
return feature_add(features, ctx)
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
182
255
|
return {
|
|
183
|
-
pino,
|
|
256
|
+
pino: pino as any,
|
|
184
257
|
generate,
|
|
185
258
|
action,
|
|
259
|
+
target,
|
|
260
|
+
feature,
|
|
186
261
|
}
|
|
187
262
|
|
|
188
263
|
}
|
|
@@ -267,7 +342,6 @@ export const each: (subject?: any, apply?: any) => any = JostracaModule.each
|
|
|
267
342
|
export const snakify: (input: any[] | string) => string = JostracaModule.snakify
|
|
268
343
|
export const camelify: (input: any[] | string) => string = JostracaModule.camelify
|
|
269
344
|
export const kebabify: (input: any[] | string) => string = JostracaModule.kebabify
|
|
270
|
-
export const select: (key: any, map: Record<string, Function>) => any = JostracaModule.select
|
|
271
345
|
export const cmap: (o: any, p: any) => any = JostracaModule.cmap
|
|
272
346
|
export const vmap: (o: any, p: any) => any = JostracaModule.vmap
|
|
273
347
|
export const get: (root: any, path: string | string[]) => any = JostracaModule.get
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
|
|
2
|
+
import Fs from 'node:fs'
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
JostracaResult
|
|
6
|
+
} from 'jostraca'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
type FsUtil = typeof Fs
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
type ActionContext = {
|
|
13
|
+
fs: () => FsUtil,
|
|
14
|
+
log: any,
|
|
15
|
+
folder: string,
|
|
16
|
+
model: any,
|
|
17
|
+
tree: any,
|
|
18
|
+
opts: any,
|
|
19
|
+
jostraca: any
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
type ActionResult = {
|
|
24
|
+
jres: JostracaResult
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
export type {
|
|
30
|
+
ActionContext,
|
|
31
|
+
ActionResult,
|
|
32
|
+
}
|
|
33
|
+
|
package/src/utility.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
|
|
2
2
|
import Path from 'node:path'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import { JostracaResult } from 'jostraca'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
function resolvePath(ctx$: any, path: string): any {
|
|
7
9
|
const fullpath = Path.join(ctx$.folder, '.sdk', 'dist', path)
|
|
8
10
|
return fullpath
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
function requirePath(ctx$: any, path: string, flags?: { ignore?: boolean }): any {
|
|
13
15
|
const fullpath = resolvePath(ctx$, path)
|
|
14
16
|
const ignore = null == flags?.ignore ? false : flags.ignore
|
|
15
17
|
|
|
@@ -1,88 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
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
|
-
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
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
|
-
}
|