@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
|
@@ -180,8 +180,8 @@ function generateDirectGraphql(
|
|
|
180
180
|
point: any,
|
|
181
181
|
strict: boolean,
|
|
182
182
|
) {
|
|
183
|
-
const doc: string = point.
|
|
184
|
-
const vars: any[] = point.
|
|
183
|
+
const doc: string = point.gq.doc
|
|
184
|
+
const vars: any[] = point.gq.vars || []
|
|
185
185
|
|
|
186
186
|
const varLine = (target: string, key: string, v: any) =>
|
|
187
187
|
` ${target}[${JSON.stringify(v.name)}] = ${key}`
|
|
@@ -275,8 +275,8 @@ function generateDirectLoad(model: Model, entity: ModelEntity, strict: boolean)
|
|
|
275
275
|
return
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
-
const allLoadParams = loadPoint.
|
|
279
|
-
const loadPath = normalizePathParams(pointParts(loadPoint), allLoadParams, loadPoint.
|
|
278
|
+
const allLoadParams = loadPoint.g?.params || []
|
|
279
|
+
const loadPath = normalizePathParams(pointParts(loadPoint), allLoadParams, loadPoint.r?.param)
|
|
280
280
|
|
|
281
281
|
// Some upstream OpenAPI specs declare a parameter as `in: path` even when
|
|
282
282
|
// that path has no `{name}` placeholder for it. Only path params that
|
|
@@ -289,7 +289,7 @@ function generateDirectLoad(model: Model, entity: ModelEntity, strict: boolean)
|
|
|
289
289
|
pathPlaceholders.add(part.slice(1, -1))
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
|
-
const renameMap = (loadPoint.
|
|
292
|
+
const renameMap = (loadPoint.r?.param || {}) as Record<string, string>
|
|
293
293
|
const renamedPlaceholders = new Set<string>()
|
|
294
294
|
for (const ph of pathPlaceholders) {
|
|
295
295
|
renamedPlaceholders.add(ph)
|
|
@@ -298,42 +298,42 @@ function generateDirectLoad(model: Model, entity: ModelEntity, strict: boolean)
|
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
const loadParams = allLoadParams.filter((p: any) =>
|
|
301
|
-
renamedPlaceholders.has(p.
|
|
301
|
+
renamedPlaceholders.has(p.n) || renamedPlaceholders.has(p.or))
|
|
302
302
|
|
|
303
303
|
// Required query params that the spec advertises an example value for.
|
|
304
304
|
// Live mode needs these on the request or the API returns 4xx; mock mode
|
|
305
305
|
// ignores them. Optional query params (e.g. `app`, `version`) are skipped
|
|
306
306
|
// even when they have examples — only the strictly required ones are
|
|
307
307
|
// necessary to satisfy the contract.
|
|
308
|
-
const loadQuery = loadPoint.
|
|
308
|
+
const loadQuery = loadPoint.g?.query || []
|
|
309
309
|
const liveQueryEntries = loadQuery
|
|
310
|
-
.filter((q: any) => q.
|
|
310
|
+
.filter((q: any) => q.r && undefined !== q.ex && null !== q.ex)
|
|
311
311
|
const hasLiveQuery = liveQueryEntries.length > 0
|
|
312
312
|
const liveQueryLines = liveQueryEntries
|
|
313
|
-
.map((q: any) => ` ${jsProp('query', q.
|
|
313
|
+
.map((q: any) => ` ${jsProp('query', q.n)} = ${JSON.stringify(q.ex)}`)
|
|
314
314
|
.join('\n')
|
|
315
315
|
|
|
316
316
|
const listOp = entity.op?.list
|
|
317
317
|
const listPoint = listOp?.points?.[0]
|
|
318
|
-
const listParams = listPoint?.
|
|
319
|
-
const listPath = listPoint ? normalizePathParams(pointParts(listPoint), listParams, listPoint.
|
|
318
|
+
const listParams = listPoint?.g?.params || []
|
|
319
|
+
const listPath = listPoint ? normalizePathParams(pointParts(listPoint), listParams, listPoint.r?.param) : ''
|
|
320
320
|
const hasList = null != listPoint
|
|
321
321
|
|
|
322
|
-
const ancestorParams = loadParams.filter((p: any) => p.
|
|
322
|
+
const ancestorParams = loadParams.filter((p: any) => p.n !== 'id')
|
|
323
323
|
|
|
324
324
|
const paramAsserts = loadParams.map((p: any, i: number) =>
|
|
325
325
|
' assert(calls[0].url.includes(\'direct0' + (i + 1) + '\'))\n').join('')
|
|
326
326
|
|
|
327
327
|
const liveListParams = listParams.map((p: any) => {
|
|
328
|
-
const key = p.
|
|
328
|
+
const key = p.n === 'id'
|
|
329
329
|
? entity.name + '01'
|
|
330
|
-
: p.
|
|
331
|
-
return { name: p.
|
|
330
|
+
: p.n.replace(/_id$/, '') + '01'
|
|
331
|
+
return { name: p.n, key }
|
|
332
332
|
})
|
|
333
333
|
|
|
334
334
|
const liveAncestorParams = ancestorParams.map((p: any) => {
|
|
335
|
-
const key = p.
|
|
336
|
-
return { name: p.
|
|
335
|
+
const key = p.n.replace(/_id$/, '') + '01'
|
|
336
|
+
return { name: p.n, key }
|
|
337
337
|
})
|
|
338
338
|
|
|
339
339
|
const liveQueryPrefix = liveQueryLines ? liveQueryLines + '\n' : ''
|
|
@@ -344,7 +344,7 @@ function generateDirectLoad(model: Model, entity: ModelEntity, strict: boolean)
|
|
|
344
344
|
// so they avoid the brittleness of mapping list-response field names
|
|
345
345
|
// back to load path-param names.
|
|
346
346
|
const liveExampleParams = loadParams.filter(
|
|
347
|
-
(p: any) => undefined !== p.
|
|
347
|
+
(p: any) => undefined !== p.ex && null !== p.ex
|
|
348
348
|
)
|
|
349
349
|
const allLoadParamsHaveExamples =
|
|
350
350
|
loadParams.length > 0 && liveExampleParams.length === loadParams.length
|
|
@@ -354,12 +354,12 @@ function generateDirectLoad(model: Model, entity: ModelEntity, strict: boolean)
|
|
|
354
354
|
let liveParamsBlock = ''
|
|
355
355
|
if (allLoadParamsHaveExamples) {
|
|
356
356
|
const exampleLines = loadParams.map(
|
|
357
|
-
(p: any) => ` ${jsProp('params', p.
|
|
357
|
+
(p: any) => ` ${jsProp('params', p.n)} = ${JSON.stringify(p.ex)}`
|
|
358
358
|
).join('\n')
|
|
359
359
|
liveParamsBlock = ` if (setup.live) {
|
|
360
360
|
${liveQueryPrefix}${exampleLines}
|
|
361
361
|
} else {
|
|
362
|
-
${loadParams.map((p: any, i: number) => ` ${jsProp('params', p.
|
|
362
|
+
${loadParams.map((p: any, i: number) => ` ${jsProp('params', p.n)} = 'direct0${i + 1}'`).join('\n')}
|
|
363
363
|
}`
|
|
364
364
|
}
|
|
365
365
|
else if (hasList) {
|
|
@@ -372,9 +372,9 @@ ${loadParams.map((p: any, i: number) => ` ${jsProp('params', p.name)} = 'di
|
|
|
372
372
|
` ${lp.name}: setup.idmap['${lp.key}'],`).join('\n')
|
|
373
373
|
const ancestorParamLines = liveAncestorParams.map((lp: any) =>
|
|
374
374
|
` ${jsProp('params', lp.name)} = setup.idmap['${lp.key}']`).join('\n')
|
|
375
|
-
const idParamName = loadParams.find((p: any) => p.
|
|
375
|
+
const idParamName = loadParams.find((p: any) => p.n === 'id')
|
|
376
376
|
? 'id'
|
|
377
|
-
: (loadParams[0]?.
|
|
377
|
+
: (loadParams[0]?.n ?? 'id')
|
|
378
378
|
|
|
379
379
|
liveParamsBlock = ` if (setup.live) {
|
|
380
380
|
${liveQueryPrefix} const listResult: any = await client.direct({
|
|
@@ -397,7 +397,7 @@ ${listParamLines}
|
|
|
397
397
|
${jsProp('params', idParamName)} = candidateId
|
|
398
398
|
${ancestorParamLines}
|
|
399
399
|
} else {
|
|
400
|
-
${loadParams.map((p: any, i: number) => ` ${jsProp('params', p.
|
|
400
|
+
${loadParams.map((p: any, i: number) => ` ${jsProp('params', p.n)} = 'direct0${i + 1}'`).join('\n')}
|
|
401
401
|
}`
|
|
402
402
|
} else if (hasLiveQuery || loadParams.length > 0) {
|
|
403
403
|
// Synthetic-only fallback: if there are load params with no examples
|
|
@@ -405,12 +405,12 @@ ${loadParams.map((p: any, i: number) => ` ${jsProp('params', p.name)} = 'di
|
|
|
405
405
|
// undefined values. Mark the path-param keys so the test skips when
|
|
406
406
|
// ENTID overrides aren't supplied.
|
|
407
407
|
if (loadParams.length > 0) {
|
|
408
|
-
liveIdKeys = loadParams.map((p: any) => p.
|
|
408
|
+
liveIdKeys = loadParams.map((p: any) => p.n + '01')
|
|
409
409
|
}
|
|
410
410
|
liveParamsBlock = ` if (setup.live) {
|
|
411
411
|
${liveQueryPrefix.replace(/\n$/, '')}
|
|
412
412
|
} else {
|
|
413
|
-
${loadParams.map((p: any, i: number) => ` ${jsProp('params', p.
|
|
413
|
+
${loadParams.map((p: any, i: number) => ` ${jsProp('params', p.n)} = 'direct0${i + 1}'`).join('\n')}
|
|
414
414
|
}`
|
|
415
415
|
} else {
|
|
416
416
|
liveParamsBlock = ''
|
|
@@ -496,20 +496,20 @@ function generateDirectList(model: Model, entity: ModelEntity, strict: boolean)
|
|
|
496
496
|
return
|
|
497
497
|
}
|
|
498
498
|
|
|
499
|
-
const listParams = listPoint.
|
|
500
|
-
const listPath = normalizePathParams(pointParts(listPoint), listParams, listPoint.
|
|
499
|
+
const listParams = listPoint.g?.params || []
|
|
500
|
+
const listPath = normalizePathParams(pointParts(listPoint), listParams, listPoint.r?.param)
|
|
501
501
|
|
|
502
|
-
const listQuery = listPoint.
|
|
502
|
+
const listQuery = listPoint.g?.query || []
|
|
503
503
|
const liveQueryLines = listQuery
|
|
504
|
-
.filter((q: any) => q.
|
|
505
|
-
.map((q: any) => ` ${jsProp('query', q.
|
|
504
|
+
.filter((q: any) => q.r && undefined !== q.ex && null !== q.ex)
|
|
505
|
+
.map((q: any) => ` ${jsProp('query', q.n)} = ${JSON.stringify(q.ex)}`)
|
|
506
506
|
.join('\n')
|
|
507
507
|
|
|
508
508
|
const liveParams = listParams.map((p: any) => {
|
|
509
|
-
const key = p.
|
|
509
|
+
const key = p.n === 'id'
|
|
510
510
|
? entity.name + '01'
|
|
511
|
-
: p.
|
|
512
|
-
return { name: p.
|
|
511
|
+
: p.n.replace(/_id$/, '') + '01'
|
|
512
|
+
return { name: p.n, key }
|
|
513
513
|
})
|
|
514
514
|
|
|
515
515
|
const paramAsserts = listParams.map((p: any, i: number) =>
|
|
@@ -523,7 +523,7 @@ function generateDirectList(model: Model, entity: ModelEntity, strict: boolean)
|
|
|
523
523
|
` ${jsProp('params', lp.name)} = setup.idmap['${lp.key}']`).join('\n'),
|
|
524
524
|
].filter(Boolean).join('\n')
|
|
525
525
|
const mockLines = listParams.map((p: any, i: number) =>
|
|
526
|
-
` ${jsProp('params', p.
|
|
526
|
+
` ${jsProp('params', p.n)} = 'direct0${i + 1}'`).join('\n')
|
|
527
527
|
|
|
528
528
|
paramsBlock = ` const params: any = {}
|
|
529
529
|
const query: any = {}
|
|
@@ -620,10 +620,10 @@ function normalizePathParams(
|
|
|
620
620
|
// original name was renamed to another param's current name (e.g. badge
|
|
621
621
|
// load: param 'group_id' has orig 'id', and another param has name 'id').
|
|
622
622
|
const param = params.find((p: any) =>
|
|
623
|
-
p.
|
|
623
|
+
p.n === snaked || p.n === depluralized) ||
|
|
624
624
|
params.find((p: any) =>
|
|
625
|
-
p.
|
|
626
|
-
if (param) return '{' + param.
|
|
625
|
+
p.or === snaked || p.or === depluralized)
|
|
626
|
+
if (param) return '{' + param.n + '}'
|
|
627
627
|
|
|
628
628
|
// Reverse-lookup through rename mapping: if rawName is a renamed value
|
|
629
629
|
// (e.g. "id"), find the original camelCase key (e.g. "closureId"),
|
|
@@ -634,10 +634,10 @@ function normalizePathParams(
|
|
|
634
634
|
const origSnaked = snakify(origCamel)
|
|
635
635
|
const origDepluralized = depluralize(origSnaked)
|
|
636
636
|
const renamedParam = params.find(
|
|
637
|
-
(p: any) => p.
|
|
638
|
-
p.
|
|
637
|
+
(p: any) => p.or === origSnaked || p.n === origSnaked ||
|
|
638
|
+
p.or === origDepluralized || p.n === origDepluralized
|
|
639
639
|
)
|
|
640
|
-
if (renamedParam) return '{' + renamedParam.
|
|
640
|
+
if (renamedParam) return '{' + renamedParam.n + '}'
|
|
641
641
|
}
|
|
642
642
|
}
|
|
643
643
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { pointFacts } from '@voxgig/sdkgen'
|
|
2
|
+
import { buildIdNames } from '@voxgig/sdkgen'
|
|
3
|
+
import { flowSteps } from '@voxgig/sdkgen'
|
|
1
4
|
|
|
2
5
|
import * as Path from 'node:path'
|
|
3
6
|
|
|
@@ -105,6 +108,8 @@ const TestEntity = cmp(function TestEntity(props: any) {
|
|
|
105
108
|
const basicflow = getModelPath(model, `main.${KIT}.flow.Basic${nom(entity, 'Name')}Flow`)
|
|
106
109
|
|
|
107
110
|
const dobasic = basicflow && true === basicflow.active
|
|
111
|
+
const liveFacts = Object.fromEntries(Object.values(entity.op || {}).flatMap((op: any) =>
|
|
112
|
+
(op.points || []).map((point: any) => [point.m + ' ' + point.o, pointFacts(ctx$, point)])))
|
|
108
113
|
|
|
109
114
|
if (!dobasic) {
|
|
110
115
|
return;
|
|
@@ -112,15 +117,7 @@ const TestEntity = cmp(function TestEntity(props: any) {
|
|
|
112
117
|
|
|
113
118
|
const indent = 2
|
|
114
119
|
|
|
115
|
-
const idlist =
|
|
116
|
-
entity.name + '01',
|
|
117
|
-
entity.name + '02',
|
|
118
|
-
entity.name + '03',
|
|
119
|
-
flatten(items(entity.relations.ancestors, (ap: any) =>
|
|
120
|
-
items(ap[1], (a: any) =>
|
|
121
|
-
items(['01', '02', '03'], (n: any) =>
|
|
122
|
-
a[1] + n[1]))), 2)
|
|
123
|
-
])
|
|
120
|
+
const idlist = buildIdNames(entity, basicflow)
|
|
124
121
|
|
|
125
122
|
Slot({ name: 'basicSetup' }, () => {
|
|
126
123
|
Content(`
|
|
@@ -208,8 +205,8 @@ function basicSetup(extra?: any) {
|
|
|
208
205
|
|
|
209
206
|
|
|
210
207
|
Slot({ name: 'basic' }, () => {
|
|
211
|
-
const flowHasCreate = Object.values(basicflow
|
|
212
|
-
(s: any) => s.
|
|
208
|
+
const flowHasCreate = Object.values(flowSteps(basicflow)).some(
|
|
209
|
+
(s: any) => s.o === 'create'
|
|
213
210
|
)
|
|
214
211
|
|
|
215
212
|
// The basic test exercises a flow with one or more ops (load,
|
|
@@ -218,7 +215,7 @@ function basicSetup(extra?: any) {
|
|
|
218
215
|
// dependent (e.g. update needs prior load), skipping ANY op the
|
|
219
216
|
// flow exercises skips the whole basic test.
|
|
220
217
|
const flowOps = Array.from(new Set(
|
|
221
|
-
(basicflow
|
|
218
|
+
(flowSteps(basicflow) as any[]).map((s: any) => s.o).filter(Boolean)
|
|
222
219
|
))
|
|
223
220
|
const flowOpsLiteral = '[' + flowOps.map((o: any) => `'${o}'`).join(', ') + ']'
|
|
224
221
|
|
|
@@ -231,7 +228,7 @@ function basicSetup(extra?: any) {
|
|
|
231
228
|
${hasLiveScenarios(model) ? `if (live) { t.skip('Covered by live operation scenarios'); return }` : ''}
|
|
232
229
|
const setup = basicSetup()
|
|
233
230
|
if (setup.live) {
|
|
234
|
-
return runLiveEntity(setup, ${JSON.stringify(entity)}, ${JSON.stringify(basicflow)}, '${nom(entity, 'Name')}')
|
|
231
|
+
return runLiveEntity(setup, ${JSON.stringify(entity)}, ${JSON.stringify(basicflow)}, '${nom(entity, 'Name')}', ${JSON.stringify(liveFacts)})
|
|
235
232
|
}
|
|
236
233
|
const client = setup.client
|
|
237
234
|
const struct = setup.struct
|
|
@@ -253,16 +250,16 @@ function basicSetup(extra?: any) {
|
|
|
253
250
|
const genCtx: GenCtx = {
|
|
254
251
|
model, entity, flow: basicflow, PROJUPPER: PROJENVNAME,
|
|
255
252
|
}
|
|
256
|
-
each(basicflow
|
|
253
|
+
each(flowSteps(basicflow), (step: ModelEntityFlowStep, index: number) => {
|
|
257
254
|
// Never emit a REMOVE (or its removed-item verify LIST) without a
|
|
258
255
|
// preceding CREATE: a coherent CRUD flow only removes what it made,
|
|
259
256
|
// so a create-less remove would mutate pre-existing (live) data.
|
|
260
257
|
if (!flowHasCreate) {
|
|
261
|
-
if ('remove' === step.
|
|
262
|
-
if ('list' === step.
|
|
263
|
-
(step.
|
|
258
|
+
if ('remove' === step.o) { return }
|
|
259
|
+
if ('list' === step.o &&
|
|
260
|
+
(step.v || []).some((v: any) => 'ItemNotExists' === v.apply)) { return }
|
|
264
261
|
}
|
|
265
|
-
const opgen = GENERATE_OP[step.
|
|
262
|
+
const opgen = GENERATE_OP[step.o]
|
|
266
263
|
if (null != opgen) {
|
|
267
264
|
opgen(genCtx, step, index)
|
|
268
265
|
Content('\n')
|
|
@@ -277,18 +274,18 @@ function basicSetup(extra?: any) {
|
|
|
277
274
|
|
|
278
275
|
const generateCreate: OpGen = (ctx, step, index) => {
|
|
279
276
|
const { entity, flow } = ctx
|
|
280
|
-
const ref = step.
|
|
281
|
-
const entvar = step.
|
|
282
|
-
const datavar = step.
|
|
277
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
278
|
+
const entvar = step.i.entvar ?? ref + '_ent'
|
|
279
|
+
const datavar = step.i.datavar ?? (ref + '_data' + (step.i.suffix ?? ''))
|
|
283
280
|
|
|
284
|
-
const priorSteps = flow.
|
|
281
|
+
const priorSteps = flowSteps(flow).slice(0, Number(index))
|
|
285
282
|
const needsEnt = !priorSteps.some(s =>
|
|
286
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
283
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
287
284
|
|
|
288
285
|
const hasDatvar = priorSteps.some(s => {
|
|
289
|
-
if ('create' === s.
|
|
290
|
-
const priorRef = s.
|
|
291
|
-
const priorDatvar = s.
|
|
286
|
+
if ('create' === s.o) {
|
|
287
|
+
const priorRef = s.i.ref ?? entity.name + '_ref01'
|
|
288
|
+
const priorDatvar = s.i.datavar ?? (priorRef + '_data' + (s.i.suffix ?? ''))
|
|
292
289
|
return priorDatvar === datavar
|
|
293
290
|
}
|
|
294
291
|
return false
|
|
@@ -309,7 +306,7 @@ const generateCreate: OpGen = (ctx, step, index) => {
|
|
|
309
306
|
`)
|
|
310
307
|
}
|
|
311
308
|
|
|
312
|
-
each(step.
|
|
309
|
+
each(step.m, (mi: any) => {
|
|
313
310
|
Content(` ${datavar}['${mi.key$}'] = setup.idmap['${mi.val$}']
|
|
314
311
|
`)
|
|
315
312
|
})
|
|
@@ -333,14 +330,14 @@ const generateCreate: OpGen = (ctx, step, index) => {
|
|
|
333
330
|
const generateList: OpGen = (ctx, step, index) => {
|
|
334
331
|
const { entity, flow } = ctx
|
|
335
332
|
const hasDataId = null != entityDataIdField(entity)
|
|
336
|
-
const ref = step.
|
|
337
|
-
const entvar = step.
|
|
338
|
-
const matchvar = step.
|
|
339
|
-
const listvar = step.
|
|
333
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
334
|
+
const entvar = step.i.entvar ?? ref + '_ent'
|
|
335
|
+
const matchvar = step.i.matchvar ?? (ref + '_match' + (step.i.suffix ?? ''))
|
|
336
|
+
const listvar = step.i.listvar ?? (ref + '_list' + (step.i.suffix ?? ''))
|
|
340
337
|
|
|
341
|
-
const priorSteps = flow.
|
|
338
|
+
const priorSteps = flowSteps(flow).slice(0, Number(index))
|
|
342
339
|
const needsEnt = !priorSteps.some(s =>
|
|
343
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
340
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
344
341
|
|
|
345
342
|
Content(`
|
|
346
343
|
// LIST
|
|
@@ -352,7 +349,7 @@ const generateList: OpGen = (ctx, step, index) => {
|
|
|
352
349
|
Content(` const ${matchvar}: any = {}
|
|
353
350
|
`)
|
|
354
351
|
|
|
355
|
-
each(step.
|
|
352
|
+
each(step.m, (mi: any) => {
|
|
356
353
|
Content(` ${matchvar}['${mi.key$}'] = setup.idmap['${mi.val$}']
|
|
357
354
|
`)
|
|
358
355
|
})
|
|
@@ -360,12 +357,12 @@ const generateList: OpGen = (ctx, step, index) => {
|
|
|
360
357
|
Content(`
|
|
361
358
|
const ${listvar} = (await ${entvar}.list(${matchvar})).map((e: any) => e.data())
|
|
362
359
|
`)
|
|
363
|
-
const allSteps = flow
|
|
364
|
-
for (let vI = 0; vI < step.
|
|
365
|
-
const validator = step.
|
|
360
|
+
const allSteps = flowSteps(flow)
|
|
361
|
+
for (let vI = 0; vI < step.v.length; vI++) {
|
|
362
|
+
const validator = step.v[vI]
|
|
366
363
|
const validRef = validator.def?.ref
|
|
367
|
-
const hasRefData = validRef && allSteps.some(s => 'create' === s.
|
|
368
|
-
((s.
|
|
364
|
+
const hasRefData = validRef && allSteps.some(s => 'create' === s.o &&
|
|
365
|
+
((s.i.ref ?? entity.name + '_ref01') === validRef))
|
|
369
366
|
|
|
370
367
|
if ('ItemExists' === validator.apply && hasRefData && hasDataId) {
|
|
371
368
|
Content(`
|
|
@@ -383,16 +380,16 @@ const generateList: OpGen = (ctx, step, index) => {
|
|
|
383
380
|
|
|
384
381
|
const generateUpdate: OpGen = (ctx, step, index) => {
|
|
385
382
|
const { entity, flow } = ctx
|
|
386
|
-
const ref = step.
|
|
387
|
-
const entvar = step.
|
|
388
|
-
const datavar = step.
|
|
389
|
-
const resdatavar = step.
|
|
390
|
-
const markdefvar = step.
|
|
391
|
-
const srcdatavar = step.
|
|
392
|
-
|
|
393
|
-
const priorSteps = flow.
|
|
383
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
384
|
+
const entvar = step.i.entvar ?? ref + '_ent'
|
|
385
|
+
const datavar = step.i.datavar ?? (ref + '_data' + (step.i.suffix ?? ''))
|
|
386
|
+
const resdatavar = step.i.resdatavar ?? (ref + '_resdata' + (step.i.suffix ?? ''))
|
|
387
|
+
const markdefvar = step.i.markdefvar ?? (ref + '_markdef' + (step.i.suffix ?? ''))
|
|
388
|
+
const srcdatavar = step.i.srcdatavar ?? (ref + '_data' + (step.i.suffix ?? ''))
|
|
389
|
+
|
|
390
|
+
const priorSteps = flowSteps(flow).slice(0, Number(index))
|
|
394
391
|
const needsEnt = !priorSteps.some(s =>
|
|
395
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
392
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
396
393
|
|
|
397
394
|
const hasEntIdU = null != entity.id
|
|
398
395
|
|
|
@@ -410,7 +407,7 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
410
407
|
`)
|
|
411
408
|
}
|
|
412
409
|
|
|
413
|
-
each(step.
|
|
410
|
+
each(step.d, (mi: any) => {
|
|
414
411
|
if ('id' !== mi.key$) {
|
|
415
412
|
Content(` ${datavar} ['${mi.key$}'] = setup.idmap['${mi.key$}']
|
|
416
413
|
`)
|
|
@@ -418,10 +415,10 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
418
415
|
})
|
|
419
416
|
|
|
420
417
|
|
|
421
|
-
for (let sI = 0; sI < step.
|
|
422
|
-
const spec = step.
|
|
423
|
-
if ('TextFieldMark' === spec.apply && null != step.
|
|
424
|
-
const fieldname = step.
|
|
418
|
+
for (let sI = 0; sI < step.s.length; sI++) {
|
|
419
|
+
const spec = step.s[sI]
|
|
420
|
+
if ('TextFieldMark' === spec.apply && null != step.i.textfield) {
|
|
421
|
+
const fieldname = step.i.textfield
|
|
425
422
|
const fieldvalue = spec.def.mark
|
|
426
423
|
Content(`
|
|
427
424
|
const ${markdefvar} = { name: '${fieldname}', value: '${fieldvalue}_' + setup.now }
|
|
@@ -442,9 +439,9 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
442
439
|
`)
|
|
443
440
|
}
|
|
444
441
|
|
|
445
|
-
for (let sI = 0; sI < step.
|
|
446
|
-
const spec = step.
|
|
447
|
-
if ('TextFieldMark' === spec.apply && null != step.
|
|
442
|
+
for (let sI = 0; sI < step.s.length; sI++) {
|
|
443
|
+
const spec = step.s[sI]
|
|
444
|
+
if ('TextFieldMark' === spec.apply && null != step.i.textfield) {
|
|
448
445
|
Content(`
|
|
449
446
|
assert((${resdatavar} as any)[${markdefvar}.name] === ${markdefvar}.value)
|
|
450
447
|
`)
|
|
@@ -456,25 +453,25 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
456
453
|
|
|
457
454
|
const generateLoad: OpGen = (ctx, step, index) => {
|
|
458
455
|
const { entity, flow } = ctx
|
|
459
|
-
const ref = step.
|
|
460
|
-
const entvar = step.
|
|
461
|
-
const matchvar = step.
|
|
462
|
-
const datavar = step.
|
|
463
|
-
const srcdatavar = step.
|
|
456
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
457
|
+
const entvar = step.i.entvar ?? ref + '_ent'
|
|
458
|
+
const matchvar = step.i.matchvar ?? (ref + '_match' + (step.i.suffix ?? ''))
|
|
459
|
+
const datavar = step.i.datavar ?? (ref + '_data' + (step.i.suffix ?? ''))
|
|
460
|
+
const srcdatavar = step.i.srcdatavar ?? (ref + '_data' + (step.i.suffix ?? ''))
|
|
464
461
|
|
|
465
|
-
const priorSteps = flow.
|
|
462
|
+
const priorSteps = flowSteps(flow).slice(0, Number(index))
|
|
466
463
|
const hasEntVar = priorSteps.some(s =>
|
|
467
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
464
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
468
465
|
|
|
469
466
|
// Check if srcdatavar was declared by a prior create step or by the
|
|
470
467
|
// preamble bootstrap (which runs when the flow has no create step)
|
|
471
|
-
const flowHasCreate = flow.
|
|
468
|
+
const flowHasCreate = flowSteps(flow).some(s => s.o === 'create')
|
|
472
469
|
const preambleRef = entity.name + '_ref01'
|
|
473
470
|
const hasSrcData = (!flowHasCreate && srcdatavar === preambleRef + '_data') ||
|
|
474
471
|
priorSteps.some(s => {
|
|
475
|
-
if ('create' === s.
|
|
476
|
-
const priorRef = s.
|
|
477
|
-
const priorDatvar = s.
|
|
472
|
+
if ('create' === s.o) {
|
|
473
|
+
const priorRef = s.i.ref ?? entity.name + '_ref01'
|
|
474
|
+
const priorDatvar = s.i.datavar ?? (priorRef + '_data' + (s.i.suffix ?? ''))
|
|
478
475
|
return priorDatvar === srcdatavar
|
|
479
476
|
}
|
|
480
477
|
return false
|
|
@@ -484,8 +481,8 @@ const generateLoad: OpGen = (ctx, step, index) => {
|
|
|
484
481
|
|
|
485
482
|
const loadOp = entity.op?.load
|
|
486
483
|
const loadPoint = loadOp?.points?.[0]
|
|
487
|
-
const loadPathParams = loadPoint?.
|
|
488
|
-
const loadHasRequiredParams = loadPathParams.some((p: any) => p.
|
|
484
|
+
const loadPathParams = loadPoint?.g?.params || []
|
|
485
|
+
const loadHasRequiredParams = loadPathParams.some((p: any) => p.r !== false)
|
|
489
486
|
if (!hasEntId && loadHasRequiredParams) {
|
|
490
487
|
if (!hasEntVar) {
|
|
491
488
|
Content(`
|
|
@@ -526,14 +523,14 @@ const generateLoad: OpGen = (ctx, step, index) => {
|
|
|
526
523
|
|
|
527
524
|
const generateRemove: OpGen = (ctx, step, index) => {
|
|
528
525
|
const { entity, flow } = ctx
|
|
529
|
-
const ref = step.
|
|
530
|
-
const entvar = step.
|
|
531
|
-
const matchvar = step.
|
|
532
|
-
const srcdatavar = step.
|
|
526
|
+
const ref = step.i.ref ?? entity.name + '_ref01'
|
|
527
|
+
const entvar = step.i.entvar ?? ref + '_ent'
|
|
528
|
+
const matchvar = step.i.matchvar ?? (ref + '_match' + (step.i.suffix ?? ''))
|
|
529
|
+
const srcdatavar = step.i.srcdatavar ?? (ref + '_data')
|
|
533
530
|
|
|
534
|
-
const priorSteps = flow.
|
|
531
|
+
const priorSteps = flowSteps(flow).slice(0, Number(index))
|
|
535
532
|
const needsEnt = !priorSteps.some(s =>
|
|
536
|
-
['create', 'list', 'load', 'update', 'remove'].includes(s.
|
|
533
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.o))
|
|
537
534
|
|
|
538
535
|
// "Remove what you created" needs the created record's id. An entity with
|
|
539
536
|
// no DATA id field (entityDataIdField null — e.g. Multichannel's Template)
|
|
@@ -16,10 +16,10 @@ const TestLive = cmp(function TestLive(props: any) {
|
|
|
16
16
|
securitySource: all.securitySource,
|
|
17
17
|
responses: all.responses,
|
|
18
18
|
}
|
|
19
|
-
const same = operation.points.filter((p: any) => JSON.stringify(p.
|
|
19
|
+
const same = operation.points.filter((p: any) => JSON.stringify(p.q || {}) === JSON.stringify(point.q || {}))
|
|
20
20
|
plan.push({ entity: entity.name, accessor: nom(entity, 'Name'), op,
|
|
21
|
-
id: point.
|
|
22
|
-
action: point.
|
|
21
|
+
id: point.m + ' ' + point.o, contractVersion: 1, kind: point.k, graphql: point.gq, path: point.o, method: point.m,
|
|
22
|
+
action: point.q?.$action, rename: point.r, args: point.g, facts, reachable: same.length === 1 })
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -17,19 +17,19 @@ import {
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
// The declared canon-type sentinel of a named parameter of an op — looked up
|
|
20
|
-
// in the op's `points[].
|
|
20
|
+
// in the op's `points[].g.params[]` exactly as the typed-model generator
|
|
21
21
|
// does. Falls back to the entity field of the same name (used when the op
|
|
22
22
|
// has no params and the generated match type is `Partial<Entity>`). Returns
|
|
23
23
|
// undefined when neither is present.
|
|
24
24
|
function paramCanonType(entity: any, op: any, paramName: string): unknown {
|
|
25
25
|
const params = op ? each(opParams(op)) : []
|
|
26
|
-
const found = (params as any[]).find((p: any) => p && p.
|
|
26
|
+
const found = (params as any[]).find((p: any) => p && p.n === paramName)
|
|
27
27
|
if (found) {
|
|
28
|
-
return found.
|
|
28
|
+
return found.t
|
|
29
29
|
}
|
|
30
30
|
const field = (entity && entity.fields ? each(entity.fields) : [])
|
|
31
|
-
.find((f: any) => f && f.
|
|
32
|
-
return field && field.
|
|
31
|
+
.find((f: any) => f && f.n === paramName) as any
|
|
32
|
+
return field && field.t
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
|
|
@@ -66,7 +66,7 @@ const ReadmeEntity = cmp(function ReadmeEntity(props: any) {
|
|
|
66
66
|
|
|
67
67
|
publishedEntities.map((entity: any) => {
|
|
68
68
|
const opnames = Object.keys(entity.op || {})
|
|
69
|
-
const fields = entity.fields ||
|
|
69
|
+
const fields = Object.values(entity.fields || {})
|
|
70
70
|
const idF = entityIdField(entity)
|
|
71
71
|
const eVar = zigVarName(entity.name)
|
|
72
72
|
const method = zigVarName(entity.name)
|
|
@@ -115,8 +115,8 @@ carries the result \`Value\`, \`.err => |e|\` carries the branded error.
|
|
|
115
115
|
`)
|
|
116
116
|
|
|
117
117
|
each(fields, (field: any) => {
|
|
118
|
-
const desc = field.
|
|
119
|
-
Content(`| \`${field.
|
|
118
|
+
const desc = field.sh || ''
|
|
119
|
+
Content(`| \`${field.n}\` | \`${zigType(field.t)}\` | ${desc} |
|
|
120
120
|
`)
|
|
121
121
|
})
|
|
122
122
|
|
|
@@ -118,13 +118,13 @@ On error, \`ok\` is \`false\` and \`err\` carries the error message.
|
|
|
118
118
|
|
|
119
119
|
`)
|
|
120
120
|
each(entityList, (ent: any) => {
|
|
121
|
-
const fields = ent.fields ||
|
|
121
|
+
const fields = Object.values(ent.fields || {})
|
|
122
122
|
const opnames = Object.keys(ent.op || {})
|
|
123
123
|
const ops = ent.op || {}
|
|
124
124
|
const points = each(ops).map((op: any) =>
|
|
125
125
|
op.points ? each(op.points) : []
|
|
126
126
|
).flat()
|
|
127
|
-
const path = points.length > 0 ? (points[0] as any).
|
|
127
|
+
const path = points.length > 0 ? (points[0] as any).o || '' : ''
|
|
128
128
|
|
|
129
129
|
Content(`#### ${ent.Name}
|
|
130
130
|
|
|
@@ -132,7 +132,7 @@ On error, \`ok\` is \`false\` and \`err\` carries the error message.
|
|
|
132
132
|
| --- | --- |
|
|
133
133
|
`)
|
|
134
134
|
each(fields, (field: any) => {
|
|
135
|
-
Content(`| \`${field.
|
|
135
|
+
Content(`| \`${field.n}\` | ${field.sh || ''} |
|
|
136
136
|
`)
|
|
137
137
|
})
|
|
138
138
|
|
|
@@ -175,7 +175,7 @@ Prepare a fetch definition without sending. Returns the fetchdef (use
|
|
|
175
175
|
// Entity reference sections
|
|
176
176
|
publishedEntities.map((ent: any) => {
|
|
177
177
|
const opnames = Object.keys(ent.op || {})
|
|
178
|
-
const fields = ent.fields ||
|
|
178
|
+
const fields = Object.values(ent.fields || {})
|
|
179
179
|
const idF = entityIdField(ent)
|
|
180
180
|
const eVar = zigVarName(ent.name)
|
|
181
181
|
const method = zigVarName(ent.name)
|
|
@@ -208,9 +208,9 @@ const ${eVar} = client.${method}(h.vnull());
|
|
|
208
208
|
| --- | --- | --- | --- |
|
|
209
209
|
`)
|
|
210
210
|
each(fields, (field: any) => {
|
|
211
|
-
const req = field.
|
|
212
|
-
const desc = field.
|
|
213
|
-
Content(`| \`${field.
|
|
211
|
+
const req = field.r ? 'Yes' : 'No'
|
|
212
|
+
const desc = field.sh || ''
|
|
213
|
+
Content(`| \`${field.n}\` | \`${zigType(field.t)}\` | ${req} | ${desc} |
|
|
214
214
|
`)
|
|
215
215
|
})
|
|
216
216
|
|
|
@@ -235,7 +235,7 @@ const ${eVar} = client.${method}(h.vnull());
|
|
|
235
235
|
if (fop.active === false) return '-'
|
|
236
236
|
return 'Yes'
|
|
237
237
|
})
|
|
238
|
-
Content(`| \`${field.
|
|
238
|
+
Content(`| \`${field.n}\` | ${cols.join(' | ')} |
|
|
239
239
|
`)
|
|
240
240
|
})
|
|
241
241
|
|
|
@@ -28,7 +28,7 @@ const Schema = cmp(async function Schema(props: any) {
|
|
|
28
28
|
Content(`// ${model.const.Name} SDK: generated schemas. Do not edit.
|
|
29
29
|
//
|
|
30
30
|
// Built from the model: \`main.kit.optspec\` and each feature's
|
|
31
|
-
// \`config.options\` for the option spec; entity \`fields
|
|
31
|
+
// \`config.options\` for the option spec; entity \`fields{}.type\` for the
|
|
32
32
|
// entity specs.
|
|
33
33
|
|
|
34
34
|
const h = @import("helpers.zig");
|