mikser-io 11.2.0 → 11.2.1
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/package.json +1 -1
- package/src/render.js +27 -1
package/package.json
CHANGED
package/src/render.js
CHANGED
|
@@ -544,6 +544,25 @@ export function useRenderer(runtime, { defaultTimeout = 30_000 } = {}) {
|
|
|
544
544
|
* @returns {Promise<{output, entity}>}
|
|
545
545
|
*/
|
|
546
546
|
async function render(entity, { timeout = defaultTimeout, catalog = true, save = true } = {}) {
|
|
547
|
+
// Was this row already in the catalog BEFORE the render? `catalog:
|
|
548
|
+
// false` means "do not leave a row behind", and that is only the
|
|
549
|
+
// render's to decide for a row the render created. Asked here, before
|
|
550
|
+
// the render puts one there.
|
|
551
|
+
//
|
|
552
|
+
// Without it, `catalog: false` deleted whatever it was handed: a
|
|
553
|
+
// preview of an EXISTING entity pruned the real row, so the entity
|
|
554
|
+
// vanished from the site while its file sat on disk — no change set,
|
|
555
|
+
// no cycle, and the removal logged only at debug. It cost a day to
|
|
556
|
+
// find, in a form that rendered once and then answered "Entity not
|
|
557
|
+
// found".
|
|
558
|
+
// Imported HERE, not at the top: catalog.js reaches back into this
|
|
559
|
+
// module, and a static import makes that cycle load-bearing at
|
|
560
|
+
// module-evaluation time — it surfaced as "Cannot access 'schemas'
|
|
561
|
+
// before initialization" in three unrelated test files.
|
|
562
|
+
const preexisting = catalog === false && entity?.id
|
|
563
|
+
? Boolean(await (await import('./catalog.js')).findById(entity.id))
|
|
564
|
+
: false
|
|
565
|
+
|
|
547
566
|
const result = await new Promise((resolve, reject) => {
|
|
548
567
|
const correlationId = randomUUID()
|
|
549
568
|
// Engine-set fields live under entity.options. The caller's
|
|
@@ -585,7 +604,14 @@ export function useRenderer(runtime, { defaultTimeout = 30_000 } = {}) {
|
|
|
585
604
|
// and wrong for one that did. `catalog: false, save: true`
|
|
586
605
|
// therefore keeps its row, and says so rather than dropping
|
|
587
606
|
// the output on the floor.
|
|
588
|
-
if (
|
|
607
|
+
if (preexisting) {
|
|
608
|
+
// Someone else's row. It was here before this render and is
|
|
609
|
+
// not this render's to remove.
|
|
610
|
+
useLogger()?.debug(
|
|
611
|
+
'render: catalog:false ignored for %s — the entity was already in the catalog',
|
|
612
|
+
result.entity.id,
|
|
613
|
+
)
|
|
614
|
+
} else if (save === false) {
|
|
589
615
|
await runtime.delete(result.entity)
|
|
590
616
|
} else {
|
|
591
617
|
useLogger()?.warn(
|