@voxgig/sdkgen 0.36.0 → 0.37.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.
- package/bin/voxgig-sdkgen +1 -1
- package/dist/cmp/Main.js +0 -12
- package/dist/cmp/Main.js.map +1 -1
- package/package.json +1 -1
- package/project/.sdk/src/cmp/go/Config_go.ts +6 -2
- package/project/.sdk/src/cmp/js/EntityBase_js.ts +34 -0
- package/project/.sdk/src/cmp/js/Main_js.ts +10 -0
- package/project/.sdk/src/cmp/js/ReadmeExplanation_js.ts +33 -0
- package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +123 -0
- package/project/.sdk/src/cmp/js/ReadmeModel_js.ts +152 -0
- package/project/.sdk/src/cmp/js/ReadmeTopHowto_js.ts +25 -0
- package/project/.sdk/src/cmp/js/ReadmeTopQuick_js.ts +65 -0
- package/project/.sdk/src/cmp/js/ReadmeTopTest_js.ts +36 -0
- package/project/.sdk/src/cmp/js/TestDirect_js.ts +53 -5
- package/project/.sdk/src/cmp/js/TestEntity_js.ts +114 -20
- package/project/.sdk/src/cmp/js/fragment/Entity.fragment.js +7 -139
- package/project/.sdk/src/cmp/js/fragment/EntityBase.fragment.js +149 -0
- package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +6 -10
- package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +6 -10
- package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +7 -11
- package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +7 -11
- package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +7 -11
- package/project/.sdk/src/cmp/js/fragment/Main.fragment.js +2 -0
- package/project/.sdk/src/cmp/js/fragment/SdkError.fragment.js +0 -2
- package/project/.sdk/src/cmp/lua/Config_lua.ts +6 -2
- package/project/.sdk/src/cmp/lua/TestEntity_lua.ts +3 -1
- package/project/.sdk/src/cmp/php/Config_php.ts +6 -2
- package/project/.sdk/src/cmp/php/TestDirect_php.ts +2 -2
- package/project/.sdk/src/cmp/php/TestEntity_php.ts +10 -15
- package/project/.sdk/src/cmp/py/Config_py.ts +6 -2
- package/project/.sdk/src/cmp/py/TestEntity_py.ts +3 -1
- package/project/.sdk/src/cmp/rb/Config_rb.ts +6 -2
- package/project/.sdk/src/cmp/ts/Main_ts.ts +7 -0
- package/project/.sdk/tm/go/feature/log_feature.go +1 -1
- package/project/.sdk/tm/go/test/runner_test.go +16 -2
- package/project/.sdk/tm/js/src/Context.js +142 -0
- package/project/.sdk/tm/js/src/Control.js +16 -0
- package/project/.sdk/tm/js/src/Operation.js +19 -0
- package/project/.sdk/tm/js/src/Point.js +24 -0
- package/project/.sdk/tm/js/src/README.md +1 -0
- package/project/.sdk/tm/js/src/Response.js +19 -0
- package/project/.sdk/tm/js/src/Result.js +21 -0
- package/project/.sdk/tm/js/src/Spec.js +26 -0
- package/project/.sdk/tm/js/src/feature/README.md +1 -0
- package/project/.sdk/tm/js/src/feature/base/BaseFeature.js +45 -0
- package/project/.sdk/tm/js/src/feature/log/LogFeature.js +46 -47
- package/project/.sdk/tm/js/src/feature/test/TestFeature.js +207 -0
- package/project/.sdk/tm/js/src/types.js +22 -0
- package/project/.sdk/tm/js/src/utility/CleanUtility.js +31 -0
- package/project/.sdk/tm/js/src/utility/DoneUtility.js +11 -4
- package/project/.sdk/tm/js/src/utility/FeatureAddUtility.js +42 -0
- package/project/.sdk/tm/js/src/utility/FeatureHookUtility.js +25 -0
- package/project/.sdk/tm/js/src/utility/FeatureInitUtility.js +11 -0
- package/project/.sdk/tm/js/src/utility/FetcherUtility.js +28 -0
- package/project/.sdk/tm/js/src/utility/MakeContextUtility.js +11 -0
- package/project/.sdk/tm/js/src/utility/MakeErrorUtility.js +55 -0
- package/project/.sdk/tm/js/src/utility/MakeFetchDefUtility.js +44 -0
- package/project/.sdk/tm/js/src/utility/MakeOptionsUtility.js +93 -0
- package/project/.sdk/tm/js/src/utility/MakePointUtility.js +77 -0
- package/project/.sdk/tm/js/src/utility/MakeRequestUtility.js +63 -0
- package/project/.sdk/tm/js/src/utility/MakeResponseUtility.js +55 -0
- package/project/.sdk/tm/js/src/utility/MakeResultUtility.js +54 -0
- package/project/.sdk/tm/js/src/utility/MakeSpecUtility.js +58 -0
- package/project/.sdk/tm/js/src/utility/MakeUrlUtility.js +40 -0
- package/project/.sdk/tm/js/src/utility/ParamUtility.js +61 -0
- package/project/.sdk/tm/js/src/utility/PrepareAuthUtility.js +41 -0
- package/project/.sdk/tm/js/src/utility/PrepareBodyUtility.js +25 -0
- package/project/.sdk/tm/js/src/utility/PrepareHeadersUtility.js +18 -0
- package/project/.sdk/tm/js/src/utility/{MethodUtility.js → PrepareMethodUtility.js} +7 -7
- package/project/.sdk/tm/js/src/utility/PrepareParamsUtility.js +25 -0
- package/project/.sdk/tm/js/src/utility/PreparePathUtility.js +13 -0
- package/project/.sdk/tm/js/src/utility/PrepareQueryUtility.js +26 -0
- package/project/.sdk/tm/js/src/utility/README.md +1 -0
- package/project/.sdk/tm/js/src/utility/ResultBasicUtility.js +34 -0
- package/project/.sdk/tm/js/src/utility/ResultBodyUtility.js +18 -0
- package/project/.sdk/tm/js/src/utility/ResultHeadersUtility.js +22 -0
- package/project/.sdk/tm/js/src/utility/StructUtility.js +2219 -1078
- package/project/.sdk/tm/js/src/utility/TransformRequestUtility.js +28 -0
- package/project/.sdk/tm/js/src/utility/TransformResponseUtility.js +31 -0
- package/project/.sdk/tm/js/src/utility/Utility.js +61 -61
- package/project/.sdk/tm/js/test/README.md +1 -0
- package/project/.sdk/tm/js/test/exists.test.js +16 -0
- package/project/.sdk/tm/js/test/runner.js +323 -107
- package/project/.sdk/tm/js/test/utility/Custom.test.js +41 -63
- package/project/.sdk/tm/js/test/utility/PrimaryUtility.test.js +390 -116
- package/project/.sdk/tm/js/test/utility/StructUtility.test.js +728 -175
- package/project/.sdk/tm/js/test/utility/index.js +9 -0
- package/project/.sdk/tm/js/test/utility.js +72 -0
- package/project/.sdk/tm/lua/test/primary_utility_test.lua +1213 -0
- package/project/.sdk/tm/lua/test/runner.lua +2 -2
- package/project/.sdk/tm/lua/test/struct_runner.lua +602 -0
- package/project/.sdk/tm/lua/test/struct_utility_test.lua +959 -0
- package/project/.sdk/tm/lua/utility/struct/struct.lua +10 -0
- package/project/.sdk/tm/php/feature/TestFeature.php +59 -96
- package/project/.sdk/tm/php/test/PrimaryUtilityTest.php +1309 -0
- package/project/.sdk/tm/php/test/Runner.php +24 -1
- package/project/.sdk/tm/php/test/StructRunner.php +275 -0
- package/project/.sdk/tm/php/test/StructUtilityTest.php +1336 -0
- package/project/.sdk/tm/php/utility/Fetcher.php +6 -2
- package/project/.sdk/tm/php/utility/MakeOptions.php +5 -1
- package/project/.sdk/tm/php/utility/MakeResult.php +3 -0
- package/project/.sdk/tm/php/utility/Param.php +9 -7
- package/project/.sdk/tm/php/utility/struct/Struct.php +312 -208
- package/project/.sdk/tm/py/test/runner.py +13 -0
- package/project/.sdk/tm/py/test/struct_runner.py +411 -0
- package/project/.sdk/tm/py/test/test_primary_utility.py +1101 -0
- package/project/.sdk/tm/py/test/test_struct_utility.py +751 -0
- package/project/.sdk/tm/rb/test/primary_utility_test.rb +1083 -0
- package/project/.sdk/tm/rb/test/runner.rb +5 -0
- package/project/.sdk/tm/rb/test/struct_runner.rb +309 -0
- package/project/.sdk/tm/rb/test/struct_utility_test.rb +670 -0
- package/src/cmp/Main.ts +1 -16
- package/project/.sdk/src/cmp/js/Quick_js.ts +0 -78
- package/project/.sdk/src/cmp/js/TestAcceptEntity_js.ts +0 -13
- package/project/.sdk/src/cmp/js/TestAccept_js.ts +0 -18
- package/project/.sdk/tm/js/src/utility/AuthUtility.js +0 -21
- package/project/.sdk/tm/js/src/utility/BodyUtility.js +0 -29
- package/project/.sdk/tm/js/src/utility/ErrorUtility.js +0 -33
- package/project/.sdk/tm/js/src/utility/FindparamUtility.js +0 -31
- package/project/.sdk/tm/js/src/utility/FullurlUtility.js +0 -39
- package/project/.sdk/tm/js/src/utility/HeadersUtility.js +0 -13
- package/project/.sdk/tm/js/src/utility/JoinurlUtility.js +0 -14
- package/project/.sdk/tm/js/src/utility/OperatorUtility.js +0 -44
- package/project/.sdk/tm/js/src/utility/OptionsUtility.js +0 -54
- package/project/.sdk/tm/js/src/utility/ParamsUtility.js +0 -21
- package/project/.sdk/tm/js/src/utility/QueryUtility.js +0 -21
- package/project/.sdk/tm/js/src/utility/ReqformUtility.js +0 -32
- package/project/.sdk/tm/js/src/utility/RequestUtility.js +0 -48
- package/project/.sdk/tm/js/src/utility/ResbasicUtility.js +0 -27
- package/project/.sdk/tm/js/src/utility/ResbodyUtility.js +0 -15
- package/project/.sdk/tm/js/src/utility/ResformUtility.js +0 -34
- package/project/.sdk/tm/js/src/utility/ResheadersUtility.js +0 -19
- package/project/.sdk/tm/js/src/utility/ResponseUtility.js +0 -37
- package/project/.sdk/tm/js/src/utility/ResultUtility.js +0 -28
- package/project/.sdk/tm/js/src/utility/SpecUtility.js +0 -35
|
@@ -1394,7 +1394,17 @@ local function merge(val, maxdepth)
|
|
|
1394
1394
|
end
|
|
1395
1395
|
|
|
1396
1396
|
local list = val
|
|
1397
|
+
|
|
1398
|
+
-- Use rawlen or find max integer key to handle nil gaps in arrays.
|
|
1397
1399
|
local lenlist = #list
|
|
1400
|
+
if lenlist == 0 then
|
|
1401
|
+
-- Check for nil gaps: find the actual max integer key.
|
|
1402
|
+
for k in pairs(list) do
|
|
1403
|
+
if type(k) == S_number and k > lenlist then
|
|
1404
|
+
lenlist = k
|
|
1405
|
+
end
|
|
1406
|
+
end
|
|
1407
|
+
end
|
|
1398
1408
|
|
|
1399
1409
|
if lenlist == 0 then
|
|
1400
1410
|
return NONE
|
|
@@ -25,24 +25,26 @@ class ProjectNameTestFeature extends ProjectNameBaseFeature
|
|
|
25
25
|
$this->client = $ctx->client;
|
|
26
26
|
$this->options = $options;
|
|
27
27
|
|
|
28
|
-
$
|
|
29
|
-
if (!is_array($
|
|
30
|
-
$
|
|
28
|
+
$entity_data = \Voxgig\Struct\Struct::getprop($options, 'entity');
|
|
29
|
+
if (!is_array($entity_data)) {
|
|
30
|
+
$entity_data = [];
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
$this->client->mode = 'test';
|
|
34
34
|
|
|
35
35
|
// Ensure entity ids are correct.
|
|
36
|
-
\Voxgig\Struct\Struct::walk($
|
|
36
|
+
\Voxgig\Struct\Struct::walk($entity_data, function ($key, $val, $parent, $path) {
|
|
37
37
|
if (count($path) === 2 && is_array($val) && $key !== null) {
|
|
38
38
|
$val['id'] = $key;
|
|
39
39
|
}
|
|
40
40
|
return $val;
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
// Wrap in object so closure mutations persist (PHP arrays are value types).
|
|
44
|
+
$entity = new \stdClass();
|
|
45
|
+
$entity->data = $entity_data;
|
|
44
46
|
|
|
45
|
-
$test_fetcher = function (ProjectNameContext $fctx, string $_fullurl, array $_fetchdef) use ($entity
|
|
47
|
+
$test_fetcher = function (ProjectNameContext $fctx, string $_fullurl, array $_fetchdef) use ($entity): array {
|
|
46
48
|
$respond = function (int $status, mixed $data, ?array $extra): array {
|
|
47
49
|
$out = [
|
|
48
50
|
'status' => $status,
|
|
@@ -59,83 +61,90 @@ class ProjectNameTestFeature extends ProjectNameBaseFeature
|
|
|
59
61
|
};
|
|
60
62
|
|
|
61
63
|
$op = $fctx->op;
|
|
62
|
-
$
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
$entname = $op->entity;
|
|
65
|
+
$entmap = is_array($entity->data[$entname] ?? null) ? $entity->data[$entname] : [];
|
|
66
|
+
|
|
67
|
+
// Extract id from context: reqmatch for load/remove, reqdata for update/create.
|
|
68
|
+
$get_id = function () use ($fctx) {
|
|
69
|
+
$sources = [$fctx->reqmatch, $fctx->reqdata, $fctx->data];
|
|
70
|
+
foreach ($sources as $src) {
|
|
71
|
+
if (is_array($src) && isset($src['id']) && $src['id'] !== '__UNDEFINED__') {
|
|
72
|
+
return $src['id'];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
};
|
|
66
77
|
|
|
67
78
|
if ($op->name === 'load') {
|
|
68
|
-
$
|
|
69
|
-
$
|
|
70
|
-
|
|
79
|
+
$id = $get_id();
|
|
80
|
+
$ent = ($id !== null && isset($entmap[$id])) ? $entmap[$id] : null;
|
|
81
|
+
if (!$ent) {
|
|
82
|
+
// Fallback: search by id field value
|
|
83
|
+
foreach ($entmap as $e) {
|
|
84
|
+
if (is_array($e) && ($e['id'] ?? null) === $id) { $ent = $e; break; }
|
|
85
|
+
}
|
|
86
|
+
}
|
|
71
87
|
if (!$ent) {
|
|
72
88
|
return $respond(404, null, ['statusText' => 'Not found']);
|
|
73
89
|
}
|
|
74
|
-
\Voxgig\Struct\Struct::delprop($ent, '$KEY');
|
|
75
90
|
$out = \Voxgig\Struct\Struct::clone($ent);
|
|
91
|
+
if (is_array($out)) { unset($out['$KEY']); }
|
|
76
92
|
return $respond(200, $out, null);
|
|
77
93
|
|
|
78
94
|
} elseif ($op->name === 'list') {
|
|
79
|
-
$
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
foreach ($found as $item) {
|
|
86
|
-
\Voxgig\Struct\Struct::delprop($item, '$KEY');
|
|
95
|
+
$out = [];
|
|
96
|
+
foreach ($entmap as $e) {
|
|
97
|
+
if (is_array($e)) {
|
|
98
|
+
$copy = $e;
|
|
99
|
+
unset($copy['$KEY']);
|
|
100
|
+
$out[] = $copy;
|
|
87
101
|
}
|
|
88
102
|
}
|
|
89
|
-
$out = \Voxgig\Struct\Struct::clone($found);
|
|
90
103
|
return $respond(200, $out, null);
|
|
91
104
|
|
|
92
105
|
} elseif ($op->name === 'update') {
|
|
93
|
-
$
|
|
94
|
-
$
|
|
95
|
-
|
|
106
|
+
$id = $get_id();
|
|
107
|
+
$ent = ($id !== null && isset($entmap[$id])) ? $entmap[$id] : null;
|
|
108
|
+
if (!$ent) {
|
|
109
|
+
foreach ($entmap as $e) {
|
|
110
|
+
if (is_array($e) && ($e['id'] ?? null) === $id) { $ent = $e; break; }
|
|
111
|
+
}
|
|
112
|
+
}
|
|
96
113
|
if (!$ent) {
|
|
97
114
|
return $respond(404, null, ['statusText' => 'Not found']);
|
|
98
115
|
}
|
|
99
|
-
if (is_array($
|
|
116
|
+
if (is_array($fctx->reqdata)) {
|
|
100
117
|
foreach ($fctx->reqdata as $k => $v) {
|
|
101
118
|
$ent[$k] = $v;
|
|
102
119
|
}
|
|
103
120
|
}
|
|
104
|
-
|
|
121
|
+
$entmap[$id] = $ent;
|
|
122
|
+
$entity->data[$entname] = $entmap;
|
|
105
123
|
$out = \Voxgig\Struct\Struct::clone($ent);
|
|
124
|
+
if (is_array($out)) { unset($out['$KEY']); }
|
|
106
125
|
return $respond(200, $out, null);
|
|
107
126
|
|
|
108
127
|
} elseif ($op->name === 'remove') {
|
|
109
|
-
$
|
|
110
|
-
$
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return $respond(404, null, ['statusText' => 'Not found']);
|
|
114
|
-
}
|
|
115
|
-
if (is_array($ent)) {
|
|
116
|
-
$id = \Voxgig\Struct\Struct::getprop($ent, 'id');
|
|
117
|
-
\Voxgig\Struct\Struct::delprop($entmap, $id);
|
|
128
|
+
$id = $get_id();
|
|
129
|
+
if ($id !== null && isset($entmap[$id])) {
|
|
130
|
+
unset($entmap[$id]);
|
|
131
|
+
$entity->data[$entname] = $entmap;
|
|
118
132
|
}
|
|
119
133
|
return $respond(200, null, null);
|
|
120
134
|
|
|
121
135
|
} elseif ($op->name === 'create') {
|
|
122
|
-
$
|
|
123
|
-
$id = ($fctx->utility->param)($fctx, 'id');
|
|
136
|
+
$id = $get_id();
|
|
124
137
|
if ($id === null) {
|
|
125
138
|
$id = sprintf('%04x%04x%04x%04x', random_int(0, 0xFFFF), random_int(0, 0xFFFF), random_int(0, 0xFFFF), random_int(0, 0xFFFF));
|
|
126
139
|
}
|
|
127
140
|
|
|
128
|
-
$ent =
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
$out = \Voxgig\Struct\Struct::clone($ent);
|
|
136
|
-
return $respond(200, $out, null);
|
|
137
|
-
}
|
|
138
|
-
return $respond(200, $ent, null);
|
|
141
|
+
$ent = is_array($fctx->reqdata) ? $fctx->reqdata : [];
|
|
142
|
+
$ent['id'] = $id;
|
|
143
|
+
$entmap[$id] = $ent;
|
|
144
|
+
$entity->data[$entname] = $entmap;
|
|
145
|
+
$out = \Voxgig\Struct\Struct::clone($ent);
|
|
146
|
+
if (is_array($out)) { unset($out['$KEY']); }
|
|
147
|
+
return $respond(200, $out, null);
|
|
139
148
|
|
|
140
149
|
} else {
|
|
141
150
|
return $respond(404, null, ['statusText' => 'Unknown operation']);
|
|
@@ -144,50 +153,4 @@ class ProjectNameTestFeature extends ProjectNameBaseFeature
|
|
|
144
153
|
|
|
145
154
|
$ctx->utility->fetcher = $test_fetcher;
|
|
146
155
|
}
|
|
147
|
-
|
|
148
|
-
public function build_args(ProjectNameContext $ctx, ProjectNameOperation $op, mixed $args): array
|
|
149
|
-
{
|
|
150
|
-
$opname = $op->name;
|
|
151
|
-
$entname = (is_object($ctx->entity) && method_exists($ctx->entity, 'get_name'))
|
|
152
|
-
? $ctx->entity->get_name()
|
|
153
|
-
: '_';
|
|
154
|
-
$points = \Voxgig\Struct\Struct::getpath($ctx->config, "entity.{$entname}.op.{$opname}.points");
|
|
155
|
-
$point = \Voxgig\Struct\Struct::getelem($points, -1);
|
|
156
|
-
|
|
157
|
-
$params_path = \Voxgig\Struct\Struct::getpath($point, 'args.params');
|
|
158
|
-
$reqd_params = \Voxgig\Struct\Struct::select($params_path, ['reqd' => true]);
|
|
159
|
-
$reqd = \Voxgig\Struct\Struct::transform($reqd_params, ['`$EACH`', '', '`$KEY.name`']);
|
|
160
|
-
|
|
161
|
-
$qand = [];
|
|
162
|
-
$q = ['`$AND`' => &$qand];
|
|
163
|
-
|
|
164
|
-
if ($args) {
|
|
165
|
-
$keys = \Voxgig\Struct\Struct::keysof($args);
|
|
166
|
-
if ($keys) {
|
|
167
|
-
foreach ($keys as $key) {
|
|
168
|
-
$is_id = ($key === 'id');
|
|
169
|
-
$selected = \Voxgig\Struct\Struct::select($reqd, $key);
|
|
170
|
-
$is_reqd = !\Voxgig\Struct\Struct::isempty($selected);
|
|
171
|
-
|
|
172
|
-
if ($is_id || $is_reqd) {
|
|
173
|
-
$v = ($ctx->utility->param)($ctx, $key);
|
|
174
|
-
$ka = $op->alias_map ? \Voxgig\Struct\Struct::getprop($op->alias_map, $key) : null;
|
|
175
|
-
|
|
176
|
-
$qor = [[$key => $v]];
|
|
177
|
-
if (is_string($ka)) {
|
|
178
|
-
$qor[] = [$ka => $v];
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
$qand[] = ['`$OR`' => $qor];
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if ($ctx->ctrl->explain) {
|
|
188
|
-
$ctx->ctrl->explain['test'] = ['query' => $q];
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
return $q;
|
|
192
|
-
}
|
|
193
156
|
}
|