@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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content, isAuthActive, envName, canonKey, canonScalarKey, opRequestShape, entityIdField, entityOps, matchExampleItems, requiredItems } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, Content, isAuthActive, envName, canonKey, canonScalarKey, opRequestShape, entityIdField, entityOps, matchExampleItems, requiredItems, requestExampleItems, sendsId } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -172,7 +172,7 @@ catch (err: RuntimeException) {
|
|
|
172
172
|
// Model-driven example fields: derive the create/update body from the op
|
|
173
173
|
// shape (opRequestShape) so the docs reference REAL writable fields.
|
|
174
174
|
const examplePairs = (opname: string): string[] => {
|
|
175
|
-
const items =
|
|
175
|
+
const items = requestExampleItems(exampleEntity, opname)
|
|
176
176
|
.filter((it: any) => (it.name !== idF && it.name !== 'id') ||
|
|
177
177
|
('create' === opname && !it.optional))
|
|
178
178
|
const required = items.filter((it: any) => !it.optional)
|
|
@@ -201,15 +201,15 @@ val created = client.${accessor}(null).create(mutableMapOf<String, Any?>(${examp
|
|
|
201
201
|
`)
|
|
202
202
|
}
|
|
203
203
|
if (opnames.includes('update')) {
|
|
204
|
-
const updatePairs = (idF ? [`${kotlinString(idF)} to ${kotlinLit(idParamType('update'), 'example_id')}`] : [])
|
|
204
|
+
const updatePairs = (sendsId(exampleEntity, 'update', idF) ? [`${kotlinString(idF)} to ${kotlinLit(idParamType('update'), 'example_id')}`] : [])
|
|
205
205
|
.concat(examplePairs('update'))
|
|
206
|
-
Content(`// Update — supply the id in the match/data
|
|
206
|
+
Content(`// Update${sendsId(exampleEntity, 'update', idF) ? ' — supply the id in the match/data' : ''}
|
|
207
207
|
client.${accessor}(null).update(mutableMapOf<String, Any?>(${updatePairs.join(', ')}), null)
|
|
208
208
|
|
|
209
209
|
`)
|
|
210
210
|
}
|
|
211
211
|
if (opnames.includes('patch')) {
|
|
212
|
-
const patchPairs = (idF ? [`${kotlinString(idF)} to ${kotlinLit(idParamType('patch'), 'example_id')}`] : [])
|
|
212
|
+
const patchPairs = (sendsId(exampleEntity, 'patch', idF) ? [`${kotlinString(idF)} to ${kotlinLit(idParamType('patch'), 'example_id')}`] : [])
|
|
213
213
|
.concat(examplePairs('patch'))
|
|
214
214
|
Content(`// Patch — sends only the fields given
|
|
215
215
|
client.${accessor}(null).patch(mutableMapOf<String, Any?>(${patchPairs.join(', ')}), null)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, each, Content, canonToType, canonKey, canonScalarKey, File, isAuthActive, entityIdField
|
|
2
|
+
import { cmp, each, Content, canonToType, canonKey, canonScalarKey, File, isAuthActive, entityIdField , targetFeatures, opNeedsAction, bodyNote, matchExampleItems, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
import { ReadmeRefFeatures } from '@voxgig/sdkgen'
|
|
4
4
|
|
|
5
5
|
import {
|
|
@@ -294,7 +294,7 @@ for (item in results) {
|
|
|
294
294
|
`)
|
|
295
295
|
}
|
|
296
296
|
else if ('create' === opname) {
|
|
297
|
-
const createItems =
|
|
297
|
+
const createItems = requestExampleItems(ent, 'create')
|
|
298
298
|
.filter((it: any) => !it.optional)
|
|
299
299
|
Content(`\`\`\`kotlin
|
|
300
300
|
val result = client.${accessor}(null).create(mutableMapOf<String, Any?>(
|
|
@@ -310,7 +310,7 @@ val result = client.${accessor}(null).create(mutableMapOf<String, Any?>(
|
|
|
310
310
|
`)
|
|
311
311
|
}
|
|
312
312
|
else if ('update' === opname || 'patch' === opname) {
|
|
313
|
-
const updateItems =
|
|
313
|
+
const updateItems = requestExampleItems(ent, opname)
|
|
314
314
|
.filter((it: any) => !it.optional || it.name === idF)
|
|
315
315
|
.sort((a: any, b: any) =>
|
|
316
316
|
(a.name === idF ? 0 : 1) - (b.name === idF ? 0 : 1))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content, isAuthActive, envName, canonKey, canonScalarKey, entityIdField, opRequestShape, matchExampleItems } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, Content, isAuthActive, envName, canonKey, canonScalarKey, entityIdField, opRequestShape, matchExampleItems, entityOps } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -37,7 +37,7 @@ const ReadmeTopQuick = cmp(function ReadmeTopQuick(props: any) {
|
|
|
37
37
|
const authActive = isAuthActive(model)
|
|
38
38
|
|
|
39
39
|
const shown = null != exampleEntity &&
|
|
40
|
-
['list', 'load'].some((op: string) =>
|
|
40
|
+
['list', 'load'].some((op: string) => entityOps(exampleEntity).includes(op))
|
|
41
41
|
|
|
42
42
|
Content(`\`\`\`kotlin
|
|
43
43
|
import ${kotlinPackage(model)}.core.${SDK}
|
|
@@ -61,7 +61,7 @@ ${shown ? `import ${kotlinPackage(model)}.core.SdkEntity\n` : ''}
|
|
|
61
61
|
const eVar = kotlinVarName(exampleEntity.name)
|
|
62
62
|
const accessor = kotlinVarName(exampleEntity.name)
|
|
63
63
|
const eNameLower = nom(exampleEntity, 'Name').toLowerCase()
|
|
64
|
-
const opnames =
|
|
64
|
+
const opnames = entityOps(exampleEntity)
|
|
65
65
|
const idF = entityIdField(exampleEntity)
|
|
66
66
|
|
|
67
67
|
if (opnames.includes('list')) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content, canonKey, canonScalarKey, entityIdField, pickExampleEntity,
|
|
2
|
+
import { cmp, Content, canonKey, canonScalarKey, entityIdField, pickExampleEntity, requiredItems, matchExampleItems, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -52,7 +52,7 @@ val client = ${SDK}.testSDK(null, null)
|
|
|
52
52
|
`${kotlinString(it.name)} to ${isMatchOp && it.name === idF ? '"test01"' : kotlinLit(it.type)}`).join(', ')})`
|
|
53
53
|
: 'null'
|
|
54
54
|
} else if ('create' === primaryOp || 'update' === primaryOp || 'patch' === primaryOp) {
|
|
55
|
-
const items =
|
|
55
|
+
const items = requestExampleItems(exampleEntity, primaryOp)
|
|
56
56
|
.filter((it: any) => it.name !== idF && it.name !== 'id')
|
|
57
57
|
const required = items.filter((it: any) => !it.optional)
|
|
58
58
|
const chosen = required.length ? required : items.slice(0, 3)
|
|
@@ -13,10 +13,15 @@ import {
|
|
|
13
13
|
snakify,
|
|
14
14
|
isAuthActive, envName, envToken,
|
|
15
15
|
pointParts,
|
|
16
|
+
pointPlaceholders,
|
|
16
17
|
liveStrict,
|
|
17
18
|
liveStrictNote,
|
|
18
19
|
pointIsGraphql,
|
|
19
20
|
graphqlDirectSkip,
|
|
21
|
+
liveExampleIds,
|
|
22
|
+
liveQueryExamples,
|
|
23
|
+
liveEntity,
|
|
24
|
+
liveDirectGetOnly, liveExcludedLines, liveExcludedSummary, LIVE_GETONLY_ENV,
|
|
20
25
|
} from '@voxgig/sdkgen'
|
|
21
26
|
|
|
22
27
|
|
|
@@ -60,7 +65,19 @@ function normalizePathParams(
|
|
|
60
65
|
function kotlinLiteral(v: any): string {
|
|
61
66
|
if (null == v) return 'null'
|
|
62
67
|
if ('number' === typeof v || 'boolean' === typeof v) return String(v)
|
|
63
|
-
return JSON.stringify(String(v))
|
|
68
|
+
return JSON.stringify(String(v)).replace(/\$/g, '\\$')
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
// A GET-only live run excludes a test needing an id that only a write gives.
|
|
73
|
+
function getOnlyKeysBlock(model: any, entity: any, test: string, keys: string[]): string {
|
|
74
|
+
return liveDirectGetOnly(model, entity, test, keys).map((miss) =>
|
|
75
|
+
` if (setup.live && "TRUE" == System.getenv(${kotlinLiteral(LIVE_GETONLY_ENV)})
|
|
76
|
+
&& setup.idmap[${kotlinLiteral(miss.key)}] == null) {
|
|
77
|
+
println(${kotlinLiteral(liveExcludedLines({ excluded: [miss] })[0])})
|
|
78
|
+
Assumptions.assumeTrue(false, ${kotlinLiteral(liveExcludedSummary({ excluded: [miss] }))})
|
|
79
|
+
}
|
|
80
|
+
`).join('')
|
|
64
81
|
}
|
|
65
82
|
|
|
66
83
|
|
|
@@ -69,7 +86,7 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
69
86
|
const model: Model = ctx$.model
|
|
70
87
|
|
|
71
88
|
const target = props.target
|
|
72
|
-
const entity: ModelEntity = props.entity
|
|
89
|
+
const entity: ModelEntity = liveEntity(ctx$, props.entity)
|
|
73
90
|
const kotlinpackage: string = props.kotlinpackage
|
|
74
91
|
|
|
75
92
|
const PROJECTNAME = envName(model)
|
|
@@ -91,12 +108,7 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
91
108
|
const loadPoint = loadOp?.points?.[0]
|
|
92
109
|
const loadPath = loadPoint ? normalizePathParams(pointParts(loadPoint), loadPoint?.g?.params || [], loadPoint?.r?.param) : ''
|
|
93
110
|
const allLoadParams = loadPoint?.g?.params || []
|
|
94
|
-
const _pathPlaceholders = new Set<string>()
|
|
95
|
-
for (const part of pointParts(loadPoint)) {
|
|
96
|
-
if (typeof part === 'string' && part.startsWith('{') && part.endsWith('}')) {
|
|
97
|
-
_pathPlaceholders.add(part.slice(1, -1))
|
|
98
|
-
}
|
|
99
|
-
}
|
|
111
|
+
const _pathPlaceholders = new Set<string>(pointPlaceholders(loadPoint))
|
|
100
112
|
const _renameMap = (loadPoint?.r?.param || {}) as Record<string, string>
|
|
101
113
|
const _renamedPlaceholders = new Set<string>()
|
|
102
114
|
for (const ph of _pathPlaceholders) {
|
|
@@ -112,11 +124,8 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
112
124
|
const listPath = listPoint ? normalizePathParams(pointParts(listPoint), listPoint?.g?.params || [], listPoint?.r?.param) : ''
|
|
113
125
|
const listParams = listPoint?.g?.params || []
|
|
114
126
|
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
.filter((q: any) => q.r && undefined !== q.ex && null !== q.ex)
|
|
118
|
-
const loadLiveQueryLines = loadLiveQueryEntries
|
|
119
|
-
.map((q: any) => ` query["${q.n}"] = ${kotlinLiteral(q.ex)}`)
|
|
127
|
+
const loadLiveQueryLines = liveQueryExamples(loadPoint)
|
|
128
|
+
.map(([name, ex]) => ` query["${name}"] = ${kotlinLiteral(ex)}`)
|
|
120
129
|
.join('\n')
|
|
121
130
|
|
|
122
131
|
const loadAllHaveExamples =
|
|
@@ -128,6 +137,10 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
128
137
|
|
|
129
138
|
const entidEnvVar = `${PROJECTNAME}_TEST_${envToken(entity.name)}_ENTID`
|
|
130
139
|
|
|
140
|
+
const exampleIds = liveExampleIds(entity)
|
|
141
|
+
const listLiveQueryLines = liveQueryExamples(listPoint)
|
|
142
|
+
.map(([name, ex]) => ` query["${name}"] = ${kotlinLiteral(ex)}\n`).join('')
|
|
143
|
+
|
|
131
144
|
File({ name: entity.Name + 'DirectTest.' + target.ext }, () => {
|
|
132
145
|
|
|
133
146
|
Content(`package ${kotlinpackage}.sdktest
|
|
@@ -177,7 +190,8 @@ ${liveStrictNote(liveStrict(model, target.name), '//', ' ')}
|
|
|
177
190
|
const listLiveIdKeys = listParams.length > 0
|
|
178
191
|
? listLiveParams.map((lp: any) => lp.key)
|
|
179
192
|
: []
|
|
180
|
-
const listSkipBlock =
|
|
193
|
+
const listSkipBlock = getOnlyKeysBlock(model, entity, 'direct-list-' + entity.name, listLiveIdKeys) +
|
|
194
|
+
(listLiveIdKeys.length > 0
|
|
181
195
|
? ` if (setup.live) {
|
|
182
196
|
for (liveKey in arrayOf<String>(${listLiveIdKeys.map((k: string) => `"${k}"`).join(', ')})) {
|
|
183
197
|
if (setup.idmap[liveKey] == null) {
|
|
@@ -186,7 +200,7 @@ ${liveStrictNote(liveStrict(model, target.name), '//', ' ')}
|
|
|
186
200
|
}
|
|
187
201
|
}
|
|
188
202
|
`
|
|
189
|
-
: ''
|
|
203
|
+
: '')
|
|
190
204
|
|
|
191
205
|
Content(` @Test
|
|
192
206
|
fun directList${entity.Name}() {
|
|
@@ -204,9 +218,10 @@ ${listSkipBlock} val client = setup.client
|
|
|
204
218
|
|
|
205
219
|
`)
|
|
206
220
|
|
|
207
|
-
if (listParams.length > 0) {
|
|
221
|
+
if (listParams.length > 0 || '' !== listLiveQueryLines) {
|
|
208
222
|
Content(` val params = linkedMapOf<String, Any?>()
|
|
209
|
-
|
|
223
|
+
val query = linkedMapOf<String, Any?>()
|
|
224
|
+
${listLiveQueryLines ? ' if (setup.live) {\n' + listLiveQueryLines + ' }\n' : ''}`)
|
|
210
225
|
listLiveParams.forEach((lp: any, i: number) => {
|
|
211
226
|
const placeholder = 'direct0' + (i + 1)
|
|
212
227
|
Content(` if (setup.live) {
|
|
@@ -220,7 +235,8 @@ ${listSkipBlock} val client = setup.client
|
|
|
220
235
|
val result = client.direct(jm(
|
|
221
236
|
"path", "${listPath}",
|
|
222
237
|
"method", "GET",
|
|
223
|
-
"params", params
|
|
238
|
+
"params", params,
|
|
239
|
+
"query", query))
|
|
224
240
|
`)
|
|
225
241
|
} else {
|
|
226
242
|
Content(`
|
|
@@ -289,7 +305,8 @@ ${listSkipBlock} val client = setup.client
|
|
|
289
305
|
loadLiveIdKeys = [...new Set((hasList ?
|
|
290
306
|
[...listParams, ...loadParams.filter((p: any) => p.n !== 'id')] : loadParams).map(liveKey))]
|
|
291
307
|
}
|
|
292
|
-
const loadSkipBlock =
|
|
308
|
+
const loadSkipBlock = getOnlyKeysBlock(model, entity, 'direct-load-' + entity.name, loadLiveIdKeys) +
|
|
309
|
+
(loadLiveIdKeys.length > 0
|
|
293
310
|
? ` if (setup.live) {
|
|
294
311
|
for (liveKey in arrayOf<String>(${loadLiveIdKeys.map(k => `"${k}"`).join(', ')})) {
|
|
295
312
|
if (setup.idmap[liveKey] == null) {
|
|
@@ -298,7 +315,7 @@ ${listSkipBlock} val client = setup.client
|
|
|
298
315
|
}
|
|
299
316
|
}
|
|
300
317
|
`
|
|
301
|
-
: ''
|
|
318
|
+
: '')
|
|
302
319
|
|
|
303
320
|
Content(` @Test
|
|
304
321
|
fun directLoad${entity.Name}() {
|
|
@@ -488,7 +505,10 @@ ${authActive ? ` mergedOpts["apikey"] = env["${PROJECTNAME}_APIKEY"]\n` :
|
|
|
488
505
|
} else if (entidRaw is MutableMap<*, *>) {
|
|
489
506
|
idmap = entidRaw as MutableMap<String, Any?>
|
|
490
507
|
}
|
|
491
|
-
|
|
508
|
+
${0 === exampleIds.length ? '' : ` // A path parameter's example stands in for an id *_ENTID does not give.
|
|
509
|
+
idmap = LinkedHashMap(idmap)
|
|
510
|
+
${exampleIds.map(([key, ex]) => ` if (idmap["${key}"] == null) idmap["${key}"] = ${kotlinLiteral(ex)}
|
|
511
|
+
`).join('')}`} setup.idmap = idmap
|
|
492
512
|
return setup
|
|
493
513
|
}
|
|
494
514
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { flowSteps, opReachable, invalidRequest } from '@voxgig/sdkgen'
|
|
1
|
+
import { flowSteps, opReachable, invalidRequest, flowLoadRoute, flowLoadReadsRecord } from '@voxgig/sdkgen'
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
KIT,
|
|
@@ -20,6 +20,9 @@ import {
|
|
|
20
20
|
getMatchEntries,
|
|
21
21
|
isAuthActive, envName, envToken,
|
|
22
22
|
liveFlowNeeds, liveStrict, liveStrictNote,
|
|
23
|
+
liveGetOnly, liveExcludedLines, liveExcludedSummary, LIVE_GETONLY_ENV,
|
|
24
|
+
liveRouteExamples, liveStepExamples,
|
|
25
|
+
liveEntity,
|
|
23
26
|
} from '@voxgig/sdkgen'
|
|
24
27
|
|
|
25
28
|
|
|
@@ -72,7 +75,9 @@ function liveFlowGate(entity: any, needs: any, entidEnv: string, accessor: strin
|
|
|
72
75
|
out += ' val client = setup.client\n'
|
|
73
76
|
if (null != needs.discover) {
|
|
74
77
|
const match = Object.entries(needs.discover)
|
|
75
|
-
.map(([k, v]: any) => `${JSON.stringify(k)} to setup.idmap?.get(${JSON.stringify(v)})`)
|
|
78
|
+
.map(([k, v]: any) => `${JSON.stringify(k)} to setup.idmap?.get(${JSON.stringify(v)})`)
|
|
79
|
+
.concat(liveRouteExamples(entity, 'list', Object.keys(needs.discover))
|
|
80
|
+
.map(([k, ex]) => `${JSON.stringify(k)} to ${kotlinLit(ex)}`)).join(', ')
|
|
76
81
|
out += ` if (setup.live) {
|
|
77
82
|
RunnerSupport.liveExisting(setup.data!!, LIVE_STRICT, ${JSON.stringify(entity.name)}) {
|
|
78
83
|
client.${accessor}(null).list(linkedMapOf<String, Any?>(${match}), null)
|
|
@@ -92,7 +97,7 @@ const TestEntity = cmp(function TestEntity(props: any) {
|
|
|
92
97
|
const model: Model = ctx$.model
|
|
93
98
|
|
|
94
99
|
const target = props.target
|
|
95
|
-
const entity: ModelEntity = props.entity
|
|
100
|
+
const entity: ModelEntity = liveEntity(ctx$, props.entity)
|
|
96
101
|
const kotlinpackage: string = props.kotlinpackage
|
|
97
102
|
|
|
98
103
|
const basicflow: ModelEntityFlow | undefined =
|
|
@@ -122,7 +127,6 @@ const TestEntity = cmp(function TestEntity(props: any) {
|
|
|
122
127
|
const genCtx: GenCtx = { model, entity, kotlinpackage, flow: basicflow, PROJUPPER, accessor }
|
|
123
128
|
|
|
124
129
|
const strict = liveStrict(model, target.name)
|
|
125
|
-
const needs = liveFlowNeeds(entity, basicflow)
|
|
126
130
|
|
|
127
131
|
const stepOps = Array.from(new Set(
|
|
128
132
|
(allSteps as any[]).map((s: any) => s.o).filter(Boolean)))
|
|
@@ -177,33 +181,63 @@ ${liveStrictNote(strict, '//', ' ')}
|
|
|
177
181
|
if (reason == null || "" == reason) "skipped via sdk-test-control.json" else reason,
|
|
178
182
|
)
|
|
179
183
|
}
|
|
180
|
-
|
|
184
|
+
`)
|
|
185
|
+
|
|
186
|
+
const flowBody = (flow: any) => {
|
|
187
|
+
const steps = flowSteps(flow) as any[]
|
|
188
|
+
Content(liveFlowGate(entity, liveFlowNeeds(entity, flow), entidEnvVar, accessor, strict,
|
|
189
|
+
steps.length > 0))
|
|
181
190
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
191
|
+
const flowHasCreate = steps.some((s: any) => s.o === 'create')
|
|
192
|
+
if (!flowHasCreate) {
|
|
193
|
+
const preambleRef = entity.name + '_ref01'
|
|
194
|
+
const preambleVar = kvar(preambleRef)
|
|
195
|
+
Content(` // Bootstrap entity data from existing test data (no create step in flow).
|
|
187
196
|
val ${preambleVar}DataRaw = Struct.items(Helpers.toMapAny(
|
|
188
197
|
Struct.getpath(setup.data, "existing.${entity.name}")))
|
|
189
198
|
val ${preambleVar}Data: MutableMap<String, Any?> = if (${preambleVar}DataRaw.isEmpty())
|
|
190
199
|
linkedMapOf() else (Helpers.toMapAny(${preambleVar}DataRaw[0][1]) ?: linkedMapOf())
|
|
191
200
|
|
|
201
|
+
`)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
each(steps, (step: any, index: any) => {
|
|
205
|
+
const opgen: OpGen = GENERATE_OP[step.o]
|
|
206
|
+
if (opgen) {
|
|
207
|
+
opgen({ ...genCtx, flow }, step, index)
|
|
208
|
+
Content('\n')
|
|
209
|
+
}
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
Content(strict || 0 === steps.length ? '' : ` } catch (err: Throwable) {
|
|
213
|
+
RunnerSupport.liveObserve(err, setup.live, LIVE_STRICT)
|
|
214
|
+
}
|
|
192
215
|
`)
|
|
193
216
|
}
|
|
194
217
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
if (
|
|
198
|
-
|
|
199
|
-
|
|
218
|
+
const getOnly = liveGetOnly(entity, basicflow)
|
|
219
|
+
if (null != getOnly) {
|
|
220
|
+
Content(` if (setup.live && "TRUE" == System.getenv(${kotlinLit(LIVE_GETONLY_ENV)})) {
|
|
221
|
+
${liveExcludedLines(getOnly).map((line) => ' println(' + kotlinLit(line) + ')\n').join('')}`)
|
|
222
|
+
if (0 === flowSteps(getOnly.flow).length) {
|
|
223
|
+
Content(` Assumptions.assumeTrue(false, ${kotlinLit(liveExcludedSummary(getOnly))})
|
|
224
|
+
return
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
`)
|
|
200
228
|
}
|
|
201
|
-
|
|
229
|
+
else {
|
|
230
|
+
flowBody(getOnly.flow)
|
|
231
|
+
Content(` return
|
|
232
|
+
}
|
|
202
233
|
|
|
203
|
-
|
|
204
|
-
|
|
234
|
+
`)
|
|
235
|
+
}
|
|
205
236
|
}
|
|
206
|
-
|
|
237
|
+
|
|
238
|
+
flowBody(basicflow)
|
|
239
|
+
|
|
240
|
+
Content(` }
|
|
207
241
|
|
|
208
242
|
`)
|
|
209
243
|
|
|
@@ -407,6 +441,7 @@ const generateList: OpGen = (ctx, step, index) => {
|
|
|
407
441
|
Content(` ${matchvar}["${key}"] = setup.idmap!!["${val}"]
|
|
408
442
|
`)
|
|
409
443
|
}
|
|
444
|
+
Content(liveFill(entity, step, matchvar))
|
|
410
445
|
|
|
411
446
|
const allSteps = Object.values(flowSteps(flow)) as any[]
|
|
412
447
|
const listvarUsed = !!step.v?.some((v: any) => {
|
|
@@ -559,7 +594,7 @@ const generateLoad: OpGen = (ctx, step, index) => {
|
|
|
559
594
|
Content(` val ${entvar} = client.${accessor}(null)
|
|
560
595
|
`)
|
|
561
596
|
}
|
|
562
|
-
if (!hasSrcData && hasEntId) {
|
|
597
|
+
if (!hasSrcData && (hasEntId || flowLoadReadsRecord(entity, step))) {
|
|
563
598
|
Content(` val ${srcdatavar}Raw = Struct.items(Helpers.toMapAny(
|
|
564
599
|
Struct.getpath(setup.data, "existing.${entity.name}")))
|
|
565
600
|
val ${srcdatavar}: MutableMap<String, Any?> = if (${srcdatavar}Raw.isEmpty())
|
|
@@ -570,14 +605,14 @@ const generateLoad: OpGen = (ctx, step, index) => {
|
|
|
570
605
|
`)
|
|
571
606
|
if (hasEntId) {
|
|
572
607
|
Content(` ${matchvar}["id"] = ${srcdatavar}["id"]
|
|
573
|
-
${
|
|
608
|
+
${loadMatch(entity, step, matchvar, srcdatavar)}${liveFill(entity, step, matchvar)} val ${datavar}Loaded = ${entvar}.load(${matchvar}, null)
|
|
574
609
|
val ${datavar}LoadResult = Helpers.toMapAny(if (${datavar}Loaded is SdkEntity) ${datavar}Loaded.data() else ${datavar}Loaded) ?: linkedMapOf()
|
|
575
610
|
assertNotNull(${datavar}LoadResult, "expected load result to be a map")
|
|
576
611
|
assertEquals(${srcdatavar}["id"], ${datavar}LoadResult["id"],
|
|
577
612
|
"expected load result id to match")
|
|
578
613
|
`)
|
|
579
614
|
} else {
|
|
580
|
-
Content(`${
|
|
615
|
+
Content(`${loadMatch(entity, step, matchvar, srcdatavar)}${liveFill(entity, step, matchvar)} val ${datavar}Loaded = ${entvar}.load(${matchvar}, null)
|
|
581
616
|
assertNotNull(${datavar}Loaded, "expected load result to be non-null")
|
|
582
617
|
`)
|
|
583
618
|
}
|
|
@@ -611,6 +646,21 @@ ${parentMatch(step, matchvar)} ${entvar}.remove(${matchvar}, null)
|
|
|
611
646
|
// A child's route names its parents, and an entity no earlier step has
|
|
612
647
|
// filled knows none of them, so the call itself gives each parent id. A live
|
|
613
648
|
// ENTID may key a parent by its field name, the fixture by its own name.
|
|
649
|
+
function kotlinLit(value: any): string {
|
|
650
|
+
if ('string' === typeof value) return JSON.stringify(value).replace(/\$/g, '\\$')
|
|
651
|
+
return Number.isInteger(value) && Math.abs(value) > 2147483647 ? value + 'L' : String(value)
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
// A live step sends each example its route requires and the step leaves unbound.
|
|
656
|
+
function liveFill(entity: any, step: any, matchvar: string): string {
|
|
657
|
+
const fills = liveStepExamples(entity, step)
|
|
658
|
+
return 0 === fills.length ? '' : ` if (setup.live) {
|
|
659
|
+
${fills.map(([k, ex]) => ` ${matchvar}[${JSON.stringify(k)}] = ${kotlinLit(ex)}\n`).join('')} }
|
|
660
|
+
`
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
|
|
614
664
|
function parentMatch(step: any, matchvar: string): string {
|
|
615
665
|
return Object.entries(step.m || {})
|
|
616
666
|
.filter(([k]: any) => k !== 'id' && !k.endsWith('$'))
|
|
@@ -619,6 +669,33 @@ function parentMatch(step: any, matchvar: string): string {
|
|
|
619
669
|
}
|
|
620
670
|
|
|
621
671
|
|
|
672
|
+
// A load of a known record fills its route from that record, and from the
|
|
673
|
+
// step's binding where the record holds no scalar for it. A record only the
|
|
674
|
+
// fixture holds replaces the step's binding offline.
|
|
675
|
+
function loadMatch(entity: any, step: any, matchvar: string, srcdatavar: string): string {
|
|
676
|
+
const route = flowLoadRoute(entity, step)
|
|
677
|
+
if (null == route) {
|
|
678
|
+
return parentMatch(step, matchvar)
|
|
679
|
+
}
|
|
680
|
+
if (route.offline) {
|
|
681
|
+
const own = route.args.filter((arg) => null != arg.field)
|
|
682
|
+
return parentMatch(step, matchvar) + (0 === own.length ? '' : ` if (!setup.live) {
|
|
683
|
+
${own.map((arg, i) => ` val own${i} = ${srcdatavar}["${arg.field}"]
|
|
684
|
+
if (own${i} is String || own${i} is Number || own${i} is Boolean) {
|
|
685
|
+
${matchvar}["${arg.name}"] = own${i}
|
|
686
|
+
}
|
|
687
|
+
`).join('')} }
|
|
688
|
+
`)
|
|
689
|
+
}
|
|
690
|
+
return route.args.map((arg) => {
|
|
691
|
+
const bound = arg.idmap.map((key) => `setup.idmap?.get("${key}")`).join(' ?: ')
|
|
692
|
+
return ` ${matchvar}["${arg.name}"] = ${null == arg.field ? bound :
|
|
693
|
+
`${srcdatavar}["${arg.field}"].let { if (it is String || it is Number || it is Boolean) it else ${bound} }`}
|
|
694
|
+
`
|
|
695
|
+
}).join('')
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
|
|
622
699
|
const GENERATE_OP: Record<string, OpGen> = {
|
|
623
700
|
create: generateCreate,
|
|
624
701
|
list: generateList,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, each, Content, canonToType, canonKey, canonScalarKey, entityIdField,
|
|
2
|
+
import { cmp, each, Content, canonToType, canonKey, canonScalarKey, entityIdField, safeVarName, exampleVarName, luaKey, opNeedsAction, listMatchArg, matchExampleItems, litString, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -145,7 +145,7 @@ local ${eVar}s, err = client:${entity.Name}():list(${listMatchArg('lua', entity)
|
|
|
145
145
|
// required id and parent keys like page_id — with a real, executable
|
|
146
146
|
// literal (the doc test RUNS this block, so a nil member would vanish
|
|
147
147
|
// from the table and a comment placeholder would not parse).
|
|
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, luaKey, requiredItems, matchExampleItems, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -39,7 +39,7 @@ const ReadmeHowto = cmp(function ReadmeHowto(props: any) {
|
|
|
39
39
|
? `{ ${items.map((it: any) => `${luaKey(it.name)} = ${isMatchOp && it.name === idF ? '"test01"' : luaLit(it.type)}`).join(', ')} }`
|
|
40
40
|
: ''
|
|
41
41
|
} else if (exampleEntity && ('create' === primaryOp || 'update' === primaryOp || 'patch' === primaryOp)) {
|
|
42
|
-
const items =
|
|
42
|
+
const items = requestExampleItems(exampleEntity, primaryOp)
|
|
43
43
|
.filter((it: any) => it.name !== idF && it.name !== 'id')
|
|
44
44
|
const required = items.filter((it: any) => !it.optional)
|
|
45
45
|
const chosen = required.length ? required : items.slice(0, 3)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, each, Content, isAuthActive, envName, canonKey, canonScalarKey, opRequestShape, entityIdField, entityDataIdField, entityOps, safeVarName, exampleVarName, luaKey, listMatchArg, matchExampleItems, requiredItems, litString } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, each, Content, isAuthActive, envName, canonKey, canonScalarKey, opRequestShape, entityIdField, entityDataIdField, entityOps, safeVarName, exampleVarName, luaKey, listMatchArg, matchExampleItems, requiredItems, litString, requestExampleItems, sendsId } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -161,7 +161,7 @@ ${printRecord(eVar, printCols, '')}
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
const examplePairs = (opname: string): string[] => {
|
|
164
|
-
const items =
|
|
164
|
+
const items = requestExampleItems(exampleEntity, opname)
|
|
165
165
|
.filter((it: any) => !idNames.has(it.name) ||
|
|
166
166
|
('create' === opname && !it.optional))
|
|
167
167
|
const required = items.filter((it: any) => !it.optional)
|
|
@@ -195,14 +195,14 @@ if err then error(err) end
|
|
|
195
195
|
`)
|
|
196
196
|
}
|
|
197
197
|
if (opnames.includes('update')) {
|
|
198
|
-
const updatePairs = (idF ? [`${luaKey(idF)} = ${idValueFor('update')}`] : []).concat(examplePairs('update'))
|
|
198
|
+
const updatePairs = (sendsId(exampleEntity, 'update', idF) ? [`${luaKey(idF)} = ${idValueFor('update')}`] : []).concat(examplePairs('update'))
|
|
199
199
|
Content(`-- Update
|
|
200
200
|
client:${eName}():update({ ${updatePairs.join(', ')} })
|
|
201
201
|
|
|
202
202
|
`)
|
|
203
203
|
}
|
|
204
204
|
if (opnames.includes('patch')) {
|
|
205
|
-
const patchPairs = (idF ? [`${luaKey(idF)} = ${idValueFor('patch')}`] : []).concat(examplePairs('patch'))
|
|
205
|
+
const patchPairs = (sendsId(exampleEntity, 'patch', idF) ? [`${luaKey(idF)} = ${idValueFor('patch')}`] : []).concat(examplePairs('patch'))
|
|
206
206
|
Content(`-- Patch — sends only the fields given
|
|
207
207
|
client:${eName}():patch({ ${patchPairs.join(', ')} })
|
|
208
208
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, each, Content, canonToType, canonKey, canonScalarKey, File, isAuthActive, entityIdField,
|
|
2
|
+
import { cmp, each, Content, canonToType, canonKey, canonScalarKey, File, isAuthActive, entityIdField, safeVarName, exampleVarName, luaKey, targetFeatures, opNeedsAction, bodyNote, listMatchArg, matchExampleItems, litString, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
import { ReadmeRefFeatures } from '@voxgig/sdkgen'
|
|
4
4
|
|
|
5
5
|
import {
|
|
@@ -296,7 +296,7 @@ local results, err = client:${ent.Name}():list(${listMatchArg('lua', ent)})
|
|
|
296
296
|
// a required id and parent keys like page_id (the --[[ type ]]
|
|
297
297
|
// placeholders mark the block as an illustration for the doc
|
|
298
298
|
// gate).
|
|
299
|
-
const createItems =
|
|
299
|
+
const createItems = requestExampleItems(ent, 'create')
|
|
300
300
|
.filter((it: any) => !it.optional)
|
|
301
301
|
Content(`\`\`\`lua
|
|
302
302
|
local result, err = client:${ent.Name}():create({
|
|
@@ -313,7 +313,7 @@ local result, err = client:${ent.Name}():create({
|
|
|
313
313
|
else if ('update' === opname || 'patch' === opname) {
|
|
314
314
|
// The id key plus every REQUIRED data member — the same shape the
|
|
315
315
|
// runtime validates — then the patch-fields note.
|
|
316
|
-
const updateItems =
|
|
316
|
+
const updateItems = requestExampleItems(ent, opname)
|
|
317
317
|
.filter((it: any) => !it.optional || it.name === idF)
|
|
318
318
|
.sort((a: any, b: any) =>
|
|
319
319
|
(a.name === idF ? 0 : 1) - (b.name === idF ? 0 : 1))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content, isAuthActive, envName, canonKey, canonScalarKey, entityIdField, opRequestShape, safeVarName, exampleVarName, luaKey, listMatchArg, matchExampleItems, litString } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, Content, isAuthActive, envName, canonKey, canonScalarKey, entityIdField, opRequestShape, safeVarName, exampleVarName, luaKey, listMatchArg, matchExampleItems, litString, entityOps } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -35,7 +35,7 @@ const ReadmeTopQuick = cmp(function ReadmeTopQuick(props: any) {
|
|
|
35
35
|
: `sdk.new()`
|
|
36
36
|
|
|
37
37
|
const shown = null != exampleEntity &&
|
|
38
|
-
['list', 'load'].some((op: string) =>
|
|
38
|
+
['list', 'load'].some((op: string) => entityOps(exampleEntity).includes(op))
|
|
39
39
|
|
|
40
40
|
Content(`\`\`\`lua
|
|
41
41
|
local sdk = require("${model.name}_sdk")
|
|
@@ -49,7 +49,7 @@ local client = ${ctor}
|
|
|
49
49
|
// Sanitise the local variable name — an entity whose lowercased name is a
|
|
50
50
|
// Lua keyword (e.g. `end`) would otherwise emit uncompilable code.
|
|
51
51
|
const eVar = exampleVarName(eName.toLowerCase(), 'lua')
|
|
52
|
-
const opnames =
|
|
52
|
+
const opnames = entityOps(exampleEntity)
|
|
53
53
|
const idF = entityIdField(exampleEntity)
|
|
54
54
|
|
|
55
55
|
let hasCall = false
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content, canonKey, canonScalarKey, entityIdField, pickExampleEntity,
|
|
2
|
+
import { cmp, Content, canonKey, canonScalarKey, entityIdField, pickExampleEntity, luaKey, requiredItems, matchExampleItems, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -48,7 +48,7 @@ local client = sdk.test()
|
|
|
48
48
|
`${luaKey(it.name)} = ${isMatchOp && it.name === idF ? '"test01"' : luaLit(it.type)}`).join(', ')} }`
|
|
49
49
|
: ''
|
|
50
50
|
} else if ('create' === primaryOp || 'update' === primaryOp || 'patch' === primaryOp) {
|
|
51
|
-
const items =
|
|
51
|
+
const items = requestExampleItems(exampleEntity, primaryOp)
|
|
52
52
|
.filter((it: any) => it.name !== idF && it.name !== 'id')
|
|
53
53
|
const required = items.filter((it: any) => !it.optional)
|
|
54
54
|
const chosen = required.length ? required : items.slice(0, 3)
|