@voxgig/sdkgen 4.2.8 → 4.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.
- package/bin/voxgig-sdkgen +1 -1
- package/dist/helpers/naming.d.ts +2 -1
- package/dist/helpers/naming.js +50 -12
- package/dist/helpers/naming.js.map +1 -1
- package/dist/sdkgen.d.ts +2 -2
- package/dist/sdkgen.js +4 -3
- package/dist/sdkgen.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/project/.sdk/src/cmp/zig/Config_zig.ts +1 -1
- package/project/.sdk/tm/c/tests/primary_corpus_test.c +565 -0
- package/project/.sdk/tm/c/utility/prepare_method.c +3 -1
- package/project/.sdk/tm/c/utility/transform_request.c +4 -3
- package/project/.sdk/tm/clojure/src/sdk/core.clj +55 -5
- package/project/.sdk/tm/clojure/test/sdk/test/primary.clj +171 -1
- package/project/.sdk/tm/clojure/test/sdk/test/struct_corpus.clj +13 -2
- package/project/.sdk/tm/clojure/test/sdk/test_runner.clj +2 -0
- package/project/.sdk/tm/csharp/test/CustomUtilityTest.cs +104 -0
- package/project/.sdk/tm/csharp/utility/MakeOptions.cs +82 -2
- package/project/.sdk/tm/elixir/lib/projectname/utility.ex +50 -2
- package/project/.sdk/tm/elixir/test/primary_utility_test.exs +18 -200
- package/project/.sdk/tm/elixir/test/support/struct_corpus.ex +413 -2
- package/project/.sdk/tm/go/test/custom_utility_test.go +103 -0
- package/project/.sdk/tm/go/test/feature_corpus_test.go +550 -0
- package/project/.sdk/tm/go/utility/make_options.go +7 -1
- package/project/.sdk/tm/go/utility/register.go +194 -0
- package/project/.sdk/tm/java/test/CustomUtilityTest.java +55 -0
- package/project/.sdk/tm/java/test/FeatureCorpusTest.java +463 -0
- package/project/.sdk/tm/java/utility/MakeOptions.java +11 -2
- package/project/.sdk/tm/java/utility/Register.java +91 -0
- package/project/.sdk/tm/js/test/feature/Corpus.test.js +285 -0
- package/project/.sdk/tm/kotlin/utility/MakeOptions.kt +56 -2
- package/project/.sdk/tm/lua/utility/make_options.lua +22 -2
- package/project/.sdk/tm/ocaml/Makefile +15 -4
- package/project/.sdk/tm/ocaml/sdk_runtime.ml +8 -1
- package/project/.sdk/tm/ocaml/test/corpus_runner.ml +185 -0
- package/project/.sdk/tm/ocaml/test/primary_utility_test.ml +238 -0
- package/project/.sdk/tm/ocaml/test/struct_corpus.ml +5 -160
- package/project/.sdk/tm/perl/t/feature_corpus.t +345 -0
- package/project/.sdk/tm/perl/utility/make_options.pm +33 -1
- package/project/.sdk/tm/php/core/Context.php +3 -0
- package/project/.sdk/tm/php/core/Control.php +13 -0
- package/project/.sdk/tm/php/core/Error.php +12 -0
- package/project/.sdk/tm/php/test/FeatureCorpusTest.php +376 -0
- package/project/.sdk/tm/php/utility/MakeOptions.php +30 -1
- package/project/.sdk/tm/py/pkg/utility/make_options.py +42 -1
- package/project/.sdk/tm/py/test/test_feature_corpus.py +309 -0
- package/project/.sdk/tm/rb/test/feature_corpus_test.rb +281 -0
- package/project/.sdk/tm/rb/utility/make_options.rb +32 -1
- package/project/.sdk/tm/scala/Makefile +1 -0
- package/project/.sdk/tm/scala/sdktest/PrimaryCorpus.scala +294 -0
- package/project/.sdk/tm/scala/sdktest/StructCorpus.scala +0 -0
- package/project/.sdk/tm/scala/utility/Make.scala +49 -2
- package/project/.sdk/tm/scala/utility/Prepare.scala +3 -1
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeOptions.swift +21 -3
- package/project/.sdk/tm/ts/src/feature/test/TestFeature.ts +13 -2
- package/project/.sdk/tm/ts/test/feature/Corpus.test.ts +287 -0
- package/project/.sdk/tm/zig/core/utility.zig +8 -1
- package/project/.sdk/tm/zig/test/primary_utility_test.zig +445 -0
- package/project/.sdk/tm/zig/test/struct_runner.zig +238 -0
- package/project/sdkgen-package.json +1 -1
- package/src/helpers/naming.ts +54 -12
- package/src/sdkgen.ts +2 -1
|
@@ -39,3 +39,197 @@ func registerAll(u *core.Utility) {
|
|
|
39
39
|
u.TransformRequest = transformRequestUtil
|
|
40
40
|
u.TransformResponse = transformResponseUtil
|
|
41
41
|
}
|
|
42
|
+
|
|
43
|
+
// overrideUtil replaces one utility member from `options.utility`, matching
|
|
44
|
+
// the ts reference: a key naming a real utility member REPLACES it, and any
|
|
45
|
+
// other key is attached as a custom extra.
|
|
46
|
+
//
|
|
47
|
+
// Without this the override was a no-op here. `makeOptions` put every entry
|
|
48
|
+
// in `u.Custom`, which nothing reads, so a caller passing
|
|
49
|
+
// `utility: {"fetcher": myTransport}` - the documented way to script the
|
|
50
|
+
// transport, and the seam the shared feature corpus runs on - was silently
|
|
51
|
+
// ignored while ts and js honoured it. The custom-utility test did not catch
|
|
52
|
+
// it because it asserted the side map rather than the behaviour.
|
|
53
|
+
//
|
|
54
|
+
// Returns false when the key names no member, or when the value is not that
|
|
55
|
+
// member's signature; the caller then keeps it in Custom. A wrong signature
|
|
56
|
+
// is deliberately NOT an error: ts attaches whatever it is given, so a typed
|
|
57
|
+
// port that rejected it outright would diverge in the other direction.
|
|
58
|
+
//
|
|
59
|
+
// Keep this list in step with registerAll above - a utility added to one and
|
|
60
|
+
// not the other is overridable in ts and not here, which is the divergence
|
|
61
|
+
// this exists to remove.
|
|
62
|
+
func overrideUtil(u *core.Utility, key string, val any) bool {
|
|
63
|
+
switch key {
|
|
64
|
+
case "clean":
|
|
65
|
+
if fn, ok := val.(func(ctx *core.Context, val any) any); ok {
|
|
66
|
+
u.Clean = fn
|
|
67
|
+
return true
|
|
68
|
+
}
|
|
69
|
+
case "done":
|
|
70
|
+
if fn, ok := val.(func(ctx *core.Context) (any, error)); ok {
|
|
71
|
+
u.Done = fn
|
|
72
|
+
return true
|
|
73
|
+
}
|
|
74
|
+
case "makeError":
|
|
75
|
+
if fn, ok := val.(func(ctx *core.Context, err error) (any, error)); ok {
|
|
76
|
+
u.MakeError = fn
|
|
77
|
+
return true
|
|
78
|
+
}
|
|
79
|
+
case "featureAdd":
|
|
80
|
+
if fn, ok := val.(func(ctx *core.Context, f core.Feature)); ok {
|
|
81
|
+
u.FeatureAdd = fn
|
|
82
|
+
return true
|
|
83
|
+
}
|
|
84
|
+
case "featureHook":
|
|
85
|
+
if fn, ok := val.(func(ctx *core.Context, name string)); ok {
|
|
86
|
+
u.FeatureHook = fn
|
|
87
|
+
return true
|
|
88
|
+
}
|
|
89
|
+
case "featureInit":
|
|
90
|
+
if fn, ok := val.(func(ctx *core.Context, f core.Feature)); ok {
|
|
91
|
+
u.FeatureInit = fn
|
|
92
|
+
return true
|
|
93
|
+
}
|
|
94
|
+
case "fetcher":
|
|
95
|
+
// BOTH SPELLINGS. Fetcher is the one member declared as a NAMED type,
|
|
96
|
+
// and a type assertion to a defined type matches only that exact
|
|
97
|
+
// dynamic type. A plain function literal in a map[string]any - the
|
|
98
|
+
// ordinary way to write this - carries the UNNAMED signature and
|
|
99
|
+
// asserts to `func(...)` but not to `core.FetcherFunc`; a value the
|
|
100
|
+
// caller converted asserts to `core.FetcherFunc` but not to the
|
|
101
|
+
// unnamed one. Accepting only the named type shelved every ordinary
|
|
102
|
+
// caller's transport in Custom, which is the exact defect this
|
|
103
|
+
// function exists to remove.
|
|
104
|
+
if fn, ok := val.(core.FetcherFunc); ok {
|
|
105
|
+
u.Fetcher = fn
|
|
106
|
+
return true
|
|
107
|
+
}
|
|
108
|
+
if fn, ok := val.(func(ctx *core.Context, fullurl string,
|
|
109
|
+
fetchdef map[string]any) (any, error)); ok {
|
|
110
|
+
u.Fetcher = fn
|
|
111
|
+
return true
|
|
112
|
+
}
|
|
113
|
+
case "makeFetchDef":
|
|
114
|
+
if fn, ok := val.(func(ctx *core.Context) (map[string]any, error)); ok {
|
|
115
|
+
u.MakeFetchDef = fn
|
|
116
|
+
return true
|
|
117
|
+
}
|
|
118
|
+
case "makeContext":
|
|
119
|
+
if fn, ok := val.(func(ctxmap map[string]any, basectx *core.Context) *core.Context); ok {
|
|
120
|
+
u.MakeContext = fn
|
|
121
|
+
return true
|
|
122
|
+
}
|
|
123
|
+
case "makeOptions":
|
|
124
|
+
if fn, ok := val.(func(ctx *core.Context) map[string]any); ok {
|
|
125
|
+
u.MakeOptions = fn
|
|
126
|
+
return true
|
|
127
|
+
}
|
|
128
|
+
case "makeRequest":
|
|
129
|
+
if fn, ok := val.(func(ctx *core.Context) (*core.Response, error)); ok {
|
|
130
|
+
u.MakeRequest = fn
|
|
131
|
+
return true
|
|
132
|
+
}
|
|
133
|
+
case "makeResponse":
|
|
134
|
+
if fn, ok := val.(func(ctx *core.Context) (*core.Response, error)); ok {
|
|
135
|
+
u.MakeResponse = fn
|
|
136
|
+
return true
|
|
137
|
+
}
|
|
138
|
+
case "makeResult":
|
|
139
|
+
if fn, ok := val.(func(ctx *core.Context) (*core.Result, error)); ok {
|
|
140
|
+
u.MakeResult = fn
|
|
141
|
+
return true
|
|
142
|
+
}
|
|
143
|
+
case "makePoint":
|
|
144
|
+
if fn, ok := val.(func(ctx *core.Context) (map[string]any, error)); ok {
|
|
145
|
+
u.MakePoint = fn
|
|
146
|
+
return true
|
|
147
|
+
}
|
|
148
|
+
case "makeSpec":
|
|
149
|
+
if fn, ok := val.(func(ctx *core.Context) (*core.Spec, error)); ok {
|
|
150
|
+
u.MakeSpec = fn
|
|
151
|
+
return true
|
|
152
|
+
}
|
|
153
|
+
case "makeUrl":
|
|
154
|
+
if fn, ok := val.(func(ctx *core.Context) (string, error)); ok {
|
|
155
|
+
u.MakeUrl = fn
|
|
156
|
+
return true
|
|
157
|
+
}
|
|
158
|
+
case "param":
|
|
159
|
+
if fn, ok := val.(func(ctx *core.Context, paramdef any) any); ok {
|
|
160
|
+
u.Param = fn
|
|
161
|
+
return true
|
|
162
|
+
}
|
|
163
|
+
case "prepareAuth":
|
|
164
|
+
if fn, ok := val.(func(ctx *core.Context) (*core.Spec, error)); ok {
|
|
165
|
+
u.PrepareAuth = fn
|
|
166
|
+
return true
|
|
167
|
+
}
|
|
168
|
+
case "prepareBody":
|
|
169
|
+
if fn, ok := val.(func(ctx *core.Context) any); ok {
|
|
170
|
+
u.PrepareBody = fn
|
|
171
|
+
return true
|
|
172
|
+
}
|
|
173
|
+
case "prepareHeaders":
|
|
174
|
+
if fn, ok := val.(func(ctx *core.Context) map[string]any); ok {
|
|
175
|
+
u.PrepareHeaders = fn
|
|
176
|
+
return true
|
|
177
|
+
}
|
|
178
|
+
case "prepareMethod":
|
|
179
|
+
if fn, ok := val.(func(ctx *core.Context) string); ok {
|
|
180
|
+
u.PrepareMethod = fn
|
|
181
|
+
return true
|
|
182
|
+
}
|
|
183
|
+
case "prepareParams":
|
|
184
|
+
if fn, ok := val.(func(ctx *core.Context) map[string]any); ok {
|
|
185
|
+
u.PrepareParams = fn
|
|
186
|
+
return true
|
|
187
|
+
}
|
|
188
|
+
case "preparePath":
|
|
189
|
+
if fn, ok := val.(func(ctx *core.Context) string); ok {
|
|
190
|
+
u.PreparePath = fn
|
|
191
|
+
return true
|
|
192
|
+
}
|
|
193
|
+
case "prepareQuery":
|
|
194
|
+
if fn, ok := val.(func(ctx *core.Context) map[string]any); ok {
|
|
195
|
+
u.PrepareQuery = fn
|
|
196
|
+
return true
|
|
197
|
+
}
|
|
198
|
+
case "graphqlBody":
|
|
199
|
+
if fn, ok := val.(func(ctx *core.Context) any); ok {
|
|
200
|
+
u.GraphqlBody = fn
|
|
201
|
+
return true
|
|
202
|
+
}
|
|
203
|
+
case "graphqlErrors":
|
|
204
|
+
if fn, ok := val.(func(ctx *core.Context) bool); ok {
|
|
205
|
+
u.GraphqlErrors = fn
|
|
206
|
+
return true
|
|
207
|
+
}
|
|
208
|
+
case "resultBasic":
|
|
209
|
+
if fn, ok := val.(func(ctx *core.Context) *core.Result); ok {
|
|
210
|
+
u.ResultBasic = fn
|
|
211
|
+
return true
|
|
212
|
+
}
|
|
213
|
+
case "resultBody":
|
|
214
|
+
if fn, ok := val.(func(ctx *core.Context) *core.Result); ok {
|
|
215
|
+
u.ResultBody = fn
|
|
216
|
+
return true
|
|
217
|
+
}
|
|
218
|
+
case "resultHeaders":
|
|
219
|
+
if fn, ok := val.(func(ctx *core.Context) *core.Result); ok {
|
|
220
|
+
u.ResultHeaders = fn
|
|
221
|
+
return true
|
|
222
|
+
}
|
|
223
|
+
case "transformRequest":
|
|
224
|
+
if fn, ok := val.(func(ctx *core.Context) any); ok {
|
|
225
|
+
u.TransformRequest = fn
|
|
226
|
+
return true
|
|
227
|
+
}
|
|
228
|
+
case "transformResponse":
|
|
229
|
+
if fn, ok := val.(func(ctx *core.Context) any); ok {
|
|
230
|
+
u.TransformResponse = fn
|
|
231
|
+
return true
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return false
|
|
235
|
+
}
|
|
@@ -4,6 +4,8 @@ package JAVAPACKAGE.sdktest;
|
|
|
4
4
|
// utility object's custom map. Mirrors tm/go/test/custom_utility_test.go.
|
|
5
5
|
|
|
6
6
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
7
|
+
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
8
|
+
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
7
9
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
8
10
|
|
|
9
11
|
import static JAVAPACKAGE.sdktest.FeatureHarness.fhMap;
|
|
@@ -14,6 +16,7 @@ import java.util.function.Supplier;
|
|
|
14
16
|
|
|
15
17
|
import org.junit.jupiter.api.Test;
|
|
16
18
|
|
|
19
|
+
import JAVAPACKAGE.core.Context;
|
|
17
20
|
import JAVAPACKAGE.core.ProjectNameSDK;
|
|
18
21
|
import JAVAPACKAGE.core.Utility;
|
|
19
22
|
|
|
@@ -56,4 +59,56 @@ public class CustomUtilityTest {
|
|
|
56
59
|
"custom utility " + key);
|
|
57
60
|
}
|
|
58
61
|
}
|
|
62
|
+
|
|
63
|
+
// The half the test above cannot see. Those keys are ALIASES - `auth`,
|
|
64
|
+
// `body`, `spec` - and no utility member has those names, so landing in
|
|
65
|
+
// custom is the right outcome for them and the assertion passes whether or
|
|
66
|
+
// not overriding works at all.
|
|
67
|
+
//
|
|
68
|
+
// A key that DOES name a member must replace it. That is the documented
|
|
69
|
+
// contract, it is what ts does, and it was silently absent here: every entry
|
|
70
|
+
// went to custom, which nothing reads, so `utility: {"fetcher": ...}` did
|
|
71
|
+
// nothing while ts honoured it.
|
|
72
|
+
@Test
|
|
73
|
+
public void aRealUtilityMemberIsReplacedNotShelved() {
|
|
74
|
+
int[] reached = {0};
|
|
75
|
+
Utility.FetcherFn scripted = (ctx, fullurl, fetchdef) -> {
|
|
76
|
+
reached[0]++;
|
|
77
|
+
Map<String, Object> out = new LinkedHashMap<>();
|
|
78
|
+
out.put("status", 200);
|
|
79
|
+
out.put("statusText", "OK");
|
|
80
|
+
out.put("headers", new LinkedHashMap<String, Object>());
|
|
81
|
+
out.put("body", "{}");
|
|
82
|
+
return out;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// The plain constructor, not testSDK. The `test` feature is
|
|
86
|
+
// transport: 'base' - it REPLACES the transport by design - so a client in
|
|
87
|
+
// test mode would shadow the scripted fetcher and this would assert
|
|
88
|
+
// nothing.
|
|
89
|
+
ProjectNameSDK client = new ProjectNameSDK(fhMap(
|
|
90
|
+
"utility", fhMap("fetcher", scripted)));
|
|
91
|
+
|
|
92
|
+
Utility u = client.getUtility();
|
|
93
|
+
|
|
94
|
+
assertNotNull(u.fetcher, "fetcher is null");
|
|
95
|
+
assertFalse(u.custom.containsKey("fetcher"),
|
|
96
|
+
"fetcher was shelved in custom instead of replacing the member");
|
|
97
|
+
|
|
98
|
+
// Behaviour, not identity: a lambda cannot be compared, so drive it.
|
|
99
|
+
Context ctx = u.makeContext.apply(
|
|
100
|
+
new LinkedHashMap<String, Object>(), client.getRootCtx());
|
|
101
|
+
u.fetcher.fetch(ctx, "http://example.test/probe", new LinkedHashMap<String, Object>());
|
|
102
|
+
assertEquals(1, reached[0], "the scripted fetcher was not installed");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// An unknown key must still be attached rather than dropped, so the two
|
|
106
|
+
// halves cannot be satisfied by a switch that also swallows extras.
|
|
107
|
+
@Test
|
|
108
|
+
public void anUnknownKeyIsStillAttached() {
|
|
109
|
+
ProjectNameSDK client = new ProjectNameSDK(fhMap(
|
|
110
|
+
"utility", fhMap("notAUtilityMember", (Supplier<String>) () -> "EXTRA")));
|
|
111
|
+
assertTrue(client.getUtility().custom.containsKey("notAUtilityMember"),
|
|
112
|
+
"an unknown utility key was dropped instead of kept in custom");
|
|
113
|
+
}
|
|
59
114
|
}
|