@voxgig/sdkgen 4.22.0 → 4.23.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/cmp/ReadmeUnions.js +1 -1
- package/dist/cmp/ReadmeUnions.js.map +1 -1
- package/dist/cmp/Test.js +1 -1
- package/dist/cmp/Test.js.map +1 -1
- package/dist/helpers/buildIdNames.d.ts +3 -1
- package/dist/helpers/buildIdNames.js +15 -7
- package/dist/helpers/buildIdNames.js.map +1 -1
- package/dist/helpers/canonSpec.js +2 -2
- package/dist/helpers/canonSpec.js.map +1 -1
- package/dist/helpers/getMatchEntries.js +2 -2
- package/dist/helpers/getMatchEntries.js.map +1 -1
- package/dist/helpers/modelNames.js +5 -1
- package/dist/helpers/modelNames.js.map +1 -1
- package/dist/helpers/opShape.js +33 -33
- package/dist/helpers/opShape.js.map +1 -1
- package/dist/helpers/pointPath.js +5 -10
- package/dist/helpers/pointPath.js.map +1 -1
- package/dist/helpers/resolved.js +2 -29
- package/dist/helpers/resolved.js.map +1 -1
- package/dist/sdkgen.d.ts +2 -2
- package/dist/sdkgen.js +5 -3
- package/dist/sdkgen.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utility.js +15 -7
- package/dist/utility.js.map +1 -1
- package/package.json +3 -3
- package/project/.sdk/src/cmp/c/EntityTypes_c.ts +4 -4
- package/project/.sdk/src/cmp/c/ReadmeEntity_c.ts +3 -3
- package/project/.sdk/src/cmp/c/ReadmeModel_c.ts +3 -3
- package/project/.sdk/src/cmp/c/ReadmeRef_c.ts +5 -5
- package/project/.sdk/src/cmp/c/Schema_c.ts +1 -1
- package/project/.sdk/src/cmp/c/TestDirect_c.ts +12 -12
- package/project/.sdk/src/cmp/clojure/ReadmeEntity_clojure.ts +3 -3
- package/project/.sdk/src/cmp/clojure/ReadmeModel_clojure.ts +3 -3
- package/project/.sdk/src/cmp/clojure/ReadmeRef_clojure.ts +5 -5
- package/project/.sdk/src/cmp/clojure/Schema_clojure.ts +1 -1
- package/project/.sdk/src/cmp/cpp/EntityTypes_cpp.ts +3 -3
- package/project/.sdk/src/cmp/cpp/ReadmeEntity_cpp.ts +3 -3
- package/project/.sdk/src/cmp/cpp/ReadmeModel_cpp.ts +3 -3
- package/project/.sdk/src/cmp/cpp/ReadmeRef_cpp.ts +5 -5
- package/project/.sdk/src/cmp/cpp/Schema_cpp.ts +1 -1
- package/project/.sdk/src/cmp/cpp/TestDirect_cpp.ts +14 -14
- package/project/.sdk/src/cmp/cpp/TestEntity_cpp.ts +51 -50
- package/project/.sdk/src/cmp/csharp/EntityTypes_csharp.ts +4 -4
- package/project/.sdk/src/cmp/csharp/ReadmeEntity_csharp.ts +3 -3
- package/project/.sdk/src/cmp/csharp/ReadmeModel_csharp.ts +3 -3
- package/project/.sdk/src/cmp/csharp/ReadmeRef_csharp.ts +5 -5
- package/project/.sdk/src/cmp/csharp/Schema_csharp.ts +1 -1
- package/project/.sdk/src/cmp/csharp/TestDirect_csharp.ts +30 -30
- package/project/.sdk/src/cmp/csharp/TestEntity_csharp.ts +66 -65
- package/project/.sdk/src/cmp/elixir/EntityTypes_elixir.ts +4 -4
- package/project/.sdk/src/cmp/elixir/ReadmeEntity_elixir.ts +3 -3
- package/project/.sdk/src/cmp/elixir/ReadmeModel_elixir.ts +3 -3
- package/project/.sdk/src/cmp/elixir/ReadmeRef_elixir.ts +4 -4
- package/project/.sdk/src/cmp/elixir/Schema_elixir.ts +1 -1
- package/project/.sdk/src/cmp/go/EntityTypes_go.ts +4 -4
- package/project/.sdk/src/cmp/go/ReadmeEntity_go.ts +3 -3
- package/project/.sdk/src/cmp/go/ReadmeModel_go.ts +3 -3
- package/project/.sdk/src/cmp/go/ReadmeRef_go.ts +5 -5
- package/project/.sdk/src/cmp/go/Schema_go.ts +1 -1
- package/project/.sdk/src/cmp/go/TestDirect_go.ts +38 -38
- package/project/.sdk/src/cmp/go/TestEntity_go.ts +75 -74
- package/project/.sdk/src/cmp/go/utility_go.ts +5 -5
- package/project/.sdk/src/cmp/java/EntityTypes_java.ts +4 -4
- package/project/.sdk/src/cmp/java/ReadmeEntity_java.ts +3 -3
- package/project/.sdk/src/cmp/java/ReadmeModel_java.ts +3 -3
- package/project/.sdk/src/cmp/java/ReadmeRef_java.ts +5 -5
- package/project/.sdk/src/cmp/java/Schema_java.ts +1 -1
- package/project/.sdk/src/cmp/java/TestDirect_java.ts +30 -30
- package/project/.sdk/src/cmp/java/TestEntity_java.ts +69 -68
- package/project/.sdk/src/cmp/js/EntityTypes_js.ts +5 -5
- package/project/.sdk/src/cmp/js/ReadmeEntity_js.ts +3 -3
- package/project/.sdk/src/cmp/js/ReadmeModel_js.ts +3 -3
- package/project/.sdk/src/cmp/js/ReadmeRef_js.ts +5 -5
- package/project/.sdk/src/cmp/js/Schema_js.ts +1 -1
- package/project/.sdk/src/cmp/js/TestDirect_js.ts +27 -27
- package/project/.sdk/src/cmp/js/TestEntity_js.ts +66 -69
- package/project/.sdk/src/cmp/js/TestLive_js.ts +3 -3
- package/project/.sdk/src/cmp/js/utility_js.ts +5 -5
- package/project/.sdk/src/cmp/kotlin/EntityTypes_kotlin.ts +4 -4
- package/project/.sdk/src/cmp/kotlin/ReadmeEntity_kotlin.ts +3 -3
- package/project/.sdk/src/cmp/kotlin/ReadmeModel_kotlin.ts +3 -3
- package/project/.sdk/src/cmp/kotlin/ReadmeRef_kotlin.ts +5 -5
- package/project/.sdk/src/cmp/kotlin/Schema_kotlin.ts +1 -1
- package/project/.sdk/src/cmp/kotlin/TestDirect_kotlin.ts +30 -30
- package/project/.sdk/src/cmp/kotlin/TestEntity_kotlin.ts +67 -66
- package/project/.sdk/src/cmp/lua/EntityTypes_lua.ts +5 -5
- package/project/.sdk/src/cmp/lua/ReadmeEntity_lua.ts +3 -3
- package/project/.sdk/src/cmp/lua/ReadmeModel_lua.ts +3 -3
- package/project/.sdk/src/cmp/lua/ReadmeQuick_lua.ts +4 -4
- package/project/.sdk/src/cmp/lua/ReadmeRef_lua.ts +5 -5
- package/project/.sdk/src/cmp/lua/Schema_lua.ts +1 -1
- package/project/.sdk/src/cmp/lua/TestDirect_lua.ts +25 -25
- package/project/.sdk/src/cmp/lua/TestEntity_lua.ts +66 -65
- package/project/.sdk/src/cmp/ocaml/ReadmeEntity_ocaml.ts +3 -3
- package/project/.sdk/src/cmp/ocaml/ReadmeModel_ocaml.ts +3 -3
- package/project/.sdk/src/cmp/ocaml/ReadmeRef_ocaml.ts +5 -5
- package/project/.sdk/src/cmp/ocaml/Schema_ocaml.ts +1 -1
- package/project/.sdk/src/cmp/perl/ReadmeEntity_perl.ts +3 -3
- package/project/.sdk/src/cmp/perl/ReadmeModel_perl.ts +3 -3
- package/project/.sdk/src/cmp/perl/ReadmeRef_perl.ts +5 -5
- package/project/.sdk/src/cmp/perl/Schema_perl.ts +1 -1
- package/project/.sdk/src/cmp/perl/TestDirect_perl.ts +25 -25
- package/project/.sdk/src/cmp/perl/TestEntity_perl.ts +60 -59
- package/project/.sdk/src/cmp/php/EntityTypes_php.ts +4 -4
- package/project/.sdk/src/cmp/php/ReadmeEntity_php.ts +3 -3
- package/project/.sdk/src/cmp/php/ReadmeModel_php.ts +3 -3
- package/project/.sdk/src/cmp/php/ReadmeQuick_php.ts +4 -4
- package/project/.sdk/src/cmp/php/ReadmeRef_php.ts +5 -5
- package/project/.sdk/src/cmp/php/Schema_php.ts +1 -1
- package/project/.sdk/src/cmp/php/TestDirect_php.ts +25 -25
- package/project/.sdk/src/cmp/php/TestEntity_php.ts +66 -65
- package/project/.sdk/src/cmp/py/EntityTypes_py.ts +4 -4
- package/project/.sdk/src/cmp/py/ReadmeEntity_py.ts +3 -3
- package/project/.sdk/src/cmp/py/ReadmeModel_py.ts +3 -3
- package/project/.sdk/src/cmp/py/ReadmeRef_py.ts +5 -5
- package/project/.sdk/src/cmp/py/Schema_py.ts +1 -1
- package/project/.sdk/src/cmp/py/TestDirect_py.ts +25 -25
- package/project/.sdk/src/cmp/py/TestEntity_py.ts +66 -65
- package/project/.sdk/src/cmp/py-data/Main_py-data.ts +4 -4
- package/project/.sdk/src/cmp/rb/EntityTypes_rb.ts +4 -4
- package/project/.sdk/src/cmp/rb/ReadmeEntity_rb.ts +3 -3
- package/project/.sdk/src/cmp/rb/ReadmeModel_rb.ts +3 -3
- package/project/.sdk/src/cmp/rb/ReadmeQuick_rb.ts +4 -4
- package/project/.sdk/src/cmp/rb/ReadmeRef_rb.ts +5 -5
- package/project/.sdk/src/cmp/rb/Schema_rb.ts +1 -1
- package/project/.sdk/src/cmp/rb/TestDirect_rb.ts +25 -25
- package/project/.sdk/src/cmp/rb/TestEntity_rb.ts +66 -65
- package/project/.sdk/src/cmp/rust/EntityTypes_rust.ts +4 -4
- package/project/.sdk/src/cmp/rust/ReadmeEntity_rust.ts +3 -3
- package/project/.sdk/src/cmp/rust/ReadmeModel_rust.ts +3 -3
- package/project/.sdk/src/cmp/rust/ReadmeRef_rust.ts +5 -5
- package/project/.sdk/src/cmp/rust/Schema_rust.ts +1 -1
- package/project/.sdk/src/cmp/rust/TestDirect_rust.ts +18 -18
- package/project/.sdk/src/cmp/rust/TestEntity_rust.ts +63 -62
- package/project/.sdk/src/cmp/scala/EntityTypes_scala.ts +4 -4
- package/project/.sdk/src/cmp/scala/ReadmeEntity_scala.ts +3 -3
- package/project/.sdk/src/cmp/scala/ReadmeModel_scala.ts +3 -3
- package/project/.sdk/src/cmp/scala/ReadmeRef_scala.ts +5 -5
- package/project/.sdk/src/cmp/scala/Schema_scala.ts +1 -1
- package/project/.sdk/src/cmp/scala/TestDirect_scala.ts +14 -14
- package/project/.sdk/src/cmp/scala/TestEntity_scala.ts +60 -59
- package/project/.sdk/src/cmp/swift/EntityTypes_swift.ts +4 -4
- package/project/.sdk/src/cmp/swift/ReadmeEntity_swift.ts +3 -3
- package/project/.sdk/src/cmp/swift/ReadmeModel_swift.ts +3 -3
- package/project/.sdk/src/cmp/swift/ReadmeRef_swift.ts +5 -5
- package/project/.sdk/src/cmp/swift/Schema_swift.ts +1 -1
- package/project/.sdk/src/cmp/ts/EntityTypes_ts.ts +5 -5
- package/project/.sdk/src/cmp/ts/ReadmeEntity_ts.ts +3 -3
- package/project/.sdk/src/cmp/ts/ReadmeModel_ts.ts +3 -3
- package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +1 -1
- package/project/.sdk/src/cmp/ts/ReadmeRef_ts.ts +5 -5
- package/project/.sdk/src/cmp/ts/Schema_ts.ts +1 -1
- package/project/.sdk/src/cmp/ts/TestDirect_ts.ts +40 -40
- package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +72 -75
- package/project/.sdk/src/cmp/ts/TestLive_ts.ts +3 -3
- package/project/.sdk/src/cmp/ts/utility_ts.ts +5 -5
- package/project/.sdk/src/cmp/zig/ReadmeEntity_zig.ts +3 -3
- package/project/.sdk/src/cmp/zig/ReadmeModel_zig.ts +3 -3
- package/project/.sdk/src/cmp/zig/ReadmeRef_zig.ts +5 -5
- package/project/.sdk/src/cmp/zig/Schema_zig.ts +1 -1
- package/project/.sdk/tm/c/feature/test.c +20 -4
- package/project/.sdk/tm/clojure/src/sdk/features.clj +6 -4
- package/project/.sdk/tm/cpp/feature/test.hpp +17 -6
- package/project/.sdk/tm/csharp/feature/TestFeature.cs +10 -4
- package/project/.sdk/tm/elixir/lib/projectname/feature/test.ex +11 -5
- package/project/.sdk/tm/java/feature/TestFeature.java +11 -6
- package/project/.sdk/tm/js/test/live-entity.js +29 -29
- package/project/.sdk/tm/js/test/live-scenarios.js +4 -4
- package/project/.sdk/tm/kotlin/feature/TestFeature.kt +8 -4
- package/project/.sdk/tm/ocaml/sdk_features.ml +6 -4
- package/project/.sdk/tm/perl/feature/test_feature.pm +6 -4
- package/project/.sdk/tm/rb/feature/test_feature.rb +6 -4
- package/project/.sdk/tm/rust/feature/test.rs +8 -4
- package/project/.sdk/tm/scala/feature/TestFeature.scala +10 -6
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/TestFeature.swift +10 -6
- package/project/.sdk/tm/ts/test/live-entity.ts +26 -26
- package/project/.sdk/tm/ts/test/live-scenarios.ts +3 -3
- package/project/.sdk/tm/zig/feature/test.zig +11 -4
- package/project/sdkgen-package.json +1 -1
- package/src/cmp/ReadmeTop.ts +1 -1
- package/src/cmp/ReadmeUnions.ts +1 -1
- package/src/cmp/Test.ts +1 -1
- package/src/helpers/buildIdNames.ts +17 -7
- package/src/helpers/canonSpec.ts +2 -2
- package/src/helpers/getMatchEntries.ts +2 -2
- package/src/helpers/modelNames.ts +6 -1
- package/src/helpers/opShape.ts +33 -33
- package/src/helpers/pointPath.ts +5 -10
- package/src/helpers/resolved.ts +3 -14
- package/src/sdkgen.ts +3 -1
- package/src/utility.ts +16 -7
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { flowSteps } from '@voxgig/sdkgen'
|
|
1
2
|
|
|
2
3
|
import {
|
|
3
4
|
KIT,
|
|
@@ -85,17 +86,17 @@ const TestEntity = cmp(function TestEntity(props: any) {
|
|
|
85
86
|
const idnamesStr = idnames.map(n => `"${n}"`).join(', ')
|
|
86
87
|
|
|
87
88
|
// Get all update data entries for alias generation
|
|
88
|
-
const allSteps = Object.values(basicflow
|
|
89
|
-
const updateStep = allSteps.find((s: any) => s.
|
|
90
|
-
const updateData = updateStep?.
|
|
91
|
-
? Object.entries(updateStep.
|
|
89
|
+
const allSteps = Object.values(flowSteps(basicflow)) as any[]
|
|
90
|
+
const updateStep = allSteps.find((s: any) => s.o === 'update')
|
|
91
|
+
const updateData = updateStep?.d
|
|
92
|
+
? Object.entries(updateStep.d).filter(([k]: any) => k !== 'id' && !k.endsWith('$'))
|
|
92
93
|
: []
|
|
93
94
|
const aliases = updateData.map(([k, v]: any) => [k, v])
|
|
94
95
|
|
|
95
96
|
const genCtx: GenCtx = { model, entity, flow: basicflow, PROJUPPER }
|
|
96
97
|
|
|
97
98
|
const opNames = Array.from(new Set(
|
|
98
|
-
(allSteps as any[]).map((s: any) => s.
|
|
99
|
+
(allSteps as any[]).map((s: any) => s.o).filter(Boolean)))
|
|
99
100
|
const opsList = opNames.map(o => `"${o}"`).join(', ')
|
|
100
101
|
|
|
101
102
|
// An entity whose basic flow has no ops must not emit the per-op skip
|
|
@@ -152,7 +153,7 @@ ${skipBlock} // The basic flow consumes synthetic IDs from the fixture. I
|
|
|
152
153
|
${allSteps.length > 0 ? ' var client = setup.Client;\n\n' : ''}`)
|
|
153
154
|
|
|
154
155
|
// Check if the flow has a create step; if not, bootstrap entity data
|
|
155
|
-
const flowHasCreate = allSteps.some((s: any) => s.
|
|
156
|
+
const flowHasCreate = allSteps.some((s: any) => s.o === 'create')
|
|
156
157
|
if (!flowHasCreate) {
|
|
157
158
|
const preambleRef = entity.name + '_ref01'
|
|
158
159
|
const preambleVar = csVar(preambleRef)
|
|
@@ -167,8 +168,8 @@ ${allSteps.length > 0 ? ' var client = setup.Client;\n\n' : ''}`)
|
|
|
167
168
|
}
|
|
168
169
|
|
|
169
170
|
// Model-driven step iteration
|
|
170
|
-
each(basicflow
|
|
171
|
-
const opgen: OpGen = GENERATE_OP[step.
|
|
171
|
+
each(flowSteps(basicflow), (step: any, index: any) => {
|
|
172
|
+
const opgen: OpGen = GENERATE_OP[step.o]
|
|
172
173
|
if (opgen) {
|
|
173
174
|
opgen(genCtx, step, index)
|
|
174
175
|
Content('\n')
|
|
@@ -179,7 +180,7 @@ ${allSteps.length > 0 ? ' var client = setup.Client;\n\n' : ''}`)
|
|
|
179
180
|
|
|
180
181
|
`)
|
|
181
182
|
|
|
182
|
-
const flowHasList = allSteps.some((s: any) => s.
|
|
183
|
+
const flowHasList = allSteps.some((s: any) => s.o === 'list')
|
|
183
184
|
if (flowHasList) {
|
|
184
185
|
Content(` [Fact]
|
|
185
186
|
public async Task Stream()
|
|
@@ -339,18 +340,18 @@ ${allSteps.length > 0 ? ' var client = setup.Client;\n\n' : ''}`)
|
|
|
339
340
|
|
|
340
341
|
const generateCreate: OpGen = (ctx, step, index) => {
|
|
341
342
|
const { entity, flow } = ctx
|
|
342
|
-
const ref = step.
|
|
343
|
-
const entvar = csVar(step.
|
|
344
|
-
const datavar = csVar(step.
|
|
343
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
344
|
+
const entvar = csVar(step.i.entvar ?? ref + '_ent')
|
|
345
|
+
const datavar = csVar(step.i.datavar ?? (ref + '_data' + (step.i.suffix ?? '')))
|
|
345
346
|
|
|
346
|
-
const priorSteps = Object.values(flow
|
|
347
|
+
const priorSteps = Object.values(flowSteps(flow)).slice(0, Number(index)) as any[]
|
|
347
348
|
const needsEnt = !priorSteps.some((s: any) =>
|
|
348
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
349
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
349
350
|
|
|
350
351
|
const hasDatvar = priorSteps.some((s: any) => {
|
|
351
|
-
if ('create' === s.
|
|
352
|
-
const priorRef = s.
|
|
353
|
-
const priorDatvar = csVar(s.
|
|
352
|
+
if ('create' === s.o) {
|
|
353
|
+
const priorRef = s.i.ref ?? entity.name + '_ref01'
|
|
354
|
+
const priorDatvar = csVar(s.i.datavar ?? (priorRef + '_data' + (s.i.suffix ?? '')))
|
|
354
355
|
return priorDatvar === datavar
|
|
355
356
|
}
|
|
356
357
|
return false
|
|
@@ -390,14 +391,14 @@ const generateCreate: OpGen = (ctx, step, index) => {
|
|
|
390
391
|
|
|
391
392
|
const generateList: OpGen = (ctx, step, index) => {
|
|
392
393
|
const { entity, flow } = ctx
|
|
393
|
-
const ref = step.
|
|
394
|
-
const entvar = csVar(step.
|
|
395
|
-
const matchvar = csVar(step.
|
|
396
|
-
const listvar = csVar(step.
|
|
394
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
395
|
+
const entvar = csVar(step.i.entvar ?? ref + '_ent')
|
|
396
|
+
const matchvar = csVar(step.i.matchvar ?? (ref + '_match' + (step.i.suffix ?? '')))
|
|
397
|
+
const listvar = csVar(step.i.listvar ?? (ref + '_list' + (step.i.suffix ?? '')))
|
|
397
398
|
|
|
398
|
-
const priorSteps = Object.values(flow
|
|
399
|
+
const priorSteps = Object.values(flowSteps(flow)).slice(0, Number(index)) as any[]
|
|
399
400
|
const needsEnt = !priorSteps.some((s: any) =>
|
|
400
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
401
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
401
402
|
|
|
402
403
|
Content(` // LIST
|
|
403
404
|
`)
|
|
@@ -430,13 +431,13 @@ const generateList: OpGen = (ctx, step, index) => {
|
|
|
430
431
|
$"expected list result to be a list, got {${listvar}Result?.GetType()}");
|
|
431
432
|
`)
|
|
432
433
|
|
|
433
|
-
// Handle validators from step.
|
|
434
|
-
const allSteps = Object.values(flow
|
|
435
|
-
if (step.
|
|
436
|
-
for (const validator of step.
|
|
434
|
+
// Handle validators from step.v
|
|
435
|
+
const allSteps = Object.values(flowSteps(flow)) as any[]
|
|
436
|
+
if (step.v) {
|
|
437
|
+
for (const validator of step.v) {
|
|
437
438
|
const validRef = validator.def?.ref
|
|
438
|
-
const hasRefData = validRef && allSteps.some((s: any) => 'create' === s.
|
|
439
|
-
((s.
|
|
439
|
+
const hasRefData = validRef && allSteps.some((s: any) => 'create' === s.o &&
|
|
440
|
+
((s.i.ref ?? entity.name + '_ref01') === validRef))
|
|
440
441
|
|
|
441
442
|
if ('ItemExists' === validator.apply && hasRefData) {
|
|
442
443
|
const refDataVar = csVar(validRef + '_data')
|
|
@@ -464,16 +465,16 @@ const generateList: OpGen = (ctx, step, index) => {
|
|
|
464
465
|
|
|
465
466
|
const generateUpdate: OpGen = (ctx, step, index) => {
|
|
466
467
|
const { entity, flow } = ctx
|
|
467
|
-
const ref = step.
|
|
468
|
-
const entvar = csVar(step.
|
|
469
|
-
const datavar = csVar(step.
|
|
470
|
-
const resdatavar = csVar(step.
|
|
471
|
-
const markdefvar = csVar(step.
|
|
472
|
-
const srcdatavar = csVar(step.
|
|
473
|
-
|
|
474
|
-
const priorSteps = Object.values(flow
|
|
468
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
469
|
+
const entvar = csVar(step.i.entvar ?? ref + '_ent')
|
|
470
|
+
const datavar = csVar(step.i.datavar ?? (ref + '_data' + (step.i.suffix ?? '')))
|
|
471
|
+
const resdatavar = csVar(step.i.resdatavar ?? (ref + '_resdata' + (step.i.suffix ?? '')))
|
|
472
|
+
const markdefvar = csVar(step.i.markdefvar ?? (ref + '_markdef' + (step.i.suffix ?? '')))
|
|
473
|
+
const srcdatavar = csVar(step.i.srcdatavar ?? (ref + '_data' + (step.i.suffix ?? '')))
|
|
474
|
+
|
|
475
|
+
const priorSteps = Object.values(flowSteps(flow)).slice(0, Number(index)) as any[]
|
|
475
476
|
const needsEnt = !priorSteps.some((s: any) =>
|
|
476
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
477
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
477
478
|
|
|
478
479
|
const hasEntIdU = null != entity.id
|
|
479
480
|
|
|
@@ -491,9 +492,9 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
491
492
|
`)
|
|
492
493
|
}
|
|
493
494
|
|
|
494
|
-
// Add data entries from step.
|
|
495
|
-
if (step.
|
|
496
|
-
const dataEntries = Object.entries(step.
|
|
495
|
+
// Add data entries from step.d
|
|
496
|
+
if (step.d) {
|
|
497
|
+
const dataEntries = Object.entries(step.d).filter(([k]: any) => k !== 'id' && !k.endsWith('$'))
|
|
497
498
|
for (const [key] of dataEntries) {
|
|
498
499
|
Content(` ["${key}"] = setup.Idmap["${key}"],
|
|
499
500
|
`)
|
|
@@ -504,10 +505,10 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
504
505
|
`)
|
|
505
506
|
|
|
506
507
|
// Handle TextFieldMark spec
|
|
507
|
-
if (step.
|
|
508
|
-
for (const spec of step.
|
|
509
|
-
if ('TextFieldMark' === spec.apply && null != step.
|
|
510
|
-
const fieldname = step.
|
|
508
|
+
if (step.s) {
|
|
509
|
+
for (const spec of step.s) {
|
|
510
|
+
if ('TextFieldMark' === spec.apply && null != step.i.textfield) {
|
|
511
|
+
const fieldname = step.i.textfield
|
|
511
512
|
const fieldvalue = spec.def?.mark ?? `Mark01-${ref}`
|
|
512
513
|
Content(`
|
|
513
514
|
var ${markdefvar}Name = "${fieldname}";
|
|
@@ -530,9 +531,9 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
530
531
|
}
|
|
531
532
|
|
|
532
533
|
// Assert TextFieldMark
|
|
533
|
-
if (step.
|
|
534
|
-
for (const spec of step.
|
|
535
|
-
if ('TextFieldMark' === spec.apply && null != step.
|
|
534
|
+
if (step.s) {
|
|
535
|
+
for (const spec of step.s) {
|
|
536
|
+
if ('TextFieldMark' === spec.apply && null != step.i.textfield) {
|
|
536
537
|
Content(` Assert.True(Equals(${resdatavar}![${markdefvar}Name], ${markdefvar}Value),
|
|
537
538
|
$"expected {${markdefvar}Name} to be updated, got {${resdatavar}[${markdefvar}Name]}");
|
|
538
539
|
`)
|
|
@@ -544,24 +545,24 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
544
545
|
|
|
545
546
|
const generateLoad: OpGen = (ctx, step, index) => {
|
|
546
547
|
const { entity, flow } = ctx
|
|
547
|
-
const ref = step.
|
|
548
|
-
const entvar = csVar(step.
|
|
549
|
-
const matchvar = csVar(step.
|
|
550
|
-
const datavar = csVar(step.
|
|
551
|
-
const srcdatavar = csVar(step.
|
|
548
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
549
|
+
const entvar = csVar(step.i.entvar ?? ref + '_ent')
|
|
550
|
+
const matchvar = csVar(step.i.matchvar ?? (ref + '_match' + (step.i.suffix ?? '')))
|
|
551
|
+
const datavar = csVar(step.i.datavar ?? (ref + '_data' + (step.i.suffix ?? '')))
|
|
552
|
+
const srcdatavar = csVar(step.i.srcdatavar ?? (ref + '_data' + (step.i.suffix ?? '')))
|
|
552
553
|
|
|
553
|
-
const priorSteps = Object.values(flow
|
|
554
|
+
const priorSteps = Object.values(flowSteps(flow)).slice(0, Number(index)) as any[]
|
|
554
555
|
const hasEntVar = priorSteps.some((s: any) =>
|
|
555
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
556
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
556
557
|
|
|
557
558
|
// Check if srcdatavar was declared by a prior create step or preamble
|
|
558
|
-
const flowHasCreate = Object.values(flow
|
|
559
|
+
const flowHasCreate = Object.values(flowSteps(flow)).some((s: any) => (s as any).o === 'create')
|
|
559
560
|
const preambleRef = entity.name + '_ref01'
|
|
560
561
|
const hasSrcData = (!flowHasCreate && srcdatavar === csVar(preambleRef + '_data')) ||
|
|
561
562
|
priorSteps.some((s: any) => {
|
|
562
|
-
if ('create' === s.
|
|
563
|
-
const priorRef = s.
|
|
564
|
-
const priorDatvar = csVar(s.
|
|
563
|
+
if ('create' === s.o) {
|
|
564
|
+
const priorRef = s.i.ref ?? entity.name + '_ref01'
|
|
565
|
+
const priorDatvar = csVar(s.i.datavar ?? (priorRef + '_data' + (s.i.suffix ?? '')))
|
|
565
566
|
return priorDatvar === srcdatavar
|
|
566
567
|
}
|
|
567
568
|
return false
|
|
@@ -606,14 +607,14 @@ const generateLoad: OpGen = (ctx, step, index) => {
|
|
|
606
607
|
|
|
607
608
|
const generateRemove: OpGen = (ctx, step, index) => {
|
|
608
609
|
const { entity, flow } = ctx
|
|
609
|
-
const ref = step.
|
|
610
|
-
const entvar = csVar(step.
|
|
611
|
-
const matchvar = csVar(step.
|
|
612
|
-
const srcdatavar = csVar(step.
|
|
610
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
611
|
+
const entvar = csVar(step.i.entvar ?? ref + '_ent')
|
|
612
|
+
const matchvar = csVar(step.i.matchvar ?? (ref + '_match' + (step.i.suffix ?? '')))
|
|
613
|
+
const srcdatavar = csVar(step.i.srcdatavar ?? (ref + '_data'))
|
|
613
614
|
|
|
614
|
-
const priorSteps = Object.values(flow
|
|
615
|
+
const priorSteps = Object.values(flowSteps(flow)).slice(0, Number(index)) as any[]
|
|
615
616
|
const needsEnt = !priorSteps.some((s: any) =>
|
|
616
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
617
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
617
618
|
|
|
618
619
|
Content(` // REMOVE
|
|
619
620
|
`)
|
|
@@ -68,8 +68,8 @@ const EntityTypes = cmp(function EntityTypes(props: any) {
|
|
|
68
68
|
|
|
69
69
|
Content(`# Typed models for the ${Name} SDK.
|
|
70
70
|
#
|
|
71
|
-
# GENERATED from the API model: main.${KIT}.entity.<e>.fields
|
|
72
|
-
# params (op.<name>.points[].
|
|
71
|
+
# GENERATED from the API model: main.${KIT}.entity.<e>.fields{} and per-op
|
|
72
|
+
# params (op.<name>.points[].g.params[]). Member types come from the
|
|
73
73
|
# canonical type sentinels. The SDK carries data as string-keyed struct value
|
|
74
74
|
# nodes, so each alias is an open string-keyed map; the @typedoc member lists
|
|
75
75
|
# document the concrete shapes. Do not edit by hand.
|
|
@@ -89,12 +89,12 @@ defmodule ${Name}.Types do
|
|
|
89
89
|
const EName = ent.Name
|
|
90
90
|
const ename = ent.name
|
|
91
91
|
const fields = (ent.fields ? each(ent.fields) : [])
|
|
92
|
-
.filter((f: any) => f.
|
|
92
|
+
.filter((f: any) => f.a !== false)
|
|
93
93
|
|
|
94
94
|
emitType(
|
|
95
95
|
ename,
|
|
96
96
|
`${EName} entity data model.`,
|
|
97
|
-
fields.map((f: any) => ({ name: f.
|
|
97
|
+
fields.map((f: any) => ({ name: f.n, type: f.t, optional: false === f.r })),
|
|
98
98
|
)
|
|
99
99
|
|
|
100
100
|
const ops = ent.op || {}
|
|
@@ -49,7 +49,7 @@ takes an entity handle built from the client:
|
|
|
49
49
|
const EName = entity.Name
|
|
50
50
|
const eVar = entity.name
|
|
51
51
|
const opnames = Object.keys(entity.op || {})
|
|
52
|
-
const fields = entity.fields ||
|
|
52
|
+
const fields = Object.values(entity.fields || {})
|
|
53
53
|
const idF = entityIdField(entity)
|
|
54
54
|
|
|
55
55
|
Content(`
|
|
@@ -93,8 +93,8 @@ takes an entity handle built from the client:
|
|
|
93
93
|
`)
|
|
94
94
|
|
|
95
95
|
each(fields, (field: any) => {
|
|
96
|
-
const desc = field.
|
|
97
|
-
Content(`| \`${field.
|
|
96
|
+
const desc = field.sh || ''
|
|
97
|
+
Content(`| \`${field.n}\` | \`${canonToType(field.t, target.name)}\` | ${desc} |
|
|
98
98
|
`)
|
|
99
99
|
})
|
|
100
100
|
|
|
@@ -116,13 +116,13 @@ On error, \`ok\` is \`false\` and \`err\` carries the error value.
|
|
|
116
116
|
|
|
117
117
|
`)
|
|
118
118
|
each(entityList, (ent: any) => {
|
|
119
|
-
const fields = ent.fields ||
|
|
119
|
+
const fields = Object.values(ent.fields || {})
|
|
120
120
|
const opnames = Object.keys(ent.op || {})
|
|
121
121
|
const ops = ent.op || {}
|
|
122
122
|
const points = each(ops).map((op: any) =>
|
|
123
123
|
op.points ? each(op.points) : []
|
|
124
124
|
).flat()
|
|
125
|
-
const path = points.length > 0 ? (points[0] as any).
|
|
125
|
+
const path = points.length > 0 ? (points[0] as any).o || '' : ''
|
|
126
126
|
|
|
127
127
|
Content(`#### ${ent.Name}
|
|
128
128
|
|
|
@@ -130,7 +130,7 @@ On error, \`ok\` is \`false\` and \`err\` carries the error value.
|
|
|
130
130
|
| --- | --- |
|
|
131
131
|
`)
|
|
132
132
|
each(fields, (field: any) => {
|
|
133
|
-
Content(`| \`${field.
|
|
133
|
+
Content(`| \`${field.n}\` | ${field.sh || ''} |
|
|
134
134
|
`)
|
|
135
135
|
})
|
|
136
136
|
|
|
@@ -140,7 +140,7 @@ on error.
|
|
|
140
140
|
const EName = ent.Name
|
|
141
141
|
const eVar = ent.name
|
|
142
142
|
const opnames = Object.keys(ent.op || {})
|
|
143
|
-
const fields = ent.fields ||
|
|
143
|
+
const fields = Object.values(ent.fields || {})
|
|
144
144
|
const idF = entityIdField(ent)
|
|
145
145
|
|
|
146
146
|
Content(`
|
|
@@ -171,9 +171,9 @@ ${eVar} = ${Name}.${eVar}(sdk)
|
|
|
171
171
|
| --- | --- | --- | --- |
|
|
172
172
|
`)
|
|
173
173
|
each(fields, (field: any) => {
|
|
174
|
-
const req = field.
|
|
175
|
-
const desc = field.
|
|
176
|
-
Content(`| \`${field.
|
|
174
|
+
const req = field.r ? 'Yes' : 'No'
|
|
175
|
+
const desc = field.sh || ''
|
|
176
|
+
Content(`| \`${field.n}\` | \`${canonToType(field.t, target.name)}\` | ${req} | ${desc} |
|
|
177
177
|
`)
|
|
178
178
|
})
|
|
179
179
|
|
|
@@ -34,7 +34,7 @@ const Schema = cmp(async function Schema(props: any) {
|
|
|
34
34
|
Content(`# ${Name} ${target.Name} SDK: generated schemas. Do not edit.
|
|
35
35
|
#
|
|
36
36
|
# Generated from the model: \`main.kit.optspec\` and each feature's
|
|
37
|
-
# \`config.options\` for OPTSPEC; entity \`fields
|
|
37
|
+
# \`config.options\` for OPTSPEC; entity \`fields{}.type\` for ENTITYSPEC.
|
|
38
38
|
|
|
39
39
|
defmodule ${Name}.Schema do
|
|
40
40
|
@optspec_data ${elixirString(JSON.stringify(optspec))}
|
|
@@ -128,8 +128,8 @@ const EntityTypes = cmp(function EntityTypes(props: any) {
|
|
|
128
128
|
|
|
129
129
|
Content(`// Typed models for the ${model.const.Name} SDK.
|
|
130
130
|
//
|
|
131
|
-
// GENERATED from the API model: main.${KIT}.entity.<e>.fields
|
|
132
|
-
// params (op.<name>.points[].
|
|
131
|
+
// GENERATED from the API model: main.${KIT}.entity.<e>.fields{} and per-op
|
|
132
|
+
// params (op.<name>.points[].g.params[]). Field/param types come from the
|
|
133
133
|
// canonical type sentinels via @voxgig/sdkgen canonToType (source of truth:
|
|
134
134
|
// @voxgig/apidef VALID_CANON). Do not edit by hand.
|
|
135
135
|
package entity
|
|
@@ -145,7 +145,7 @@ import (
|
|
|
145
145
|
entityList.forEach((ent: any) => {
|
|
146
146
|
const Name = ent.Name
|
|
147
147
|
const fields = (ent.fields ? each(ent.fields) : [])
|
|
148
|
-
.filter((f: any) => f.
|
|
148
|
+
.filter((f: any) => f.a !== false)
|
|
149
149
|
|
|
150
150
|
Content(`// ${Name} is the typed data model for the ${ent.name} entity.
|
|
151
151
|
type ${Name} struct {
|
|
@@ -154,7 +154,7 @@ type ${Name} struct {
|
|
|
154
154
|
(f: any) => skipUntaggable(f, Name, log))
|
|
155
155
|
const fieldIdents = uniqueGoFields(taggable)
|
|
156
156
|
taggable.forEach((f: any, i: number) => {
|
|
157
|
-
Content(fieldLine(f.
|
|
157
|
+
Content(fieldLine(f.n, f.t, false === f.r, fieldIdents[i]))
|
|
158
158
|
})
|
|
159
159
|
Content(`}
|
|
160
160
|
|
|
@@ -42,7 +42,7 @@ const ReadmeEntity = cmp(function ReadmeEntity(props: any) {
|
|
|
42
42
|
|
|
43
43
|
publishedEntities.map((entity: any) => {
|
|
44
44
|
const opnames = entityOps(entity)
|
|
45
|
-
const fields = entity.fields ||
|
|
45
|
+
const fields = Object.values(entity.fields || {})
|
|
46
46
|
const idF = entityIdField(entity)
|
|
47
47
|
const eVar = goVarName(entity.name)
|
|
48
48
|
|
|
@@ -87,8 +87,8 @@ const ReadmeEntity = cmp(function ReadmeEntity(props: any) {
|
|
|
87
87
|
`)
|
|
88
88
|
|
|
89
89
|
each(fields, (field: any) => {
|
|
90
|
-
const desc = field.
|
|
91
|
-
Content(`| \`${field.
|
|
90
|
+
const desc = field.sh || ''
|
|
91
|
+
Content(`| \`${field.n}\` | \`${canonToType(field.t, target.name)}\` | ${desc} |
|
|
92
92
|
`)
|
|
93
93
|
})
|
|
94
94
|
|
|
@@ -147,13 +147,13 @@ ${resultCallExample}Only \`Direct()\` returns a response envelope — a \`map[st
|
|
|
147
147
|
|
|
148
148
|
`)
|
|
149
149
|
each(entityList, (ent: any) => {
|
|
150
|
-
const fields = ent.fields ||
|
|
150
|
+
const fields = Object.values(ent.fields || {})
|
|
151
151
|
const opnames = Object.keys(ent.op || {})
|
|
152
152
|
const ops = ent.op || {}
|
|
153
153
|
const points = each(ops).map((op: any) =>
|
|
154
154
|
op.points ? each(op.points) : []
|
|
155
155
|
).flat()
|
|
156
|
-
const path = points.length > 0 ? (points[0] as any).
|
|
156
|
+
const path = points.length > 0 ? (points[0] as any).o || '' : ''
|
|
157
157
|
|
|
158
158
|
Content(`#### ${ent.Name}
|
|
159
159
|
|
|
@@ -161,7 +161,7 @@ ${resultCallExample}Only \`Direct()\` returns a response envelope — a \`map[st
|
|
|
161
161
|
| --- | --- |
|
|
162
162
|
`)
|
|
163
163
|
each(fields, (field: any) => {
|
|
164
|
-
Content(`| \`"${field.
|
|
164
|
+
Content(`| \`"${field.n}"\` | ${field.sh || ''} |
|
|
165
165
|
`)
|
|
166
166
|
})
|
|
167
167
|
|
|
@@ -162,7 +162,7 @@ same parameters as \`Direct()\`.
|
|
|
162
162
|
// ACTIVE ops only — an inactive op generates no method, so an example
|
|
163
163
|
// calling it would not compile.
|
|
164
164
|
const opnames = entityOps(ent)
|
|
165
|
-
const fields = ent.fields ||
|
|
165
|
+
const fields = Object.values(ent.fields || {})
|
|
166
166
|
// Model-driven id key: null when this entity has no id-like field, in
|
|
167
167
|
// which case load/remove pass a nil match and update omits the id.
|
|
168
168
|
const idF = entityIdField(ent)
|
|
@@ -196,9 +196,9 @@ fmt.Println(${eVar}.GetName()) // "${ent.name}"
|
|
|
196
196
|
| --- | --- | --- | --- |
|
|
197
197
|
`)
|
|
198
198
|
each(fields, (field: any) => {
|
|
199
|
-
const req = field.
|
|
200
|
-
const desc = field.
|
|
201
|
-
Content(`| \`${field.
|
|
199
|
+
const req = field.r ? 'Yes' : 'No'
|
|
200
|
+
const desc = field.sh || ''
|
|
201
|
+
Content(`| \`${field.n}\` | \`${canonToType(field.t, target.name)}\` | ${req} | ${desc} |
|
|
202
202
|
`)
|
|
203
203
|
})
|
|
204
204
|
|
|
@@ -225,7 +225,7 @@ fmt.Println(${eVar}.GetName()) // "${ent.name}"
|
|
|
225
225
|
if (fop.active === false) return '-'
|
|
226
226
|
return 'Yes'
|
|
227
227
|
})
|
|
228
|
-
Content(`| \`${field.
|
|
228
|
+
Content(`| \`${field.n}\` | ${cols.join(' | ')} |
|
|
229
229
|
`)
|
|
230
230
|
})
|
|
231
231
|
|
|
@@ -36,7 +36,7 @@ import (
|
|
|
36
36
|
// ${model.const.Name} ${target.Name} SDK: generated schemas. Do not edit.
|
|
37
37
|
//
|
|
38
38
|
// Generated from the model: \`main.kit.optspec\` and each feature's
|
|
39
|
-
// \`config.options\` for OPTSPEC; entity \`fields
|
|
39
|
+
// \`config.options\` for OPTSPEC; entity \`fields{}.type\` for ENTITYSPEC.
|
|
40
40
|
|
|
41
41
|
const optspecJSON = ${formatGoString(JSON.stringify(optspec))}
|
|
42
42
|
|