@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.
@@ -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} ['${mi.key$}'] = setup.idmap['${mi.key$}']
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(` const ${matchvar}: any = {}
522
- ${matchvar}.id = ${srcdatavar}.id
523
- const ${datavar} = (await ${entvar}.load(${matchvar})).data()
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 ${matchvar}: any = {}
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
- await ${entvar}.remove(${matchvar})
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,
@@ -3,7 +3,7 @@
3
3
  "package": 1
4
4
  },
5
5
  "name": "@voxgig/sdkgen",
6
- "version": "4.34.3",
6
+ "version": "4.34.4",
7
7
  "provides": {
8
8
  "target": [
9
9
  "c",
@@ -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