@voxgig/sdkgen 4.5.3 → 4.7.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/action/check.js +15 -0
- package/dist/action/check.js.map +1 -1
- package/dist/cmp/AgentGuide.js +1 -1
- package/dist/cmp/AgentGuide.js.map +1 -1
- package/dist/cmp/AgentGuideContent.d.ts +1 -1
- package/dist/cmp/AgentGuideContent.js +8 -2
- package/dist/cmp/AgentGuideContent.js.map +1 -1
- package/dist/cmp/Feature.js +22 -0
- package/dist/cmp/Feature.js.map +1 -1
- package/dist/cmp/FeatureDocs.d.ts +1 -1
- package/dist/cmp/FeatureDocs.js +6 -1
- package/dist/cmp/FeatureDocs.js.map +1 -1
- package/dist/cmp/ReadmeExplanation.js +3 -1
- package/dist/cmp/ReadmeExplanation.js.map +1 -1
- package/dist/cmp/ReadmeFeatures.js +1 -1
- package/dist/cmp/ReadmeFeatures.js.map +1 -1
- package/dist/cmp/ReadmeRefFeatures.js +1 -1
- package/dist/cmp/ReadmeRefFeatures.js.map +1 -1
- package/dist/cmp/TestControl.d.ts +4 -0
- package/dist/cmp/TestControl.js +51 -0
- package/dist/cmp/TestControl.js.map +1 -0
- package/dist/helpers/applicability.d.ts +6 -0
- package/dist/helpers/applicability.js +103 -0
- package/dist/helpers/applicability.js.map +1 -0
- package/dist/helpers/collectDeps.js +4 -2
- package/dist/helpers/collectDeps.js.map +1 -1
- package/dist/helpers/featureSource.d.ts +3 -1
- package/dist/helpers/featureSource.js +105 -0
- package/dist/helpers/featureSource.js.map +1 -1
- package/dist/helpers/serverVars.d.ts +2 -1
- package/dist/helpers/serverVars.js +17 -0
- package/dist/helpers/serverVars.js.map +1 -1
- package/dist/sdkgen.d.ts +5 -3
- package/dist/sdkgen.js +16 -4
- package/dist/sdkgen.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utility.d.ts +2 -1
- package/dist/utility.js +59 -1
- package/dist/utility.js.map +1 -1
- package/model/sdkgen.aon +97 -0
- package/package.json +1 -1
- package/project/.sdk/model/feature/feature-index.aon +1 -0
- package/project/.sdk/model/feature/secrets.aon +200 -0
- package/project/.sdk/model/target/ts.aon +8 -1
- package/project/.sdk/src/cmp/c/Config_c.ts +5 -1
- package/project/.sdk/src/cmp/cpp/Config_cpp.ts +5 -1
- package/project/.sdk/src/cmp/cpp/Main_cpp.ts +2 -1
- package/project/.sdk/src/cmp/cpp/Test_cpp.ts +5 -1
- package/project/.sdk/src/cmp/csharp/Config_csharp.ts +5 -1
- package/project/.sdk/src/cmp/csharp/Main_csharp.ts +2 -1
- package/project/.sdk/src/cmp/csharp/TestDirect_csharp.ts +30 -6
- package/project/.sdk/src/cmp/csharp/TestEntity_csharp.ts +29 -5
- package/project/.sdk/src/cmp/csharp/Test_csharp.ts +5 -1
- package/project/.sdk/src/cmp/dart/Config_dart.ts +5 -1
- package/project/.sdk/src/cmp/dart/Main_dart.ts +2 -1
- package/project/.sdk/src/cmp/dart/TestDirect_dart.ts +23 -6
- package/project/.sdk/src/cmp/dart/TestEntity_dart.ts +28 -7
- package/project/.sdk/src/cmp/dart/Test_dart.ts +5 -1
- package/project/.sdk/src/cmp/elixir/Config_elixir.ts +5 -1
- package/project/.sdk/src/cmp/elixir/Main_elixir.ts +5 -1
- package/project/.sdk/src/cmp/go/Config_go.ts +5 -1
- package/project/.sdk/src/cmp/go/Main_go.ts +8 -3
- package/project/.sdk/src/cmp/go/ReadmeQuick_go.ts +16 -3
- package/project/.sdk/src/cmp/go/ReadmeTopQuick_go.ts +16 -3
- package/project/.sdk/src/cmp/go/TestDirect_go.ts +28 -4
- package/project/.sdk/src/cmp/go/TestEntity_go.ts +43 -10
- package/project/.sdk/src/cmp/go/Test_go.ts +5 -1
- package/project/.sdk/src/cmp/go/fragment/Main.fragment.go +5 -5
- package/project/.sdk/src/cmp/java/Config_java.ts +22 -1
- package/project/.sdk/src/cmp/java/Main_java.ts +7 -2
- package/project/.sdk/src/cmp/java/ReadmeQuick_java.ts +17 -3
- package/project/.sdk/src/cmp/java/ReadmeTopQuick_java.ts +17 -3
- package/project/.sdk/src/cmp/java/TestDirect_java.ts +23 -4
- package/project/.sdk/src/cmp/java/TestEntity_java.ts +29 -4
- package/project/.sdk/src/cmp/java/Test_java.ts +5 -1
- package/project/.sdk/src/cmp/js/Config_js.ts +5 -1
- package/project/.sdk/src/cmp/js/Main_js.ts +7 -2
- package/project/.sdk/src/cmp/js/Package_js.ts +4 -1
- package/project/.sdk/src/cmp/js/TestDirect_js.ts +30 -5
- package/project/.sdk/src/cmp/js/TestEntity_js.ts +35 -5
- package/project/.sdk/src/cmp/js/Test_js.ts +5 -1
- package/project/.sdk/src/cmp/js/fragment/Direct.test.fragment.js +7 -1
- package/project/.sdk/src/cmp/js/fragment/Entity.test.fragment.js +7 -1
- package/project/.sdk/src/cmp/kotlin/Config_kotlin.ts +5 -1
- package/project/.sdk/src/cmp/kotlin/Main_kotlin.ts +2 -1
- package/project/.sdk/src/cmp/kotlin/Test_kotlin.ts +5 -1
- package/project/.sdk/src/cmp/lean/Config_lean.ts +5 -1
- package/project/.sdk/src/cmp/lua/Config_lua.ts +5 -1
- package/project/.sdk/src/cmp/lua/Main_lua.ts +7 -2
- package/project/.sdk/src/cmp/lua/Package_lua.ts +4 -1
- package/project/.sdk/src/cmp/lua/TestDirect_lua.ts +28 -4
- package/project/.sdk/src/cmp/lua/TestEntity_lua.ts +24 -4
- package/project/.sdk/src/cmp/lua/Test_lua.ts +5 -1
- package/project/.sdk/src/cmp/ocaml/Config_ocaml.ts +5 -1
- package/project/.sdk/src/cmp/ocaml/Gitignore_ocaml.ts +1 -0
- package/project/.sdk/src/cmp/perl/Main_perl.ts +7 -2
- package/project/.sdk/src/cmp/perl/TestDirect_perl.ts +25 -4
- package/project/.sdk/src/cmp/perl/TestEntity_perl.ts +24 -4
- package/project/.sdk/src/cmp/perl/Test_perl.ts +5 -1
- package/project/.sdk/src/cmp/perl/utility_perl.ts +10 -0
- package/project/.sdk/src/cmp/php/Config_php.ts +5 -1
- package/project/.sdk/src/cmp/php/Main_php.ts +7 -2
- package/project/.sdk/src/cmp/php/TestDirect_php.ts +24 -5
- package/project/.sdk/src/cmp/php/TestEntity_php.ts +28 -4
- package/project/.sdk/src/cmp/php/Test_php.ts +5 -1
- package/project/.sdk/src/cmp/py/Config_py.ts +5 -1
- package/project/.sdk/src/cmp/py/Main_py.ts +7 -2
- package/project/.sdk/src/cmp/py/ReadmeQuick_py.ts +16 -3
- package/project/.sdk/src/cmp/py/ReadmeTopQuick_py.ts +16 -3
- package/project/.sdk/src/cmp/py/TestDirect_py.ts +24 -5
- package/project/.sdk/src/cmp/py/TestEntity_py.ts +23 -3
- package/project/.sdk/src/cmp/py/Test_py.ts +5 -1
- package/project/.sdk/src/cmp/rb/Config_rb.ts +5 -1
- package/project/.sdk/src/cmp/rb/Main_rb.ts +7 -2
- package/project/.sdk/src/cmp/rb/TestDirect_rb.ts +24 -5
- package/project/.sdk/src/cmp/rb/TestEntity_rb.ts +24 -4
- package/project/.sdk/src/cmp/rb/Test_rb.ts +5 -1
- package/project/.sdk/src/cmp/rb/utility_rb.ts +3 -1
- package/project/.sdk/src/cmp/rust/Config_rust.ts +5 -1
- package/project/.sdk/src/cmp/rust/Main_rust.ts +7 -2
- package/project/.sdk/src/cmp/rust/TestDirect_rust.ts +31 -4
- package/project/.sdk/src/cmp/rust/TestEntity_rust.ts +37 -4
- package/project/.sdk/src/cmp/rust/Test_rust.ts +5 -1
- package/project/.sdk/src/cmp/scala/Config_scala.ts +5 -1
- package/project/.sdk/src/cmp/scala/Main_scala.ts +7 -2
- package/project/.sdk/src/cmp/scala/Test_scala.ts +5 -1
- package/project/.sdk/src/cmp/swift/Config_swift.ts +5 -1
- package/project/.sdk/src/cmp/ts/Config_ts.ts +55 -9
- package/project/.sdk/src/cmp/ts/Main_ts.ts +67 -3
- package/project/.sdk/src/cmp/ts/Package_ts.ts +4 -1
- package/project/.sdk/src/cmp/ts/ReadmeModel_ts.ts +15 -3
- package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +18 -5
- package/project/.sdk/src/cmp/ts/ReadmeTopQuick_ts.ts +19 -5
- package/project/.sdk/src/cmp/ts/TestDirect_ts.ts +75 -8
- package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +36 -5
- package/project/.sdk/src/cmp/ts/Test_ts.ts +5 -1
- package/project/.sdk/src/cmp/ts/fragment/Direct.test.fragment.ts +9 -2
- package/project/.sdk/src/cmp/ts/fragment/Entity.test.fragment.ts +9 -2
- package/project/.sdk/src/cmp/ts/fragment/Main.fragment.ts +7 -0
- package/project/.sdk/src/cmp/zig/Config_zig.ts +5 -1
- package/project/.sdk/tm/c/utility/make_options.c +22 -0
- package/project/.sdk/tm/clojure/src/sdk/core.clj +18 -1
- package/project/.sdk/tm/cpp/utility/pipeline.hpp +23 -0
- package/project/.sdk/tm/csharp/test/CustomUtilityTest.cs +15 -0
- package/project/.sdk/tm/csharp/test/Runner.cs +45 -0
- package/project/.sdk/tm/csharp/utility/MakeOptions.cs +23 -0
- package/project/.sdk/tm/dart/lib/utility/MakeOptionsUtility.dart +22 -0
- package/project/.sdk/tm/dart/test/utility.dart +39 -0
- package/project/.sdk/tm/elixir/lib/projectname/utility.ex +19 -0
- package/project/.sdk/tm/go/core/context.go +1 -1
- package/project/.sdk/tm/go/feature/cost_feature.go +1 -1
- package/project/.sdk/tm/go/feature/paging_feature.go +5 -5
- package/project/.sdk/tm/go/feature/test_feature.go +12 -5
- package/project/.sdk/tm/go/test/custom_utility_test.go +15 -0
- package/project/.sdk/tm/go/test/feature_corpus_test.go +7 -0
- package/project/.sdk/tm/go/test/runner_test.go +46 -0
- package/project/.sdk/tm/go/test/struct_runner_test.go +7 -7
- package/project/.sdk/tm/go/test/struct_utility_test.go +63 -27
- package/project/.sdk/tm/go/utility/fetcher.go +2 -2
- package/project/.sdk/tm/go/utility/make_options.go +24 -5
- package/project/.sdk/tm/go/utility/make_point.go +1 -1
- package/project/.sdk/tm/go/utility/make_spec.go +17 -1
- package/project/.sdk/tm/go/utility/prepare_auth.go +1 -1
- package/project/.sdk/tm/go/utility/struct/voxgigstruct.go +370 -307
- package/project/.sdk/tm/go/utility/transform_request.go +29 -1
- package/project/.sdk/tm/go/utility/transform_response.go +20 -1
- package/project/.sdk/tm/java/test/CustomUtilityTest.java +10 -0
- package/project/.sdk/tm/java/test/FeatureCorpusTest.java +7 -0
- package/project/.sdk/tm/java/test/PrimaryUtilityTest.java +6 -0
- package/project/.sdk/tm/java/test/RunnerSupport.java +43 -0
- package/project/.sdk/tm/java/utility/MakeOptions.java +84 -1
- package/project/.sdk/tm/js/src/utility/MakeOptionsUtility.js +24 -0
- package/project/.sdk/tm/js/src/utility/StructUtility.js +2076 -1837
- package/project/.sdk/tm/js/test/feature/Corpus.test.js +9 -0
- package/project/.sdk/tm/js/test/sdk-test-control.json +19 -0
- package/project/.sdk/tm/js/test/utility.js +91 -1
- package/project/.sdk/tm/kotlin/utility/MakeOptions.kt +21 -0
- package/project/.sdk/tm/lean/src/SdkUtility.lean +12 -1
- package/project/.sdk/tm/lua/test/runner.lua +40 -0
- package/project/.sdk/tm/ocaml/sdk_runtime.ml +11 -0
- package/project/.sdk/tm/ocaml/test/harness.ml +14 -4
- package/project/.sdk/tm/perl/t/runner.pm +30 -0
- package/project/.sdk/tm/perl/utility/make_options.pm +18 -0
- package/project/.sdk/tm/php/test/FeatureCorpusTest.php +10 -1
- package/project/.sdk/tm/php/test/Runner.php +36 -0
- package/project/.sdk/tm/php/utility/MakeOptions.php +24 -0
- package/project/.sdk/tm/py/pkg/utility/make_options.py +20 -0
- package/project/.sdk/tm/py/test/runner.py +32 -0
- package/project/.sdk/tm/py/test/test_feature_corpus.py +10 -1
- package/project/.sdk/tm/rb/test/feature_corpus_test.rb +9 -1
- package/project/.sdk/tm/rb/test/runner.rb +25 -0
- package/project/.sdk/tm/rb/utility/make_options.rb +17 -0
- package/project/.sdk/tm/rust/tests/common/mod.rs +32 -0
- package/project/.sdk/tm/rust/utility/make_options.rs +26 -1
- package/project/.sdk/tm/scala/utility/Make.scala +17 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeOptions.swift +21 -0
- package/project/.sdk/tm/ts/src/feature/secrets/SecretsFeature.ts +419 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/Sekreto.ts +387 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/Sigv4.ts +175 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/index.ts +51 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/Registry.ts +90 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/addr.ts +48 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/aws.ts +219 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/azuresecrets.ts +144 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/boru.ts +113 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/doppler.ts +77 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/dotenv.ts +51 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/env.ts +31 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/file.ts +54 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/gcpsecrets.ts +118 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/hashicorp.ts +159 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/http.ts +66 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/infisical.ts +107 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/memory.ts +33 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/onepassword.ts +120 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/support.ts +176 -0
- package/project/.sdk/tm/ts/src/utility/MakeOptionsUtility.ts +18 -0
- package/project/.sdk/tm/ts/src/utility/StructUtility.ts +1321 -710
- package/project/.sdk/tm/ts/test/feature/Corpus.test.ts +9 -0
- package/project/.sdk/tm/ts/test/feature/secrets/Secrets.test.ts +764 -0
- package/project/.sdk/tm/ts/test/omni.test.ts +84 -0
- package/project/.sdk/tm/ts/test/omni.ts +86 -0
- package/project/.sdk/tm/ts/test/utility/PrimaryUtility.test.ts +6 -2
- package/project/.sdk/tm/ts/test/utility/StructUtility.test.ts +2 -2
- package/project/.sdk/tm/ts/test/utility.ts +122 -0
- package/project/.sdk/tm/ts/test/vendor/omni/Runner.ts +694 -0
- package/project/.sdk/tm/ts/test/vendor/omni/Util.ts +244 -0
- package/project/.sdk/tm/ts/test/vendor/omni/compat.ts +188 -0
- package/project/.sdk/tm/ts/test/vendor/omni/index.ts +38 -0
- package/project/.sdk/tm/zig/core/utility.zig +24 -1
- package/project/sdkgen-package.json +2 -1
- package/src/action/check.ts +18 -0
- package/src/cmp/AgentGuide.ts +1 -1
- package/src/cmp/AgentGuideContent.ts +9 -2
- package/src/cmp/Feature.ts +24 -0
- package/src/cmp/FeatureDocs.ts +7 -1
- package/src/cmp/ReadmeExplanation.ts +4 -1
- package/src/cmp/ReadmeFeatures.ts +1 -1
- package/src/cmp/ReadmeRefFeatures.ts +1 -1
- package/src/cmp/TestControl.ts +64 -0
- package/src/helpers/applicability.ts +123 -0
- package/src/helpers/collectDeps.ts +5 -1
- package/src/helpers/featureSource.ts +130 -0
- package/src/helpers/serverVars.ts +19 -0
- package/src/sdkgen.ts +16 -1
- package/src/utility.ts +71 -1
- package/project/.sdk/tm/ts/test/runner.ts +0 -425
|
@@ -11,7 +11,9 @@ import {
|
|
|
11
11
|
File,
|
|
12
12
|
cmp,
|
|
13
13
|
snakify,
|
|
14
|
-
isAuthActive, envName, envToken
|
|
14
|
+
isAuthActive, envName, envToken,
|
|
15
|
+
serverVarEnv,
|
|
16
|
+
serverVariables
|
|
15
17
|
} from '@voxgig/sdkgen'
|
|
16
18
|
|
|
17
19
|
import { formatCsValue } from './utility_csharp'
|
|
@@ -67,12 +69,26 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
67
69
|
|
|
68
70
|
const authActive = isAuthActive(model)
|
|
69
71
|
const apikeyEnvEntry = authActive
|
|
70
|
-
? `\n ["${PROJECTNAME}_APIKEY"] = "
|
|
72
|
+
? `\n ["${PROJECTNAME}_APIKEY"] = "",`
|
|
71
73
|
: ''
|
|
72
74
|
const apikeyLiveField = authActive
|
|
73
75
|
? `\n ["apikey"] = env["${PROJECTNAME}_APIKEY"],`
|
|
74
76
|
: ''
|
|
75
77
|
|
|
78
|
+
// A templated server URL (OpenAPI server variables) makes a LIVE client
|
|
79
|
+
// impossible to construct without values: makeOptions raises rather than
|
|
80
|
+
// request a URL with a literal `{account_id}` in it. So the live suite
|
|
81
|
+
// takes them from the environment the same way it takes the apikey.
|
|
82
|
+
const svars = serverVariables(model)
|
|
83
|
+
const serverEnvEntry = svars
|
|
84
|
+
.map((v: any) => `\n ["${serverVarEnv(PROJECTNAME, v.name)}"] = ${JSON.stringify(v.dflt)},`).join('')
|
|
85
|
+
const serverLiveField = 0 === svars.length ? '' : `
|
|
86
|
+
["server"] = new Dictionary<string, object?>
|
|
87
|
+
{${svars
|
|
88
|
+
.map((v: any) => `
|
|
89
|
+
["${v.name}"] = env["${serverVarEnv(PROJECTNAME, v.name)}"],`).join('')}
|
|
90
|
+
},`
|
|
91
|
+
|
|
76
92
|
const opnames = Object.keys(entity.op || {})
|
|
77
93
|
const hasLoad = opnames.includes('load')
|
|
78
94
|
const hasList = opnames.includes('list')
|
|
@@ -475,16 +491,24 @@ ${loadSkipBlock} var client = setup.Client;
|
|
|
475
491
|
var env = TestRunner.EnvOverride(new Dictionary<string, object?>
|
|
476
492
|
{
|
|
477
493
|
["${entidEnvVar}"] = new Dictionary<string, object?>(),
|
|
478
|
-
["${PROJECTNAME}_TEST_LIVE"] = "FALSE",${apikeyEnvEntry}
|
|
494
|
+
["${PROJECTNAME}_TEST_LIVE"] = "FALSE",${apikeyEnvEntry}${serverEnvEntry}
|
|
479
495
|
});
|
|
480
496
|
|
|
481
497
|
var live = Equals(env["${PROJECTNAME}_TEST_LIVE"], "TRUE");
|
|
482
498
|
|
|
483
499
|
if (live)
|
|
484
500
|
{
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
501
|
+
// sdk-test-control.json's test.client.options goes UNDER the
|
|
502
|
+
// generated fields: it adds to the live client, it does not
|
|
503
|
+
// redirect it, so the generated entries overwrite it here.
|
|
504
|
+
var liveOpts = TestRunner.LiveClientOptions();
|
|
505
|
+
foreach (var _kv in new Dictionary<string, object?>
|
|
506
|
+
{${apikeyLiveField}${serverLiveField}
|
|
507
|
+
})
|
|
508
|
+
{
|
|
509
|
+
liveOpts[_kv.Key] = _kv.Value;
|
|
510
|
+
}
|
|
511
|
+
var liveClient = new ${Name}SDK(liveOpts);
|
|
488
512
|
|
|
489
513
|
var idmap = new Dictionary<string, object?>();
|
|
490
514
|
var entidRaw = env["${entidEnvVar}"];
|
|
@@ -17,7 +17,9 @@ import {
|
|
|
17
17
|
each,
|
|
18
18
|
buildIdNames,
|
|
19
19
|
getMatchEntries,
|
|
20
|
-
isAuthActive, envName, envToken
|
|
20
|
+
isAuthActive, envName, envToken,
|
|
21
|
+
serverVarEnv,
|
|
22
|
+
serverVariables
|
|
21
23
|
} from '@voxgig/sdkgen'
|
|
22
24
|
|
|
23
25
|
|
|
@@ -59,12 +61,26 @@ const TestEntity = cmp(function TestEntity(props: any) {
|
|
|
59
61
|
|
|
60
62
|
const authActive = isAuthActive(model)
|
|
61
63
|
const apikeyEnvEntry = authActive
|
|
62
|
-
? `\n ["${PROJUPPER}_APIKEY"] = "
|
|
64
|
+
? `\n ["${PROJUPPER}_APIKEY"] = "",`
|
|
63
65
|
: ''
|
|
64
66
|
const apikeyLiveField = authActive
|
|
65
67
|
? `\n ["apikey"] = env["${PROJUPPER}_APIKEY"],`
|
|
66
68
|
: ''
|
|
67
69
|
|
|
70
|
+
// A templated server URL (OpenAPI server variables) makes a LIVE client
|
|
71
|
+
// impossible to construct without values: makeOptions raises rather than
|
|
72
|
+
// request a URL with a literal `{account_id}` in it. So the live suite
|
|
73
|
+
// takes them from the environment the same way it takes the apikey.
|
|
74
|
+
const svars = serverVariables(model)
|
|
75
|
+
const serverEnvEntry = svars
|
|
76
|
+
.map((v: any) => `\n ["${serverVarEnv(PROJUPPER, v.name)}"] = ${JSON.stringify(v.dflt)},`).join('')
|
|
77
|
+
const serverLiveField = 0 === svars.length ? '' : `
|
|
78
|
+
["server"] = new Dictionary<string, object?>
|
|
79
|
+
{${svars
|
|
80
|
+
.map((v: any) => `
|
|
81
|
+
["${v.name}"] = env["${serverVarEnv(PROJUPPER, v.name)}"],`).join('')}
|
|
82
|
+
},`
|
|
83
|
+
|
|
68
84
|
const idnames = buildIdNames(entity, basicflow)
|
|
69
85
|
const idnamesStr = idnames.map(n => `"${n}"`).join(', ')
|
|
70
86
|
|
|
@@ -266,7 +282,7 @@ ${allSteps.length > 0 ? ' var client = setup.Client;\n\n' : ''}`)
|
|
|
266
282
|
{
|
|
267
283
|
["${PROJUPPER}_TEST_${ENTUPPER}_ENTID"] = idmap,
|
|
268
284
|
["${PROJUPPER}_TEST_LIVE"] = "FALSE",
|
|
269
|
-
["${PROJUPPER}_TEST_EXPLAIN"] = "FALSE",${apikeyEnvEntry}
|
|
285
|
+
["${PROJUPPER}_TEST_EXPLAIN"] = "FALSE",${apikeyEnvEntry}${serverEnvEntry}
|
|
270
286
|
});
|
|
271
287
|
|
|
272
288
|
var idmapResolved = Helpers.ToMapAny(env["${PROJUPPER}_TEST_${ENTUPPER}_ENTID"])
|
|
@@ -288,12 +304,20 @@ ${allSteps.length > 0 ? ' var client = setup.Client;\n\n' : ''}`)
|
|
|
288
304
|
Content(`
|
|
289
305
|
if (Equals(env["${PROJUPPER}_TEST_LIVE"], "TRUE"))
|
|
290
306
|
{
|
|
307
|
+
// 'extra ?? new ...', not a bare 'extra': Merge returns null when
|
|
308
|
+
// the last entry is null, and BasicSetup is normally called with no
|
|
309
|
+
// argument at all - so a bare 'extra' silently discarded the apikey
|
|
310
|
+
// and server values above and handed the SDK null.
|
|
311
|
+
var extraOpts = extra ?? new Dictionary<string, object?>();
|
|
291
312
|
var mergedOpts = StructUtils.Merge(new List<object?>
|
|
292
313
|
{
|
|
314
|
+
// FIRST, so the generated fields below win: sdk-test-control.json's
|
|
315
|
+
// test.client.options adds to the live client, it does not redirect it.
|
|
316
|
+
TestRunner.LiveClientOptions(),
|
|
293
317
|
new Dictionary<string, object?>
|
|
294
|
-
{${apikeyLiveField}
|
|
318
|
+
{${apikeyLiveField}${serverLiveField}
|
|
295
319
|
},
|
|
296
|
-
|
|
320
|
+
extraOpts,
|
|
297
321
|
});
|
|
298
322
|
client = new ${Name}SDK(Helpers.ToMapAny(mergedOpts));
|
|
299
323
|
}
|
|
@@ -3,7 +3,8 @@ import type {
|
|
|
3
3
|
ModelEntity
|
|
4
4
|
} from '@voxgig/apidef'
|
|
5
5
|
|
|
6
|
-
import { cmp, each, Folder, entityCollection
|
|
6
|
+
import { cmp, each, Folder, entityCollection,
|
|
7
|
+
TestControl } from '@voxgig/sdkgen'
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
import { TestEntity } from './TestEntity_csharp'
|
|
@@ -21,6 +22,9 @@ const Test = cmp(function Test(props: any) {
|
|
|
21
22
|
// tests are generated here.
|
|
22
23
|
Folder({ name: 'test' }, () => {
|
|
23
24
|
|
|
25
|
+
// Write-once: a project's edited control file survives regeneration.
|
|
26
|
+
TestControl({ target, dir: 'test' })
|
|
27
|
+
|
|
24
28
|
const entity = each(entityCollection(model))
|
|
25
29
|
.filter((e: any) => false !== e.active)
|
|
26
30
|
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
isConfigData,
|
|
14
14
|
isAuthActive,
|
|
15
15
|
resolveAuthPrefix,
|
|
16
|
+
targetFeatures,
|
|
16
17
|
} from '@voxgig/sdkgen'
|
|
17
18
|
|
|
18
19
|
|
|
@@ -38,7 +39,10 @@ const Config = cmp(async function Config(props: any) {
|
|
|
38
39
|
const model: Model = ctx$.model
|
|
39
40
|
|
|
40
41
|
const entity = getModelPath(model, `main.${KIT}.entity`)
|
|
41
|
-
|
|
42
|
+
// Gated by the applicability tags, so this target never imports or
|
|
43
|
+
// registers a feature it has no source for. One rule, one place:
|
|
44
|
+
// helpers/applicability.
|
|
45
|
+
const feature = targetFeatures(model, target)
|
|
42
46
|
|
|
43
47
|
const ff = Path.normalize(__dirname + '/../../../src/cmp/dart/fragment/')
|
|
44
48
|
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
cmp, each,
|
|
6
6
|
List, File, Copy, Folder, Fragment, Line,
|
|
7
7
|
entityClassName, entityCollection,
|
|
8
|
+
TEST_CONTROL_EXCLUDE
|
|
8
9
|
} from '@voxgig/sdkgen'
|
|
9
10
|
|
|
10
11
|
|
|
@@ -45,7 +46,7 @@ const Main = cmp(async function Main(props: any) {
|
|
|
45
46
|
// lib/feature/), so they are excluded from the generated package.
|
|
46
47
|
Copy({
|
|
47
48
|
from: 'tm/' + target.name,
|
|
48
|
-
exclude: [/src
|
|
49
|
+
exclude: [/src\//, TEST_CONTROL_EXCLUDE],
|
|
49
50
|
replace: {
|
|
50
51
|
...props.ctx$.stdrep,
|
|
51
52
|
}
|
|
@@ -16,14 +16,15 @@ import {
|
|
|
16
16
|
Slot,
|
|
17
17
|
cmp,
|
|
18
18
|
snakify,
|
|
19
|
-
isAuthActive, envName, envToken
|
|
19
|
+
isAuthActive, envName, envToken,
|
|
20
|
+
serverVarEnv,
|
|
21
|
+
serverVariables
|
|
20
22
|
} from '@voxgig/sdkgen'
|
|
21
23
|
|
|
22
24
|
|
|
23
25
|
import {
|
|
24
26
|
projectPath,
|
|
25
|
-
dartValue,
|
|
26
|
-
} from './utility_dart'
|
|
27
|
+
dartValue, dartStringLiteral} from './utility_dart'
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
const TestDirect = cmp(function TestDirect(props: any) {
|
|
@@ -40,13 +41,26 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
40
41
|
|
|
41
42
|
const authActive = isAuthActive(model)
|
|
42
43
|
const apikeyEnvEntry = authActive
|
|
43
|
-
? `\n '${PROJECTNAME}_APIKEY': '
|
|
44
|
+
? `\n '${PROJECTNAME}_APIKEY': '',`
|
|
44
45
|
: ''
|
|
45
46
|
const apikeyLiveField = authActive
|
|
46
47
|
? `
|
|
47
48
|
'apikey': env['${PROJECTNAME}_APIKEY'],`
|
|
48
49
|
: ''
|
|
49
50
|
|
|
51
|
+
// A templated server URL (OpenAPI server variables) makes a LIVE client
|
|
52
|
+
// impossible to construct without values: makeOptions raises rather than
|
|
53
|
+
// request a URL with a literal `{account_id}` in it. So the live suite
|
|
54
|
+
// takes them from the environment the same way it takes the apikey.
|
|
55
|
+
const svars = serverVariables(model)
|
|
56
|
+
const serverEnvEntry = svars
|
|
57
|
+
.map((v: any) => `\n '${serverVarEnv(PROJECTNAME, v.name)}': ${dartStringLiteral(v.dflt)},`).join('')
|
|
58
|
+
const serverLiveField = 0 === svars.length ? '' : `
|
|
59
|
+
'server': <String, dynamic>{${svars
|
|
60
|
+
.map((v: any) => `
|
|
61
|
+
'${v.name}': env['${serverVarEnv(PROJECTNAME, v.name)}'],`).join('')}
|
|
62
|
+
},`
|
|
63
|
+
|
|
50
64
|
const opnames = Object.keys(entity.op || {})
|
|
51
65
|
const hasLoad = opnames.includes('load')
|
|
52
66
|
const hasList = opnames.includes('list')
|
|
@@ -78,13 +92,16 @@ Map<String, dynamic> directSetup([dynamic mockres]) {
|
|
|
78
92
|
|
|
79
93
|
final env = envOverride({
|
|
80
94
|
'${entidEnvVar}': <String, dynamic>{},
|
|
81
|
-
'${PROJECTNAME}_TEST_LIVE': 'FALSE',${apikeyEnvEntry}
|
|
95
|
+
'${PROJECTNAME}_TEST_LIVE': 'FALSE',${apikeyEnvEntry}${serverEnvEntry}
|
|
82
96
|
});
|
|
83
97
|
|
|
84
98
|
final live = 'TRUE' == env['${PROJECTNAME}_TEST_LIVE'];
|
|
85
99
|
|
|
86
100
|
if (live) {
|
|
87
|
-
|
|
101
|
+
// Spread FIRST, so the generated fields below win: sdk-test-control.json's
|
|
102
|
+
// test.client.options adds to the live client, it does not redirect it.
|
|
103
|
+
final client = ${nom(model.const, 'Name')}SDK(<String, dynamic>{
|
|
104
|
+
...liveClientOptions(),${apikeyLiveField}${serverLiveField}
|
|
88
105
|
});
|
|
89
106
|
|
|
90
107
|
dynamic idmap = env['${entidEnvVar}'];
|
|
@@ -23,13 +23,14 @@ import {
|
|
|
23
23
|
Slot,
|
|
24
24
|
cmp,
|
|
25
25
|
each,
|
|
26
|
-
isAuthActive, envName, envToken
|
|
26
|
+
isAuthActive, envName, envToken,
|
|
27
|
+
serverVarEnv,
|
|
28
|
+
serverVariables
|
|
27
29
|
} from '@voxgig/sdkgen'
|
|
28
30
|
|
|
29
31
|
|
|
30
32
|
import {
|
|
31
|
-
projectPath
|
|
32
|
-
} from './utility_dart'
|
|
33
|
+
projectPath, dartStringLiteral} from './utility_dart'
|
|
33
34
|
|
|
34
35
|
|
|
35
36
|
// GenCtx is the per-language generation context passed to every OpGen.
|
|
@@ -54,13 +55,26 @@ const TestEntity = cmp(function TestEntity(props: any) {
|
|
|
54
55
|
const ENTENVNAME = envToken(entity.name)
|
|
55
56
|
const authActive = isAuthActive(model)
|
|
56
57
|
const apikeyEnvEntry = authActive
|
|
57
|
-
? `\n '${PROJENVNAME}_APIKEY': '
|
|
58
|
+
? `\n '${PROJENVNAME}_APIKEY': '',`
|
|
58
59
|
: ''
|
|
59
60
|
const apikeyLiveField = authActive
|
|
60
61
|
? `
|
|
61
62
|
'apikey': env['${PROJENVNAME}_APIKEY'],`
|
|
62
63
|
: ''
|
|
63
64
|
|
|
65
|
+
// A templated server URL (OpenAPI server variables) makes a LIVE client
|
|
66
|
+
// impossible to construct without values: makeOptions raises rather than
|
|
67
|
+
// request a URL with a literal `{account_id}` in it. So the live suite
|
|
68
|
+
// takes them from the environment the same way it takes the apikey.
|
|
69
|
+
const svars = serverVariables(model)
|
|
70
|
+
const serverEnvEntry = svars
|
|
71
|
+
.map((v: any) => `\n '${serverVarEnv(PROJENVNAME, v.name)}': ${dartStringLiteral(v.dflt)},`).join('')
|
|
72
|
+
const serverLiveField = 0 === svars.length ? '' : `
|
|
73
|
+
'server': <String, dynamic>{${svars
|
|
74
|
+
.map((v: any) => `
|
|
75
|
+
'${v.name}': env['${serverVarEnv(PROJENVNAME, v.name)}'],`).join('')}
|
|
76
|
+
},`
|
|
77
|
+
|
|
64
78
|
const ff = projectPath('src/cmp/dart/fragment/')
|
|
65
79
|
|
|
66
80
|
Folder({ name: entity.name }, () => {
|
|
@@ -191,7 +205,7 @@ Map<String, dynamic> basicSetup([dynamic extra]) {
|
|
|
191
205
|
final env = envOverride({
|
|
192
206
|
'${PROJENVNAME}_TEST_${ENTENVNAME}_ENTID': idmap,
|
|
193
207
|
'${PROJENVNAME}_TEST_LIVE': 'FALSE',
|
|
194
|
-
'${PROJENVNAME}_TEST_EXPLAIN': 'FALSE',${apikeyEnvEntry}
|
|
208
|
+
'${PROJENVNAME}_TEST_EXPLAIN': 'FALSE',${apikeyEnvEntry}${serverEnvEntry}
|
|
195
209
|
});
|
|
196
210
|
|
|
197
211
|
idmap = env['${PROJENVNAME}_TEST_${ENTENVNAME}_ENTID'];
|
|
@@ -200,9 +214,16 @@ Map<String, dynamic> basicSetup([dynamic extra]) {
|
|
|
200
214
|
|
|
201
215
|
if (live) {
|
|
202
216
|
client = ${model.Name}SDK(merge([
|
|
203
|
-
|
|
217
|
+
// FIRST, so the generated fields below win: sdk-test-control.json's
|
|
218
|
+
// test.client.options adds to the live client, it does not redirect it.
|
|
219
|
+
liveClientOptions(),
|
|
220
|
+
<String, dynamic>{${apikeyLiveField}${serverLiveField}
|
|
204
221
|
},
|
|
205
|
-
extra
|
|
222
|
+
// 'extra ?? {}', not a bare 'extra': merge returns null when the last
|
|
223
|
+
// entry is null, and basicSetup is normally called with no argument at
|
|
224
|
+
// all - so a bare 'extra' silently discarded the apikey and server
|
|
225
|
+
// values above and handed the SDK null.
|
|
226
|
+
extra ?? <String, dynamic>{}
|
|
206
227
|
]));
|
|
207
228
|
}
|
|
208
229
|
|
|
@@ -7,7 +7,8 @@ import type {
|
|
|
7
7
|
ModelEntity
|
|
8
8
|
} from '@voxgig/apidef'
|
|
9
9
|
|
|
10
|
-
import { cmp, each, snakify, Folder, File, Content, entityCollection
|
|
10
|
+
import { cmp, each, snakify, Folder, File, Content, entityCollection,
|
|
11
|
+
TestControl } from '@voxgig/sdkgen'
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
import { TestDirect } from './TestDirect_dart'
|
|
@@ -24,6 +25,9 @@ const Test = cmp(function Test(props: any) {
|
|
|
24
25
|
|
|
25
26
|
Folder({ name: 'test' }, () => {
|
|
26
27
|
|
|
28
|
+
// Write-once: a project's edited control file survives regeneration.
|
|
29
|
+
TestControl({ target, dir: 'test' })
|
|
30
|
+
|
|
27
31
|
// Suite entry: registers every static suite plus the generated
|
|
28
32
|
// per-entity suites, then runs them (Makefile: dart run test/main.dart).
|
|
29
33
|
File({ name: 'main.' + target.ext }, () => {
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
isAuthActive,
|
|
11
11
|
isConfigData,
|
|
12
12
|
resolveAuthPrefix,
|
|
13
|
+
targetFeatures,
|
|
13
14
|
} from '@voxgig/sdkgen'
|
|
14
15
|
|
|
15
16
|
|
|
@@ -35,7 +36,10 @@ const Config = cmp(async function Config(props: any) {
|
|
|
35
36
|
const Name = model.const.Name
|
|
36
37
|
|
|
37
38
|
const entity = getModelPath(model, `main.${KIT}.entity`)
|
|
38
|
-
|
|
39
|
+
// Gated by the applicability tags, so this target never imports or
|
|
40
|
+
// registers a feature it has no source for. One rule, one place:
|
|
41
|
+
// helpers/applicability.
|
|
42
|
+
const feature = targetFeatures(model, target)
|
|
39
43
|
|
|
40
44
|
const headers = getModelPath(model, `main.${KIT}.config.headers`) || {}
|
|
41
45
|
|
|
@@ -4,6 +4,7 @@ import * as Path from 'node:path'
|
|
|
4
4
|
import {
|
|
5
5
|
cmp, each,
|
|
6
6
|
File, Folder, Content, Copy, Fragment,
|
|
7
|
+
targetFeatures,
|
|
7
8
|
} from '@voxgig/sdkgen'
|
|
8
9
|
|
|
9
10
|
|
|
@@ -38,7 +39,10 @@ const Main = cmp(async function Main(props: any) {
|
|
|
38
39
|
|
|
39
40
|
const Name = model.const.Name
|
|
40
41
|
const entity = getModelPath(model, `main.${KIT}.entity`)
|
|
41
|
-
|
|
42
|
+
// Gated by the applicability tags, so this target never imports or
|
|
43
|
+
// registers a feature it has no source for. One rule, one place:
|
|
44
|
+
// helpers/applicability.
|
|
45
|
+
const feature = targetFeatures(model, target)
|
|
42
46
|
|
|
43
47
|
const ff = Path.normalize(__dirname + '/../../../src/cmp/elixir/fragment/')
|
|
44
48
|
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
isConfigData,
|
|
17
17
|
resolveAuthPrefix,
|
|
18
18
|
serverVariables,
|
|
19
|
+
targetFeatures,
|
|
19
20
|
} from '@voxgig/sdkgen'
|
|
20
21
|
|
|
21
22
|
|
|
@@ -40,7 +41,10 @@ const Config = cmp(async function Config(props: any) {
|
|
|
40
41
|
const model: Model = ctx$.model
|
|
41
42
|
|
|
42
43
|
const entity = getModelPath(model, `main.${KIT}.entity`)
|
|
43
|
-
|
|
44
|
+
// Gated by the applicability tags, so this target never imports or
|
|
45
|
+
// registers a feature it has no source for. One rule, one place:
|
|
46
|
+
// helpers/applicability.
|
|
47
|
+
const feature = targetFeatures(model, target)
|
|
44
48
|
|
|
45
49
|
const headers = getModelPath(model, `main.${KIT}.config.headers`) || {}
|
|
46
50
|
|
|
@@ -4,7 +4,9 @@ import * as Path from 'node:path'
|
|
|
4
4
|
import {
|
|
5
5
|
cmp, each, names, cmap,
|
|
6
6
|
List, File, Content, Copy, Folder, Fragment, Line, FeatureHook,
|
|
7
|
-
entityClassName, entityCollection, goModule, goPackageIdent
|
|
7
|
+
entityClassName, entityCollection, goModule, goPackageIdent,
|
|
8
|
+
targetFeatures,
|
|
9
|
+
TEST_CONTROL_EXCLUDE
|
|
8
10
|
} from '@voxgig/sdkgen'
|
|
9
11
|
|
|
10
12
|
|
|
@@ -33,7 +35,10 @@ const Main = cmp(async function Main(props: any) {
|
|
|
33
35
|
const { model } = props.ctx$
|
|
34
36
|
|
|
35
37
|
const entity: ModelEntity = getModelPath(model, `main.${KIT}.entity`)
|
|
36
|
-
|
|
38
|
+
// Gated by the applicability tags, so this target never imports or
|
|
39
|
+
// registers a feature it has no source for. One rule, one place:
|
|
40
|
+
// helpers/applicability.
|
|
41
|
+
const feature = targetFeatures(model, target)
|
|
37
42
|
|
|
38
43
|
// Go module path == the repo path on GitHub (org from model.origin),
|
|
39
44
|
// e.g. github.com/voxgig-sdk/<slug>-sdk. Used in go.mod and every import.
|
|
@@ -55,7 +60,7 @@ const Main = cmp(async function Main(props: any) {
|
|
|
55
60
|
// downstream consumers.
|
|
56
61
|
Copy({
|
|
57
62
|
from: 'tm/' + target.name,
|
|
58
|
-
exclude: [/src\//, /utility\/struct\/go\.mod
|
|
63
|
+
exclude: [/src\//, /utility\/struct\/go\.mod$/, TEST_CONTROL_EXCLUDE],
|
|
59
64
|
replace: {
|
|
60
65
|
...props.ctx$.stdrep,
|
|
61
66
|
GOMODULE: gomodule,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content, isAuthActive, envName, opRequestShape, entityIdField, entityOps, goModule } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, Content, isAuthActive, envName, opRequestShape, entityIdField, entityOps, goModule , serverVariables} from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -25,9 +25,22 @@ const ReadmeQuick = cmp(function ReadmeQuick(props: any) {
|
|
|
25
25
|
const exampleEntity = Object.values(entity).find((e: any) => e.active !== false) as any
|
|
26
26
|
|
|
27
27
|
const authActive = isAuthActive(model)
|
|
28
|
+
|
|
29
|
+
// Server variables (a templated server URL) are REQUIRED at construction
|
|
30
|
+
// - the SDK refuses rather than request a URL with a literal
|
|
31
|
+
// {account_id} in it - so a quickstart that omits them is a quickstart
|
|
32
|
+
// that fails on its first line.
|
|
33
|
+
const svars = serverVariables(model)
|
|
34
|
+
const goServerField = 0 === svars.length ? '' :
|
|
35
|
+
`\n "server": map[string]any{` +
|
|
36
|
+
svars.map((v: any) => `\n "${v.name}": "<${v.name}>",`).join('') +
|
|
37
|
+
`\n },`
|
|
38
|
+
|
|
28
39
|
const ctor = authActive
|
|
29
|
-
? `sdk.New${model.const.Name}SDK(map[string]any{\n "apikey": os.Getenv("${envName(model)}_APIKEY")
|
|
30
|
-
:
|
|
40
|
+
? `sdk.New${model.const.Name}SDK(map[string]any{\n "apikey": os.Getenv("${envName(model)}_APIKEY"),${goServerField}\n })`
|
|
41
|
+
: ('' === goServerField
|
|
42
|
+
? `sdk.New()`
|
|
43
|
+
: `sdk.New${model.const.Name}SDK(map[string]any{${goServerField}\n })`)
|
|
31
44
|
|
|
32
45
|
// Build the body of main() from the operations the example entity
|
|
33
46
|
// supports. Each op names a fresh value var, so `:=` always declares a
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { cmp, Content, isAuthActive, envName, entityIdField, entityOps, opRequestShape, goModule } from '@voxgig/sdkgen'
|
|
2
|
+
import { cmp, Content, isAuthActive, envName, entityIdField, entityOps, opRequestShape, goModule , serverVariables} from '@voxgig/sdkgen'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
KIT,
|
|
@@ -20,9 +20,22 @@ const ReadmeTopQuick = cmp(function ReadmeTopQuick(props: any) {
|
|
|
20
20
|
const exampleEntity = Object.values(entity).find((e: any) => e.active !== false) as any
|
|
21
21
|
|
|
22
22
|
const authActive = isAuthActive(model)
|
|
23
|
+
|
|
24
|
+
// Server variables (a templated server URL) are REQUIRED at construction
|
|
25
|
+
// - the SDK refuses rather than request a URL with a literal
|
|
26
|
+
// {account_id} in it - so a quickstart that omits them is a quickstart
|
|
27
|
+
// that fails on its first line.
|
|
28
|
+
const svars = serverVariables(model)
|
|
29
|
+
const goServerField = 0 === svars.length ? '' :
|
|
30
|
+
`\n "server": map[string]any{` +
|
|
31
|
+
svars.map((v: any) => `\n "${v.name}": "<${v.name}>",`).join('') +
|
|
32
|
+
`\n },`
|
|
33
|
+
|
|
23
34
|
const ctor = authActive
|
|
24
|
-
? `sdk.New${model.const.Name}SDK(map[string]any{\n "apikey": os.Getenv("${envName(model)}_APIKEY")
|
|
25
|
-
:
|
|
35
|
+
? `sdk.New${model.const.Name}SDK(map[string]any{\n "apikey": os.Getenv("${envName(model)}_APIKEY"),${goServerField}\n})`
|
|
36
|
+
: ('' === goServerField
|
|
37
|
+
? `sdk.New()`
|
|
38
|
+
: `sdk.New${model.const.Name}SDK(map[string]any{${goServerField}\n})`)
|
|
26
39
|
|
|
27
40
|
Content(`\`\`\`go
|
|
28
41
|
import sdk "${gomodule}"
|
|
@@ -11,7 +11,9 @@ import {
|
|
|
11
11
|
File,
|
|
12
12
|
cmp,
|
|
13
13
|
snakify,
|
|
14
|
-
isAuthActive,
|
|
14
|
+
isAuthActive,
|
|
15
|
+
serverVarEnv,
|
|
16
|
+
serverVariables, envName, envToken, liveStrict
|
|
15
17
|
} from '@voxgig/sdkgen'
|
|
16
18
|
|
|
17
19
|
|
|
@@ -73,12 +75,26 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
73
75
|
|
|
74
76
|
const authActive = isAuthActive(model)
|
|
75
77
|
const apikeyEnvEntry = authActive
|
|
76
|
-
? `\n\t\t"${PROJECTNAME}_APIKEY": "
|
|
78
|
+
? `\n\t\t"${PROJECTNAME}_APIKEY": "",`
|
|
77
79
|
: ''
|
|
78
80
|
const apikeyLiveField = authActive
|
|
79
81
|
? `\n\t\t\t"apikey": env["${PROJECTNAME}_APIKEY"],`
|
|
80
82
|
: ''
|
|
81
83
|
|
|
84
|
+
// A templated server URL (OpenAPI server variables) makes a LIVE client
|
|
85
|
+
// impossible to construct without values: makeOptions refuses rather than
|
|
86
|
+
// request a URL with a literal `{account_id}` in it. Taken from the
|
|
87
|
+
// environment, the same way the apikey is.
|
|
88
|
+
const svars = serverVariables(model)
|
|
89
|
+
const serverEnvEntry = svars
|
|
90
|
+
.map((v: any) => `\n\t\t"${serverVarEnv(PROJECTNAME, v.name)}": ${JSON.stringify(v.dflt)},`).join('')
|
|
91
|
+
const serverLiveField = 0 === svars.length ? '' :
|
|
92
|
+
`\n\t\t"server": map[string]any{` +
|
|
93
|
+
svars.map((v: any) =>
|
|
94
|
+
`\n\t\t\t"${v.name}": env["${serverVarEnv(PROJECTNAME, v.name)}"],`).join('') +
|
|
95
|
+
`\n\t\t},`
|
|
96
|
+
|
|
97
|
+
|
|
82
98
|
const opnames = Object.keys(entity.op || {})
|
|
83
99
|
const hasLoad = opnames.includes('load')
|
|
84
100
|
const hasList = opnames.includes('list')
|
|
@@ -559,13 +575,21 @@ func ${entity.name}DirectSetup(mockres any) *${entity.name}DirectSetupResult {
|
|
|
559
575
|
|
|
560
576
|
env := envOverride(map[string]any{
|
|
561
577
|
"${entidEnvVar}": map[string]any{},
|
|
562
|
-
"${PROJECTNAME}_TEST_LIVE": "FALSE",${apikeyEnvEntry}
|
|
578
|
+
"${PROJECTNAME}_TEST_LIVE": "FALSE",${apikeyEnvEntry}${serverEnvEntry}
|
|
563
579
|
})
|
|
564
580
|
|
|
565
581
|
live := env["${PROJECTNAME}_TEST_LIVE"] == "TRUE"
|
|
566
582
|
|
|
567
583
|
if live {
|
|
568
|
-
|
|
584
|
+
// sdk-test-control.json's test.client.options seeds the live
|
|
585
|
+
// client; the generated fields below overwrite anything they name.
|
|
586
|
+
mergedOpts := map[string]any{}
|
|
587
|
+
for k, v := range liveClientOptions() {
|
|
588
|
+
mergedOpts[k] = v
|
|
589
|
+
}
|
|
590
|
+
for k, v := range map[string]any{${apikeyLiveField}${serverLiveField}
|
|
591
|
+
} {
|
|
592
|
+
mergedOpts[k] = v
|
|
569
593
|
}
|
|
570
594
|
client := sdk.New${model.const.Name}SDK(mergedOpts)
|
|
571
595
|
|