@voxgig/sdkgen 1.0.1 → 1.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/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.0.1'
11
+ const VERSION = '1.1.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.0.1",
3
+ "version": "1.1.1",
4
4
  "main": "dist/sdkgen.js",
5
5
  "type": "commonjs",
6
6
  "types": "dist/sdkgen.d.ts",
@@ -114,8 +114,10 @@ func (f *TestFeature) Init(ctx *core.Context, options map[string]any) {
114
114
  // Match the existing entity by id only (or its alias). Reqdata
115
115
  // also contains the new field values, which would otherwise
116
116
  // cause Select to filter out the entity we want to update.
117
- // Falls back to first entity when no match found, mirroring
118
- // the TS mock.
117
+ // When reqdata has no id, fall back to the id the entity
118
+ // client carries from a prior create/load (in ctx.Match /
119
+ // ctx.Data), mirroring the TS mock where param(ctx,'id')
120
+ // resolves from accumulated state.
119
121
  updateMatch := map[string]any{}
120
122
  if ctx.Reqdata != nil {
121
123
  if v, has := ctx.Reqdata["id"]; has {
@@ -131,6 +133,9 @@ func (f *TestFeature) Init(ctx *core.Context, options map[string]any) {
131
133
  }
132
134
  }
133
135
  }
136
+ if len(updateMatch) == 0 {
137
+ updateMatch = resolveMatch(map[string]any{})
138
+ }
134
139
  args := self.buildArgs(ctx, op, updateMatch)
135
140
  found := vs.Select(entmap, args)
136
141
  ent := vs.GetElem(found, 0)
@@ -109,8 +109,10 @@ function TestFeature:init(ctx, options)
109
109
  elseif op.name == "update" then
110
110
  -- Match the existing entity by id only (or its alias). reqdata also
111
111
  -- contains the new field values, which would otherwise cause select
112
- -- to filter out the entity we want to update. Falls back to first
113
- -- entity when no match found, mirroring the TS mock.
112
+ -- to filter out the entity we want to update. When reqdata has no id,
113
+ -- fall back to the id the entity client carries from a prior
114
+ -- create/load (in fctx.match / fctx.data), mirroring the TS mock
115
+ -- where param(ctx,'id') resolves from accumulated state.
114
116
  local update_match = {}
115
117
  if type(fctx.reqdata) == "table" then
116
118
  if fctx.reqdata["id"] ~= nil then update_match["id"] = fctx.reqdata["id"] end
@@ -121,6 +123,9 @@ function TestFeature:init(ctx, options)
121
123
  end
122
124
  end
123
125
  end
126
+ if next(update_match) == nil then
127
+ update_match = resolve_match({})
128
+ end
124
129
  local args = test_self:build_args(fctx, op, update_match)
125
130
  local found = vs.select(entmap, args)
126
131
  local ent = vs.getelem(found, 0)
@@ -162,6 +162,10 @@ class ProjectNameTestFeature extends ProjectNameBaseFeature
162
162
  // Match the existing entity by id only (or its alias). reqdata
163
163
  // also contains the new field values, which would otherwise
164
164
  // cause find_first to filter out the entity we want to update.
165
+ // When reqdata has no id, fall back to the id the entity
166
+ // client carries from a prior create/load (in $fctx->match /
167
+ // $fctx->data), mirroring the TS mock where param(ctx,'id')
168
+ // resolves from accumulated state.
165
169
  $update_match = [];
166
170
  if (is_array($fctx->reqdata)) {
167
171
  if (array_key_exists('id', $fctx->reqdata)) {
@@ -172,6 +176,9 @@ class ProjectNameTestFeature extends ProjectNameBaseFeature
172
176
  $update_match[$id_alias] = $fctx->reqdata[$id_alias];
173
177
  }
174
178
  }
179
+ if (empty($update_match)) {
180
+ $update_match = $resolve_match([]);
181
+ }
175
182
  $ent = $find_first($entmap, $update_match, $alias);
176
183
  if ($ent === null) {
177
184
  return $respond(404, null, ['statusText' => 'Not found']);
@@ -90,8 +90,10 @@ class ProjectNameTestFeature(ProjectNameBaseFeature):
90
90
  # Match the existing entity by id only (or its alias). reqdata
91
91
  # also contains the new field values, which would otherwise
92
92
  # cause select to filter out the entity we want to update.
93
- # Falls back to first entity when no match found, mirroring
94
- # the TS mock.
93
+ # When reqdata has no id, fall back to the id the entity
94
+ # client carries from a prior create/load (in fctx.match /
95
+ # fctx.data), mirroring the TS mock where param(ctx,'id')
96
+ # resolves from accumulated state.
95
97
  update_match = {}
96
98
  if isinstance(fctx.reqdata, dict):
97
99
  if "id" in fctx.reqdata:
@@ -101,6 +103,8 @@ class ProjectNameTestFeature(ProjectNameBaseFeature):
101
103
  alias_id = vs.getprop(alias_map, "id")
102
104
  if alias_id is not None and alias_id in fctx.reqdata:
103
105
  update_match[alias_id] = fctx.reqdata[alias_id]
106
+ if not update_match:
107
+ update_match = _resolve_match({})
104
108
  args = test_self.build_args(fctx, op, update_match)
105
109
  found = vs.select(entmap, args)
106
110
  ent = vs.getelem(found, 0)
@@ -84,10 +84,10 @@ class ProjectNameTestFeature < ProjectNameBaseFeature
84
84
  elsif op.name == "update"
85
85
  # Match the existing entity by id only (or its alias). reqdata also
86
86
  # contains the new field values, which would otherwise cause select
87
- # to filter out the entity we want to update. Falls back to first
88
- # entity when no id present and no match found, mirroring the TS
89
- # mock's empirical behavior where param(undef) collapses to "no
90
- # constraint" and select returns all.
87
+ # to filter out the entity we want to update. When reqdata has no id,
88
+ # fall back to the id the entity client carries from a prior
89
+ # create/load (in fctx.match / fctx.data), mirroring the TS mock
90
+ # where param(ctx,'id') resolves from accumulated state.
91
91
  update_match = {}
92
92
  if fctx.reqdata.is_a?(Hash)
93
93
  update_match["id"] = fctx.reqdata["id"] if fctx.reqdata.key?("id")
@@ -98,6 +98,7 @@ class ProjectNameTestFeature < ProjectNameBaseFeature
98
98
  end
99
99
  end
100
100
  end
101
+ update_match = resolve_match.call({}) if update_match.empty?
101
102
  args = test_self.build_args(fctx, op, update_match)
102
103
  found = VoxgigStruct.select(entmap, args)
103
104
  ent = VoxgigStruct.getelem(found, 0)