@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,
|
|
@@ -63,10 +64,10 @@ const TestEntity = cmp(function TestEntity(props: any) {
|
|
|
63
64
|
for (const n of idnames) {
|
|
64
65
|
idmapObj[n] = String(n).toUpperCase()
|
|
65
66
|
}
|
|
66
|
-
const allSteps = Object.values(basicflow
|
|
67
|
-
const updateStep = allSteps.find((s: any) => s.
|
|
68
|
-
const updateData = updateStep?.
|
|
69
|
-
? Object.entries(updateStep.
|
|
67
|
+
const allSteps = Object.values(flowSteps(basicflow)) as any[]
|
|
68
|
+
const updateStep = allSteps.find((s: any) => s.o === 'update')
|
|
69
|
+
const updateData = updateStep?.d
|
|
70
|
+
? Object.entries(updateStep.d).filter(([k]: any) => k !== 'id' && !k.endsWith('$'))
|
|
70
71
|
: []
|
|
71
72
|
for (const [k, v] of updateData as any[]) {
|
|
72
73
|
if (null == idmapObj[k] && null != idmapObj[v as string]) {
|
|
@@ -120,10 +121,10 @@ object ${EntityName}EntityTest {
|
|
|
120
121
|
// that a later load/update/remove reads its id from. Seed it from the
|
|
121
122
|
// shipped "existing" fixtures here, mirroring the ts generator. Guarded on a
|
|
122
123
|
// DATA id field — an entity that carries no id has no `.get("id")` to read.
|
|
123
|
-
const flowHasCreate = allSteps.some((s: any) => s.
|
|
124
|
+
const flowHasCreate = allSteps.some((s: any) => s.o === 'create')
|
|
124
125
|
const needsPreambleData = !flowHasCreate &&
|
|
125
126
|
null != entityDataIdField(entity) &&
|
|
126
|
-
allSteps.some((s: any) => ['load', 'update', 'remove'].includes(s.
|
|
127
|
+
allSteps.some((s: any) => ['load', 'update', 'remove'].includes(s.o))
|
|
127
128
|
if (needsPreambleData) {
|
|
128
129
|
const preambleData = scalaVarName(entity.name + '_ref01_data')
|
|
129
130
|
Content(` val ${preambleData}Raw = Struct.items(Helpers.toMapAny(
|
|
@@ -133,8 +134,8 @@ object ${EntityName}EntityTest {
|
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
// Model-driven step iteration (sorted-key order for byte-stable output).
|
|
136
|
-
each(basicflow
|
|
137
|
-
const opgen: OpGen = GENERATE_OP[step.
|
|
137
|
+
each(flowSteps(basicflow), (step: any, index: any) => {
|
|
138
|
+
const opgen: OpGen = GENERATE_OP[step.o]
|
|
138
139
|
if (opgen) {
|
|
139
140
|
Content('\n')
|
|
140
141
|
opgen(genCtx, step, index)
|
|
@@ -151,13 +152,13 @@ object ${EntityName}EntityTest {
|
|
|
151
152
|
|
|
152
153
|
const generateCreate: OpGen = (ctx, step, index) => {
|
|
153
154
|
const { entity, flow, accessor, ENTLOWER } = ctx
|
|
154
|
-
const ref = step.
|
|
155
|
-
const entvar = scalaVarName(step.
|
|
156
|
-
const datavar = scalaVarName(step.
|
|
155
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
156
|
+
const entvar = scalaVarName(step.i.entvar ?? ref + '_ent')
|
|
157
|
+
const datavar = scalaVarName(step.i.datavar ?? (ref + '_data' + (step.i.suffix ?? '')))
|
|
157
158
|
|
|
158
|
-
const priorSteps = Object.values(flow
|
|
159
|
+
const priorSteps = Object.values(flowSteps(flow)).slice(0, Number(index)) as any[]
|
|
159
160
|
const needsEnt = !priorSteps.some((s: any) =>
|
|
160
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
161
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
161
162
|
|
|
162
163
|
Content(` // CREATE
|
|
163
164
|
`)
|
|
@@ -188,14 +189,14 @@ const generateCreate: OpGen = (ctx, step, index) => {
|
|
|
188
189
|
|
|
189
190
|
const generateList: OpGen = (ctx, step, index) => {
|
|
190
191
|
const { entity, flow, accessor, ENTLOWER } = ctx
|
|
191
|
-
const ref = step.
|
|
192
|
-
const entvar = scalaVarName(step.
|
|
193
|
-
const matchvar = scalaVarName(step.
|
|
194
|
-
const listvar = scalaVarName(step.
|
|
192
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
193
|
+
const entvar = scalaVarName(step.i.entvar ?? ref + '_ent')
|
|
194
|
+
const matchvar = scalaVarName(step.i.matchvar ?? (ref + '_match' + (step.i.suffix ?? '')))
|
|
195
|
+
const listvar = scalaVarName(step.i.listvar ?? (ref + '_list' + (step.i.suffix ?? '')))
|
|
195
196
|
|
|
196
|
-
const priorSteps = Object.values(flow
|
|
197
|
+
const priorSteps = Object.values(flowSteps(flow)).slice(0, Number(index)) as any[]
|
|
197
198
|
const needsEnt = !priorSteps.some((s: any) =>
|
|
198
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
199
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
199
200
|
|
|
200
201
|
Content(` // LIST
|
|
201
202
|
`)
|
|
@@ -213,12 +214,12 @@ const generateList: OpGen = (ctx, step, index) => {
|
|
|
213
214
|
}
|
|
214
215
|
|
|
215
216
|
const hasDataId = null != entityDataIdField(entity)
|
|
216
|
-
const allSteps = Object.values(flow
|
|
217
|
-
const listvarUsed = hasDataId && !!step.
|
|
217
|
+
const allSteps = Object.values(flowSteps(flow)) as any[]
|
|
218
|
+
const listvarUsed = hasDataId && !!step.v?.some((v: any) => {
|
|
218
219
|
if ('ItemExists' !== v.apply && 'ItemNotExists' !== v.apply) return false
|
|
219
220
|
const validRef = v.def?.ref
|
|
220
|
-
return validRef && allSteps.some((s: any) => 'create' === s.
|
|
221
|
-
((s.
|
|
221
|
+
return validRef && allSteps.some((s: any) => 'create' === s.o &&
|
|
222
|
+
((s.i.ref ?? entity.name + '_ref01') === validRef))
|
|
222
223
|
})
|
|
223
224
|
|
|
224
225
|
Content(` val ${listvar}Result = ${entvar}.list(${matchvar}, null)
|
|
@@ -229,11 +230,11 @@ const generateList: OpGen = (ctx, step, index) => {
|
|
|
229
230
|
`)
|
|
230
231
|
}
|
|
231
232
|
|
|
232
|
-
if (step.
|
|
233
|
-
for (const validator of step.
|
|
233
|
+
if (step.v) {
|
|
234
|
+
for (const validator of step.v) {
|
|
234
235
|
const validRef = validator.def?.ref
|
|
235
|
-
const hasRefData = validRef && allSteps.some((s: any) => 'create' === s.
|
|
236
|
-
((s.
|
|
236
|
+
const hasRefData = validRef && allSteps.some((s: any) => 'create' === s.o &&
|
|
237
|
+
((s.i.ref ?? entity.name + '_ref01') === validRef))
|
|
237
238
|
const refDataVar = scalaVarName(validRef + '_data')
|
|
238
239
|
|
|
239
240
|
if ('ItemExists' === validator.apply && hasRefData && hasDataId) {
|
|
@@ -254,16 +255,16 @@ const generateList: OpGen = (ctx, step, index) => {
|
|
|
254
255
|
|
|
255
256
|
const generateUpdate: OpGen = (ctx, step, index) => {
|
|
256
257
|
const { entity, flow, accessor, ENTLOWER } = ctx
|
|
257
|
-
const ref = step.
|
|
258
|
-
const entvar = scalaVarName(step.
|
|
259
|
-
const datavar = scalaVarName(step.
|
|
260
|
-
const resdatavar = scalaVarName(step.
|
|
261
|
-
const markdefvar = scalaVarName(step.
|
|
262
|
-
const srcdatavar = scalaVarName(step.
|
|
263
|
-
|
|
264
|
-
const priorSteps = Object.values(flow
|
|
258
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
259
|
+
const entvar = scalaVarName(step.i.entvar ?? ref + '_ent')
|
|
260
|
+
const datavar = scalaVarName(step.i.datavar ?? (ref + '_data' + (step.i.suffix ?? '')))
|
|
261
|
+
const resdatavar = scalaVarName(step.i.resdatavar ?? (ref + '_resdata' + (step.i.suffix ?? '')))
|
|
262
|
+
const markdefvar = scalaVarName(step.i.markdefvar ?? (ref + '_markdef' + (step.i.suffix ?? '')))
|
|
263
|
+
const srcdatavar = scalaVarName(step.i.srcdatavar ?? (ref + '_data' + (step.i.suffix ?? '')))
|
|
264
|
+
|
|
265
|
+
const priorSteps = Object.values(flowSteps(flow)).slice(0, Number(index)) as any[]
|
|
265
266
|
const needsEnt = !priorSteps.some((s: any) =>
|
|
266
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
267
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
267
268
|
|
|
268
269
|
const hasDataId = null != entityDataIdField(entity)
|
|
269
270
|
|
|
@@ -280,8 +281,8 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
280
281
|
`)
|
|
281
282
|
}
|
|
282
283
|
|
|
283
|
-
if (step.
|
|
284
|
-
const dataEntries = Object.entries(step.
|
|
284
|
+
if (step.d) {
|
|
285
|
+
const dataEntries = Object.entries(step.d).filter(([k]: any) => k !== 'id' && !k.endsWith('$'))
|
|
285
286
|
for (const [key] of dataEntries) {
|
|
286
287
|
Content(` ${datavar}Up.put("${key}", idmap.get("${key}"))
|
|
287
288
|
`)
|
|
@@ -289,10 +290,10 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
289
290
|
}
|
|
290
291
|
|
|
291
292
|
let hasMark = false
|
|
292
|
-
if (step.
|
|
293
|
-
for (const spec of step.
|
|
294
|
-
if ('TextFieldMark' === spec.apply && null != step.
|
|
295
|
-
const fieldname = step.
|
|
293
|
+
if (step.s) {
|
|
294
|
+
for (const spec of step.s) {
|
|
295
|
+
if ('TextFieldMark' === spec.apply && null != step.i.textfield) {
|
|
296
|
+
const fieldname = step.i.textfield
|
|
296
297
|
const fieldvalue = spec.def?.mark ?? `Mark01-${ref}`
|
|
297
298
|
hasMark = true
|
|
298
299
|
Content(` val ${markdefvar}Name = "${fieldname}"
|
|
@@ -320,23 +321,23 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
320
321
|
|
|
321
322
|
const generateLoad: OpGen = (ctx, step, index) => {
|
|
322
323
|
const { entity, flow, accessor, ENTLOWER } = ctx
|
|
323
|
-
const ref = step.
|
|
324
|
-
const entvar = scalaVarName(step.
|
|
325
|
-
const matchvar = scalaVarName(step.
|
|
326
|
-
const datavar = scalaVarName(step.
|
|
327
|
-
const srcdatavar = scalaVarName(step.
|
|
324
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
325
|
+
const entvar = scalaVarName(step.i.entvar ?? ref + '_ent')
|
|
326
|
+
const matchvar = scalaVarName(step.i.matchvar ?? (ref + '_match' + (step.i.suffix ?? '')))
|
|
327
|
+
const datavar = scalaVarName(step.i.datavar ?? (ref + '_data' + (step.i.suffix ?? '')))
|
|
328
|
+
const srcdatavar = scalaVarName(step.i.srcdatavar ?? (ref + '_data' + (step.i.suffix ?? '')))
|
|
328
329
|
|
|
329
|
-
const priorSteps = Object.values(flow
|
|
330
|
+
const priorSteps = Object.values(flowSteps(flow)).slice(0, Number(index)) as any[]
|
|
330
331
|
const hasEntVar = priorSteps.some((s: any) =>
|
|
331
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
332
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
332
333
|
|
|
333
|
-
const flowHasCreate = Object.values(flow
|
|
334
|
+
const flowHasCreate = Object.values(flowSteps(flow)).some((s: any) => (s as any).o === 'create')
|
|
334
335
|
const preambleRef = entity.name + '_ref01'
|
|
335
336
|
const hasSrcData = (!flowHasCreate && srcdatavar === scalaVarName(preambleRef + '_data')) ||
|
|
336
337
|
priorSteps.some((s: any) => {
|
|
337
|
-
if ('create' === s.
|
|
338
|
-
const priorRef = s.
|
|
339
|
-
const priorDatvar = scalaVarName(s.
|
|
338
|
+
if ('create' === s.o) {
|
|
339
|
+
const priorRef = s.i.ref ?? entity.name + '_ref01'
|
|
340
|
+
const priorDatvar = scalaVarName(s.i.datavar ?? (priorRef + '_data' + (s.i.suffix ?? '')))
|
|
340
341
|
return priorDatvar === srcdatavar
|
|
341
342
|
}
|
|
342
343
|
return false
|
|
@@ -375,10 +376,10 @@ const generateLoad: OpGen = (ctx, step, index) => {
|
|
|
375
376
|
|
|
376
377
|
const generateRemove: OpGen = (ctx, step, index) => {
|
|
377
378
|
const { entity, flow, accessor, ENTLOWER } = ctx
|
|
378
|
-
const ref = step.
|
|
379
|
-
const entvar = scalaVarName(step.
|
|
380
|
-
const matchvar = scalaVarName(step.
|
|
381
|
-
const srcdatavar = scalaVarName(step.
|
|
379
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
380
|
+
const entvar = scalaVarName(step.i.entvar ?? ref + '_ent')
|
|
381
|
+
const matchvar = scalaVarName(step.i.matchvar ?? (ref + '_match' + (step.i.suffix ?? '')))
|
|
382
|
+
const srcdatavar = scalaVarName(step.i.srcdatavar ?? (ref + '_data'))
|
|
382
383
|
|
|
383
384
|
// The remove-by-id match reads ${srcdatavar}.get("id"); skip the whole step
|
|
384
385
|
// when the DATA type has no id field (there is no created id to remove by).
|
|
@@ -386,9 +387,9 @@ const generateRemove: OpGen = (ctx, step, index) => {
|
|
|
386
387
|
return
|
|
387
388
|
}
|
|
388
389
|
|
|
389
|
-
const priorSteps = Object.values(flow
|
|
390
|
+
const priorSteps = Object.values(flowSteps(flow)).slice(0, Number(index)) as any[]
|
|
390
391
|
const needsEnt = !priorSteps.some((s: any) =>
|
|
391
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
392
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
392
393
|
|
|
393
394
|
Content(` // REMOVE
|
|
394
395
|
`)
|
|
@@ -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
|
|
@@ -82,13 +82,13 @@ import Foundation
|
|
|
82
82
|
entityList.forEach((ent: any) => {
|
|
83
83
|
const Name = ent.Name
|
|
84
84
|
const fields = (ent.fields ? each(ent.fields) : [])
|
|
85
|
-
.filter((f: any) => f.
|
|
85
|
+
.filter((f: any) => f.a !== false)
|
|
86
86
|
|
|
87
87
|
const TypeName = swiftSafeTypeName(Name)
|
|
88
88
|
emitStruct(
|
|
89
89
|
`/// ${TypeName} is the typed data model for the ${ent.name} entity.`,
|
|
90
90
|
TypeName,
|
|
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 || {}
|
|
@@ -55,7 +55,7 @@ const ReadmeEntity = cmp(function ReadmeEntity(props: any) {
|
|
|
55
55
|
|
|
56
56
|
publishedEntities.map((entity: any) => {
|
|
57
57
|
const opnames = Object.keys(entity.op || {})
|
|
58
|
-
const fields = entity.fields ||
|
|
58
|
+
const fields = Object.values(entity.fields || {})
|
|
59
59
|
const idF = entityIdField(entity)
|
|
60
60
|
// Sanitise the local variable name — a camelCased Swift keyword gets a
|
|
61
61
|
// trailing underscore (swiftVarName) so the snippet compiles.
|
|
@@ -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
|
|
|
@@ -115,13 +115,13 @@ On error, \`ok\` is \`false\` and \`err\` contains the error value.
|
|
|
115
115
|
|
|
116
116
|
`)
|
|
117
117
|
each(entityList, (ent: any) => {
|
|
118
|
-
const fields = ent.fields ||
|
|
118
|
+
const fields = Object.values(ent.fields || {})
|
|
119
119
|
const opnames = Object.keys(ent.op || {})
|
|
120
120
|
const ops = ent.op || {}
|
|
121
121
|
const points = each(ops).map((op: any) =>
|
|
122
122
|
op.points ? each(op.points) : []
|
|
123
123
|
).flat()
|
|
124
|
-
const path = points.length > 0 ? (points[0] as any).
|
|
124
|
+
const path = points.length > 0 ? (points[0] as any).o || '' : ''
|
|
125
125
|
|
|
126
126
|
Content(`#### ${ent.Name}
|
|
127
127
|
|
|
@@ -129,7 +129,7 @@ On error, \`ok\` is \`false\` and \`err\` contains the error value.
|
|
|
129
129
|
| --- | --- |
|
|
130
130
|
`)
|
|
131
131
|
each(fields, (field: any) => {
|
|
132
|
-
Content(`| \`${field.
|
|
132
|
+
Content(`| \`${field.n}\` | ${field.sh || ''} |
|
|
133
133
|
`)
|
|
134
134
|
})
|
|
135
135
|
|
|
@@ -169,7 +169,7 @@ Prepare a fetch definition without sending. Returns the \`fetchdef\` and throws
|
|
|
169
169
|
// Entity reference sections
|
|
170
170
|
publishedEntities.map((ent: any) => {
|
|
171
171
|
const opnames = Object.keys(ent.op || {})
|
|
172
|
-
const fields = ent.fields ||
|
|
172
|
+
const fields = Object.values(ent.fields || {})
|
|
173
173
|
// Model-driven id key: null when this entity has no id-like field.
|
|
174
174
|
const idF = entityIdField(ent)
|
|
175
175
|
// Sanitise the local variable name — swiftVarName guards Swift keywords.
|
|
@@ -204,9 +204,9 @@ let ${eVar} = client.${accessor}()
|
|
|
204
204
|
| --- | --- | --- | --- |
|
|
205
205
|
`)
|
|
206
206
|
each(fields, (field: any) => {
|
|
207
|
-
const req = field.
|
|
208
|
-
const desc = field.
|
|
209
|
-
Content(`| \`${field.
|
|
207
|
+
const req = field.r ? 'Yes' : 'No'
|
|
208
|
+
const desc = field.sh || ''
|
|
209
|
+
Content(`| \`${field.n}\` | \`${canonToType(field.t, target.name)}\` | ${req} | ${desc} |
|
|
210
210
|
`)
|
|
211
211
|
})
|
|
212
212
|
|
|
@@ -231,7 +231,7 @@ let ${eVar} = client.${accessor}()
|
|
|
231
231
|
if (fop.active === false) return '-'
|
|
232
232
|
return 'Yes'
|
|
233
233
|
})
|
|
234
|
-
Content(`| \`${field.
|
|
234
|
+
Content(`| \`${field.n}\` | ${cols.join(' | ')} |
|
|
235
235
|
`)
|
|
236
236
|
})
|
|
237
237
|
|
|
@@ -32,7 +32,7 @@ const Schema = cmp(async function Schema(props: any) {
|
|
|
32
32
|
// do not edit by hand.
|
|
33
33
|
//
|
|
34
34
|
// Built from the model: \`main.kit.optspec\` and each feature's
|
|
35
|
-
// \`config.options\` for optspec; entity \`fields
|
|
35
|
+
// \`config.options\` for optspec; entity \`fields{}.type\` for entityspec.
|
|
36
36
|
|
|
37
37
|
import Foundation
|
|
38
38
|
|
|
@@ -42,8 +42,8 @@ const EntityTypes = cmp(function EntityTypes(props: any) {
|
|
|
42
42
|
|
|
43
43
|
Content(`// Typed models for the ${model.const.Name} SDK.
|
|
44
44
|
//
|
|
45
|
-
// GENERATED from the API model: main.${KIT}.entity.<e>.fields
|
|
46
|
-
// params (op.<name>.points[].
|
|
45
|
+
// GENERATED from the API model: main.${KIT}.entity.<e>.fields{} and per-op
|
|
46
|
+
// params (op.<name>.points[].g.params[]). Field/param types come from the
|
|
47
47
|
// canonical type sentinels via @voxgig/sdkgen canonToType (source of truth:
|
|
48
48
|
// @voxgig/apidef VALID_CANON). Do not edit by hand.
|
|
49
49
|
|
|
@@ -53,13 +53,13 @@ const EntityTypes = cmp(function EntityTypes(props: any) {
|
|
|
53
53
|
const Name = ent.Name
|
|
54
54
|
const TypeName = tsSafeTypeName(Name)
|
|
55
55
|
const fields = (ent.fields ? each(ent.fields) : [])
|
|
56
|
-
.filter((f: any) => f.
|
|
56
|
+
.filter((f: any) => f.a !== false)
|
|
57
57
|
|
|
58
58
|
Content(`export interface ${TypeName} {
|
|
59
59
|
`)
|
|
60
60
|
fields.forEach((f: any) => {
|
|
61
|
-
const opt = false === f.
|
|
62
|
-
Content(` ${propKey(f.
|
|
61
|
+
const opt = false === f.r ? '?' : ''
|
|
62
|
+
Content(` ${propKey(f.n)}${opt}: ${canonToType(f.t, LANG)}
|
|
63
63
|
`)
|
|
64
64
|
})
|
|
65
65
|
Content(`}
|
|
@@ -45,7 +45,7 @@ const ReadmeEntity = cmp(function ReadmeEntity(props: any) {
|
|
|
45
45
|
|
|
46
46
|
publishedEntities.map((entity: any) => {
|
|
47
47
|
const opnames = Object.keys(entity.op || {})
|
|
48
|
-
const fields = entity.fields ||
|
|
48
|
+
const fields = Object.values(entity.fields || {})
|
|
49
49
|
// Model-driven id key: null when this entity has no id-like field.
|
|
50
50
|
const idF = entityIdField(entity)
|
|
51
51
|
const eVar = exampleVarName(entity.name, target.name)
|
|
@@ -91,8 +91,8 @@ const ReadmeEntity = cmp(function ReadmeEntity(props: any) {
|
|
|
91
91
|
`)
|
|
92
92
|
|
|
93
93
|
each(fields, (field: any) => {
|
|
94
|
-
const desc = field.
|
|
95
|
-
Content(`| \`${field.
|
|
94
|
+
const desc = field.sh || ''
|
|
95
|
+
Content(`| \`${field.n}\` | \`${canonToType(field.t, target.name)}\` | ${desc} |
|
|
96
96
|
`)
|
|
97
97
|
})
|
|
98
98
|
|
|
@@ -175,13 +175,13 @@ The \`prepare()\` method returns:
|
|
|
175
175
|
`)
|
|
176
176
|
|
|
177
177
|
each(entityList, (ent: any) => {
|
|
178
|
-
const fields = ent.fields ||
|
|
178
|
+
const fields = Object.values(ent.fields || {})
|
|
179
179
|
const opnames = Object.keys(ent.op || {})
|
|
180
180
|
const ops = ent.op || {}
|
|
181
181
|
const points = each(ops).map((op: any) =>
|
|
182
182
|
op.points ? each(op.points) : []
|
|
183
183
|
).flat()
|
|
184
|
-
const path = points.length > 0 ? (points[0] as any).
|
|
184
|
+
const path = points.length > 0 ? (points[0] as any).o || '' : ''
|
|
185
185
|
|
|
186
186
|
Content(`#### ${ent.Name}
|
|
187
187
|
|
|
@@ -189,7 +189,7 @@ The \`prepare()\` method returns:
|
|
|
189
189
|
| --- | --- |
|
|
190
190
|
`)
|
|
191
191
|
each(fields, (field: any) => {
|
|
192
|
-
Content(`| \`${field.
|
|
192
|
+
Content(`| \`${field.n}\` | ${field.sh || ''} |
|
|
193
193
|
`)
|
|
194
194
|
})
|
|
195
195
|
|
|
@@ -174,7 +174,7 @@ try {
|
|
|
174
174
|
|
|
175
175
|
const dataFields: any[] = exampleEntity.fields ? each(exampleEntity.fields) : []
|
|
176
176
|
const dataIdType = dataIdF
|
|
177
|
-
? (dataFields.find((f: any) => f && f.
|
|
177
|
+
? (dataFields.find((f: any) => f && f.n === dataIdF) || {}).type
|
|
178
178
|
: null
|
|
179
179
|
const usesCreatedId = (opname: string): boolean => {
|
|
180
180
|
if (null == dataIdF || !opnames.includes('create')) {
|
|
@@ -187,7 +187,7 @@ Alias for \`${model.Name}SDK.test()\`.
|
|
|
187
187
|
// Entity reference sections
|
|
188
188
|
publishedEntities.map((ent: any) => {
|
|
189
189
|
const opnames = Object.keys(ent.op || {})
|
|
190
|
-
const fields = ent.fields ||
|
|
190
|
+
const fields = Object.values(ent.fields || {})
|
|
191
191
|
// Model-driven id key: null when this entity has no id-like field, in
|
|
192
192
|
// which case load/remove match on no argument and update omits the id.
|
|
193
193
|
const idF = entityIdField(ent)
|
|
@@ -221,9 +221,9 @@ const ${eVar} = client.${ent.Name}()
|
|
|
221
221
|
| --- | --- | --- | --- |
|
|
222
222
|
`)
|
|
223
223
|
each(fields, (field: any) => {
|
|
224
|
-
const req = field.
|
|
225
|
-
const desc = field.
|
|
226
|
-
Content(`| \`${field.
|
|
224
|
+
const req = field.r ? 'Yes' : 'No'
|
|
225
|
+
const desc = field.sh || ''
|
|
226
|
+
Content(`| \`${field.n}\` | \`${canonToType(field.t, target.name)}\` | ${req} | ${desc} |
|
|
227
227
|
`)
|
|
228
228
|
})
|
|
229
229
|
|
|
@@ -250,7 +250,7 @@ const ${eVar} = client.${ent.Name}()
|
|
|
250
250
|
if (fop.active === false) return '-'
|
|
251
251
|
return 'Yes'
|
|
252
252
|
})
|
|
253
|
-
Content(`| \`${field.
|
|
253
|
+
Content(`| \`${field.n}\` | ${cols.join(' | ')} |
|
|
254
254
|
`)
|
|
255
255
|
})
|
|
256
256
|
|
|
@@ -25,7 +25,7 @@ const Schema = cmp(async function Schema(props: any) {
|
|
|
25
25
|
Content(`// ${model.const.Name} ${target.Name} SDK: generated schemas. Do not edit.
|
|
26
26
|
//
|
|
27
27
|
// Generated from the model: \`main.kit.optspec\` and each feature's
|
|
28
|
-
// \`config.options\` for OPTSPEC; entity \`fields
|
|
28
|
+
// \`config.options\` for OPTSPEC; entity \`fields{}.type\` for ENTITYSPEC.
|
|
29
29
|
|
|
30
30
|
const OPTSPEC = ${JSON.stringify(optspec, null, 2)}
|
|
31
31
|
|