@voxgig/sdkgen 4.40.1 → 4.41.1
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 +5 -5
- package/dist/cmp/Main.js +4 -0
- package/dist/cmp/Main.js.map +1 -1
- package/dist/helpers/testPolicy.d.ts +5 -1
- package/dist/helpers/testPolicy.js +32 -3
- package/dist/helpers/testPolicy.js.map +1 -1
- package/dist/helpers/useragent.d.ts +2 -0
- package/dist/helpers/useragent.js +31 -0
- package/dist/helpers/useragent.js.map +1 -0
- package/dist/sdkgen.d.ts +2 -2
- package/dist/sdkgen.js +6 -3
- package/dist/sdkgen.js.map +1 -1
- package/dist/testkit.js +1 -1
- package/dist/testkit.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/model/sdkgen.aontu +6 -0
- package/package.json +4 -4
- package/project/.sdk/src/cmp/csharp/TestEntity_csharp.ts +35 -16
- package/project/.sdk/src/cmp/go/ReadmeExamplesTest_go.ts +7 -6
- package/project/.sdk/src/cmp/go/TestEntity_go.ts +24 -13
- package/project/.sdk/src/cmp/java/TestEntity_java.ts +21 -11
- package/project/.sdk/src/cmp/kotlin/TestEntity_kotlin.ts +26 -14
- package/project/.sdk/src/cmp/lua/ReadmeExamplesTest_lua.ts +7 -5
- package/project/.sdk/src/cmp/lua/ReadmeHowto_lua.ts +12 -0
- package/project/.sdk/src/cmp/lua/TestEntity_lua.ts +25 -13
- package/project/.sdk/src/cmp/perl/ReadmeExamplesTest_perl.ts +15 -1
- package/project/.sdk/src/cmp/perl/TestEntity_perl.ts +23 -13
- package/project/.sdk/src/cmp/php/ReadmeExamplesTest_php.ts +31 -2
- package/project/.sdk/src/cmp/php/TestEntity_php.ts +29 -14
- package/project/.sdk/src/cmp/py/ReadmeExamplesTest_py.ts +14 -1
- package/project/.sdk/src/cmp/py/TestEntity_py.ts +28 -14
- package/project/.sdk/src/cmp/rb/ReadmeExamplesTest_rb.ts +18 -1
- package/project/.sdk/src/cmp/rb/TestEntity_rb.ts +24 -13
- package/project/.sdk/src/cmp/rust/TestEntity_rust.ts +27 -14
- package/project/.sdk/src/cmp/ts/ReadmeExamplesTest_ts.ts +7 -2
- package/project/.sdk/tm/c/feature/test.c +22 -2
- package/project/.sdk/tm/c/tests/transport_test.c +2 -2
- package/project/.sdk/tm/c/utility/http.c +1 -1
- package/project/.sdk/tm/clojure/src/sdk/core.clj +1 -1
- package/project/.sdk/tm/clojure/src/sdk/features.clj +13 -1
- package/project/.sdk/tm/cpp/feature/test.hpp +16 -2
- package/project/.sdk/tm/csharp/feature/TestFeature.cs +18 -0
- package/project/.sdk/tm/csharp/utility/Fetcher.cs +5 -4
- package/project/.sdk/tm/elixir/lib/projectname/feature/test.ex +19 -1
- package/project/.sdk/tm/elixir/lib/projectname/utility.ex +1 -1
- package/project/.sdk/tm/go/feature/test_feature.go +16 -0
- package/project/.sdk/tm/go/utility/fetcher.go +4 -3
- package/project/.sdk/tm/java/feature/TestFeature.java +15 -0
- package/project/.sdk/tm/java/utility/Fetcher.java +4 -4
- package/project/.sdk/tm/js/src/feature/test/TestFeature.js +16 -0
- package/project/.sdk/tm/js/src/utility/FetcherUtility.js +4 -3
- package/project/.sdk/tm/js/src/utility/ResultBodyUtility.js +19 -1
- package/project/.sdk/tm/js/test/live-entity.js +2 -1
- package/project/.sdk/tm/kotlin/feature/TestFeature.kt +15 -0
- package/project/.sdk/tm/kotlin/utility/Fetcher.kt +1 -1
- package/project/.sdk/tm/lua/feature/secrets_feature.lua +9 -2
- package/project/.sdk/tm/lua/feature/test_feature.lua +18 -0
- package/project/.sdk/tm/lua/utility/fetcher.lua +11 -25
- package/project/.sdk/tm/lua/utility/tls.lua +241 -0
- package/project/.sdk/tm/ocaml/sdk_features.ml +18 -1
- package/project/.sdk/tm/perl/feature/test_feature.pm +12 -0
- package/project/.sdk/tm/perl/utility/fetcher.pm +4 -4
- package/project/.sdk/tm/php/feature/TestFeature.php +18 -1
- package/project/.sdk/tm/php/utility/Fetcher.php +4 -4
- package/project/.sdk/tm/py/pkg/feature/test_feature.py +20 -4
- package/project/.sdk/tm/py/pkg/utility/fetcher.py +4 -4
- package/project/.sdk/tm/rb/feature/test_feature.rb +14 -1
- package/project/.sdk/tm/rb/utility/fetcher.rb +56 -6
- package/project/.sdk/tm/rust/feature/test.rs +18 -0
- package/project/.sdk/tm/rust/utility/fetcher.rs +4 -4
- package/project/.sdk/tm/scala/feature/TestFeature.scala +12 -0
- package/project/.sdk/tm/scala/utility/Fetcher.scala +1 -1
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/TestFeature.swift +15 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Fetcher.swift +1 -1
- package/project/.sdk/tm/ts/src/feature/test/TestFeature.ts +26 -5
- package/project/.sdk/tm/ts/src/utility/FetcherUtility.ts +4 -3
- package/project/.sdk/tm/ts/src/utility/ResultBodyUtility.ts +19 -1
- package/project/.sdk/tm/ts/test/live-entity.ts +2 -1
- package/project/.sdk/tm/zig/feature/test.zig +23 -0
- package/project/sdkgen-package.json +1 -1
- package/src/cmp/Main.ts +5 -0
- package/src/helpers/testPolicy.ts +32 -3
- package/src/helpers/useragent.ts +41 -0
- package/src/sdkgen.ts +4 -0
- package/src/testkit.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voxgig/sdkgen",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.41.1",
|
|
4
4
|
"main": "dist/sdkgen.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"engines": {
|
|
@@ -94,9 +94,9 @@
|
|
|
94
94
|
"@voxgig/docgen": ">=0.27.0",
|
|
95
95
|
"@voxgig/struct": ">=0.2",
|
|
96
96
|
"@voxgig/util": ">=0.5",
|
|
97
|
-
"aontu": ">=0.
|
|
98
|
-
"jostraca": ">=0.
|
|
99
|
-
"shape": ">=
|
|
97
|
+
"aontu": ">=0.76.3",
|
|
98
|
+
"jostraca": ">=0.42.0",
|
|
99
|
+
"shape": ">=12"
|
|
100
100
|
},
|
|
101
101
|
"peerDependenciesMeta": {
|
|
102
102
|
"@voxgig/docgen": {
|
|
@@ -18,13 +18,13 @@ import {
|
|
|
18
18
|
each,
|
|
19
19
|
buildIdNames,
|
|
20
20
|
getMatchEntries,
|
|
21
|
-
isAuthActive, envName, envToken,
|
|
21
|
+
isAuthActive, envName, envToken, entityRecordIdField,
|
|
22
22
|
serverVarEnv,
|
|
23
23
|
serverVariables,
|
|
24
24
|
liveFlowNeeds, liveStrict, liveStrictNote,
|
|
25
25
|
liveGates, liveExcludedLines, liveExcludedSummary, LIVE_GETONLY_ENV,
|
|
26
26
|
liveRouteExamples, liveStepExamples,
|
|
27
|
-
liveEntity, liveIdentity,
|
|
27
|
+
liveEntity, liveIdentity, liveRepeatsId, liveLoadComparesId, liveUnrouted,
|
|
28
28
|
} from '@voxgig/sdkgen'
|
|
29
29
|
|
|
30
30
|
|
|
@@ -97,18 +97,22 @@ function liveFlowGate(entity: any, needs: any, identity: any, entidEnv: string,
|
|
|
97
97
|
`
|
|
98
98
|
}
|
|
99
99
|
if (null != needs.discover) {
|
|
100
|
-
const match = Object.entries(needs.discover)
|
|
101
|
-
.map(([k, v]: any) =>
|
|
100
|
+
const match = 'new Dictionary<string, object?> {' + Object.entries(needs.discover)
|
|
101
|
+
.map(([k, v]: any) => (needs.unrouted || []).some(([name]: [string, string]) => k === name) ?
|
|
102
|
+
` [${JSON.stringify(k)}] = StructUtils.GetProp(setup.Idmap, ${JSON.stringify(v)}),` :
|
|
103
|
+
` [${JSON.stringify(k)}] = setup.Idmap[${JSON.stringify(v)}],`)
|
|
102
104
|
.concat(liveRouteExamples(entity, 'list', Object.keys(needs.discover))
|
|
103
|
-
.map(([k, ex]) => ` [${JSON.stringify(k)}] = ${formatCsValue(ex)},`)).join('')
|
|
105
|
+
.map(([k, ex]) => ` [${JSON.stringify(k)}] = ${formatCsValue(ex)},`)).join('') + ' }'
|
|
106
|
+
const omit = needs.unrouted || []
|
|
104
107
|
out += ` if (setup.Live)
|
|
105
108
|
{
|
|
106
109
|
var liveId = setup.SyntheticOnly ? null : StructUtils.GetProp(setup.Idmap, ${JSON.stringify(identity.key)});
|
|
107
110
|
${undefined === identity.ex ? '' : ` liveId ??= ${formatCsValue(identity.ex)};
|
|
108
|
-
`}
|
|
111
|
+
`}${0 === omit.length ? '' : ` var liveMatch = ${match};
|
|
112
|
+
${liveOmit(omit, 'liveMatch', ' ')}`} TestRunner.LivePace();
|
|
109
113
|
if (!TestRunner.LiveExisting(setup.Data, LIVE_STRICT, ${JSON.stringify(entity.name)},
|
|
110
114
|
${JSON.stringify(identity.field)}, liveId,
|
|
111
|
-
() => client.${entity.Name}().List(
|
|
115
|
+
() => client.${entity.Name}().List(${0 === omit.length ? match : 'liveMatch'}, null)))
|
|
112
116
|
{
|
|
113
117
|
return;
|
|
114
118
|
}
|
|
@@ -539,8 +543,11 @@ const generateList: OpGen = (ctx, step, index) => {
|
|
|
539
543
|
Content(` var ${matchvar} = new Dictionary<string, object?>
|
|
540
544
|
{
|
|
541
545
|
`)
|
|
546
|
+
// *_ENTID may not give a binding the live route does not take.
|
|
547
|
+
const unrouted = liveUnrouted(entity, step, flow).map(([name]) => name)
|
|
542
548
|
for (const [key, val] of matchEntries) {
|
|
543
|
-
Content(` ["${key}"] = setup.Idmap
|
|
549
|
+
Content(unrouted.includes(key) ? ` ["${key}"] = StructUtils.GetProp(setup.Idmap, "${val}"),
|
|
550
|
+
` : ` ["${key}"] = setup.Idmap["${val}"],
|
|
544
551
|
`)
|
|
545
552
|
}
|
|
546
553
|
Content(` };
|
|
@@ -649,7 +656,7 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
649
656
|
Assert.True(${resdatavar} != null, "expected update result to be a map");
|
|
650
657
|
`)
|
|
651
658
|
if (hasEntIdU) {
|
|
652
|
-
Content(sameId(entity, `StructUtils.GetProp(${resdatavar}, ${rid(entity)})`, `${datavar}Up["id"]`,
|
|
659
|
+
Content(sameId(liveRepeatsId(entity), `StructUtils.GetProp(${resdatavar}, ${rid(entity)})`, `${datavar}Up["id"]`,
|
|
653
660
|
'expected update result id to match'))
|
|
654
661
|
}
|
|
655
662
|
|
|
@@ -715,7 +722,7 @@ const generateLoad: OpGen = (ctx, step, index) => {
|
|
|
715
722
|
${loadMatch(entity, step, matchvar, srcdatavar)}${liveFill(entity, step, matchvar, flow)} var ${datavar}Loaded = ${entvar}.Load(${matchvar}, null);
|
|
716
723
|
var ${datavar}LoadResult = Helpers.ToMapAny(${datavar}Loaded is IEntity le ? le.Data() : ${datavar}Loaded);
|
|
717
724
|
Assert.True(${datavar}LoadResult != null, "expected load result to be a map");
|
|
718
|
-
${sameId(entity, `StructUtils.GetProp(${datavar}LoadResult, ${rid(entity)})`,
|
|
725
|
+
${sameId(liveLoadComparesId(entity, flow), `StructUtils.GetProp(${datavar}LoadResult, ${rid(entity)})`,
|
|
719
726
|
`StructUtils.GetProp(${srcdatavar}, ${rid(entity)})`, 'expected load result id to match')}`)
|
|
720
727
|
}
|
|
721
728
|
else {
|
|
@@ -767,11 +774,11 @@ const LIVE_PACE = ` if (setup.Live)
|
|
|
767
774
|
`
|
|
768
775
|
|
|
769
776
|
|
|
770
|
-
// A result's identity matches the one asked for, live only
|
|
771
|
-
//
|
|
772
|
-
function sameId(
|
|
777
|
+
// A result's identity matches the one asked for, live only as the live
|
|
778
|
+
// entity harness compares it.
|
|
779
|
+
function sameId(compares: boolean, result: string, expected: string, message: string): string {
|
|
773
780
|
const check = `Assert.True(TestRunner.LiveSameId(${result}, ${expected}), ${JSON.stringify(message)});`
|
|
774
|
-
return
|
|
781
|
+
return !compares ? ` if (!setup.Live)
|
|
775
782
|
{
|
|
776
783
|
${check}
|
|
777
784
|
}
|
|
@@ -809,13 +816,25 @@ function fixtureIdentity(entity: any): string {
|
|
|
809
816
|
// A live step sends each example its route requires and the step leaves unbound.
|
|
810
817
|
function liveFill(entity: any, step: any, matchvar: string, flow: any): string {
|
|
811
818
|
const fills = liveStepExamples(entity, step, flow)
|
|
812
|
-
|
|
819
|
+
const omit = liveUnrouted(entity, step, flow)
|
|
820
|
+
return 0 === fills.length + omit.length ? '' : ` if (setup.Live)
|
|
813
821
|
{
|
|
814
|
-
${fills.map(([k, ex]) => ` ${matchvar}[${JSON.stringify(k)}] = ${formatCsValue(ex)};\n`).join('')} }
|
|
822
|
+
${fills.map(([k, ex]) => ` ${matchvar}[${JSON.stringify(k)}] = ${formatCsValue(ex)};\n`).join('')}${liveOmit(omit, matchvar, ' ')} }
|
|
815
823
|
`
|
|
816
824
|
}
|
|
817
825
|
|
|
818
826
|
|
|
827
|
+
// A binding the live route does not take is sent only as *_ENTID gives it.
|
|
828
|
+
function liveOmit(omit: [string, string][], matchvar: string, indent: string): string {
|
|
829
|
+
return omit.map(([name, key]) =>
|
|
830
|
+
`${indent}if (setup.SyntheticOnly || StructUtils.GetProp(setup.Idmap, ${JSON.stringify(key)}) == null)
|
|
831
|
+
${indent}{
|
|
832
|
+
${indent} ${matchvar}.Remove(${JSON.stringify(name)});
|
|
833
|
+
${indent}}
|
|
834
|
+
`).join('')
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
|
|
819
838
|
function parentMatch(step: any, matchvar: string): string {
|
|
820
839
|
return Object.entries(step.m || {})
|
|
821
840
|
.filter(([k]: any) => k !== 'id' && !k.endsWith('$'))
|
|
@@ -13,13 +13,14 @@ const ReadmeExamplesTest = cmp(function ReadmeExamplesTest(props: any) {
|
|
|
13
13
|
// examples load by "example_id", so seed that record for each entity; the
|
|
14
14
|
// offline mock then returns it instead of 404-ing.
|
|
15
15
|
const entity = getModelPath(model, `main.${KIT}.entity`) || {}
|
|
16
|
-
const
|
|
16
|
+
const goSeedEntries = Object.values(entity)
|
|
17
17
|
.filter((e: any) => e && e.active !== false)
|
|
18
|
-
.map((e: any) =>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
`"${
|
|
18
|
+
.map((e: any) => {
|
|
19
|
+
const idField = e.id?.field
|
|
20
|
+
const extra = 'string' === typeof idField && '' !== idField && 'id' !== idField
|
|
21
|
+
? `, ${JSON.stringify(idField)}: "example_id"` : ''
|
|
22
|
+
return `"${e.name}": map[string]any{"example_id": map[string]any{"id": "example_id"${extra}}}`
|
|
23
|
+
})
|
|
23
24
|
.join(', ')
|
|
24
25
|
const goSeed = `map[string]any{"entity": map[string]any{${goSeedEntries}}}`
|
|
25
26
|
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
liveFlowNeeds, liveStrict, liveStrictNote,
|
|
33
33
|
liveRouteExamples, liveStepExamples, flowLoadRoute, flowLoadReadsRecord,
|
|
34
34
|
liveGates, liveExcludedLines, liveExcludedSummary, LIVE_GETONLY_ENV,
|
|
35
|
-
liveEntity, liveIdentity,
|
|
35
|
+
liveEntity, liveIdentity, liveRepeatsId, liveLoadComparesId, liveUnrouted,
|
|
36
36
|
} from '@voxgig/sdkgen'
|
|
37
37
|
|
|
38
38
|
|
|
@@ -452,10 +452,11 @@ function liveFlowGate(entity: any, needs: any, identity: any, strict: boolean, s
|
|
|
452
452
|
`
|
|
453
453
|
}
|
|
454
454
|
if (null != needs.discover) {
|
|
455
|
-
const match = Object.entries(needs.discover)
|
|
455
|
+
const match = 'map[string]any{' + Object.entries(needs.discover)
|
|
456
456
|
.map(([k, v]: any) => `${JSON.stringify(k)}: setup.idmap[${JSON.stringify(v)}]`)
|
|
457
457
|
.concat(liveRouteExamples(entity, 'list', Object.keys(needs.discover))
|
|
458
|
-
.map(([k, ex]) => `${JSON.stringify(k)}: ${JSON.stringify(ex)}`)).join(', ')
|
|
458
|
+
.map(([k, ex]) => `${JSON.stringify(k)}: ${JSON.stringify(ex)}`)).join(', ') + '}'
|
|
459
|
+
const omit = needs.unrouted || []
|
|
459
460
|
out += ` if setup.live {
|
|
460
461
|
var _liveId any
|
|
461
462
|
if !setup.syntheticOnly {
|
|
@@ -464,10 +465,11 @@ function liveFlowGate(entity: any, needs: any, identity: any, strict: boolean, s
|
|
|
464
465
|
${undefined === identity.ex ? '' : ` if _liveId == nil {
|
|
465
466
|
_liveId = ${goIdLit(identity.ex)}
|
|
466
467
|
}
|
|
467
|
-
`}
|
|
468
|
+
`}${0 === omit.length ? '' : ` _liveMatch := ${match}
|
|
469
|
+
${liveOmit(omit, '_liveMatch', '\t\t\t')}`} livePace()
|
|
468
470
|
liveExisting(t, ${strictConst}, setup.data, ${JSON.stringify(entity.name)}, ${JSON.stringify(identity.field)}, _liveId,
|
|
469
471
|
func() (any, error) {
|
|
470
|
-
return client.${entity.Name}(nil).List(
|
|
472
|
+
return client.${entity.Name}(nil).List(${0 === omit.length ? match : '_liveMatch'}, nil)
|
|
471
473
|
})
|
|
472
474
|
}
|
|
473
475
|
`
|
|
@@ -703,7 +705,7 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
703
705
|
}
|
|
704
706
|
`)
|
|
705
707
|
if (hasEntIdU) {
|
|
706
|
-
Content(` if ${liveDeclared(entity)}!liveSameId(${resdatavar}[${rid(entity)}], ${datavar}Up["id"]) {
|
|
708
|
+
Content(` if ${liveDeclared(liveRepeatsId(entity))}!liveSameId(${resdatavar}[${rid(entity)}], ${datavar}Up["id"]) {
|
|
707
709
|
t.Fatal("expected update result id to match")
|
|
708
710
|
}
|
|
709
711
|
`)
|
|
@@ -779,7 +781,7 @@ const generateLoad: OpGen = (ctx, step, index) => {
|
|
|
779
781
|
if ${datavar}LoadResult == nil {
|
|
780
782
|
t.Fatal("expected load result to be a map")
|
|
781
783
|
}
|
|
782
|
-
if ${liveDeclared(entity)}!liveSameId(${datavar}LoadResult[${rid(entity)}], ${srcdatavar}[${rid(entity)}]) {
|
|
784
|
+
if ${liveDeclared(liveLoadComparesId(entity, flow))}!liveSameId(${datavar}LoadResult[${rid(entity)}], ${srcdatavar}[${rid(entity)}]) {
|
|
783
785
|
t.Fatal("expected load result id to match")
|
|
784
786
|
}
|
|
785
787
|
`)
|
|
@@ -845,10 +847,9 @@ function rid(entity: any): string {
|
|
|
845
847
|
}
|
|
846
848
|
|
|
847
849
|
|
|
848
|
-
// A
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
return null == entityDataIdField(entity) ? '!setup.live && ' : ''
|
|
850
|
+
// A live result is compared on its identity only as the live entity harness does.
|
|
851
|
+
function liveDeclared(compares: boolean): string {
|
|
852
|
+
return compares ? '' : '!setup.live && '
|
|
852
853
|
}
|
|
853
854
|
|
|
854
855
|
|
|
@@ -872,14 +873,24 @@ function fixtureIdentity(entity: any): string {
|
|
|
872
873
|
// A live step sends each example its route requires and the step leaves unbound.
|
|
873
874
|
function liveFill(entity: any, step: any, matchvar: string, flow: any) {
|
|
874
875
|
const fills = liveStepExamples(entity, step, flow)
|
|
875
|
-
|
|
876
|
+
const omit = liveUnrouted(entity, step, flow)
|
|
877
|
+
if (0 < fills.length + omit.length) {
|
|
876
878
|
Content(` if setup.live {
|
|
877
|
-
${fills.map(([k, ex]) => ` ${matchvar}[${JSON.stringify(k)}] = ${JSON.stringify(ex)}\n`).join('')} }
|
|
879
|
+
${fills.map(([k, ex]) => ` ${matchvar}[${JSON.stringify(k)}] = ${JSON.stringify(ex)}\n`).join('')}${liveOmit(omit, matchvar, '\t\t\t')} }
|
|
878
880
|
`)
|
|
879
881
|
}
|
|
880
882
|
}
|
|
881
883
|
|
|
882
884
|
|
|
885
|
+
// A binding the live route does not take is sent only as *_ENTID gives it.
|
|
886
|
+
function liveOmit(omit: [string, string][], matchvar: string, indent: string): string {
|
|
887
|
+
return omit.map(([name, key]) => `${indent}if setup.syntheticOnly || setup.idmap[${JSON.stringify(key)}] == nil {
|
|
888
|
+
${indent} delete(${matchvar}, ${JSON.stringify(name)})
|
|
889
|
+
${indent}}
|
|
890
|
+
`).join('')
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
|
|
883
894
|
// A number as JSON decodes one, so an example compares equal to a record's id.
|
|
884
895
|
function goIdLit(value: any): string {
|
|
885
896
|
return 'number' === typeof value ? 'float64(' + value + ')' : JSON.stringify(value)
|
|
@@ -20,11 +20,11 @@ import {
|
|
|
20
20
|
getMatchEntries,
|
|
21
21
|
isAuthActive,
|
|
22
22
|
serverVarEnv,
|
|
23
|
-
serverVariables, envName, envToken,
|
|
23
|
+
serverVariables, envName, envToken, entityRecordIdField,
|
|
24
24
|
liveFlowNeeds, liveStrict, liveStrictNote,
|
|
25
25
|
liveGates, liveExcludedLines, liveExcludedSummary, LIVE_GETONLY_ENV,
|
|
26
26
|
liveRouteExamples, liveStepExamples,
|
|
27
|
-
liveEntity, liveIdentity,
|
|
27
|
+
liveEntity, liveIdentity, liveRepeatsId, liveLoadComparesId, liveUnrouted,
|
|
28
28
|
} from '@voxgig/sdkgen'
|
|
29
29
|
|
|
30
30
|
|
|
@@ -99,7 +99,9 @@ function liveFlowGate(entity: any, needs: any, identity: any, entidEnv: string,
|
|
|
99
99
|
const match = Object.entries(needs.discover)
|
|
100
100
|
.map(([k, v]: any) => `match.put(${JSON.stringify(k)}, setup.idmap.get(${JSON.stringify(v)}));`)
|
|
101
101
|
.concat(liveRouteExamples(entity, 'list', Object.keys(needs.discover))
|
|
102
|
-
.map(([k, ex]) => `match.put(${JSON.stringify(k)}, ${javaLit(ex)});`))
|
|
102
|
+
.map(([k, ex]) => `match.put(${JSON.stringify(k)}, ${javaLit(ex)});`))
|
|
103
|
+
.concat((needs.unrouted || []).map(([name, key]: [string, string]) =>
|
|
104
|
+
`if (${unsupplied(key)}) match.remove(${JSON.stringify(name)});`)).join(' ')
|
|
103
105
|
out += ` if (setup.live) {
|
|
104
106
|
Object liveId = setup.syntheticOnly ? null : setup.idmap.get(${JSON.stringify(identity.key)});
|
|
105
107
|
${undefined === identity.ex ? '' : ` if (liveId == null) {
|
|
@@ -623,7 +625,7 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
623
625
|
assertNotNull(${resdatavar}, "expected update result to be a map");
|
|
624
626
|
`)
|
|
625
627
|
if (hasEntIdU) {
|
|
626
|
-
Content(sameId(entity, `${resdatavar}.get(${rid(entity)})`, `${datavar}Up.get("id")`,
|
|
628
|
+
Content(sameId(liveRepeatsId(entity), `${resdatavar}.get(${rid(entity)})`, `${datavar}Up.get("id")`,
|
|
627
629
|
'expected update result id to match'))
|
|
628
630
|
}
|
|
629
631
|
|
|
@@ -687,7 +689,7 @@ const generateLoad: OpGen = (ctx, step, index) => {
|
|
|
687
689
|
${loadMatch(entity, step, matchvar, srcdatavar)}${liveFill(entity, step, matchvar, flow)} Object ${datavar}Loaded = ${entvar}.load(${matchvar}, null);
|
|
688
690
|
Map<String, Object> ${datavar}LoadResult = Helpers.toMapAny(${datavar}Loaded instanceof SdkEntity ? ((SdkEntity) ${datavar}Loaded).data() : ${datavar}Loaded);
|
|
689
691
|
assertNotNull(${datavar}LoadResult, "expected load result to be a map");
|
|
690
|
-
${sameId(entity, `${datavar}LoadResult.get(${rid(entity)})`, `${srcdatavar}.get(${rid(entity)})`,
|
|
692
|
+
${sameId(liveLoadComparesId(entity, flow), `${datavar}LoadResult.get(${rid(entity)})`, `${srcdatavar}.get(${rid(entity)})`,
|
|
691
693
|
'expected load result id to match')}`)
|
|
692
694
|
}
|
|
693
695
|
else {
|
|
@@ -735,11 +737,11 @@ const LIVE_PACE = ` if (setup.live) {
|
|
|
735
737
|
`
|
|
736
738
|
|
|
737
739
|
|
|
738
|
-
// A result's identity matches the one asked for, live only
|
|
739
|
-
//
|
|
740
|
-
function sameId(
|
|
740
|
+
// A result's identity matches the one asked for, live only as the live
|
|
741
|
+
// entity harness compares it.
|
|
742
|
+
function sameId(compares: boolean, result: string, expected: string, message: string): string {
|
|
741
743
|
const check = `assertTrue(RunnerSupport.liveSameId(${result}, ${expected}), ${JSON.stringify(message)});`
|
|
742
|
-
return
|
|
744
|
+
return !compares ? ` if (!setup.live) {
|
|
743
745
|
${check}
|
|
744
746
|
}
|
|
745
747
|
` : ` ${check}
|
|
@@ -786,12 +788,20 @@ function javaIdLit(value: any): string {
|
|
|
786
788
|
// A live step sends each example its route requires and the step leaves unbound.
|
|
787
789
|
function liveFill(entity: any, step: any, matchvar: string, flow: any): string {
|
|
788
790
|
const fills = liveStepExamples(entity, step, flow)
|
|
789
|
-
|
|
790
|
-
|
|
791
|
+
const omit = liveUnrouted(entity, step, flow)
|
|
792
|
+
return 0 === fills.length + omit.length ? '' : ` if (setup.live) {
|
|
793
|
+
${fills.map(([k, ex]) => ` ${matchvar}.put(${JSON.stringify(k)}, ${javaLit(ex)});\n`).join('')}${omit.map(([name, key]) =>
|
|
794
|
+
` if (${unsupplied(key)}) {\n ${matchvar}.remove(${JSON.stringify(name)});\n }\n`).join('')} }
|
|
791
795
|
`
|
|
792
796
|
}
|
|
793
797
|
|
|
794
798
|
|
|
799
|
+
// A binding the live route does not take is sent only as *_ENTID gives it.
|
|
800
|
+
function unsupplied(key: string): string {
|
|
801
|
+
return `setup.syntheticOnly || setup.idmap.get(${JSON.stringify(key)}) == null`
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
|
|
795
805
|
function parentMatch(step: any, matchvar: string): string {
|
|
796
806
|
return Object.entries(step.m || {})
|
|
797
807
|
.filter(([k]: any) => k !== 'id' && !k.endsWith('$'))
|
|
@@ -18,11 +18,11 @@ import {
|
|
|
18
18
|
each,
|
|
19
19
|
buildIdNames,
|
|
20
20
|
getMatchEntries,
|
|
21
|
-
isAuthActive, envName, envToken,
|
|
21
|
+
isAuthActive, envName, envToken, entityRecordIdField,
|
|
22
22
|
liveFlowNeeds, liveStrict, liveStrictNote,
|
|
23
23
|
liveGates, liveExcludedLines, liveExcludedSummary, LIVE_GETONLY_ENV,
|
|
24
24
|
liveRouteExamples, liveStepExamples,
|
|
25
|
-
liveEntity, liveIdentity,
|
|
25
|
+
liveEntity, liveIdentity, liveRepeatsId, liveLoadComparesId, liveUnrouted,
|
|
26
26
|
} from '@voxgig/sdkgen'
|
|
27
27
|
|
|
28
28
|
|
|
@@ -90,17 +90,19 @@ function liveFlowGate(entity: any, needs: any, identity: any, entidEnv: string,
|
|
|
90
90
|
`
|
|
91
91
|
}
|
|
92
92
|
if (null != needs.discover) {
|
|
93
|
-
const match = Object.entries(needs.discover)
|
|
93
|
+
const match = 'linkedMapOf<String, Any?>(' + Object.entries(needs.discover)
|
|
94
94
|
.map(([k, v]: any) => `${JSON.stringify(k)} to setup.idmap?.get(${JSON.stringify(v)})`)
|
|
95
95
|
.concat(liveRouteExamples(entity, 'list', Object.keys(needs.discover))
|
|
96
|
-
.map(([k, ex]) => `${JSON.stringify(k)} to ${kotlinLit(ex)}`)).join(', ')
|
|
96
|
+
.map(([k, ex]) => `${JSON.stringify(k)} to ${kotlinLit(ex)}`)).join(', ') + ')'
|
|
97
|
+
const omit = needs.unrouted || []
|
|
97
98
|
const given = `if (setup.syntheticOnly) null else setup.idmap?.get(${JSON.stringify(identity.key)})`
|
|
98
99
|
out += ` if (setup.live) {
|
|
99
100
|
val liveId: Any? = ${undefined === identity.ex ? given : `(${given}) ?: ${kotlinIdLit(identity.ex)}`}
|
|
100
|
-
|
|
101
|
+
${0 === omit.length ? '' : ` val liveMatch = ${match}
|
|
102
|
+
${liveOmit(omit, 'liveMatch', ' ')}`} RunnerSupport.livePace()
|
|
101
103
|
RunnerSupport.liveExisting(setup.data!!, LIVE_STRICT, ${JSON.stringify(entity.name)},
|
|
102
104
|
${JSON.stringify(identity.field)}, liveId) {
|
|
103
|
-
client.${accessor}(null).list(
|
|
105
|
+
client.${accessor}(null).list(${0 === omit.length ? match : 'liveMatch'}, null)
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
108
|
`
|
|
@@ -565,7 +567,7 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
565
567
|
assertNotNull(${resdatavar}, "expected update result to be a map")
|
|
566
568
|
`)
|
|
567
569
|
if (hasEntIdU) {
|
|
568
|
-
Content(sameId(entity, `${resdatavar}[${rid(entity)}]`, `${datavar}Up["id"]`,
|
|
570
|
+
Content(sameId(liveRepeatsId(entity), `${resdatavar}[${rid(entity)}]`, `${datavar}Up["id"]`,
|
|
569
571
|
'expected update result id to match'))
|
|
570
572
|
}
|
|
571
573
|
|
|
@@ -627,7 +629,7 @@ const generateLoad: OpGen = (ctx, step, index) => {
|
|
|
627
629
|
${loadMatch(entity, step, matchvar, srcdatavar)}${liveFill(entity, step, matchvar, flow)} val ${datavar}Loaded = ${entvar}.load(${matchvar}, null)
|
|
628
630
|
val ${datavar}LoadResult = Helpers.toMapAny(if (${datavar}Loaded is SdkEntity) ${datavar}Loaded.data() else ${datavar}Loaded) ?: linkedMapOf()
|
|
629
631
|
assertNotNull(${datavar}LoadResult, "expected load result to be a map")
|
|
630
|
-
${sameId(entity, `${datavar}LoadResult[${rid(entity)}]`, `${srcdatavar}[${rid(entity)}]`,
|
|
632
|
+
${sameId(liveLoadComparesId(entity, flow), `${datavar}LoadResult[${rid(entity)}]`, `${srcdatavar}[${rid(entity)}]`,
|
|
631
633
|
'expected load result id to match')}`)
|
|
632
634
|
} else {
|
|
633
635
|
Content(`${loadMatch(entity, step, matchvar, srcdatavar)}${liveFill(entity, step, matchvar, flow)} val ${datavar}Loaded = ${entvar}.load(${matchvar}, null)
|
|
@@ -673,11 +675,11 @@ const LIVE_PACE = ` if (setup.live) {
|
|
|
673
675
|
`
|
|
674
676
|
|
|
675
677
|
|
|
676
|
-
// A result's identity matches the one asked for, live only
|
|
677
|
-
//
|
|
678
|
-
function sameId(
|
|
678
|
+
// A result's identity matches the one asked for, live only as the live
|
|
679
|
+
// entity harness compares it.
|
|
680
|
+
function sameId(compares: boolean, result: string, expected: string, message: string): string {
|
|
679
681
|
const check = `assertTrue(RunnerSupport.liveSameId(${result}, ${expected}), ${JSON.stringify(message)})`
|
|
680
|
-
return
|
|
682
|
+
return !compares ? ` if (!setup.live) {
|
|
681
683
|
${check}
|
|
682
684
|
}
|
|
683
685
|
` : ` ${check}
|
|
@@ -719,12 +721,22 @@ function kotlinIdLit(value: any): string {
|
|
|
719
721
|
// A live step sends each example its route requires and the step leaves unbound.
|
|
720
722
|
function liveFill(entity: any, step: any, matchvar: string, flow: any): string {
|
|
721
723
|
const fills = liveStepExamples(entity, step, flow)
|
|
722
|
-
|
|
723
|
-
|
|
724
|
+
const omit = liveUnrouted(entity, step, flow)
|
|
725
|
+
return 0 === fills.length + omit.length ? '' : ` if (setup.live) {
|
|
726
|
+
${fills.map(([k, ex]) => ` ${matchvar}[${JSON.stringify(k)}] = ${kotlinLit(ex)}\n`).join('')}${liveOmit(omit, matchvar, ' ')} }
|
|
724
727
|
`
|
|
725
728
|
}
|
|
726
729
|
|
|
727
730
|
|
|
731
|
+
// A binding the live route does not take is sent only as *_ENTID gives it.
|
|
732
|
+
function liveOmit(omit: [string, string][], matchvar: string, indent: string): string {
|
|
733
|
+
return omit.map(([name, key]) => `${indent}if (setup.syntheticOnly || setup.idmap?.get(${JSON.stringify(key)}) == null) {
|
|
734
|
+
${indent} ${matchvar}.remove(${JSON.stringify(name)})
|
|
735
|
+
${indent}}
|
|
736
|
+
`).join('')
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
|
|
728
740
|
function parentMatch(step: any, matchvar: string): string {
|
|
729
741
|
return Object.entries(step.m || {})
|
|
730
742
|
.filter(([k]: any) => k !== 'id' && !k.endsWith('$'))
|
|
@@ -14,12 +14,14 @@ const ReadmeExamplesTest = cmp(function ReadmeExamplesTest(props: any) {
|
|
|
14
14
|
// resolves offline. Bracket-string keys keep the literal valid for any
|
|
15
15
|
// entity name.
|
|
16
16
|
const entity = getModelPath(model, `main.${KIT}.entity`) || {}
|
|
17
|
-
const
|
|
17
|
+
const seedEntries = Object.values(entity)
|
|
18
18
|
.filter((e: any) => e && e.active !== false)
|
|
19
|
-
.map((e: any) =>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
.map((e: any) => {
|
|
20
|
+
const idField = e.id?.field
|
|
21
|
+
const extra = 'string' === typeof idField && '' !== idField && 'id' !== idField
|
|
22
|
+
? `, [${JSON.stringify(idField)}] = "test01"` : ''
|
|
23
|
+
return `["${e.name}"] = { ["test01"] = { id = "test01"${extra} } }`
|
|
24
|
+
})
|
|
23
25
|
.join(', ')
|
|
24
26
|
const seedLiteral = `{ entity = { ${seedEntries} } }`
|
|
25
27
|
|
|
@@ -102,6 +102,18 @@ local client = sdk.test()
|
|
|
102
102
|
${testModeExample}
|
|
103
103
|
\`\`\`
|
|
104
104
|
|
|
105
|
+
### Verify the server over HTTPS
|
|
106
|
+
|
|
107
|
+
An \`https://\` request goes through LuaSocket and LuaSec, and the SDK checks
|
|
108
|
+
the server itself before any of the request is sent: its certificate against
|
|
109
|
+
the system's trust store, and its name against the host (an address against
|
|
110
|
+
the certificate's addresses). Nothing turns that off. \`SSL_CERT_FILE\` or
|
|
111
|
+
\`SSL_CERT_DIR\` names the trust store, as for OpenSSL; with neither set and no
|
|
112
|
+
system store found, an \`https://\` request fails rather than going unverified.
|
|
113
|
+
\`${envName(model)}_CA_BUNDLE\` names a PEM file of roots added to the store,
|
|
114
|
+
for a local service with its own certificate authority or a self-signed
|
|
115
|
+
certificate. A different policy is a custom fetch function, described next.
|
|
116
|
+
|
|
105
117
|
### Use a custom fetch function
|
|
106
118
|
|
|
107
119
|
Replace the HTTP transport with your own function:
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
liveFlowNeeds, liveStrict, liveStrictNote,
|
|
33
33
|
liveRouteExamples, liveStepExamples, flowLoadRoute, flowLoadReadsRecord,
|
|
34
34
|
liveGates, liveExcludedLines, liveExcludedSummary, LIVE_GETONLY_ENV,
|
|
35
|
-
liveEntity, liveIdentity,
|
|
35
|
+
liveEntity, liveIdentity, liveRepeatsId, liveLoadComparesId, liveUnrouted,
|
|
36
36
|
} from '@voxgig/sdkgen'
|
|
37
37
|
|
|
38
38
|
import { formatLuaValue } from './utility_lua'
|
|
@@ -92,10 +92,11 @@ function liveFlowGate(entity: any, needs: any, identity: any, entidEnv: string,
|
|
|
92
92
|
`
|
|
93
93
|
}
|
|
94
94
|
if (null != needs.discover) {
|
|
95
|
-
const match = Object.entries(needs.discover)
|
|
95
|
+
const match = '{' + Object.entries(needs.discover)
|
|
96
96
|
.map(([k, v]: any) => `[${JSON.stringify(k)}] = setup.idmap[${JSON.stringify(v)}]`)
|
|
97
97
|
.concat(liveRouteExamples(entity, 'list', Object.keys(needs.discover))
|
|
98
|
-
.map(([k, ex]) => `[${JSON.stringify(k)}] = ${formatLuaValue(ex)}`)).join(', ')
|
|
98
|
+
.map(([k, ex]) => `[${JSON.stringify(k)}] = ${formatLuaValue(ex)}`)).join(', ') + '}'
|
|
99
|
+
const omit = needs.unrouted || []
|
|
99
100
|
out += ` if setup.live then
|
|
100
101
|
local _live_id = nil
|
|
101
102
|
if not setup.synthetic_only then
|
|
@@ -104,9 +105,10 @@ function liveFlowGate(entity: any, needs: any, identity: any, entidEnv: string,
|
|
|
104
105
|
${undefined === identity.ex ? '' : ` if _live_id == nil then
|
|
105
106
|
_live_id = ${formatLuaValue(identity.ex)}
|
|
106
107
|
end
|
|
107
|
-
`}
|
|
108
|
+
`}${0 === omit.length ? '' : ` local _live_match = ${match}
|
|
109
|
+
${liveOmit(omit, '_live_match', ' ')}`} runner.live_pace()
|
|
108
110
|
runner.live_existing(pending, setup, LIVE_STRICT, ${JSON.stringify(entity.name)}, function()
|
|
109
|
-
return client:${entity.Name}(nil):list(
|
|
111
|
+
return client:${entity.Name}(nil):list(${0 === omit.length ? match : '_live_match'}, nil)
|
|
110
112
|
end, ${JSON.stringify(identity.field)}, _live_id)
|
|
111
113
|
end
|
|
112
114
|
`
|
|
@@ -598,7 +600,7 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
598
600
|
assert.is_not_nil(${resdatavar})
|
|
599
601
|
`)
|
|
600
602
|
if (hasEntIdU) {
|
|
601
|
-
Content(sameId(entity, `${resdatavar}[${rid(entity)}]`, `${datavar}_up["id"]`))
|
|
603
|
+
Content(sameId(liveRepeatsId(entity), `${resdatavar}[${rid(entity)}]`, `${datavar}_up["id"]`))
|
|
602
604
|
}
|
|
603
605
|
|
|
604
606
|
if (step.s) {
|
|
@@ -661,7 +663,7 @@ ${loadMatch(entity, step, matchvar, srcdatavar)}${liveFill(entity, step, matchva
|
|
|
661
663
|
assert.is_nil(err)
|
|
662
664
|
local ${datavar}_load_result = helpers.to_map(type(${datavar}_loaded) == 'table' and ${datavar}_loaded.data_get and ${datavar}_loaded:data_get() or ${datavar}_loaded)
|
|
663
665
|
assert.is_not_nil(${datavar}_load_result)
|
|
664
|
-
${sameId(entity, `${datavar}_load_result[${rid(entity)}]`, `${srcdatavar}[${rid(entity)}]`)}`)
|
|
666
|
+
${sameId(liveLoadComparesId(entity, flow), `${datavar}_load_result[${rid(entity)}]`, `${srcdatavar}[${rid(entity)}]`)}`)
|
|
665
667
|
}
|
|
666
668
|
else {
|
|
667
669
|
Content(` local ${matchvar} = {}
|
|
@@ -716,11 +718,11 @@ const LIVE_PACE = ` if setup.live then
|
|
|
716
718
|
`
|
|
717
719
|
|
|
718
720
|
|
|
719
|
-
// A result's identity matches the one asked for, live only
|
|
720
|
-
//
|
|
721
|
-
function sameId(
|
|
721
|
+
// A result's identity matches the one asked for, live only as the live
|
|
722
|
+
// entity harness compares it.
|
|
723
|
+
function sameId(compares: boolean, result: string, expected: string): string {
|
|
722
724
|
const check = `assert.is_true(runner.live_same_id(${result}, ${expected}))`
|
|
723
|
-
return
|
|
725
|
+
return !compares ? ` if not setup.live then
|
|
724
726
|
${check}
|
|
725
727
|
end
|
|
726
728
|
` : ` ${check}
|
|
@@ -748,12 +750,22 @@ function fixtureIdentity(entity: any): string {
|
|
|
748
750
|
// A live step sends each example its route requires and the step leaves unbound.
|
|
749
751
|
function liveFill(entity: any, step: any, matchvar: string, flow: any): string {
|
|
750
752
|
const fills = liveStepExamples(entity, step, flow)
|
|
751
|
-
|
|
752
|
-
|
|
753
|
+
const omit = liveUnrouted(entity, step, flow)
|
|
754
|
+
return 0 === fills.length + omit.length ? '' : ` if setup.live then
|
|
755
|
+
${fills.map(([k, ex]) => ` ${matchvar}[${JSON.stringify(k)}] = ${formatLuaValue(ex)}\n`).join('')}${liveOmit(omit, matchvar, ' ')} end
|
|
753
756
|
`
|
|
754
757
|
}
|
|
755
758
|
|
|
756
759
|
|
|
760
|
+
// A binding the live route does not take is sent only as *_ENTID gives it.
|
|
761
|
+
function liveOmit(omit: [string, string][], matchvar: string, indent: string): string {
|
|
762
|
+
return omit.map(([name, key]) => `${indent}if setup.synthetic_only or setup.idmap[${JSON.stringify(key)}] == nil then
|
|
763
|
+
${indent} ${matchvar}[${JSON.stringify(name)}] = nil
|
|
764
|
+
${indent}end
|
|
765
|
+
`).join('')
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
|
|
757
769
|
function parentMatch(step: any, matchvar: string): string {
|
|
758
770
|
return Object.entries(step.m || {})
|
|
759
771
|
.filter(([k]: any) => k !== 'id' && !k.endsWith('$'))
|
|
@@ -21,6 +21,13 @@ const ReadmeExamplesTest = cmp(function ReadmeExamplesTest(props: any) {
|
|
|
21
21
|
.map((e: any) => ` '${nom(e, 'Name')}' => '${e.name}',`)
|
|
22
22
|
.join('\n')
|
|
23
23
|
|
|
24
|
+
// The declared identity field of each entity that names one other than
|
|
25
|
+
// `id`, by fixture key: the mock keys a record by it, so the seed does too.
|
|
26
|
+
const idFieldLines = entities
|
|
27
|
+
.filter((e: any) => 'string' === typeof e.id?.field && '' !== e.id.field && 'id' !== e.id.field)
|
|
28
|
+
.map((e: any) => ` '${e.name}' => '${String(e.id.field).replace(/[\\']/g, '\\$&')}',`)
|
|
29
|
+
.join('\n')
|
|
30
|
+
|
|
24
31
|
// Perl test files use the `.t` extension (run by `prove`), not target.ext
|
|
25
32
|
// (`pl`); this component is invoked inside the `t/` folder by Test_perl.
|
|
26
33
|
File({ name: 'readme_examples.t' }, () => {
|
|
@@ -75,6 +82,11 @@ my %ENTITIES = (
|
|
|
75
82
|
${entityLines}
|
|
76
83
|
);
|
|
77
84
|
|
|
85
|
+
# Fixture key => the entity's declared identity field, where it is not "id".
|
|
86
|
+
my %ID_FIELDS = (
|
|
87
|
+
${idFieldLines}
|
|
88
|
+
);
|
|
89
|
+
|
|
78
90
|
# Documented SDK method names - used only to recognise the NARROW
|
|
79
91
|
# signature/method-table "illustration" class.
|
|
80
92
|
my @METHODS = qw(options_map get_utility prepare direct data_get data_set match_get match_set make get_name);
|
|
@@ -199,7 +211,9 @@ sub fixtures_literal {
|
|
|
199
211
|
%refs = %ENTITIES unless %refs;
|
|
200
212
|
my @pairs;
|
|
201
213
|
for my $name (sort keys %refs) {
|
|
202
|
-
|
|
214
|
+
my $storage = $refs{$name};
|
|
215
|
+
my $extra = exists $ID_FIELDS{$storage} ? ", '" . $ID_FIELDS{$storage} . "' => 'test01'" : '';
|
|
216
|
+
push @pairs, "'" . $storage . "' => { 'test01' => { 'id' => 'test01'" . $extra . " } }";
|
|
203
217
|
}
|
|
204
218
|
return "{ 'entity' => { " . join(', ', @pairs) . " } }";
|
|
205
219
|
}
|