@voxgig/sdkgen 1.1.1 → 1.2.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/bin/voxgig-sdkgen CHANGED
@@ -8,7 +8,7 @@ const { Shape, One } = require('shape')
8
8
 
9
9
  const { SdkGen } = require('../dist/sdkgen.js')
10
10
 
11
- const VERSION = '1.1.1'
11
+ const VERSION = '1.2.1'
12
12
  const KONSOLE = console
13
13
 
14
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voxgig/sdkgen",
3
- "version": "1.1.1",
3
+ "version": "1.2.1",
4
4
  "main": "dist/sdkgen.js",
5
5
  "type": "commonjs",
6
6
  "types": "dist/sdkgen.d.ts",
@@ -41,7 +41,7 @@
41
41
  ],
42
42
  "devDependencies": {
43
43
  "@types/js-yaml": "4.0.9",
44
- "@types/node": "25.7.0",
44
+ "@types/node": "25.8.0",
45
45
  "json-schema-to-ts": "3.1.1",
46
46
  "memfs": "4.57.2",
47
47
  "typescript": "6.0.3"
@@ -51,6 +51,7 @@
51
51
  "@voxgig/struct": ">=0",
52
52
  "@voxgig/util": ">=0",
53
53
  "aontu": ">=0",
54
- "jostraca": ">=0"
54
+ "jostraca": ">=0",
55
+ "shape": ">=10.1"
55
56
  }
56
57
  }
@@ -593,16 +593,14 @@ const generateRemove: OpGen = (ctx, step, index) => {
593
593
  // otherwise reuse the `err` from a prior op step.
594
594
  const errOp = needsEnt ? ':=' : '='
595
595
 
596
- const hasEntIdR = null != entity.id
597
-
598
596
  Content(` // REMOVE
599
597
  `)
600
598
  if (needsEnt) {
601
599
  Content(` ${entvar} := client.${entity.Name}(nil)
602
600
  `)
603
601
  }
604
- if (hasEntIdR) {
605
- Content(` ${matchvar} := map[string]any{
602
+ // Always match the prior-created entity by id to avoid mock-order flakes.
603
+ Content(` ${matchvar} := map[string]any{
606
604
  "id": ${srcdatavar}["id"],
607
605
  }
608
606
  _, err ${errOp} ${entvar}.Remove(${matchvar}, nil)
@@ -610,15 +608,6 @@ const generateRemove: OpGen = (ctx, step, index) => {
610
608
  t.Fatalf("remove failed: %v", err)
611
609
  }
612
610
  `)
613
- }
614
- else {
615
- Content(` ${matchvar} := map[string]any{}
616
- _, err ${errOp} ${entvar}.Remove(${matchvar}, nil)
617
- if err != nil {
618
- t.Fatalf("remove failed: %v", err)
619
- }
620
- `)
621
- }
622
611
  }
623
612
 
624
613
 
@@ -502,28 +502,19 @@ const generateRemove: OpGen = (ctx, step, index) => {
502
502
  const needsEnt = !priorSteps.some((s: any) =>
503
503
  ['create', 'list', 'load', 'update', 'remove'].includes(s.op))
504
504
 
505
- const hasEntIdR = null != entity.id
506
-
507
505
  Content(` -- REMOVE
508
506
  `)
509
507
  if (needsEnt) {
510
508
  Content(` local ${entvar} = client:${entity.Name}(nil)
511
509
  `)
512
510
  }
513
- if (hasEntIdR) {
514
- Content(` local ${matchvar} = {
511
+ // Always match the prior-created entity by id to avoid mock-order flakes.
512
+ Content(` local ${matchvar} = {
515
513
  id = ${srcdatavar}["id"],
516
514
  }
517
515
  local _, err = ${entvar}:remove(${matchvar}, nil)
518
516
  assert.is_nil(err)
519
517
  `)
520
- }
521
- else {
522
- Content(` local ${matchvar} = {}
523
- local _, err = ${entvar}:remove(${matchvar}, nil)
524
- assert.is_nil(err)
525
- `)
526
- }
527
518
  }
528
519
 
529
520
 
@@ -507,28 +507,19 @@ const generateRemove: OpGen = (ctx, step, index) => {
507
507
  const needsEnt = !priorSteps.some((s: any) =>
508
508
  ['create', 'list', 'load', 'update', 'remove'].includes(s.op))
509
509
 
510
- const hasEntIdR = null != entity.id
511
-
512
510
  Content(` // REMOVE
513
511
  `)
514
512
  if (needsEnt) {
515
513
  Content(` $${entvar} = $client->${accessor}(null);
516
514
  `)
517
515
  }
518
- if (hasEntIdR) {
519
- Content(` $${matchvar} = [
516
+ // Always match the prior-created entity by id to avoid mock-order flakes.
517
+ Content(` $${matchvar} = [
520
518
  "id" => $${srcdatavar}["id"],
521
519
  ];
522
520
  [$_, $err] = $${entvar}->remove($${matchvar}, null);
523
521
  $this->assertNull($err);
524
522
  `)
525
- }
526
- else {
527
- Content(` $${matchvar} = [];
528
- [$_, $err] = $${entvar}->remove($${matchvar}, null);
529
- $this->assertNull($err);
530
- `)
531
- }
532
523
  }
533
524
 
534
525
 
@@ -500,28 +500,19 @@ const generateRemove: OpGen = (ctx, step, index) => {
500
500
  const needsEnt = !priorSteps.some((s: any) =>
501
501
  ['create', 'list', 'load', 'update', 'remove'].includes(s.op))
502
502
 
503
- const hasEntIdR = null != entity.id
504
-
505
503
  Content(` # REMOVE
506
504
  `)
507
505
  if (needsEnt) {
508
506
  Content(` ${entvar} = client.${entity.Name}(None)
509
507
  `)
510
508
  }
511
- if (hasEntIdR) {
512
- Content(` ${matchvar} = {
509
+ // Always match the prior-created entity by id to avoid mock-order flakes.
510
+ Content(` ${matchvar} = {
513
511
  "id": ${srcdatavar}["id"],
514
512
  }
515
513
  _, err = ${entvar}.remove(${matchvar}, None)
516
514
  assert err is None
517
515
  `)
518
- }
519
- else {
520
- Content(` ${matchvar} = {}
521
- _, err = ${entvar}.remove(${matchvar}, None)
522
- assert err is None
523
- `)
524
- }
525
516
  }
526
517
 
527
518
 
@@ -493,28 +493,19 @@ const generateRemove: OpGen = (ctx, step, index) => {
493
493
  const needsEnt = !priorSteps.some((s: any) =>
494
494
  ['create', 'list', 'load', 'update', 'remove'].includes(s.op))
495
495
 
496
- const hasEntIdR = null != entity.id
497
-
498
496
  Content(` # REMOVE
499
497
  `)
500
498
  if (needsEnt) {
501
499
  Content(` ${entvar} = client.${entity.Name}(nil)
502
500
  `)
503
501
  }
504
- if (hasEntIdR) {
505
- Content(` ${matchvar} = {
502
+ // Always match the prior-created entity by id to avoid mock-order flakes.
503
+ Content(` ${matchvar} = {
506
504
  "id" => ${srcdatavar}["id"],
507
505
  }
508
506
  _, err = ${entvar}.remove(${matchvar}, nil)
509
507
  assert_nil err
510
508
  `)
511
- }
512
- else {
513
- Content(` ${matchvar} = {}
514
- _, err = ${entvar}.remove(${matchvar}, nil)
515
- assert_nil err
516
- `)
517
- }
518
509
  }
519
510
 
520
511
 
@@ -516,8 +516,6 @@ const generateRemove: OpGen = (ctx, step, index) => {
516
516
  const needsEnt = !priorSteps.some(s =>
517
517
  ['create', 'list', 'load', 'update', 'remove'].includes(s.op))
518
518
 
519
- const hasEntIdR = null != entity.id
520
-
521
519
  Content(`
522
520
  // REMOVE
523
521
  `)
@@ -525,13 +523,11 @@ const generateRemove: OpGen = (ctx, step, index) => {
525
523
  Content(` const ${entvar} = client.${nom(entity, 'Name')}()
526
524
  `)
527
525
  }
528
- Content(` const ${matchvar}: any = {}
529
- `)
530
- if (hasEntIdR) {
531
- Content(` ${matchvar}.id = ${srcdatavar}.id
532
- `)
533
- }
534
- Content(` await ${entvar}.remove(${matchvar})
526
+ // Always match the prior-created entity by id. The mock test feature
527
+ // removes the first match in entmap, so without a specific id the
528
+ // result depends on hash-sort order and flakes (see cheapshark).
529
+ Content(` const ${matchvar}: any = { id: ${srcdatavar}.id }
530
+ await ${entvar}.remove(${matchvar})
535
531
  `)
536
532
  }
537
533
 
@@ -165,9 +165,8 @@ func (f *TestFeature) Init(ctx *core.Context, options map[string]any) {
165
165
  args := self.buildArgs(ctx, op, resolveMatch(ctx.Reqmatch))
166
166
  found := vs.Select(entmap, args)
167
167
  ent := vs.GetElem(found, 0)
168
- if ent == nil {
169
- return respond(404, nil, map[string]any{"statusText": "Not found"}), nil
170
- }
168
+ // Remove only the first matched entity. If nothing matches,
169
+ // succeed as a no-op rather than erroring.
171
170
  if entm, ok := ent.(map[string]any); ok {
172
171
  id := vs.GetProp(entm, "id")
173
172
  vs.DelProp(entmap, id)
@@ -153,9 +153,8 @@ function TestFeature:init(ctx, options)
153
153
  local args = test_self:build_args(fctx, op, resolve_match(fctx.reqmatch))
154
154
  local found = vs.select(entmap, args)
155
155
  local ent = vs.getelem(found, 0)
156
- if ent == nil then
157
- return respond(404, nil, { statusText = "Not found" })
158
- end
156
+ -- Remove only the first matched entity. If nothing matches,
157
+ -- succeed as a no-op rather than erroring.
159
158
  if type(ent) == "table" then
160
159
  local id = vs.getprop(ent, "id")
161
160
  vs.delprop(entmap, id)
@@ -199,9 +199,8 @@ class ProjectNameTestFeature extends ProjectNameBaseFeature
199
199
 
200
200
  } elseif ($op->name === 'remove') {
201
201
  $ent = $find_first($entmap, $resolve_match($fctx->reqmatch), $alias);
202
- if ($ent === null) {
203
- return $respond(404, null, ['statusText' => 'Not found']);
204
- }
202
+ // Remove only the first matched entity. If nothing matches,
203
+ // succeed as a no-op rather than erroring.
205
204
  $id = is_array($ent) ? ($ent['id'] ?? null) : null;
206
205
  if ($id !== null) {
207
206
  unset($entmap[$id]);
@@ -128,8 +128,8 @@ class ProjectNameTestFeature(ProjectNameBaseFeature):
128
128
  args = test_self.build_args(fctx, op, _resolve_match(fctx.reqmatch))
129
129
  found = vs.select(entmap, args)
130
130
  ent = vs.getelem(found, 0)
131
- if ent is None:
132
- return respond(404, None, {"statusText": "Not found"})
131
+ # Remove only the first matched entity. If nothing matches,
132
+ # succeed as a no-op rather than erroring.
133
133
  if isinstance(ent, dict):
134
134
  eid = vs.getprop(ent, "id")
135
135
  vs.delprop(entmap, eid)
@@ -117,7 +117,8 @@ class ProjectNameTestFeature < ProjectNameBaseFeature
117
117
  args = test_self.build_args(fctx, op, resolve_match.call(fctx.reqmatch))
118
118
  found = VoxgigStruct.select(entmap, args)
119
119
  ent = VoxgigStruct.getelem(found, 0)
120
- return respond.call(404, nil, { "statusText" => "Not found" }) unless ent
120
+ # Remove only the first matched entity. If nothing matches,
121
+ # succeed as a no-op rather than erroring.
121
122
  if ent.is_a?(Hash)
122
123
  id = VoxgigStruct.getprop(ent, "id")
123
124
  VoxgigStruct.delprop(entmap, id)
@@ -124,13 +124,12 @@ class TestFeature extends BaseFeature {
124
124
  const args = self.buildArgs(ctx, op, ctx.reqmatch)
125
125
  const found = select(entmap, args)
126
126
  const ent = getelem(found, 0)
127
- if (null == ent) {
128
- return respond(404, undefined, { statusText: S_NOT_FOUND })
129
- }
130
- else {
127
+ // Remove only the first matched entity. If nothing matches,
128
+ // succeed as a no-op rather than erroring.
129
+ if (null != ent) {
131
130
  delprop(entmap, getprop(ent, 'id'))
132
- return respond(200)
133
131
  }
132
+ return respond(200)
134
133
  }
135
134
  else if ('create' === op.name) {
136
135
  const args = self.buildArgs(ctx, op, ctx.reqdata)