@voxgig/sdkgen 4.35.3 → 4.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/voxgig-sdkgen +1 -1
- package/dist/cmp/ReadmeTop.js +1 -1
- package/dist/cmp/ReadmeTop.js.map +1 -1
- package/dist/helpers/opExample.d.ts +4 -1
- package/dist/helpers/opExample.js +11 -1
- package/dist/helpers/opExample.js.map +1 -1
- package/dist/helpers/opShape.d.ts +2 -1
- package/dist/helpers/opShape.js +53 -26
- package/dist/helpers/opShape.js.map +1 -1
- package/dist/helpers/pointPath.d.ts +2 -1
- package/dist/helpers/pointPath.js +17 -0
- package/dist/helpers/pointPath.js.map +1 -1
- package/dist/helpers/testPolicy.d.ts +48 -2
- package/dist/helpers/testPolicy.js +265 -0
- package/dist/helpers/testPolicy.js.map +1 -1
- package/dist/sdkgen.d.ts +7 -7
- package/dist/sdkgen.js +26 -4
- package/dist/sdkgen.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/project/.sdk/src/cmp/c/PrepareAuth_c.ts +10 -4
- package/project/.sdk/src/cmp/c/ReadmeEntity_c.ts +2 -2
- package/project/.sdk/src/cmp/c/ReadmeHowto_c.ts +2 -2
- package/project/.sdk/src/cmp/c/ReadmeQuick_c.ts +6 -5
- package/project/.sdk/src/cmp/c/ReadmeRef_c.ts +3 -3
- package/project/.sdk/src/cmp/c/ReadmeTopQuick_c.ts +2 -2
- package/project/.sdk/src/cmp/c/ReadmeTopTest_c.ts +2 -2
- package/project/.sdk/src/cmp/c/TestDirect_c.ts +2 -6
- package/project/.sdk/src/cmp/clojure/ReadmeEntity_clojure.ts +2 -2
- package/project/.sdk/src/cmp/clojure/ReadmeHowto_clojure.ts +2 -2
- package/project/.sdk/src/cmp/clojure/ReadmeQuick_clojure.ts +4 -4
- package/project/.sdk/src/cmp/clojure/ReadmeRef_clojure.ts +3 -3
- package/project/.sdk/src/cmp/clojure/ReadmeTopQuick_clojure.ts +2 -2
- package/project/.sdk/src/cmp/clojure/ReadmeTopTest_clojure.ts +2 -2
- package/project/.sdk/src/cmp/cpp/ReadmeEntity_cpp.ts +2 -2
- package/project/.sdk/src/cmp/cpp/ReadmeHowto_cpp.ts +2 -2
- package/project/.sdk/src/cmp/cpp/ReadmeQuick_cpp.ts +4 -4
- package/project/.sdk/src/cmp/cpp/ReadmeRef_cpp.ts +3 -3
- package/project/.sdk/src/cmp/cpp/ReadmeTopQuick_cpp.ts +2 -2
- package/project/.sdk/src/cmp/cpp/ReadmeTopTest_cpp.ts +2 -2
- package/project/.sdk/src/cmp/cpp/TestDirect_cpp.ts +2 -6
- package/project/.sdk/src/cmp/cpp/TestEntity_cpp.ts +51 -3
- package/project/.sdk/src/cmp/csharp/ReadmeEntity_csharp.ts +2 -2
- package/project/.sdk/src/cmp/csharp/ReadmeHowto_csharp.ts +2 -2
- package/project/.sdk/src/cmp/csharp/ReadmeQuick_csharp.ts +5 -5
- package/project/.sdk/src/cmp/csharp/ReadmeRef_csharp.ts +3 -3
- package/project/.sdk/src/cmp/csharp/ReadmeTopQuick_csharp.ts +3 -3
- package/project/.sdk/src/cmp/csharp/ReadmeTopTest_csharp.ts +2 -2
- package/project/.sdk/src/cmp/csharp/TestDirect_csharp.ts +41 -19
- package/project/.sdk/src/cmp/csharp/TestEntity_csharp.ts +105 -27
- package/project/.sdk/src/cmp/elixir/ReadmeEntity_elixir.ts +2 -2
- package/project/.sdk/src/cmp/elixir/ReadmeHowto_elixir.ts +2 -2
- package/project/.sdk/src/cmp/elixir/ReadmeQuick_elixir.ts +4 -4
- package/project/.sdk/src/cmp/elixir/ReadmeRef_elixir.ts +3 -3
- package/project/.sdk/src/cmp/elixir/ReadmeTopQuick_elixir.ts +2 -2
- package/project/.sdk/src/cmp/elixir/ReadmeTopTest_elixir.ts +2 -2
- package/project/.sdk/src/cmp/go/EntityOperation_go.ts +2 -2
- package/project/.sdk/src/cmp/go/Entity_go.ts +5 -4
- package/project/.sdk/src/cmp/go/MainEntity_go.ts +1 -1
- package/project/.sdk/src/cmp/go/Main_go.ts +9 -5
- package/project/.sdk/src/cmp/go/PrepareAuth_go.ts +24 -15
- package/project/.sdk/src/cmp/go/ReadmeEntity_go.ts +2 -2
- package/project/.sdk/src/cmp/go/ReadmeHowto_go.ts +2 -2
- package/project/.sdk/src/cmp/go/ReadmeModel_go.ts +3 -3
- package/project/.sdk/src/cmp/go/ReadmeQuick_go.ts +4 -4
- package/project/.sdk/src/cmp/go/ReadmeRef_go.ts +4 -4
- package/project/.sdk/src/cmp/go/ReadmeTopTest_go.ts +2 -2
- package/project/.sdk/src/cmp/go/TestDirect_go.ts +61 -26
- package/project/.sdk/src/cmp/go/TestEntity_go.ts +115 -32
- package/project/.sdk/src/cmp/go-cli/fragment/words.fragment.go +1 -1
- package/project/.sdk/src/cmp/go-mcp/fragment/tools.fragment.go +1 -1
- package/project/.sdk/src/cmp/java/ReadmeEntity_java.ts +2 -2
- package/project/.sdk/src/cmp/java/ReadmeHowto_java.ts +2 -2
- package/project/.sdk/src/cmp/java/ReadmeQuick_java.ts +5 -5
- package/project/.sdk/src/cmp/java/ReadmeRef_java.ts +3 -3
- package/project/.sdk/src/cmp/java/ReadmeTopQuick_java.ts +3 -3
- package/project/.sdk/src/cmp/java/ReadmeTopTest_java.ts +2 -2
- package/project/.sdk/src/cmp/java/TestDirect_java.ts +40 -20
- package/project/.sdk/src/cmp/java/TestEntity_java.ts +107 -26
- package/project/.sdk/src/cmp/js/ReadmeEntity_js.ts +2 -2
- package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +2 -2
- package/project/.sdk/src/cmp/js/ReadmeQuick_js.ts +4 -4
- package/project/.sdk/src/cmp/js/ReadmeRef_js.ts +3 -3
- package/project/.sdk/src/cmp/js/ReadmeTopTest_js.ts +2 -2
- package/project/.sdk/src/cmp/js/TestDirect_js.ts +68 -13
- package/project/.sdk/src/cmp/js/TestEntity_js.ts +46 -4
- package/project/.sdk/src/cmp/kotlin/ReadmeEntity_kotlin.ts +2 -2
- package/project/.sdk/src/cmp/kotlin/ReadmeHowto_kotlin.ts +2 -2
- package/project/.sdk/src/cmp/kotlin/ReadmeQuick_kotlin.ts +5 -5
- package/project/.sdk/src/cmp/kotlin/ReadmeRef_kotlin.ts +3 -3
- package/project/.sdk/src/cmp/kotlin/ReadmeTopQuick_kotlin.ts +3 -3
- package/project/.sdk/src/cmp/kotlin/ReadmeTopTest_kotlin.ts +2 -2
- package/project/.sdk/src/cmp/kotlin/TestDirect_kotlin.ts +41 -21
- package/project/.sdk/src/cmp/kotlin/TestEntity_kotlin.ts +99 -22
- package/project/.sdk/src/cmp/lua/ReadmeEntity_lua.ts +2 -2
- package/project/.sdk/src/cmp/lua/ReadmeHowto_lua.ts +2 -2
- package/project/.sdk/src/cmp/lua/ReadmeQuick_lua.ts +4 -4
- package/project/.sdk/src/cmp/lua/ReadmeRef_lua.ts +3 -3
- package/project/.sdk/src/cmp/lua/ReadmeTopQuick_lua.ts +3 -3
- package/project/.sdk/src/cmp/lua/ReadmeTopTest_lua.ts +2 -2
- package/project/.sdk/src/cmp/lua/TestDirect_lua.ts +40 -16
- package/project/.sdk/src/cmp/lua/TestEntity_lua.ts +108 -30
- package/project/.sdk/src/cmp/ocaml/ReadmeEntity_ocaml.ts +2 -2
- package/project/.sdk/src/cmp/ocaml/ReadmeHowto_ocaml.ts +2 -2
- package/project/.sdk/src/cmp/ocaml/ReadmeQuick_ocaml.ts +4 -4
- package/project/.sdk/src/cmp/ocaml/ReadmeRef_ocaml.ts +3 -3
- package/project/.sdk/src/cmp/ocaml/ReadmeTopQuick_ocaml.ts +2 -2
- package/project/.sdk/src/cmp/ocaml/ReadmeTopTest_ocaml.ts +2 -2
- package/project/.sdk/src/cmp/perl/ReadmeEntity_perl.ts +2 -2
- package/project/.sdk/src/cmp/perl/ReadmeHowto_perl.ts +2 -2
- package/project/.sdk/src/cmp/perl/ReadmeQuick_perl.ts +4 -4
- package/project/.sdk/src/cmp/perl/ReadmeRef_perl.ts +3 -3
- package/project/.sdk/src/cmp/perl/ReadmeTopQuick_perl.ts +2 -2
- package/project/.sdk/src/cmp/perl/ReadmeTopTest_perl.ts +2 -2
- package/project/.sdk/src/cmp/perl/TestDirect_perl.ts +35 -16
- package/project/.sdk/src/cmp/perl/TestEntity_perl.ts +98 -22
- package/project/.sdk/src/cmp/php/ReadmeEntity_php.ts +2 -2
- package/project/.sdk/src/cmp/php/ReadmeHowto_php.ts +2 -2
- package/project/.sdk/src/cmp/php/ReadmeQuick_php.ts +4 -4
- package/project/.sdk/src/cmp/php/ReadmeRef_php.ts +3 -3
- package/project/.sdk/src/cmp/php/ReadmeTopQuick_php.ts +2 -2
- package/project/.sdk/src/cmp/php/ReadmeTopTest_php.ts +2 -2
- package/project/.sdk/src/cmp/php/TestDirect_php.ts +33 -16
- package/project/.sdk/src/cmp/php/TestEntity_php.ts +98 -29
- package/project/.sdk/src/cmp/py/ReadmeEntity_py.ts +2 -2
- package/project/.sdk/src/cmp/py/ReadmeHowto_py.ts +2 -2
- package/project/.sdk/src/cmp/py/ReadmeQuick_py.ts +4 -4
- package/project/.sdk/src/cmp/py/ReadmeRef_py.ts +3 -3
- package/project/.sdk/src/cmp/py/ReadmeTopQuick_py.ts +2 -2
- package/project/.sdk/src/cmp/py/ReadmeTopTest_py.ts +2 -2
- package/project/.sdk/src/cmp/py/TestDirect_py.ts +39 -16
- package/project/.sdk/src/cmp/py/TestEntity_py.ts +90 -27
- package/project/.sdk/src/cmp/rb/ReadmeEntity_rb.ts +2 -2
- package/project/.sdk/src/cmp/rb/ReadmeHowto_rb.ts +2 -2
- package/project/.sdk/src/cmp/rb/ReadmeQuick_rb.ts +4 -4
- package/project/.sdk/src/cmp/rb/ReadmeRef_rb.ts +3 -3
- package/project/.sdk/src/cmp/rb/ReadmeTopQuick_rb.ts +2 -2
- package/project/.sdk/src/cmp/rb/ReadmeTopTest_rb.ts +2 -2
- package/project/.sdk/src/cmp/rb/TestClean_rb.ts +1 -1
- package/project/.sdk/src/cmp/rb/TestDirect_rb.ts +33 -16
- package/project/.sdk/src/cmp/rb/TestEntity_rb.ts +90 -25
- package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +3 -3
- package/project/.sdk/src/cmp/rust/EntityOperation_rust.ts +1 -1
- package/project/.sdk/src/cmp/rust/Main_rust.ts +3 -1
- package/project/.sdk/src/cmp/rust/ReadmeEntity_rust.ts +2 -2
- package/project/.sdk/src/cmp/rust/ReadmeHowto_rust.ts +3 -3
- package/project/.sdk/src/cmp/rust/ReadmeModel_rust.ts +1 -1
- package/project/.sdk/src/cmp/rust/ReadmeQuick_rust.ts +5 -5
- package/project/.sdk/src/cmp/rust/ReadmeRef_rust.ts +4 -4
- package/project/.sdk/src/cmp/rust/ReadmeTopQuick_rust.ts +3 -3
- package/project/.sdk/src/cmp/rust/ReadmeTopTest_rust.ts +3 -3
- package/project/.sdk/src/cmp/rust/TestClean_rust.ts +1 -1
- package/project/.sdk/src/cmp/rust/TestDirect_rust.ts +40 -12
- package/project/.sdk/src/cmp/rust/TestEntity_rust.ts +109 -26
- package/project/.sdk/src/cmp/rust/fragment/Entity.fragment.rs +2 -2
- package/project/.sdk/src/cmp/scala/ReadmeEntity_scala.ts +2 -2
- package/project/.sdk/src/cmp/scala/ReadmeHowto_scala.ts +2 -2
- package/project/.sdk/src/cmp/scala/ReadmeQuick_scala.ts +5 -5
- package/project/.sdk/src/cmp/scala/ReadmeRef_scala.ts +3 -3
- package/project/.sdk/src/cmp/scala/ReadmeTopQuick_scala.ts +3 -3
- package/project/.sdk/src/cmp/scala/ReadmeTopTest_scala.ts +2 -2
- package/project/.sdk/src/cmp/scala/TestDirect_scala.ts +2 -6
- package/project/.sdk/src/cmp/scala/TestEntity_scala.ts +36 -7
- package/project/.sdk/src/cmp/swift/ReadmeEntity_swift.ts +2 -2
- package/project/.sdk/src/cmp/swift/ReadmeHowto_swift.ts +2 -2
- package/project/.sdk/src/cmp/swift/ReadmeQuick_swift.ts +5 -5
- package/project/.sdk/src/cmp/swift/ReadmeRef_swift.ts +3 -3
- package/project/.sdk/src/cmp/swift/ReadmeTopQuick_swift.ts +2 -2
- package/project/.sdk/src/cmp/swift/ReadmeTopTest_swift.ts +2 -2
- package/project/.sdk/src/cmp/ts/ReadmeEntity_ts.ts +2 -2
- package/project/.sdk/src/cmp/ts/ReadmeExamplesTest_ts.ts +49 -19
- package/project/.sdk/src/cmp/ts/ReadmeHowto_ts.ts +2 -2
- package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +4 -4
- package/project/.sdk/src/cmp/ts/ReadmeRef_ts.ts +3 -3
- package/project/.sdk/src/cmp/ts/ReadmeTopTest_ts.ts +3 -3
- package/project/.sdk/src/cmp/ts/TestDirect_ts.ts +54 -23
- package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +49 -4
- package/project/.sdk/src/cmp/zig/ReadmeEntity_zig.ts +2 -2
- package/project/.sdk/src/cmp/zig/ReadmeHowto_zig.ts +2 -2
- package/project/.sdk/src/cmp/zig/ReadmeQuick_zig.ts +4 -4
- package/project/.sdk/src/cmp/zig/ReadmeRef_zig.ts +3 -3
- package/project/.sdk/src/cmp/zig/ReadmeTopQuick_zig.ts +2 -2
- package/project/.sdk/src/cmp/zig/ReadmeTopTest_zig.ts +2 -2
- package/project/.sdk/tm/c/core/sdk.h +2 -2
- package/project/.sdk/tm/c/tests/primary_utility_test.c +37 -0
- package/project/.sdk/tm/c/utility/fetcher.c +31 -1
- package/project/.sdk/tm/c/utility/make_url.c +6 -2
- package/project/.sdk/tm/clojure/src/sdk/core.clj +21 -3
- package/project/.sdk/tm/clojure/test/sdk/test/pipeline.clj +34 -0
- package/project/.sdk/tm/cpp/test/primary_utility_test.cpp +37 -0
- package/project/.sdk/tm/cpp/utility/pipeline.hpp +28 -2
- package/project/.sdk/tm/csharp/test/PrimaryUtilityTest.cs +40 -0
- package/project/.sdk/tm/csharp/utility/Fetcher.cs +27 -0
- package/project/.sdk/tm/csharp/utility/MakeUrl.cs +7 -2
- package/project/.sdk/tm/elixir/lib/projectname/utility.ex +30 -3
- package/project/.sdk/tm/elixir/test/pipeline_test.exs +23 -0
- package/project/.sdk/tm/go/core/helpers.go +1 -1
- package/project/.sdk/tm/go/core/types.go +9 -1
- package/project/.sdk/tm/go/test/feature_corpus_test.go +3 -4
- package/project/.sdk/tm/go/test/primary_utility_test.go +28 -0
- package/project/.sdk/tm/go/utility/fetcher.go +26 -0
- package/project/.sdk/tm/go/utility/make_url.go +5 -2
- package/project/.sdk/tm/java/test/FeatureCorpusTest.java +4 -5
- package/project/.sdk/tm/java/test/PrimaryUtilityTest.java +49 -0
- package/project/.sdk/tm/java/utility/Fetcher.java +24 -0
- package/project/.sdk/tm/java/utility/MakeUrl.java +6 -2
- package/project/.sdk/tm/js/src/utility/FetcherUtility.js +24 -0
- package/project/.sdk/tm/js/src/utility/MakeUrlUtility.js +6 -2
- package/project/.sdk/tm/js/test/feature/Corpus.test.js +7 -6
- package/project/.sdk/tm/js/test/live-entity.js +18 -6
- package/project/.sdk/tm/js/test/live-runner.js +15 -3
- package/project/.sdk/tm/js/test/utility/PrimaryUtility.test.js +25 -0
- package/project/.sdk/tm/kotlin/test/PrimaryUtilityTest.kt +48 -0
- package/project/.sdk/tm/kotlin/utility/Fetcher.kt +20 -0
- package/project/.sdk/tm/kotlin/utility/MakeSpecUrl.kt +6 -2
- package/project/.sdk/tm/lua/test/pipeline_test.lua +27 -0
- package/project/.sdk/tm/lua/test/primary_utility_test.lua +36 -0
- package/project/.sdk/tm/lua/utility/fetcher.lua +31 -0
- package/project/.sdk/tm/lua/utility/make_url.lua +6 -2
- package/project/.sdk/tm/ocaml/Makefile +5 -1
- package/project/.sdk/tm/ocaml/sdk_runtime.ml +36 -4
- package/project/.sdk/tm/ocaml/test/t_pipeline.ml +22 -0
- package/project/.sdk/tm/perl/t/primary_utility.t +22 -0
- package/project/.sdk/tm/perl/utility/fetcher.pm +18 -0
- package/project/.sdk/tm/perl/utility/make_url.pm +4 -2
- package/project/.sdk/tm/php/test/FeatureCorpusTest.php +6 -5
- package/project/.sdk/tm/php/test/PipelineTest.php +31 -7
- package/project/.sdk/tm/php/utility/Fetcher.php +34 -27
- package/project/.sdk/tm/php/utility/MakeOptions.php +2 -1
- package/project/.sdk/tm/php/utility/MakeUrl.php +6 -2
- package/project/.sdk/tm/py/pkg/utility/fetcher.py +23 -0
- package/project/.sdk/tm/py/pkg/utility/make_url.py +5 -2
- package/project/.sdk/tm/py/test/test_feature_corpus.py +5 -5
- package/project/.sdk/tm/py/test/test_primary_utility.py +21 -0
- package/project/.sdk/tm/rb/core/context.rb +1 -1
- package/project/.sdk/tm/rb/core/error.rb +20 -1
- package/project/.sdk/tm/rb/test/feature_corpus_test.rb +4 -5
- package/project/.sdk/tm/rb/test/feature_test.rb +2 -2
- package/project/.sdk/tm/rb/test/omni.rb +1 -1
- package/project/.sdk/tm/rb/test/pipeline_test.rb +19 -2
- package/project/.sdk/tm/rb/test/primary_utility_test.rb +28 -1
- package/project/.sdk/tm/rb/utility/fetcher.rb +20 -1
- package/project/.sdk/tm/rb/utility/make_error.rb +1 -1
- package/project/.sdk/tm/rb/utility/make_url.rb +4 -2
- package/project/.sdk/tm/rust/core/helpers.rs +1 -1
- package/project/.sdk/tm/rust/core/types.rs +2 -2
- package/project/.sdk/tm/rust/tests/primary_utility_test.rs +34 -0
- package/project/.sdk/tm/rust/utility/fetcher.rs +27 -0
- package/project/.sdk/tm/rust/utility/make_url.rs +7 -2
- package/project/.sdk/tm/scala/sdktest/SdkTestMain.scala +51 -1
- package/project/.sdk/tm/scala/utility/Fetcher.scala +16 -0
- package/project/.sdk/tm/scala/utility/Make.scala +6 -2
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Fetcher.swift +24 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Make.swift +6 -2
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/PrimaryUtilityTest.swift +34 -0
- package/project/.sdk/tm/ts/src/utility/FetcherUtility.ts +24 -0
- package/project/.sdk/tm/ts/src/utility/MakeUrlUtility.ts +6 -2
- package/project/.sdk/tm/ts/test/feature/Corpus.test.ts +7 -6
- package/project/.sdk/tm/ts/test/live-entity.ts +20 -5
- package/project/.sdk/tm/ts/test/live-runner.ts +17 -3
- package/project/.sdk/tm/ts/test/utility/PrimaryUtility.test.ts +25 -0
- package/project/.sdk/tm/zig/core/utility.zig +30 -3
- package/project/.sdk/tm/zig/test/primary_utility_test.zig +28 -0
- package/project/sdkgen-package.json +1 -1
- package/src/cmp/ReadmeTop.ts +3 -3
- package/src/helpers/opExample.ts +16 -1
- package/src/helpers/opShape.ts +64 -30
- package/src/helpers/pointPath.ts +19 -0
- package/src/helpers/testPolicy.ts +316 -2
- package/src/sdkgen.ts +37 -5
|
@@ -4,10 +4,16 @@ import { runLiveSteps, settleLiveReport, LiveBlocked, LiveEmpty } from './live-r
|
|
|
4
4
|
import type { LiveSettle } from './live-runner'
|
|
5
5
|
import { isControlSkipped, liveDelayMs } from './utility'
|
|
6
6
|
|
|
7
|
+
const routeOf = (point: any) => String(point.m).toUpperCase() + ' ' + point.o
|
|
8
|
+
|
|
9
|
+
const scalarOf = (value: any) => ['string', 'number', 'boolean'].includes(typeof value) ? value : undefined
|
|
10
|
+
|
|
7
11
|
// The offline flow keeps its deterministic fixture assertions. Live flows
|
|
8
12
|
// resolve real prerequisites per operation and collect failures until done.
|
|
13
|
+
// `excluded` names, by step id, the steps this run leaves out, and why.
|
|
9
14
|
async function runLiveEntity(
|
|
10
15
|
setup: any, entity: any, flow: any, accessor: string, facts: any = {}, settle: LiveSettle = {},
|
|
16
|
+
excluded: Record<string, string> = {},
|
|
11
17
|
) {
|
|
12
18
|
const { client, transport } = setup
|
|
13
19
|
// A step switched off only because the offline call reaches no route of
|
|
@@ -26,11 +32,12 @@ async function runLiveEntity(
|
|
|
26
32
|
const report = await runLiveSteps(steps.map((step, index) => {
|
|
27
33
|
const ref = step.i?.ref || entity.name + '_ref01'
|
|
28
34
|
const op = step.o
|
|
29
|
-
const
|
|
35
|
+
const id = entity.name + '.' + op + '.' + index
|
|
36
|
+
const control = isControlSkipped('entityOp', entity.name + '.' + op, 'live')
|
|
30
37
|
return {
|
|
31
|
-
id
|
|
38
|
+
id,
|
|
32
39
|
cleanup: op === 'remove' || (step.v || []).some((v: any) => v.apply === 'ItemNotExists'),
|
|
33
|
-
excluded:
|
|
40
|
+
excluded: control.skip ? control.reason || 'Excluded by test control' : excluded[id],
|
|
34
41
|
run: async (context: any) => {
|
|
35
42
|
transport.enter(context)
|
|
36
43
|
const points = (entity.op?.[op]?.points || []).filter((point: any) => false !== point.a)
|
|
@@ -59,6 +66,14 @@ async function runLiveEntity(
|
|
|
59
66
|
const id = loaded[idField] ?? loaded.id
|
|
60
67
|
if (undefined !== id) input.id = id
|
|
61
68
|
}
|
|
69
|
+
// A load of a known record takes the route the offline flow takes,
|
|
70
|
+
// and the parameters that flow reads from the record.
|
|
71
|
+
for (const [name, field] of Object.entries(step.record || {})) {
|
|
72
|
+
const value = scalarOf(loaded?.[field as string])
|
|
73
|
+
if (undefined !== value) input[name] = value
|
|
74
|
+
}
|
|
75
|
+
const ordered = null == step.route ? points : [...points].sort((a: any, b: any) =>
|
|
76
|
+
Number(step.route !== routeOf(a)) - Number(step.route !== routeOf(b)))
|
|
62
77
|
// A nested route needing a parent id must not hide an available
|
|
63
78
|
// parameter-free route for the same operation. Use the first viable
|
|
64
79
|
// candidate. An action route is taken only when the step names its
|
|
@@ -67,7 +82,7 @@ async function runLiveEntity(
|
|
|
67
82
|
let selected: any
|
|
68
83
|
const unusable: { route: string, missing: string[] }[] = []
|
|
69
84
|
const actionOnly = points.every((point: any) => null != point.q?.$action)
|
|
70
|
-
for (const point of
|
|
85
|
+
for (const point of ordered) {
|
|
71
86
|
const action = point.q?.$action
|
|
72
87
|
if (null == input.$action ? null != action && !actionOnly : action !== input.$action) continue
|
|
73
88
|
const candidate = null == action ? { ...input } : { ...input, $action: action }
|
|
@@ -77,7 +92,7 @@ async function runLiveEntity(
|
|
|
77
92
|
for (const arg of [...params, ...query]) {
|
|
78
93
|
if (undefined !== candidate[arg.n] && null !== candidate[arg.n]) continue
|
|
79
94
|
const key = arg.n === 'id' ? entity.name + '01' : arg.n.replace(/_id$/, '') + '01'
|
|
80
|
-
const value = setup.idmap[key] ?? setup.idmap[arg.n] ?? loaded?.[arg.n] ?? arg.ex
|
|
95
|
+
const value = setup.idmap[key] ?? setup.idmap[arg.n] ?? scalarOf(loaded?.[arg.n]) ?? arg.ex
|
|
81
96
|
if (undefined !== value && null !== value) candidate[arg.n] = value
|
|
82
97
|
else if (arg.r !== false) missing.push(arg.n)
|
|
83
98
|
}
|
|
@@ -40,6 +40,9 @@ type LiveStep = {
|
|
|
40
40
|
|
|
41
41
|
class LiveBlocked extends Error {}
|
|
42
42
|
|
|
43
|
+
// The SDK fetcher's code for a write a GET-only run refused unsent.
|
|
44
|
+
const GETONLY_CODE = 'fetch_getonly_block'
|
|
45
|
+
|
|
43
46
|
// The account answered, but holds no record the step could act on.
|
|
44
47
|
class LiveEmpty extends Error {}
|
|
45
48
|
|
|
@@ -119,10 +122,12 @@ async function runLiveSteps(
|
|
|
119
122
|
record({ id: step.id, state: 'passed', attempted, requests })
|
|
120
123
|
}
|
|
121
124
|
catch (error) {
|
|
125
|
+
const refused = GETONLY_CODE === (error as any)?.code
|
|
122
126
|
const state: LiveState = error instanceof LiveEmpty ? 'empty'
|
|
123
|
-
: error instanceof LiveBlocked ? 'blocked' : 'failed'
|
|
127
|
+
: error instanceof LiveBlocked || refused ? 'blocked' : 'failed'
|
|
124
128
|
record({ id: step.id, state, attempted, requests,
|
|
125
|
-
reason:
|
|
129
|
+
reason: refused ? 'Refused by the GET-only guard' :
|
|
130
|
+
'failed' === state ? failureReason(error) : (error as Error).message })
|
|
126
131
|
}
|
|
127
132
|
if (attempted && (options.delayMs || 0) > 0) {
|
|
128
133
|
await new Promise(resolve => setTimeout(resolve, options.delayMs))
|
|
@@ -173,8 +178,12 @@ function assertLiveReport(report: LiveReport): void {
|
|
|
173
178
|
}
|
|
174
179
|
}
|
|
175
180
|
|
|
176
|
-
// An account with no record for a step to read skips in either mode
|
|
181
|
+
// An account with no record for a step to read skips in either mode, as
|
|
182
|
+
// does a run that leaves out every step.
|
|
177
183
|
function settleLiveReport(report: LiveReport, settle: LiveSettle = {}): void {
|
|
184
|
+
if (0 < report.planned && report.excluded === report.planned && null != settle.t) {
|
|
185
|
+
return settle.t.skip('Live coverage incomplete: ' + liveSummary(report))
|
|
186
|
+
}
|
|
178
187
|
if (liveIncomplete(report)) {
|
|
179
188
|
if (false !== settle.strict || null == settle.t) return assertLiveReport(report)
|
|
180
189
|
return settle.t.skip('Live coverage incomplete (main.kit.test.live.strict is false): ' +
|
|
@@ -199,6 +208,11 @@ function createLiveTransport(timeoutMs = 30000) {
|
|
|
199
208
|
enter(next: LiveContext) { context = next },
|
|
200
209
|
fetch: async (input: any, init?: any) => {
|
|
201
210
|
const url = new URL(String(input))
|
|
211
|
+
const method = String(init?.method || 'GET').toUpperCase()
|
|
212
|
+
if ('TRUE' === process.env.VOXGIG_GETONLY_GUARD && 'GET' !== method) {
|
|
213
|
+
throw Object.assign(new Error('[GET-ONLY GUARD] blocked ' + method + ' ' + url.pathname),
|
|
214
|
+
{ code: GETONLY_CODE })
|
|
215
|
+
}
|
|
202
216
|
// A credential can travel as the agent (auth.name), so only whether
|
|
203
217
|
// the request carried one is recorded, never its value.
|
|
204
218
|
const request: LiveRequest = {
|
|
@@ -499,6 +499,31 @@ describe('PrimaryUtility', async () => {
|
|
|
499
499
|
})
|
|
500
500
|
|
|
501
501
|
|
|
502
|
+
// Nothing listens on port 9: a request the guard let through fails there.
|
|
503
|
+
test('fetcher-getonly-guard', async () => {
|
|
504
|
+
const liveClient = new (SDK as any)({ base: 'http://127.0.0.1:9' })
|
|
505
|
+
const liveUtility = liveClient.utility()
|
|
506
|
+
const ctx = liveUtility.makeContext({ opname: 'create' }, liveClient._rootctx)
|
|
507
|
+
ctx.client = liveClient
|
|
508
|
+
const url = 'http://127.0.0.1:9/planet/p1?apikey=GUARDKEY01'
|
|
509
|
+
|
|
510
|
+
const prior = process.env.VOXGIG_GETONLY_GUARD
|
|
511
|
+
process.env.VOXGIG_GETONLY_GUARD = 'TRUE'
|
|
512
|
+
try {
|
|
513
|
+
const refused = await liveUtility.fetcher(ctx, url, { method: 'POST', headers: {} })
|
|
514
|
+
equal(refused?.code, 'fetch_getonly_block')
|
|
515
|
+
ok(refused.message.includes('[GET-ONLY GUARD] blocked POST /planet/p1'), refused.message)
|
|
516
|
+
ok(!refused.message.includes('GUARDKEY01'))
|
|
517
|
+
|
|
518
|
+
await assert.rejects(liveUtility.fetcher(ctx, url, { method: 'GET', headers: {} }))
|
|
519
|
+
}
|
|
520
|
+
finally {
|
|
521
|
+
if (undefined === prior) delete process.env.VOXGIG_GETONLY_GUARD
|
|
522
|
+
else process.env.VOXGIG_GETONLY_GUARD = prior
|
|
523
|
+
}
|
|
524
|
+
})
|
|
525
|
+
|
|
526
|
+
|
|
502
527
|
test('makeError-no-throw', () => {
|
|
503
528
|
const ctx = makeFullCtx()
|
|
504
529
|
ctx.ctrl.throw = false
|
|
@@ -10,6 +10,7 @@ const std = @import("std");
|
|
|
10
10
|
const vs = @import("voxgig-struct");
|
|
11
11
|
const h = @import("helpers.zig");
|
|
12
12
|
const err = @import("error.zig");
|
|
13
|
+
const mem = @import("mem.zig");
|
|
13
14
|
const types = @import("types.zig");
|
|
14
15
|
const ctxmod = @import("context.zig");
|
|
15
16
|
const control_mod = @import("control.zig");
|
|
@@ -1188,14 +1189,19 @@ pub fn make_url_util(ctx: *Context) E![]const u8 {
|
|
|
1188
1189
|
h.vstr(spec.suffix),
|
|
1189
1190
|
}), "/", true) catch "";
|
|
1190
1191
|
|
|
1191
|
-
// A route the definition ends with a slash keeps it
|
|
1192
|
-
//
|
|
1192
|
+
// A route the definition ends with a slash keeps it, for a Django REST server,
|
|
1193
|
+
// and a host with no path takes /, or luasocket reads a query as the host.
|
|
1193
1194
|
const orig = h.getp(ctx.point, "orig");
|
|
1194
1195
|
if (orig == .string and std.mem.endsWith(u8, orig.string, "/") and spec.suffix.len == 0 and
|
|
1195
1196
|
!std.mem.endsWith(u8, url, "/"))
|
|
1196
1197
|
{
|
|
1197
1198
|
url = std.mem.concat(h.A(), u8, &.{ url, "/" }) catch url;
|
|
1198
1199
|
}
|
|
1200
|
+
if (std.mem.indexOf(u8, url, "://")) |authority| {
|
|
1201
|
+
if (0 < authority and std.mem.indexOfAny(u8, url[authority + 3 ..], "/?#") == null) {
|
|
1202
|
+
url = std.mem.concat(h.A(), u8, &.{ url, "/" }) catch url;
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1199
1205
|
|
|
1200
1206
|
const resmatch = h.omap();
|
|
1201
1207
|
|
|
@@ -2300,8 +2306,29 @@ pub fn fetcher_util(ctx: *Context, fullurl: []const u8, fetchdef: Value) E!Value
|
|
|
2300
2306
|
return ctx.fail("fetch_invalid", "system.fetch is not a valid function");
|
|
2301
2307
|
}
|
|
2302
2308
|
|
|
2309
|
+
// A GET-only live run refuses any other method before it is sent. The error
|
|
2310
|
+
// names the path alone: the query can carry a credential.
|
|
2311
|
+
fn getonly_refusal(fullurl: []const u8, fetchdef: Value) ?[]const u8 {
|
|
2312
|
+
const environ = mem.threaded().environ.process_environ;
|
|
2313
|
+
const flag = environ.getAlloc(h.A(), "VOXGIG_GETONLY_GUARD") catch return null;
|
|
2314
|
+
if (!std.mem.eql(u8, flag, "TRUE")) return null;
|
|
2315
|
+
const raw = h.get_str(fetchdef, "method") orelse "";
|
|
2316
|
+
var buf: [16]u8 = undefined;
|
|
2317
|
+
const method = if (raw.len == 0) "GET" else std.ascii.upperString(buf[0..@min(raw.len, buf.len)], raw[0..@min(raw.len, buf.len)]);
|
|
2318
|
+
if (std.mem.eql(u8, method, "GET")) return null;
|
|
2319
|
+
var rest = fullurl;
|
|
2320
|
+
if (std.mem.indexOf(u8, rest, "://")) |i| {
|
|
2321
|
+
rest = rest[i + 3 ..];
|
|
2322
|
+
rest = rest[(std.mem.indexOfAny(u8, rest, "/?#") orelse rest.len)..];
|
|
2323
|
+
}
|
|
2324
|
+
const path = rest[0..(std.mem.indexOfAny(u8, rest, "?#") orelse rest.len)];
|
|
2325
|
+
return fmt("[GET-ONLY GUARD] blocked {s} {s}", .{ method, if (path.len == 0) "/" else path });
|
|
2326
|
+
}
|
|
2327
|
+
|
|
2303
2328
|
fn default_http_fetch(ctx: *Context, fullurl: []const u8, fetchdef: Value) E!Value {
|
|
2304
|
-
|
|
2329
|
+
if (getonly_refusal(fullurl, fetchdef)) |msg| {
|
|
2330
|
+
return ctx.fail("fetch_getonly_block", msg);
|
|
2331
|
+
}
|
|
2305
2332
|
// Live HTTP transport. The generated test suite runs entirely against the
|
|
2306
2333
|
// offline mock (the `test` feature), so this path is not exercised by
|
|
2307
2334
|
// tests; a real deployment injects `system.fetch`. A std.http.Client
|
|
@@ -340,6 +340,34 @@ test "primary fetcher blocked test mode" {
|
|
|
340
340
|
try testing.expect(std.ascii.indexOfIgnoreCase(ctx.pending_err.?.msg, "blocked") != null);
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
+
// Nothing listens on port 9; this target has no transport of its own, so a
|
|
344
|
+
// request the guard let through fails as fetch_transport. The environment
|
|
345
|
+
// std captured at startup is swapped for one that sets the flag.
|
|
346
|
+
test "primary fetcher getonly guard" {
|
|
347
|
+
const threaded = std.Io.Threaded.global_single_threaded;
|
|
348
|
+
const saved = threaded.environ.process_environ;
|
|
349
|
+
if (@TypeOf(saved.block) != std.process.Environ.PosixBlock) return error.SkipZigTest;
|
|
350
|
+
const flagged = [_:null]?[*:0]const u8{"VOXGIG_GETONLY_GUARD=TRUE"};
|
|
351
|
+
threaded.environ.process_environ = .{ .block = .{ .slice = &flagged } };
|
|
352
|
+
defer threaded.environ.process_environ = saved;
|
|
353
|
+
|
|
354
|
+
const client = sdk.SDK.new(h.jo(&.{.{ "base", h.vstr("http://127.0.0.1:9") }}));
|
|
355
|
+
const utility = client.get_utility();
|
|
356
|
+
const ctx = utility.make_context(sdk.CtxSpec{ .opname = "create", .client = client, .utility = utility }, client.get_root_ctx());
|
|
357
|
+
const url = "http://127.0.0.1:9/planet/p1?apikey=GUARDKEY01";
|
|
358
|
+
|
|
359
|
+
const post = h.jo(&.{ .{ "method", h.vstr("POST") }, .{ "headers", h.omap() } });
|
|
360
|
+
try testing.expectError(error.Sdk, utility.fetch(ctx, url, post));
|
|
361
|
+
const refused = ctx.pending_err.?;
|
|
362
|
+
try testing.expectEqualStrings("fetch_getonly_block", refused.code);
|
|
363
|
+
try testing.expect(std.mem.indexOf(u8, refused.msg, "[GET-ONLY GUARD] blocked POST /planet/p1") != null);
|
|
364
|
+
try testing.expect(std.mem.indexOf(u8, refused.msg, "GUARDKEY01") == null);
|
|
365
|
+
|
|
366
|
+
const get = h.jo(&.{ .{ "method", h.vstr("GET") }, .{ "headers", h.omap() } });
|
|
367
|
+
try testing.expectError(error.Sdk, utility.fetch(ctx, url, get));
|
|
368
|
+
try testing.expectEqualStrings("fetch_transport", ctx.pending_err.?.code);
|
|
369
|
+
}
|
|
370
|
+
|
|
343
371
|
test "primary new sdk smoke" {
|
|
344
372
|
const client = sdk.new();
|
|
345
373
|
try testing.expect(std.mem.eql(u8, client.mode, "live"));
|
package/src/cmp/ReadmeTop.ts
CHANGED
|
@@ -13,9 +13,9 @@ import { featureDocs } from './FeatureDocs'
|
|
|
13
13
|
import type { FeatureDoc } from './FeatureDocs'
|
|
14
14
|
|
|
15
15
|
import {
|
|
16
|
-
entityPrimaryOp, entityIdField,
|
|
16
|
+
entityPrimaryOp, entityIdField, entityPath, entityActions,
|
|
17
17
|
} from '../helpers/opShape'
|
|
18
|
-
import { EXAMPLE_LANGS, matchArg, listMatchArg, idLiteral, primaryOpCall } from '../helpers/opExample'
|
|
18
|
+
import { EXAMPLE_LANGS, matchArg, listMatchArg, idLiteral, primaryOpCall, requestExampleItems } from '../helpers/opExample'
|
|
19
19
|
import { mcpTools, MCP_WRITE_OPS } from '../helpers/mcpTools'
|
|
20
20
|
import type { ExampleLang, PrimaryCall } from '../helpers/opExample'
|
|
21
21
|
import { canonScalarKey } from '../helpers/canonType'
|
|
@@ -307,7 +307,7 @@ ${aboutMd.trim()}
|
|
|
307
307
|
// server-assigned on a normal create, but an op whose id comes from a
|
|
308
308
|
// PATH PARAMETER requires it, and the typed CreateData then rejects a
|
|
309
309
|
// body without it. Same rule as dataArg in helpers/opExample.
|
|
310
|
-
const shapeItems =
|
|
310
|
+
const shapeItems = requestExampleItems(exEnt, primaryOp)
|
|
311
311
|
.filter((it: any) =>
|
|
312
312
|
(it.name !== exIdF && it.name !== 'id') || !it.optional)
|
|
313
313
|
const required = shapeItems.filter((it: any) => !it.optional)
|
package/src/helpers/opExample.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { each } from 'jostraca'
|
|
3
3
|
import { canonScalarKey } from './canonType'
|
|
4
4
|
import { opRequestShape, opParams, selectablePoints, pointRequires } from './opShape'
|
|
5
|
+
import type { OpShapeItem } from './opShape'
|
|
5
6
|
|
|
6
7
|
import { phpEntityAccessor, jsKey, jsQuote, luaKey, luaString } from './naming'
|
|
7
8
|
|
|
@@ -101,6 +102,18 @@ function requiredItems(ent: any, op: string): any[] {
|
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
|
|
105
|
+
// Shape-ordered request members, required as requiredItems decides, so an example reaches a route.
|
|
106
|
+
function requestExampleItems(ent: any, op: string): OpShapeItem[] {
|
|
107
|
+
const required = new Set(requiredItems(ent, op).map((it: any) => it.name))
|
|
108
|
+
return opRequestShape(ent, op).items.map((it: OpShapeItem) => ({ ...it, optional: !required.has(it.name) }))
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
function sendsId(ent: any, op: string, idF: string | null): idF is string {
|
|
113
|
+
return null != idF && opRequestShape(ent, op).items.some((it: OpShapeItem) => it.name === idF)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
|
|
104
117
|
// A load or remove example's members: requiredItems and the id, in shape order.
|
|
105
118
|
function matchExampleItems(ent: any, op: string, idF: string | null): any[] {
|
|
106
119
|
const required: Record<string, any> = Object.create(null)
|
|
@@ -176,7 +189,7 @@ function seededList(lang: LiteralLang, ent: any, idF: string | null, key: string
|
|
|
176
189
|
function dataArg(lang: LiteralLang, ent: any, op: string, idF: string | null): string {
|
|
177
190
|
const routed = new Set(opParams(ent?.op?.[op]).map((p: any) => p.n))
|
|
178
191
|
const addresses = (it: any) => it.name === idF || it.name === 'id' || routed.has(it.name)
|
|
179
|
-
const items =
|
|
192
|
+
const items = requestExampleItems(ent, op)
|
|
180
193
|
.filter((it: any) =>
|
|
181
194
|
(it.name !== idF && it.name !== 'id') || !it.optional)
|
|
182
195
|
const required = items.filter((it: any) => !it.optional)
|
|
@@ -255,6 +268,8 @@ export {
|
|
|
255
268
|
primaryOpCall,
|
|
256
269
|
idLiteral,
|
|
257
270
|
requiredItems,
|
|
271
|
+
requestExampleItems,
|
|
272
|
+
sendsId,
|
|
258
273
|
matchExampleItems,
|
|
259
274
|
matchArg,
|
|
260
275
|
listMatchArg,
|
package/src/helpers/opShape.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { each, names } from 'jostraca'
|
|
3
3
|
import { KIT, getModelPath } from '@voxgig/apidef'
|
|
4
4
|
|
|
5
|
-
import { pointSegments, pointTerminalParam, pointPathKey } from './pointPath'
|
|
5
|
+
import { pointSegments, pointPlaceholders, pointTerminalParam, pointPathKey } from './pointPath'
|
|
6
6
|
import { canonScalarKey } from './canonType'
|
|
7
7
|
|
|
8
8
|
import type { TargetOrigins } from '../action/resolve'
|
|
@@ -140,29 +140,12 @@ function samePath(points: any[]): boolean {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
|
|
143
|
-
// A placeholder inside a literal segment needs a value too.
|
|
144
|
-
function pointParams(point: any): string[] {
|
|
145
|
-
const names: string[] = []
|
|
146
|
-
for (const seg of pointSegments(point)) {
|
|
147
|
-
if (null != seg.var) {
|
|
148
|
-
names.push(String(seg.var))
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
for (const found of String(seg.lit ?? '').matchAll(/\{([^{}/]+)\}/g)) {
|
|
152
|
-
names.push(found[1])
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
return names
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
143
|
// The rule makePoint applies: a lone point is taken as it is, otherwise only
|
|
161
144
|
// a point without an action, and one the call fills.
|
|
162
145
|
function opReachable(op: any, given: string[]): boolean {
|
|
163
146
|
const points: any[] = op && op.points ? each(op.points) : []
|
|
164
147
|
const have = new Set(given)
|
|
165
|
-
const fills = (pt: any) =>
|
|
148
|
+
const fills = (pt: any) => pointPlaceholders(pt).every((name) => have.has(name))
|
|
166
149
|
|
|
167
150
|
if (1 === points.length) {
|
|
168
151
|
return fills(points[0])
|
|
@@ -215,7 +198,9 @@ function opParams(op: any): any[] {
|
|
|
215
198
|
const requiredHere: Record<string, boolean> = Object.create(null)
|
|
216
199
|
params.forEach((p: any) => {
|
|
217
200
|
if (p && null != p.n) {
|
|
218
|
-
|
|
201
|
+
// A route parameter stays required beside an optional query
|
|
202
|
+
// parameter of the same name: the URL cannot be built without it.
|
|
203
|
+
requiredHere[p.n] = true === requiredHere[p.n] || false !== p.r
|
|
219
204
|
if (!seen[p.n]) {
|
|
220
205
|
seen[p.n] = { ...p }
|
|
221
206
|
requiredOnAll[p.n] = 0 === pointIndex
|
|
@@ -537,16 +522,7 @@ function entityClassNames(entityColl: any, fold = false): Record<string, string>
|
|
|
537
522
|
|
|
538
523
|
const key = (name: string) => fold ? name.toLowerCase() : name
|
|
539
524
|
const ents = deriveEntityNames(entityColl)
|
|
540
|
-
|
|
541
|
-
const taken = new Set<string>()
|
|
542
|
-
ents.forEach((e: any) => {
|
|
543
|
-
taken.add(key(e.Name))
|
|
544
|
-
for (const op of CANON_OP_ORDER) {
|
|
545
|
-
if (e.op && e.op[op]) {
|
|
546
|
-
taken.add(key(opTypeName(e.Name, op)))
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
})
|
|
525
|
+
const taken = declaredTypeNames(ents, key)
|
|
550
526
|
|
|
551
527
|
// 2. Assign each class name, avoiding all data types and prior classes.
|
|
552
528
|
const out: Record<string, string> = {}
|
|
@@ -581,6 +557,63 @@ function entityClassName(ent: any, entityColl: any, fold = false): string {
|
|
|
581
557
|
}
|
|
582
558
|
|
|
583
559
|
|
|
560
|
+
function declaredTypeNames(ents: any[], key: (name: string) => string): Set<string> {
|
|
561
|
+
const taken = new Set<string>()
|
|
562
|
+
ents.forEach((e: any) => {
|
|
563
|
+
taken.add(key(e.Name))
|
|
564
|
+
for (const op of CANON_OP_ORDER) {
|
|
565
|
+
if (e.op && e.op[op]) {
|
|
566
|
+
taken.add(key(opTypeName(e.Name, op)))
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
})
|
|
570
|
+
return taken
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
const _ctorNameCache = new WeakMap<object, Record<string, string>>()
|
|
575
|
+
|
|
576
|
+
// Go declares each constructor, New<Class>, in the entity package beside
|
|
577
|
+
// every type, where the class of a new_foo entity is the constructor name of
|
|
578
|
+
// foo. A taken name is numbered, so no constructor meets a type or another.
|
|
579
|
+
function entityConstructorNames(entityColl: any): Record<string, string> {
|
|
580
|
+
const cached = _ctorNameCache.get(entityColl)
|
|
581
|
+
if (null != cached) {
|
|
582
|
+
return cached
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
const ents = deriveEntityNames(entityColl)
|
|
586
|
+
const classes = entityClassNames(entityColl)
|
|
587
|
+
const taken = declaredTypeNames(ents, (name: string) => name)
|
|
588
|
+
Object.values(classes).forEach((cls: string) => taken.add(cls))
|
|
589
|
+
|
|
590
|
+
const out: Record<string, string> = {}
|
|
591
|
+
ents.forEach((e: any) => {
|
|
592
|
+
const base = 'New' + classes[e.name]
|
|
593
|
+
let name = base
|
|
594
|
+
let n = 1
|
|
595
|
+
while (taken.has(name)) {
|
|
596
|
+
n++
|
|
597
|
+
name = base + n
|
|
598
|
+
}
|
|
599
|
+
taken.add(name)
|
|
600
|
+
out[e.name] = name
|
|
601
|
+
})
|
|
602
|
+
|
|
603
|
+
_ctorNameCache.set(entityColl, out)
|
|
604
|
+
return out
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
function entityConstructorName(ent: any, entityColl: any): string {
|
|
609
|
+
if (null == ent) {
|
|
610
|
+
return ''
|
|
611
|
+
}
|
|
612
|
+
return entityConstructorNames(entityColl)[ent.name] ||
|
|
613
|
+
('New' + entityClassName(ent, entityColl))
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
|
|
584
617
|
const _typeCollisionCache = new WeakMap<object, string[]>()
|
|
585
618
|
const _typeCollisionCacheFold = new WeakMap<object, string[]>()
|
|
586
619
|
|
|
@@ -744,6 +777,7 @@ export {
|
|
|
744
777
|
entityPrimaryOp,
|
|
745
778
|
pickExampleEntity,
|
|
746
779
|
entityClassName,
|
|
780
|
+
entityConstructorName,
|
|
747
781
|
entityTypeCollisions,
|
|
748
782
|
warnEntityTypeCollisions,
|
|
749
783
|
ungeneratedOps,
|
package/src/helpers/pointPath.ts
CHANGED
|
@@ -31,6 +31,24 @@ function pointParts(point: any): string[] {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
|
|
34
|
+
// The path parameters a point's URL needs, including a placeholder inside a
|
|
35
|
+
// literal segment such as `{version}.mod`.
|
|
36
|
+
function pointPlaceholders(point: any): string[] {
|
|
37
|
+
const names: string[] = []
|
|
38
|
+
for (const seg of pointSegments(point)) {
|
|
39
|
+
if (null != seg.var) {
|
|
40
|
+
names.push(String(seg.var))
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
for (const found of String(seg.lit ?? '').matchAll(/\{([^{}/]+)\}/g)) {
|
|
44
|
+
names.push(found[1])
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return names
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
34
52
|
function pointTerminalParam(point: any): boolean {
|
|
35
53
|
const parts = pointParts(point)
|
|
36
54
|
const last = 0 < parts.length ? parts[parts.length - 1] : ''
|
|
@@ -53,6 +71,7 @@ export type {
|
|
|
53
71
|
export {
|
|
54
72
|
pointSegments,
|
|
55
73
|
pointParts,
|
|
74
|
+
pointPlaceholders,
|
|
56
75
|
pointTerminalParam,
|
|
57
76
|
pointPathKey,
|
|
58
77
|
}
|