@voxgig/sdkgen 4.35.3 → 4.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/ReadmeTop.js +1 -1
- package/dist/cmp/ReadmeTop.js.map +1 -1
- package/dist/helpers/opExample.d.ts +4 -1
- package/dist/helpers/opExample.js +11 -1
- package/dist/helpers/opExample.js.map +1 -1
- package/dist/helpers/opShape.d.ts +2 -1
- package/dist/helpers/opShape.js +53 -26
- package/dist/helpers/opShape.js.map +1 -1
- package/dist/helpers/pointPath.d.ts +2 -1
- package/dist/helpers/pointPath.js +17 -0
- package/dist/helpers/pointPath.js.map +1 -1
- package/dist/helpers/testPolicy.d.ts +48 -2
- package/dist/helpers/testPolicy.js +265 -0
- package/dist/helpers/testPolicy.js.map +1 -1
- package/dist/sdkgen.d.ts +7 -7
- package/dist/sdkgen.js +26 -4
- package/dist/sdkgen.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/project/.sdk/src/cmp/c/PrepareAuth_c.ts +10 -4
- package/project/.sdk/src/cmp/c/ReadmeEntity_c.ts +2 -2
- package/project/.sdk/src/cmp/c/ReadmeHowto_c.ts +2 -2
- package/project/.sdk/src/cmp/c/ReadmeQuick_c.ts +6 -5
- package/project/.sdk/src/cmp/c/ReadmeRef_c.ts +3 -3
- package/project/.sdk/src/cmp/c/ReadmeTopQuick_c.ts +2 -2
- package/project/.sdk/src/cmp/c/ReadmeTopTest_c.ts +2 -2
- package/project/.sdk/src/cmp/c/TestDirect_c.ts +2 -6
- package/project/.sdk/src/cmp/clojure/ReadmeEntity_clojure.ts +2 -2
- package/project/.sdk/src/cmp/clojure/ReadmeHowto_clojure.ts +2 -2
- package/project/.sdk/src/cmp/clojure/ReadmeQuick_clojure.ts +4 -4
- package/project/.sdk/src/cmp/clojure/ReadmeRef_clojure.ts +3 -3
- package/project/.sdk/src/cmp/clojure/ReadmeTopQuick_clojure.ts +2 -2
- package/project/.sdk/src/cmp/clojure/ReadmeTopTest_clojure.ts +2 -2
- package/project/.sdk/src/cmp/cpp/ReadmeEntity_cpp.ts +2 -2
- package/project/.sdk/src/cmp/cpp/ReadmeHowto_cpp.ts +2 -2
- package/project/.sdk/src/cmp/cpp/ReadmeQuick_cpp.ts +4 -4
- package/project/.sdk/src/cmp/cpp/ReadmeRef_cpp.ts +3 -3
- package/project/.sdk/src/cmp/cpp/ReadmeTopQuick_cpp.ts +2 -2
- package/project/.sdk/src/cmp/cpp/ReadmeTopTest_cpp.ts +2 -2
- package/project/.sdk/src/cmp/cpp/TestDirect_cpp.ts +2 -6
- package/project/.sdk/src/cmp/cpp/TestEntity_cpp.ts +51 -3
- package/project/.sdk/src/cmp/csharp/ReadmeEntity_csharp.ts +2 -2
- package/project/.sdk/src/cmp/csharp/ReadmeHowto_csharp.ts +2 -2
- package/project/.sdk/src/cmp/csharp/ReadmeQuick_csharp.ts +5 -5
- package/project/.sdk/src/cmp/csharp/ReadmeRef_csharp.ts +3 -3
- package/project/.sdk/src/cmp/csharp/ReadmeTopQuick_csharp.ts +3 -3
- package/project/.sdk/src/cmp/csharp/ReadmeTopTest_csharp.ts +2 -2
- package/project/.sdk/src/cmp/csharp/TestDirect_csharp.ts +41 -19
- package/project/.sdk/src/cmp/csharp/TestEntity_csharp.ts +105 -27
- package/project/.sdk/src/cmp/elixir/ReadmeEntity_elixir.ts +2 -2
- package/project/.sdk/src/cmp/elixir/ReadmeHowto_elixir.ts +2 -2
- package/project/.sdk/src/cmp/elixir/ReadmeQuick_elixir.ts +4 -4
- package/project/.sdk/src/cmp/elixir/ReadmeRef_elixir.ts +3 -3
- package/project/.sdk/src/cmp/elixir/ReadmeTopQuick_elixir.ts +2 -2
- package/project/.sdk/src/cmp/elixir/ReadmeTopTest_elixir.ts +2 -2
- package/project/.sdk/src/cmp/go/EntityOperation_go.ts +2 -2
- package/project/.sdk/src/cmp/go/Entity_go.ts +5 -4
- package/project/.sdk/src/cmp/go/MainEntity_go.ts +1 -1
- package/project/.sdk/src/cmp/go/Main_go.ts +9 -5
- package/project/.sdk/src/cmp/go/PrepareAuth_go.ts +24 -15
- package/project/.sdk/src/cmp/go/ReadmeEntity_go.ts +2 -2
- package/project/.sdk/src/cmp/go/ReadmeHowto_go.ts +2 -2
- package/project/.sdk/src/cmp/go/ReadmeModel_go.ts +3 -3
- package/project/.sdk/src/cmp/go/ReadmeQuick_go.ts +4 -4
- package/project/.sdk/src/cmp/go/ReadmeRef_go.ts +4 -4
- package/project/.sdk/src/cmp/go/ReadmeTopTest_go.ts +2 -2
- package/project/.sdk/src/cmp/go/TestDirect_go.ts +61 -26
- package/project/.sdk/src/cmp/go/TestEntity_go.ts +115 -32
- package/project/.sdk/src/cmp/go-cli/fragment/words.fragment.go +1 -1
- package/project/.sdk/src/cmp/go-mcp/fragment/tools.fragment.go +1 -1
- package/project/.sdk/src/cmp/java/ReadmeEntity_java.ts +2 -2
- package/project/.sdk/src/cmp/java/ReadmeHowto_java.ts +2 -2
- package/project/.sdk/src/cmp/java/ReadmeQuick_java.ts +5 -5
- package/project/.sdk/src/cmp/java/ReadmeRef_java.ts +3 -3
- package/project/.sdk/src/cmp/java/ReadmeTopQuick_java.ts +3 -3
- package/project/.sdk/src/cmp/java/ReadmeTopTest_java.ts +2 -2
- package/project/.sdk/src/cmp/java/TestDirect_java.ts +40 -20
- package/project/.sdk/src/cmp/java/TestEntity_java.ts +107 -26
- package/project/.sdk/src/cmp/js/ReadmeEntity_js.ts +2 -2
- package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +2 -2
- package/project/.sdk/src/cmp/js/ReadmeQuick_js.ts +4 -4
- package/project/.sdk/src/cmp/js/ReadmeRef_js.ts +3 -3
- package/project/.sdk/src/cmp/js/ReadmeTopTest_js.ts +2 -2
- package/project/.sdk/src/cmp/js/TestDirect_js.ts +68 -13
- package/project/.sdk/src/cmp/js/TestEntity_js.ts +46 -4
- package/project/.sdk/src/cmp/kotlin/ReadmeEntity_kotlin.ts +2 -2
- package/project/.sdk/src/cmp/kotlin/ReadmeHowto_kotlin.ts +2 -2
- package/project/.sdk/src/cmp/kotlin/ReadmeQuick_kotlin.ts +5 -5
- package/project/.sdk/src/cmp/kotlin/ReadmeRef_kotlin.ts +3 -3
- package/project/.sdk/src/cmp/kotlin/ReadmeTopQuick_kotlin.ts +3 -3
- package/project/.sdk/src/cmp/kotlin/ReadmeTopTest_kotlin.ts +2 -2
- package/project/.sdk/src/cmp/kotlin/TestDirect_kotlin.ts +41 -21
- package/project/.sdk/src/cmp/kotlin/TestEntity_kotlin.ts +99 -22
- package/project/.sdk/src/cmp/lua/ReadmeEntity_lua.ts +2 -2
- package/project/.sdk/src/cmp/lua/ReadmeHowto_lua.ts +2 -2
- package/project/.sdk/src/cmp/lua/ReadmeQuick_lua.ts +4 -4
- package/project/.sdk/src/cmp/lua/ReadmeRef_lua.ts +3 -3
- package/project/.sdk/src/cmp/lua/ReadmeTopQuick_lua.ts +3 -3
- package/project/.sdk/src/cmp/lua/ReadmeTopTest_lua.ts +2 -2
- package/project/.sdk/src/cmp/lua/TestDirect_lua.ts +40 -16
- package/project/.sdk/src/cmp/lua/TestEntity_lua.ts +108 -30
- package/project/.sdk/src/cmp/ocaml/ReadmeEntity_ocaml.ts +2 -2
- package/project/.sdk/src/cmp/ocaml/ReadmeHowto_ocaml.ts +2 -2
- package/project/.sdk/src/cmp/ocaml/ReadmeQuick_ocaml.ts +4 -4
- package/project/.sdk/src/cmp/ocaml/ReadmeRef_ocaml.ts +3 -3
- package/project/.sdk/src/cmp/ocaml/ReadmeTopQuick_ocaml.ts +2 -2
- package/project/.sdk/src/cmp/ocaml/ReadmeTopTest_ocaml.ts +2 -2
- package/project/.sdk/src/cmp/perl/ReadmeEntity_perl.ts +2 -2
- package/project/.sdk/src/cmp/perl/ReadmeHowto_perl.ts +2 -2
- package/project/.sdk/src/cmp/perl/ReadmeQuick_perl.ts +4 -4
- package/project/.sdk/src/cmp/perl/ReadmeRef_perl.ts +3 -3
- package/project/.sdk/src/cmp/perl/ReadmeTopQuick_perl.ts +2 -2
- package/project/.sdk/src/cmp/perl/ReadmeTopTest_perl.ts +2 -2
- package/project/.sdk/src/cmp/perl/TestDirect_perl.ts +35 -16
- package/project/.sdk/src/cmp/perl/TestEntity_perl.ts +98 -22
- package/project/.sdk/src/cmp/php/ReadmeEntity_php.ts +2 -2
- package/project/.sdk/src/cmp/php/ReadmeHowto_php.ts +2 -2
- package/project/.sdk/src/cmp/php/ReadmeQuick_php.ts +4 -4
- package/project/.sdk/src/cmp/php/ReadmeRef_php.ts +3 -3
- package/project/.sdk/src/cmp/php/ReadmeTopQuick_php.ts +2 -2
- package/project/.sdk/src/cmp/php/ReadmeTopTest_php.ts +2 -2
- package/project/.sdk/src/cmp/php/TestDirect_php.ts +33 -16
- package/project/.sdk/src/cmp/php/TestEntity_php.ts +98 -29
- package/project/.sdk/src/cmp/py/ReadmeEntity_py.ts +2 -2
- package/project/.sdk/src/cmp/py/ReadmeHowto_py.ts +2 -2
- package/project/.sdk/src/cmp/py/ReadmeQuick_py.ts +4 -4
- package/project/.sdk/src/cmp/py/ReadmeRef_py.ts +3 -3
- package/project/.sdk/src/cmp/py/ReadmeTopQuick_py.ts +2 -2
- package/project/.sdk/src/cmp/py/ReadmeTopTest_py.ts +2 -2
- package/project/.sdk/src/cmp/py/TestDirect_py.ts +39 -16
- package/project/.sdk/src/cmp/py/TestEntity_py.ts +90 -27
- package/project/.sdk/src/cmp/rb/ReadmeEntity_rb.ts +2 -2
- package/project/.sdk/src/cmp/rb/ReadmeHowto_rb.ts +2 -2
- package/project/.sdk/src/cmp/rb/ReadmeQuick_rb.ts +4 -4
- package/project/.sdk/src/cmp/rb/ReadmeRef_rb.ts +3 -3
- package/project/.sdk/src/cmp/rb/ReadmeTopQuick_rb.ts +2 -2
- package/project/.sdk/src/cmp/rb/ReadmeTopTest_rb.ts +2 -2
- package/project/.sdk/src/cmp/rb/TestClean_rb.ts +1 -1
- package/project/.sdk/src/cmp/rb/TestDirect_rb.ts +33 -16
- package/project/.sdk/src/cmp/rb/TestEntity_rb.ts +90 -25
- package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +3 -3
- package/project/.sdk/src/cmp/rust/EntityOperation_rust.ts +1 -1
- package/project/.sdk/src/cmp/rust/Main_rust.ts +3 -1
- package/project/.sdk/src/cmp/rust/ReadmeEntity_rust.ts +2 -2
- package/project/.sdk/src/cmp/rust/ReadmeHowto_rust.ts +3 -3
- package/project/.sdk/src/cmp/rust/ReadmeModel_rust.ts +1 -1
- package/project/.sdk/src/cmp/rust/ReadmeQuick_rust.ts +5 -5
- package/project/.sdk/src/cmp/rust/ReadmeRef_rust.ts +4 -4
- package/project/.sdk/src/cmp/rust/ReadmeTopQuick_rust.ts +3 -3
- package/project/.sdk/src/cmp/rust/ReadmeTopTest_rust.ts +3 -3
- package/project/.sdk/src/cmp/rust/TestClean_rust.ts +1 -1
- package/project/.sdk/src/cmp/rust/TestDirect_rust.ts +40 -12
- package/project/.sdk/src/cmp/rust/TestEntity_rust.ts +109 -26
- package/project/.sdk/src/cmp/rust/fragment/Entity.fragment.rs +2 -2
- package/project/.sdk/src/cmp/scala/ReadmeEntity_scala.ts +2 -2
- package/project/.sdk/src/cmp/scala/ReadmeHowto_scala.ts +2 -2
- package/project/.sdk/src/cmp/scala/ReadmeQuick_scala.ts +5 -5
- package/project/.sdk/src/cmp/scala/ReadmeRef_scala.ts +3 -3
- package/project/.sdk/src/cmp/scala/ReadmeTopQuick_scala.ts +3 -3
- package/project/.sdk/src/cmp/scala/ReadmeTopTest_scala.ts +2 -2
- package/project/.sdk/src/cmp/scala/TestDirect_scala.ts +2 -6
- package/project/.sdk/src/cmp/scala/TestEntity_scala.ts +36 -7
- package/project/.sdk/src/cmp/swift/ReadmeEntity_swift.ts +2 -2
- package/project/.sdk/src/cmp/swift/ReadmeHowto_swift.ts +2 -2
- package/project/.sdk/src/cmp/swift/ReadmeQuick_swift.ts +5 -5
- package/project/.sdk/src/cmp/swift/ReadmeRef_swift.ts +3 -3
- package/project/.sdk/src/cmp/swift/ReadmeTopQuick_swift.ts +2 -2
- package/project/.sdk/src/cmp/swift/ReadmeTopTest_swift.ts +2 -2
- package/project/.sdk/src/cmp/ts/ReadmeEntity_ts.ts +2 -2
- package/project/.sdk/src/cmp/ts/ReadmeExamplesTest_ts.ts +49 -19
- package/project/.sdk/src/cmp/ts/ReadmeHowto_ts.ts +2 -2
- package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +4 -4
- package/project/.sdk/src/cmp/ts/ReadmeRef_ts.ts +3 -3
- package/project/.sdk/src/cmp/ts/ReadmeTopTest_ts.ts +3 -3
- package/project/.sdk/src/cmp/ts/TestDirect_ts.ts +54 -23
- package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +49 -4
- package/project/.sdk/src/cmp/zig/ReadmeEntity_zig.ts +2 -2
- package/project/.sdk/src/cmp/zig/ReadmeHowto_zig.ts +2 -2
- package/project/.sdk/src/cmp/zig/ReadmeQuick_zig.ts +4 -4
- package/project/.sdk/src/cmp/zig/ReadmeRef_zig.ts +3 -3
- package/project/.sdk/src/cmp/zig/ReadmeTopQuick_zig.ts +2 -2
- package/project/.sdk/src/cmp/zig/ReadmeTopTest_zig.ts +2 -2
- package/project/.sdk/tm/c/core/sdk.h +2 -2
- package/project/.sdk/tm/c/tests/primary_utility_test.c +37 -0
- package/project/.sdk/tm/c/utility/fetcher.c +31 -1
- package/project/.sdk/tm/c/utility/make_url.c +6 -2
- package/project/.sdk/tm/clojure/src/sdk/core.clj +21 -3
- package/project/.sdk/tm/clojure/test/sdk/test/pipeline.clj +34 -0
- package/project/.sdk/tm/cpp/test/primary_utility_test.cpp +37 -0
- package/project/.sdk/tm/cpp/utility/pipeline.hpp +28 -2
- package/project/.sdk/tm/csharp/test/PrimaryUtilityTest.cs +40 -0
- package/project/.sdk/tm/csharp/utility/Fetcher.cs +27 -0
- package/project/.sdk/tm/csharp/utility/MakeUrl.cs +7 -2
- package/project/.sdk/tm/elixir/lib/projectname/utility.ex +30 -3
- package/project/.sdk/tm/elixir/test/pipeline_test.exs +23 -0
- package/project/.sdk/tm/go/core/helpers.go +1 -1
- package/project/.sdk/tm/go/core/types.go +9 -1
- package/project/.sdk/tm/go/test/feature_corpus_test.go +3 -4
- package/project/.sdk/tm/go/test/primary_utility_test.go +28 -0
- package/project/.sdk/tm/go/utility/fetcher.go +26 -0
- package/project/.sdk/tm/go/utility/make_url.go +5 -2
- package/project/.sdk/tm/java/test/FeatureCorpusTest.java +4 -5
- package/project/.sdk/tm/java/test/PrimaryUtilityTest.java +49 -0
- package/project/.sdk/tm/java/utility/Fetcher.java +24 -0
- package/project/.sdk/tm/java/utility/MakeUrl.java +6 -2
- package/project/.sdk/tm/js/src/utility/FetcherUtility.js +24 -0
- package/project/.sdk/tm/js/src/utility/MakeUrlUtility.js +6 -2
- package/project/.sdk/tm/js/test/feature/Corpus.test.js +7 -6
- package/project/.sdk/tm/js/test/live-entity.js +18 -6
- package/project/.sdk/tm/js/test/live-runner.js +15 -3
- package/project/.sdk/tm/js/test/utility/PrimaryUtility.test.js +25 -0
- package/project/.sdk/tm/kotlin/test/PrimaryUtilityTest.kt +48 -0
- package/project/.sdk/tm/kotlin/utility/Fetcher.kt +20 -0
- package/project/.sdk/tm/kotlin/utility/MakeSpecUrl.kt +6 -2
- package/project/.sdk/tm/lua/test/pipeline_test.lua +27 -0
- package/project/.sdk/tm/lua/test/primary_utility_test.lua +36 -0
- package/project/.sdk/tm/lua/utility/fetcher.lua +31 -0
- package/project/.sdk/tm/lua/utility/make_url.lua +6 -2
- package/project/.sdk/tm/ocaml/Makefile +5 -1
- package/project/.sdk/tm/ocaml/sdk_runtime.ml +36 -4
- package/project/.sdk/tm/ocaml/test/t_pipeline.ml +22 -0
- package/project/.sdk/tm/perl/t/primary_utility.t +22 -0
- package/project/.sdk/tm/perl/utility/fetcher.pm +18 -0
- package/project/.sdk/tm/perl/utility/make_url.pm +4 -2
- package/project/.sdk/tm/php/test/FeatureCorpusTest.php +6 -5
- package/project/.sdk/tm/php/test/PipelineTest.php +31 -7
- package/project/.sdk/tm/php/utility/Fetcher.php +34 -27
- package/project/.sdk/tm/php/utility/MakeOptions.php +2 -1
- package/project/.sdk/tm/php/utility/MakeUrl.php +6 -2
- package/project/.sdk/tm/py/pkg/utility/fetcher.py +23 -0
- package/project/.sdk/tm/py/pkg/utility/make_url.py +5 -2
- package/project/.sdk/tm/py/test/test_feature_corpus.py +5 -5
- package/project/.sdk/tm/py/test/test_primary_utility.py +21 -0
- package/project/.sdk/tm/rb/core/context.rb +1 -1
- package/project/.sdk/tm/rb/core/error.rb +20 -1
- package/project/.sdk/tm/rb/test/feature_corpus_test.rb +4 -5
- package/project/.sdk/tm/rb/test/feature_test.rb +2 -2
- package/project/.sdk/tm/rb/test/omni.rb +1 -1
- package/project/.sdk/tm/rb/test/pipeline_test.rb +19 -2
- package/project/.sdk/tm/rb/test/primary_utility_test.rb +28 -1
- package/project/.sdk/tm/rb/utility/fetcher.rb +20 -1
- package/project/.sdk/tm/rb/utility/make_error.rb +1 -1
- package/project/.sdk/tm/rb/utility/make_url.rb +4 -2
- package/project/.sdk/tm/rust/core/helpers.rs +1 -1
- package/project/.sdk/tm/rust/core/types.rs +2 -2
- package/project/.sdk/tm/rust/tests/primary_utility_test.rs +34 -0
- package/project/.sdk/tm/rust/utility/fetcher.rs +27 -0
- package/project/.sdk/tm/rust/utility/make_url.rs +7 -2
- package/project/.sdk/tm/scala/sdktest/SdkTestMain.scala +51 -1
- package/project/.sdk/tm/scala/utility/Fetcher.scala +16 -0
- package/project/.sdk/tm/scala/utility/Make.scala +6 -2
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Fetcher.swift +24 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Make.swift +6 -2
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/PrimaryUtilityTest.swift +34 -0
- package/project/.sdk/tm/ts/src/utility/FetcherUtility.ts +24 -0
- package/project/.sdk/tm/ts/src/utility/MakeUrlUtility.ts +6 -2
- package/project/.sdk/tm/ts/test/feature/Corpus.test.ts +7 -6
- package/project/.sdk/tm/ts/test/live-entity.ts +20 -5
- package/project/.sdk/tm/ts/test/live-runner.ts +17 -3
- package/project/.sdk/tm/ts/test/utility/PrimaryUtility.test.ts +25 -0
- package/project/.sdk/tm/zig/core/utility.zig +30 -3
- package/project/.sdk/tm/zig/test/primary_utility_test.zig +28 -0
- package/project/sdkgen-package.json +1 -1
- package/src/cmp/ReadmeTop.ts +3 -3
- package/src/helpers/opExample.ts +16 -1
- package/src/helpers/opShape.ts +64 -30
- package/src/helpers/pointPath.ts +19 -0
- package/src/helpers/testPolicy.ts +316 -2
- package/src/sdkgen.ts +37 -5
|
@@ -4,7 +4,7 @@ import * as Path from 'node:path'
|
|
|
4
4
|
import {
|
|
5
5
|
cmp, each, camelify, names,
|
|
6
6
|
File, Content, Folder, Fragment, Line, FeatureHook, Slot,
|
|
7
|
-
entityClassName, entityCollection, goModule
|
|
7
|
+
entityClassName, entityConstructorName, entityCollection, goModule
|
|
8
8
|
} from '@voxgig/sdkgen'
|
|
9
9
|
|
|
10
10
|
import {
|
|
@@ -26,6 +26,7 @@ const Entity = cmp(function Entity(props: any) {
|
|
|
26
26
|
// clash with another entity's data-type name. The DATA type stays `<Name>`.
|
|
27
27
|
const entityColl = entityCollection(model)
|
|
28
28
|
const cls = entityClassName(entity, entityColl)
|
|
29
|
+
const ctor = entityConstructorName(entity, entityColl)
|
|
29
30
|
|
|
30
31
|
const entrep = {
|
|
31
32
|
...stdrep,
|
|
@@ -43,7 +44,7 @@ const Entity = cmp(function Entity(props: any) {
|
|
|
43
44
|
|
|
44
45
|
// For each CRUD op: if the spec defines it, splice in the real
|
|
45
46
|
// implementation. Otherwise emit a stub that satisfies the static
|
|
46
|
-
//
|
|
47
|
+
// ProjectNameEntityBase interface (so the package compiles) but errors
|
|
47
48
|
// at runtime if the caller invokes an unsupported op.
|
|
48
49
|
const opfrags =
|
|
49
50
|
(['load', 'list', 'create', 'update', 'patch', 'remove']
|
|
@@ -58,7 +59,7 @@ const Entity = cmp(function Entity(props: any) {
|
|
|
58
59
|
`)
|
|
59
60
|
} :
|
|
60
61
|
({ indent }: any) => {
|
|
61
|
-
EntityOperation({ ff, opname, indent, entity, entrep, gomodule, cls })
|
|
62
|
+
EntityOperation({ ff, opname, indent, entity, entrep, gomodule, cls, ctor })
|
|
62
63
|
}, a), {}))
|
|
63
64
|
|
|
64
65
|
Fragment({
|
|
@@ -72,7 +73,7 @@ const Entity = cmp(function Entity(props: any) {
|
|
|
72
73
|
entityname: entity.name,
|
|
73
74
|
|
|
74
75
|
EntyClass: cls,
|
|
75
|
-
NewEntyClass:
|
|
76
|
+
NewEntyClass: ctor,
|
|
76
77
|
|
|
77
78
|
'#Entity-Hook': ({ name, indent }: any) =>
|
|
78
79
|
Content({ indent }, `utility.FeatureHook(ctx, "${name}")`),
|
|
@@ -14,7 +14,7 @@ const MainEntity = cmp(async function MainEntity(props: any) {
|
|
|
14
14
|
// ${entity.Name} returns a ${entity.Name} entity bound to this client.
|
|
15
15
|
// Idiomatic usage: client.${entity.Name}(nil).List(nil, nil) or
|
|
16
16
|
// client.${entity.Name}(nil).Load(map[string]any{"id": ...}, nil).
|
|
17
|
-
func (sdk *${model.const.Name}SDK) ${entity.Name}(data map[string]any) ${model.const.Name}
|
|
17
|
+
func (sdk *${model.const.Name}SDK) ${entity.Name}(data map[string]any) ${model.const.Name}EntityBase {
|
|
18
18
|
return New${entity.Name}EntityFunc(sdk, data)
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
cmp, each, names, cmap,
|
|
6
6
|
List, File, Content, Copy, Folder, Fragment, Line, FeatureHook,
|
|
7
7
|
inactiveFeatureExcludes,
|
|
8
|
-
|
|
8
|
+
entityConstructorName, entityCollection, goModule, goPackageIdent, pluginExcludes,
|
|
9
9
|
targetFeatures,
|
|
10
10
|
TEST_CONTROL_EXCLUDE
|
|
11
11
|
} from '@voxgig/sdkgen'
|
|
@@ -129,7 +129,7 @@ var NewBaseFeatureFunc func() Feature
|
|
|
129
129
|
})
|
|
130
130
|
|
|
131
131
|
each(entity, (ent: any) => {
|
|
132
|
-
Content(`var New${ent.Name}EntityFunc func(client *${model.const.Name}SDK, entopts map[string]any) ${model.const.Name}
|
|
132
|
+
Content(`var New${ent.Name}EntityFunc func(client *${model.const.Name}SDK, entopts map[string]any) ${model.const.Name}EntityBase
|
|
133
133
|
|
|
134
134
|
`)
|
|
135
135
|
})
|
|
@@ -153,7 +153,11 @@ type Context = core.Context
|
|
|
153
153
|
type Utility = core.Utility
|
|
154
154
|
type Feature = core.Feature
|
|
155
155
|
type Entity = core.Entity
|
|
156
|
-
type ${model.const.Name}
|
|
156
|
+
type ${model.const.Name}EntityBase = core.${model.const.Name}EntityBase
|
|
157
|
+
|
|
158
|
+
// Deprecated: use ${model.const.Name}EntityBase.
|
|
159
|
+
type ${model.const.Name}Entity = core.${model.const.Name}EntityBase
|
|
160
|
+
|
|
157
161
|
type StreamItem = core.StreamItem
|
|
158
162
|
type FetcherFunc = core.FetcherFunc
|
|
159
163
|
type Spec = core.Spec
|
|
@@ -185,8 +189,8 @@ func init() {
|
|
|
185
189
|
})
|
|
186
190
|
|
|
187
191
|
each(entity, (ent: any) => {
|
|
188
|
-
Content(` core.New${ent.Name}EntityFunc = func(client *core.${model.const.Name}SDK, entopts map[string]any) core.${model.const.Name}
|
|
189
|
-
return entity
|
|
192
|
+
Content(` core.New${ent.Name}EntityFunc = func(client *core.${model.const.Name}SDK, entopts map[string]any) core.${model.const.Name}EntityBase {
|
|
193
|
+
return entity.${entityConstructorName(ent, entityCollection(model))}(client, entopts)
|
|
190
194
|
}
|
|
191
195
|
`)
|
|
192
196
|
})
|
|
@@ -79,22 +79,10 @@ func prepareAuthUtil(ctx *core.Context) (*core.Spec, error) {
|
|
|
79
79
|
// HTTP Basic is header-only by definition: the scheme is
|
|
80
80
|
// `Authorization: Basic base64(user:pass)`. It cannot be expressed as a
|
|
81
81
|
// query parameter or a cookie, so the branch is emitted only where it can
|
|
82
|
-
// mean something
|
|
82
|
+
// mean something.
|
|
83
83
|
const withBasic = spec.basic && 'header' === spec.where
|
|
84
84
|
|
|
85
|
-
const head = `
|
|
86
|
-
|
|
87
|
-
import (
|
|
88
|
-
${withBasic ? ` "encoding/base64"
|
|
89
|
-
|
|
90
|
-
` : ''}${'query' !== spec.where ? ` "strings"
|
|
91
|
-
|
|
92
|
-
` : ''} vs "${spec.gomodule}/utility/struct"
|
|
93
|
-
|
|
94
|
-
"${spec.gomodule}/core"
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
const credName = "${gostr(credLiteral(spec.where, spec.name))}"
|
|
85
|
+
const head = `const credName = "${gostr(credLiteral(spec.where, spec.name))}"
|
|
98
86
|
${'cookie' === spec.where ? `const cookieHeader = "cookie"
|
|
99
87
|
` : ''}const optionApikey = "apikey"
|
|
100
88
|
${withBasic ? `const optionSecret = "secret"
|
|
@@ -181,7 +169,7 @@ ${cookieHelper(spec.where)}func prepareAuthUtil(ctx *core.Context) (*core.Spec,
|
|
|
181
169
|
}
|
|
182
170
|
`
|
|
183
171
|
|
|
184
|
-
|
|
172
|
+
const body = head + basicBlock + `
|
|
185
173
|
if skip {
|
|
186
174
|
${clear(spec.where, 'name')}
|
|
187
175
|
} else {
|
|
@@ -191,6 +179,27 @@ ${place(spec.where, 'name')}
|
|
|
191
179
|
return spec, nil
|
|
192
180
|
}
|
|
193
181
|
`
|
|
182
|
+
|
|
183
|
+
return `package utility
|
|
184
|
+
|
|
185
|
+
import (
|
|
186
|
+
${stdImports(body)} vs "${spec.gomodule}/utility/struct"
|
|
187
|
+
|
|
188
|
+
"${spec.gomodule}/core"
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
` + body
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
// Go rejects an unused import, and which of these the body calls varies by placement.
|
|
196
|
+
const STD_IMPORTS = ['encoding/base64', 'strings']
|
|
197
|
+
|
|
198
|
+
function stdImports(body: string): string {
|
|
199
|
+
return STD_IMPORTS
|
|
200
|
+
.filter((pkg) => new RegExp('\\b' + pkg.split('/').pop() + '\\.[A-Z]').test(body))
|
|
201
|
+
.map((pkg) => `\t"${pkg}"\n\n`)
|
|
202
|
+
.join('')
|
|
194
203
|
}
|
|
195
204
|
|
|
196
205
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, each, Content, canonToType, entityIdField, entityOps,
|
|
2
|
+
import { cmp, each, Content, canonToType, entityIdField, entityOps, listMatchArg, matchExampleItems, litString, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -145,7 +145,7 @@ for _, item := range ${eVar}s.([]any) {
|
|
|
145
145
|
// with a type-correct example VALUE via exampleValue — a
|
|
146
146
|
// `"name": /* type */` comment is not a value and yields uncompilable
|
|
147
147
|
// Go, so the example must carry a real literal.
|
|
148
|
-
const createItems =
|
|
148
|
+
const createItems = requestExampleItems(entity, 'create')
|
|
149
149
|
.filter((it: any) => !it.optional)
|
|
150
150
|
Content(`#### Example: Create
|
|
151
151
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content, isAuthActive, envName, canonKey, canonScalarKey, entityIdField, pickExampleEntity,
|
|
2
|
+
import { cmp, Content, isAuthActive, envName, canonKey, canonScalarKey, entityIdField, pickExampleEntity, goModule, requiredItems, litPair, matchExampleItems, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -49,7 +49,7 @@ const ReadmeHowto = cmp(function ReadmeHowto(props: any) {
|
|
|
49
49
|
? `map[string]any{${items.map((it: any) => litPair('go', it.name, isMatchOp && it.name === idF ? '"test01"' : goLit(it.type))).join(', ')}}`
|
|
50
50
|
: 'nil'
|
|
51
51
|
} else if (exampleEntity && ('create' === primaryOp || 'update' === primaryOp || 'patch' === primaryOp)) {
|
|
52
|
-
const items =
|
|
52
|
+
const items = requestExampleItems(exampleEntity, primaryOp)
|
|
53
53
|
.filter((it: any) => it.name !== idF && it.name !== 'id')
|
|
54
54
|
const required = items.filter((it: any) => !it.optional)
|
|
55
55
|
const chosen = required.length ? required : items.slice(0, 3)
|
|
@@ -121,14 +121,14 @@ Creates a test-mode client with mock transport. Both arguments may be \`nil\`.
|
|
|
121
121
|
|
|
122
122
|
each(entityList, (ent: any) => {
|
|
123
123
|
const article = /^[aeiou]/i.test(ent.Name) ? 'an' : 'a'
|
|
124
|
-
Content(`| \`${ent.Name}\` | \`(data map[string]any) ${model.const.Name}
|
|
124
|
+
Content(`| \`${ent.Name}\` | \`(data map[string]any) ${model.const.Name}EntityBase\` | Create ${article} ${ent.Name} entity instance. |
|
|
125
125
|
`)
|
|
126
126
|
})
|
|
127
127
|
|
|
128
128
|
Content(`
|
|
129
|
-
### Entity interface (${model.const.Name}
|
|
129
|
+
### Entity interface (${model.const.Name}EntityBase)
|
|
130
130
|
|
|
131
|
-
All entities implement the \`${model.const.Name}
|
|
131
|
+
All entities implement the \`${model.const.Name}EntityBase\` interface.
|
|
132
132
|
|
|
133
133
|
| Method | Signature | Description |
|
|
134
134
|
| --- | --- | --- |
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content, isAuthActive, envName,
|
|
2
|
+
import { cmp, Content, isAuthActive, envName, entityIdField, entityOps, goModule, serverVariables, listMatchArg, matchExampleItems, litString, requestExampleItems, sendsId } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -50,7 +50,7 @@ const ReadmeQuick = cmp(function ReadmeQuick(props: any) {
|
|
|
50
50
|
const idF = entityIdField(exampleEntity)
|
|
51
51
|
|
|
52
52
|
const exampleFields = (opname: string): string[] => {
|
|
53
|
-
const items =
|
|
53
|
+
const items = requestExampleItems(exampleEntity, opname)
|
|
54
54
|
.filter((it: any) => (it.name !== idF && it.name !== 'id') ||
|
|
55
55
|
('create' === opname && !it.optional))
|
|
56
56
|
const required = items.filter((it: any) => !it.optional)
|
|
@@ -116,7 +116,7 @@ const ReadmeQuick = cmp(function ReadmeQuick(props: any) {
|
|
|
116
116
|
if (opnames.includes('update')) {
|
|
117
117
|
// The id member (when the entity has an id-like key) plus example
|
|
118
118
|
// patch fields — the same shape that generates the op's request data.
|
|
119
|
-
const updateMembers = (idF
|
|
119
|
+
const updateMembers = (sendsId(exampleEntity, 'update', idF)
|
|
120
120
|
? [`${litString('go', idF)}: ${exampleValue(exampleEntity, exampleEntity.op.update, idF, 'example_id')}`]
|
|
121
121
|
: []).concat(exampleFields('update'))
|
|
122
122
|
body.push(` // Update a ${eLower}.`)
|
|
@@ -130,7 +130,7 @@ const ReadmeQuick = cmp(function ReadmeQuick(props: any) {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
if (opnames.includes('patch')) {
|
|
133
|
-
const patchMembers = (idF
|
|
133
|
+
const patchMembers = (sendsId(exampleEntity, 'patch', idF)
|
|
134
134
|
? [`${litString('go', idF)}: ${exampleValue(exampleEntity, exampleEntity.op.patch, idF, 'example_id')}`]
|
|
135
135
|
: []).concat(exampleFields('patch'))
|
|
136
136
|
body.push(` // Patch a ${eLower}: only the fields given are sent.`)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, each, Content, canonToType, File, isAuthActive, entityIdField, entityOps,
|
|
2
|
+
import { cmp, each, Content, canonToType, File, isAuthActive, entityIdField, entityOps, targetFeatures, bodyNote, listMatchArg, matchExampleItems, litString, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
import { ReadmeRefFeatures } from '@voxgig/sdkgen'
|
|
4
4
|
|
|
5
5
|
import {
|
|
@@ -119,7 +119,7 @@ client := sdk.TestSDK(testopts, sdkopts)
|
|
|
119
119
|
|
|
120
120
|
|
|
121
121
|
publishedEntities.map((ent: any) => {
|
|
122
|
-
Content(`#### \`${ent.Name}(data map[string]any) ${model.const.Name}
|
|
122
|
+
Content(`#### \`${ent.Name}(data map[string]any) ${model.const.Name}EntityBase\`
|
|
123
123
|
|
|
124
124
|
Create a new \`${ent.Name}\` entity instance. Pass \`nil\` for no initial data.
|
|
125
125
|
|
|
@@ -300,7 +300,7 @@ for _, item := range results.([]any) {
|
|
|
300
300
|
// required id), each with a type-correct example VALUE via
|
|
301
301
|
// exampleValue — a `"name": /* type */` comment is not a value
|
|
302
302
|
// and yields uncompilable Go.
|
|
303
|
-
const createItems =
|
|
303
|
+
const createItems = requestExampleItems(ent, 'create')
|
|
304
304
|
.filter((it: any) => !it.optional)
|
|
305
305
|
Content(`\`\`\`go
|
|
306
306
|
result, err := client.${ent.Name}(nil).Create(map[string]any{
|
|
@@ -322,7 +322,7 @@ fmt.Println(result.(sdk.Entity).Data())
|
|
|
322
322
|
// The id key plus every REQUIRED data member — the same shape
|
|
323
323
|
// that generates the op's request data — then the patch-fields
|
|
324
324
|
// note.
|
|
325
|
-
const updateItems =
|
|
325
|
+
const updateItems = requestExampleItems(ent, opname)
|
|
326
326
|
.filter((it: any) => !it.optional || it.name === idF)
|
|
327
327
|
.sort((a: any, b: any) =>
|
|
328
328
|
(a.name === idF ? 0 : 1) - (b.name === idF ? 0 : 1))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content, canonKey, canonScalarKey, entityIdField, pickExampleEntity,
|
|
2
|
+
import { cmp, Content, canonKey, canonScalarKey, entityIdField, pickExampleEntity, goModule, requiredItems, litPair, matchExampleItems, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -54,7 +54,7 @@ client := sdk.Test()
|
|
|
54
54
|
const chosen = requiredItems(exampleEntity, 'list')
|
|
55
55
|
arg = `map[string]any{${chosen.map((it: any) => litPair('go', it.name, goLit(it.type))).join(', ')}}`
|
|
56
56
|
} else if ('create' === primaryOp || 'update' === primaryOp || 'patch' === primaryOp) {
|
|
57
|
-
const items =
|
|
57
|
+
const items = requestExampleItems(exampleEntity, primaryOp)
|
|
58
58
|
.filter((it: any) => it.name !== idF && it.name !== 'id')
|
|
59
59
|
const required = items.filter((it: any) => !it.optional)
|
|
60
60
|
const chosen = required.length ? required : items.slice(0, 3)
|
|
@@ -15,8 +15,14 @@ import {
|
|
|
15
15
|
serverVarEnv,
|
|
16
16
|
serverVariables, envName, envToken, liveStrict, liveStrictNote,
|
|
17
17
|
pointParts,
|
|
18
|
+
pointPlaceholders,
|
|
18
19
|
pointIsGraphql,
|
|
19
20
|
primaryPoint,
|
|
21
|
+
liveExampleIds,
|
|
22
|
+
liveQueryExamples,
|
|
23
|
+
liveEntity,
|
|
24
|
+
liveGetOnlyReason, LIVE_GETONLY_ENV,
|
|
25
|
+
liveDirectGetOnly, liveExcludedLines, liveExcludedSummary,
|
|
20
26
|
} from '@voxgig/sdkgen'
|
|
21
27
|
|
|
22
28
|
|
|
@@ -67,7 +73,7 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
67
73
|
const model: Model = ctx$.model
|
|
68
74
|
|
|
69
75
|
const target = props.target
|
|
70
|
-
const entity: ModelEntity = props.entity
|
|
76
|
+
const entity: ModelEntity = liveEntity(ctx$, props.entity)
|
|
71
77
|
const gomodule = props.gomodule
|
|
72
78
|
|
|
73
79
|
const PROJECTNAME = envName(model)
|
|
@@ -118,12 +124,7 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
118
124
|
// actually appear in the URL template should drive direct-test path-param
|
|
119
125
|
// setup and URL-substitution asserts; otherwise the SDK silently drops
|
|
120
126
|
// them and the URL-includes assert fails.
|
|
121
|
-
const _pathPlaceholders = new Set<string>()
|
|
122
|
-
for (const part of pointParts(loadPoint)) {
|
|
123
|
-
if (typeof part === 'string' && part.startsWith('{') && part.endsWith('}')) {
|
|
124
|
-
_pathPlaceholders.add(part.slice(1, -1))
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
+
const _pathPlaceholders = new Set<string>(pointPlaceholders(loadPoint))
|
|
127
128
|
const _renameMap = (loadPoint?.r?.param || {}) as Record<string, string>
|
|
128
129
|
const _renamedPlaceholders = new Set<string>()
|
|
129
130
|
for (const ph of _pathPlaceholders) {
|
|
@@ -141,19 +142,11 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
141
142
|
const listPath = listPoint ? normalizePathParams(pointParts(listPoint), listPoint?.g?.params || [], listPoint?.r?.param) : ''
|
|
142
143
|
const listParams = listPoint?.g?.params || []
|
|
143
144
|
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
.filter((q: any) => q.r && undefined !== q.ex && null !== q.ex)
|
|
147
|
-
const loadLiveQueryLines = loadLiveQueryEntries
|
|
148
|
-
.map((q: any) => `\t\t\tquery["${q.n}"] = ${JSON.stringify(q.ex)}`)
|
|
149
|
-
.join('\n')
|
|
150
|
-
|
|
151
|
-
const listQuery = listPoint?.g?.query || []
|
|
152
|
-
const listLiveQueryEntries = listQuery
|
|
153
|
-
.filter((q: any) => q.r && undefined !== q.ex && null !== q.ex)
|
|
154
|
-
const listLiveQueryLines = listLiveQueryEntries
|
|
155
|
-
.map((q: any) => `\t\t\tquery["${q.n}"] = ${JSON.stringify(q.ex)}`)
|
|
145
|
+
const liveQueryLines = (point: any) => liveQueryExamples(point)
|
|
146
|
+
.map(([name, ex]) => `\t\t\tquery[${JSON.stringify(name)}] = ${JSON.stringify(ex)}`)
|
|
156
147
|
.join('\n')
|
|
148
|
+
const loadLiveQueryLines = liveQueryLines(loadPoint)
|
|
149
|
+
const listLiveQueryLines = liveQueryLines(listPoint)
|
|
157
150
|
|
|
158
151
|
// Path params with spec-provided examples — when ALL load params have
|
|
159
152
|
// spec examples, prefer them over list-bootstrap. Spec example values are
|
|
@@ -169,6 +162,17 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
169
162
|
|
|
170
163
|
const entidEnvVar = `${PROJECTNAME}_TEST_${envToken(entity.name)}_ENTID`
|
|
171
164
|
|
|
165
|
+
const exampleIds = liveExampleIds(entity)
|
|
166
|
+
const exampleIdBlock = 0 === exampleIds.length ? '' :
|
|
167
|
+
` // A path parameter's example stands in for an id *_ENTID does not give.
|
|
168
|
+
for k, v := range map[string]any{${exampleIds.map(([key, ex]) =>
|
|
169
|
+
`${JSON.stringify(key)}: ${JSON.stringify(ex)}`).join(', ')}} {
|
|
170
|
+
if idmap[k] == nil {
|
|
171
|
+
idmap[k] = v
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
`
|
|
175
|
+
|
|
172
176
|
File({ name: entity.name + '_direct_test.' + target.ext }, () => {
|
|
173
177
|
|
|
174
178
|
Content(`package sdktest
|
|
@@ -213,7 +217,8 @@ func Test${entity.Name}Direct(t *testing.T) {
|
|
|
213
217
|
const listLiveIdKeysGoLiteral = listLiveIdKeys.length > 0
|
|
214
218
|
? `[]string{${listLiveIdKeys.map((k: string) => `"${k}"`).join(', ')}}`
|
|
215
219
|
: ''
|
|
216
|
-
const listSkipBlock =
|
|
220
|
+
const listSkipBlock = getOnlyKeysBlock(model, entity, 'direct-list-' + entity.name, listLiveIdKeys) +
|
|
221
|
+
(listLiveIdKeys.length > 0
|
|
217
222
|
? ` if setup.live {
|
|
218
223
|
for _, _liveKey := range ${listLiveIdKeysGoLiteral} {
|
|
219
224
|
if v := setup.idmap[_liveKey]; v == nil {
|
|
@@ -223,7 +228,7 @@ func Test${entity.Name}Direct(t *testing.T) {
|
|
|
223
228
|
}
|
|
224
229
|
}
|
|
225
230
|
`
|
|
226
|
-
: ''
|
|
231
|
+
: '')
|
|
227
232
|
|
|
228
233
|
Content(` t.Run("direct-list-${entity.name}", func(t *testing.T) {
|
|
229
234
|
setup := ${entity.name}DirectSetup([]any{
|
|
@@ -245,9 +250,16 @@ ${listSkipBlock} client := setup.client
|
|
|
245
250
|
|
|
246
251
|
`)
|
|
247
252
|
|
|
248
|
-
if (listParams.length > 0) {
|
|
253
|
+
if (listParams.length > 0 || '' !== listLiveQueryLines) {
|
|
249
254
|
Content(` params := map[string]any{}
|
|
255
|
+
query := map[string]any{}
|
|
256
|
+
`)
|
|
257
|
+
if (listLiveQueryLines) {
|
|
258
|
+
Content(` if setup.live {
|
|
259
|
+
${listLiveQueryLines}
|
|
260
|
+
}
|
|
250
261
|
`)
|
|
262
|
+
}
|
|
251
263
|
listLiveParams.forEach((lp: any, i: number) => {
|
|
252
264
|
const placeholder = 'direct0' + (i + 1)
|
|
253
265
|
Content(` if setup.live {
|
|
@@ -262,6 +274,7 @@ ${listSkipBlock} client := setup.client
|
|
|
262
274
|
"path": "${listPath}",
|
|
263
275
|
"method": "GET",
|
|
264
276
|
"params": params,
|
|
277
|
+
"query": query,
|
|
265
278
|
})
|
|
266
279
|
`)
|
|
267
280
|
} else {
|
|
@@ -354,7 +367,8 @@ ${listSkipBlock} client := setup.client
|
|
|
354
367
|
loadLiveIdKeys = [...new Set((hasList ?
|
|
355
368
|
[...listParams, ...loadParams.filter((p: any) => p.n !== 'id')] : loadParams).map(liveKey))]
|
|
356
369
|
}
|
|
357
|
-
const loadSkipBlock =
|
|
370
|
+
const loadSkipBlock = getOnlyKeysBlock(model, entity, 'direct-load-' + entity.name, loadLiveIdKeys) +
|
|
371
|
+
(loadLiveIdKeys.length > 0
|
|
358
372
|
? ` if setup.live {
|
|
359
373
|
for _, _liveKey := range []string{${loadLiveIdKeys.map(k => `"${k}"`).join(', ')}} {
|
|
360
374
|
if v := setup.idmap[_liveKey]; v == nil {
|
|
@@ -364,7 +378,7 @@ ${listSkipBlock} client := setup.client
|
|
|
364
378
|
}
|
|
365
379
|
}
|
|
366
380
|
`
|
|
367
|
-
: ''
|
|
381
|
+
: '')
|
|
368
382
|
|
|
369
383
|
Content(` t.Run("direct-load-${entity.name}", func(t *testing.T) {
|
|
370
384
|
setup := ${entity.name}DirectSetup(map[string]any{"id": "direct01"})
|
|
@@ -577,7 +591,7 @@ func ${entity.name}DirectSetup(mockres any) *${entity.name}DirectSetupResult {
|
|
|
577
591
|
idmap = entidMap
|
|
578
592
|
}
|
|
579
593
|
}
|
|
580
|
-
|
|
594
|
+
${exampleIdBlock}
|
|
581
595
|
return &${entity.name}DirectSetupResult{client: client, calls: calls, live: true, idmap: idmap}
|
|
582
596
|
}
|
|
583
597
|
|
|
@@ -615,6 +629,18 @@ var _ = json.Unmarshal
|
|
|
615
629
|
})
|
|
616
630
|
|
|
617
631
|
|
|
632
|
+
// A GET-only live run excludes a test needing an id that only a write gives.
|
|
633
|
+
function getOnlyKeysBlock(model: any, entity: any, test: string, keys: string[]): string {
|
|
634
|
+
return liveDirectGetOnly(model, entity, test, keys).map((miss) =>
|
|
635
|
+
` if setup.live && os.Getenv(${JSON.stringify(LIVE_GETONLY_ENV)}) == "TRUE" && setup.idmap[${JSON.stringify(miss.key)}] == nil {
|
|
636
|
+
t.Log(${JSON.stringify(liveExcludedLines({ excluded: [miss] })[0])})
|
|
637
|
+
t.Skip(${JSON.stringify(liveExcludedSummary({ excluded: [miss] }))})
|
|
638
|
+
return
|
|
639
|
+
}
|
|
640
|
+
`).join('')
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
|
|
618
644
|
// GraphQL-backed op needs POST+body, not a REST-shaped GET+params Direct()
|
|
619
645
|
// call — reuse apidef's own point.gq.doc via the SDK's Graphql() hatch.
|
|
620
646
|
// Mirrors TestDirect_ts.ts's generateDirectGraphql.
|
|
@@ -628,6 +654,15 @@ function generateDirectGraphqlGo(
|
|
|
628
654
|
const doc: string = point.gq.doc
|
|
629
655
|
const vars: any[] = point.gq.vars || []
|
|
630
656
|
|
|
657
|
+
// A GraphQL request is a POST, which a GET-only live run does not send.
|
|
658
|
+
const getOnlyReason = liveGetOnlyReason(point)
|
|
659
|
+
const getOnlySkip = null == getOnlyReason ? '' :
|
|
660
|
+
`\t\tif setup.live && os.Getenv(${JSON.stringify(LIVE_GETONLY_ENV)}) == "TRUE" {
|
|
661
|
+
\t\t\tt.Skip(${JSON.stringify(getOnlyReason)})
|
|
662
|
+
\t\t\treturn
|
|
663
|
+
\t\t}
|
|
664
|
+
`
|
|
665
|
+
|
|
631
666
|
const mockVarLines = vars.map((v: any, i: number) =>
|
|
632
667
|
`\t\tvariables["${v.name}"] = "direct0${i + 1}"`).join('\n')
|
|
633
668
|
|
|
@@ -679,7 +714,7 @@ function generateDirectGraphqlGo(
|
|
|
679
714
|
t.Skip(_reason)
|
|
680
715
|
return
|
|
681
716
|
}
|
|
682
|
-
${skipBlock} client := setup.client
|
|
717
|
+
${getOnlySkip}${skipBlock} client := setup.client
|
|
683
718
|
|
|
684
719
|
variables := map[string]any{}
|
|
685
720
|
if setup.live {
|