@voxgig/sdkgen 4.35.2 → 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/flowGuard.js +12 -1
- package/dist/helpers/flowGuard.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/flowGuard.ts +12 -1
- 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
|
@@ -30,6 +30,9 @@ import {
|
|
|
30
30
|
serverVariables,
|
|
31
31
|
invalidRequest,
|
|
32
32
|
liveFlowNeeds, liveStrict, liveStrictNote,
|
|
33
|
+
liveRouteExamples, liveStepExamples, flowLoadRoute, flowLoadReadsRecord,
|
|
34
|
+
liveGetOnly, liveExcludedLines, liveExcludedSummary, LIVE_GETONLY_ENV,
|
|
35
|
+
liveEntity,
|
|
33
36
|
} from '@voxgig/sdkgen'
|
|
34
37
|
|
|
35
38
|
import { formatLuaValue } from './utility_lua'
|
|
@@ -70,7 +73,9 @@ function liveFlowGate(entity: any, needs: any, entidEnv: string, strict: boolean
|
|
|
70
73
|
out += ' local client = setup.client\n'
|
|
71
74
|
if (null != needs.discover) {
|
|
72
75
|
const match = Object.entries(needs.discover)
|
|
73
|
-
.map(([k, v]: any) => `[${JSON.stringify(k)}] = setup.idmap[${JSON.stringify(v)}]`)
|
|
76
|
+
.map(([k, v]: any) => `[${JSON.stringify(k)}] = setup.idmap[${JSON.stringify(v)}]`)
|
|
77
|
+
.concat(liveRouteExamples(entity, 'list', Object.keys(needs.discover))
|
|
78
|
+
.map(([k, ex]) => `[${JSON.stringify(k)}] = ${formatLuaValue(ex)}`)).join(', ')
|
|
74
79
|
out += ` if setup.live then
|
|
75
80
|
runner.live_existing(pending, setup, LIVE_STRICT, ${JSON.stringify(entity.name)}, function()
|
|
76
81
|
return client:${entity.Name}(nil):list({${match}}, nil)
|
|
@@ -90,7 +95,7 @@ const TestEntity = cmp(function TestEntity(props: any) {
|
|
|
90
95
|
const model: Model = ctx$.model
|
|
91
96
|
|
|
92
97
|
const target = props.target
|
|
93
|
-
const entity: ModelEntity = props.entity
|
|
98
|
+
const entity: ModelEntity = liveEntity(ctx$, props.entity)
|
|
94
99
|
|
|
95
100
|
// The stream test streams the "list" op with no match and asserts a 3-item
|
|
96
101
|
// collection, so it only applies to an entity whose list a bare call can
|
|
@@ -140,7 +145,6 @@ const TestEntity = cmp(function TestEntity(props: any) {
|
|
|
140
145
|
const genCtx: GenCtx = { model, entity, flow: basicflow, PROJUPPER }
|
|
141
146
|
|
|
142
147
|
const strict = liveStrict(model, target.name)
|
|
143
|
-
const needs = liveFlowNeeds(entity, basicflow)
|
|
144
148
|
const entidEnv = PROJUPPER + '_TEST_' + envToken(entity.name) + '_ENTID'
|
|
145
149
|
|
|
146
150
|
File({ name: entity.name + '_entity_test.' + target.ext }, () => {
|
|
@@ -218,13 +222,16 @@ ${failureTests(entity)}` : ''}${validateTest(entity)}
|
|
|
218
222
|
return
|
|
219
223
|
end
|
|
220
224
|
end
|
|
221
|
-
${liveFlowGate(entity, needs, entidEnv, strict)}
|
|
222
225
|
`)
|
|
223
226
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
227
|
+
const flowBody = (flow: any) => {
|
|
228
|
+
const steps = flowSteps(flow) as any[]
|
|
229
|
+
Content(liveFlowGate(entity, liveFlowNeeds(entity, flow), entidEnv, strict) + '\n')
|
|
230
|
+
|
|
231
|
+
// Check if the flow has a create step
|
|
232
|
+
const flowHasCreate = steps.some((s: any) => s.o === 'create')
|
|
233
|
+
if (!flowHasCreate) {
|
|
234
|
+
Content(` -- Bootstrap entity data from existing test data.
|
|
228
235
|
local ${entity.name}_ref01_data_raw = vs.items(helpers.to_map(
|
|
229
236
|
vs.getpath(setup.data, "existing.${entity.name}")))
|
|
230
237
|
local ${entity.name}_ref01_data = nil
|
|
@@ -233,30 +240,55 @@ ${liveFlowGate(entity, needs, entidEnv, strict)}
|
|
|
233
240
|
end
|
|
234
241
|
|
|
235
242
|
`)
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// Model-driven step iteration
|
|
239
|
-
each(flowSteps(basicflow), (step: any, index: any) => {
|
|
240
|
-
// Never emit a REMOVE (or its removed-item verify LIST) without a
|
|
241
|
-
// preceding CREATE: a coherent CRUD flow only removes what it created,
|
|
242
|
-
// so a create-less remove would mutate pre-existing (live) data.
|
|
243
|
-
if (!flowHasCreate) {
|
|
244
|
-
if ('remove' === step.o) { return }
|
|
245
|
-
if ('list' === step.o &&
|
|
246
|
-
(step.v || []).some((v: any) => 'ItemNotExists' === v.apply)) { return }
|
|
247
243
|
}
|
|
248
|
-
const opgen: OpGen = GENERATE_OP[step.o]
|
|
249
|
-
if (opgen) {
|
|
250
|
-
opgen(genCtx, step, index)
|
|
251
|
-
Content('\n')
|
|
252
|
-
}
|
|
253
|
-
})
|
|
254
244
|
|
|
255
|
-
|
|
245
|
+
// Model-driven step iteration
|
|
246
|
+
each(steps, (step: any, index: any) => {
|
|
247
|
+
// Never emit a REMOVE (or its removed-item verify LIST) without a
|
|
248
|
+
// preceding CREATE: a coherent CRUD flow only removes what it created,
|
|
249
|
+
// so a create-less remove would mutate pre-existing (live) data.
|
|
250
|
+
if (!flowHasCreate) {
|
|
251
|
+
if ('remove' === step.o) { return }
|
|
252
|
+
if ('list' === step.o &&
|
|
253
|
+
(step.v || []).some((v: any) => 'ItemNotExists' === v.apply)) { return }
|
|
254
|
+
}
|
|
255
|
+
const opgen: OpGen = GENERATE_OP[step.o]
|
|
256
|
+
if (opgen) {
|
|
257
|
+
opgen({ ...genCtx, flow }, step, index)
|
|
258
|
+
Content('\n')
|
|
259
|
+
}
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
Content(strict ? '' : ` end)
|
|
256
263
|
if not _live_ok then
|
|
257
264
|
runner.live_observe(pending, _live_err, setup, LIVE_STRICT)
|
|
258
265
|
end
|
|
259
|
-
`
|
|
266
|
+
`)
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const getOnly = liveGetOnly(entity, basicflow)
|
|
270
|
+
if (null != getOnly) {
|
|
271
|
+
Content(` if setup.live and os.getenv(${formatLuaValue(LIVE_GETONLY_ENV)}) == "TRUE" then
|
|
272
|
+
${liveExcludedLines(getOnly).map((line) => ' print(' + formatLuaValue(line) + ')\n').join('')}`)
|
|
273
|
+
if (0 === flowSteps(getOnly.flow).length) {
|
|
274
|
+
Content(` pending(${formatLuaValue(liveExcludedSummary(getOnly))})
|
|
275
|
+
return
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
`)
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
flowBody(getOnly.flow)
|
|
282
|
+
Content(` return
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
`)
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
flowBody(basicflow)
|
|
290
|
+
|
|
291
|
+
Content(` end)
|
|
260
292
|
end)
|
|
261
293
|
|
|
262
294
|
`)
|
|
@@ -440,6 +472,7 @@ const generateList: OpGen = (ctx, step, index) => {
|
|
|
440
472
|
Content(` }
|
|
441
473
|
`)
|
|
442
474
|
}
|
|
475
|
+
Content(liveFill(entity, step, matchvar))
|
|
443
476
|
|
|
444
477
|
Content(`
|
|
445
478
|
local ${listvar}_result, err = ${entvar}:list(${matchvar}, nil)
|
|
@@ -584,7 +617,7 @@ const generateLoad: OpGen = (ctx, step, index) => {
|
|
|
584
617
|
Content(` local ${entvar} = client:${entity.Name}(nil)
|
|
585
618
|
`)
|
|
586
619
|
}
|
|
587
|
-
if (!hasSrcData && hasEntId) {
|
|
620
|
+
if (!hasSrcData && (hasEntId || flowLoadReadsRecord(entity, step))) {
|
|
588
621
|
Content(` local ${srcdatavar}_raw = vs.items(helpers.to_map(
|
|
589
622
|
vs.getpath(setup.data, "existing.${entity.name}")))
|
|
590
623
|
local ${srcdatavar} = nil
|
|
@@ -597,7 +630,7 @@ const generateLoad: OpGen = (ctx, step, index) => {
|
|
|
597
630
|
Content(` local ${matchvar} = {
|
|
598
631
|
id = ${srcdatavar}["id"],
|
|
599
632
|
}
|
|
600
|
-
${
|
|
633
|
+
${loadMatch(entity, step, matchvar, srcdatavar)}${liveFill(entity, step, matchvar)} local ${datavar}_loaded, err = ${entvar}:load(${matchvar}, nil)
|
|
601
634
|
assert.is_nil(err)
|
|
602
635
|
local ${datavar}_load_result = helpers.to_map(type(${datavar}_loaded) == 'table' and ${datavar}_loaded.data_get and ${datavar}_loaded:data_get() or ${datavar}_loaded)
|
|
603
636
|
assert.is_not_nil(${datavar}_load_result)
|
|
@@ -606,7 +639,7 @@ ${parentMatch(step, matchvar)} local ${datavar}_loaded, err = ${entvar}:load(
|
|
|
606
639
|
}
|
|
607
640
|
else {
|
|
608
641
|
Content(` local ${matchvar} = {}
|
|
609
|
-
${
|
|
642
|
+
${loadMatch(entity, step, matchvar, srcdatavar)}${liveFill(entity, step, matchvar)} local ${datavar}_loaded, err = ${entvar}:load(${matchvar}, nil)
|
|
610
643
|
assert.is_nil(err)
|
|
611
644
|
assert.is_not_nil(${datavar}_loaded)
|
|
612
645
|
`)
|
|
@@ -648,6 +681,15 @@ ${parentMatch(step, matchvar)} local _, err = ${entvar}:remove(${matchvar}, n
|
|
|
648
681
|
// A child's route names its parents, and an entity no earlier step has
|
|
649
682
|
// filled knows none of them, so the call itself gives each parent id. A live
|
|
650
683
|
// ENTID may key a parent by its field name, the fixture by its own name.
|
|
684
|
+
// A live step sends each example its route requires and the step leaves unbound.
|
|
685
|
+
function liveFill(entity: any, step: any, matchvar: string): string {
|
|
686
|
+
const fills = liveStepExamples(entity, step)
|
|
687
|
+
return 0 === fills.length ? '' : ` if setup.live then
|
|
688
|
+
${fills.map(([k, ex]) => ` ${matchvar}[${JSON.stringify(k)}] = ${formatLuaValue(ex)}\n`).join('')} end
|
|
689
|
+
`
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
|
|
651
693
|
function parentMatch(step: any, matchvar: string): string {
|
|
652
694
|
return Object.entries(step.m || {})
|
|
653
695
|
.filter(([k]: any) => k !== 'id' && !k.endsWith('$'))
|
|
@@ -655,6 +697,42 @@ function parentMatch(step: any, matchvar: string): string {
|
|
|
655
697
|
`).join('')
|
|
656
698
|
}
|
|
657
699
|
|
|
700
|
+
// A load of a known record fills its route from that record, and from the
|
|
701
|
+
// step's binding where the record holds no scalar for it. A record only the
|
|
702
|
+
// fixture holds replaces the step's binding offline.
|
|
703
|
+
function loadMatch(entity: any, step: any, matchvar: string, srcdatavar: string): string {
|
|
704
|
+
const route = flowLoadRoute(entity, step)
|
|
705
|
+
if (null == route) {
|
|
706
|
+
return parentMatch(step, matchvar)
|
|
707
|
+
}
|
|
708
|
+
if (route.offline) {
|
|
709
|
+
const own = route.args.filter((arg) => null != arg.field)
|
|
710
|
+
return parentMatch(step, matchvar) + (0 === own.length ? '' : ` if not setup.live then
|
|
711
|
+
${own.map((arg) => ` do
|
|
712
|
+
local own = ${srcdatavar}["${arg.field}"]
|
|
713
|
+
if type(own) == "string" or type(own) == "number" or type(own) == "boolean" then
|
|
714
|
+
${matchvar}["${arg.name}"] = own
|
|
715
|
+
end
|
|
716
|
+
end
|
|
717
|
+
`).join('')} end
|
|
718
|
+
`)
|
|
719
|
+
}
|
|
720
|
+
return route.args.map((arg) => {
|
|
721
|
+
const bound = arg.idmap.map((key) => `setup.idmap["${key}"]`).join(' or ')
|
|
722
|
+
return null == arg.field ? ` ${matchvar}["${arg.name}"] = ${bound}
|
|
723
|
+
` : ` do
|
|
724
|
+
local own = ${srcdatavar}["${arg.field}"]
|
|
725
|
+
if type(own) == "string" or type(own) == "number" or type(own) == "boolean" then
|
|
726
|
+
${matchvar}["${arg.name}"] = own
|
|
727
|
+
else
|
|
728
|
+
${matchvar}["${arg.name}"] = ${bound}
|
|
729
|
+
end
|
|
730
|
+
end
|
|
731
|
+
`
|
|
732
|
+
}).join('')
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
|
|
658
736
|
const GENERATE_OP: Record<string, OpGen> = {
|
|
659
737
|
create: generateCreate,
|
|
660
738
|
list: generateList,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, each, Content, canonKey, canonScalarKey, entityIdField,
|
|
2
|
+
import { cmp, each, Content, canonKey, canonScalarKey, entityIdField, opNeedsAction, matchExampleItems, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -162,7 +162,7 @@ let ${fn}_datas = List.map (fun e -> e.e_data_get ()) ${fn}s
|
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
if (callable.includes('create')) {
|
|
165
|
-
const createItems =
|
|
165
|
+
const createItems = requestExampleItems(entity, 'create')
|
|
166
166
|
.filter((it: any) => !it.optional)
|
|
167
167
|
Content(`#### Example: Create
|
|
168
168
|
|
|
@@ -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, matchExampleItems, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -43,7 +43,7 @@ const ReadmeHowto = cmp(function ReadmeHowto(props: any) {
|
|
|
43
43
|
? `(jo [${items.map((it: any) => `("${ocamlString(it.name)}", ${it.name === idF ? 'Str "test01"' : ocamlLit(it.type)})`).join('; ')}])`
|
|
44
44
|
: '(empty_map ())'
|
|
45
45
|
} else if (exampleEntity && ('create' === primaryOp || 'update' === primaryOp || 'patch' === primaryOp)) {
|
|
46
|
-
const items =
|
|
46
|
+
const items = requestExampleItems(exampleEntity, primaryOp)
|
|
47
47
|
.filter((it: any) => it.name !== idF && it.name !== 'id')
|
|
48
48
|
const required = items.filter((it: any) => !it.optional)
|
|
49
49
|
const chosen = required.length ? required : items.slice(0, 3)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content, isAuthActive, envName, canonKey, canonScalarKey, opRequestShape, entityIdField, entityDataIdField, entityOps, matchExampleItems, requiredItems } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, Content, isAuthActive, envName, canonKey, canonScalarKey, opRequestShape, entityIdField, entityDataIdField, entityOps, matchExampleItems, requiredItems, requestExampleItems, sendsId } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -142,7 +142,7 @@ record.
|
|
|
142
142
|
// Model-driven example fields: derive the create/update body from the op
|
|
143
143
|
// shape so the docs reference REAL writable fields.
|
|
144
144
|
const examplePairs = (opname: string): string[] => {
|
|
145
|
-
const items =
|
|
145
|
+
const items = requestExampleItems(exampleEntity, opname)
|
|
146
146
|
.filter((it: any) => (it.name !== idF && it.name !== 'id') ||
|
|
147
147
|
('create' === opname && !it.optional))
|
|
148
148
|
const required = items.filter((it: any) => !it.optional)
|
|
@@ -175,14 +175,14 @@ print_endline (stringify (created.e_data_get ()));
|
|
|
175
175
|
`)
|
|
176
176
|
}
|
|
177
177
|
if (opnames.includes('update')) {
|
|
178
|
-
const updatePairs = (idF ? [`("${ocamlString(idF)}", ${idValueFor('update')})`] : []).concat(examplePairs('update'))
|
|
178
|
+
const updatePairs = (sendsId(exampleEntity, 'update', idF) ? [`("${ocamlString(idF)}", ${idValueFor('update')})`] : []).concat(examplePairs('update'))
|
|
179
179
|
Content(`(* Update *)
|
|
180
180
|
ignore ((Sdk_client.${fn} client Noval).e_update (jo [${updatePairs.join('; ')}]) Noval);
|
|
181
181
|
|
|
182
182
|
`)
|
|
183
183
|
}
|
|
184
184
|
if (opnames.includes('patch')) {
|
|
185
|
-
const patchPairs = (idF ? [`("${ocamlString(idF)}", ${idValueFor('patch')})`] : []).concat(examplePairs('patch'))
|
|
185
|
+
const patchPairs = (sendsId(exampleEntity, 'patch', idF) ? [`("${ocamlString(idF)}", ${idValueFor('patch')})`] : []).concat(examplePairs('patch'))
|
|
186
186
|
Content(`(* Patch — sends only the fields given *)
|
|
187
187
|
ignore ((Sdk_client.${fn} client Noval).e_patch (jo [${patchPairs.join('; ')}]) Noval);
|
|
188
188
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, each, Content, canonKey, canonScalarKey, File, isAuthActive, entityIdField
|
|
2
|
+
import { cmp, each, Content, 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 {
|
|
@@ -299,7 +299,7 @@ List.iter (fun e -> print_endline (stringify (e.e_data_get ()))) results
|
|
|
299
299
|
`)
|
|
300
300
|
}
|
|
301
301
|
else if ('create' === opname) {
|
|
302
|
-
const createItems =
|
|
302
|
+
const createItems = requestExampleItems(ent, 'create')
|
|
303
303
|
.filter((it: any) => !it.optional)
|
|
304
304
|
Content(`\`\`\`ocaml
|
|
305
305
|
let result = (Sdk_client.${fn} client Noval).e_create (jo [
|
|
@@ -315,7 +315,7 @@ let result_data = result.e_data_get ()
|
|
|
315
315
|
`)
|
|
316
316
|
}
|
|
317
317
|
else if ('update' === opname || 'patch' === opname) {
|
|
318
|
-
const updateItems =
|
|
318
|
+
const updateItems = requestExampleItems(ent, opname)
|
|
319
319
|
.filter((it: any) => !it.optional || it.name === idF)
|
|
320
320
|
.sort((a: any, b: any) =>
|
|
321
321
|
(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,
|
|
@@ -45,7 +45,7 @@ let () =
|
|
|
45
45
|
|
|
46
46
|
if (exampleEntity) {
|
|
47
47
|
const fn = ocamlVarName(exampleEntity.name)
|
|
48
|
-
const opnames =
|
|
48
|
+
const opnames = entityOps(exampleEntity)
|
|
49
49
|
// Model-driven id key: null when the entity has no id-like field, in which
|
|
50
50
|
// case the load example takes no match argument.
|
|
51
51
|
const idF = entityIdField(exampleEntity)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content, canonKey, canonScalarKey, entityIdField, pickExampleEntity,
|
|
2
|
+
import { cmp, Content, canonKey, canonScalarKey, entityIdField, pickExampleEntity, matchExampleItems, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -53,7 +53,7 @@ let () =
|
|
|
53
53
|
`("${ocamlString(it.name)}", ${it.name === idF ? '(Str "test01")' : ocamlLit(it.type)})`).join('; ')}])`
|
|
54
54
|
: '(empty_map ())'
|
|
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)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, each, Content, canonKey, canonScalarKey, entityIdField,
|
|
2
|
+
import { cmp, each, Content, canonKey, canonScalarKey, entityIdField, opNeedsAction, matchExampleItems, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -160,7 +160,7 @@ print $_->data_get->{id}, "\\n" for @$${eVar}s;
|
|
|
160
160
|
// (opRequestShape): every required member must appear — including a
|
|
161
161
|
// required id and parent keys like page_id — with a real, executable
|
|
162
162
|
// literal.
|
|
163
|
-
const createItems =
|
|
163
|
+
const createItems = requestExampleItems(entity, 'create')
|
|
164
164
|
.filter((it: any) => !it.optional)
|
|
165
165
|
Content(`#### Example: Create
|
|
166
166
|
|
|
@@ -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, requiredItems, matchExampleItems, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -46,7 +46,7 @@ const ReadmeHowto = cmp(function ReadmeHowto(props: any) {
|
|
|
46
46
|
const chosen = requiredItems(exampleEntity, 'list')
|
|
47
47
|
testArg = `{ ${chosen.map((it: any) => `${perlStringLiteral(it.name)} => ${perlLit(it.type)}`).join(', ')} }`
|
|
48
48
|
} else if (exampleEntity && ('create' === primaryOp || 'update' === primaryOp || 'patch' === primaryOp)) {
|
|
49
|
-
const items =
|
|
49
|
+
const items = requestExampleItems(exampleEntity, primaryOp)
|
|
50
50
|
.filter((it: any) => it.name !== idF && it.name !== 'id')
|
|
51
51
|
const required = items.filter((it: any) => !it.optional)
|
|
52
52
|
const chosen = required.length ? required : items.slice(0, 3)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content, isAuthActive, envName, canonKey, canonScalarKey, opRequestShape, entityIdField, entityDataIdField, entityOps, matchExampleItems, requiredItems } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, Content, isAuthActive, envName, canonKey, canonScalarKey, opRequestShape, entityIdField, entityDataIdField, entityOps, matchExampleItems, requiredItems, requestExampleItems, sendsId } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -154,7 +154,7 @@ else {
|
|
|
154
154
|
// separately as the match key for update/remove; a REQUIRED create id
|
|
155
155
|
// stays (the call is invalid without it).
|
|
156
156
|
const examplePairs = (opname: string): string[] => {
|
|
157
|
-
const items =
|
|
157
|
+
const items = requestExampleItems(exampleEntity, opname)
|
|
158
158
|
.filter((it: any) => (it.name !== idF && it.name !== 'id') ||
|
|
159
159
|
('create' === opname && !it.optional))
|
|
160
160
|
const required = items.filter((it: any) => !it.optional)
|
|
@@ -186,7 +186,7 @@ my $created = $client->${eName}->create({ ${examplePairs('create').join(', ')} }
|
|
|
186
186
|
`)
|
|
187
187
|
}
|
|
188
188
|
if (opnames.includes('update')) {
|
|
189
|
-
const updatePairs = (idF ? [`${perlStringLiteral(idF)} => ${idValueFor('update')}`] : []).concat(examplePairs('update'))
|
|
189
|
+
const updatePairs = (sendsId(exampleEntity, 'update', idF) ? [`${perlStringLiteral(idF)} => ${idValueFor('update')}`] : []).concat(examplePairs('update'))
|
|
190
190
|
const fromCreated = null != dataIdF && opnames.includes('create')
|
|
191
191
|
Content(`# Update${fromCreated ? " — the created entity's record holds its id" : ''}
|
|
192
192
|
$client->${eName}->update({ ${updatePairs.join(', ')} });
|
|
@@ -194,7 +194,7 @@ $client->${eName}->update({ ${updatePairs.join(', ')} });
|
|
|
194
194
|
`)
|
|
195
195
|
}
|
|
196
196
|
if (opnames.includes('patch')) {
|
|
197
|
-
const patchPairs = (idF ? [`${perlStringLiteral(idF)} => ${idValueFor('patch')}`] : []).concat(examplePairs('patch'))
|
|
197
|
+
const patchPairs = (sendsId(exampleEntity, 'patch', idF) ? [`${perlStringLiteral(idF)} => ${idValueFor('patch')}`] : []).concat(examplePairs('patch'))
|
|
198
198
|
Content(`# Patch — sends only the fields given
|
|
199
199
|
$client->${eName}->patch({ ${patchPairs.join(', ')} });
|
|
200
200
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, each, Content, canonKey, canonScalarKey, File, isAuthActive, entityIdField
|
|
2
|
+
import { cmp, each, Content, canonKey, canonScalarKey, File, isAuthActive, entityIdField , targetFeatures, opNeedsAction, bodyNote, entityClassName, entityCollection, matchExampleItems, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
import { ReadmeRefFeatures } from '@voxgig/sdkgen'
|
|
4
4
|
|
|
5
5
|
import {
|
|
@@ -297,7 +297,7 @@ for my $${eVar} (@$results) {
|
|
|
297
297
|
`)
|
|
298
298
|
}
|
|
299
299
|
else if ('create' === opname) {
|
|
300
|
-
const createItems =
|
|
300
|
+
const createItems = requestExampleItems(ent, 'create')
|
|
301
301
|
.filter((it: any) => !it.optional)
|
|
302
302
|
Content(`\`\`\`perl
|
|
303
303
|
my $result = $client->${ent.Name}->create({
|
|
@@ -312,7 +312,7 @@ my $result = $client->${ent.Name}->create({
|
|
|
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,
|
|
@@ -48,7 +48,7 @@ my $client = ${ctor};
|
|
|
48
48
|
if (exampleEntity) {
|
|
49
49
|
const eName = nom(exampleEntity, 'Name')
|
|
50
50
|
const eVar = eName.toLowerCase()
|
|
51
|
-
const opnames =
|
|
51
|
+
const opnames = entityOps(exampleEntity)
|
|
52
52
|
const idF = entityIdField(exampleEntity)
|
|
53
53
|
|
|
54
54
|
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,
|
|
@@ -55,7 +55,7 @@ my $client = ${model.const.Name}SDK->test(undef, undef);
|
|
|
55
55
|
`${perlStringLiteral(it.name)} => ${isMatchOp && it.name === idF ? "'test01'" : perlLit(it.type)}`).join(', ')} }`
|
|
56
56
|
: ''
|
|
57
57
|
} else if ('create' === primaryOp || 'update' === primaryOp || 'patch' === primaryOp) {
|
|
58
|
-
const items =
|
|
58
|
+
const items = requestExampleItems(exampleEntity, primaryOp)
|
|
59
59
|
.filter((it: any) => it.name !== idF && it.name !== 'id')
|
|
60
60
|
const required = items.filter((it: any) => !it.optional)
|
|
61
61
|
const chosen = required.length ? required : items.slice(0, 3)
|
|
@@ -15,16 +15,34 @@ 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 { perlStringLiteral } from './utility_perl'
|
|
25
30
|
|
|
26
31
|
|
|
27
32
|
// Blocked without the ids its request needs, rather than sent with undef.
|
|
33
|
+
// A GET-only live run excludes a test needing an id that only a write gives.
|
|
34
|
+
function getOnlyKeysBlock(model: any, entity: any, label: string, block: string, keys: string[]): string {
|
|
35
|
+
return liveDirectGetOnly(model, entity, label, keys).map((miss) =>
|
|
36
|
+
` if ($setup->{live} && ($ENV{${LIVE_GETONLY_ENV}} // '') eq 'TRUE' && !defined $setup->{idmap}{${perlStringLiteral(miss.key)}}) {
|
|
37
|
+
note(${perlStringLiteral(liveExcludedLines({ excluded: [miss] })[0])});
|
|
38
|
+
note(${perlStringLiteral(liveExcludedSummary({ excluded: [miss] }))});
|
|
39
|
+
pass('${label}: skipped, a GET-only live run excludes it');
|
|
40
|
+
last ${block};
|
|
41
|
+
}
|
|
42
|
+
`).join('')
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
28
46
|
function liveKeysBlock(N: string, label: string, block: string, keys: string[],
|
|
29
47
|
entidEnvVar: string): string {
|
|
30
48
|
return 0 === keys.length ? '' : ` if ($setup->{live}) {
|
|
@@ -90,7 +108,7 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
90
108
|
const ctx$ = props.ctx$
|
|
91
109
|
const model: Model = ctx$.model
|
|
92
110
|
|
|
93
|
-
const entity: ModelEntity = props.entity
|
|
111
|
+
const entity: ModelEntity = liveEntity(ctx$, props.entity)
|
|
94
112
|
const target = props.target
|
|
95
113
|
|
|
96
114
|
const N = model.const.Name
|
|
@@ -133,12 +151,7 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
133
151
|
const allLoadParams = loadPoint?.g?.params || []
|
|
134
152
|
// Only path params that actually appear in the URL template drive direct-
|
|
135
153
|
// test path-param setup and URL-substitution asserts (see TestDirect_rb).
|
|
136
|
-
const _pathPlaceholders = new Set<string>()
|
|
137
|
-
for (const part of pointParts(loadPoint)) {
|
|
138
|
-
if (typeof part === 'string' && part.startsWith('{') && part.endsWith('}')) {
|
|
139
|
-
_pathPlaceholders.add(part.slice(1, -1))
|
|
140
|
-
}
|
|
141
|
-
}
|
|
154
|
+
const _pathPlaceholders = new Set<string>(pointPlaceholders(loadPoint))
|
|
142
155
|
const _renameMap = (loadPoint?.r?.param || {}) as Record<string, string>
|
|
143
156
|
const _renamedPlaceholders = new Set<string>()
|
|
144
157
|
for (const ph of _pathPlaceholders) {
|
|
@@ -155,11 +168,8 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
155
168
|
const listParams = listPoint?.g?.params || []
|
|
156
169
|
|
|
157
170
|
// Required query params with spec-provided examples - needed in live mode.
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
.filter((q: any) => q.r && undefined !== q.ex && null !== q.ex)
|
|
161
|
-
const loadLiveQueryLines = loadLiveQueryEntries
|
|
162
|
-
.map((q: any) => ` $query->{'${q.n}'} = ${perlScalar(q.ex)};`)
|
|
171
|
+
const loadLiveQueryLines = liveQueryExamples(loadPoint)
|
|
172
|
+
.map(([name, ex]) => ` $query->{'${name}'} = ${perlScalar(ex)};`)
|
|
163
173
|
.join('\n')
|
|
164
174
|
|
|
165
175
|
const loadAllHaveExamples =
|
|
@@ -171,6 +181,10 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
171
181
|
|
|
172
182
|
const entidEnvVar = `${PROJECTNAME}_TEST_${envToken(entity.name)}_ENTID`
|
|
173
183
|
|
|
184
|
+
const exampleIds = liveExampleIds(entity)
|
|
185
|
+
const listLiveQueryLines = liveQueryExamples(listPoint)
|
|
186
|
+
.map(([name, ex]) => ` $query->{'${name}'} = ${perlScalar(ex)};\n`).join('')
|
|
187
|
+
|
|
174
188
|
// The *_ENTID key a live test reads a parameter's value from.
|
|
175
189
|
const liveKey = (param: any): string =>
|
|
176
190
|
('id' === param.n ? entity.name : param.n.replace(/_id$/, '')) + '01'
|
|
@@ -222,10 +236,11 @@ sub live_ok {
|
|
|
222
236
|
pass('${label}: skipped via sdk-test-control.json');
|
|
223
237
|
last DIRECT_LIST;
|
|
224
238
|
}
|
|
225
|
-
${liveKeysBlock(N, label, 'DIRECT_LIST', listParams.map(liveKey), entidEnvVar)} my $client = $setup->{client};
|
|
239
|
+
${getOnlyKeysBlock(model, entity, label, 'DIRECT_LIST', listParams.map(liveKey))}${liveKeysBlock(N, label, 'DIRECT_LIST', listParams.map(liveKey), entidEnvVar)} my $client = $setup->{client};
|
|
226
240
|
|
|
227
241
|
my $params = {};
|
|
228
|
-
|
|
242
|
+
my $query = {};
|
|
243
|
+
${listLiveQueryLines ? ' if ($setup->{live}) {\n' + listLiveQueryLines + ' }\n' : ''}`)
|
|
229
244
|
listParams.forEach((lp: any, i: number) => {
|
|
230
245
|
Content(` $params->{'${lp.n}'} = $setup->{live} ? $setup->{idmap}{'${liveKey(lp)}'} : 'direct0${i + 1}';
|
|
231
246
|
`)
|
|
@@ -235,6 +250,7 @@ ${liveKeysBlock(N, label, 'DIRECT_LIST', listParams.map(liveKey), entidEnvVar)}
|
|
|
235
250
|
'path' => '${listPath}',
|
|
236
251
|
'method' => 'GET',
|
|
237
252
|
'params' => $params,
|
|
253
|
+
'query' => $query,
|
|
238
254
|
});
|
|
239
255
|
if ($setup->{live}) {
|
|
240
256
|
if (!live_ok($result)) {
|
|
@@ -283,7 +299,7 @@ ${liveKeysBlock(N, label, 'DIRECT_LIST', listParams.map(liveKey), entidEnvVar)}
|
|
|
283
299
|
pass('${label}: skipped via sdk-test-control.json');
|
|
284
300
|
last DIRECT_LOAD;
|
|
285
301
|
}
|
|
286
|
-
${liveKeysBlock(N, label, 'DIRECT_LOAD', [...new Set(loadLiveIdKeys)], entidEnvVar)} my $client = $setup->{client};
|
|
302
|
+
${getOnlyKeysBlock(model, entity, label, 'DIRECT_LOAD', [...new Set(loadLiveIdKeys)])}${liveKeysBlock(N, label, 'DIRECT_LOAD', [...new Set(loadLiveIdKeys)], entidEnvVar)} my $client = $setup->{client};
|
|
287
303
|
|
|
288
304
|
my $params = {};
|
|
289
305
|
my $query = {};
|
|
@@ -393,7 +409,10 @@ sub ${entity.name}_direct_setup {
|
|
|
393
409
|
%{ ${N}TestRunner::live_client_options() },${apikeyLiveField}${serverLiveField}
|
|
394
410
|
});
|
|
395
411
|
my $idmap = $env->{'${entidEnvVar}'};
|
|
396
|
-
|
|
412
|
+
${0 === exampleIds.length ? '' : ` # A path parameter's example stands in for an id *_ENTID does not give.
|
|
413
|
+
$idmap = { ${exampleIds.map(([key, ex]) => `'${key}' => ${perlScalar(ex)}`).join(', ')},
|
|
414
|
+
%{ ref $idmap eq 'HASH' ? $idmap : {} } };
|
|
415
|
+
`} return {
|
|
397
416
|
'client' => $client,
|
|
398
417
|
'calls' => $calls,
|
|
399
418
|
'live' => 1,
|