@voxgig/sdkgen 0.32.2 → 0.32.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/bin/voxgig-sdkgen +1 -1
  2. package/dist/cmp/Readme.js +10 -0
  3. package/dist/cmp/Readme.js.map +1 -1
  4. package/dist/cmp/ReadmeEntity.js +91 -8
  5. package/dist/cmp/ReadmeEntity.js.map +1 -1
  6. package/dist/cmp/ReadmeIntro.js +24 -2
  7. package/dist/cmp/ReadmeIntro.js.map +1 -1
  8. package/dist/cmp/ReadmeModel.js +93 -16
  9. package/dist/cmp/ReadmeModel.js.map +1 -1
  10. package/dist/cmp/ReadmeOptions.js +30 -5
  11. package/dist/cmp/ReadmeOptions.js.map +1 -1
  12. package/dist/cmp/ReadmeRef.d.ts +2 -0
  13. package/dist/cmp/ReadmeRef.js +334 -0
  14. package/dist/cmp/ReadmeRef.js.map +1 -0
  15. package/dist/sdkgen.d.ts +2 -1
  16. package/dist/sdkgen.js +3 -1
  17. package/dist/sdkgen.js.map +1 -1
  18. package/dist/tsconfig.tsbuildinfo +1 -1
  19. package/package.json +1 -1
  20. package/project/.sdk/src/cmp/go/TestDirect_go.ts +2 -2
  21. package/project/.sdk/src/cmp/go/TestEntity_go.ts +3 -3
  22. package/project/.sdk/src/cmp/js/Config_js.ts +62 -23
  23. package/project/.sdk/src/cmp/js/EntityOperation_js.ts +49 -0
  24. package/project/.sdk/src/cmp/js/Entity_js.ts +21 -50
  25. package/project/.sdk/src/cmp/js/MainEntity_js.ts +1 -1
  26. package/project/.sdk/src/cmp/js/Main_js.ts +53 -44
  27. package/project/.sdk/src/cmp/js/Package_js.ts +39 -12
  28. package/project/.sdk/src/cmp/js/Quick_js.ts +6 -10
  29. package/project/.sdk/src/cmp/js/ReadmeQuick_js.ts +101 -5
  30. package/project/.sdk/src/cmp/js/SdkError_js.ts +42 -0
  31. package/project/.sdk/src/cmp/js/TestDirect_js.ts +288 -0
  32. package/project/.sdk/src/cmp/js/TestEntity_js.ts +352 -2
  33. package/project/.sdk/src/cmp/js/TestMain_js.ts +0 -3
  34. package/project/.sdk/src/cmp/js/Test_js.ts +20 -8
  35. package/project/.sdk/src/cmp/js/fragment/Config.fragment.js +55 -0
  36. package/project/.sdk/src/cmp/js/fragment/Direct.test.fragment.js +30 -0
  37. package/project/.sdk/src/cmp/js/fragment/Entity.fragment.js +119 -28
  38. package/project/.sdk/src/cmp/js/fragment/Entity.test.fragment.js +39 -0
  39. package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +89 -45
  40. package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +92 -41
  41. package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +95 -45
  42. package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +95 -43
  43. package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +95 -43
  44. package/project/.sdk/src/cmp/js/fragment/Main.fragment.js +150 -65
  45. package/project/.sdk/src/cmp/js/fragment/SdkError.fragment.js +22 -0
  46. package/project/.sdk/src/cmp/js/utility_js.ts +64 -0
  47. package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +102 -5
  48. package/project/.sdk/src/cmp/ts/TestDirect_ts.ts +2 -2
  49. package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +11 -8
  50. package/src/cmp/Readme.ts +12 -0
  51. package/src/cmp/ReadmeEntity.ts +105 -9
  52. package/src/cmp/ReadmeIntro.ts +30 -2
  53. package/src/cmp/ReadmeModel.ts +101 -18
  54. package/src/cmp/ReadmeOptions.ts +35 -6
  55. package/src/cmp/ReadmeRef.ts +369 -0
  56. package/src/sdkgen.ts +2 -0
@@ -0,0 +1,55 @@
1
+
2
+ const { BaseFeature } = require('./feature/base/BaseFeature')
3
+ // #ImportFeatures
4
+
5
+
6
+ const FEATURE_CLASS = {
7
+ // #FeatureClasses
8
+ }
9
+
10
+
11
+ class Config {
12
+
13
+ makeFeature(fn) {
14
+ const fc = FEATURE_CLASS[fn]
15
+ const fi = new fc()
16
+ // TODO: errors etc
17
+ return fi
18
+ }
19
+
20
+
21
+ main = {
22
+ name: 'ProjectName',
23
+ }
24
+
25
+
26
+ feature = {
27
+ // #FeatureConfigs
28
+ }
29
+
30
+
31
+ options = {
32
+ base: '$$main.kit.info.servers.0.url$$',
33
+
34
+ auth: {
35
+ prefix: '$$main.kit.config.auth.prefix$$',
36
+ },
37
+
38
+ headers: 'HEADERS',
39
+
40
+ entity: {
41
+ // #EntityConfigs
42
+ }
43
+ }
44
+
45
+
46
+ entity = 'ENTITYMAP'
47
+ }
48
+
49
+
50
+ const config = new Config()
51
+
52
+ module.exports = {
53
+ config
54
+ }
55
+
@@ -0,0 +1,30 @@
1
+
2
+ const envlocal = __dirname + '/../../../.env.local'
3
+ require('dotenv').config({ quiet: true, path: [envlocal] })
4
+
5
+ const { test, describe } = require('node:test')
6
+ const assert = require('node:assert')
7
+
8
+
9
+ const { ProjectNameSDK } = require('../../..')
10
+
11
+ const {
12
+ envOverride,
13
+ } = require('../../utility')
14
+
15
+
16
+ describe('EntityNameDirect', async () => {
17
+
18
+ test('direct-exists', async () => {
19
+ const sdk = new ProjectNameSDK({
20
+ system: { fetch: async () => ({}) }
21
+ })
22
+ assert('function' === typeof sdk.direct)
23
+ assert('function' === typeof sdk.prepare)
24
+ })
25
+
26
+ // <[SLOT:direct]>
27
+ })
28
+
29
+
30
+ // <[SLOT:directSetup]>
@@ -1,28 +1,52 @@
1
1
 
2
- class NameEntity {
2
+ const { inspect } = require('node:util')
3
+
4
+ const {
5
+ SdkNameSDK,
6
+ SdkNameEntity,
7
+ } = require('../SdkNameSDK')
8
+
9
+ const {
10
+ Utility
11
+ } = require('../utility/Utility')
12
+
13
+
14
+ // TODO: needs Entity superclass
15
+ class EntityNameEntity {
16
+ name = 'entityname'
17
+
3
18
  #client
4
- #options
5
- #features
6
19
  #utility
20
+ #entopts
7
21
  #data
8
22
  #match
9
-
10
- constructor(client, options) {
11
- options = options || {}
12
- options.active = false !== options.active
23
+
24
+ _entctx
25
+
26
+ constructor(client, entopts) {
27
+ // super()
28
+ entopts = entopts || {}
29
+ entopts.active = false !== entopts.active
13
30
 
14
31
  this.#client = client
15
- this.#options = options
16
- this.#features = client.features()
32
+ this.#entopts = entopts
17
33
  this.#utility = client.utility()
18
34
  this.#data = {}
19
35
  this.#match = {}
20
36
 
21
- // #PostConstructEntity-Hook
37
+ const makeContext = this.#utility.makeContext
38
+
39
+ this._entctx = makeContext({
40
+ entity: this,
41
+ entopts,
42
+ }, client._rootctx)
43
+
44
+ const featureHook = this.#utility.featureHook
45
+ featureHook(this._entctx, 'PostConstructEntity')
22
46
  }
23
47
 
24
- options() {
25
- return { ...this.#options }
48
+ entopts() {
49
+ return { ...this.#entopts }
26
50
  }
27
51
 
28
52
  client() {
@@ -30,37 +54,56 @@ class NameEntity {
30
54
  }
31
55
 
32
56
  make() {
33
- return new NameEntity(this.#client, this.options())
57
+ return new EntityNameEntity(this.#client, this.entopts())
34
58
  }
35
59
 
36
-
60
+
37
61
  data(data) {
38
- // NOTE: data can be mutated.
39
- if(null != data) {
62
+ const struct = this.#utility.struct
63
+ const featureHook = this.#utility.featureHook
40
64
 
41
- // #SetData-Hook
42
-
43
- this.#data = { ...data }
65
+ if (null != data) {
66
+ this.#data = struct.clone(data)
67
+ featureHook(this._entctx, 'SetData')
44
68
  }
45
69
 
46
- let out = { ...this.#data }
47
-
48
- // #GetData-Hook
70
+ featureHook(this._entctx, 'GetData')
71
+ let out = struct.clone(this.#data)
49
72
 
50
73
  return out
51
74
  }
52
75
 
53
-
54
- match() {
55
- // NOTE: match cannot be mutated.
56
- let out = { ...this.#match }
57
76
 
58
- // #GetMatch-Hook
77
+ match(match) {
78
+ const struct = this.#utility.struct
79
+ const featureHook = this.#utility.featureHook
80
+
81
+ if (null != match) {
82
+ this.#match = struct.clone(match)
83
+ featureHook(this._entctx, 'SetMatch')
84
+ }
85
+
86
+ featureHook(this._entctx, 'GetMatch')
87
+ let out = struct.clone(this.#match)
59
88
 
60
89
  return out
61
90
  }
62
91
 
63
92
 
93
+ toJSON() {
94
+ const struct = this.#utility.struct
95
+ return struct.merge([{}, struct.getdef(this.#data, {}), { $entity: 'EntityName' }])
96
+ }
97
+
98
+ toString() {
99
+ return 'EntityName ' + this.#utility.struct.jsonify(this.#data)
100
+ }
101
+
102
+ [inspect.custom]() {
103
+ return this.toString()
104
+ }
105
+
106
+
64
107
  // #LoadOp
65
108
 
66
109
  // #ListOp
@@ -71,9 +114,57 @@ class NameEntity {
71
114
 
72
115
  // #RemoveOp
73
116
 
117
+
118
+ #unexpected(ctx, err) {
119
+ const clean = this.#utility.clean
120
+ const struct = this.#utility.struct
121
+
122
+ const delprop = struct.delprop
123
+ const clone = struct.clone
124
+ const merge = struct.merge
125
+
126
+ const ctrl = ctx.ctrl
127
+
128
+ ctrl.err = err
129
+
130
+ if (ctrl.explain) {
131
+ ctx.ctrl.explain = clean(ctx, ctx.ctrl.explain)
132
+ delprop(ctx.ctrl.explain.result, 'err')
133
+
134
+ if (null != ctx.result && null != ctx.result.err) {
135
+ ctrl.explain.err = clean(ctx, merge([
136
+ clone({ err: ctx.result.err }).err,
137
+ {
138
+ message: ctx.result.err.message,
139
+ stack: ctx.result.err.stack,
140
+ }]))
141
+ }
142
+
143
+ const cleanerr = clean(ctx, merge([
144
+ clone({ err }).err,
145
+ {
146
+ message: err.message,
147
+ stack: err.stack,
148
+ }]))
149
+
150
+ if (null == ctrl.explain.err) {
151
+ ctrl.explain.err = cleanerr
152
+ }
153
+ else if (ctrl.explain.err.message != cleanerr.message) {
154
+ ctrl.explain.unexpected = cleanerr
155
+ }
156
+ }
157
+
158
+ if (false === ctrl.throw) {
159
+ return undefined
160
+ }
161
+
162
+ return err
163
+ }
164
+
74
165
  }
75
166
 
76
167
 
77
168
  module.exports = {
78
- NameEntity
169
+ EntityNameEntity
79
170
  }
@@ -0,0 +1,39 @@
1
+
2
+ const envlocal = __dirname + '/../../../.env.local'
3
+ require('dotenv').config({ quiet: true, path: [envlocal] })
4
+
5
+ const Path = require('node:path')
6
+ const Fs = require('node:fs')
7
+
8
+ const { test, describe } = require('node:test')
9
+ const assert = require('node:assert')
10
+
11
+
12
+ const { ProjectNameSDK, BaseFeature, stdutil } = require('../../..')
13
+
14
+ const {
15
+ envOverride,
16
+ makeCtrl,
17
+ makeMatch,
18
+ makeReqdata,
19
+ makeStepData,
20
+ makeValid,
21
+ } = require('../../utility')
22
+
23
+
24
+ describe('EntityNameEntity', async () => {
25
+
26
+ test('instance', async () => {
27
+ const testsdk = ProjectNameSDK.test()
28
+ const ent = testsdk.EntityName()
29
+ assert(null != ent)
30
+ })
31
+
32
+
33
+ test('basic', async () => {
34
+ // <[SLOT:basic]>
35
+ })
36
+ })
37
+
38
+
39
+ // <[SLOT:basicSetup]>
@@ -1,61 +1,105 @@
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, makeSpec, makeRequest, makeResponse, makeResult, 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
1
 
24
-
25
- // #PreTarget-Hook
2
+ class EntityOperation {
3
+
4
+ #match
5
+ #data
6
+ #utility
7
+
8
+
9
+ // EJECT-START
10
+
11
+ async create(reqdata, ctrl) {
12
+
13
+ const utility = this.#utility
14
+ const {
15
+ makeContext,
16
+ done,
17
+ error,
18
+ featureHook,
19
+ makeTarget,
20
+ makeRequest,
21
+ makeResponse,
22
+ makeResult,
23
+ makeSpec,
24
+ } = utility
25
+
26
+ let fres = undefined
27
+
28
+ let ctx = makeContext({
29
+ opname: 'create',
30
+ ctrl,
31
+ match: this.#match,
32
+ data: this.#data,
33
+ reqdata
34
+ }, this._entctx)
35
+
36
+ try {
37
+ // #PreSelection-Hook
38
+
39
+ ctx.out.target = makeTarget(ctx)
40
+ if (ctx.out.target instanceof Error) {
41
+ return error(ctx, ctx.out.target)
42
+ }
26
43
 
27
- await operator(ctx)
28
44
 
29
-
30
- // #PreSpec-Hook
45
+ // #PreSpec-Hook
31
46
 
32
- this.#data = ctx.op.data
33
-
34
- await makeSpec(ctx)
47
+ ctx.out.spec = makeSpec(ctx)
48
+ if (ctx.out.spec instanceof Error) {
49
+ return error(ctx, ctx.out.spec)
50
+ }
35
51
 
36
-
37
- // #PreRequest-Hook
38
52
 
39
- await makeRequest(ctx)
53
+ // #PreRequest-Hook
40
54
 
41
-
42
- // #PreResponse-Hook
55
+ ctx.out.request = await makeRequest(ctx)
56
+ if (ctx.out.request instanceof Error) {
57
+ return error(ctx, ctx.out.request)
58
+ }
43
59
 
44
- await makeResponse(ctx)
45
60
 
46
-
47
- // #PreResult-Hook
61
+ // #PreResponse-Hook
48
62
 
49
- await makeResult(ctx)
63
+ ctx.out.response = await makeResponse(ctx)
64
+ if (ctx.out.response instanceof Error) {
65
+ return error(ctx, ctx.out.response)
66
+ }
50
67
 
51
68
 
52
- // #PostOperation-Hook
69
+ // #PreResult-Hook
53
70
 
54
- if(null != ctx.result.resdata) {
55
- this.#data = ctx.result.resdata
71
+ ctx.out.result = await makeResult(ctx)
72
+ if (ctx.out.result instanceof Error) {
73
+ return error(ctx, ctx.out.result)
74
+ }
75
+
76
+
77
+ // #PreDone-Hook
78
+
79
+ if (null != ctx.result) {
80
+ if (null != ctx.result.resdata) {
81
+ this.#data = ctx.result.resdata
82
+ }
83
+ }
84
+
85
+ return done(ctx)
86
+ }
87
+ catch (err) {
88
+ // #PreUnexpected-Hook
89
+
90
+ err = this.#unexpected(ctx, err)
91
+
92
+ if (err) {
93
+ throw err
94
+ }
95
+ else {
96
+ return undefined
97
+ }
98
+ }
56
99
  }
57
100
 
58
- return done(ctx)
59
- }
101
+ // EJECT-END
60
102
 
61
- } // REMOVED
103
+
104
+ #unexpected(ctx, err) { return err }
105
+ }
@@ -1,57 +1,108 @@
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, makeSpec, makeRequest, makeResponse, makeResult, 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
1
 
22
- let ctx = { client, entity, op, utility}
2
+ class EntityOperation {
3
+
4
+ #match
5
+ #data
6
+ #utility
7
+
8
+
9
+ // EJECT-START
10
+
11
+ async list(reqmatch, ctrl) {
12
+
13
+ const utility = this.#utility
14
+
15
+ const {
16
+ makeContext,
17
+ done,
18
+ error,
19
+ featureHook,
20
+ makeTarget,
21
+ makeRequest,
22
+ makeResponse,
23
+ makeResult,
24
+ makeSpec,
25
+ } = utility
26
+
27
+ let fres = undefined
28
+
29
+ let ctx = makeContext({
30
+ opname: 'list',
31
+ ctrl,
32
+ match: this.#match,
33
+ data: this.#data,
34
+ reqmatch
35
+ }, this._entctx)
36
+
37
+ try {
38
+ // #PreSelection-Hook
39
+
40
+ ctx.out.target = makeTarget(ctx)
41
+ if (ctx.out.target instanceof Error) {
42
+ return error(ctx, ctx.out.target)
43
+ }
23
44
 
24
-
25
- // #PreTarget-Hook
26
45
 
27
- await operator(ctx)
46
+ // #PreSpec-Hook
28
47
 
29
-
30
- // #PreSpec-Hook
48
+ ctx.out.spec = makeSpec(ctx)
49
+ if (ctx.out.spec instanceof Error) {
50
+ return error(ctx, ctx.out.spec)
51
+ }
31
52
 
32
- this.#match = ctx.op.match
33
-
34
- await makeSpec(ctx)
35
53
 
36
-
37
- // #PreRequest-Hook
54
+ // #PreRequest-Hook
38
55
 
39
- await makeRequest(ctx)
56
+ ctx.out.request = await makeRequest(ctx)
57
+ if (ctx.out.request instanceof Error) {
58
+ return error(ctx, ctx.out.request)
59
+ }
40
60
 
41
-
42
- // #PreResponse-Hook
43
61
 
44
- await makeResponse(ctx)
62
+ // #PreResponse-Hook
45
63
 
46
-
47
- // #PreResult-Hook
64
+ ctx.out.response = await makeResponse(ctx)
65
+ if (ctx.out.response instanceof Error) {
66
+ return error(ctx, ctx.out.response)
67
+ }
68
+
69
+
70
+ // #PreResult-Hook
71
+
72
+ ctx.out.result = await makeResult(ctx)
73
+ if (ctx.out.result instanceof Error) {
74
+ return error(ctx, ctx.out.result)
75
+ }
76
+
77
+
78
+ // #PreDone-Hook
79
+
80
+ if (null != ctx.result) {
81
+ if (null != ctx.result.resmatch) {
82
+ this.#match = ctx.result.resmatch
83
+ }
84
+ }
85
+
86
+ return done(ctx)
87
+ }
88
+ catch (err) {
89
+ // #PreUnexpected-Hook
90
+
91
+ err = this.#unexpected(ctx, err)
92
+
93
+ if (err) {
94
+ throw err
95
+ }
96
+ else {
97
+ return undefined
98
+ }
99
+ }
100
+ }
48
101
 
49
- await makeResult(ctx)
102
+ // EJECT-END
50
103
 
51
104
 
52
- // #PostOperation-Hook
105
+ #unexpected(_ctx, err) { return err }
53
106
 
54
- return done(ctx)
55
107
  }
56
108
 
57
- } // REMOVED