@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
|
@@ -1,425 +0,0 @@
|
|
|
1
|
-
// VERSION: @voxgig/struct 0.0.10
|
|
2
|
-
// This test utility runs the JSON-specified tests in build/test/test.json.
|
|
3
|
-
// (or .sdk/test/test.json if used in a @voxgig/sdkgen project)
|
|
4
|
-
|
|
5
|
-
import { readFileSync } from 'node:fs'
|
|
6
|
-
import { join } from 'node:path'
|
|
7
|
-
import { deepStrictEqual, fail, AssertionError } from 'node:assert'
|
|
8
|
-
|
|
9
|
-
const NULLMARK = '__NULL__' // Value is JSON null
|
|
10
|
-
const UNDEFMARK = '__UNDEF__' // Value is not present (thus, undefined).
|
|
11
|
-
const EXISTSMARK = '__EXISTS__' // Value exists (not undefined).
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
type Subject = (...args: any[]) => any
|
|
15
|
-
type RunSet = (testspec: any, testsubject: Function) => Promise<any>
|
|
16
|
-
type RunSetFlags = (testspec: any, flags: Record<string, boolean>, testsubject: Function)
|
|
17
|
-
=> Promise<any>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
type RunPack = {
|
|
21
|
-
spec: Record<string, any>
|
|
22
|
-
runset: RunSet
|
|
23
|
-
runsetflags: RunSetFlags
|
|
24
|
-
subject: Subject
|
|
25
|
-
client: any
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
type TestPack = {
|
|
30
|
-
name?: string
|
|
31
|
-
client: any
|
|
32
|
-
subject: Subject
|
|
33
|
-
utility: any
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
type Flags = Record<string, boolean>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
type Utility = {
|
|
40
|
-
struct: any
|
|
41
|
-
makeContext: (ctxmap: Record<string, any>, basectx?: any) => any
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
type Client = {
|
|
46
|
-
utility: () => Utility
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
async function makeRunner(testfile: string, client: Client) {
|
|
51
|
-
|
|
52
|
-
return async function runner(
|
|
53
|
-
name: string,
|
|
54
|
-
store?: any,
|
|
55
|
-
): Promise<RunPack> {
|
|
56
|
-
store = store || {}
|
|
57
|
-
|
|
58
|
-
const utility = client.utility()
|
|
59
|
-
const structUtils = utility.struct
|
|
60
|
-
|
|
61
|
-
let spec = resolveSpec(name, testfile)
|
|
62
|
-
let clients = await resolveClients(client, spec, store, structUtils)
|
|
63
|
-
let subject = resolveSubject(name, utility)
|
|
64
|
-
|
|
65
|
-
let runsetflags: RunSetFlags = async (
|
|
66
|
-
testspec: any,
|
|
67
|
-
flags: Flags,
|
|
68
|
-
testsubject: Function
|
|
69
|
-
) => {
|
|
70
|
-
subject = testsubject || subject
|
|
71
|
-
flags = resolveFlags(flags)
|
|
72
|
-
const testspecmap = fixJSON(testspec, flags)
|
|
73
|
-
|
|
74
|
-
const testset: any[] = testspecmap.set
|
|
75
|
-
for (let entry of testset) {
|
|
76
|
-
try {
|
|
77
|
-
entry = resolveEntry(entry, flags)
|
|
78
|
-
|
|
79
|
-
let testpack = resolveTestPack(name, entry, subject, client, clients)
|
|
80
|
-
let args = resolveArgs(entry, testpack, utility, structUtils)
|
|
81
|
-
|
|
82
|
-
let res = await testpack.subject(...args)
|
|
83
|
-
res = fixJSON(res, flags)
|
|
84
|
-
entry.res = res
|
|
85
|
-
|
|
86
|
-
checkResult(entry, args, res, structUtils)
|
|
87
|
-
}
|
|
88
|
-
catch (err: any) {
|
|
89
|
-
if (err instanceof AssertionError) {
|
|
90
|
-
throw err
|
|
91
|
-
}
|
|
92
|
-
handleError(entry, err, structUtils)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
let runset: RunSet = async (
|
|
98
|
-
testspec: any,
|
|
99
|
-
testsubject: Function
|
|
100
|
-
) => runsetflags(testspec, {}, testsubject)
|
|
101
|
-
|
|
102
|
-
const runpack: RunPack = {
|
|
103
|
-
spec,
|
|
104
|
-
runset,
|
|
105
|
-
runsetflags,
|
|
106
|
-
subject,
|
|
107
|
-
client,
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return runpack
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function resolveSpec(name: string, testfile: string): Record<string, any> {
|
|
115
|
-
const alltests =
|
|
116
|
-
JSON.parse(readFileSync(join(__dirname, testfile), 'utf8'))
|
|
117
|
-
|
|
118
|
-
let spec = alltests.primary?.[name] || alltests[name] || alltests
|
|
119
|
-
return spec
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
async function resolveClients(
|
|
124
|
-
client: any,
|
|
125
|
-
spec: Record<string, any>,
|
|
126
|
-
store: any,
|
|
127
|
-
structUtils: Record<string, any>
|
|
128
|
-
):
|
|
129
|
-
Promise<Record<string, any>> {
|
|
130
|
-
|
|
131
|
-
const clients: Record<string, any> = {}
|
|
132
|
-
if (spec.DEF && spec.DEF.client) {
|
|
133
|
-
for (let cn in spec.DEF.client) {
|
|
134
|
-
const cdef = spec.DEF.client[cn]
|
|
135
|
-
const copts = cdef.test.options || {}
|
|
136
|
-
if ('object' === typeof store && structUtils?.inject) {
|
|
137
|
-
structUtils.inject(copts, store)
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
clients[cn] = await client.tester(copts)
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return clients
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
function resolveSubject(name: string, container: any) {
|
|
148
|
-
const subject = container[name] || container.struct[name]
|
|
149
|
-
return subject
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
function resolveFlags(flags?: Flags): Flags {
|
|
154
|
-
if (null == flags) {
|
|
155
|
-
flags = {}
|
|
156
|
-
}
|
|
157
|
-
flags.null = null == flags.null ? true : !!flags.null
|
|
158
|
-
return flags
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
function resolveEntry(entry: any, flags: Flags): any {
|
|
163
|
-
entry.out = null == entry.out && flags.null ? NULLMARK : entry.out
|
|
164
|
-
return entry
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
function checkResult(entry: any, args: any[], res: any, structUtils: Record<string, any>) {
|
|
169
|
-
let matched = false
|
|
170
|
-
|
|
171
|
-
if (entry.err) {
|
|
172
|
-
return fail('Expected error did not occur: ' + entry.err +
|
|
173
|
-
'\n\nENTRY: ' + safeStringify(entry))
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if (entry.match) {
|
|
177
|
-
const result = { in: entry.in, args, out: entry.res, ctx: entry.ctx }
|
|
178
|
-
match(
|
|
179
|
-
entry.match,
|
|
180
|
-
result,
|
|
181
|
-
structUtils
|
|
182
|
-
)
|
|
183
|
-
|
|
184
|
-
matched = true
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
const out = entry.out
|
|
188
|
-
|
|
189
|
-
if (out === res) {
|
|
190
|
-
return
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// NOTE: allow match with no out.
|
|
194
|
-
if (matched && (NULLMARK === out || null == out)) {
|
|
195
|
-
return
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
deepStrictEqual(null != res ? JSON.parse(safeStringify(res)) : res, entry.out)
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
// Handle errors from test execution
|
|
203
|
-
function handleError(entry: any, err: any, structUtils: Record<string, any>) {
|
|
204
|
-
entry.thrown = err
|
|
205
|
-
|
|
206
|
-
const entry_err = entry.err
|
|
207
|
-
|
|
208
|
-
if (null != entry_err) {
|
|
209
|
-
if (true === entry_err || matchval(entry_err, err.message, structUtils)) {
|
|
210
|
-
if (entry.match) {
|
|
211
|
-
match(
|
|
212
|
-
entry.match,
|
|
213
|
-
{ in: entry.in, out: entry.res, ctx: entry.ctx, err: fixJSON(err, { null: true }) },
|
|
214
|
-
structUtils
|
|
215
|
-
)
|
|
216
|
-
}
|
|
217
|
-
return
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
fail('ERROR MATCH: [' + structUtils.stringify(entry_err) +
|
|
221
|
-
'] <=> [' + err.message + ']')
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// Unexpected error (test didn't specify an error expectation)
|
|
225
|
-
else if (err instanceof AssertionError) {
|
|
226
|
-
fail(err.message + '\n\nENTRY: ' + safeStringify(entry))
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
fail(err.stack + '\n\nENTRY: ' + safeStringify(entry))
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
function resolveArgs(
|
|
235
|
-
entry: any,
|
|
236
|
-
testpack: TestPack,
|
|
237
|
-
utility: Utility,
|
|
238
|
-
structUtils: Record<string, any>
|
|
239
|
-
): any[] {
|
|
240
|
-
let args: any[] = []
|
|
241
|
-
|
|
242
|
-
if (entry.ctx) {
|
|
243
|
-
args = [entry.ctx]
|
|
244
|
-
}
|
|
245
|
-
else if (entry.args) {
|
|
246
|
-
args = entry.args
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
args = [structUtils.clone(entry.in)]
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
if (entry.ctx || entry.args) {
|
|
253
|
-
let first = args[0]
|
|
254
|
-
if (structUtils.ismap(first)) {
|
|
255
|
-
first = structUtils.clone(first)
|
|
256
|
-
first = utility.makeContext(first)
|
|
257
|
-
args[0] = first
|
|
258
|
-
entry.ctx = first
|
|
259
|
-
|
|
260
|
-
first.client = testpack.client
|
|
261
|
-
first.utility = testpack.utility
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
return args
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
function resolveTestPack(
|
|
270
|
-
name: string,
|
|
271
|
-
entry: any,
|
|
272
|
-
subject: Subject,
|
|
273
|
-
client: any,
|
|
274
|
-
clients: Record<string, any>
|
|
275
|
-
) {
|
|
276
|
-
const testpack: TestPack = {
|
|
277
|
-
name,
|
|
278
|
-
client,
|
|
279
|
-
subject,
|
|
280
|
-
utility: client.utility(),
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
if (entry.client) {
|
|
284
|
-
testpack.client = clients[entry.client]
|
|
285
|
-
testpack.utility = testpack.client.utility()
|
|
286
|
-
testpack.subject = resolveSubject(name, testpack.utility)
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
return testpack
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
function match(
|
|
294
|
-
check: any,
|
|
295
|
-
basex: any,
|
|
296
|
-
structUtils: Record<string, any>
|
|
297
|
-
) {
|
|
298
|
-
const cbase = structUtils.clone(basex)
|
|
299
|
-
|
|
300
|
-
structUtils.walk(check, (_key: any, val: any, _parent: any, path: any) => {
|
|
301
|
-
if (!structUtils.isnode(val)) {
|
|
302
|
-
let baseval = structUtils.getpath(cbase, path)
|
|
303
|
-
|
|
304
|
-
if (baseval === val) {
|
|
305
|
-
return val
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
// Explicit undefined expected
|
|
309
|
-
if (UNDEFMARK === val && undefined === baseval) {
|
|
310
|
-
return val
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// Explicit defined expected
|
|
314
|
-
if (EXISTSMARK === val && null != baseval) {
|
|
315
|
-
return val
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
if (!matchval(val, baseval, structUtils)) {
|
|
319
|
-
fail('MATCH: ' + path.join('.') +
|
|
320
|
-
': [' + structUtils.stringify(val) +
|
|
321
|
-
'] <=> [' + structUtils.stringify(baseval) + ']')
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
return val
|
|
326
|
-
})
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
function matchval(
|
|
331
|
-
check: any,
|
|
332
|
-
base: any,
|
|
333
|
-
structUtils: Record<string, any>
|
|
334
|
-
) {
|
|
335
|
-
let pass = check === base
|
|
336
|
-
|
|
337
|
-
if (!pass) {
|
|
338
|
-
|
|
339
|
-
if ('string' === typeof check) {
|
|
340
|
-
let basestr = structUtils.stringify(base)
|
|
341
|
-
|
|
342
|
-
let rem = check.match(/^\/(.+)\/$/)
|
|
343
|
-
if (rem) {
|
|
344
|
-
pass = new RegExp(rem[1]).test(basestr)
|
|
345
|
-
}
|
|
346
|
-
else {
|
|
347
|
-
pass = basestr.toLowerCase().includes(structUtils.stringify(check).toLowerCase())
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
else if ('function' === typeof check) {
|
|
351
|
-
pass = true
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
return pass
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
function safeStringify(val: any): string {
|
|
360
|
-
const seen = new WeakSet()
|
|
361
|
-
return JSON.stringify(val, (_k, v) => {
|
|
362
|
-
if ('object' === typeof v && null !== v) {
|
|
363
|
-
if (seen.has(v)) return '[Circular]'
|
|
364
|
-
seen.add(v)
|
|
365
|
-
}
|
|
366
|
-
if (v instanceof Error) {
|
|
367
|
-
return { name: v.name, message: v.message }
|
|
368
|
-
}
|
|
369
|
-
return v
|
|
370
|
-
}, 2)
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
function fixJSON(val: any, flags?: Flags): any {
|
|
375
|
-
if (null == val) {
|
|
376
|
-
return flags?.null ? NULLMARK : val
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
const seen = new WeakSet()
|
|
380
|
-
const replacer = (_k: string, v: any) => {
|
|
381
|
-
if (null == v && flags?.null) {
|
|
382
|
-
return NULLMARK
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
if (v instanceof Error) {
|
|
386
|
-
return {
|
|
387
|
-
...v,
|
|
388
|
-
name: v.name,
|
|
389
|
-
message: v.message,
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
if ('object' === typeof v && null !== v) {
|
|
394
|
-
if (seen.has(v)) return '[Circular]'
|
|
395
|
-
seen.add(v)
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
return v
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
return JSON.parse(JSON.stringify(val, replacer))
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
function nullModifier(
|
|
406
|
-
val: any,
|
|
407
|
-
key: any,
|
|
408
|
-
parent: any
|
|
409
|
-
) {
|
|
410
|
-
if ("__NULL__" === val) {
|
|
411
|
-
parent[key] = null
|
|
412
|
-
}
|
|
413
|
-
else if ('string' === typeof val) {
|
|
414
|
-
parent[key] = val.replaceAll('__NULL__', 'null')
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
export {
|
|
420
|
-
NULLMARK,
|
|
421
|
-
EXISTSMARK,
|
|
422
|
-
nullModifier,
|
|
423
|
-
makeRunner,
|
|
424
|
-
}
|
|
425
|
-
|