@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,
|
|
@@ -75,16 +76,16 @@ const TestEntity = cmp(function TestEntity(props: any) {
|
|
|
75
76
|
const idnamesStr = idnames.map(n => `Value::str("${n}")`).join(', ')
|
|
76
77
|
|
|
77
78
|
// All update data entries for alias generation.
|
|
78
|
-
const allSteps = Object.values(basicflow
|
|
79
|
-
const updateStep = allSteps.find((s: any) => s.
|
|
80
|
-
const updateData = updateStep?.
|
|
81
|
-
? Object.entries(updateStep.
|
|
79
|
+
const allSteps = Object.values(flowSteps(basicflow)) as any[]
|
|
80
|
+
const updateStep = allSteps.find((s: any) => s.o === 'update')
|
|
81
|
+
const updateData = updateStep?.d
|
|
82
|
+
? Object.entries(updateStep.d).filter(([k]: any) => k !== 'id' && !k.endsWith('$'))
|
|
82
83
|
: []
|
|
83
84
|
const aliases = updateData.map(([k, v]: any) => [k, v])
|
|
84
85
|
|
|
85
86
|
const genCtx: GenCtx = { model, entity, rustcrate, flow: basicflow, PROJUPPER }
|
|
86
87
|
|
|
87
|
-
const opNames = Array.from(new Set(allSteps.map((s: any) => s.
|
|
88
|
+
const opNames = Array.from(new Set(allSteps.map((s: any) => s.o).filter(Boolean)))
|
|
88
89
|
const opsList = opNames.map(o => `"${o}"`).join(', ')
|
|
89
90
|
|
|
90
91
|
// Same hazard as the csharp target: an entity whose basic flow has no ops
|
|
@@ -140,7 +141,7 @@ fn ${evar}_entity_instance() {
|
|
|
140
141
|
// The stream test drives the list op; only emit it when the entity has a
|
|
141
142
|
// list op (a create/load-only entity has no list endpoint, so
|
|
142
143
|
// stream("list") panics with point_no_points).
|
|
143
|
-
const flowHasList = allSteps.some((s: any) => 'list' === s.
|
|
144
|
+
const flowHasList = allSteps.some((s: any) => 'list' === s.o)
|
|
144
145
|
if (flowHasList) {
|
|
145
146
|
Content(`
|
|
146
147
|
#[test]
|
|
@@ -198,7 +199,7 @@ ${skipBlock} // The basic flow consumes synthetic IDs from the fixture. In li
|
|
|
198
199
|
${allSteps.length > 0 ? ' let client = setup.client.clone();\n' : ''}`)
|
|
199
200
|
|
|
200
201
|
// No create step: bootstrap entity data from existing fixture data.
|
|
201
|
-
const flowHasCreate = allSteps.some((s: any) => s.
|
|
202
|
+
const flowHasCreate = allSteps.some((s: any) => s.o === 'create')
|
|
202
203
|
if (!flowHasCreate) {
|
|
203
204
|
const preambleVar = rustVarName(entity.name + '_ref01')
|
|
204
205
|
Content(`
|
|
@@ -213,8 +214,8 @@ ${allSteps.length > 0 ? ' let client = setup.client.clone();\n' : ''}`)
|
|
|
213
214
|
}
|
|
214
215
|
|
|
215
216
|
// Model-driven step iteration.
|
|
216
|
-
each(basicflow
|
|
217
|
-
const opgen: OpGen = GENERATE_OP[step.
|
|
217
|
+
each(flowSteps(basicflow), (step: any, index: any) => {
|
|
218
|
+
const opgen: OpGen = GENERATE_OP[step.o]
|
|
218
219
|
if (opgen) {
|
|
219
220
|
opgen(genCtx, step, index)
|
|
220
221
|
Content('\n')
|
|
@@ -343,13 +344,13 @@ ${allSteps.length > 0 ? ' let client = setup.client.clone();\n' : ''}`)
|
|
|
343
344
|
|
|
344
345
|
const generateCreate: OpGen = (ctx, step, index) => {
|
|
345
346
|
const { entity, flow } = ctx
|
|
346
|
-
const ref = step.
|
|
347
|
-
const entvar = rustVarName(step.
|
|
348
|
-
const datavar = rustVarName(step.
|
|
347
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
348
|
+
const entvar = rustVarName(step.i.entvar ?? ref + '_ent')
|
|
349
|
+
const datavar = rustVarName(step.i.datavar ?? (ref + '_data' + (step.i.suffix ?? '')))
|
|
349
350
|
|
|
350
|
-
const priorSteps = Object.values(flow
|
|
351
|
+
const priorSteps = Object.values(flowSteps(flow)).slice(0, Number(index)) as any[]
|
|
351
352
|
const needsEnt = !priorSteps.some((s: any) =>
|
|
352
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
353
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
353
354
|
|
|
354
355
|
Content(` // CREATE
|
|
355
356
|
`)
|
|
@@ -393,14 +394,14 @@ const generateCreate: OpGen = (ctx, step, index) => {
|
|
|
393
394
|
|
|
394
395
|
const generateList: OpGen = (ctx, step, index) => {
|
|
395
396
|
const { entity, flow } = ctx
|
|
396
|
-
const ref = step.
|
|
397
|
-
const entvar = rustVarName(step.
|
|
398
|
-
const matchvar = rustVarName(step.
|
|
399
|
-
const listvar = rustVarName(step.
|
|
397
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
398
|
+
const entvar = rustVarName(step.i.entvar ?? ref + '_ent')
|
|
399
|
+
const matchvar = rustVarName(step.i.matchvar ?? (ref + '_match' + (step.i.suffix ?? '')))
|
|
400
|
+
const listvar = rustVarName(step.i.listvar ?? (ref + '_list' + (step.i.suffix ?? '')))
|
|
400
401
|
|
|
401
|
-
const priorSteps = Object.values(flow
|
|
402
|
+
const priorSteps = Object.values(flowSteps(flow)).slice(0, Number(index)) as any[]
|
|
402
403
|
const needsEnt = !priorSteps.some((s: any) =>
|
|
403
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
404
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
404
405
|
|
|
405
406
|
Content(` // LIST
|
|
406
407
|
`)
|
|
@@ -432,13 +433,13 @@ const generateList: OpGen = (ctx, step, index) => {
|
|
|
432
433
|
let ${listvar} = ja(${listvar}.iter().map(|e| e.data(None)).collect::<Vec<Value>>());
|
|
433
434
|
`)
|
|
434
435
|
|
|
435
|
-
// Validators from step.
|
|
436
|
-
const allSteps = Object.values(flow
|
|
437
|
-
if (step.
|
|
438
|
-
for (const validator of (step as any).
|
|
436
|
+
// Validators from step.v.
|
|
437
|
+
const allSteps = Object.values(flowSteps(flow)) as any[]
|
|
438
|
+
if (step.v) {
|
|
439
|
+
for (const validator of (step as any).v) {
|
|
439
440
|
const validRef = validator.def?.ref
|
|
440
|
-
const hasRefData = validRef && allSteps.some((s: any) => 'create' === s.
|
|
441
|
-
((s.
|
|
441
|
+
const hasRefData = validRef && allSteps.some((s: any) => 'create' === s.o &&
|
|
442
|
+
((s.i.ref ?? entity.name + '_ref01') === validRef))
|
|
442
443
|
|
|
443
444
|
if ('ItemExists' === validator.apply && hasRefData) {
|
|
444
445
|
const refDataVar = rustVarName(validRef + '_data')
|
|
@@ -472,16 +473,16 @@ const generateList: OpGen = (ctx, step, index) => {
|
|
|
472
473
|
|
|
473
474
|
const generateUpdate: OpGen = (ctx, step, index) => {
|
|
474
475
|
const { entity, flow } = ctx
|
|
475
|
-
const ref = step.
|
|
476
|
-
const entvar = rustVarName(step.
|
|
477
|
-
const datavar = rustVarName(step.
|
|
478
|
-
const resdatavar = rustVarName(step.
|
|
479
|
-
const markdefvar = rustVarName(step.
|
|
480
|
-
const srcdatavar = rustVarName(step.
|
|
481
|
-
|
|
482
|
-
const priorSteps = Object.values(flow
|
|
476
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
477
|
+
const entvar = rustVarName(step.i.entvar ?? ref + '_ent')
|
|
478
|
+
const datavar = rustVarName(step.i.datavar ?? (ref + '_data' + (step.i.suffix ?? '')))
|
|
479
|
+
const resdatavar = rustVarName(step.i.resdatavar ?? (ref + '_resdata' + (step.i.suffix ?? '')))
|
|
480
|
+
const markdefvar = rustVarName(step.i.markdefvar ?? (ref + '_markdef' + (step.i.suffix ?? '')))
|
|
481
|
+
const srcdatavar = rustVarName(step.i.srcdatavar ?? (ref + '_data' + (step.i.suffix ?? '')))
|
|
482
|
+
|
|
483
|
+
const priorSteps = Object.values(flowSteps(flow)).slice(0, Number(index)) as any[]
|
|
483
484
|
const needsEnt = !priorSteps.some((s: any) =>
|
|
484
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
485
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
485
486
|
|
|
486
487
|
const hasEntIdU = null != entity.id
|
|
487
488
|
|
|
@@ -498,9 +499,9 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
498
499
|
`)
|
|
499
500
|
}
|
|
500
501
|
|
|
501
|
-
// Data entries from step.
|
|
502
|
-
if (step.
|
|
503
|
-
const dataEntries = Object.entries(step.
|
|
502
|
+
// Data entries from step.d.
|
|
503
|
+
if (step.d) {
|
|
504
|
+
const dataEntries = Object.entries(step.d).filter(([k]: any) => k !== 'id' && !k.endsWith('$'))
|
|
504
505
|
for (const [key] of dataEntries) {
|
|
505
506
|
Content(` setp(&${datavar}_up, "${key}", getp(&setup.idmap, "${key}"));
|
|
506
507
|
`)
|
|
@@ -508,10 +509,10 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
508
509
|
}
|
|
509
510
|
|
|
510
511
|
// TextFieldMark spec.
|
|
511
|
-
if (step.
|
|
512
|
-
for (const spec of (step as any).
|
|
513
|
-
if ('TextFieldMark' === spec.apply && null != step.
|
|
514
|
-
const fieldname = step.
|
|
512
|
+
if (step.s) {
|
|
513
|
+
for (const spec of (step as any).s) {
|
|
514
|
+
if ('TextFieldMark' === spec.apply && null != step.i.textfield) {
|
|
515
|
+
const fieldname = step.i.textfield
|
|
515
516
|
const fieldvalue = spec.def?.mark ?? `Mark01-${ref}`
|
|
516
517
|
Content(`
|
|
517
518
|
let ${markdefvar}_name = "${fieldname}";
|
|
@@ -546,9 +547,9 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
546
547
|
}
|
|
547
548
|
|
|
548
549
|
// Assert TextFieldMark.
|
|
549
|
-
if (step.
|
|
550
|
-
for (const spec of (step as any).
|
|
551
|
-
if ('TextFieldMark' === spec.apply && null != step.
|
|
550
|
+
if (step.s) {
|
|
551
|
+
for (const spec of (step as any).s) {
|
|
552
|
+
if ('TextFieldMark' === spec.apply && null != step.i.textfield) {
|
|
552
553
|
Content(` assert_eq!(
|
|
553
554
|
getp(&${resdatavar}, ${markdefvar}_name),
|
|
554
555
|
Value::str(${markdefvar}_value.clone()),
|
|
@@ -564,24 +565,24 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
564
565
|
|
|
565
566
|
const generateLoad: OpGen = (ctx, step, index) => {
|
|
566
567
|
const { entity, flow } = ctx
|
|
567
|
-
const ref = step.
|
|
568
|
-
const entvar = rustVarName(step.
|
|
569
|
-
const matchvar = rustVarName(step.
|
|
570
|
-
const datavar = rustVarName(step.
|
|
571
|
-
const srcdatavar = rustVarName(step.
|
|
568
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
569
|
+
const entvar = rustVarName(step.i.entvar ?? ref + '_ent')
|
|
570
|
+
const matchvar = rustVarName(step.i.matchvar ?? (ref + '_match' + (step.i.suffix ?? '')))
|
|
571
|
+
const datavar = rustVarName(step.i.datavar ?? (ref + '_data' + (step.i.suffix ?? '')))
|
|
572
|
+
const srcdatavar = rustVarName(step.i.srcdatavar ?? (ref + '_data' + (step.i.suffix ?? '')))
|
|
572
573
|
|
|
573
|
-
const priorSteps = Object.values(flow
|
|
574
|
+
const priorSteps = Object.values(flowSteps(flow)).slice(0, Number(index)) as any[]
|
|
574
575
|
const hasEntVar = priorSteps.some((s: any) =>
|
|
575
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
576
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
576
577
|
|
|
577
578
|
// Was srcdatavar declared by a prior create step or the preamble?
|
|
578
|
-
const flowHasCreate = Object.values(flow
|
|
579
|
+
const flowHasCreate = Object.values(flowSteps(flow)).some((s: any) => (s as any).o === 'create')
|
|
579
580
|
const preambleRef = entity.name + '_ref01'
|
|
580
581
|
const hasSrcData = (!flowHasCreate && srcdatavar === rustVarName(preambleRef + '_data')) ||
|
|
581
582
|
priorSteps.some((s: any) => {
|
|
582
|
-
if ('create' === s.
|
|
583
|
-
const priorRef = s.
|
|
584
|
-
const priorDatvar = rustVarName(s.
|
|
583
|
+
if ('create' === s.o) {
|
|
584
|
+
const priorRef = s.i.ref ?? entity.name + '_ref01'
|
|
585
|
+
const priorDatvar = rustVarName(s.i.datavar ?? (priorRef + '_data' + (s.i.suffix ?? '')))
|
|
585
586
|
return priorDatvar === srcdatavar
|
|
586
587
|
}
|
|
587
588
|
return false
|
|
@@ -638,14 +639,14 @@ const generateLoad: OpGen = (ctx, step, index) => {
|
|
|
638
639
|
|
|
639
640
|
const generateRemove: OpGen = (ctx, step, index) => {
|
|
640
641
|
const { entity, flow } = ctx
|
|
641
|
-
const ref = step.
|
|
642
|
-
const entvar = rustVarName(step.
|
|
643
|
-
const matchvar = rustVarName(step.
|
|
644
|
-
const srcdatavar = rustVarName(step.
|
|
642
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
643
|
+
const entvar = rustVarName(step.i.entvar ?? ref + '_ent')
|
|
644
|
+
const matchvar = rustVarName(step.i.matchvar ?? (ref + '_match' + (step.i.suffix ?? '')))
|
|
645
|
+
const srcdatavar = rustVarName(step.i.srcdatavar ?? (ref + '_data'))
|
|
645
646
|
|
|
646
|
-
const priorSteps = Object.values(flow
|
|
647
|
+
const priorSteps = Object.values(flowSteps(flow)).slice(0, Number(index)) as any[]
|
|
647
648
|
const needsEnt = !priorSteps.some((s: any) =>
|
|
648
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
649
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
649
650
|
|
|
650
651
|
Content(` // REMOVE
|
|
651
652
|
`)
|
|
@@ -101,8 +101,8 @@ const EntityTypes = cmp(function EntityTypes(props: any) {
|
|
|
101
101
|
|
|
102
102
|
// Typed reference models for the ${model.const.Name} SDK.
|
|
103
103
|
//
|
|
104
|
-
// GENERATED from the API model: main.${KIT}.entity.<e>.fields
|
|
105
|
-
// params (op.<name>.points[].
|
|
104
|
+
// GENERATED from the API model: main.${KIT}.entity.<e>.fields{} and per-op
|
|
105
|
+
// params (op.<name>.points[].g.params[]). Field/param types come from the
|
|
106
106
|
// canonical type sentinels (source of truth: @voxgig/apidef VALID_CANON). Do
|
|
107
107
|
// not edit by hand.
|
|
108
108
|
//
|
|
@@ -120,10 +120,10 @@ object ${model.const.Name}Types {
|
|
|
120
120
|
entityList.forEach((ent: any) => {
|
|
121
121
|
const Name = ent.Name
|
|
122
122
|
const fields = (ent.fields ? each(ent.fields) : [])
|
|
123
|
-
.filter((f: any) => f.
|
|
123
|
+
.filter((f: any) => f.a !== false)
|
|
124
124
|
|
|
125
125
|
emitCaseClass(Name, fields.map((f: any) => ({
|
|
126
|
-
name: f.
|
|
126
|
+
name: f.n, type: f.t,
|
|
127
127
|
})), log)
|
|
128
128
|
|
|
129
129
|
const ops = ent.op || {}
|
|
@@ -54,7 +54,7 @@ const ReadmeEntity = cmp(function ReadmeEntity(props: any) {
|
|
|
54
54
|
|
|
55
55
|
publishedEntities.map((entity: any) => {
|
|
56
56
|
const opnames = Object.keys(entity.op || {})
|
|
57
|
-
const fields = entity.fields ||
|
|
57
|
+
const fields = Object.values(entity.fields || {})
|
|
58
58
|
// Model-driven id key: null when this entity has no id-like field.
|
|
59
59
|
const idF = entityIdField(entity)
|
|
60
60
|
// Sanitise the local variable name — a camelCased Scala keyword gets a
|
|
@@ -103,8 +103,8 @@ const ReadmeEntity = cmp(function ReadmeEntity(props: any) {
|
|
|
103
103
|
`)
|
|
104
104
|
|
|
105
105
|
each(fields, (field: any) => {
|
|
106
|
-
const desc = field.
|
|
107
|
-
Content(`| \`${field.
|
|
106
|
+
const desc = field.sh || ''
|
|
107
|
+
Content(`| \`${field.n}\` | \`${canonToType(field.t, target.name)}\` | ${desc} |
|
|
108
108
|
`)
|
|
109
109
|
})
|
|
110
110
|
|
|
@@ -116,13 +116,13 @@ On error, \`ok\` is \`false\` and \`err\` contains 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\` contains 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
|
|
|
@@ -170,7 +170,7 @@ Prepare a fetch definition without sending. Returns the \`fetchdef\` and raises
|
|
|
170
170
|
// Entity reference sections
|
|
171
171
|
publishedEntities.map((ent: any) => {
|
|
172
172
|
const opnames = Object.keys(ent.op || {})
|
|
173
|
-
const fields = ent.fields ||
|
|
173
|
+
const fields = Object.values(ent.fields || {})
|
|
174
174
|
// Model-driven id key: null when this entity has no id-like field.
|
|
175
175
|
const idF = entityIdField(ent)
|
|
176
176
|
// Sanitise the local variable name — scalaVarName guards Scala keywords.
|
|
@@ -205,9 +205,9 @@ val ${eVar} = client.${accessor}(null)
|
|
|
205
205
|
| --- | --- | --- | --- |
|
|
206
206
|
`)
|
|
207
207
|
each(fields, (field: any) => {
|
|
208
|
-
const req = field.
|
|
209
|
-
const desc = field.
|
|
210
|
-
Content(`| \`${field.
|
|
208
|
+
const req = field.r ? 'Yes' : 'No'
|
|
209
|
+
const desc = field.sh || ''
|
|
210
|
+
Content(`| \`${field.n}\` | \`${canonToType(field.t, target.name)}\` | ${req} | ${desc} |
|
|
211
211
|
`)
|
|
212
212
|
})
|
|
213
213
|
|
|
@@ -232,7 +232,7 @@ val ${eVar} = client.${accessor}(null)
|
|
|
232
232
|
if (fop.active === false) return '-'
|
|
233
233
|
return 'Yes'
|
|
234
234
|
})
|
|
235
|
-
Content(`| \`${field.
|
|
235
|
+
Content(`| \`${field.n}\` | ${cols.join(' | ')} |
|
|
236
236
|
`)
|
|
237
237
|
})
|
|
238
238
|
|
|
@@ -41,7 +41,7 @@ import ${scalapackage}.utility.Json
|
|
|
41
41
|
// ${model.const.Name} ${target.Name} SDK: generated schemas. Do not edit.
|
|
42
42
|
//
|
|
43
43
|
// Generated from the model: \`main.kit.optspec\` and each feature's
|
|
44
|
-
// \`config.options\` for the option spec; entity \`fields
|
|
44
|
+
// \`config.options\` for the option spec; entity \`fields{}.type\` for the
|
|
45
45
|
// entity specs.
|
|
46
46
|
object Schema {
|
|
47
47
|
|
|
@@ -29,10 +29,10 @@ function normalizePathParams(
|
|
|
29
29
|
const snaked = snakify(rawName)
|
|
30
30
|
const depluralized = depluralize(snaked)
|
|
31
31
|
const param = params.find((p: any) =>
|
|
32
|
-
p.
|
|
32
|
+
p.n === snaked || p.n === depluralized) ||
|
|
33
33
|
params.find((p: any) =>
|
|
34
|
-
p.
|
|
35
|
-
if (param) return '{' + param.
|
|
34
|
+
p.or === snaked || p.or === depluralized)
|
|
35
|
+
if (param) return '{' + param.n + '}'
|
|
36
36
|
|
|
37
37
|
if (rename) {
|
|
38
38
|
for (const [origCamel, renamedTo] of Object.entries(rename)) {
|
|
@@ -40,10 +40,10 @@ function normalizePathParams(
|
|
|
40
40
|
const origSnaked = snakify(origCamel)
|
|
41
41
|
const origDepluralized = depluralize(origSnaked)
|
|
42
42
|
const renamedParam = params.find(
|
|
43
|
-
(p: any) => p.
|
|
44
|
-
p.
|
|
43
|
+
(p: any) => p.or === origSnaked || p.n === origSnaked ||
|
|
44
|
+
p.or === origDepluralized || p.n === origDepluralized
|
|
45
45
|
)
|
|
46
|
-
if (renamedParam) return '{' + renamedParam.
|
|
46
|
+
if (renamedParam) return '{' + renamedParam.n + '}'
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -80,9 +80,9 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
80
80
|
// Load point info.
|
|
81
81
|
const loadPoint = loadOp?.points?.[0]
|
|
82
82
|
const loadPath = loadPoint
|
|
83
|
-
? normalizePathParams(pointParts(loadPoint), loadPoint?.
|
|
83
|
+
? normalizePathParams(pointParts(loadPoint), loadPoint?.g?.params || [], loadPoint?.r?.param)
|
|
84
84
|
: ''
|
|
85
|
-
const allLoadParams = loadPoint?.
|
|
85
|
+
const allLoadParams = loadPoint?.g?.params || []
|
|
86
86
|
// Only path params that actually appear in the URL template drive the
|
|
87
87
|
// direct-test path-param setup and URL-substitution asserts.
|
|
88
88
|
const _pathPlaceholders = new Set<string>()
|
|
@@ -91,7 +91,7 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
91
91
|
_pathPlaceholders.add(part.slice(1, -1))
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
const _renameMap = (loadPoint?.
|
|
94
|
+
const _renameMap = (loadPoint?.r?.param || {}) as Record<string, string>
|
|
95
95
|
const _renamedPlaceholders = new Set<string>()
|
|
96
96
|
for (const ph of _pathPlaceholders) {
|
|
97
97
|
_renamedPlaceholders.add(ph)
|
|
@@ -100,14 +100,14 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
const loadParams = allLoadParams.filter((p: any) =>
|
|
103
|
-
_renamedPlaceholders.has(p.
|
|
103
|
+
_renamedPlaceholders.has(p.n) || _renamedPlaceholders.has(p.or))
|
|
104
104
|
|
|
105
105
|
// List point info.
|
|
106
106
|
const listPoint = listOp?.points?.[0]
|
|
107
107
|
const listPath = listPoint
|
|
108
|
-
? normalizePathParams(pointParts(listPoint), listPoint?.
|
|
108
|
+
? normalizePathParams(pointParts(listPoint), listPoint?.g?.params || [], listPoint?.r?.param)
|
|
109
109
|
: ''
|
|
110
|
-
const listParams = listPoint?.
|
|
110
|
+
const listParams = listPoint?.g?.params || []
|
|
111
111
|
|
|
112
112
|
File({ name: EntityName + 'DirectTest.' + target.ext }, () => {
|
|
113
113
|
|
|
@@ -158,7 +158,7 @@ object ${EntityName}DirectTest {
|
|
|
158
158
|
val params = new LinkedHashMap[String, Object]()
|
|
159
159
|
`)
|
|
160
160
|
listParams.forEach((p: any, i: number) => {
|
|
161
|
-
Content(` params.put("${p.
|
|
161
|
+
Content(` params.put("${p.n}", "direct0${i + 1}")
|
|
162
162
|
`)
|
|
163
163
|
})
|
|
164
164
|
Content(` val result = client.direct(SdkTestSupport.om(
|
|
@@ -195,7 +195,7 @@ object ${EntityName}DirectTest {
|
|
|
195
195
|
val params = new LinkedHashMap[String, Object]()
|
|
196
196
|
`)
|
|
197
197
|
loadParams.forEach((p: any, i: number) => {
|
|
198
|
-
Content(` params.put("${p.
|
|
198
|
+
Content(` params.put("${p.n}", "direct0${i + 1}")
|
|
199
199
|
`)
|
|
200
200
|
})
|
|
201
201
|
Content(` val result = client.direct(SdkTestSupport.om(
|