@voxgig/sdkgen 4.35.3 → 4.36.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 +4 -3
- package/project/.sdk/src/cmp/go/Main_go.ts +2 -2
- 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/ReadmeQuick_go.ts +4 -4
- package/project/.sdk/src/cmp/go/ReadmeRef_go.ts +3 -3
- 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/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/ReadmeEntity_rust.ts +2 -2
- package/project/.sdk/src/cmp/rust/ReadmeHowto_rust.ts +2 -2
- package/project/.sdk/src/cmp/rust/ReadmeQuick_rust.ts +4 -4
- package/project/.sdk/src/cmp/rust/ReadmeRef_rust.ts +3 -3
- package/project/.sdk/src/cmp/rust/ReadmeTopQuick_rust.ts +2 -2
- package/project/.sdk/src/cmp/rust/ReadmeTopTest_rust.ts +2 -2
- package/project/.sdk/src/cmp/rust/TestDirect_rust.ts +40 -12
- package/project/.sdk/src/cmp/rust/TestEntity_rust.ts +108 -25
- 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/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/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/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,
|
|
@@ -163,7 +163,7 @@ catch (Exception err)
|
|
|
163
163
|
// Model-driven example fields: derive the create/update body from the op
|
|
164
164
|
// shape (opRequestShape) so the docs reference REAL writable fields.
|
|
165
165
|
const examplePairs = (opname: string): string[] => {
|
|
166
|
-
const items =
|
|
166
|
+
const items = requestExampleItems(exampleEntity, opname)
|
|
167
167
|
.filter((it: any) => (it.name !== idF && it.name !== 'id') ||
|
|
168
168
|
('create' === opname && !it.optional))
|
|
169
169
|
const required = items.filter((it: any) => !it.optional)
|
|
@@ -192,15 +192,15 @@ var created = client.${eName}().Create(new Dictionary<string, object?> { ${examp
|
|
|
192
192
|
`)
|
|
193
193
|
}
|
|
194
194
|
if (opnames.includes('update')) {
|
|
195
|
-
const updatePairs = (idF ? [`[${csStringLiteral(idF)}] = ${csLit(idParamType('update'), 'example_id')}`] : [])
|
|
195
|
+
const updatePairs = (sendsId(exampleEntity, 'update', idF) ? [`[${csStringLiteral(idF)}] = ${csLit(idParamType('update'), 'example_id')}`] : [])
|
|
196
196
|
.concat(examplePairs('update'))
|
|
197
|
-
Content(`// Update — supply the id in the match/data
|
|
197
|
+
Content(`// Update${sendsId(exampleEntity, 'update', idF) ? ' — supply the id in the match/data' : ''}
|
|
198
198
|
client.${eName}().Update(new Dictionary<string, object?> { ${updatePairs.join(', ')} });
|
|
199
199
|
|
|
200
200
|
`)
|
|
201
201
|
}
|
|
202
202
|
if (opnames.includes('patch')) {
|
|
203
|
-
const patchPairs = (idF ? [`[${csStringLiteral(idF)}] = ${csLit(idParamType('patch'), 'example_id')}`] : [])
|
|
203
|
+
const patchPairs = (sendsId(exampleEntity, 'patch', idF) ? [`[${csStringLiteral(idF)}] = ${csLit(idParamType('patch'), 'example_id')}`] : [])
|
|
204
204
|
.concat(examplePairs('patch'))
|
|
205
205
|
Content(`// Patch — sends only the fields given
|
|
206
206
|
client.${eName}().Patch(new Dictionary<string, object?> { ${patchPairs.join(', ')} });
|
|
@@ -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 {
|
|
@@ -296,7 +296,7 @@ foreach (var item in results)
|
|
|
296
296
|
`)
|
|
297
297
|
}
|
|
298
298
|
else if ('create' === opname) {
|
|
299
|
-
const createItems =
|
|
299
|
+
const createItems = requestExampleItems(ent, 'create')
|
|
300
300
|
.filter((it: any) => !it.optional)
|
|
301
301
|
Content(`\`\`\`csharp
|
|
302
302
|
var result = client.${ent.Name}().Create(new Dictionary<string, object?>
|
|
@@ -312,7 +312,7 @@ var result = client.${ent.Name}().Create(new Dictionary<string, object?>
|
|
|
312
312
|
`)
|
|
313
313
|
}
|
|
314
314
|
else if ('update' === opname || 'patch' === opname) {
|
|
315
|
-
const updateItems =
|
|
315
|
+
const updateItems = requestExampleItems(ent, opname)
|
|
316
316
|
.filter((it: any) => !it.optional || it.name === idF)
|
|
317
317
|
.sort((a: any, b: any) =>
|
|
318
318
|
(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,
|
|
@@ -38,7 +38,7 @@ const ReadmeTopQuick = cmp(function ReadmeTopQuick(props: any) {
|
|
|
38
38
|
: `new ${model.const.Name}SDK()`
|
|
39
39
|
|
|
40
40
|
const shown = null != exampleEntity &&
|
|
41
|
-
['list', 'load'].some((op: string) =>
|
|
41
|
+
['list', 'load'].some((op: string) => entityOps(exampleEntity).includes(op))
|
|
42
42
|
|
|
43
43
|
Content(`\`\`\`csharp
|
|
44
44
|
using ${model.const.Name}Sdk;
|
|
@@ -52,7 +52,7 @@ var client = ${ctor};
|
|
|
52
52
|
// Sanitise the local variable name — an entity whose camelCased name is a
|
|
53
53
|
// C# keyword gets a trailing underscore (csVarName) so the snippet compiles.
|
|
54
54
|
const eVar = csVarName(exampleEntity.name)
|
|
55
|
-
const opnames =
|
|
55
|
+
const opnames = entityOps(exampleEntity)
|
|
56
56
|
const idF = entityIdField(exampleEntity)
|
|
57
57
|
|
|
58
58
|
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,
|
|
@@ -53,7 +53,7 @@ var client = ${model.const.Name}SDK.TestSDK(null, null);
|
|
|
53
53
|
` [${csStringLiteral(it.name)}] = ${isMatchOp && it.name === idF ? '"test01"' : csLit(it.type)}`).join(',')} }`
|
|
54
54
|
: 'null'
|
|
55
55
|
} else if ('create' === primaryOp || 'update' === primaryOp || 'patch' === primaryOp) {
|
|
56
|
-
const items =
|
|
56
|
+
const items = requestExampleItems(exampleEntity, primaryOp)
|
|
57
57
|
.filter((it: any) => it.name !== idF && it.name !== 'id')
|
|
58
58
|
const required = items.filter((it: any) => !it.optional)
|
|
59
59
|
const chosen = required.length ? required : items.slice(0, 3)
|
|
@@ -15,10 +15,15 @@ import {
|
|
|
15
15
|
serverVarEnv,
|
|
16
16
|
serverVariables,
|
|
17
17
|
pointParts,
|
|
18
|
+
pointPlaceholders,
|
|
18
19
|
liveStrict,
|
|
19
20
|
liveStrictNote,
|
|
20
21
|
pointIsGraphql,
|
|
21
22
|
graphqlDirectSkip,
|
|
23
|
+
liveExampleIds,
|
|
24
|
+
liveQueryExamples,
|
|
25
|
+
liveEntity,
|
|
26
|
+
liveDirectGetOnly, liveExcludedLines, liveExcludedSummary, LIVE_GETONLY_ENV,
|
|
22
27
|
} from '@voxgig/sdkgen'
|
|
23
28
|
|
|
24
29
|
import { formatCsValue } from './utility_csharp'
|
|
@@ -61,12 +66,26 @@ function normalizePathParams(
|
|
|
61
66
|
}
|
|
62
67
|
|
|
63
68
|
|
|
69
|
+
// A GET-only live run excludes a test needing an id that only a write gives.
|
|
70
|
+
function getOnlyKeysBlock(model: any, entity: any, test: string, keys: string[]): string {
|
|
71
|
+
return liveDirectGetOnly(model, entity, test, keys).map((miss) =>
|
|
72
|
+
` if (setup.Live && Environment.GetEnvironmentVariable(${formatCsValue(LIVE_GETONLY_ENV)}) == "TRUE"
|
|
73
|
+
&& StructUtils.GetProp(setup.Idmap, ${formatCsValue(miss.key)}) == null)
|
|
74
|
+
{
|
|
75
|
+
Console.WriteLine(${formatCsValue(liveExcludedLines({ excluded: [miss] })[0])});
|
|
76
|
+
Console.WriteLine(${formatCsValue('skip: ' + liveExcludedSummary({ excluded: [miss] }))});
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
`).join('')
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
64
83
|
const TestDirect = cmp(function TestDirect(props: any) {
|
|
65
84
|
const ctx$ = props.ctx$
|
|
66
85
|
const model: Model = ctx$.model
|
|
67
86
|
|
|
68
87
|
const target = props.target
|
|
69
|
-
const entity: ModelEntity = props.entity
|
|
88
|
+
const entity: ModelEntity = liveEntity(ctx$, props.entity)
|
|
70
89
|
|
|
71
90
|
const Name = model.const.Name
|
|
72
91
|
const PROJECTNAME = envName(model)
|
|
@@ -111,12 +130,7 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
111
130
|
const allLoadParams = loadPoint?.g?.params || []
|
|
112
131
|
// Only path params that actually appear in the URL template drive direct
|
|
113
132
|
// path-param setup and URL-substitution asserts.
|
|
114
|
-
const _pathPlaceholders = new Set<string>()
|
|
115
|
-
for (const part of pointParts(loadPoint)) {
|
|
116
|
-
if (typeof part === 'string' && part.startsWith('{') && part.endsWith('}')) {
|
|
117
|
-
_pathPlaceholders.add(part.slice(1, -1))
|
|
118
|
-
}
|
|
119
|
-
}
|
|
133
|
+
const _pathPlaceholders = new Set<string>(pointPlaceholders(loadPoint))
|
|
120
134
|
const _renameMap = (loadPoint?.r?.param || {}) as Record<string, string>
|
|
121
135
|
const _renamedPlaceholders = new Set<string>()
|
|
122
136
|
for (const ph of _pathPlaceholders) {
|
|
@@ -134,11 +148,8 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
134
148
|
const listParams = listPoint?.g?.params || []
|
|
135
149
|
|
|
136
150
|
// Required query params with spec-provided examples - needed in live mode.
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
.filter((q: any) => q.r && undefined !== q.ex && null !== q.ex)
|
|
140
|
-
const loadLiveQueryLines = loadLiveQueryEntries
|
|
141
|
-
.map((q: any) => ` query["${q.n}"] = ${formatCsValue(q.ex)};`)
|
|
151
|
+
const loadLiveQueryLines = liveQueryExamples(loadPoint)
|
|
152
|
+
.map(([name, ex]) => ` query["${name}"] = ${formatCsValue(ex)};`)
|
|
142
153
|
.join('\n')
|
|
143
154
|
|
|
144
155
|
// Path params with spec-provided examples - when ALL load params have
|
|
@@ -153,6 +164,10 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
153
164
|
|
|
154
165
|
const entidEnvVar = `${PROJECTNAME}_TEST_${ENTUPPER}_ENTID`
|
|
155
166
|
|
|
167
|
+
const exampleIds = liveExampleIds(entity)
|
|
168
|
+
const listLiveQueryLines = liveQueryExamples(listPoint)
|
|
169
|
+
.map(([name, ex]) => ` query["${name}"] = ${formatCsValue(ex)};\n`).join('')
|
|
170
|
+
|
|
156
171
|
File({ name: entity.Name + 'DirectTest.' + target.ext }, () => {
|
|
157
172
|
|
|
158
173
|
Content(`// ${entity.name} direct API tests (generated from the API model).
|
|
@@ -192,7 +207,8 @@ ${liveStrictNote(liveStrict(model, target.name), '//', ' ')}
|
|
|
192
207
|
const listLiveIdKeys = listParams.length > 0
|
|
193
208
|
? listLiveParams.map((lp: any) => lp.key)
|
|
194
209
|
: []
|
|
195
|
-
const listSkipBlock =
|
|
210
|
+
const listSkipBlock = getOnlyKeysBlock(model, entity, 'direct-list-' + entity.name, listLiveIdKeys) +
|
|
211
|
+
(listLiveIdKeys.length > 0
|
|
196
212
|
? ` if (setup.Live)
|
|
197
213
|
{
|
|
198
214
|
foreach (var _liveKey in new[] { ${listLiveIdKeys.map((k: string) => `"${k}"`).join(', ')} })
|
|
@@ -205,7 +221,7 @@ ${liveStrictNote(liveStrict(model, target.name), '//', ' ')}
|
|
|
205
221
|
}
|
|
206
222
|
}
|
|
207
223
|
`
|
|
208
|
-
: ''
|
|
224
|
+
: '')
|
|
209
225
|
|
|
210
226
|
Content(` [Fact]
|
|
211
227
|
public void DirectList()
|
|
@@ -226,9 +242,10 @@ ${listSkipBlock} var client = setup.Client;
|
|
|
226
242
|
|
|
227
243
|
`)
|
|
228
244
|
|
|
229
|
-
if (listParams.length > 0) {
|
|
245
|
+
if (listParams.length > 0 || '' !== listLiveQueryLines) {
|
|
230
246
|
Content(` var pathParams = new Dictionary<string, object?>();
|
|
231
|
-
|
|
247
|
+
var query = new Dictionary<string, object?>();
|
|
248
|
+
${listLiveQueryLines ? ' if (setup.Live)\n {\n' + listLiveQueryLines + ' }\n' : ''}`)
|
|
232
249
|
listLiveParams.forEach((lp: any, i: number) => {
|
|
233
250
|
const placeholder = 'direct0' + (i + 1)
|
|
234
251
|
Content(` if (setup.Live)
|
|
@@ -247,6 +264,7 @@ ${listSkipBlock} var client = setup.Client;
|
|
|
247
264
|
["path"] = "${listPath}",
|
|
248
265
|
["method"] = "GET",
|
|
249
266
|
["params"] = pathParams,
|
|
267
|
+
["query"] = query,
|
|
250
268
|
});
|
|
251
269
|
`)
|
|
252
270
|
} else {
|
|
@@ -327,7 +345,8 @@ ${listSkipBlock} var client = setup.Client;
|
|
|
327
345
|
loadLiveIdKeys = [...new Set((hasList ?
|
|
328
346
|
[...listParams, ...loadParams.filter((p: any) => p.n !== 'id')] : loadParams).map(liveKey))]
|
|
329
347
|
}
|
|
330
|
-
const loadSkipBlock =
|
|
348
|
+
const loadSkipBlock = getOnlyKeysBlock(model, entity, 'direct-load-' + entity.name, loadLiveIdKeys) +
|
|
349
|
+
(loadLiveIdKeys.length > 0
|
|
331
350
|
? ` if (setup.Live)
|
|
332
351
|
{
|
|
333
352
|
foreach (var _liveKey in new[] { ${loadLiveIdKeys.map(k => `"${k}"`).join(', ')} })
|
|
@@ -340,7 +359,7 @@ ${listSkipBlock} var client = setup.Client;
|
|
|
340
359
|
}
|
|
341
360
|
}
|
|
342
361
|
`
|
|
343
|
-
: ''
|
|
362
|
+
: '')
|
|
344
363
|
|
|
345
364
|
Content(` [Fact]
|
|
346
365
|
public void DirectLoad()
|
|
@@ -559,7 +578,10 @@ ${loadSkipBlock} var client = setup.Client;
|
|
|
559
578
|
{
|
|
560
579
|
idmap = entidMap;
|
|
561
580
|
}
|
|
562
|
-
|
|
581
|
+
${0 === exampleIds.length ? '' : ` // A path parameter's example stands in for an id *_ENTID does not give.
|
|
582
|
+
idmap = new Dictionary<string, object?>(idmap);
|
|
583
|
+
${exampleIds.map(([key, ex]) => ` idmap.TryAdd("${key}", ${formatCsValue(ex)});
|
|
584
|
+
`).join('')}`}
|
|
563
585
|
return new ${entity.Name}DirectSetupResult
|
|
564
586
|
{
|
|
565
587
|
Client = liveClient,
|
|
@@ -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,
|
|
@@ -22,10 +22,13 @@ import {
|
|
|
22
22
|
serverVarEnv,
|
|
23
23
|
serverVariables,
|
|
24
24
|
liveFlowNeeds, liveStrict, liveStrictNote,
|
|
25
|
+
liveGetOnly, liveExcludedLines, liveExcludedSummary, LIVE_GETONLY_ENV,
|
|
26
|
+
liveRouteExamples, liveStepExamples,
|
|
27
|
+
liveEntity,
|
|
25
28
|
} from '@voxgig/sdkgen'
|
|
26
29
|
|
|
27
30
|
|
|
28
|
-
import { csVarName } from './utility_csharp'
|
|
31
|
+
import { csVarName, formatCsValue } from './utility_csharp'
|
|
29
32
|
|
|
30
33
|
|
|
31
34
|
// Convert a model name to a camelCase C# local (planet_ref01 -> planetRef01).
|
|
@@ -78,7 +81,9 @@ function liveFlowGate(entity: any, needs: any, entidEnv: string, strict: boolean
|
|
|
78
81
|
out += ' var client = setup.Client;\n'
|
|
79
82
|
if (null != needs.discover) {
|
|
80
83
|
const match = Object.entries(needs.discover)
|
|
81
|
-
.map(([k, v]: any) => ` [${JSON.stringify(k)}] = setup.Idmap[${JSON.stringify(v)}],`)
|
|
84
|
+
.map(([k, v]: any) => ` [${JSON.stringify(k)}] = setup.Idmap[${JSON.stringify(v)}],`)
|
|
85
|
+
.concat(liveRouteExamples(entity, 'list', Object.keys(needs.discover))
|
|
86
|
+
.map(([k, ex]) => ` [${JSON.stringify(k)}] = ${formatCsValue(ex)},`)).join('')
|
|
82
87
|
out += ` if (setup.Live && !TestRunner.LiveExisting(setup.Data, LIVE_STRICT, ${JSON.stringify(entity.name)},
|
|
83
88
|
() => client.${entity.Name}().List(new Dictionary<string, object?> {${match} }, null)))
|
|
84
89
|
{
|
|
@@ -98,7 +103,7 @@ const TestEntity = cmp(function TestEntity(props: any) {
|
|
|
98
103
|
const model: Model = ctx$.model
|
|
99
104
|
|
|
100
105
|
const target = props.target
|
|
101
|
-
const entity: ModelEntity = props.entity
|
|
106
|
+
const entity: ModelEntity = liveEntity(ctx$, props.entity)
|
|
102
107
|
|
|
103
108
|
const basicflow: ModelEntityFlow | undefined =
|
|
104
109
|
getModelPath(model, `main.${KIT}.flow.Basic${nom(entity, 'Name')}Flow`)
|
|
@@ -146,7 +151,6 @@ const TestEntity = cmp(function TestEntity(props: any) {
|
|
|
146
151
|
const genCtx: GenCtx = { model, entity, flow: basicflow, PROJUPPER }
|
|
147
152
|
|
|
148
153
|
const strict = liveStrict(model, target.name)
|
|
149
|
-
const needs = liveFlowNeeds(entity, basicflow)
|
|
150
154
|
const entidEnvVar = `${PROJUPPER}_TEST_${ENTUPPER}_ENTID`
|
|
151
155
|
|
|
152
156
|
const opNames = Array.from(new Set(
|
|
@@ -201,14 +205,18 @@ ${liveStrictNote(strict, '//', ' ')}
|
|
|
201
205
|
public void Basic()
|
|
202
206
|
{
|
|
203
207
|
var setup = ${entity.Name}BasicSetup(null);
|
|
204
|
-
${skipBlock}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
208
|
+
${skipBlock}`)
|
|
209
|
+
|
|
210
|
+
const flowBody = (flow: any) => {
|
|
211
|
+
const steps = flowSteps(flow) as any[]
|
|
212
|
+
Content(liveFlowGate(entity, liveFlowNeeds(entity, flow), entidEnvVar, strict, steps.length > 0))
|
|
213
|
+
|
|
214
|
+
// Check if the flow has a create step; if not, bootstrap entity data
|
|
215
|
+
const flowHasCreate = steps.some((s: any) => s.o === 'create')
|
|
216
|
+
if (!flowHasCreate) {
|
|
217
|
+
const preambleRef = entity.name + '_ref01'
|
|
218
|
+
const preambleVar = csVar(preambleRef)
|
|
219
|
+
Content(` // Bootstrap entity data from existing test data (no create step in flow).
|
|
212
220
|
var ${preambleVar}DataRaw = StructUtils.Items(
|
|
213
221
|
Helpers.ToMapAny(StructUtils.GetPath(setup.Data, "existing.${entity.name}")));
|
|
214
222
|
var ${preambleVar}Data = ${preambleVar}DataRaw.Count > 0
|
|
@@ -216,25 +224,55 @@ ${skipBlock}${liveFlowGate(entity, needs, entidEnvVar, strict, allSteps.length >
|
|
|
216
224
|
: null;
|
|
217
225
|
|
|
218
226
|
`)
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// Model-driven step iteration
|
|
222
|
-
each(flowSteps(basicflow), (step: any, index: any) => {
|
|
223
|
-
const opgen: OpGen = GENERATE_OP[step.o]
|
|
224
|
-
if (opgen) {
|
|
225
|
-
opgen(genCtx, step, index)
|
|
226
|
-
Content('\n')
|
|
227
227
|
}
|
|
228
|
-
})
|
|
229
228
|
|
|
230
|
-
|
|
229
|
+
// Model-driven step iteration
|
|
230
|
+
each(steps, (step: any, index: any) => {
|
|
231
|
+
const opgen: OpGen = GENERATE_OP[step.o]
|
|
232
|
+
if (opgen) {
|
|
233
|
+
opgen({ ...genCtx, flow }, step, index)
|
|
234
|
+
Content('\n')
|
|
235
|
+
}
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
Content(strict || 0 === steps.length ? '' : ` }
|
|
231
239
|
catch (Exception liveErr)
|
|
232
240
|
{
|
|
233
241
|
TestRunner.LiveObserve(liveErr, setup.Live, LIVE_STRICT);
|
|
234
242
|
}
|
|
235
|
-
`
|
|
243
|
+
`)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// A C# local is in scope throughout its block, so the steps a GET-only
|
|
247
|
+
// run keeps cannot share the method with the full flow's.
|
|
248
|
+
const getOnly = liveGetOnly(entity, basicflow)
|
|
249
|
+
const getOnlyRuns = null != getOnly && 0 < flowSteps(getOnly.flow).length
|
|
250
|
+
if (null != getOnly) {
|
|
251
|
+
Content(` if (setup.Live && Environment.GetEnvironmentVariable(${formatCsValue(LIVE_GETONLY_ENV)}) == "TRUE")
|
|
252
|
+
{
|
|
253
|
+
${liveExcludedLines(getOnly).map((line) => ' Console.WriteLine(' + formatCsValue(line) + ');\n').join('')}${getOnlyRuns ?
|
|
254
|
+
' BasicGetOnly(setup);\n' :
|
|
255
|
+
' Console.WriteLine(' + formatCsValue('skip: ' + liveExcludedSummary(getOnly)) + ');\n'} return;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
`)
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
flowBody(basicflow)
|
|
262
|
+
|
|
263
|
+
Content(` }
|
|
264
|
+
|
|
265
|
+
`)
|
|
266
|
+
|
|
267
|
+
if (null != getOnly && getOnlyRuns) {
|
|
268
|
+
Content(` private static void BasicGetOnly(EntityTestSetup setup)
|
|
269
|
+
{
|
|
270
|
+
`)
|
|
271
|
+
flowBody(getOnly.flow)
|
|
272
|
+
Content(` }
|
|
236
273
|
|
|
237
274
|
`)
|
|
275
|
+
}
|
|
238
276
|
|
|
239
277
|
// The stream test lists with no match, so a bare call must reach a route.
|
|
240
278
|
const flowHasList = allSteps.some((s: any) => s.o === 'list') &&
|
|
@@ -482,6 +520,7 @@ const generateList: OpGen = (ctx, step, index) => {
|
|
|
482
520
|
Content(` };
|
|
483
521
|
`)
|
|
484
522
|
}
|
|
523
|
+
Content(liveFill(entity, step, matchvar))
|
|
485
524
|
|
|
486
525
|
Content(`
|
|
487
526
|
var ${listvar}Result = ${entvar}.List(${matchvar}, null);
|
|
@@ -635,7 +674,7 @@ const generateLoad: OpGen = (ctx, step, index) => {
|
|
|
635
674
|
Content(` var ${entvar} = client.${entity.Name}();
|
|
636
675
|
`)
|
|
637
676
|
}
|
|
638
|
-
if (!hasSrcData && hasEntId) {
|
|
677
|
+
if (!hasSrcData && (hasEntId || flowLoadReadsRecord(entity, step))) {
|
|
639
678
|
Content(` var ${srcdatavar}Raw = StructUtils.Items(
|
|
640
679
|
Helpers.ToMapAny(StructUtils.GetPath(setup.Data, "existing.${entity.name}")));
|
|
641
680
|
var ${srcdatavar} = ${srcdatavar}Raw.Count > 0
|
|
@@ -648,7 +687,7 @@ const generateLoad: OpGen = (ctx, step, index) => {
|
|
|
648
687
|
{
|
|
649
688
|
["id"] = ${srcdatavar}!["id"],
|
|
650
689
|
};
|
|
651
|
-
${
|
|
690
|
+
${loadMatch(entity, step, matchvar, srcdatavar)}${liveFill(entity, step, matchvar)} var ${datavar}Loaded = ${entvar}.Load(${matchvar}, null);
|
|
652
691
|
var ${datavar}LoadResult = Helpers.ToMapAny(${datavar}Loaded is IEntity le ? le.Data() : ${datavar}Loaded);
|
|
653
692
|
Assert.True(${datavar}LoadResult != null, "expected load result to be a map");
|
|
654
693
|
Assert.True(StructRunner.DeepEqual(${datavar}LoadResult!["id"], ${srcdatavar}["id"]),
|
|
@@ -657,7 +696,7 @@ ${parentMatch(step, matchvar)} var ${datavar}Loaded = ${entvar}.Load(${ma
|
|
|
657
696
|
}
|
|
658
697
|
else {
|
|
659
698
|
Content(` var ${matchvar} = new Dictionary<string, object?>();
|
|
660
|
-
${
|
|
699
|
+
${loadMatch(entity, step, matchvar, srcdatavar)}${liveFill(entity, step, matchvar)} var ${datavar}Loaded = ${entvar}.Load(${matchvar}, null);
|
|
661
700
|
Assert.True(${datavar}Loaded != null, "expected load result to be non-null");
|
|
662
701
|
`)
|
|
663
702
|
}
|
|
@@ -694,6 +733,16 @@ ${parentMatch(step, matchvar)} ${entvar}.Remove(${matchvar}, null);
|
|
|
694
733
|
// A child's route names its parents, and an entity no earlier step has
|
|
695
734
|
// filled knows none of them, so the call itself gives each parent id. A live
|
|
696
735
|
// ENTID may key a parent by its field name, the fixture by its own name.
|
|
736
|
+
// A live step sends each example its route requires and the step leaves unbound.
|
|
737
|
+
function liveFill(entity: any, step: any, matchvar: string): string {
|
|
738
|
+
const fills = liveStepExamples(entity, step)
|
|
739
|
+
return 0 === fills.length ? '' : ` if (setup.Live)
|
|
740
|
+
{
|
|
741
|
+
${fills.map(([k, ex]) => ` ${matchvar}[${JSON.stringify(k)}] = ${formatCsValue(ex)};\n`).join('')} }
|
|
742
|
+
`
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
|
|
697
746
|
function parentMatch(step: any, matchvar: string): string {
|
|
698
747
|
return Object.entries(step.m || {})
|
|
699
748
|
.filter(([k]: any) => k !== 'id' && !k.endsWith('$'))
|
|
@@ -702,6 +751,35 @@ function parentMatch(step: any, matchvar: string): string {
|
|
|
702
751
|
}
|
|
703
752
|
|
|
704
753
|
|
|
754
|
+
// A load of a known record fills its route from that record, and from the
|
|
755
|
+
// step's binding where the record holds no scalar for it. A record only the
|
|
756
|
+
// fixture holds replaces the step's binding offline.
|
|
757
|
+
function loadMatch(entity: any, step: any, matchvar: string, srcdatavar: string): string {
|
|
758
|
+
const route = flowLoadRoute(entity, step)
|
|
759
|
+
if (null == route) {
|
|
760
|
+
return parentMatch(step, matchvar)
|
|
761
|
+
}
|
|
762
|
+
if (route.offline) {
|
|
763
|
+
const own = route.args.filter((arg) => null != arg.field)
|
|
764
|
+
return parentMatch(step, matchvar) + (0 === own.length ? '' : ` if (!setup.Live)
|
|
765
|
+
{
|
|
766
|
+
${own.map((arg, i) => ` if (StructUtils.GetProp(${srcdatavar}, "${arg.field}") is System.IConvertible own${i})
|
|
767
|
+
{
|
|
768
|
+
${matchvar}["${arg.name}"] = own${i};
|
|
769
|
+
}
|
|
770
|
+
`).join('')} }
|
|
771
|
+
`)
|
|
772
|
+
}
|
|
773
|
+
return route.args.map((arg) => {
|
|
774
|
+
const bound = arg.idmap.map((key) => `StructUtils.GetProp(setup.Idmap, "${key}")`).join(' ?? ')
|
|
775
|
+
const own = `StructUtils.GetProp(${srcdatavar}, "${arg.field}")`
|
|
776
|
+
return ` ${matchvar}["${arg.name}"] = ${null == arg.field ? bound :
|
|
777
|
+
`${own} is System.IConvertible ? ${own} : ${bound}`};
|
|
778
|
+
`
|
|
779
|
+
}).join('')
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
|
|
705
783
|
const GENERATE_OP: Record<string, OpGen> = {
|
|
706
784
|
create: generateCreate,
|
|
707
785
|
list: generateList,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, each, Content, canonToType, entityIdField,
|
|
2
|
+
import { cmp, each, Content, canonToType, entityIdField, opNeedsAction, elixirAccessor, entityCollection, exampleVarName, matchExampleItems, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -140,7 +140,7 @@ ${eVar}s = ${Name}.Entity.${EName}.list(${eVar}${elixirListArgs(entity, Name)})
|
|
|
140
140
|
// Members come from the SAME shape the runtime validates
|
|
141
141
|
// (opRequestShape): every required member must appear — with a real,
|
|
142
142
|
// executable literal.
|
|
143
|
-
const createItems =
|
|
143
|
+
const createItems = requestExampleItems(entity, 'create')
|
|
144
144
|
.filter((it: any) => !it.optional)
|
|
145
145
|
Content(`#### Example: Create
|
|
146
146
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content, isAuthActive, envName, entityIdField, pickExampleEntity,
|
|
2
|
+
import { cmp, Content, isAuthActive, envName, entityIdField, pickExampleEntity, elixirAccessor, entityCollection, exampleVarName, requiredItems, matchExampleItems, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -34,7 +34,7 @@ const ReadmeHowto = cmp(function ReadmeHowto(props: any) {
|
|
|
34
34
|
const chosen = requiredItems(exampleEntity, 'list')
|
|
35
35
|
testArg = `H.deep(%{${chosen.map((it: any) => `${elixirString(it.name)} => ${elixirLit(it.type)}`).join(', ')}})`
|
|
36
36
|
} else if (exampleEntity && ('create' === primaryOp || 'update' === primaryOp || 'patch' === primaryOp)) {
|
|
37
|
-
const items =
|
|
37
|
+
const items = requestExampleItems(exampleEntity, primaryOp)
|
|
38
38
|
.filter((it: any) => it.name !== idF && it.name !== 'id')
|
|
39
39
|
const required = items.filter((it: any) => !it.optional)
|
|
40
40
|
const chosen = required.length ? required : items.slice(0, 3)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content, isAuthActive, envName, opRequestShape, entityIdField, entityDataIdField, entityOps, elixirAccessor, entityCollection, exampleVarName, matchExampleItems, requiredItems } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, Content, isAuthActive, envName, opRequestShape, entityIdField, entityDataIdField, entityOps, elixirAccessor, entityCollection, exampleVarName, matchExampleItems, requiredItems, requestExampleItems, sendsId } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -140,7 +140,7 @@ end
|
|
|
140
140
|
// Model-driven example fields: derive the create/update body from the op
|
|
141
141
|
// shape so the docs reference REAL writable fields.
|
|
142
142
|
const examplePairs = (opname: string): string[] => {
|
|
143
|
-
const items =
|
|
143
|
+
const items = requestExampleItems(exampleEntity, opname)
|
|
144
144
|
.filter((it: any) => (it.name !== idF && it.name !== 'id') ||
|
|
145
145
|
('create' === opname && !it.optional))
|
|
146
146
|
const required = items.filter((it: any) => !it.optional)
|
|
@@ -174,14 +174,14 @@ created = ${Name}.Entity.${eName}.create(${eVar}, H.deep(%{${examplePairs('creat
|
|
|
174
174
|
`)
|
|
175
175
|
}
|
|
176
176
|
if (opnames.includes('update')) {
|
|
177
|
-
const updatePairs = (idF ? [`${elixirString(idF)} => ${idValueFor('update')}`] : []).concat(examplePairs('update'))
|
|
177
|
+
const updatePairs = (sendsId(exampleEntity, 'update', idF) ? [`${elixirString(idF)} => ${idValueFor('update')}`] : []).concat(examplePairs('update'))
|
|
178
178
|
Content(`# Update
|
|
179
179
|
${Name}.Entity.${eName}.update(${eVar}, H.deep(%{${updatePairs.join(', ')}}))
|
|
180
180
|
|
|
181
181
|
`)
|
|
182
182
|
}
|
|
183
183
|
if (opnames.includes('patch')) {
|
|
184
|
-
const patchPairs = (idF ? [`${elixirString(idF)} => ${idValueFor('patch')}`] : []).concat(examplePairs('patch'))
|
|
184
|
+
const patchPairs = (sendsId(exampleEntity, 'patch', idF) ? [`${elixirString(idF)} => ${idValueFor('patch')}`] : []).concat(examplePairs('patch'))
|
|
185
185
|
Content(`# Patch — sends only the fields given
|
|
186
186
|
${Name}.Entity.${eName}.patch(${eVar}, H.deep(%{${patchPairs.join(', ')}}))
|
|
187
187
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, each, Content, canonToType, File, isAuthActive, entityIdField
|
|
2
|
+
import { cmp, each, Content, canonToType, File, isAuthActive, entityIdField , targetFeatures, opNeedsAction, bodyNote, elixirAccessor, entityCollection, exampleVarName, matchExampleItems, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
import { ReadmeRefFeatures } from '@voxgig/sdkgen'
|
|
4
4
|
|
|
5
5
|
import {
|
|
@@ -230,7 +230,7 @@ ${eVar}s = ${Name}.Entity.${EName}.list(${eVar}${elixirListArgs(ent, Name)})
|
|
|
230
230
|
`)
|
|
231
231
|
}
|
|
232
232
|
else if ('create' === opname) {
|
|
233
|
-
const createItems =
|
|
233
|
+
const createItems = requestExampleItems(ent, 'create')
|
|
234
234
|
.filter((it: any) => !it.optional)
|
|
235
235
|
Content(`\`\`\`elixir
|
|
236
236
|
${eVar} = ${Name}.Entity.${EName}.create(${eVar}, ${Name}.Helpers.deep(%{
|
|
@@ -245,7 +245,7 @@ ${eVar} = ${Name}.Entity.${EName}.create(${eVar}, ${Name}.Helpers.deep(%{
|
|
|
245
245
|
`)
|
|
246
246
|
}
|
|
247
247
|
else if ('update' === opname || 'patch' === opname) {
|
|
248
|
-
const updateItems =
|
|
248
|
+
const updateItems = requestExampleItems(ent, opname)
|
|
249
249
|
.filter((it: any) => !it.optional || it.name === idF)
|
|
250
250
|
.sort((a: any, b: any) =>
|
|
251
251
|
(a.name === idF ? 0 : 1) - (b.name === idF ? 0 : 1))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content, isAuthActive, envName, entityIdField, opRequestShape, elixirAccessor, entityCollection, exampleVarName, matchExampleItems } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, Content, isAuthActive, envName, entityIdField, opRequestShape, elixirAccessor, entityCollection, exampleVarName, matchExampleItems, entityOps } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -34,7 +34,7 @@ sdk = ${ctor}
|
|
|
34
34
|
const eName = nom(exampleEntity, 'Name')
|
|
35
35
|
const eVar = exampleVarName(exampleEntity.name, 'elixir')
|
|
36
36
|
const eCall = elixirAccessor(exampleEntity, entityCollection(model))
|
|
37
|
-
const opnames =
|
|
37
|
+
const opnames = entityOps(exampleEntity)
|
|
38
38
|
const idF = entityIdField(exampleEntity)
|
|
39
39
|
|
|
40
40
|
Content(`${eVar} = ${Name}.${eCall}(sdk)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content, entityIdField, pickExampleEntity,
|
|
2
|
+
import { cmp, Content, entityIdField, pickExampleEntity, elixirAccessor, entityCollection, exampleVarName, requiredItems, matchExampleItems, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -42,7 +42,7 @@ sdk = ${Name}.test()
|
|
|
42
42
|
`${elixirString(it.name)} => ${isMatchOp && it.name === idF ? '"test01"' : elixirLit(it.type)}`).join(', ')}})`
|
|
43
43
|
: 'H.deep(%{})'
|
|
44
44
|
} else if ('create' === primaryOp || 'update' === primaryOp || 'patch' === primaryOp) {
|
|
45
|
-
const items =
|
|
45
|
+
const items = requestExampleItems(exampleEntity, primaryOp)
|
|
46
46
|
.filter((it: any) => it.name !== idF && it.name !== 'id')
|
|
47
47
|
const required = items.filter((it: any) => !it.optional)
|
|
48
48
|
const chosen = required.length ? required : items.slice(0, 3)
|
|
@@ -10,7 +10,7 @@ import { formatGoMap } from './utility_go'
|
|
|
10
10
|
|
|
11
11
|
const EntityOperation = cmp(function Operation(props: any) {
|
|
12
12
|
const { model } = props.ctx$
|
|
13
|
-
const { ff, opname, entity, entrep, gomodule, cls } = props
|
|
13
|
+
const { ff, opname, entity, entrep, gomodule, cls, ctor } = props
|
|
14
14
|
|
|
15
15
|
let { indent } = props
|
|
16
16
|
|
|
@@ -39,7 +39,7 @@ const EntityOperation = cmp(function Operation(props: any) {
|
|
|
39
39
|
// in the Entity<Op>Op.fragment.go files (receiver -> cls; the per-op
|
|
40
40
|
// EntityName<Op>Match/Data data types stay derived from EntityName).
|
|
41
41
|
EntyClass: cls,
|
|
42
|
-
NewEntyClass:
|
|
42
|
+
NewEntyClass: ctor,
|
|
43
43
|
|
|
44
44
|
'#Feature-Hook': ({ name, indent }: any) =>
|
|
45
45
|
Content({ indent }, `
|