@voxgig/apidef 3.1.1 → 3.4.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.
Files changed (40) hide show
  1. package/dist/apidef.d.ts +1 -1
  2. package/dist/apidef.js.map +1 -1
  3. package/dist/builder/flow/flowHeuristic01.js +4 -4
  4. package/dist/builder/flow/flowHeuristic01.js.map +1 -1
  5. package/dist/guide/guide.js +3 -5
  6. package/dist/guide/guide.js.map +1 -1
  7. package/dist/guide/heuristic01.js +42 -34
  8. package/dist/guide/heuristic01.js.map +1 -1
  9. package/dist/model.d.ts +9 -4
  10. package/dist/transform/args.js +8 -7
  11. package/dist/transform/args.js.map +1 -1
  12. package/dist/transform/field.js +10 -10
  13. package/dist/transform/field.js.map +1 -1
  14. package/dist/transform/flowstep.js +20 -14
  15. package/dist/transform/flowstep.js.map +1 -1
  16. package/dist/transform/operation.js +5 -5
  17. package/dist/transform/operation.js.map +1 -1
  18. package/dist/transform/select.js +12 -12
  19. package/dist/transform/select.js.map +1 -1
  20. package/dist/transform/top.js +1 -1
  21. package/dist/transform/top.js.map +1 -1
  22. package/dist/types.d.ts +1 -1
  23. package/dist/utility.d.ts +1 -0
  24. package/dist/utility.js +71 -36
  25. package/dist/utility.js.map +1 -1
  26. package/model/apidef.jsonic +7 -4
  27. package/package.json +6 -6
  28. package/src/apidef.ts +2 -6
  29. package/src/builder/flow/flowHeuristic01.ts +5 -5
  30. package/src/guide/guide.ts +7 -10
  31. package/src/guide/heuristic01.ts +37 -142
  32. package/src/model.ts +13 -5
  33. package/src/transform/args.ts +9 -8
  34. package/src/transform/field.ts +11 -11
  35. package/src/transform/flowstep.ts +21 -14
  36. package/src/transform/operation.ts +6 -6
  37. package/src/transform/select.ts +13 -13
  38. package/src/transform/top.ts +2 -2
  39. package/src/types.ts +1 -1
  40. package/src/utility.ts +88 -42
@@ -21,7 +21,7 @@ import type {
21
21
  OpName,
22
22
  ModelOp,
23
23
  ModelEntity,
24
- ModelAlt,
24
+ ModelTarget,
25
25
  ModelArg,
26
26
  } from '../model'
27
27
 
@@ -38,16 +38,16 @@ const argsTransform: Transform = async function(
38
38
 
39
39
  each(kit.entity, (ment: ModelEntity, entname: string) => {
40
40
  each(ment.op, (mop: ModelOp, opname: OpName) => {
41
- each(mop.alts, (malt: ModelAlt) => {
41
+ each(mop.targets, (mtarget: ModelTarget) => {
42
42
  const argdefs: ParameterDef[] = []
43
43
 
44
- const pathdef: PathDef = def.paths[malt.orig]
44
+ const pathdef: PathDef = def.paths[mtarget.orig]
45
45
  argdefs.push(...(pathdef.parameters ?? []))
46
46
 
47
- const opdef: MethodDef = (pathdef as any)[malt.method.toLowerCase()]
47
+ const opdef: MethodDef = (pathdef as any)[mtarget.method.toLowerCase()]
48
48
  argdefs.push(...(opdef.parameters ?? []))
49
49
 
50
- resolveArgs(ment, mop, malt, argdefs)
50
+ resolveArgs(ment, mop, mtarget, argdefs)
51
51
  })
52
52
 
53
53
  })
@@ -67,11 +67,11 @@ const ARG_KIND: Record<string, ModelArg["kind"]> = {
67
67
  }
68
68
 
69
69
 
70
- function resolveArgs(ment: ModelEntity, mop: ModelOp, malt: ModelAlt, argdefs: ParameterDef[]) {
70
+ function resolveArgs(ment: ModelEntity, mop: ModelOp, mtarget: ModelTarget, argdefs: ParameterDef[]) {
71
71
  each(argdefs, (argdef: ParameterDef) => {
72
72
  const orig = depluralize(snakify(argdef.name))
73
73
  const kind = ARG_KIND[argdef.in] ?? 'query'
74
- const name = malt.rename[kind]?.[orig] ?? orig
74
+ const name = mtarget.rename[kind]?.[orig] ?? orig
75
75
  const marg: ModelArg = {
76
76
  name,
77
77
  orig,
@@ -85,7 +85,8 @@ function resolveArgs(ment: ModelEntity, mop: ModelOp, malt: ModelAlt, argdefs: P
85
85
  }
86
86
 
87
87
  // insert sorted by name
88
- let kindargs = (malt.args[marg.kind] = malt.args[marg.kind] ?? [])
88
+ const argsKey = (marg.kind === 'param' ? 'params' : marg.kind) as keyof typeof mtarget.args
89
+ let kindargs = (mtarget.args[argsKey] = mtarget.args[argsKey] ?? [])
89
90
  kindargs.push(marg)
90
91
  kindargs.sort((a: ModelArg, b: ModelArg) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)
91
92
  })
@@ -20,7 +20,7 @@ import type {
20
20
  OpName,
21
21
  ModelOp,
22
22
  ModelEntity,
23
- ModelAlt,
23
+ ModelTarget,
24
24
  ModelField,
25
25
  } from '../model'
26
26
 
@@ -43,10 +43,10 @@ const fieldTransform: Transform = async function(
43
43
  for (let opname of opFieldPrecedence) {
44
44
  const mop = ment.op[opname]
45
45
  if (mop) {
46
- const malts = mop.alts
46
+ const mtargets = mop.targets
47
47
 
48
- for (let malt of malts) {
49
- const opfields = resolveOpFields(ment, mop, malt, def)
48
+ for (let mtarget of mtargets) {
49
+ const opfields = resolveOpFields(ment, mop, mtarget, def)
50
50
 
51
51
  for (let opfield of opfields) {
52
52
  if (!seen[opfield.name]) {
@@ -54,7 +54,7 @@ const fieldTransform: Transform = async function(
54
54
  seen[opfield.name] = opfield
55
55
  }
56
56
  else {
57
- mergeField(ment, mop, malt, def, seen[opfield.name], opfield)
57
+ mergeField(ment, mop, mtarget, def, seen[opfield.name], opfield)
58
58
  }
59
59
  }
60
60
  }
@@ -76,11 +76,11 @@ const fieldTransform: Transform = async function(
76
76
  function resolveOpFields(
77
77
  ment: ModelEntity,
78
78
  mop: ModelOp,
79
- malt: ModelAlt,
79
+ mtarget: ModelTarget,
80
80
  def: any
81
81
  ): ModelField[] {
82
82
  const mfields: ModelField[] = []
83
- const fielddefs = findFieldDefs(ment, mop, malt, def)
83
+ const fielddefs = findFieldDefs(ment, mop, mtarget, def)
84
84
 
85
85
  for (let fielddef of fielddefs) {
86
86
  const fieldname = (fielddef as any).key$ as string
@@ -100,13 +100,13 @@ function resolveOpFields(
100
100
  function findFieldDefs(
101
101
  _ment: ModelEntity,
102
102
  mop: ModelOp,
103
- malt: ModelAlt,
103
+ mtarget: ModelTarget,
104
104
  def: any
105
105
  ): SchemaDef[] {
106
106
  const fielddefs: SchemaDef[] = []
107
- const pathdef = def.paths[malt.orig]
107
+ const pathdef = def.paths[mtarget.orig]
108
108
 
109
- const method = malt.method.toLowerCase()
109
+ const method = mtarget.method.toLowerCase()
110
110
  const opdef: any = pathdef[method]
111
111
 
112
112
  if (opdef) {
@@ -160,7 +160,7 @@ function findFieldDefs(
160
160
  function mergeField(
161
161
  ment: ModelEntity,
162
162
  mop: ModelOp,
163
- malt: ModelAlt,
163
+ mtarget: ModelTarget,
164
164
  def: any,
165
165
  exisingField: ModelField,
166
166
  newField: ModelField
@@ -123,10 +123,17 @@ const createStep: MakeFlowStep = (
123
123
  args: Record<string, any>
124
124
  ) => {
125
125
  if (null != opmap.update) {
126
- // Use last alt as most generic
127
- const alt = getelem(opmap.update.alts, -1)
126
+ // Use last target as most generic
127
+ const target = getelem(opmap.update.targets, -1)
128
128
  const step = newFlowStep('create', args)
129
129
 
130
+ each(target.args.params, (param: any) => {
131
+ // id should not be here in the first place
132
+ if ('id' !== param.name) {
133
+ step.match[param.name] = args.input?.[param.name] ?? param.name.replace(/_id/, '') + '01'
134
+ }
135
+ })
136
+
130
137
  flow.step.push(step)
131
138
  }
132
139
  }
@@ -139,11 +146,11 @@ const listStep: MakeFlowStep = (
139
146
  args: Record<string, any>
140
147
  ) => {
141
148
  if (null != opmap.list) {
142
- // Use last alt as most generic
143
- const alt = getelem(opmap.list.alts, -1)
149
+ // Use last target as most generic
150
+ const target = getelem(opmap.list.targets, -1)
144
151
  const step = newFlowStep('list', args)
145
152
 
146
- each(alt.args.param, (param: any) => {
153
+ each(target.args.params, (param: any) => {
147
154
  step.match[param.name] = args.input?.[param.name] ?? param.name.replace(/_id/, '') + '01'
148
155
  })
149
156
 
@@ -159,11 +166,11 @@ const updateStep: MakeFlowStep = (
159
166
  args: Record<string, any>
160
167
  ) => {
161
168
  if (null != opmap.update) {
162
- // Use last alt as most generic
163
- const alt = getelem(opmap.update.alts, -1)
169
+ // Use last target as most generic
170
+ const target = getelem(opmap.update.targets, -1)
164
171
  const step = newFlowStep('update', args)
165
172
 
166
- each(alt.args.param, (param: any) => {
173
+ each(target.args.params, (param: any) => {
167
174
  if ('id' === param.name) {
168
175
  step.data.id = args.input?.id ?? ent.name + '01'
169
176
  }
@@ -184,11 +191,11 @@ const loadStep: MakeFlowStep = (
184
191
  args: Record<string, any>
185
192
  ) => {
186
193
  if (null != opmap.load) {
187
- // Use last alt as most generic
188
- const alt = getelem(opmap.load.alts, -1)
194
+ // Use last target as most generic
195
+ const target = getelem(opmap.load.targets, -1)
189
196
  const step = newFlowStep('load', args)
190
197
 
191
- each(alt.args.param, (param: any) => {
198
+ each(target.args.params, (param: any) => {
192
199
  if ('id' === param.name) {
193
200
  step.match.id = args.input?.id ?? ent.name + '01'
194
201
  }
@@ -209,11 +216,11 @@ const removeStep: MakeFlowStep = (
209
216
  args: Record<string, any>
210
217
  ) => {
211
218
  if (null != opmap.remove) {
212
- // Use last alt as most generic
213
- const alt = getelem(opmap.remove.alts, -1)
219
+ // Use last target as most generic
220
+ const target = getelem(opmap.remove.targets, -1)
214
221
  const step = newFlowStep('remove', args)
215
222
 
216
- each(alt.args.param, (param: any) => {
223
+ each(target.args.params, (param: any) => {
217
224
  if ('id' === param.name) {
218
225
  step.match.id = args.input?.id ?? ent.name + '01'
219
226
  }
@@ -19,7 +19,7 @@ import type {
19
19
  OpName,
20
20
  ModelOpMap,
21
21
  ModelOp,
22
- ModelAlt,
22
+ ModelTarget,
23
23
  } from '../model'
24
24
 
25
25
 
@@ -136,10 +136,10 @@ function resolveOp(opname: OpName, gent: GuideEntity): undefined | ModelOp {
136
136
  if (opdesc) {
137
137
  mop = {
138
138
  name: opname,
139
- alts: opdesc.paths.map((p: PathDesc) => {
139
+ targets: opdesc.paths.map((p: PathDesc) => {
140
140
  const parts = applyRename(p)
141
141
 
142
- const malt: ModelAlt = {
142
+ const mtarget: ModelTarget = {
143
143
  orig: p.orig,
144
144
  parts,
145
145
  rename: p.rename,
@@ -151,10 +151,10 @@ function resolveOp(opname: OpName, gent: GuideEntity): undefined | ModelOp {
151
151
  }
152
152
  }
153
153
 
154
- malt.transform.req = malt.transform.req ?? '`reqdata`'
155
- malt.transform.res = malt.transform.res ?? '`body`'
154
+ mtarget.transform.req = mtarget.transform.req ?? '`reqdata`'
155
+ mtarget.transform.res = mtarget.transform.res ?? '`body`'
156
156
 
157
- return malt
157
+ return mtarget
158
158
  })
159
159
  }
160
160
  }
@@ -20,7 +20,7 @@ import type {
20
20
  OpName,
21
21
  ModelOp,
22
22
  ModelEntity,
23
- ModelAlt,
23
+ ModelTarget,
24
24
  ModelArg,
25
25
  } from '../model'
26
26
 
@@ -36,12 +36,12 @@ const selectTransform: Transform = async function(
36
36
 
37
37
  each(kit.entity, (ment: ModelEntity, _entname: string) => {
38
38
  each(ment.op, (mop: ModelOp, _opname: OpName) => {
39
- each(mop.alts, (malt: ModelAlt) => {
40
- const pdef: PathDef = def.paths[malt.orig]
41
- resolveSelect(guide, ment, mop, malt, pdef)
39
+ each(mop.targets, (mtarget: ModelTarget) => {
40
+ const pdef: PathDef = def.paths[mtarget.orig]
41
+ resolveSelect(guide, ment, mop, mtarget, pdef)
42
42
  })
43
- if (null != mop.alts && 0 < mop.alts.length) {
44
- sortAlts(guide, ment, mop)
43
+ if (null != mop.targets && 0 < mop.targets.length) {
44
+ sortTargets(guide, ment, mop)
45
45
  }
46
46
  })
47
47
 
@@ -56,13 +56,13 @@ function resolveSelect(
56
56
  guide: Guide,
57
57
  ment: ModelEntity,
58
58
  _mop: ModelOp,
59
- malt: ModelAlt,
59
+ mtarget: ModelTarget,
60
60
  _pdef: PathDef
61
61
  ) {
62
- const select: any = malt.select
63
- const margs: any = malt.args
62
+ const select: any = mtarget.select
63
+ const margs: any = mtarget.args
64
64
 
65
- const argkinds = ['param', 'query', 'header', 'cookie']
65
+ const argkinds = ['params', 'query', 'header', 'cookie']
66
66
 
67
67
  argkinds.map((kind: string) => {
68
68
  each(margs[kind], (marg: ModelArg) => {
@@ -75,7 +75,7 @@ function resolveSelect(
75
75
  select.exist.sort()
76
76
 
77
77
  const gent = guide.entity[ment.name]
78
- const gpath = gent.path[malt.orig]
78
+ const gpath = gent.path[mtarget.orig]
79
79
 
80
80
  if (gpath.action) {
81
81
  const actname = Object.keys(gpath.action)[0]
@@ -88,12 +88,12 @@ function resolveSelect(
88
88
  }
89
89
 
90
90
 
91
- function sortAlts(
91
+ function sortTargets(
92
92
  _guide: Guide,
93
93
  _ment: ModelEntity,
94
94
  mop: ModelOp,
95
95
  ) {
96
- mop.alts.sort((a: ModelAlt, b: ModelAlt) => {
96
+ mop.targets.sort((a: ModelTarget, b: ModelTarget) => {
97
97
  // longest exist len first
98
98
  let order = b.select.exist.length - a.select.exist.length
99
99
  if (0 === order) {
@@ -1,5 +1,5 @@
1
1
 
2
- import { joinurl } from '@voxgig/struct'
2
+ import { join } from '@voxgig/struct'
3
3
 
4
4
  import { KIT } from '../types'
5
5
 
@@ -47,7 +47,7 @@ const topTransform = async function(
47
47
  // Swagger 2.0
48
48
  if (def.host) {
49
49
  kit.info.servers.push({
50
- url: (def.schemes?.[0] ?? 'https') + '://' + joinurl([def.host, def.basePath])
50
+ url: (def.schemes?.[0] ?? 'https') + '://' + join([def.host, def.basePath], '/', true)
51
51
  })
52
52
  }
53
53
 
package/src/types.ts CHANGED
@@ -291,7 +291,7 @@ export type {
291
291
  ModelFieldOp,
292
292
  ModelField,
293
293
  ModelArg,
294
- ModelAlt,
294
+ ModelTarget,
295
295
  ModelOp,
296
296
  ModelEntity,
297
297
  } from './model'
package/src/utility.ts CHANGED
@@ -6,7 +6,12 @@ import { snakify, camelify, kebabify, each } from 'jostraca'
6
6
  import { decircular } from '@voxgig/util'
7
7
 
8
8
  import {
9
- slice, merge, inject, clone, isnode, walk, transform, select
9
+ slice, merge, inject, clone, isnode, walk, transform, select,
10
+ Injection,
11
+ M_VAL,
12
+ M_KEYPRE,
13
+ M_KEYPOST,
14
+
10
15
  } from '@voxgig/struct'
11
16
 
12
17
 
@@ -17,6 +22,8 @@ import type {
17
22
  } from './types'
18
23
 
19
24
 
25
+ const KONSOLE_LOG = console['log']
26
+
20
27
 
21
28
  function makeWarner(spec: { point: string, log: Log }): Warner {
22
29
  const { point, log } = spec
@@ -222,26 +229,28 @@ function capture(data: any, shape: any): Record<string, any> {
222
229
  })
223
230
 
224
231
  if (0 < errs.length) {
225
- console.log('ERRS', errs)
232
+ KONSOLE_LOG('ERRS', errs)
226
233
  dlog(errs)
227
234
  }
228
235
  return meta.capture
229
236
  }
230
237
 
231
238
 
232
- function $CAPTURE(inj: any) {
239
+ function $CAPTURE(inj: Injection) {
233
240
  // Set prop foo with value at x: { x: { '`$CAPTURE`': 'foo' } }
234
- if ('key:pre' === inj.mode) {
241
+ if (M_KEYPRE === inj.mode) {
235
242
  const { val, prior } = inj
236
- const { dparent, key } = prior
237
- const dval = dparent?.[key]
238
- if (undefined !== dval) {
239
- inj.meta.capture[val] = dval
243
+ if (null != prior) {
244
+ const { dparent, key } = prior
245
+ const dval = dparent?.[key]
246
+ if (undefined !== dval) {
247
+ inj.meta.capture[val] = dval
248
+ }
240
249
  }
241
250
  }
242
251
 
243
252
  // Use key x as prop name: { x: '`$CAPTURE`': }
244
- else if ('val' === inj.mode) {
253
+ else if (M_VAL === inj.mode) {
245
254
  const { key, dparent } = inj
246
255
  const dval = dparent?.[key]
247
256
  if (undefined !== dval) {
@@ -251,22 +260,28 @@ function $CAPTURE(inj: any) {
251
260
  }
252
261
 
253
262
 
254
- function $APPEND(inj: any, val: any, ref: any, store: any) {
263
+ function $APPEND(inj: Injection, val: any, ref: any, store: any) {
255
264
  // Set prop foo with value at x: { x: { '`$CAPTURE`': 'foo' } }
256
- if ('key:pre' === inj.mode) {
265
+ if (M_KEYPRE === inj.mode) {
257
266
  const { val, prior } = inj
258
- const { dparent, key } = prior
259
- const dval = dparent?.[key]
260
- if (undefined !== dval) {
261
- inj.meta.capture[val] = (inj.meta.capture[val] || [])
262
- inj.meta.capture[val].push(dval)
267
+ if (null != prior) {
268
+ const { dparent, key } = prior
269
+ const dval = dparent?.[key]
270
+ if (undefined !== dval) {
271
+ inj.meta.capture[val] = (inj.meta.capture[val] || [])
272
+ inj.meta.capture[val].push(dval)
273
+ }
263
274
  }
264
275
  }
265
276
 
266
277
 
267
- else if ('val' === inj.mode) {
278
+ else if (M_VAL === inj.mode) {
268
279
  inj.keyI = inj.keys.length
269
280
 
281
+ if (null == inj.prior) {
282
+ return
283
+ }
284
+
270
285
  const [_, prop, xform] = inj.parent
271
286
  const { key, dparent } = inj.prior
272
287
  const dval = dparent?.[key]
@@ -291,28 +306,30 @@ function $APPEND(inj: any, val: any, ref: any, store: any) {
291
306
 
292
307
 
293
308
 
294
- function $ANY(inj: any, _val: any, _ref: any, store: any) {
295
- if ('key:pre' === inj.mode) {
309
+ function $ANY(inj: Injection, _val: any, _ref: any, store: any) {
310
+ if (M_KEYPRE === inj.mode) {
296
311
  const { prior } = inj
297
312
  const child = inj.parent[inj.key]
298
- const { dparent, key } = prior
299
- const dval = dparent?.[key]
300
- if (isnode(dval)) {
301
- for (let n of Object.entries(dval)) {
302
- let vstore = { ...store }
303
- vstore.$TOP = { [n[0]]: n[1] }
304
- inject(clone({ [n[0]]: child }), vstore, {
305
- meta: inj.meta,
306
- errs: inj.errs,
307
- })
313
+ if (null != prior) {
314
+ const { dparent, key } = prior
315
+ const dval = dparent?.[key]
316
+ if (isnode(dval)) {
317
+ for (let n of Object.entries(dval)) {
318
+ let vstore = { ...store }
319
+ vstore.$TOP = { [n[0]]: n[1] }
320
+ inject(clone({ [n[0]]: child }), vstore, {
321
+ meta: inj.meta,
322
+ errs: inj.errs,
323
+ })
324
+ }
308
325
  }
309
326
  }
310
327
  }
311
328
  }
312
329
 
313
330
 
314
- function $SELECT(inj: any, _val: any, _ref: any, store: any) {
315
- if ('val' === inj.mode) {
331
+ function $SELECT(inj: Injection, _val: any, _ref: any, store: any) {
332
+ if (M_VAL === inj.mode) {
316
333
  inj.keyI = inj.keys.length
317
334
 
318
335
  let [_, selector, descendor] = inj.parent
@@ -352,8 +369,12 @@ function $SELECT(inj: any, _val: any, _ref: any, store: any) {
352
369
  }
353
370
 
354
371
 
355
- function $RECASE(inj: any, val: any, ref: any, store: any) {
356
- if ('key:pre' === inj.mode) {
372
+ function $RECASE(inj: Injection, val: any, ref: any, store: any) {
373
+ if (
374
+ M_KEYPRE === inj.mode
375
+ && null != inj.prior
376
+ && null != inj.prior.prior
377
+ ) {
357
378
  const dval = inj.parent[inj.key]
358
379
 
359
380
  // TODO: handle paths more generally! use inj.prior?
@@ -727,19 +748,22 @@ function warnOnError(where: string, warn: Warner, fn: Function, result?: any) {
727
748
 
728
749
  function debugpath(pathStr: string, methodName: string | null | undefined, ...args: any[]): void {
729
750
  const apipath = process.env.APIDEF_DEBUG_PATH
730
- if (!apipath) return
731
751
 
732
- const [targetPath, targetMethod] = apipath.split(':')
752
+ if (null == apipath || '' === apipath) return
733
753
 
734
- // Check if path matches
735
- if (pathStr !== targetPath) return
754
+ if ('ALL' !== apipath) {
755
+ const [targetPath, targetMethod] = apipath.split(':')
736
756
 
737
- // If a method is specified in apipath and we have a method name, check if it matches
738
- if (targetMethod && methodName) {
739
- if (methodName.toLowerCase() !== targetMethod.toLowerCase()) return
757
+ // Check if path matches
758
+ if (pathStr !== targetPath) return
759
+
760
+ // If a method is specified in apipath and we have a method name, check if it matches
761
+ if (targetMethod && methodName) {
762
+ if (methodName.toLowerCase() !== targetMethod.toLowerCase()) return
763
+ }
740
764
  }
741
765
 
742
- console.log(methodName || '', ...args)
766
+ KONSOLE_LOG(methodName || '', ...args)
743
767
  }
744
768
 
745
769
 
@@ -807,12 +831,14 @@ function relativizePath(path: string): string {
807
831
  }
808
832
 
809
833
 
834
+ // NOTE: removes inactive items by default
810
835
  function getModelPath(
811
836
  model: any,
812
837
  path: string,
813
- flags?: { required?: boolean }
838
+ flags?: { required?: boolean, only_active?: boolean }
814
839
  ): any {
815
840
  const required = flags?.required ?? true
841
+ const only_active = flags?.only_active ?? true
816
842
 
817
843
  if (path === '') {
818
844
  if (required) {
@@ -876,6 +902,26 @@ function getModelPath(
876
902
  current = current[part]
877
903
  }
878
904
 
905
+ if (current && only_active) {
906
+ if (false === current.active) {
907
+ current = undefined
908
+ }
909
+ if ('object' === typeof current) {
910
+ const out: any = Array.isArray(current) ? [] : {}
911
+ Object.entries(current).map((n: any) => {
912
+ if (null != n[1] && false !== n[1].active) {
913
+ if (Array.isArray(out)) {
914
+ out.push(n[1])
915
+ }
916
+ else {
917
+ out[n[0]] = n[1]
918
+ }
919
+ }
920
+ })
921
+ current = out
922
+ }
923
+ }
924
+
879
925
  return current
880
926
  }
881
927