@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
|
@@ -89,7 +89,7 @@ Spec* prepare_auth_util(Context* ctx, PNError** err) {
|
|
|
89
89
|
|
|
90
90
|
const bag = bagName(spec.where)
|
|
91
91
|
|
|
92
|
-
const
|
|
92
|
+
const preamble = (joins: boolean) => `// prepare_auth utility (mirrors utility/prepare_auth.rs).
|
|
93
93
|
//
|
|
94
94
|
// GENERATED, not templated: where the credential goes - header, query or
|
|
95
95
|
// cookie, and under what name - is a fact about THIS API, and tm/ can only
|
|
@@ -97,7 +97,7 @@ Spec* prepare_auth_util(Context* ctx, PNError** err) {
|
|
|
97
97
|
|
|
98
98
|
#include "sdk.h"
|
|
99
99
|
|
|
100
|
-
${
|
|
100
|
+
${joins ? `#include <stdio.h>
|
|
101
101
|
` : ''}#include <stdlib.h>
|
|
102
102
|
#include <string.h>
|
|
103
103
|
|
|
@@ -131,7 +131,9 @@ static const char* auth_name(voxgig_value* options) {
|
|
|
131
131
|
const char* name = voxgig_is_string(v) ? voxgig_as_string(v) : NULL;
|
|
132
132
|
return (NULL == name || '\\0' == name[0]) ? CRED_NAME : name;
|
|
133
133
|
}`}
|
|
134
|
-
${
|
|
134
|
+
${joins ? JOIN_HELPER : ''}${cookie ? COOKIE_HELPER : ''}`
|
|
135
|
+
|
|
136
|
+
const head = `
|
|
135
137
|
// Places or clears the credential under name, the one in effect.
|
|
136
138
|
static Spec* prepare_auth_as(Context* ctx, Spec* spec, voxgig_value* ${bag},
|
|
137
139
|
voxgig_value* options,${withBasic ? ' voxgig_value* auth,' : ''} const char* name,
|
|
@@ -207,7 +209,7 @@ ${setHeader('b64', 6)}
|
|
|
207
209
|
}
|
|
208
210
|
`
|
|
209
211
|
|
|
210
|
-
|
|
212
|
+
const body = head + basicBlock + `
|
|
211
213
|
if (skip) {
|
|
212
214
|
${clear(spec.where, 'name', 4)}
|
|
213
215
|
} else {
|
|
@@ -247,6 +249,10 @@ ${header ? `
|
|
|
247
249
|
return prepare_auth_as(ctx, spec, ${bag}, options, auth_name(options), err);`}
|
|
248
250
|
}
|
|
249
251
|
`
|
|
252
|
+
|
|
253
|
+
// Any placement but query and cookie takes the header branch, which joins
|
|
254
|
+
// a prefix, so the helper goes with its callers rather than with `header`.
|
|
255
|
+
return preamble(/\bauth_join\(/.test(body)) + body
|
|
250
256
|
}
|
|
251
257
|
|
|
252
258
|
|
|
@@ -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,
|
|
@@ -167,7 +167,7 @@ for (size_t i = 0; ${evar}s && ${evar}s[i]; i++) {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
if (callable.includes('create')) {
|
|
170
|
-
const createItems =
|
|
170
|
+
const createItems = requestExampleItems(entity, 'create')
|
|
171
171
|
.filter((it: any) => !it.optional)
|
|
172
172
|
Content(`#### Example: Create
|
|
173
173
|
|
|
@@ -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, targetFeatures, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -85,7 +85,7 @@ const ReadmeHowto = cmp(function ReadmeHowto(props: any) {
|
|
|
85
85
|
const chosen = requiredItems(exampleEntity, 'list')
|
|
86
86
|
testArg = cmapExpr(chosen.map((it: any) => `${cString(it.name)}, ${cLit(it.type)}`))
|
|
87
87
|
} else if (exampleEntity && ('create' === primaryOp || 'update' === primaryOp || 'patch' === primaryOp)) {
|
|
88
|
-
const items =
|
|
88
|
+
const items = requestExampleItems(exampleEntity, primaryOp)
|
|
89
89
|
.filter((it: any) => it.name !== idF && it.name !== 'id')
|
|
90
90
|
const required = items.filter((it: any) => !it.optional)
|
|
91
91
|
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,
|
|
@@ -159,7 +159,7 @@ if (err) {
|
|
|
159
159
|
// Model-driven example fields: derive the create/update body from the op
|
|
160
160
|
// shape so the docs reference REAL writable fields.
|
|
161
161
|
const examplePairs = (opname: string): string[] => {
|
|
162
|
-
const items =
|
|
162
|
+
const items = requestExampleItems(exampleEntity, opname)
|
|
163
163
|
.filter((it: any) => (it.name !== idF && it.name !== 'id') ||
|
|
164
164
|
('create' === opname && !it.optional))
|
|
165
165
|
const required = items.filter((it: any) => !it.optional)
|
|
@@ -192,7 +192,8 @@ if (err) {
|
|
|
192
192
|
\`\`\`c
|
|
193
193
|
${acquire}`)
|
|
194
194
|
if (opnames.includes('create')) {
|
|
195
|
-
const idLine = readsId &&
|
|
195
|
+
const idLine = readsId && ['update', 'patch', 'remove'].some((op: string) =>
|
|
196
|
+
opnames.includes(op) && sendsId(exampleEntity, op, idF))
|
|
196
197
|
? `voxgig_value* created_id = created
|
|
197
198
|
? getp(created->vt->data(created, NULL), ${cString(dataIdF)}) : v_undef();
|
|
198
199
|
`
|
|
@@ -203,14 +204,14 @@ ${idLine}
|
|
|
203
204
|
`)
|
|
204
205
|
}
|
|
205
206
|
if (opnames.includes('update')) {
|
|
206
|
-
const updatePairs = (idF ? [`${cString(idF)}, ${idValueFor('update')}`] : []).concat(examplePairs('update'))
|
|
207
|
+
const updatePairs = (sendsId(exampleEntity, 'update', idF) ? [`${cString(idF)}, ${idValueFor('update')}`] : []).concat(examplePairs('update'))
|
|
207
208
|
Content(`// Update
|
|
208
209
|
${evar}->vt->update(${evar}, ${cmapExpr(updatePairs)}, NULL, &err);
|
|
209
210
|
|
|
210
211
|
`)
|
|
211
212
|
}
|
|
212
213
|
if (opnames.includes('patch')) {
|
|
213
|
-
const patchPairs = (idF ? [`${cString(idF)}, ${idValueFor('patch')}`] : []).concat(examplePairs('patch'))
|
|
214
|
+
const patchPairs = (sendsId(exampleEntity, 'patch', idF) ? [`${cString(idF)}, ${idValueFor('patch')}`] : []).concat(examplePairs('patch'))
|
|
214
215
|
Content(`// Patch — sends only the fields given
|
|
215
216
|
${evar}->vt->patch(${evar}, ${cmapExpr(patchPairs)}, NULL, &err);
|
|
216
217
|
|
|
@@ -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 {
|
|
@@ -298,7 +298,7 @@ for (size_t i = 0; results && results[i]; i++) {
|
|
|
298
298
|
`)
|
|
299
299
|
}
|
|
300
300
|
else if ('create' === opname) {
|
|
301
|
-
const createItems =
|
|
301
|
+
const createItems = requestExampleItems(ent, 'create')
|
|
302
302
|
.filter((it: any) => !it.optional)
|
|
303
303
|
Content(`\`\`\`c
|
|
304
304
|
Entity* ${evar} = ${acc}(client, NULL);
|
|
@@ -322,7 +322,7 @@ Entity* ${evar} = ${acc}(client, NULL);
|
|
|
322
322
|
`)
|
|
323
323
|
}
|
|
324
324
|
else if ('update' === opname || 'patch' === opname) {
|
|
325
|
-
const updateItems =
|
|
325
|
+
const updateItems = requestExampleItems(ent, opname)
|
|
326
326
|
.filter((it: any) => !it.optional || it.name === idF)
|
|
327
327
|
.sort((a: any, b: any) =>
|
|
328
328
|
(a.name === idF ? 0 : 1) - (b.name === idF ? 0 : 1))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content, 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,
|
|
@@ -54,7 +54,7 @@ PNError* err = NULL;
|
|
|
54
54
|
const eName = nom(exampleEntity, 'Name')
|
|
55
55
|
const evar = cVarName(exampleEntity.name)
|
|
56
56
|
const acc = `${ident}_${evar}`
|
|
57
|
-
const opnames =
|
|
57
|
+
const opnames = entityOps(exampleEntity)
|
|
58
58
|
// Model-driven id key: null when the entity has no id-like field, in which
|
|
59
59
|
// case the load example takes no match argument.
|
|
60
60
|
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, requiredItems, matchExampleItems, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -62,7 +62,7 @@ PNError* err = NULL;
|
|
|
62
62
|
arg = cmapExpr(items.map((it: any) =>
|
|
63
63
|
`${cString(it.name)}, ${isMatchOp && it.name === idF ? 'v_str("test01")' : cLit(it.type)}`))
|
|
64
64
|
} else if ('create' === primaryOp || 'update' === primaryOp || 'patch' === primaryOp) {
|
|
65
|
-
const items =
|
|
65
|
+
const items = requestExampleItems(exampleEntity, primaryOp)
|
|
66
66
|
.filter((it: any) => it.name !== idF && it.name !== 'id')
|
|
67
67
|
const required = items.filter((it: any) => !it.optional)
|
|
68
68
|
const chosen = required.length ? required : items.slice(0, 3)
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
cmp,
|
|
13
13
|
snakify,
|
|
14
14
|
pointParts,
|
|
15
|
+
pointPlaceholders,
|
|
15
16
|
pointIsGraphql,
|
|
16
17
|
graphqlDirectSkip,
|
|
17
18
|
} from '@voxgig/sdkgen'
|
|
@@ -80,12 +81,7 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
80
81
|
const loadPoint = loadOp?.points?.[0]
|
|
81
82
|
const loadPath = loadPoint ? normalizePathParams(pointParts(loadPoint), loadPoint?.g?.params || [], loadPoint?.r?.param) : ''
|
|
82
83
|
const allLoadParams = loadPoint?.g?.params || []
|
|
83
|
-
const _pathPlaceholders = new Set<string>()
|
|
84
|
-
for (const part of pointParts(loadPoint)) {
|
|
85
|
-
if (typeof part === 'string' && part.startsWith('{') && part.endsWith('}')) {
|
|
86
|
-
_pathPlaceholders.add(part.slice(1, -1))
|
|
87
|
-
}
|
|
88
|
-
}
|
|
84
|
+
const _pathPlaceholders = new Set<string>(pointPlaceholders(loadPoint))
|
|
89
85
|
const _renameMap = (loadPoint?.r?.param || {}) as Record<string, string>
|
|
90
86
|
const _renamedPlaceholders = new Set<string>()
|
|
91
87
|
for (const ph of _pathPlaceholders) {
|
|
@@ -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,
|
|
@@ -159,7 +159,7 @@ const ReadmeEntity = cmp(function ReadmeEntity(props: any) {
|
|
|
159
159
|
if (callable.includes('create')) {
|
|
160
160
|
// Members come from the SAME shape the runtime validates
|
|
161
161
|
// (opRequestShape): every required member must appear.
|
|
162
|
-
const createItems =
|
|
162
|
+
const createItems = requestExampleItems(entity, 'create')
|
|
163
163
|
.filter((it: any) => !it.optional)
|
|
164
164
|
Content(`#### Example: Create
|
|
165
165
|
|
|
@@ -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,
|
|
@@ -43,7 +43,7 @@ const ReadmeHowto = cmp(function ReadmeHowto(props: any) {
|
|
|
43
43
|
const chosen = requiredItems(exampleEntity, 'list')
|
|
44
44
|
testArg = `(vs/jm ${chosen.map((it: any) => `${cljString(it.name)} ${cljLit(it.type)}`).join(' ')})`
|
|
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, each, Content, isAuthActive, envName, canonKey, canonScalarKey, opRequestShape, entityIdField, entityDataIdField, entityOps, matchExampleItems, requiredItems } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, each, Content, isAuthActive, envName, canonKey, canonScalarKey, opRequestShape, entityIdField, entityDataIdField, entityOps, matchExampleItems, requiredItems, requestExampleItems, sendsId } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -150,7 +150,7 @@ its record.
|
|
|
150
150
|
|
|
151
151
|
// Model-driven example fields from the op shape (opRequestShape).
|
|
152
152
|
const examplePairs = (opname: string): string[] => {
|
|
153
|
-
const items =
|
|
153
|
+
const items = requestExampleItems(exampleEntity, opname)
|
|
154
154
|
.filter((it: any) => (it.name !== idF && it.name !== 'id') ||
|
|
155
155
|
('create' === opname && !it.optional))
|
|
156
156
|
const required = items.filter((it: any) => !it.optional)
|
|
@@ -182,7 +182,7 @@ its record.
|
|
|
182
182
|
`)
|
|
183
183
|
}
|
|
184
184
|
if (opnames.includes('update')) {
|
|
185
|
-
const updatePairs = (idF ? [`${cljString(idF)} ${idValueFor('update')}`] : []).concat(examplePairs('update'))
|
|
185
|
+
const updatePairs = (sendsId(exampleEntity, 'update', idF) ? [`${cljString(idF)} ${idValueFor('update')}`] : []).concat(examplePairs('update'))
|
|
186
186
|
const fromCreated = null != dataIdF && opnames.includes('create')
|
|
187
187
|
Content(`;; Update${fromCreated ? " — the created entity's record holds its id" : ''}
|
|
188
188
|
(e-${eLow}/update (api/${eLow} client nil) (vs/jm ${updatePairs.join(' ')}) nil)
|
|
@@ -190,7 +190,7 @@ its record.
|
|
|
190
190
|
`)
|
|
191
191
|
}
|
|
192
192
|
if (opnames.includes('patch')) {
|
|
193
|
-
const patchPairs = (idF ? [`${cljString(idF)} ${idValueFor('patch')}`] : []).concat(examplePairs('patch'))
|
|
193
|
+
const patchPairs = (sendsId(exampleEntity, 'patch', idF) ? [`${cljString(idF)} ${idValueFor('patch')}`] : []).concat(examplePairs('patch'))
|
|
194
194
|
Content(`;; Patch — sends only the fields given
|
|
195
195
|
(e-${eLow}/patch (api/${eLow} client nil) (vs/jm ${patchPairs.join(' ')}) nil)
|
|
196
196
|
|
|
@@ -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 {
|
|
@@ -298,7 +298,7 @@ ${info.desc}
|
|
|
298
298
|
`)
|
|
299
299
|
}
|
|
300
300
|
else if ('create' === opname) {
|
|
301
|
-
const createItems =
|
|
301
|
+
const createItems = requestExampleItems(ent, 'create')
|
|
302
302
|
.filter((it: any) => !it.optional)
|
|
303
303
|
Content(`\`\`\`clojure
|
|
304
304
|
(def result
|
|
@@ -316,7 +316,7 @@ ${info.desc}
|
|
|
316
316
|
`)
|
|
317
317
|
}
|
|
318
318
|
else if ('update' === opname || 'patch' === opname) {
|
|
319
|
-
const updateItems =
|
|
319
|
+
const updateItems = requestExampleItems(ent, opname)
|
|
320
320
|
.filter((it: any) => !it.optional || it.name === idF)
|
|
321
321
|
.sort((a: any, b: any) =>
|
|
322
322
|
(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 @@ const ReadmeTopQuick = cmp(function ReadmeTopQuick(props: any) {
|
|
|
48
48
|
|
|
49
49
|
`)
|
|
50
50
|
|
|
51
|
-
const opnames =
|
|
51
|
+
const opnames = entityOps(exampleEntity)
|
|
52
52
|
// Model-driven id key: null when the entity has no id-like field, in which
|
|
53
53
|
// case the load example takes no match argument.
|
|
54
54
|
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, requiredItems, matchExampleItems, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -57,7 +57,7 @@ const ReadmeTopTest = cmp(function ReadmeTopTest(props: any) {
|
|
|
57
57
|
`${cljString(it.name)} ${isMatchOp && it.name === idF ? '"test01"' : cljLit(it.type)}`).join(' ')})`
|
|
58
58
|
: 'nil'
|
|
59
59
|
} else if ('create' === primaryOp || 'update' === primaryOp || 'patch' === primaryOp) {
|
|
60
|
-
const items =
|
|
60
|
+
const items = requestExampleItems(exampleEntity, primaryOp)
|
|
61
61
|
.filter((it: any) => it.name !== idF && it.name !== 'id')
|
|
62
62
|
const required = items.filter((it: any) => !it.optional)
|
|
63
63
|
const chosen = required.length ? required : items.slice(0, 3)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, each, Content, canonToType, canonKey, canonScalarKey, entityIdField,
|
|
2
|
+
import { cmp, each, Content, canonToType, canonKey, canonScalarKey, entityIdField, opNeedsAction, matchExampleItems, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -152,7 +152,7 @@ for (const auto& ${eVar} : ${eVar}s) {
|
|
|
152
152
|
if (callable.includes('create')) {
|
|
153
153
|
// Members come from the SAME shape the runtime validates
|
|
154
154
|
// (opRequestShape): every required member must appear.
|
|
155
|
-
const createItems =
|
|
155
|
+
const createItems = requestExampleItems(entity, 'create')
|
|
156
156
|
.filter((it: any) => !it.optional)
|
|
157
157
|
Content(`#### Example: Create
|
|
158
158
|
|
|
@@ -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,
|
|
@@ -45,7 +45,7 @@ const ReadmeHowto = cmp(function ReadmeHowto(props: any) {
|
|
|
45
45
|
const chosen = requiredItems(exampleEntity, 'list')
|
|
46
46
|
testArg = `vmap({${chosen.map((it: any) => `{"${cppEscape(it.name)}", ${cppLit(it.type)}}`).join(', ')}})`
|
|
47
47
|
} else if (exampleEntity && ('create' === primaryOp || 'update' === primaryOp || 'patch' === primaryOp)) {
|
|
48
|
-
const items =
|
|
48
|
+
const items = requestExampleItems(exampleEntity, primaryOp)
|
|
49
49
|
.filter((it: any) => it.name !== idF && it.name !== 'id')
|
|
50
50
|
const required = items.filter((it: any) => !it.optional)
|
|
51
51
|
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,
|
|
@@ -160,7 +160,7 @@ try {
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
const examplePairs = (opname: string): string[] => {
|
|
163
|
-
const items =
|
|
163
|
+
const items = requestExampleItems(exampleEntity, opname)
|
|
164
164
|
.filter((it: any) => (it.name !== idF && it.name !== 'id') ||
|
|
165
165
|
('create' === opname && !it.optional))
|
|
166
166
|
const required = items.filter((it: any) => !it.optional)
|
|
@@ -195,7 +195,7 @@ SdkEntityPtr created = client->${acc}()->create(vmap({${examplePairs('create').j
|
|
|
195
195
|
`)
|
|
196
196
|
}
|
|
197
197
|
if (opnames.includes('update')) {
|
|
198
|
-
const updatePairs = (idF ? [`{"${cppEscape(idF)}", ${idValueFor('update')}}`] : []).concat(examplePairs('update'))
|
|
198
|
+
const updatePairs = (sendsId(exampleEntity, 'update', idF) ? [`{"${cppEscape(idF)}", ${idValueFor('update')}}`] : []).concat(examplePairs('update'))
|
|
199
199
|
const fromCreated = null != dataIdF && opnames.includes('create')
|
|
200
200
|
Content(`// Update${fromCreated ? " — reuse the created record's id" : ''}
|
|
201
201
|
client->${acc}()->update(vmap({${updatePairs.join(', ')}}), Value::undef());
|
|
@@ -203,7 +203,7 @@ client->${acc}()->update(vmap({${updatePairs.join(', ')}}), Value::undef());
|
|
|
203
203
|
`)
|
|
204
204
|
}
|
|
205
205
|
if (opnames.includes('patch')) {
|
|
206
|
-
const patchPairs = (idF ? [`{"${cppEscape(idF)}", ${idValueFor('patch')}}`] : []).concat(examplePairs('patch'))
|
|
206
|
+
const patchPairs = (sendsId(exampleEntity, 'patch', idF) ? [`{"${cppEscape(idF)}", ${idValueFor('patch')}}`] : []).concat(examplePairs('patch'))
|
|
207
207
|
Content(`// Patch — sends only the fields given
|
|
208
208
|
client->${acc}()->patch(vmap({${patchPairs.join(', ')}}), Value::undef());
|
|
209
209
|
|
|
@@ -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 {
|
|
@@ -292,7 +292,7 @@ for (const auto& ${acc} : results) {
|
|
|
292
292
|
`)
|
|
293
293
|
}
|
|
294
294
|
else if ('create' === opname) {
|
|
295
|
-
const createItems =
|
|
295
|
+
const createItems = requestExampleItems(ent, 'create')
|
|
296
296
|
.filter((it: any) => !it.optional)
|
|
297
297
|
Content(`\`\`\`cpp
|
|
298
298
|
SdkEntityPtr result = client->${acc}()->create(vmap({
|
|
@@ -307,7 +307,7 @@ SdkEntityPtr result = client->${acc}()->create(vmap({
|
|
|
307
307
|
`)
|
|
308
308
|
}
|
|
309
309
|
else if ('update' === opname || 'patch' === opname) {
|
|
310
|
-
const updateItems =
|
|
310
|
+
const updateItems = requestExampleItems(ent, opname)
|
|
311
311
|
.filter((it: any) => !it.optional || it.name === idF)
|
|
312
312
|
.sort((a: any, b: any) =>
|
|
313
313
|
(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,
|
|
@@ -53,7 +53,7 @@ ${ctor}
|
|
|
53
53
|
if (exampleEntity) {
|
|
54
54
|
const acc = cppVarName(exampleEntity.name)
|
|
55
55
|
const eVar = acc
|
|
56
|
-
const opnames =
|
|
56
|
+
const opnames = entityOps(exampleEntity)
|
|
57
57
|
// Model-driven id key: null when the entity has no id-like field.
|
|
58
58
|
const idF = entityIdField(exampleEntity)
|
|
59
59
|
|
|
@@ -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,
|
|
@@ -47,7 +47,7 @@ auto client = ${model.const.Name}SDK::testSDK();
|
|
|
47
47
|
`{"${cppEscape(it.name)}", ${isMatchOp && it.name === idF ? 'Value("test01")' : cppLit(it.type)}}`).join(', ')}})`
|
|
48
48
|
: 'Value::undef()'
|
|
49
49
|
} else if ('create' === primaryOp || 'update' === primaryOp || 'patch' === primaryOp) {
|
|
50
|
-
const items =
|
|
50
|
+
const items = requestExampleItems(exampleEntity, primaryOp)
|
|
51
51
|
.filter((it: any) => it.name !== idF && it.name !== 'id')
|
|
52
52
|
const required = items.filter((it: any) => !it.optional)
|
|
53
53
|
const chosen = required.length ? required : items.slice(0, 3)
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
cmp,
|
|
13
13
|
snakify,
|
|
14
14
|
pointParts,
|
|
15
|
+
pointPlaceholders,
|
|
15
16
|
pointIsGraphql,
|
|
16
17
|
graphqlDirectSkip,
|
|
17
18
|
} from '@voxgig/sdkgen'
|
|
@@ -76,12 +77,7 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
76
77
|
const loadPoint = loadOp?.points?.[0]
|
|
77
78
|
const loadPath = loadPoint ? normalizePathParams(pointParts(loadPoint), loadPoint?.g?.params || [], loadPoint?.r?.param) : ''
|
|
78
79
|
const allLoadParams = loadPoint?.g?.params || []
|
|
79
|
-
const _pathPlaceholders = new Set<string>()
|
|
80
|
-
for (const part of pointParts(loadPoint)) {
|
|
81
|
-
if (typeof part === 'string' && part.startsWith('{') && part.endsWith('}')) {
|
|
82
|
-
_pathPlaceholders.add(part.slice(1, -1))
|
|
83
|
-
}
|
|
84
|
-
}
|
|
80
|
+
const _pathPlaceholders = new Set<string>(pointPlaceholders(loadPoint))
|
|
85
81
|
const _renameMap = (loadPoint?.r?.param || {}) as Record<string, string>
|
|
86
82
|
const _renamedPlaceholders = new Set<string>()
|
|
87
83
|
for (const ph of _pathPlaceholders) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { flowSteps, invalidRequest, opReachable } from '@voxgig/sdkgen'
|
|
1
|
+
import { flowSteps, invalidRequest, opReachable, flowLoadRoute, flowLoadReadsRecord } from '@voxgig/sdkgen'
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
KIT,
|
|
@@ -536,23 +536,35 @@ const generateLoad: OpGen = (ctx, step: any, index) => {
|
|
|
536
536
|
const hasEntVar = priorSteps.some((s: any) =>
|
|
537
537
|
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
538
538
|
const hasEntId = null != entity.id
|
|
539
|
+
const created = (s: any) => cppVarName(s.i?.datavar ?? ((s.i?.ref ?? entity.name + '_ref01') + '_data' + (s.i?.suffix ?? '')))
|
|
540
|
+
const hasSrcData = priorSteps.some((s: any) => 'create' === s.o && created(s) === srcdatavar) ||
|
|
541
|
+
(!Object.values(flowSteps(flow)).some((s: any) => 'create' === s.o) &&
|
|
542
|
+
srcdatavar === cppVarName(entity.name + '_ref01') + '_data')
|
|
539
543
|
|
|
540
544
|
Content(` // LOAD
|
|
541
545
|
`)
|
|
542
546
|
if (!hasEntVar) {
|
|
543
547
|
Content(` auto ${entvar} = client->${cppVarName(entity.name)}();
|
|
548
|
+
`)
|
|
549
|
+
}
|
|
550
|
+
if (!hasEntId && !hasSrcData && flowLoadReadsRecord(entity, step)) {
|
|
551
|
+
Content(` Value ${srcdatavar} = vmap();
|
|
552
|
+
{
|
|
553
|
+
std::vector<Value> its = Struct::items(Helpers::toMapAny(Struct::getpath(setup.data, {"existing", "${entity.name}"})));
|
|
554
|
+
${srcdatavar} = its.empty() ? vmap() : Helpers::toMapAny(pair_val(its[0]));
|
|
555
|
+
}
|
|
544
556
|
`)
|
|
545
557
|
}
|
|
546
558
|
if (hasEntId) {
|
|
547
559
|
Content(` Value ${matchvar} = vmap({{"id", getp(${srcdatavar}, "id")}});
|
|
548
|
-
${
|
|
560
|
+
${loadMatch(entity, step, matchvar, srcdatavar, ' ')} Value ${datavar}_loaded = ${entvar}->load(Struct::clone(${matchvar}), Value::undef())->data();
|
|
549
561
|
Value ${datavar}_load_result = Helpers::toMapAny(${datavar}_loaded);
|
|
550
562
|
ASSERT_TRUE(${datavar}_load_result.is_map(), "expected load result to be a map");
|
|
551
563
|
ASSERT_EQ_VAL(getp(${datavar}_load_result, "id"), getp(${srcdatavar}, "id"), "expected load result id to match");
|
|
552
564
|
`)
|
|
553
565
|
} else {
|
|
554
566
|
Content(` Value ${matchvar} = vmap();
|
|
555
|
-
${
|
|
567
|
+
${loadMatch(entity, step, matchvar, srcdatavar, ' ')} Value ${datavar}_loaded = ${entvar}->load(${matchvar}, Value::undef())->data();
|
|
556
568
|
ASSERT_TRUE(!${datavar}_loaded.is_undef(), "expected load result to be non-nil");
|
|
557
569
|
`)
|
|
558
570
|
}
|
|
@@ -599,6 +611,42 @@ ${indent}}
|
|
|
599
611
|
}
|
|
600
612
|
|
|
601
613
|
|
|
614
|
+
// A load of a known record fills its route from that record, and from the
|
|
615
|
+
// step's binding where the record holds no scalar for it. A record only the
|
|
616
|
+
// fixture holds replaces the step's binding offline.
|
|
617
|
+
function loadMatch(entity: any, step: any, matchvar: string, srcdatavar: string, indent: string): string {
|
|
618
|
+
const route = flowLoadRoute(entity, step)
|
|
619
|
+
if (null == route) {
|
|
620
|
+
return parentMatch(step, matchvar, indent)
|
|
621
|
+
}
|
|
622
|
+
if (route.offline) {
|
|
623
|
+
const own = route.args.filter((arg) => null != arg.field)
|
|
624
|
+
return parentMatch(step, matchvar, indent) + (0 === own.length ? '' : `${indent}if (!setup.live) {
|
|
625
|
+
${own.map((arg) => `${indent} {
|
|
626
|
+
${indent} Value own = getp(${srcdatavar}, "${arg.field}");
|
|
627
|
+
${indent} if (own.is_string() || own.is_number() || own.is_bool()) setp(${matchvar}, "${arg.name}", own);
|
|
628
|
+
${indent} }
|
|
629
|
+
`).join('')}${indent}}
|
|
630
|
+
`)
|
|
631
|
+
}
|
|
632
|
+
return route.args.map((arg) => {
|
|
633
|
+
const [first, then] = arg.idmap
|
|
634
|
+
const fallback = (inner: string) => null == then ? '' :
|
|
635
|
+
`${inner}if (parent_id.is_undef() || parent_id.is_null()) parent_id = getp(setup.idmap, "${then}");
|
|
636
|
+
`
|
|
637
|
+
return `${indent}{
|
|
638
|
+
${null == arg.field ? `${indent} Value parent_id = getp(setup.idmap, "${first}");
|
|
639
|
+
${fallback(indent + ' ')}` : `${indent} Value parent_id = getp(${srcdatavar}, "${arg.field}");
|
|
640
|
+
${indent} if (!(parent_id.is_string() || parent_id.is_number() || parent_id.is_bool())) {
|
|
641
|
+
${indent} parent_id = getp(setup.idmap, "${first}");
|
|
642
|
+
${fallback(indent + ' ')}${indent} }
|
|
643
|
+
`}${indent} setp(${matchvar}, "${arg.name}", parent_id);
|
|
644
|
+
${indent}}
|
|
645
|
+
`
|
|
646
|
+
}).join('')
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
|
|
602
650
|
const GENERATE_OP: Record<string, OpGen> = {
|
|
603
651
|
create: generateCreate,
|
|
604
652
|
list: generateList,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, each, Content, canonToType, canonKey, canonScalarKey, entityIdField,
|
|
2
|
+
import { cmp, each, Content, canonToType, canonKey, canonScalarKey, entityIdField, opNeedsAction, matchExampleItems, requestExampleItems } from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -150,7 +150,7 @@ var ${eVar}List = client.${entity.Name}().List(${csListMatch(entity)});
|
|
|
150
150
|
// Members come from the SAME shape the runtime validates
|
|
151
151
|
// (opRequestShape): every required member must appear — including a
|
|
152
152
|
// required id and parent keys like page_id — with a real literal.
|
|
153
|
-
const createItems =
|
|
153
|
+
const createItems = requestExampleItems(entity, 'create')
|
|
154
154
|
.filter((it: any) => !it.optional)
|
|
155
155
|
Content(`#### Example: Create
|
|
156
156
|
|
|
@@ -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,
|
|
@@ -50,7 +50,7 @@ const ReadmeHowto = cmp(function ReadmeHowto(props: any) {
|
|
|
50
50
|
testArg = `new Dictionary<string, object?> {${chosen.map((it: any) =>
|
|
51
51
|
` [${csStringLiteral(it.name)}] = ${csLit(it.type)}`).join(',')} }`
|
|
52
52
|
} else if (exampleEntity && ('create' === primaryOp || 'update' === primaryOp || 'patch' === primaryOp)) {
|
|
53
|
-
const items =
|
|
53
|
+
const items = requestExampleItems(exampleEntity, primaryOp)
|
|
54
54
|
.filter((it: any) => it.name !== idF && it.name !== 'id')
|
|
55
55
|
const required = items.filter((it: any) => !it.optional)
|
|
56
56
|
const chosen = required.length ? required : items.slice(0, 3)
|