@burdenoff/be-sdk 2026.1127.2 → 2026.1128.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.
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "../rolldown-runtime-ad2WFvuA.js";
2
2
  import { a as logger } from "../logger-B6rCpb7D.js";
3
- import { c as ACTOR_ORIGIN_HEADER, d as ASSISTANT_SESSION_ID_HEADER, f as parseAssistantSessionHeaders, l as AI_ASSISTANT_ACTOR_ORIGIN, m as toAssistantSessionAttribution, o as trackOperation, p as readAssistantSessionAttribution, u as ASSISTANT_CORRELATION_ID_HEADER } from "../stub-BUnfMiAS.js";
4
- import { h as withWorkspaceContext, m as setWorkspaceContext } from "../workspace-extension-COrC0dYi.js";
3
+ import { c as ACTOR_ORIGIN_HEADER, d as ASSISTANT_SESSION_ID_HEADER, f as parseAssistantSessionHeaders, l as AI_ASSISTANT_ACTOR_ORIGIN, m as toAssistantSessionAttribution, o as trackOperation, p as readAssistantSessionAttribution, u as ASSISTANT_CORRELATION_ID_HEADER } from "../stub-DZ332ZHG.js";
4
+ import { w as withWorkspaceContext, x as setWorkspaceContext } from "../workspace-extension-ByopOwtK.js";
5
5
  import { ContextManager } from "../context/index.js";
6
6
  import { l as I18n } from "../i18n-BBMYFd0P.js";
7
7
  import { l as getMetricsRegistry } from "../metrics-collector-DXQrMUle.js";
@@ -561,7 +561,12 @@ function string(value) {
561
561
  function id(value) {
562
562
  return record(value) ? string(value["id"]) : void 0;
563
563
  }
564
- function executionContext(value) {
564
+ /**
565
+ * The workspace context for a request, read from the verified server context
566
+ * (`buildContext`'s result or a Yoga `contextValue`). Unknown shapes yield an
567
+ * empty context: no workspace, so the extension's strict mode applies.
568
+ */
569
+ function workspaceContextFromServerContext(value) {
565
570
  if (!record(value)) return {};
566
571
  const assistantSession = readAssistantSessionAttribution(value["assistantSession"]);
567
572
  return {
@@ -594,7 +599,7 @@ function createWorkspaceExecutionContextPlugin() {
594
599
  return {
595
600
  onExecute({ executeFn, setExecuteFn }) {
596
601
  setExecuteFn((args) => {
597
- const scope = executionContext(args.contextValue);
602
+ const scope = workspaceContextFromServerContext(args.contextValue);
598
603
  return withWorkspaceContext(scope, async () => {
599
604
  const result = await executeFn(args);
600
605
  return Symbol.asyncIterator in result ? scopedIterable(result, scope) : result;
@@ -603,7 +608,7 @@ function createWorkspaceExecutionContextPlugin() {
603
608
  },
604
609
  onSubscribe({ subscribeFn, setSubscribeFn }) {
605
610
  setSubscribeFn((args) => {
606
- const scope = executionContext(args.contextValue);
611
+ const scope = workspaceContextFromServerContext(args.contextValue);
607
612
  return withWorkspaceContext(scope, async () => {
608
613
  const result = await subscribeFn(args);
609
614
  return Symbol.asyncIterator in result ? scopedIterable(result, scope) : result;
@@ -612,6 +617,15 @@ function createWorkspaceExecutionContextPlugin() {
612
617
  }
613
618
  };
614
619
  }
620
+ /**
621
+ * Run a REST or raw-body endpoint handler inside its own request's verified
622
+ * workspace context. `buildContext` binds the context with `enterWith`, which
623
+ * does not reach the caller that awaited it, so without this the handler would
624
+ * run with no bound context.
625
+ */
626
+ function runWithServerWorkspaceContext(serverContext, fn) {
627
+ return withWorkspaceContext(workspaceContextFromServerContext(serverContext), fn);
628
+ }
615
629
 
616
630
  // src/server/security.ts
617
631
  const LOCALHOST_ORIGINS = [
@@ -1576,7 +1590,7 @@ async function createServer(definition) {
1576
1590
  const endpointMaxBodyBytes = resolveBodyLimitBytes(rawBodyEndpoint.maxBodyBytes, defaultRawBodyMaxBytes);
1577
1591
  const rawBody = await readBoundedRawBody(request, endpointMaxBodyBytes);
1578
1592
  const context = await buildContext(request);
1579
- const result = await rawBodyEndpoint.handler(request, context, rawBody);
1593
+ const result = await runWithServerWorkspaceContext(context, async () => rawBodyEndpoint.handler(request, context, rawBody));
1580
1594
  if (result instanceof Response) {
1581
1595
  const headers = new Headers(result.headers);
1582
1596
  for (const [key, value] of Object.entries(corsHeaders)) headers.set(key, value);
@@ -1713,7 +1727,7 @@ async function createServer(definition) {
1713
1727
  return { error: "Forbidden" };
1714
1728
  }
1715
1729
  const { organizationId, workspaceId } = query;
1716
- return moduleGraph.exportAll(organizationId, workspaceId);
1730
+ return runWithServerWorkspaceContext(context, () => moduleGraph.exportAll(organizationId, workspaceId));
1717
1731
  });
1718
1732
  app.get("/api/graph/entities", async ({ query, request, set }) => {
1719
1733
  const context = await buildContext(request);
@@ -1723,7 +1737,7 @@ async function createServer(definition) {
1723
1737
  }
1724
1738
  const { organizationId, workspaceId, types } = query;
1725
1739
  const entityTypes = types?.split(",").map((t) => t.trim());
1726
- return moduleGraph.exportEntities(organizationId, workspaceId, entityTypes);
1740
+ return runWithServerWorkspaceContext(context, () => moduleGraph.exportEntities(organizationId, workspaceId, entityTypes));
1727
1741
  });
1728
1742
  app.get("/api/graph/relationships", async ({ query, request, set }) => {
1729
1743
  const context = await buildContext(request);
@@ -1732,7 +1746,7 @@ async function createServer(definition) {
1732
1746
  return { error: "Forbidden" };
1733
1747
  }
1734
1748
  const { organizationId, workspaceId } = query;
1735
- return moduleGraph.exportRelationships(organizationId, workspaceId);
1749
+ return runWithServerWorkspaceContext(context, () => moduleGraph.exportRelationships(organizationId, workspaceId));
1736
1750
  });
1737
1751
  }
1738
1752
  if (restEndpoints && restEndpoints.length > 0) for (const endpoint of restEndpoints) {
@@ -1743,7 +1757,7 @@ async function createServer(definition) {
1743
1757
  const handler = async ({ request }) => {
1744
1758
  try {
1745
1759
  const context = await buildContext(request);
1746
- return await endpoint.handler(request, context);
1760
+ return await runWithServerWorkspaceContext(context, async () => endpoint.handler(request, context));
1747
1761
  } catch (error) {
1748
1762
  logger.error(`[Server] REST endpoint error (${endpoint.path}):`, error);
1749
1763
  return createHttpErrorResponse(error, {