@volter/world-core 2.0.3 → 2.0.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.
@@ -614,7 +614,10 @@ async function contextFor(m, call, scope) {
614
614
  // a handler reading the body itself sees the adopted id too (the boundary's one resolution, below)
615
615
  if (body && typeof body === 'object' && !Array.isArray(body))
616
616
  body = adoptedInCall(m.service, body, root);
617
- const params = await boundaryParams(m, call, root);
617
+ // every read of the body is of a copy, so the handler's own `call.request` and the core's answer (`core()`) each
618
+ // still find it unread, whichever of them reads it first
619
+ const pristine = call.request.clone();
620
+ const params = await boundaryParams(m, { ...call, request: call.request.clone() }, root);
618
621
  const paths = expandPaths(m, params);
619
622
  return {
620
623
  call,
@@ -677,7 +680,7 @@ async function contextFor(m, call, scope) {
677
680
  sse: (events) => sse(m, events, call.operation.id),
678
681
  expand: (resource, body) => (paths.length ? expand(m, resource, body, paths, root) : body),
679
682
  at: (when) => contextFor(m, { ...call, request: new Request(call.request.url) }, { ...scope, clock: () => when }),
680
- core: async () => { const out = await serveCore(m, call, { ...scope, clock: () => at }); return 'served' in out ? out.served : undefined; },
683
+ core: async () => { const out = await serveCore(m, { ...call, request: pristine.clone() }, { ...scope, clock: () => at }); return 'served' in out ? out.served : undefined; },
681
684
  own: (row) => ownFields(row),
682
685
  };
683
686
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/world-core",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "The kernel of Volter World: one log per twin, branches as pointers, checkpoints, the fold that keeps a twin current, the head that performs a write against the vendor, references, and the git plane. A twin package builds on it; the runtime serves it.",
5
5
  "keywords": [
6
6
  "twin",
@@ -851,7 +851,10 @@ async function contextFor(m: DerivedManifest, call: DerivedCall, scope: CoreScop
851
851
  try { body = text ? JSON.parse(text) : undefined; } catch { body = text; }
852
852
  // a handler reading the body itself sees the adopted id too (the boundary's one resolution, below)
853
853
  if (body && typeof body === 'object' && !Array.isArray(body)) body = adoptedInCall(m.service, body as Record<string, unknown>, root);
854
- const params = await boundaryParams(m, call, root);
854
+ // every read of the body is of a copy, so the handler's own `call.request` and the core's answer (`core()`) each
855
+ // still find it unread, whichever of them reads it first
856
+ const pristine = call.request.clone();
857
+ const params = await boundaryParams(m, { ...call, request: call.request.clone() }, root);
855
858
  const paths = expandPaths(m, params);
856
859
  return {
857
860
  call,
@@ -913,7 +916,7 @@ async function contextFor(m: DerivedManifest, call: DerivedCall, scope: CoreScop
913
916
  sse: (events) => sse(m, events, call.operation.id),
914
917
  expand: (resource, body) => (paths.length ? expand(m, resource, body, paths, root) : body),
915
918
  at: (when) => contextFor(m, { ...call, request: new Request(call.request.url) }, { ...scope, clock: () => when }),
916
- core: async () => { const out = await serveCore(m, call, { ...scope, clock: () => at }); return 'served' in out ? out.served : undefined; },
919
+ core: async () => { const out = await serveCore(m, { ...call, request: pristine.clone() }, { ...scope, clock: () => at }); return 'served' in out ? out.served : undefined; },
917
920
  own: (row) => ownFields(row as unknown as TwinResource),
918
921
  };
919
922
  }