@voxgig/sdkgen 0.24.0 → 0.26.1

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 (98) hide show
  1. package/bin/voxgig-sdkgen +6 -6
  2. package/dist/action/action.js +1 -2
  3. package/dist/action/action.js.map +1 -1
  4. package/dist/action/feature.js +4 -2
  5. package/dist/action/feature.js.map +1 -1
  6. package/dist/action/target.js +4 -2
  7. package/dist/action/target.js.map +1 -1
  8. package/dist/cmp/Entity.js +2 -1
  9. package/dist/cmp/Entity.js.map +1 -1
  10. package/dist/cmp/FeatureHook.js +2 -1
  11. package/dist/cmp/FeatureHook.js.map +1 -1
  12. package/dist/cmp/Main.js.map +1 -1
  13. package/dist/cmp/ReadmeEntity.js +2 -1
  14. package/dist/cmp/ReadmeEntity.js.map +1 -1
  15. package/dist/cmp/Test.d.ts +2 -0
  16. package/dist/cmp/Test.js +17 -0
  17. package/dist/cmp/Test.js.map +1 -0
  18. package/dist/sdkgen.d.ts +2 -1
  19. package/dist/sdkgen.js +17 -28
  20. package/dist/sdkgen.js.map +1 -1
  21. package/dist/tsconfig.tsbuildinfo +1 -1
  22. package/dist/types.d.ts +3 -1
  23. package/dist/types.js +4 -0
  24. package/dist/types.js.map +1 -1
  25. package/model/sdkgen.jsonic +8 -8
  26. package/package.json +8 -6
  27. package/project/.sdk/model/feature/log.jsonic +2 -2
  28. package/project/.sdk/model/feature/test.jsonic +7 -2
  29. package/project/.sdk/model/target/js.jsonic +2 -2
  30. package/project/.sdk/model/target/ts.jsonic +2 -2
  31. package/project/.sdk/src/cmp/js/Main_js.ts +3 -3
  32. package/project/.sdk/src/cmp/js/Quick_js.ts +1 -1
  33. package/project/.sdk/src/cmp/ts/Config_ts.ts +53 -6
  34. package/project/.sdk/src/cmp/ts/EntityOperation_ts.ts +3 -21
  35. package/project/.sdk/src/cmp/ts/Entity_ts.ts +3 -5
  36. package/project/.sdk/src/cmp/ts/Main_ts.ts +22 -12
  37. package/project/.sdk/src/cmp/ts/Package_ts.ts +32 -12
  38. package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +341 -2
  39. package/project/.sdk/src/cmp/ts/TestMain_ts.ts +0 -3
  40. package/project/.sdk/src/cmp/ts/Test_ts.ts +21 -3
  41. package/project/.sdk/src/cmp/ts/fragment/Config.fragment.ts +38 -5
  42. package/project/.sdk/src/cmp/ts/fragment/Entity.fragment.ts +50 -38
  43. package/project/.sdk/src/cmp/ts/fragment/Entity.test.fragment.ts +9 -7
  44. package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.ts +47 -31
  45. package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.ts +49 -31
  46. package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.ts +50 -33
  47. package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.ts +50 -31
  48. package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.ts +51 -31
  49. package/project/.sdk/src/cmp/ts/fragment/Main.fragment.ts +70 -34
  50. package/project/.sdk/src/cmp/ts/tsconfig.json +15 -0
  51. package/project/.sdk/src/cmp/ts/utility_ts.ts +55 -1
  52. package/project/.sdk/tm/ts/src/feature/test/TestFeature.ts +158 -104
  53. package/project/.sdk/tm/ts/src/types.ts +164 -34
  54. package/project/.sdk/tm/ts/src/utility/AuthUtility.ts +8 -2
  55. package/project/.sdk/tm/ts/src/utility/BodyUtility.ts +9 -6
  56. package/project/.sdk/tm/ts/src/utility/CleanUtility.ts +17 -31
  57. package/project/.sdk/tm/ts/src/utility/ContextUtility.ts +14 -54
  58. package/project/.sdk/tm/ts/src/utility/DoneUtility.ts +1 -1
  59. package/project/.sdk/tm/ts/src/utility/ErrorUtility.ts +7 -3
  60. package/project/.sdk/tm/ts/src/utility/FeaturehookUtility.ts +8 -5
  61. package/project/.sdk/tm/ts/src/utility/FetcherUtility.ts +18 -2
  62. package/project/.sdk/tm/ts/src/utility/FindparamUtility.ts +12 -5
  63. package/project/.sdk/tm/ts/src/utility/FullurlUtility.ts +21 -5
  64. package/project/.sdk/tm/ts/src/utility/InitfeatureUtility.ts +3 -1
  65. package/project/.sdk/tm/ts/src/utility/OperationUtility.ts +23 -0
  66. package/project/.sdk/tm/ts/src/utility/OptionsUtility.ts +25 -3
  67. package/project/.sdk/tm/ts/src/utility/ParamsUtility.ts +10 -10
  68. package/project/.sdk/tm/ts/src/utility/PreparePathUtility.ts +18 -0
  69. package/project/.sdk/tm/ts/src/utility/QueryUtility.ts +2 -2
  70. package/project/.sdk/tm/ts/src/utility/ReqformUtility.ts +2 -2
  71. package/project/.sdk/tm/ts/src/utility/RequestUtility.ts +20 -3
  72. package/project/.sdk/tm/ts/src/utility/ResbasicUtility.ts +1 -1
  73. package/project/.sdk/tm/ts/src/utility/ResbodyUtility.ts +5 -3
  74. package/project/.sdk/tm/ts/src/utility/ResformUtility.ts +3 -3
  75. package/project/.sdk/tm/ts/src/utility/ResheadersUtility.ts +9 -7
  76. package/project/.sdk/tm/ts/src/utility/ResponseUtility.ts +35 -4
  77. package/project/.sdk/tm/ts/src/utility/ResultUtility.ts +24 -4
  78. package/project/.sdk/tm/ts/src/utility/SelectionUtility.ts +78 -0
  79. package/project/.sdk/tm/ts/src/utility/SpecUtility.ts +34 -27
  80. package/project/.sdk/tm/ts/src/utility/StructUtility.ts +1117 -509
  81. package/project/.sdk/tm/ts/src/utility/Utility.ts +10 -8
  82. package/project/.sdk/tm/ts/test/exists.test.ts +0 -1
  83. package/project/.sdk/tm/ts/test/runner.ts +12 -10
  84. package/project/.sdk/tm/ts/test/utility/Custom.test.ts +30 -29
  85. package/project/.sdk/tm/ts/test/utility/PrimaryUtility.test.ts +53 -47
  86. package/project/.sdk/tm/ts/test/utility/StructUtility.test.ts +433 -189
  87. package/src/action/action.ts +1 -2
  88. package/src/action/feature.ts +7 -2
  89. package/src/action/target.ts +7 -7
  90. package/src/cmp/Entity.ts +7 -1
  91. package/src/cmp/FeatureHook.ts +6 -1
  92. package/src/cmp/Main.ts +4 -0
  93. package/src/cmp/ReadmeEntity.ts +6 -1
  94. package/src/cmp/Test.ts +31 -0
  95. package/src/sdkgen.ts +19 -34
  96. package/src/types.ts +10 -1
  97. package/project/.sdk/src/cmp/ts/EntityTest_ts.ts +0 -180
  98. package/project/.sdk/tm/ts/src/utility/OperatorUtility.ts +0 -90
@@ -1,81 +1,104 @@
1
1
 
2
- import type { Feature } from './types'
2
+ import { inspect } from 'node:util'
3
3
 
4
- import { Config } from './Config'
4
+ import type { Context, Feature } from './types'
5
+
6
+ import { config } from './Config'
5
7
  import { Utility } from './utility/Utility'
6
8
 
7
9
 
8
10
  import { BaseFeature } from './feature/base/BaseFeature'
9
11
 
10
- const utility = new Utility()
11
12
 
13
+ const stdutil = new Utility()
12
14
 
13
- class ProjectNameSDK {
14
- #options: any
15
- #utility = utility
16
15
 
16
+ class ProjectNameSDK {
17
+ _mode: string = 'live'
18
+ _options: any
19
+ _utility = new Utility()
17
20
  _features: Feature[]
18
-
21
+ _rootctx: Context
19
22
 
20
23
  constructor(options?: any) {
21
24
 
22
- const ctx = this.#utility.contextify({
25
+ this._rootctx = this._utility.makeContext({
23
26
  client: this,
24
- utility: this.#utility,
25
- config: Config,
27
+ utility: this._utility,
28
+ config,
26
29
  options,
30
+ shared: new WeakMap()
27
31
  })
28
32
 
29
- this.#options = this.#utility.options(ctx)
33
+ this._options = this._utility.options(this._rootctx)
34
+
35
+ const struct = this._utility.struct
36
+ const getpath = struct.getpath
37
+ const items = struct.items
30
38
 
31
- ctx.options = this.#options
39
+ if (true === getpath(this._options.feature, 'test.active')) {
40
+ this._mode = 'test'
41
+ }
42
+
43
+ this._rootctx.options = this._options
32
44
 
33
45
  this._features = []
34
46
 
35
- const addfeature = this.#utility.addfeature
36
- const initfeature = this.#utility.initfeature
47
+ const addfeature = this._utility.addfeature
48
+ const initfeature = this._utility.initfeature
37
49
 
38
- // #BuildFeatures
50
+ items(this._options.feature, (fitem: [string, any]) => {
51
+ const fname = fitem[0]
52
+ const fopts = fitem[1]
53
+ if (fopts.active) {
54
+ addfeature(this._rootctx, this._rootctx.config.makeFeature(fname))
55
+ }
56
+ })
39
57
 
40
- if (null != this.#options.extend) {
41
- for (let f of this.#options.extend) {
42
- addfeature(ctx, f)
58
+ if (null != this._options.extend) {
59
+ for (let f of this._options.extend) {
60
+ addfeature(this._rootctx, f)
43
61
  }
44
62
  }
45
63
 
46
64
  for (let f of this._features) {
47
- initfeature(ctx, f)
65
+ initfeature(this._rootctx, f)
48
66
  }
49
67
 
50
- const featurehook = this.#utility.featurehook
51
- featurehook(ctx, 'PostConstruct')
68
+ const featureHook = this._utility.featureHook
69
+ featureHook(this._rootctx, 'PostConstruct')
52
70
  }
53
71
 
54
72
 
55
73
  options() {
56
- return { ...this.#options }
74
+ return this._utility.struct.clone(this._options)
57
75
  }
58
76
 
59
77
 
60
78
  utility() {
61
- return { ...this.#utility }
79
+ return this._utility.struct.clone(this._utility)
62
80
  }
63
81
 
64
82
 
65
83
  // <[SLOT]>
66
84
 
67
85
 
68
- static test(testopts?: any, sdkopts?: any) {
69
- const active = null == testopts ? false : null == testopts.active ? true : !!testopts.active
70
- testopts = testopts || {}
71
- testopts.active = active
86
+ static test(testoptsarg?: any, sdkoptsarg?: any) {
87
+ const struct = stdutil.struct
88
+ const setpath = struct.setpath
89
+ const getdef = struct.getdef
90
+ const clone = struct.clone
91
+ const setprop = struct.setprop
92
+
93
+ const sdkopts = getdef(clone(sdkoptsarg), {})
94
+ const testopts = getdef(clone(testoptsarg), {})
95
+ setprop(testopts, 'active', true)
96
+ setpath(sdkopts, 'feature.test', testopts)
72
97
 
73
- sdkopts = sdkopts || {}
74
- sdkopts.feature = sdkopts.feature || {}
75
- sdkopts.feature.test = testopts || {}
76
- sdkopts.feature.test.active = true
98
+ const testsdk = new ProjectNameSDK(sdkopts)
99
+ testsdk._mode = 'test'
77
100
 
78
- return new ProjectNameSDK(sdkopts)
101
+ return testsdk
79
102
  }
80
103
 
81
104
 
@@ -83,6 +106,19 @@ class ProjectNameSDK {
83
106
  return ProjectNameSDK.test(testopts, sdkopts)
84
107
  }
85
108
 
109
+
110
+ toJSON() {
111
+ return { name: 'ProjectName' }
112
+ }
113
+
114
+ toString() {
115
+ return 'ProjectName ' + this._utility.struct.jsonify(this.toJSON())
116
+ }
117
+
118
+ [inspect.custom]() {
119
+ return this.toString()
120
+ }
121
+
86
122
  }
87
123
 
88
124
 
@@ -91,11 +127,11 @@ class ProjectNameEntity {
91
127
  }
92
128
 
93
129
 
94
-
95
130
  const SDK = ProjectNameSDK
96
131
 
132
+
97
133
  export {
98
- utility,
134
+ stdutil,
99
135
 
100
136
  BaseFeature,
101
137
  ProjectNameEntity,
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "esModuleInterop": true,
4
+ "module": "nodenext",
5
+ "noEmitOnError": true,
6
+ "outDir":"../dist",
7
+ "rootDir":".",
8
+ "resolveJsonModule": true,
9
+ "sourceMap": true,
10
+ "strict": true,
11
+ "target": "es2022",
12
+ "declaration": true,
13
+ "declarationDir": "../dist"
14
+ }
15
+ }
@@ -1,10 +1,64 @@
1
1
 
2
+ import * as Path from 'node:path'
3
+
4
+
5
+ import {
6
+ clone,
7
+ walk,
8
+ } from '@voxgig/struct'
9
+
10
+
11
+ function projectPath(suffix?: string): string {
12
+ return Path.normalize(Path.join(__dirname, '../../..', suffix ?? ''))
13
+ }
14
+
15
+
2
16
  function formatJSONSrc(jsonsrc: string) {
3
17
  return jsonsrc
4
18
  .replace(/([{:\[,])/g, '$1 ')
5
19
  .replace(/([}\]])/g, ' $1')
6
20
  }
7
21
 
22
+
23
+ function formatJson(obj: any, flags?: { line?: boolean, margin?: number }): string {
24
+ const marginSize = flags?.margin ?? 0
25
+ const marginStr = ' '.repeat(marginSize)
26
+
27
+ let json: string
28
+
29
+ if (flags?.line) {
30
+ // One line with spaces for clarity
31
+ json = JSON.stringify(obj)
32
+ .replace(/([{:\[,])/g, '$1 ')
33
+ .replace(/([}\]])/g, ' $1')
34
+ }
35
+ else {
36
+ // Pretty printed with 2-space indentation
37
+ json = JSON.stringify(obj, null, 2)
38
+ }
39
+
40
+ // Add margin to the left of every line
41
+ if (marginSize > 0) {
42
+ json = json.split('\n').map(line => marginStr + line).join('\n')
43
+ }
44
+
45
+ return json
46
+ }
47
+
48
+
49
+ function clean(o: any) {
50
+ return walk(clone(o), (k: any, v: any, p: any) => {
51
+ if (null != k && k.endsWith('$')) {
52
+ delete p[k]
53
+ }
54
+ return v
55
+ })
56
+ }
57
+
58
+
8
59
  export {
9
- formatJSONSrc
60
+ clean,
61
+ formatJSONSrc,
62
+ formatJson,
63
+ projectPath,
10
64
  }
@@ -5,6 +5,9 @@ import type { ProjectNameSDK } from '../../ProjectNameSDK'
5
5
  import { BaseFeature } from '../base/BaseFeature'
6
6
 
7
7
 
8
+ const S_NOT_FOUND = 'Not found'
9
+
10
+
8
11
  class TestFeature extends BaseFeature {
9
12
  version = '0.0.1'
10
13
  name = 'test'
@@ -18,137 +21,188 @@ class TestFeature extends BaseFeature {
18
21
  this._client = ctx.client
19
22
  this._options = options
20
23
 
21
- // console.log('TEST FEATURE', this._options)
22
-
23
- const { struct } = ctx.utility
24
- const { walk, size, setprop, stringify } = struct
24
+ const struct = ctx.utility.struct
25
+ const walk = struct.walk
26
+ const size = struct.size
27
+ const setprop = struct.setprop
25
28
 
26
29
  const entity = this._options.entity
27
30
 
28
- // Set entity ids to correct values
29
- walk(entity, (k: any, v: any, parent: any, path: any) => {
31
+ this._client._mode = 'test'
32
+
33
+ // Ensure entity ids are correct.
34
+ walk(entity, (k: any, v: any, _parent: any, path: any) => {
30
35
  if (2 === size(path)) {
31
36
  setprop(v, 'id', k)
32
37
  }
33
38
  return v
34
39
  })
35
40
 
36
- if (entity) {
37
- ctx.utility.fetcher = (ctx: any, _fullurl: string, _fetchdef: any) => {
38
- const { findparam, struct } = ctx.utility
39
- const { getprop, clone, merge, keysof, size, select, delprop } = struct
40
-
41
-
42
- function respond(status: number, data?: any, res?: any) {
43
- const out = merge([
44
- {
45
- status,
46
- statusText: 'OK',
47
- json: async () => data,
48
- },
49
- res || {}
50
- ])
51
-
52
- const headers: any = out.headers || {}
53
- out.headers = {
54
- forEach(callback: any) {
55
- Object.keys(headers).forEach((key) => {
56
- callback(headers[key], key, this)
57
- })
58
- }
41
+ const self = this
42
+
43
+ function testFetcher(ctx: any, _fullurl: string, _fetchdef: any) {
44
+ const struct = ctx.utility.struct
45
+ const findparam = ctx.utility.findparam
46
+
47
+ const getprop = struct.getprop
48
+ const clone = struct.clone
49
+ const merge = struct.merge
50
+ const getelem = struct.getelem
51
+ const select = struct.select
52
+ const delprop = struct.delprop
53
+ const getdef = struct.getdef
54
+
55
+ function respond(status: number, data?: any, res?: any) {
56
+ const out = merge([
57
+ {
58
+ status,
59
+ statusText: 'OK',
60
+ json: async () => data,
61
+ body: 'not-used',
62
+ },
63
+ getdef(res, {})
64
+ ])
65
+
66
+ const headers: any = getprop(out, 'headers', {})
67
+
68
+ // JS specific iterator.
69
+ out.headers = {
70
+ forEach(callback: any) {
71
+ Object.keys(headers).forEach((key) => {
72
+ callback(headers[key], key, this)
73
+ })
59
74
  }
60
-
61
- return out
62
75
  }
63
76
 
77
+ return out
78
+ }
64
79
 
65
- const op = ctx.op
66
- const entmap = entity[op.entity]
67
-
68
- const qand: any[] = []
69
- const q = { '`$AND`': qand }
70
-
71
- for (let k of keysof(ctx.reqmatch)) {
72
- const v = findparam(ctx, k)
73
- const ka = getprop(op.alias, k)
74
-
75
- let qor: any = [{ [k]: v }]
76
- if (null != ka) {
77
- qor.push({ [ka]: v })
78
- }
79
80
 
80
- qor = { '`$OR`': qor }
81
+ const op = ctx.op
82
+ const entmap = getprop(entity, op.entity, {})
81
83
 
82
- qand.push(qor)
84
+ if ('load' === op.name) {
85
+ const args = self.buildArgs(ctx, op, ctx.reqmatch)
86
+ const found = select(entmap, args)
87
+ const ent = getelem(found, 0)
88
+ if (null == ent) {
89
+ return respond(404, undefined, { statusText: S_NOT_FOUND })
83
90
  }
84
-
85
- if (ctx.ctrl.explain) {
86
- ctx.ctrl.explain.test = { query: q }
91
+ else {
92
+ delprop(ent, '$KEY')
93
+ const out = clone(ent)
94
+ return respond(200, out)
87
95
  }
88
-
89
- if ('load' === op.name) {
90
- const found = select(entmap, q)
91
- const ent = found[0]
92
- if (null == ent) {
93
- return respond(404, undefined, { statusText: 'Not found' })
94
- }
95
- else {
96
- delprop(ent, '$KEY')
97
- return respond(200, clone(ent))
98
- }
96
+ }
97
+ else if ('list' === op.name) {
98
+ const args = self.buildArgs(ctx, op, ctx.reqmatch)
99
+ const found = select(entmap, args)
100
+ if (null == found) {
101
+ return respond(404, undefined, { statusText: S_NOT_FOUND })
99
102
  }
100
- else if ('list' === op.name) {
101
- const found = select(entmap, q)
102
- if (null == found) {
103
- return respond(404, undefined, { statusText: 'Not found' })
104
- }
105
- else {
106
- found.map((ent: any) => delprop(ent, '$KEY'))
107
- return respond(200, clone(found))
108
- }
103
+ else {
104
+ found.map((ent: any) => delprop(ent, '$KEY'))
105
+ const out = clone(found)
106
+ return respond(200, out)
109
107
  }
110
- else if ('update' === op.name) {
111
- const found = select(entmap, q)
112
- const ent = found[0]
113
- if (null == ent) {
114
- return respond(404, undefined, { statusText: 'Not found' })
115
- }
116
- else {
117
- merge([ent, (ctx.reqdata || {})])
118
- delprop(ent, '$KEY')
119
- return respond(200, clone(ent))
120
- }
108
+ }
109
+ else if ('update' === op.name) {
110
+ const args = self.buildArgs(ctx, op, ctx.reqdata)
111
+ const found = select(entmap, args)
112
+ const ent = getelem(found, 0)
113
+ if (null == ent) {
114
+ return respond(404, undefined, { statusText: S_NOT_FOUND })
121
115
  }
122
- else if ('remove' === op.name) {
123
- const found = select(entmap, q)
124
- const ent = found[0]
125
- if (null == ent) {
126
- return respond(404, undefined, { statusText: 'Not found' })
127
- }
128
- else {
129
- delprop(entmap, getprop(ent, 'id'))
130
- return respond(200)
131
- }
116
+ else {
117
+ merge([ent, (ctx.reqdata || {})])
118
+ delprop(ent, '$KEY')
119
+ const out = clone(ent)
120
+ return respond(200, out)
132
121
  }
133
- else if ('create' === op.name) {
134
- const id = findparam(ctx, 'id')
135
- if (null != id) {
136
- const ent = clone(ctx.reqdata)
137
- ent.id = id
138
- setprop(entmap, 'id', ent)
139
- delprop(ent, '$KEY')
140
- return respond(200, clone(ent))
141
- }
142
- else {
143
- return respond(400, undefined, { statusText: 'Missing id' })
144
- }
122
+ }
123
+ else if ('remove' === op.name) {
124
+ const args = self.buildArgs(ctx, op, ctx.reqmatch)
125
+ const found = select(entmap, args)
126
+ const ent = getelem(found, 0)
127
+ if (null == ent) {
128
+ return respond(404, undefined, { statusText: S_NOT_FOUND })
129
+ }
130
+ else {
131
+ delprop(entmap, getprop(ent, 'id'))
132
+ return respond(200)
133
+ }
134
+ }
135
+ else if ('create' === op.name) {
136
+ const args = self.buildArgs(ctx, op, ctx.reqdata)
137
+ let id = findparam(ctx, 'id')
138
+ if (null == id) {
139
+ id = ((1e4 * Math.random() | 0).toString(16) +
140
+ (1e4 * Math.random() | 0).toString(16) +
141
+ (1e4 * Math.random() | 0).toString(16) +
142
+ (1e4 * Math.random() | 0).toString(16)).padEnd(16, '0')
145
143
  }
144
+
145
+ const ent = clone(ctx.reqdata)
146
+ setprop(ent, 'id', id)
147
+ setprop(entmap, id, ent)
148
+ delprop(ent, '$KEY')
149
+ const out = clone(ent)
150
+ return respond(200, out)
146
151
  }
147
152
  }
153
+
154
+ ctx.utility.fetcher = testFetcher
148
155
  }
149
- }
150
156
 
151
157
 
158
+ buildArgs(ctx: any, op: any, args: any): any {
159
+ const struct = ctx.utility.struct
160
+ const findparam = ctx.utility.findparam
161
+
162
+ const getprop = struct.getprop
163
+ const keysof = struct.keysof
164
+ const getpath = struct.getpath
165
+ const getelem = struct.getelem
166
+ const select = struct.select
167
+ const transform = struct.transform
168
+ const isempty = struct.isempty
169
+
170
+ const opname = getprop(op, 'name')
171
+ const alt =
172
+ getelem(getpath(ctx.config, [
173
+ 'entity', getprop(ctx.entity, 'name'), 'op', opname, 'alts']), -1)
174
+
175
+ const reqd = transform(
176
+ select(getpath(alt, ['args', 'param']), { reqd: true }),
177
+ ['`$EACH`', '', '`$KEY.name`']
178
+ )
179
+
180
+ const qand: any[] = []
181
+ const q = { '`$AND`': qand }
182
+
183
+ for (let k of keysof(args)) {
184
+ if ('id' === k || !isempty(select(reqd, k))) {
185
+ const v = findparam(ctx, k)
186
+ const ka = getprop(op.alias, k)
187
+
188
+ let qor: any = [{ [k]: v }]
189
+ if (null != ka) {
190
+ qor.push({ [ka]: v })
191
+ }
192
+
193
+ qor = { '`$OR`': qor }
194
+
195
+ qand.push(qor)
196
+ }
197
+ }
198
+
199
+ if (ctx.ctrl.explain) {
200
+ ctx.ctrl.explain.test = { query: q }
201
+ }
202
+
203
+ return q
204
+ }
205
+ }
152
206
 
153
207
 
154
208
  export {