@voxgig/sdkgen 4.34.3 → 4.34.4
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/helpers/opShape.js +6 -0
- package/dist/helpers/opShape.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/project/.sdk/src/cmp/cpp/TestEntity_cpp.ts +18 -3
- package/project/.sdk/src/cmp/csharp/TestEntity_csharp.ts +14 -3
- package/project/.sdk/src/cmp/go/TestEntity_go.ts +28 -4
- package/project/.sdk/src/cmp/java/TestEntity_java.ts +15 -3
- package/project/.sdk/src/cmp/js/ReadmeTopQuick_js.ts +11 -1
- package/project/.sdk/src/cmp/js/TestEntity_js.ts +22 -3
- package/project/.sdk/src/cmp/kotlin/TestEntity_kotlin.ts +14 -3
- package/project/.sdk/src/cmp/lua/TestEntity_lua.ts +14 -3
- package/project/.sdk/src/cmp/perl/TestEntity_perl.ts +14 -3
- package/project/.sdk/src/cmp/php/TestEntity_php.ts +14 -3
- package/project/.sdk/src/cmp/py/TestEntity_py.ts +14 -3
- package/project/.sdk/src/cmp/rb/TestEntity_rb.ts +14 -3
- package/project/.sdk/src/cmp/rust/TestEntity_rust.ts +17 -3
- package/project/.sdk/src/cmp/scala/TestEntity_scala.ts +13 -3
- package/project/.sdk/src/cmp/ts/ReadmeTopQuick_ts.ts +11 -1
- package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +27 -7
- package/project/sdkgen-package.json +1 -1
- package/src/helpers/opShape.ts +6 -0
|
@@ -419,9 +419,11 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
419
419
|
`)
|
|
420
420
|
}
|
|
421
421
|
|
|
422
|
+
// A parent id is keyed in idmap by its fixture name (step.d's value); a
|
|
423
|
+
// live ENTID may key it by the field name instead.
|
|
422
424
|
each(step.d, (mi: any) => {
|
|
423
425
|
if ('id' !== mi.key$) {
|
|
424
|
-
Content(` ${datavar}
|
|
426
|
+
Content(` ${datavar}['${mi.key$}'] = setup.idmap['${mi.key$}'] ?? setup.idmap['${mi.val$}']
|
|
425
427
|
`)
|
|
426
428
|
}
|
|
427
429
|
})
|
|
@@ -517,16 +519,20 @@ const generateLoad: OpGen = (ctx, step, index) => {
|
|
|
517
519
|
Content(` const ${srcdatavar} = Object.values(setup.data.existing.${entity.name})[0] as any
|
|
518
520
|
`)
|
|
519
521
|
}
|
|
522
|
+
Content(` const ${matchvar}: any = {}
|
|
523
|
+
`)
|
|
520
524
|
if (hasEntId) {
|
|
521
|
-
Content(`
|
|
522
|
-
|
|
523
|
-
|
|
525
|
+
Content(` ${matchvar}.id = ${srcdatavar}.id
|
|
526
|
+
`)
|
|
527
|
+
}
|
|
528
|
+
parentMatch(step, matchvar)
|
|
529
|
+
if (hasEntId) {
|
|
530
|
+
Content(` const ${datavar} = (await ${entvar}.load(${matchvar})).data()
|
|
524
531
|
assert(${datavar}.id === ${srcdatavar}.id)
|
|
525
532
|
`)
|
|
526
533
|
}
|
|
527
534
|
else {
|
|
528
|
-
Content(` const ${
|
|
529
|
-
const ${datavar} = (await ${entvar}.load(${matchvar})).data()
|
|
535
|
+
Content(` const ${datavar} = (await ${entvar}.load(${matchvar})).data()
|
|
530
536
|
assert(null != ${datavar})
|
|
531
537
|
`)
|
|
532
538
|
}
|
|
@@ -563,11 +569,25 @@ const generateRemove: OpGen = (ctx, step, index) => {
|
|
|
563
569
|
// removes the first match in entmap, so without a specific id the
|
|
564
570
|
// result depends on hash-sort order and flakes (see cheapshark).
|
|
565
571
|
Content(` const ${matchvar}: any = { id: ${srcdatavar}.id }
|
|
566
|
-
|
|
572
|
+
`)
|
|
573
|
+
parentMatch(step, matchvar)
|
|
574
|
+
Content(` await ${entvar}.remove(${matchvar})
|
|
567
575
|
`)
|
|
568
576
|
}
|
|
569
577
|
|
|
570
578
|
|
|
579
|
+
// A child's route names its parents, and an entity no earlier step has
|
|
580
|
+
// filled knows none of them, so the call itself gives each parent id.
|
|
581
|
+
function parentMatch(step: any, matchvar: string) {
|
|
582
|
+
each(step.m, (mi: any) => {
|
|
583
|
+
if ('id' !== mi.key$ && !mi.key$.endsWith('$')) {
|
|
584
|
+
Content(` ${matchvar}['${mi.key$}'] = setup.idmap['${mi.key$}'] ?? setup.idmap['${mi.val$}']
|
|
585
|
+
`)
|
|
586
|
+
}
|
|
587
|
+
})
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
|
|
571
591
|
const GENERATE_OP: Record<string, OpGen> = {
|
|
572
592
|
create: generateCreate,
|
|
573
593
|
list: generateList,
|
package/src/helpers/opShape.ts
CHANGED
|
@@ -324,6 +324,12 @@ function entityIdField(ent: any): string | null {
|
|
|
324
324
|
if (loadItems.some((it: OpShapeItem) => it.name === 'id')) {
|
|
325
325
|
return 'id'
|
|
326
326
|
}
|
|
327
|
+
// An entity with no load at all is still matched by its id where its
|
|
328
|
+
// remove route names it, as Umbrella's permission is.
|
|
329
|
+
if (null == (ent.op && ent.op.load) &&
|
|
330
|
+
opRequestShape(ent, 'remove').items.some((it: OpShapeItem) => it.name === idName)) {
|
|
331
|
+
return idName
|
|
332
|
+
}
|
|
327
333
|
// NO fallback to entity.fields: this is the load-MATCH key. An entity whose
|
|
328
334
|
// DATA type has an `id` field but whose load match does NOT (a query-param
|
|
329
335
|
// load, e.g. playstation-store's StoreLoadMatch { age, country, ... }) must
|