@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
|
flatten,
|
|
@@ -88,10 +89,10 @@ const TestEntity = cmp(function TestEntity(props: any) {
|
|
|
88
89
|
const idnames = buildIdNames(entity, basicflow)
|
|
89
90
|
const idnamesStr = idnames.map(n => `"${n}"`).join(', ')
|
|
90
91
|
|
|
91
|
-
const allSteps = Object.values(basicflow
|
|
92
|
-
const updateStep = allSteps.find((s: any) => s.
|
|
93
|
-
const updateData = updateStep?.
|
|
94
|
-
? Object.entries(updateStep.
|
|
92
|
+
const allSteps = Object.values(flowSteps(basicflow)) as any[]
|
|
93
|
+
const updateStep = allSteps.find((s: any) => s.o === 'update')
|
|
94
|
+
const updateData = updateStep?.d
|
|
95
|
+
? Object.entries(updateStep.d).filter(([k]: any) => k !== 'id' && !k.endsWith('$'))
|
|
95
96
|
: []
|
|
96
97
|
const aliases = updateData.map(([k, v]: any) => [k, v])
|
|
97
98
|
|
|
@@ -153,7 +154,7 @@ ${hasList ? `
|
|
|
153
154
|
setup = ${entity.name}_basic_setup(nil)
|
|
154
155
|
# Per-op sdk-test-control.json skip.
|
|
155
156
|
_live = setup[:live] || false
|
|
156
|
-
[${(Array.from(new Set((allSteps as any[]).map((s: any) => s.
|
|
157
|
+
[${(Array.from(new Set((allSteps as any[]).map((s: any) => s.o).filter(Boolean)))).map(o => `"${o}"`).join(', ')}].each do |_op|
|
|
157
158
|
_should_skip, _reason = Runner.is_control_skipped("entityOp", "${entity.name}." + _op, _live ? "live" : "unit")
|
|
158
159
|
if _should_skip
|
|
159
160
|
skip(_reason || "skipped via sdk-test-control.json")
|
|
@@ -171,7 +172,7 @@ ${hasList ? `
|
|
|
171
172
|
`)
|
|
172
173
|
|
|
173
174
|
// Check if the flow has a create step
|
|
174
|
-
const flowHasCreate = allSteps.some((s: any) => s.
|
|
175
|
+
const flowHasCreate = allSteps.some((s: any) => s.o === 'create')
|
|
175
176
|
if (!flowHasCreate) {
|
|
176
177
|
Content(` # Bootstrap entity data from existing test data.
|
|
177
178
|
${entity.name}_ref01_data_raw = Vs.items(Helpers.to_map(
|
|
@@ -185,16 +186,16 @@ ${hasList ? `
|
|
|
185
186
|
}
|
|
186
187
|
|
|
187
188
|
// Model-driven step iteration
|
|
188
|
-
each(basicflow
|
|
189
|
+
each(flowSteps(basicflow), (step: any, index: any) => {
|
|
189
190
|
// Never emit a REMOVE (or its removed-item verify LIST) without a
|
|
190
191
|
// preceding CREATE: a coherent CRUD flow only removes what it created,
|
|
191
192
|
// so a create-less remove would mutate pre-existing (live) data.
|
|
192
193
|
if (!flowHasCreate) {
|
|
193
|
-
if ('remove' === step.
|
|
194
|
-
if ('list' === step.
|
|
195
|
-
(step.
|
|
194
|
+
if ('remove' === step.o) { return }
|
|
195
|
+
if ('list' === step.o &&
|
|
196
|
+
(step.v || []).some((v: any) => 'ItemNotExists' === v.apply)) { return }
|
|
196
197
|
}
|
|
197
|
-
const opgen: OpGen = GENERATE_OP[step.
|
|
198
|
+
const opgen: OpGen = GENERATE_OP[step.o]
|
|
198
199
|
if (opgen) {
|
|
199
200
|
opgen(genCtx, step, index)
|
|
200
201
|
Content('\n')
|
|
@@ -294,18 +295,18 @@ end
|
|
|
294
295
|
|
|
295
296
|
const generateCreate: OpGen = (ctx, step, index) => {
|
|
296
297
|
const { entity, flow } = ctx
|
|
297
|
-
const ref = step.
|
|
298
|
-
const entvar = step.
|
|
299
|
-
const datavar = step.
|
|
298
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
299
|
+
const entvar = step.i.entvar ?? ref + '_ent'
|
|
300
|
+
const datavar = step.i.datavar ?? (ref + '_data' + (step.i.suffix ?? ''))
|
|
300
301
|
|
|
301
|
-
const priorSteps = Object.values(flow
|
|
302
|
+
const priorSteps = Object.values(flowSteps(flow)).slice(0, Number(index)) as any[]
|
|
302
303
|
const needsEnt = !priorSteps.some((s: any) =>
|
|
303
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
304
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
304
305
|
|
|
305
306
|
const hasDatvar = priorSteps.some((s: any) => {
|
|
306
|
-
if ('create' === s.
|
|
307
|
-
const priorRef = s.
|
|
308
|
-
const priorDatvar = s.
|
|
307
|
+
if ('create' === s.o) {
|
|
308
|
+
const priorRef = s.i.ref ?? entity.name + '_ref01'
|
|
309
|
+
const priorDatvar = s.i.datavar ?? (priorRef + '_data' + (s.i.suffix ?? ''))
|
|
309
310
|
return priorDatvar === datavar
|
|
310
311
|
}
|
|
311
312
|
return false
|
|
@@ -349,14 +350,14 @@ const generateCreate: OpGen = (ctx, step, index) => {
|
|
|
349
350
|
const generateList: OpGen = (ctx, step, index) => {
|
|
350
351
|
const { entity, flow } = ctx
|
|
351
352
|
const hasDataId = null != entityDataIdField(entity)
|
|
352
|
-
const ref = step.
|
|
353
|
-
const entvar = step.
|
|
354
|
-
const matchvar = step.
|
|
355
|
-
const listvar = step.
|
|
353
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
354
|
+
const entvar = step.i.entvar ?? ref + '_ent'
|
|
355
|
+
const matchvar = step.i.matchvar ?? (ref + '_match' + (step.i.suffix ?? ''))
|
|
356
|
+
const listvar = step.i.listvar ?? (ref + '_list' + (step.i.suffix ?? ''))
|
|
356
357
|
|
|
357
|
-
const priorSteps = Object.values(flow
|
|
358
|
+
const priorSteps = Object.values(flowSteps(flow)).slice(0, Number(index)) as any[]
|
|
358
359
|
const needsEnt = !priorSteps.some((s: any) =>
|
|
359
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
360
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
360
361
|
|
|
361
362
|
Content(` # LIST
|
|
362
363
|
`)
|
|
@@ -386,12 +387,12 @@ const generateList: OpGen = (ctx, step, index) => {
|
|
|
386
387
|
`)
|
|
387
388
|
|
|
388
389
|
// Handle validators
|
|
389
|
-
const allSteps = Object.values(flow
|
|
390
|
-
if (step.
|
|
391
|
-
for (const validator of step.
|
|
390
|
+
const allSteps = Object.values(flowSteps(flow)) as any[]
|
|
391
|
+
if (step.v) {
|
|
392
|
+
for (const validator of step.v) {
|
|
392
393
|
const validRef = validator.def?.ref
|
|
393
|
-
const hasRefData = validRef && allSteps.some((s: any) => 'create' === s.
|
|
394
|
-
((s.
|
|
394
|
+
const hasRefData = validRef && allSteps.some((s: any) => 'create' === s.o &&
|
|
395
|
+
((s.i.ref ?? entity.name + '_ref01') === validRef))
|
|
395
396
|
|
|
396
397
|
if ('ItemExists' === validator.apply && hasRefData && hasDataId) {
|
|
397
398
|
const refDataVar = validRef + '_data'
|
|
@@ -417,16 +418,16 @@ const generateList: OpGen = (ctx, step, index) => {
|
|
|
417
418
|
|
|
418
419
|
const generateUpdate: OpGen = (ctx, step, index) => {
|
|
419
420
|
const { entity, flow } = ctx
|
|
420
|
-
const ref = step.
|
|
421
|
-
const entvar = step.
|
|
422
|
-
const datavar = step.
|
|
423
|
-
const resdatavar = step.
|
|
424
|
-
const markdefvar = step.
|
|
425
|
-
const srcdatavar = step.
|
|
426
|
-
|
|
427
|
-
const priorSteps = Object.values(flow
|
|
421
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
422
|
+
const entvar = step.i.entvar ?? ref + '_ent'
|
|
423
|
+
const datavar = step.i.datavar ?? (ref + '_data' + (step.i.suffix ?? ''))
|
|
424
|
+
const resdatavar = step.i.resdatavar ?? (ref + '_resdata' + (step.i.suffix ?? ''))
|
|
425
|
+
const markdefvar = step.i.markdefvar ?? (ref + '_markdef' + (step.i.suffix ?? ''))
|
|
426
|
+
const srcdatavar = step.i.srcdatavar ?? (ref + '_data' + (step.i.suffix ?? ''))
|
|
427
|
+
|
|
428
|
+
const priorSteps = Object.values(flowSteps(flow)).slice(0, Number(index)) as any[]
|
|
428
429
|
const needsEnt = !priorSteps.some((s: any) =>
|
|
429
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
430
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
430
431
|
|
|
431
432
|
const hasEntIdU = null != entity.id
|
|
432
433
|
|
|
@@ -443,8 +444,8 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
443
444
|
`)
|
|
444
445
|
}
|
|
445
446
|
|
|
446
|
-
if (step.
|
|
447
|
-
const dataEntries = Object.entries(step.
|
|
447
|
+
if (step.d) {
|
|
448
|
+
const dataEntries = Object.entries(step.d).filter(([k]: any) => k !== 'id' && !k.endsWith('$'))
|
|
448
449
|
for (const [key] of dataEntries) {
|
|
449
450
|
Content(` "${key}" => setup[:idmap]["${key}"],
|
|
450
451
|
`)
|
|
@@ -454,10 +455,10 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
454
455
|
Content(` }
|
|
455
456
|
`)
|
|
456
457
|
|
|
457
|
-
if (step.
|
|
458
|
-
for (const spec of step.
|
|
459
|
-
if ('TextFieldMark' === spec.apply && null != step.
|
|
460
|
-
const fieldname = step.
|
|
458
|
+
if (step.s) {
|
|
459
|
+
for (const spec of step.s) {
|
|
460
|
+
if ('TextFieldMark' === spec.apply && null != step.i.textfield) {
|
|
461
|
+
const fieldname = step.i.textfield
|
|
461
462
|
const fieldvalue = spec.def?.mark ?? `Mark01-${ref}`
|
|
462
463
|
Content(`
|
|
463
464
|
${markdefvar}_name = "${fieldname}"
|
|
@@ -478,9 +479,9 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
478
479
|
`)
|
|
479
480
|
}
|
|
480
481
|
|
|
481
|
-
if (step.
|
|
482
|
-
for (const spec of step.
|
|
483
|
-
if ('TextFieldMark' === spec.apply && null != step.
|
|
482
|
+
if (step.s) {
|
|
483
|
+
for (const spec of step.s) {
|
|
484
|
+
if ('TextFieldMark' === spec.apply && null != step.i.textfield) {
|
|
484
485
|
Content(` assert_equal ${resdatavar}[${markdefvar}_name], ${markdefvar}_value
|
|
485
486
|
`)
|
|
486
487
|
}
|
|
@@ -491,23 +492,23 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
491
492
|
|
|
492
493
|
const generateLoad: OpGen = (ctx, step, index) => {
|
|
493
494
|
const { entity, flow } = ctx
|
|
494
|
-
const ref = step.
|
|
495
|
-
const entvar = step.
|
|
496
|
-
const matchvar = step.
|
|
497
|
-
const datavar = step.
|
|
498
|
-
const srcdatavar = step.
|
|
495
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
496
|
+
const entvar = step.i.entvar ?? ref + '_ent'
|
|
497
|
+
const matchvar = step.i.matchvar ?? (ref + '_match' + (step.i.suffix ?? ''))
|
|
498
|
+
const datavar = step.i.datavar ?? (ref + '_data' + (step.i.suffix ?? ''))
|
|
499
|
+
const srcdatavar = step.i.srcdatavar ?? (ref + '_data' + (step.i.suffix ?? ''))
|
|
499
500
|
|
|
500
|
-
const priorSteps = Object.values(flow
|
|
501
|
+
const priorSteps = Object.values(flowSteps(flow)).slice(0, Number(index)) as any[]
|
|
501
502
|
const hasEntVar = priorSteps.some((s: any) =>
|
|
502
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
503
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
503
504
|
|
|
504
|
-
const flowHasCreate = Object.values(flow
|
|
505
|
+
const flowHasCreate = Object.values(flowSteps(flow)).some((s: any) => (s as any).o === 'create')
|
|
505
506
|
const preambleRef = entity.name + '_ref01'
|
|
506
507
|
const hasSrcData = (!flowHasCreate && srcdatavar === (preambleRef + '_data')) ||
|
|
507
508
|
priorSteps.some((s: any) => {
|
|
508
|
-
if ('create' === s.
|
|
509
|
-
const priorRef = s.
|
|
510
|
-
const priorDatvar = s.
|
|
509
|
+
if ('create' === s.o) {
|
|
510
|
+
const priorRef = s.i.ref ?? entity.name + '_ref01'
|
|
511
|
+
const priorDatvar = s.i.datavar ?? (priorRef + '_data' + (s.i.suffix ?? ''))
|
|
511
512
|
return priorDatvar === srcdatavar
|
|
512
513
|
}
|
|
513
514
|
return false
|
|
@@ -554,14 +555,14 @@ const generateRemove: OpGen = (ctx, step, index) => {
|
|
|
554
555
|
if (null == entityDataIdField(entity)) {
|
|
555
556
|
return
|
|
556
557
|
}
|
|
557
|
-
const ref = step.
|
|
558
|
-
const entvar = step.
|
|
559
|
-
const matchvar = step.
|
|
560
|
-
const srcdatavar = step.
|
|
558
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
559
|
+
const entvar = step.i.entvar ?? ref + '_ent'
|
|
560
|
+
const matchvar = step.i.matchvar ?? (ref + '_match' + (step.i.suffix ?? ''))
|
|
561
|
+
const srcdatavar = step.i.srcdatavar ?? (ref + '_data')
|
|
561
562
|
|
|
562
|
-
const priorSteps = Object.values(flow
|
|
563
|
+
const priorSteps = Object.values(flowSteps(flow)).slice(0, Number(index)) as any[]
|
|
563
564
|
const needsEnt = !priorSteps.some((s: any) =>
|
|
564
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
565
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
565
566
|
|
|
566
567
|
Content(` # REMOVE
|
|
567
568
|
`)
|
|
@@ -67,8 +67,8 @@ const EntityTypes = cmp(function EntityTypes(props: any) {
|
|
|
67
67
|
|
|
68
68
|
Content(`// Typed models for the ${model.const.Name} SDK.
|
|
69
69
|
//
|
|
70
|
-
// GENERATED from the API model: main.${KIT}.entity.<e>.fields
|
|
71
|
-
// params (op.<name>.points[].
|
|
70
|
+
// GENERATED from the API model: main.${KIT}.entity.<e>.fields{} and per-op
|
|
71
|
+
// params (op.<name>.points[].g.params[]). Field/param types are mapped
|
|
72
72
|
// from the canonical type sentinels. Do not edit by hand.
|
|
73
73
|
//
|
|
74
74
|
// These are DOCUMENTARY: the SDK runtime is dynamic (ops take/return the
|
|
@@ -83,12 +83,12 @@ use crate::utility::voxgigstruct::Value;
|
|
|
83
83
|
entityList.forEach((ent: any) => {
|
|
84
84
|
const Name = ent.Name
|
|
85
85
|
const fields = (ent.fields ? each(ent.fields) : [])
|
|
86
|
-
.filter((f: any) => f.
|
|
86
|
+
.filter((f: any) => f.a !== false)
|
|
87
87
|
|
|
88
88
|
emitStruct(
|
|
89
89
|
`/// ${Name} is the typed data model for the ${ent.name} entity.`,
|
|
90
90
|
Name,
|
|
91
|
-
fields.map((f: any) => ({ name: f.
|
|
91
|
+
fields.map((f: any) => ({ name: f.n, type: f.t, optional: false === f.r }))
|
|
92
92
|
)
|
|
93
93
|
|
|
94
94
|
const ops = ent.op || {}
|
|
@@ -53,7 +53,7 @@ const ReadmeEntity = cmp(function ReadmeEntity(props: any) {
|
|
|
53
53
|
|
|
54
54
|
publishedEntities.map((entity: any) => {
|
|
55
55
|
const opnames = Object.keys(entity.op || {})
|
|
56
|
-
const fields = entity.fields ||
|
|
56
|
+
const fields = Object.values(entity.fields || {})
|
|
57
57
|
const idF = entityIdField(entity)
|
|
58
58
|
const eVar = rustVarName(entity.name)
|
|
59
59
|
const method = rustMethodName(entity.name)
|
|
@@ -99,8 +99,8 @@ const ReadmeEntity = cmp(function ReadmeEntity(props: any) {
|
|
|
99
99
|
`)
|
|
100
100
|
|
|
101
101
|
each(fields, (field: any) => {
|
|
102
|
-
const desc = field.
|
|
103
|
-
Content(`| \`${field.
|
|
102
|
+
const desc = field.sh || ''
|
|
103
|
+
Content(`| \`${field.n}\` | \`${canonToType(field.t, target.name)}\` | ${desc} |
|
|
104
104
|
`)
|
|
105
105
|
})
|
|
106
106
|
|
|
@@ -119,13 +119,13 @@ On error, \`ok\` is \`false\` and \`err\` carries the error value.
|
|
|
119
119
|
|
|
120
120
|
`)
|
|
121
121
|
each(entityList, (ent: any) => {
|
|
122
|
-
const fields = ent.fields ||
|
|
122
|
+
const fields = Object.values(ent.fields || {})
|
|
123
123
|
const opnames = Object.keys(ent.op || {})
|
|
124
124
|
const ops = ent.op || {}
|
|
125
125
|
const points = each(ops).map((op: any) =>
|
|
126
126
|
op.points ? each(op.points) : []
|
|
127
127
|
).flat()
|
|
128
|
-
const path = points.length > 0 ? (points[0] as any).
|
|
128
|
+
const path = points.length > 0 ? (points[0] as any).o || '' : ''
|
|
129
129
|
|
|
130
130
|
Content(`#### ${ent.Name}
|
|
131
131
|
|
|
@@ -133,7 +133,7 @@ On error, \`ok\` is \`false\` and \`err\` carries the error value.
|
|
|
133
133
|
| --- | --- |
|
|
134
134
|
`)
|
|
135
135
|
each(fields, (field: any) => {
|
|
136
|
-
Content(`| \`${field.
|
|
136
|
+
Content(`| \`${field.n}\` | ${field.sh || ''} |
|
|
137
137
|
`)
|
|
138
138
|
})
|
|
139
139
|
|
|
@@ -166,7 +166,7 @@ Prepare a fetch definition without sending. Returns the fetchdef on \`Ok\`.
|
|
|
166
166
|
// Entity reference sections
|
|
167
167
|
publishedEntities.map((ent: any) => {
|
|
168
168
|
const opnames = Object.keys(ent.op || {})
|
|
169
|
-
const fields = ent.fields ||
|
|
169
|
+
const fields = Object.values(ent.fields || {})
|
|
170
170
|
const idF = entityIdField(ent)
|
|
171
171
|
const eVar = rustVarName(ent.name)
|
|
172
172
|
const method = rustMethodName(ent.name)
|
|
@@ -199,9 +199,9 @@ let ${eVar} = client.${method}(Value::Noval);
|
|
|
199
199
|
| --- | --- | --- | --- |
|
|
200
200
|
`)
|
|
201
201
|
each(fields, (field: any) => {
|
|
202
|
-
const req = field.
|
|
203
|
-
const desc = field.
|
|
204
|
-
Content(`| \`${field.
|
|
202
|
+
const req = field.r ? 'Yes' : 'No'
|
|
203
|
+
const desc = field.sh || ''
|
|
204
|
+
Content(`| \`${field.n}\` | \`${canonToType(field.t, target.name)}\` | ${req} | ${desc} |
|
|
205
205
|
`)
|
|
206
206
|
})
|
|
207
207
|
|
|
@@ -226,7 +226,7 @@ let ${eVar} = client.${method}(Value::Noval);
|
|
|
226
226
|
if (fop.active === false) return '-'
|
|
227
227
|
return 'Yes'
|
|
228
228
|
})
|
|
229
|
-
Content(`| \`${field.
|
|
229
|
+
Content(`| \`${field.n}\` | ${cols.join(' | ')} |
|
|
230
230
|
`)
|
|
231
231
|
})
|
|
232
232
|
|
|
@@ -33,7 +33,7 @@ const Schema = cmp(async function Schema(props: any) {
|
|
|
33
33
|
Content(`// ${model.const.Name} SDK: generated schemas. Do not edit.
|
|
34
34
|
//
|
|
35
35
|
// Built from the model: \`main.kit.optspec\` and each feature's
|
|
36
|
-
// \`config.options\` for the option spec; entity \`fields
|
|
36
|
+
// \`config.options\` for the option spec; entity \`fields{}.type\` for the
|
|
37
37
|
// entity specs.
|
|
38
38
|
|
|
39
39
|
use crate::utility::jsonparse::json_parse;
|
|
@@ -33,10 +33,10 @@ function normalizePathParams(
|
|
|
33
33
|
const snaked = snakify(rawName)
|
|
34
34
|
const depluralized = depluralize(snaked)
|
|
35
35
|
const param = params.find((p: any) =>
|
|
36
|
-
p.
|
|
36
|
+
p.n === snaked || p.n === depluralized) ||
|
|
37
37
|
params.find((p: any) =>
|
|
38
|
-
p.
|
|
39
|
-
if (param) return '{' + param.
|
|
38
|
+
p.or === snaked || p.or === depluralized)
|
|
39
|
+
if (param) return '{' + param.n + '}'
|
|
40
40
|
|
|
41
41
|
if (rename) {
|
|
42
42
|
for (const [origCamel, renamedTo] of Object.entries(rename)) {
|
|
@@ -44,10 +44,10 @@ function normalizePathParams(
|
|
|
44
44
|
const origSnaked = snakify(origCamel)
|
|
45
45
|
const origDepluralized = depluralize(origSnaked)
|
|
46
46
|
const renamedParam = params.find(
|
|
47
|
-
(p: any) => p.
|
|
48
|
-
p.
|
|
47
|
+
(p: any) => p.or === origSnaked || p.n === origSnaked ||
|
|
48
|
+
p.or === origDepluralized || p.n === origDepluralized
|
|
49
49
|
)
|
|
50
|
-
if (renamedParam) return '{' + renamedParam.
|
|
50
|
+
if (renamedParam) return '{' + renamedParam.n + '}'
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -98,8 +98,8 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
98
98
|
|
|
99
99
|
// Load point info.
|
|
100
100
|
const loadPoint = loadOp?.points?.[0]
|
|
101
|
-
const loadPath = loadPoint ? normalizePathParams(pointParts(loadPoint), loadPoint?.
|
|
102
|
-
const allLoadParams = loadPoint?.
|
|
101
|
+
const loadPath = loadPoint ? normalizePathParams(pointParts(loadPoint), loadPoint?.g?.params || [], loadPoint?.r?.param) : ''
|
|
102
|
+
const allLoadParams = loadPoint?.g?.params || []
|
|
103
103
|
// Only path params that actually appear in the URL template drive the
|
|
104
104
|
// direct-test path-param setup and URL-substitution asserts.
|
|
105
105
|
const _pathPlaceholders = new Set<string>()
|
|
@@ -108,7 +108,7 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
108
108
|
_pathPlaceholders.add(part.slice(1, -1))
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
const _renameMap = (loadPoint?.
|
|
111
|
+
const _renameMap = (loadPoint?.r?.param || {}) as Record<string, string>
|
|
112
112
|
const _renamedPlaceholders = new Set<string>()
|
|
113
113
|
for (const ph of _pathPlaceholders) {
|
|
114
114
|
_renamedPlaceholders.add(ph)
|
|
@@ -117,12 +117,12 @@ const TestDirect = cmp(function TestDirect(props: any) {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
const loadParams = allLoadParams.filter((p: any) =>
|
|
120
|
-
_renamedPlaceholders.has(p.
|
|
120
|
+
_renamedPlaceholders.has(p.n) || _renamedPlaceholders.has(p.or))
|
|
121
121
|
|
|
122
122
|
// List point info.
|
|
123
123
|
const listPoint = listOp?.points?.[0]
|
|
124
|
-
const listPath = listPoint ? normalizePathParams(pointParts(listPoint), listPoint?.
|
|
125
|
-
const listParams = listPoint?.
|
|
124
|
+
const listPath = listPoint ? normalizePathParams(pointParts(listPoint), listPoint?.g?.params || [], listPoint?.r?.param) : ''
|
|
125
|
+
const listParams = listPoint?.g?.params || []
|
|
126
126
|
|
|
127
127
|
const entidEnvVar = `${PROJECTNAME}_TEST_${envToken(entity.name)}_ENTID`
|
|
128
128
|
|
|
@@ -224,10 +224,10 @@ fn ${evar}_direct_setup(mockres: Value) -> ${entity.Name}DirectSetup {
|
|
|
224
224
|
if (hasList && listPoint) {
|
|
225
225
|
// Live params: idmap keys per param.
|
|
226
226
|
const listLiveParams = listParams.map((p: any) => {
|
|
227
|
-
const key = p.
|
|
227
|
+
const key = p.n === 'id'
|
|
228
228
|
? entity.name + '01'
|
|
229
|
-
: p.
|
|
230
|
-
return { name: p.
|
|
229
|
+
: p.n.replace(/_id$/, '') + '01'
|
|
230
|
+
return { name: p.n, key }
|
|
231
231
|
})
|
|
232
232
|
|
|
233
233
|
Content(`
|
|
@@ -345,10 +345,10 @@ fn ${evar}_direct_list() {
|
|
|
345
345
|
if (hasLoad && loadPoint) {
|
|
346
346
|
// idmap keys consumed by load in live mode.
|
|
347
347
|
const loadLiveParams = loadParams.map((p: any) => {
|
|
348
|
-
const key = p.
|
|
348
|
+
const key = p.n === 'id'
|
|
349
349
|
? entity.name + '01'
|
|
350
|
-
: p.
|
|
351
|
-
return { name: p.
|
|
350
|
+
: p.n.replace(/_id$/, '') + '01'
|
|
351
|
+
return { name: p.n, key }
|
|
352
352
|
})
|
|
353
353
|
|
|
354
354
|
Content(`
|