@voxgig/apidef 4.1.0 → 5.1.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.
package/dist/types.js CHANGED
@@ -2,10 +2,10 @@
2
2
  /* Copyright (c) 2025 Voxgig, MIT License */
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.OpenBuildShape = exports.OpenModelShape = exports.OpenControlShape = exports.KIT = void 0;
5
- const gubu_1 = require("gubu");
5
+ const shape_1 = require("shape");
6
6
  const KIT = 'kit';
7
7
  exports.KIT = KIT;
8
- const ControlShape = (0, gubu_1.Gubu)({
8
+ const ControlShape = (0, shape_1.Shape)({
9
9
  step: {
10
10
  parse: true,
11
11
  guide: true,
@@ -14,9 +14,9 @@ const ControlShape = (0, gubu_1.Gubu)({
14
14
  generate: true,
15
15
  }
16
16
  });
17
- const OpenControlShape = (0, gubu_1.Gubu)((0, gubu_1.Open)(ControlShape), { name: 'Control' });
17
+ const OpenControlShape = (0, shape_1.Shape)((0, shape_1.Open)(ControlShape), { name: 'Control' });
18
18
  exports.OpenControlShape = OpenControlShape;
19
- const ModelShape = (0, gubu_1.Gubu)({
19
+ const ModelShape = (0, shape_1.Shape)({
20
20
  name: String,
21
21
  def: String,
22
22
  main: {
@@ -28,9 +28,9 @@ const ModelShape = (0, gubu_1.Gubu)({
28
28
  },
29
29
  }
30
30
  });
31
- const OpenModelShape = (0, gubu_1.Gubu)((0, gubu_1.Open)(ModelShape), { name: 'Model' });
31
+ const OpenModelShape = (0, shape_1.Shape)((0, shape_1.Open)(ModelShape), { name: 'Model' });
32
32
  exports.OpenModelShape = OpenModelShape;
33
- const BuildShape = (0, gubu_1.Gubu)({
33
+ const BuildShape = (0, shape_1.Shape)({
34
34
  spec: {
35
35
  base: '',
36
36
  path: '',
@@ -39,7 +39,7 @@ const BuildShape = (0, gubu_1.Gubu)({
39
39
  res: [],
40
40
  require: '',
41
41
  log: {},
42
- fs: (0, gubu_1.Any)(),
42
+ fs: (0, shape_1.Any)(),
43
43
  dryrun: false,
44
44
  buildargs: {},
45
45
  watch: {
@@ -49,6 +49,6 @@ const BuildShape = (0, gubu_1.Gubu)({
49
49
  }
50
50
  }
51
51
  });
52
- const OpenBuildShape = (0, gubu_1.Gubu)((0, gubu_1.Open)(BuildShape));
52
+ const OpenBuildShape = (0, shape_1.Shape)((0, shape_1.Open)(BuildShape));
53
53
  exports.OpenBuildShape = OpenBuildShape;
54
54
  //# sourceMappingURL=types.js.map
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,4CAA4C;;;AAK5C,+BAAsC;AAGtC,MAAM,GAAG,GAAG,KAAK,CAAA;AAyOf,kBAAG;AAzML,MAAM,YAAY,GAAG,IAAA,WAAI,EAAC;IACxB,IAAI,EAAE;QACJ,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,IAAI;QACX,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,IAAI;KACf;CACF,CAAC,CAAA;AACF,MAAM,gBAAgB,GAAG,IAAA,WAAI,EAAC,IAAA,WAAI,EAAC,YAAY,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAA;AAkMpE,4CAAgB;AA5LlB,MAAM,UAAU,GAAG,IAAA,WAAI,EAAC;IACtB,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,MAAM;IACX,IAAI,EAAE;QACJ,CAAC,GAAG,CAAC,EAAE,EAAE;QACT,GAAG,EAAE,EAAE;QACP,GAAG,EAAE;YACH,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,EAAE;SACX;KACF;CACF,CAAC,CAAA;AACF,MAAM,cAAc,GAAG,IAAA,WAAI,EAAC,IAAA,WAAI,EAAC,UAAU,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;AAiL9D,wCAAc;AA5KhB,MAA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ACF,CAAC,CAAA;AACF,MAAM,cAAc,GAAG,IAAA,aAAK,EAAC,IAAA,YAAI,EAAC,UAAU,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;AAiL/D,wCAAc;AA5KhB,MAAM,UAAU,GAAG,IAAA,aAAK,EAAC;IACvB,IAAI,EAAE;QACJ,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,EAAE;QACR,KAAK,EAAE,EAAE;QACT,GAAG,EAAE,EAAE;QACP,GAAG,EAAE,EAAE;QACP,OAAO,EAAE,EAAE;QACX,GAAG,EAAE,EAAE;QACP,EAAE,EAAE,IAAA,WAAG,GAAE;QACT,MAAM,EAAE,KAAK;QACb,SAAS,EAAE,EAAE;QACb,KAAK,EAAE;YACL,GAAG,EAAE,IAAI;YACT,GAAG,EAAE,IAAI;YACT,GAAG,EAAE,IAAI;SACV;KACF;CACF,CAAC,CAAA;AACF,MAAM,cAAc,GAAG,IAAA,aAAK,EAAC,IAAA,YAAI,EAAC,UAAU,CAAC,CAAC,CAAA;AA0J5C,wCAAc"}
@@ -31,7 +31,7 @@ main: kit: entity: &: {
31
31
  name: string
32
32
  input: *'data'
33
33
 
34
- targets: [ &: {
34
+ points: [ &: {
35
35
 
36
36
  active: *true
37
37
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voxgig/apidef",
3
- "version": "4.1.0",
3
+ "version": "5.1.1",
4
4
  "main": "dist/apidef.js",
5
5
  "type": "commonjs",
6
6
  "types": "dist/apidef.d.ts",
@@ -40,26 +40,21 @@
40
40
  "LICENSE"
41
41
  ],
42
42
  "devDependencies": {
43
- "@hapi/code": "^9.0.3",
44
- "@types/node": "25.5.0",
45
- "json-schema-to-ts": "^3.1.1",
43
+ "@types/node": "25.5.0",
46
44
  "typescript": "^6.0.2"
47
45
  },
48
46
  "peerDependencies": {
49
- "aontu": ">=0.39.0",
50
- "memfs": ">=4.57.1"
47
+ "aontu": ">=0.39.0"
51
48
  },
52
49
  "dependencies": {
53
50
  "@jsonic/yaml": "0.1.4",
54
51
  "jsonic": "^2.19.0",
55
52
  "@voxgig/struct": "^0.0.10",
56
- "@voxgig/util": "^0.3.0",
57
- "chokidar": "^5.0.0",
58
- "decircular": "^1.0.0",
53
+ "@voxgig/util": "^0.4.0",
59
54
  "diff": "^8.0.4",
60
- "gubu": "^9.0.0",
55
+ "shape": "^10.0.1",
61
56
  "jostraca": "^0.28.0",
62
- "ordu": "^4.1.1",
57
+ "ordu": "^4.2.0",
63
58
  "pino": "^10.3.1",
64
59
  "pino-pretty": "^13.1.3"
65
60
  }
package/src/apidef.ts CHANGED
@@ -82,7 +82,7 @@ const dlog = getdlog('apidef', __filename)
82
82
 
83
83
  function ApiDef(opts: ApiDefOptions) {
84
84
 
85
- // TODO: gubu opts!
85
+ // TODO: shape opts!
86
86
  const fs = opts.fs || Fs
87
87
  const pino = prettyPino('apidef', opts)
88
88
  const log = pino.child({ cmp: 'apidef' })
@@ -105,10 +105,10 @@ function resolveBasicEntityFlow(ctx: any, entity: any) {
105
105
 
106
106
  if (entop.load) {
107
107
 
108
- const target = findMainLoadTarget(entop.load)
108
+ const point = findMainLoadPoint(entop.load)
109
109
 
110
110
  // Get additional required match properties
111
- each(target?.args.params, (param: any) => {
111
+ each(point?.args.params, (param: any) => {
112
112
  if (param.required) {
113
113
  let ancestorName = param.name
114
114
  let ancestorEntity = apimodel.main.api.entity[ancestorName]
@@ -196,8 +196,8 @@ function resolveBasicEntityFlow(ctx: any, entity: any) {
196
196
  }
197
197
 
198
198
 
199
- function findMainLoadTarget(op: ModelOp): ModelTarget | undefined {
200
- let cands = op.targets.filter(a => '{id}' === getelem(a.parts, -1))
199
+ function findMainLoadPoint(op: ModelOp): ModelTarget | undefined {
200
+ let cands = op.points.filter(a => '{id}' === getelem(a.parts, -1))
201
201
  return cands[0]
202
202
  }
203
203
 
package/src/model.ts CHANGED
@@ -62,7 +62,7 @@ type ModelArg = {
62
62
  }
63
63
 
64
64
 
65
- // Target implementation of an operation
65
+ // Point implementation of an operation
66
66
  type ModelTarget = {
67
67
  orig: string
68
68
  method: MethodName
@@ -93,7 +93,7 @@ type ModelTarget = {
93
93
  // Operation definition
94
94
  type ModelOp = {
95
95
  name: OpName
96
- targets: ModelTarget[]
96
+ points: ModelTarget[]
97
97
  }
98
98
 
99
99
 
@@ -38,7 +38,7 @@ 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.targets, (mtarget: ModelTarget) => {
41
+ each(mop.points, (mtarget: ModelTarget) => {
42
42
  const argdefs: ParameterDef[] = []
43
43
 
44
44
  const pathdef: PathDef = def.paths[mtarget.orig]
@@ -43,7 +43,7 @@ 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 mtargets = mop.targets
46
+ const mtargets = mop.points
47
47
 
48
48
  for (let mtarget of mtargets) {
49
49
  const opfields = resolveOpFields(ment, mop, mtarget, def)
@@ -123,11 +123,11 @@ const createStep: MakeFlowStep = (
123
123
  args: Record<string, any>
124
124
  ) => {
125
125
  if (null != opmap.update) {
126
- // Use last target as most generic
127
- const target = getelem(opmap.update.targets, -1)
126
+ // Use last point as most generic
127
+ const point = getelem(opmap.update.points, -1)
128
128
  const step = newFlowStep('create', args)
129
129
 
130
- each(target.args.params, (param: any) => {
130
+ each(point.args.params, (param: any) => {
131
131
  // id should not be here in the first place
132
132
  if ('id' !== param.name) {
133
133
  step.match[param.name] = args.input?.[param.name] ?? param.name.replace(/_id/, '') + '01'
@@ -146,11 +146,11 @@ const listStep: MakeFlowStep = (
146
146
  args: Record<string, any>
147
147
  ) => {
148
148
  if (null != opmap.list) {
149
- // Use last target as most generic
150
- const target = getelem(opmap.list.targets, -1)
149
+ // Use last point as most generic
150
+ const point = getelem(opmap.list.points, -1)
151
151
  const step = newFlowStep('list', args)
152
152
 
153
- each(target.args.params, (param: any) => {
153
+ each(point.args.params, (param: any) => {
154
154
  step.match[param.name] = args.input?.[param.name] ?? param.name.replace(/_id/, '') + '01'
155
155
  })
156
156
 
@@ -166,11 +166,11 @@ const updateStep: MakeFlowStep = (
166
166
  args: Record<string, any>
167
167
  ) => {
168
168
  if (null != opmap.update) {
169
- // Use last target as most generic
170
- const target = getelem(opmap.update.targets, -1)
169
+ // Use last point as most generic
170
+ const point = getelem(opmap.update.points, -1)
171
171
  const step = newFlowStep('update', args)
172
172
 
173
- each(target.args.params, (param: any) => {
173
+ each(point.args.params, (param: any) => {
174
174
  if ('id' === param.name) {
175
175
  step.data.id = args.input?.id ?? ent.name + '01'
176
176
  }
@@ -191,11 +191,11 @@ const loadStep: MakeFlowStep = (
191
191
  args: Record<string, any>
192
192
  ) => {
193
193
  if (null != opmap.load) {
194
- // Use last target as most generic
195
- const target = getelem(opmap.load.targets, -1)
194
+ // Use last point as most generic
195
+ const point = getelem(opmap.load.points, -1)
196
196
  const step = newFlowStep('load', args)
197
197
 
198
- each(target.args.params, (param: any) => {
198
+ each(point.args.params, (param: any) => {
199
199
  if ('id' === param.name) {
200
200
  step.match.id = args.input?.id ?? ent.name + '01'
201
201
  }
@@ -216,11 +216,11 @@ const removeStep: MakeFlowStep = (
216
216
  args: Record<string, any>
217
217
  ) => {
218
218
  if (null != opmap.remove) {
219
- // Use last target as most generic
220
- const target = getelem(opmap.remove.targets, -1)
219
+ // Use last point as most generic
220
+ const point = getelem(opmap.remove.points, -1)
221
221
  const step = newFlowStep('remove', args)
222
222
 
223
- each(target.args.params, (param: any) => {
223
+ each(point.args.params, (param: any) => {
224
224
  if ('id' === param.name) {
225
225
  step.match.id = args.input?.id ?? ent.name + '01'
226
226
  }
@@ -136,7 +136,7 @@ function resolveOp(opname: OpName, gent: GuideEntity): undefined | ModelOp {
136
136
  if (opdesc) {
137
137
  mop = {
138
138
  name: opname,
139
- targets: opdesc.paths.map((p: PathDesc) => {
139
+ points: opdesc.paths.map((p: PathDesc) => {
140
140
  const parts = applyRename(p)
141
141
 
142
142
  const mtarget: ModelTarget = {
@@ -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.targets, (mtarget: ModelTarget) => {
39
+ each(mop.points, (mtarget: ModelTarget) => {
40
40
  const pdef: PathDef = def.paths[mtarget.orig]
41
41
  resolveSelect(guide, ment, mop, mtarget, pdef)
42
42
  })
43
- if (null != mop.targets && 0 < mop.targets.length) {
44
- sortTargets(guide, ment, mop)
43
+ if (null != mop.points && 0 < mop.points.length) {
44
+ sortPoints(guide, ment, mop)
45
45
  }
46
46
  })
47
47
 
@@ -88,12 +88,12 @@ function resolveSelect(
88
88
  }
89
89
 
90
90
 
91
- function sortTargets(
91
+ function sortPoints(
92
92
  _guide: Guide,
93
93
  _ment: ModelEntity,
94
94
  mop: ModelOp,
95
95
  ) {
96
- mop.targets.sort((a: ModelTarget, b: ModelTarget) => {
96
+ mop.points.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) {
package/src/transform.ts CHANGED
@@ -5,7 +5,7 @@ import Path from 'node:path'
5
5
 
6
6
  import { getx, each, camelify } from 'jostraca'
7
7
 
8
- import { Gubu, Child, Exact } from 'gubu'
8
+ import { Shape, Child, Exact } from 'shape'
9
9
 
10
10
  import { topTransform } from './transform/top'
11
11
  import { entityTransform } from './transform/entity'
@@ -73,7 +73,7 @@ const OPKIND: any = {
73
73
  }
74
74
 
75
75
 
76
- const GuideShape = Gubu({
76
+ const GuideShape = Shape({
77
77
  entity: {},
78
78
  control: {},
79
79
  transform: {},
package/src/types.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  import * as Fs from 'node:fs'
4
4
 
5
5
  import { Pino, prettyPino } from '@voxgig/util'
6
- import { Gubu, Open, Any } from 'gubu'
6
+ import { Shape, Open, Any } from 'shape'
7
7
 
8
8
 
9
9
  const KIT = 'kit'
@@ -38,7 +38,7 @@ type ApiDefOptions = {
38
38
  }
39
39
  }
40
40
 
41
- const ControlShape = Gubu({
41
+ const ControlShape = Shape({
42
42
  step: {
43
43
  parse: true,
44
44
  guide: true,
@@ -47,13 +47,13 @@ const ControlShape = Gubu({
47
47
  generate: true,
48
48
  }
49
49
  })
50
- const OpenControlShape = Gubu(Open(ControlShape), { name: 'Control' })
50
+ const OpenControlShape = Shape(Open(ControlShape), { name: 'Control' })
51
51
 
52
52
  type Control = ReturnType<typeof ControlShape>
53
53
 
54
54
 
55
55
 
56
- const ModelShape = Gubu({
56
+ const ModelShape = Shape({
57
57
  name: String,
58
58
  def: String,
59
59
  main: {
@@ -65,12 +65,12 @@ const ModelShape = Gubu({
65
65
  },
66
66
  }
67
67
  })
68
- const OpenModelShape = Gubu(Open(ModelShape), { name: 'Model' })
68
+ const OpenModelShape = Shape(Open(ModelShape), { name: 'Model' })
69
69
 
70
70
  type Model = ReturnType<typeof ModelShape>
71
71
 
72
72
 
73
- const BuildShape = Gubu({
73
+ const BuildShape = Shape({
74
74
  spec: {
75
75
  base: '',
76
76
  path: '',
@@ -89,7 +89,7 @@ const BuildShape = Gubu({
89
89
  }
90
90
  }
91
91
  })
92
- const OpenBuildShape = Gubu(Open(BuildShape))
92
+ const OpenBuildShape = Shape(Open(BuildShape))
93
93
 
94
94
  type Build = ReturnType<typeof BuildShape>
95
95