mikser-io 9.40.0 → 9.40.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/render.js +17 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mikser-io",
3
- "version": "9.40.0",
3
+ "version": "9.40.1",
4
4
  "description": "<p align=\"center\"> <img src=\"mikser-lockup-stacked.svg\" alt=\"mikser\" width=\"198\" /> </p>",
5
5
  "main": "index.js",
6
6
  "exports": {
package/src/render.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { readFileSync, existsSync } from 'node:fs'
2
2
  import { readFile, unlink } from 'node:fs/promises'
3
3
  import { createRequire } from 'node:module'
4
- import { createTrack, recordReads, serializeTrack } from './track.js'
4
+ import { createTrack, recordReads, serializeTrack, observeConsumed } from './track.js'
5
5
  import { randomUUID } from 'node:crypto'
6
6
  import path from 'node:path'
7
7
  import _ from 'lodash'
@@ -110,7 +110,8 @@ export default async ({ entity, options, config, context, state, logger, port, t
110
110
  // so the worker makes its own track here and returns its CONTENTS with the
111
111
  // result, where the engine folds them into the real one.
112
112
  const ownTrack = !track
113
- track = track ?? createTrack({ meta: options?.metaReads !== false })
113
+ track = track ?? createTrack({ meta: options?.metaReads !== false,
114
+ consumed: options?.metaReads !== false })
114
115
 
115
116
  logger = logger || {
116
117
  info(...args) {
@@ -259,7 +260,20 @@ export default async ({ entity, options, config, context, state, logger, port, t
259
260
  : typeof result.id === 'string' ? [result.id]
260
261
  : Object.values(result).map(e => e?.id).filter(Boolean)
261
262
  track?.lookup?.(href, ids)
262
- return result
263
+ // The entity goes to the TEMPLATE, which then reads fields off it.
264
+ // Recording those against the entity they belong to is what gives a
265
+ // document that never renders a contract — and this is the second
266
+ // way one reaches a render, alongside a sidecar's findEntity.
267
+ //
268
+ // `lookupUrl` needs no equivalent: it hands back a URL string, so
269
+ // nothing is ever read off an entity by the caller.
270
+ if (!result) return result
271
+ if (typeof result.id === 'string') return observeConsumed(result, track)
272
+ const observedByLang = {}
273
+ for (const [lang, row] of Object.entries(result)) {
274
+ observedByLang[lang] = row?.id ? observeConsumed(row, track) : row
275
+ }
276
+ return observedByLang
263
277
  },
264
278
  // Resolve a served-entity reference to its deployed URL, absolute
265
279
  // when runtime.options.url is set (ADR-0011).