theokit 0.67.0 → 0.69.0
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/README.md +21 -0
- package/dist/{actions-virtual-module-YIWQTI6Q.js → actions-virtual-module-DH3N34I6.js} +6 -6
- package/dist/{actions-virtual-module-WCHXKH6R.js → actions-virtual-module-OMIFGXK6.js} +4 -4
- package/dist/adapters/agent-mount.d.ts +190 -2
- package/dist/adapters/agent-mount.js +18 -3
- package/dist/adapters/security-headers.d.ts +17 -1
- package/dist/adapters/security-headers.js +7 -0
- package/dist/adapters/security-headers.js.map +1 -1
- package/dist/{agent-C7F5O5V4.js → agent-7RPGAKTY.js} +3 -3
- package/dist/{app-typed-client-2ZEGNFJP.js → app-typed-client-C4LRUSIS.js} +6 -6
- package/dist/{app-typed-client-CUM2GZ5Y.js → app-typed-client-R6OUJZEE.js} +4 -4
- package/dist/assets-map-BMQASQHW.js +70 -0
- package/dist/assets-map-BMQASQHW.js.map +1 -0
- package/dist/assets-map-CV2YZ3MY.js +69 -0
- package/dist/assets-map-CV2YZ3MY.js.map +1 -0
- package/dist/{aws-lambda-R76PWR27.js → aws-lambda-OCJM5YGB.js} +35 -23
- package/dist/aws-lambda-OCJM5YGB.js.map +1 -0
- package/dist/{build-UNBI6VKC.js → build-CGFKWZ73.js} +13 -8
- package/dist/build-CGFKWZ73.js.map +1 -0
- package/dist/{bun-NPBIAWSU.js → bun-KRUAWYRW.js} +51 -39
- package/dist/bun-KRUAWYRW.js.map +1 -0
- package/dist/{chunk-GQNBZDYK.js → chunk-2FHNJ7LI.js} +1 -1
- package/dist/{chunk-GQNBZDYK.js.map → chunk-2FHNJ7LI.js.map} +1 -1
- package/dist/chunk-3T5XLDOH.js +807 -0
- package/dist/chunk-3T5XLDOH.js.map +1 -0
- package/dist/{chunk-WAYUHS54.js → chunk-425FJKKO.js} +5 -3
- package/dist/chunk-425FJKKO.js.map +1 -0
- package/dist/chunk-46FM5AFZ.js +44 -0
- package/dist/chunk-46FM5AFZ.js.map +1 -0
- package/dist/{chunk-ASBXR57P.js → chunk-4WB62S22.js} +7 -4
- package/dist/{chunk-ASBXR57P.js.map → chunk-4WB62S22.js.map} +1 -1
- package/dist/chunk-BDPD5HEO.js +554 -0
- package/dist/chunk-BDPD5HEO.js.map +1 -0
- package/dist/{chunk-UETVDZBE.js → chunk-BINRCILF.js} +4 -1
- package/dist/{chunk-UETVDZBE.js.map → chunk-BINRCILF.js.map} +1 -1
- package/dist/{chunk-EQCSUC65.js → chunk-BTDTHXUI.js} +2 -2
- package/dist/chunk-FFGP2LGQ.js +465 -0
- package/dist/chunk-FFGP2LGQ.js.map +1 -0
- package/dist/{chunk-PRZCPSUE.js → chunk-I2H6KRCQ.js} +29 -14
- package/dist/chunk-I2H6KRCQ.js.map +1 -0
- package/dist/{chunk-ENRT6DAU.js → chunk-IDWN2OSG.js} +15 -2
- package/dist/chunk-IDWN2OSG.js.map +1 -0
- package/dist/{chunk-GAJOZJWD.js → chunk-MOGTMGGA.js} +5 -2
- package/dist/chunk-MOGTMGGA.js.map +1 -0
- package/dist/{chunk-5VLP3GQ2.js → chunk-MS4A7N77.js} +1 -1
- package/dist/chunk-MS4A7N77.js.map +1 -0
- package/dist/{chunk-YNK7DW5V.js → chunk-QVXMAHZC.js} +55 -551
- package/dist/chunk-QVXMAHZC.js.map +1 -0
- package/dist/{chunk-B4Z7KIIU.js → chunk-SJ4AW54X.js} +45 -4
- package/dist/chunk-SJ4AW54X.js.map +1 -0
- package/dist/{chunk-5AGNZXHJ.js → chunk-SRJBH5E5.js} +16 -679
- package/dist/chunk-SRJBH5E5.js.map +1 -0
- package/dist/{chunk-GQIATJEG.js → chunk-T2LDLVVV.js} +28 -3
- package/dist/chunk-T2LDLVVV.js.map +1 -0
- package/dist/{chunk-UKMOQWUC.js → chunk-TJPENLGQ.js} +3 -3
- package/dist/chunk-V5SSTT3C.js +52 -0
- package/dist/chunk-V5SSTT3C.js.map +1 -0
- package/dist/chunk-XG6SQUEP.js +27 -0
- package/dist/chunk-XG6SQUEP.js.map +1 -0
- package/dist/cli/index.js +6 -6
- package/dist/client/index.d.ts +20 -0
- package/dist/client/index.js.map +1 -1
- package/dist/{cloudflare-2WVDBHCC.js → cloudflare-GK4VD3EU.js} +71 -21
- package/dist/cloudflare-GK4VD3EU.js.map +1 -0
- package/dist/{route-config-B7FaTSby.d.ts → define-middleware-BOHpPOBs.d.ts} +39 -1
- package/dist/{deno-deploy-BXOQ45LD.js → deno-deploy-WMNXRVGL.js} +37 -36
- package/dist/deno-deploy-WMNXRVGL.js.map +1 -0
- package/dist/{dev-GLUZNBNH.js → dev-72ISY3BP.js} +7 -7
- package/dist/{index-BdIaxp0c.d.ts → index-DZ_G5iY2.d.ts} +76 -5
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/{internal-api-3JIWUI3V.js → internal-api-CEZSXGRB.js} +4 -4
- package/dist/{internal-api-OK7FS2ZF.js → internal-api-XRIBUACB.js} +8 -7
- package/dist/match-DaKsL73w.d.ts +28 -0
- package/dist/{mcp-IPDFRK4S.js → mcp-S2AOB3RE.js} +3 -3
- package/dist/{match-Dw4CNXJH.d.ts → module-loader-DCip7NoL.d.ts} +1 -28
- package/dist/{netlify-LPJAPMQ2.js → netlify-VOL54SC7.js} +23 -20
- package/dist/netlify-VOL54SC7.js.map +1 -0
- package/dist/{observability-bootstrap-H4NSILXD.js → observability-bootstrap-YQKMEYW7.js} +2 -2
- package/dist/{preview-5ONGHDKY.js → preview-WA4HORUQ.js} +3 -3
- package/dist/registry-DDBXDHJ2.js +23 -0
- package/dist/server/cost/index.d.ts +14 -1
- package/dist/server/cost/index.js +1 -1
- package/dist/server/define/index.d.ts +2 -28
- package/dist/server/define/index.js +2 -3
- package/dist/server/http/index.d.ts +4 -3
- package/dist/server/http/index.js +13 -8
- package/dist/server/index.d.ts +6 -4
- package/dist/server/index.js +15 -10
- package/dist/server/index.js.map +1 -1
- package/dist/server/scan/index.d.ts +3 -2
- package/dist/{server-boundary-6PYWFYEL.js → server-boundary-S3G4CSNK.js} +4 -4
- package/dist/{server-boundary-CNYNVFT5.js → server-boundary-YN5HAICY.js} +6 -6
- package/dist/{start-UYBVPTSV.js → start-ZTMQLNJI.js} +39 -15
- package/dist/start-ZTMQLNJI.js.map +1 -0
- package/dist/{static-SVDWIOXJ.js → static-7OJNB7D2.js} +4 -4
- package/dist/{vercel-YUZADKGV.js → vercel-LZTDSDJF.js} +42 -28
- package/dist/vercel-LZTDSDJF.js.map +1 -0
- package/dist/vite-plugin/index.js +7 -6
- package/dist/{vite-plugin-ILWLTOKK.js → vite-plugin-Z7AJG3M2.js} +7 -7
- package/package.json +4 -4
- package/dist/aws-lambda-R76PWR27.js.map +0 -1
- package/dist/build-UNBI6VKC.js.map +0 -1
- package/dist/bun-NPBIAWSU.js.map +0 -1
- package/dist/chunk-5AGNZXHJ.js.map +0 -1
- package/dist/chunk-5VLP3GQ2.js.map +0 -1
- package/dist/chunk-6B3CMPE4.js +0 -192
- package/dist/chunk-6B3CMPE4.js.map +0 -1
- package/dist/chunk-B4Z7KIIU.js.map +0 -1
- package/dist/chunk-D4VP2QPR.js +0 -16
- package/dist/chunk-D4VP2QPR.js.map +0 -1
- package/dist/chunk-ENRT6DAU.js.map +0 -1
- package/dist/chunk-GAJOZJWD.js.map +0 -1
- package/dist/chunk-GQIATJEG.js.map +0 -1
- package/dist/chunk-O55RLSGG.js +0 -127
- package/dist/chunk-O55RLSGG.js.map +0 -1
- package/dist/chunk-PRZCPSUE.js.map +0 -1
- package/dist/chunk-WAYUHS54.js.map +0 -1
- package/dist/chunk-YNK7DW5V.js.map +0 -1
- package/dist/cloudflare-2WVDBHCC.js.map +0 -1
- package/dist/deno-deploy-BXOQ45LD.js.map +0 -1
- package/dist/netlify-LPJAPMQ2.js.map +0 -1
- package/dist/registry-E5XEUKG6.js +0 -23
- package/dist/start-UYBVPTSV.js.map +0 -1
- package/dist/vercel-YUZADKGV.js.map +0 -1
- /package/dist/{actions-virtual-module-YIWQTI6Q.js.map → actions-virtual-module-DH3N34I6.js.map} +0 -0
- /package/dist/{actions-virtual-module-WCHXKH6R.js.map → actions-virtual-module-OMIFGXK6.js.map} +0 -0
- /package/dist/{agent-C7F5O5V4.js.map → agent-7RPGAKTY.js.map} +0 -0
- /package/dist/{app-typed-client-2ZEGNFJP.js.map → app-typed-client-C4LRUSIS.js.map} +0 -0
- /package/dist/{app-typed-client-CUM2GZ5Y.js.map → app-typed-client-R6OUJZEE.js.map} +0 -0
- /package/dist/{chunk-EQCSUC65.js.map → chunk-BTDTHXUI.js.map} +0 -0
- /package/dist/{chunk-UKMOQWUC.js.map → chunk-TJPENLGQ.js.map} +0 -0
- /package/dist/{dev-GLUZNBNH.js.map → dev-72ISY3BP.js.map} +0 -0
- /package/dist/{internal-api-3JIWUI3V.js.map → internal-api-CEZSXGRB.js.map} +0 -0
- /package/dist/{internal-api-OK7FS2ZF.js.map → internal-api-XRIBUACB.js.map} +0 -0
- /package/dist/{mcp-IPDFRK4S.js.map → mcp-S2AOB3RE.js.map} +0 -0
- /package/dist/{observability-bootstrap-H4NSILXD.js.map → observability-bootstrap-YQKMEYW7.js.map} +0 -0
- /package/dist/{preview-5ONGHDKY.js.map → preview-WA4HORUQ.js.map} +0 -0
- /package/dist/{registry-E5XEUKG6.js.map → registry-DDBXDHJ2.js.map} +0 -0
- /package/dist/{server-boundary-6PYWFYEL.js.map → server-boundary-S3G4CSNK.js.map} +0 -0
- /package/dist/{server-boundary-CNYNVFT5.js.map → server-boundary-YN5HAICY.js.map} +0 -0
- /package/dist/{static-SVDWIOXJ.js.map → static-7OJNB7D2.js.map} +0 -0
- /package/dist/{vite-plugin-ILWLTOKK.js.map → vite-plugin-Z7AJG3M2.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapters/cloudflare.ts"],"sourcesContent":["/* eslint-disable security/detect-non-literal-fs-filename --\n * Cloudflare deploy adapter. All write paths are under `cwd/.theokit/cloudflare/`\n * and `cwd/wrangler.toml`. Build-time tool — no HTTP input.\n */\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\n\nimport type { TheoConfig } from '../config/schema.js'\nimport { findRootDiv } from '../core/contracts/find-root-div.js'\nimport { parseAssetsMap } from '../core/contracts/module-preloads.js'\nimport type { SecurityHeadersConfig } from '../core/contracts/security-headers.js'\nimport { assertServicesUnsupported, readManifest } from '../services/index.js'\n\nimport { deployedAgentsFragment, type DeployedAgent } from './deployed-agents.js'\nimport { deployedCorsFragment, type DeployedCorsOptions } from './deployed-cors.js'\nimport { deployedCsrfFragment, type DeployedCsrfOptions } from './deployed-csrf.js'\nimport { planDeployedPlugins } from './deployed-plugins-module.js'\nimport {\n deployedRuntimeConfigFragment,\n serverDirLiteral,\n type DeployedRuntimeConfigOptions,\n type DeployedServerDirOptions,\n} from './deployed-runtime-config.js'\nimport { deployedTraceFragment } from './deployed-trace.js'\nimport { nodeAdapter } from './node.js'\nimport { describeDeployedSecurityHeaders, securityHeadersDeclarations } from './security-headers.js'\nimport type { AdapterBuildContext, DeployAdapter } from './types.js'\n\n/**\n * T2.1 — Cloudflare adapter rewritten to consume `theokit/adapters/web-shim`\n * instead of emitting an inline plain-object Request/Response shim. Reduces\n * template from ~50 lines to ~25 and centralizes maintenance.\n */\n\n/**\n * The built `index.html` split into the part before `<div id=\"root\">` and the\n * part after it.\n *\n * Refuses by name when streaming is on and the template is missing, rather than\n * emitting a worker that serves a headless document. A build that cannot produce\n * a correct artifact should say so at build time; the alternative is a deploy\n * that looks successful and serves pages with no stylesheet.\n */\n/**\n * @internal Exported for tests only. Nothing re-exports this module, so this does not reach the\n * published surface — `findRootDiv`, exported for the same reason, appears 0 times in `dist/`.\n */\nexport function readDocumentShell(\n cwd: string,\n streaming: boolean,\n): { htmlHead?: string; htmlTail?: string } {\n if (!streaming) return {}\n\n const indexPath = resolve(cwd, '.theokit/client/index.html')\n if (!existsSync(indexPath)) {\n throw new Error(\n `[adapter-cloudflare] ssrStreaming is on but ${indexPath} does not exist, so the worker ` +\n `would serve a document with no <head> and no client entry. Run the client build first, ` +\n `or set ssrStreaming: false in theo.config.ts.`,\n )\n }\n\n const indexHtml = readFileSync(indexPath, 'utf-8')\n const rootDiv = findRootDiv(indexHtml)\n if (rootDiv === undefined) {\n throw new Error(\n `[adapter-cloudflare] ${indexPath} has no <div id=\"root\">, so the streamed document has ` +\n `nowhere to put the app. Add one, or set ssrStreaming: false in theo.config.ts.`,\n )\n }\n\n return {\n htmlHead: indexHtml.slice(0, rootDiv.insertAt),\n htmlTail: indexHtml.slice(rootDiv.insertAt),\n }\n}\n\n/**\n * The routes, turned into source: static imports, a module map and a literal table (#369).\n *\n * Extracted so the worker renderer stays inside its length budget, and because this is the whole of\n * what changed about how a Worker finds a route — it reads as one idea rather than as three loops\n * inside a hundred lines of template.\n *\n * `../../` because the worker is written to `.theokit/cloudflare/worker.mjs` and `filePath` is\n * relative to the project root. The imports are static so Wrangler's bundler follows them:\n * `wrangler.toml` uploads `.theokit/client` and has never uploaded `server/`, so a module not\n * bundled INTO the worker is not on the platform at all.\n */\nfunction renderBakedRoutes(\n routes: readonly { filePath: string; routePath: string; methods?: readonly string[] }[],\n): { routeImports: string[]; routeModuleEntries: string[]; routeTableEntries: string[] } {\n const routeVar = (index: number): string => `__theoRoute${String(index)}`\n return {\n routeImports: routes.map(\n (route, index) => `import * as ${routeVar(index)} from '../../${route.filePath}'`,\n ),\n routeModuleEntries: routes.map(\n (route, index) => ` ${JSON.stringify(route.filePath)}: ${routeVar(index)},`,\n ),\n routeTableEntries: routes.map(\n (route) =>\n ` { filePath: ${JSON.stringify(route.filePath)}, routePath: ${JSON.stringify(route.routePath)}, ` +\n `methods: ${JSON.stringify([...(route.methods ?? [])])}, ` +\n `...compilePattern(${JSON.stringify(route.routePath)}) },`,\n ),\n }\n}\n\n/**\n * The route-resolution runtime the Worker gets instead of a directory scan (#369).\n *\n * A module map, the literal table, and a loader that refuses anything the build did not bake.\n * Emitted as its own block because it replaces one idea — \"find the routes\" — wholesale.\n */\nfunction routeRuntimeLines(moduleEntries: string[], tableEntries: string[]): string[] {\n return [\n `// #369 — the routes are baked at build time. The Worker used to reach for`,\n `// \\`scanServerRoutes\\` on the server directory — a readdirSync, in a runtime with no`,\n `// filesystem. The pattern is recompiled here from the same routePath the scanner`,\n `// used, so one function decides precedence on every target.`,\n `const ROUTE_MODULES = {`,\n ...moduleEntries,\n `}`,\n ``,\n `const routes = [`,\n ...tableEntries,\n `]`,\n ``,\n `// The executor asks for a module by the path the table names. Anything else was`,\n `// never bundled, and saying so beats returning undefined and failing later on a`,\n `// property access far from the cause.`,\n `async function loadModule(path) {`,\n ` const mod = ROUTE_MODULES[path]`,\n ` if (mod === undefined) {`,\n // No backticks in this message: it is emitted INTO a template literal, and a stray one closes\n // it. That is how #344 shipped a SyntaxError, and the emitted-entry parse gate caught this one\n // before it left the branch.\n \" throw new Error(`Route module '\" +\n '${path}' +\n \"' was not bundled into this Worker. \" +\n 'A Worker has no filesystem, so every route is imported at build time. ' +\n 'Re-run: theokit build --target cloudflare`)',\n ` }`,\n ` return mod`,\n `}`,\n ``,\n ]\n}\n\n/**\n * Read the map `theokit build` emitted, for baking into the worker (B-035).\n *\n * Returns `undefined` — never throws — for an absent or malformed file. A deploy that failed\n * because an optimisation was missing would turn a lost round trip into a broken build, and the\n * worker is correct without it.\n */\nexport function readAssetsMapForBake(path: string): Record<string, string[]> | undefined {\n try {\n return parseAssetsMap(readFileSync(path, 'utf8'))\n } catch {\n return undefined\n }\n}\n\n/**\n * The baked route-to-chunks map, as worker source (B-035).\n *\n * A literal and not a read, for the same reason the document shell is: a Worker has no filesystem\n * at request time. Emitted only when the build produced a map; otherwise the worker carries\n * nothing about preloads and behaves exactly as before.\n *\n * **It emits the DATA and no longer the code.** An earlier revision emitted a hand-written copy of\n * `injectModulePreloads`, justified by a claim that the worker could not import it. That claim was\n * false — `theokit/server` re-exports from `core/contracts/` and the generated worker already\n * imports that subpath — and the copy drifted within a day: a fix for proxy-form request targets\n * landed in the original and not in the duplicate. The worker now imports the real function, which\n * is the shape `adapters/security-headers.ts` established one directory over for exactly this\n * build-half/runtime-half pair.\n */\n/**\n * Whether this worker can preload at all (B-035).\n *\n * ONE predicate, read by the bake, the import and the call. Two conditions for one decision is\n * how the import came to be emitted for a worker that had no map to give it — found at review, in\n * the same change where a copy and its original had already drifted apart.\n *\n * Streaming is required because the other branch serves the document from `env.ASSETS` as a\n * static file and can inject nothing into it.\n */\nfunction preloadsApplyTo(opts: {\n ssrStreaming?: boolean\n assetsMap?: Record<string, string[]>\n}): boolean {\n return opts.ssrStreaming === true && opts.assetsMap !== undefined\n}\n\nfunction renderPreloadSupport(assetsMap: Record<string, string[]> | undefined): string {\n if (assetsMap === undefined) return ''\n return `const __THEO_ASSETS_MAP = ${JSON.stringify(assetsMap)}`\n}\n\n/**\n * The branch that answers a non-API request: streamed SSR, or the static asset the Worker\n * platform serves. Extracted at review — it is the one decision in this emitter with two whole\n * shapes behind it, and keeping it inline pushed the caller past its line budget.\n */\nfunction renderNonApiBranch(\n opts: NonNullable<Parameters<typeof renderCloudflareWorkerEntry>[0]>,\n preloadsApply: boolean,\n): string {\n return opts.ssrStreaming\n ? [\n ` // T2.3 — streaming SSR for non-API routes`,\n ` // The same primitive \\`theokit start\\` uses, not a second one:`,\n ` // 16 bytes of Web Crypto entropy, base64.`,\n ` const nonce = generateNonce()`,\n ` return withSecurityHeaders(`,\n ` await renderStreamingWeb(request, {`,\n !preloadsApply\n ? ` htmlHead: ${JSON.stringify(opts.htmlHead ?? '')},`\n : ` htmlHead: injectModulePreloads(${JSON.stringify(opts.htmlHead ?? '')}, __THEO_ASSETS_MAP, new URL(request.url).pathname),`,\n ` htmlTail: ${JSON.stringify(opts.htmlTail ?? '')},`,\n ` nonce,`,\n ` }),`,\n ` buildSecurityHeaders(SECURITY_HEADERS_CONFIG, { production: true }, { nonce }),`,\n ` )`,\n ].join('\\n')\n : [\n ` // #412 — the document, served by the worker so it carries the same baseline every`,\n ` // API response carries. It used to return 404 here while wrangler.toml declared a`,\n ` // \\`[site]\\` bucket nothing read, so the page was missing rather than unprotected.`,\n ` const assets = env?.ASSETS`,\n ` // A wrangler.toml that predates this binding has no ASSETS. Reading .fetch off`,\n ` // undefined would turn every page request into a 500; 404 is what this target`,\n ` // answered before, which is the honest fallback rather than a new failure.`,\n ` if (assets === undefined) return notFoundResponse()`,\n ` return withSecurityHeaders(await assets.fetch(request), SECURITY_HEADERS)`,\n ].join('\\n')\n}\n\nexport function renderCloudflareWorkerEntry(\n opts: {\n ssrStreaming?: boolean\n htmlHead?: string\n htmlTail?: string\n /**\n * B-035 — the route-to-chunks map, baked as a literal for the same reason the shell above\n * is: a Worker has no filesystem at request time. Absent when the build produced no map,\n * and then nothing about preloads is emitted at all.\n */\n assetsMap?: Record<string, string[]>\n securityHeaders?: SecurityHeadersConfig\n /**\n * The server routes, scanned on the BUILD machine (#369).\n *\n * A Worker has no filesystem, so the worker used to call `scanServerRoutes` — a `readdirSync` —\n * against a directory that does not exist there, and load each module through `import()` of a\n * file path. Both are baked here instead, which is the road this adapter already takes for the\n * document shell one function away.\n *\n * `filePath` is relative to the project root and is used for two things: the key the executor\n * looks a module up by, and the specifier the static import uses. Paths are emitted relative to\n * `.theokit/cloudflare/`, where the worker is written.\n */\n routes?: readonly { filePath: string; routePath: string; methods?: readonly string[] }[]\n /**\n * The two concerns #410 could not bake (#425), composed from one place so the six targets\n * cannot drift into six spellings. `serialization` is a literal like the security values above;\n * `plugins` is an import, because a closure has no literal.\n */\n runtimeConfigModule?: DeployedRuntimeConfigOptions['runtimeConfigModule']\n serialization?: DeployedRuntimeConfigOptions['serialization']\n /**\n * The app's agents, scanned on the build machine (#367).\n *\n * A different scan from `routes` and served by a different function — which is why a worker\n * that only consulted the route table answered every `/api/agents/<name>` with a 404.\n */\n agents?: readonly DeployedAgent[]\n /** B-185 — the app's `server/context.ts`, project-relative, or absent when it declares none. */\n contextModule?: string\n /** WebSocket route files, scanned on the build machine. Only their presence is used (#369). */\n wsRoutes?: readonly string[]\n } & DeployedServerDirOptions &\n DeployedCsrfOptions &\n DeployedCorsOptions = {},\n): string {\n const streamingImport = opts.ssrStreaming\n ? `import { renderStreamingWeb } from '/@theo/entry-server'`\n : `// (ssrStreaming off: renderStreamingWeb not imported)`\n // #343 — the document shell is inlined as a build-time literal because a Worker\n // has no filesystem to read `index.html` from at request time. Without it,\n // `renderStreamingWeb` falls back to its empty-string defaults and the response\n // is React output with no `<html>`, no `<head>`, no stylesheet and no client\n // entry — hydration data for a page that cannot hydrate. The streaming\n // assembly was fixed in the generated entry and this, its only caller, was\n // left passing nothing.\n //\n // `JSON.stringify` and not a template literal: the shell contains quotes,\n // angle brackets and a `</script>`, and embedding it naively produces a worker\n // that fails to parse at deploy time rather than here.\n //\n // #410 — this is also the ONE deploy path that renders HTML at request time,\n // so the one that can mint a per-request CSP nonce: `renderStreamingWeb`\n // threads `options.nonce` into `renderToReadableStream` and into the hydration\n // script (`router/entry-server.ts`). Every other response below carries the\n // nonce-less baseline, which is what `buildSecurityHeaders` already does for a\n // prerendered route (EC-4).\n // Only the streaming branch renders HTML at request time; the other serves the document from\n // `env.ASSETS` as a static file and can inject nothing. Baking the map for it would ship the whole\n // route table as dead weight — found at review, where the emitter was measured declaring it with\n // zero call sites.\n const preloadsApply = preloadsApplyTo(opts)\n const preloadSupport = preloadsApply ? renderPreloadSupport(opts.assetsMap) : ''\n\n const nonApiBranch = renderNonApiBranch(opts, preloadsApply)\n\n // CR-006: Workers lack `process.cwd()` and the `node:*` import surface\n // is brittle even under `nodejs_compat`. We use the Web Crypto\n // `crypto.randomUUID()` instead of `node:crypto.randomUUID`, and embed\n // the server directory as a build-time literal instead of resolving via\n // `node:path` at runtime.\n const { routeImports, routeModuleEntries, routeTableEntries } = renderBakedRoutes(\n opts.routes ?? [],\n )\n const runtimeConfig = deployedRuntimeConfigFragment(opts)\n const agentsFragment = deployedAgentsFragment(\n opts.agents === undefined\n ? undefined\n : // B-185 — a Worker has no filesystem, so its identity module is baked exactly like its\n // agents and its routes (ADR 0014). `contextModule` is `undefined` for an app that\n // declares none, and the generator then emits no import for it.\n { kind: 'baked', agents: opts.agents, contextModule: opts.contextModule },\n {\n wrapSecurityHeaders: true,\n // B-185 — bound only when the runtime-config fragment declared the const, which is\n // exactly when a plugins module was emitted. Referencing it otherwise would emit an\n // identifier the entry never declares.\n pluginRunnerExpr:\n opts.runtimeConfigModule === undefined ? undefined : 'await THEO_PLUGIN_RUNNER',\n },\n )\n\n return [\n `// Generated by Theo — Cloudflare Workers Adapter`,\n `//`,\n `// REQUIREMENTS (EC-3):`,\n `// - wrangler.toml MUST include compatibility_flags = [\"nodejs_compat\"]`,\n `// (still required for transitive theokit/server deps, e.g. busboy)`,\n `// - package.json MUST list \"theokit\" in dependencies (not devDependencies)`,\n `// so Wrangler bundles theokit and its transitive deps`,\n `// - Deploy: wrangler deploy`,\n ``,\n !preloadsApply\n ? `import { matchRoute, executeRoute, compilePattern, extractTraceIdFromRequest, TRACE_HEADER, createCorsWebHandler } from 'theokit/server'`\n : `import { matchRoute, executeRoute, compilePattern, extractTraceIdFromRequest, TRACE_HEADER, createCorsWebHandler } from 'theokit/server'\\nimport { injectModulePreloads } from 'theokit/server/http'`,\n `import { createWebShim } from 'theokit/adapters/web-shim'`,\n opts.ssrStreaming\n ? `import { buildSecurityHeaders, generateNonce, withSecurityHeaders } from 'theokit/adapters/security-headers'`\n : `import { buildSecurityHeaders, withSecurityHeaders } from 'theokit/adapters/security-headers'`,\n `// T3.4 — WS bridge for Cloudflare Workers`,\n `import { createCloudflareWsBridge } from 'theokit/adapters/ws-shim'`,\n streamingImport,\n ``,\n ...runtimeConfig.imports,\n ...agentsFragment.imports,\n ...routeImports,\n ``,\n `// CR-006: server directory is a build-time literal — Workers cannot`,\n `// call process.cwd() and resolving paths at runtime returned '/server'.`,\n `const serverDir = ${serverDirLiteral(opts)}`,\n ``,\n ...routeRuntimeLines(routeModuleEntries, routeTableEntries),\n `// #410 — the security baseline \\`theokit start\\` puts on every response, carried`,\n `// here as a literal because a Worker has no theo.config.ts to read. Same`,\n `// function, same input, so the deployed page and the local one cannot`,\n `// disagree about what the configuration means.`,\n preloadSupport,\n ...securityHeadersDeclarations(opts.securityHeaders),\n ``,\n ...deployedCsrfFragment(opts, 'a Worker'),\n ``,\n ...runtimeConfig.declarations,\n ...agentsFragment.declarations,\n ...deployedCorsFragment(opts.cors, 'cloudflare'),\n `// #369 — whether this project declares a WebSocket route, decided at build time. It used`,\n `// to answer it with \\`scanWebSocketRoutes\\`, which is the same readdirSync.`,\n `const HAS_WS_ROUTES = ${String((opts.wsRoutes ?? []).length > 0)}`,\n ``,\n `function notFoundResponse() {`,\n ` return withSecurityHeaders(`,\n ` new Response(`,\n ` JSON.stringify({ error: { code: 'NOT_FOUND', message: 'Route not found' } }),`,\n ` { status: 404, headers: { 'Content-Type': 'application/json' } },`,\n ` ),`,\n ` SECURITY_HEADERS,`,\n ` )`,\n `}`,\n ``,\n ...cloudflareHandleRequestFragment(\n nonApiBranch,\n runtimeConfig.executeRouteSpread,\n agentsFragment.branch,\n agentsFragment.hostBypass,\n ),\n ].join('\\n')\n}\n\n/**\n * The Worker's request handler, as generated source.\n *\n * Extracted for the reason `vercel.ts` extracts its own fragments: the emitter is one array\n * literal, so every line the entry gains counts against `max-lines-per-function`, and #410 added\n * the CSRF literal to an emitter already sitting exactly at the ceiling.\n *\n * @param nonApiBranch - what a non-`/api/` request gets, which differs with `ssrStreaming`\n */\nfunction cloudflareHandleRequestFragment(\n nonApiBranch: string,\n runtimeSpread: string,\n agentBranch: readonly string[],\n /** SI-020 — the condition that keeps an agent card path out of the static-asset branch. */\n hostBypass: string,\n): string[] {\n return [\n `async function handleRequest(request, url, env) {`,\n ` if (!url.pathname.startsWith('/api/')${hostBypass}) {`,\n nonApiBranch,\n ` }`,\n ``,\n ...agentBranch,\n ``,\n ` const match = matchRoute(url.pathname, routes)`,\n ` if (!match) return notFoundResponse()`,\n ``,\n ` const { req, res, toResponse } = createWebShim(request, { trustedProxy: 'platform' })`,\n ...deployedTraceFragment('request', ' '),\n ` const method = request.method.toUpperCase()`,\n ` // #382 — the run is NOT awaited before the Response is taken. toResponse()`,\n ` // settles as soon as status + headers are known and carries a live body, so`,\n ` // the Worker starts flushing while the handler is still writing. Awaiting`,\n ` // executeRoute() first would re-buffer the whole response here even though`,\n ` // the shim streams; awaiting toResponse() does not — it settles at the head.`,\n ` return withSecurityHeaders(await toResponse(executeRoute({`,\n ` route: match.route, method, params: match.params,`,\n ` req, res, loadModule, serverDir, requestId, ...CSRF_CONFIG, ${runtimeSpread}`,\n ` })), SECURITY_HEADERS)`,\n `}`,\n ``,\n `export default {`,\n ` async fetch(request, env, ctx) {`,\n ` const url = new URL(request.url)`,\n ``,\n ` // T3.4 — Detect WebSocket upgrade and delegate to the CF bridge.`,\n ` // A 101 carries no document and no script, so the security baseline does`,\n ` // not apply to it.`,\n ` if (request.headers.get('upgrade')?.toLowerCase() === 'websocket') {`,\n ` if (!HAS_WS_ROUTES) return notFoundResponse()`,\n ` const cfWs = createCloudflareWsBridge({`,\n ` onOpen: () => {},`,\n ` onMessage: (ws, data) => { ws.send(data) },`,\n ` onClose: () => {},`,\n ` })`,\n ` return cfWs.handle(request)`,\n ` }`,\n ``,\n ` // #409 — the preflight is answered BEFORE anything routes: an OPTIONS the router handles`,\n ` // is an OPTIONS the browser never gets a CORS answer to. The WebSocket upgrade above is`,\n ` // deliberately upstream of it — a 101 is not a CORS-governed response.`,\n ` const preflight = corsPreflight(request)`,\n ` if (preflight !== null) return withSecurityHeaders(preflight, SECURITY_HEADERS)`,\n ``,\n ` return withCors(request, await handleRequest(request, url, env))`,\n ` },`,\n `}`,\n ]\n}\n\nexport function renderWranglerToml(): string {\n return [\n `# Generated by Theo — Cloudflare Workers`,\n `name = \"theo-app\"`,\n `main = \".theokit/cloudflare/worker.mjs\"`,\n `compatibility_date = \"2025-09-01\"`,\n `compatibility_flags = [\"nodejs_compat\"]`,\n ``,\n `# #412 — \\`[assets]\\` with a BINDING, not the legacy \\`[site]\\` bucket.`,\n `#`,\n `# \\`[site]\\` uploads to KV and is read through \\`kv-asset-handler\\` and a`,\n `# \\`__STATIC_CONTENT\\` binding — neither of which this worker has ever had. So the`,\n `# bucket was declared, uploaded, and consumed by nothing: with ssrStreaming off, a`,\n `# deploy answered 404 for its own page. This binding is what the worker calls.`,\n `[assets]`,\n `directory = \".theokit/client\"`,\n `binding = \"ASSETS\"`,\n `# A client-routed app asks for /dashboard, which is no file. Without this the asset`,\n `# handler 404s a deep link and the SPA never boots.`,\n `not_found_handling = \"single-page-application\"`,\n ``,\n `# Environment variables are set via wrangler secret or dashboard`,\n `# Example: wrangler secret put DATABASE_URL`,\n ].join('\\n')\n}\n\nexport const cloudflareAdapter: DeployAdapter = {\n name: 'cloudflare',\n streamsResponses: true,\n // #409 / #410 — the generated entry calls `executeRoute` with routes, loader\n // and serverDir only. CSRF, route policy, file middleware and Zod validation\n // still run because they live inside `executeRoute`; none of the remaining\n // configurable concerns reach it. Declared explicitly rather than omitted so\n // the gap is a statement in the source and not an absence.\n //\n // `securityHeaders` IS applied: the worker carries `security.headers` as a\n // literal and puts the built baseline on every response it returns, including\n // the streamed SSR document — with a per-request nonce, the only deploy path\n // that can mint one (`adapters/security-headers.ts`).\n servesAgents: true,\n appliesConfig: ['securityHeaders', 'csrf', 'disallowed', 'cors', 'serialization', 'plugins'],\n\n async build(config: TheoConfig, cwd: string, ctx?: AdapterBuildContext): Promise<void> {\n // Wave 2 (T2.2) — reject polyglot services on this adapter.\n assertServicesUnsupported('cloudflare', readManifest(cwd))\n\n // 1. Run the standard Node build first (ctx forwarded so nodeAdapter has makeVitePlugins)\n await nodeAdapter.build(config, cwd, ctx)\n\n const outputDir = resolve(cwd, '.theokit/cloudflare')\n mkdirSync(outputDir, { recursive: true })\n\n // 2. Emit Worker entry (now uses the shared web-shim)\n //\n // The document shell is read HERE, after the Node build produced\n // `.theokit/client/index.html`, and inlined into the worker: a Worker has no\n // filesystem at request time. Split on the root div with the same helper the\n // Node server uses (`ssr-setup.ts`), so the two paths cannot disagree about\n // where the shell ends (#343).\n const shell = readDocumentShell(cwd, config.ssrStreaming)\n // B-035 — the route-to-chunks map, read HERE on the build machine for the same reason the\n // shell above is: a Worker has no filesystem at request time. `nodeAdapter.build` ran\n // first, so the map the Node build emitted is on disk by now. Absent map -> nothing about\n // preloads is emitted, and the worker behaves exactly as it did before.\n const assetsMap = readAssetsMapForBake(resolve(cwd, '.theokit', 'client', 'assets-map.json'))\n\n // #369 — the routes are resolved HERE, on the build machine, for the same reason the document\n // shell above is read here: a Worker has no filesystem at request time, and the worker used to\n // run the scan itself against a directory that does not exist there.\n //\n // The scanner is INJECTED rather than imported: importing it would add an `adapters → server`\n // edge, which is the layering inversion ADR-0001 v3 removed for `vite-plugin` and which\n // `adapters-may-only-depend-on-core-router-services` refuses. An absent scanner emits a worker\n // with no routes rather than falling back to a runtime scan — the fallback IS the defect.\n const scanned = ctx?.scanRoutes?.(config.serverDir) ?? {\n routes: [],\n wsRoutes: [],\n agents: [],\n // B-185 — no provider means no scan, and an app whose context nobody looked for is\n // indistinguishable here from one that has none. Both resolve an anonymous caller, which is\n // the honest answer rather than an invented subject.\n contextModule: undefined,\n }\n\n const pluginsPlan = planDeployedPlugins(config.plugins, 'cloudflare')\n if (pluginsPlan !== undefined) {\n // Beside the worker, so the emitted import is a sibling. Wrangler bundles from here, which is\n // what lets the static import reach the app's own module at all (#425).\n writeFileSync(resolve(outputDir, 'theo.plugins.mjs'), pluginsPlan.source)\n }\n\n writeFileSync(\n resolve(outputDir, 'worker.mjs'),\n renderCloudflareWorkerEntry({\n ssrStreaming: config.ssrStreaming,\n ...shell,\n securityHeaders: config.security?.headers,\n csrf: config.security?.csrf,\n disallowed: config.security?.disallowed,\n cors: config.security?.cors,\n assetsMap,\n // #425 — a selector, not a transformer, so it rides as a literal like the values above.\n serialization: config.serialization,\n // #425 — the ONE concern that is not a literal. A closure cannot be baked, so a plugin\n // declared by module specifier is imported by the emitted module instead; a constructed one\n // is refused by name at build time rather than dropped in silence.\n runtimeConfigModule: pluginsPlan?.moduleSpecifier,\n routes: scanned.routes,\n // #367 — a Worker has no filesystem, so its agents are decided here like its routes.\n agents: scanned.agents,\n // B-185 — rides beside the agents because it is decided by the same provider, for the same\n // reason: `build.ts` holds `serverDir` and a Worker cannot look for the module itself.\n contextModule: scanned.contextModule,\n wsRoutes: scanned.wsRoutes,\n }),\n )\n\n // 3. Emit wrangler.toml (with nodejs_compat enforced)\n writeFileSync(resolve(cwd, 'wrangler.toml'), renderWranglerToml())\n\n // eslint-disable-next-line no-console -- CLI build progress\n console.log('\\n ✓ Cloudflare output → .theokit/cloudflare/ + wrangler.toml')\n // eslint-disable-next-line no-console -- CLI build progress\n console.log(\n `${describeDeployedSecurityHeaders({\n target: 'cloudflare',\n securityHeaders: config.security?.headers,\n // Only the streaming worker renders HTML per request, so only it can put\n // the same nonce on the header and on the script tag it emits.\n mintsNonce: config.ssrStreaming,\n // #412 — either way the worker returns the document now: streamed by\n // `renderStreamingWeb`, or from the ASSETS binding it finally calls.\n documentHeaders: 'handler',\n })}\\n`,\n )\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,SAAS,YAAY,WAAW,cAAc,qBAAqB;AACnE,SAAS,eAAe;AA0CjB,SAAS,kBACd,KACA,WAC0C;AAC1C,MAAI,CAAC,UAAW,QAAO,CAAC;AAExB,QAAM,YAAY,QAAQ,KAAK,4BAA4B;AAC3D,MAAI,CAAC,WAAW,SAAS,GAAG;AAC1B,UAAM,IAAI;AAAA,MACR,+CAA+C,SAAS;AAAA,IAG1D;AAAA,EACF;AAEA,QAAM,YAAY,aAAa,WAAW,OAAO;AACjD,QAAM,UAAU,YAAY,SAAS;AACrC,MAAI,YAAY,QAAW;AACzB,UAAM,IAAI;AAAA,MACR,w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
|
|
|
69
69
|
}) => TResponse | Promise<TResponse>;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
/**
|
|
73
|
+
* A middleware, as the framework's own builder produces it (usetheokit/theokit#345).
|
|
74
|
+
*
|
|
75
|
+
* `(request, context)`: read the request as a Web `Request`, decorate `context` for the route that
|
|
76
|
+
* follows, and RETURN a `Response` to answer the request yourself. Returning nothing continues to
|
|
77
|
+
* the next middleware, and then to the route.
|
|
78
|
+
*
|
|
79
|
+
* ## Why not `(request, next) => Response`
|
|
80
|
+
*
|
|
81
|
+
* That was this type's first shape, and it described a continuation pipeline nothing in this
|
|
82
|
+
* repository implements: the file-scan runner runs BEFORE routing, so it has no downstream
|
|
83
|
+
* `Response` to hand back from `next(request)`. The consequence was measured rather than
|
|
84
|
+
* theorised — `MiddlewareHandler` had **zero runtime consumers**, while `README.md` documented the
|
|
85
|
+
* builder that produces it as the way to write middleware. A published builder whose output nothing
|
|
86
|
+
* can call is worse than a missing one, because it reads as supported.
|
|
87
|
+
*
|
|
88
|
+
* This shape is the one that fits the model AND already runs: `executeWebRequest` has invoked
|
|
89
|
+
* `(request, context) => Response | void` since T3.2 (`http/web-middleware-runner.ts`). Adopting it
|
|
90
|
+
* here converges two of the three middleware contracts instead of adding a fourth.
|
|
91
|
+
*
|
|
92
|
+
* The Express-style `(req, res, next)` export keeps working in `server/middleware/*.ts`. It is
|
|
93
|
+
* Node-bound — which is why it cannot be the framework's contract — but evicting it would break
|
|
94
|
+
* every app that has one.
|
|
95
|
+
*/
|
|
96
|
+
/**
|
|
97
|
+
* Run the rest of the chain and resolve to what it produced.
|
|
98
|
+
*
|
|
99
|
+
* Declared HERE rather than beside the runner because the dependency runs
|
|
100
|
+
* `http/ -> define/` and never the other way (`http/middleware-runner.ts:10`
|
|
101
|
+
* already imports from this module). A middleware's contract belongs with the
|
|
102
|
+
* definition of a middleware; the runner consumes it.
|
|
103
|
+
*
|
|
104
|
+
* `docs/adr/0006` clause 3 is what this parameter buys: code AFTER the
|
|
105
|
+
* downstream, which the short-circuit shape cannot express.
|
|
106
|
+
*/
|
|
107
|
+
type MiddlewareNext = () => Promise<Response | undefined>;
|
|
108
|
+
type MiddlewareHandler = (request: Request, context: Record<string, unknown>, next: MiddlewareNext) => Response | undefined | void | Promise<Response | undefined | void>;
|
|
109
|
+
|
|
110
|
+
export type { MiddlewareHandler as M, RouteConfig as R, MiddlewareNext as a };
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import "tsx/esm";
|
|
3
3
|
import {
|
|
4
|
-
deployedAgentsFragment,
|
|
5
4
|
planDeployedPlugins
|
|
6
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-V5SSTT3C.js";
|
|
6
|
+
import {
|
|
7
|
+
deployedEntryPreamble
|
|
8
|
+
} from "./chunk-XG6SQUEP.js";
|
|
7
9
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
agentsDirLiteral,
|
|
11
|
+
deployedAgentsFragment,
|
|
10
12
|
deployedRuntimeConfigFragment,
|
|
11
13
|
deployedTraceFragment,
|
|
12
14
|
describeDeployedSecurityHeaders,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
scannedFromLoaderCache,
|
|
16
|
+
serverDirLiteral
|
|
17
|
+
} from "./chunk-FFGP2LGQ.js";
|
|
15
18
|
import {
|
|
16
19
|
nodeAdapter
|
|
17
20
|
} from "./chunk-KI4DOTN4.js";
|
|
@@ -24,17 +27,25 @@ import {
|
|
|
24
27
|
// src/adapters/deno-deploy.ts
|
|
25
28
|
import { mkdirSync, writeFileSync } from "fs";
|
|
26
29
|
import { resolve } from "path";
|
|
30
|
+
var FRAMEWORK_IMPORTS = [
|
|
31
|
+
`// Use npm: specifier so Deno resolves theokit from the user's package.json`,
|
|
32
|
+
`// equivalent (works in both local 'deno run' and Deno Deploy).`,
|
|
33
|
+
`import { scanServerRoutes, matchRoute, executeRoute, createProductionLoader, scanWebSocketRoutes, extractTraceIdFromRequest, TRACE_HEADER, createCorsWebHandler } from 'npm:theokit/server'`,
|
|
34
|
+
`import { createWebShim } from 'npm:theokit/adapters/web-shim'`,
|
|
35
|
+
`import { buildSecurityHeaders, withSecurityHeaders } from 'npm:theokit/adapters/security-headers'`,
|
|
36
|
+
`// T3.3 \u2014 WS bridge for Deno runtime`,
|
|
37
|
+
`import { createDenoWsBridge } from 'npm:theokit/adapters/ws-shim'`
|
|
38
|
+
];
|
|
27
39
|
function renderDenoEntry(port, opts = {}) {
|
|
28
40
|
const runtimeConfig = deployedRuntimeConfigFragment(opts);
|
|
29
|
-
const agentsFragment = deployedAgentsFragment(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
);
|
|
41
|
+
const agentsFragment = deployedAgentsFragment(scannedFromLoaderCache(agentsDirLiteral(opts)), {
|
|
42
|
+
notFound: "notFound()",
|
|
43
|
+
importPrefix: "npm:",
|
|
44
|
+
// B-185 — bound only when the runtime-config fragment declared the const, which is
|
|
45
|
+
// exactly when a plugins module was emitted. Referencing it otherwise would emit an
|
|
46
|
+
// identifier the entry never declares.
|
|
47
|
+
pluginRunnerExpr: opts.runtimeConfigModule === void 0 ? void 0 : "await THEO_PLUGIN_RUNNER"
|
|
48
|
+
});
|
|
38
49
|
return [
|
|
39
50
|
`// Generated by Theo \u2014 Deno Deploy Adapter`,
|
|
40
51
|
`// Deploy: deployctl deploy --project=<name> .theokit/deno/server.ts`,
|
|
@@ -45,17 +56,11 @@ function renderDenoEntry(port, opts = {}) {
|
|
|
45
56
|
` throw new Error('TheoDenoDeployAdapter must run inside Deno.')`,
|
|
46
57
|
`}`,
|
|
47
58
|
``,
|
|
48
|
-
|
|
49
|
-
`// equivalent (works in both local 'deno run' and Deno Deploy).`,
|
|
50
|
-
`import { scanServerRoutes, matchRoute, executeRoute, createProductionLoader, scanWebSocketRoutes, extractTraceIdFromRequest, TRACE_HEADER, createCorsWebHandler } from 'npm:theokit/server'`,
|
|
51
|
-
`import { createWebShim } from 'npm:theokit/adapters/web-shim'`,
|
|
52
|
-
`import { buildSecurityHeaders, withSecurityHeaders } from 'npm:theokit/adapters/security-headers'`,
|
|
53
|
-
`// T3.3 \u2014 WS bridge for Deno runtime`,
|
|
54
|
-
`import { createDenoWsBridge } from 'npm:theokit/adapters/ws-shim'`,
|
|
59
|
+
...FRAMEWORK_IMPORTS,
|
|
55
60
|
``,
|
|
56
61
|
`const port = Number(Deno.env.get('PORT') ?? '${port}')`,
|
|
57
62
|
`const cwd = Deno.cwd()`,
|
|
58
|
-
`const serverDir = cwd + '/
|
|
63
|
+
`const serverDir = cwd + '/' + ${serverDirLiteral(opts)}`,
|
|
59
64
|
`let routesCache = null`,
|
|
60
65
|
`let wsRoutesCache = null`,
|
|
61
66
|
`let loaderCache = null`,
|
|
@@ -65,16 +70,7 @@ function renderDenoEntry(port, opts = {}) {
|
|
|
65
70
|
`// theo.config.ts to read. Non-API paths 404 here and are served by Deno`,
|
|
66
71
|
`// Deploy's static asset handler, so this covers the API and not the`,
|
|
67
72
|
`// document (usetheokit/theokit#412).`,
|
|
68
|
-
|
|
69
|
-
`const SECURITY_HEADERS = buildSecurityHeaders(SECURITY_HEADERS_CONFIG, { production: true })`,
|
|
70
|
-
``,
|
|
71
|
-
...runtimeConfig.imports,
|
|
72
|
-
...agentsFragment.imports,
|
|
73
|
-
...runtimeConfig.declarations,
|
|
74
|
-
...agentsFragment.declarations,
|
|
75
|
-
...deployedCsrfFragment(opts),
|
|
76
|
-
``,
|
|
77
|
-
...deployedCorsFragment(opts.cors, "deno-deploy"),
|
|
73
|
+
...deployedEntryPreamble(runtimeConfig, agentsFragment, opts, "deno-deploy"),
|
|
78
74
|
``,
|
|
79
75
|
`function notFound() {`,
|
|
80
76
|
` return new Response(JSON.stringify({ error: { code: 'NOT_FOUND' } }), {`,
|
|
@@ -108,7 +104,7 @@ function renderDenoEntry(port, opts = {}) {
|
|
|
108
104
|
`async function handleRequest(request) {`,
|
|
109
105
|
` const url = new URL(request.url)`,
|
|
110
106
|
``,
|
|
111
|
-
` if (!url.pathname.startsWith('/api/')) {`,
|
|
107
|
+
` if (!url.pathname.startsWith('/api/')${agentsFragment.hostBypass}) {`,
|
|
112
108
|
` // Static + SPA fallback are served by Deno Deploy's static asset handler.`,
|
|
113
109
|
` return notFound()`,
|
|
114
110
|
` }`,
|
|
@@ -150,7 +146,12 @@ async function buildDeno(config, cwd, deps = {}, ctx) {
|
|
|
150
146
|
// #425 — the ONE concern that is not a literal. A closure cannot be baked, so a plugin
|
|
151
147
|
// declared by module specifier is imported by the emitted module instead; a constructed one
|
|
152
148
|
// is refused by name at build time rather than dropped in silence.
|
|
153
|
-
runtimeConfigModule: pluginsPlan?.moduleSpecifier
|
|
149
|
+
runtimeConfigModule: pluginsPlan?.moduleSpecifier,
|
|
150
|
+
// #95 — the configured directories, which `build.ts:210` already threads into the Vite
|
|
151
|
+
// plugins. Without these two lines the literals above fall to their defaults and a project
|
|
152
|
+
// with a custom dir deploys an entry that resolves a directory it does not have.
|
|
153
|
+
serverDir: config.serverDir,
|
|
154
|
+
agentsDir: config.agentsDir
|
|
154
155
|
});
|
|
155
156
|
const write = deps.writeEntry ?? ((p, c) => {
|
|
156
157
|
writeFileSync(p, c);
|
|
@@ -193,4 +194,4 @@ export {
|
|
|
193
194
|
denoDeployAdapter,
|
|
194
195
|
renderDenoEntry
|
|
195
196
|
};
|
|
196
|
-
//# sourceMappingURL=deno-deploy-
|
|
197
|
+
//# sourceMappingURL=deno-deploy-WMNXRVGL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapters/deno-deploy.ts"],"sourcesContent":["/* eslint-disable security/detect-non-literal-fs-filename --\n * Deno Deploy adapter. Writes to `cwd/.theokit/deno-deploy/`. Build-time.\n */\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\n\nimport type { TheoConfig } from '../config/schema.js'\nimport { assertServicesUnsupported, readManifest } from '../services/index.js'\n\nimport { deployedAgentsFragment, scannedFromLoaderCache } from './deployed-agents.js'\nimport { planDeployedPlugins } from './deployed-plugins-module.js'\nimport { deployedEntryPreamble } from './deployed-preamble.js'\nimport {\n agentsDirLiteral,\n deployedRuntimeConfigFragment,\n serverDirLiteral,\n} from './deployed-runtime-config.js'\nimport { deployedTraceFragment } from './deployed-trace.js'\nimport { nodeAdapter } from './node.js'\nimport { describeDeployedSecurityHeaders } from './security-headers.js'\nimport type { AdapterBuildContext, DeployAdapter, DeployedEntryOptions } from './types.js'\n\nexport interface DenoBuildDeps {\n runNodeBuild?: (config: TheoConfig, cwd: string, ctx?: AdapterBuildContext) => Promise<void>\n writeEntry?: (path: string, content: string) => void\n ensureDir?: (path: string) => void\n}\n\n/**\n * The framework imports this entry opens with, as `npm:` specifiers.\n *\n * Extracted from `renderDenoEntry` when adding the configured-directory literal pushed it past the\n * per-function line budget. A cohesive block — every line is one import of the same package family\n * — so lifting it keeps the budget a signal about the renderer rather than about its preamble.\n */\nconst FRAMEWORK_IMPORTS: readonly string[] = [\n `// Use npm: specifier so Deno resolves theokit from the user's package.json`,\n `// equivalent (works in both local 'deno run' and Deno Deploy).`,\n `import { scanServerRoutes, matchRoute, executeRoute, createProductionLoader, scanWebSocketRoutes, extractTraceIdFromRequest, TRACE_HEADER, createCorsWebHandler } from 'npm:theokit/server'`,\n `import { createWebShim } from 'npm:theokit/adapters/web-shim'`,\n `import { buildSecurityHeaders, withSecurityHeaders } from 'npm:theokit/adapters/security-headers'`,\n `// T3.3 — WS bridge for Deno runtime`,\n `import { createDenoWsBridge } from 'npm:theokit/adapters/ws-shim'`,\n]\n\nexport function renderDenoEntry(port: number, opts: DeployedEntryOptions = {}): string {\n const runtimeConfig = deployedRuntimeConfigFragment(opts)\n const agentsFragment = deployedAgentsFragment(scannedFromLoaderCache(agentsDirLiteral(opts)), {\n notFound: 'notFound()',\n importPrefix: 'npm:',\n // B-185 — bound only when the runtime-config fragment declared the const, which is\n // exactly when a plugins module was emitted. Referencing it otherwise would emit an\n // identifier the entry never declares.\n pluginRunnerExpr:\n opts.runtimeConfigModule === undefined ? undefined : 'await THEO_PLUGIN_RUNNER',\n })\n return [\n `// Generated by Theo — Deno Deploy Adapter`,\n `// Deploy: deployctl deploy --project=<name> .theokit/deno/server.ts`,\n `// Requires Deno >= 1.40 (Deno.serve + npm: specifier support)`,\n ``,\n `// Runtime guard`,\n `if (typeof Deno === 'undefined') {`,\n ` throw new Error('TheoDenoDeployAdapter must run inside Deno.')`,\n `}`,\n ``,\n ...FRAMEWORK_IMPORTS,\n ``,\n `const port = Number(Deno.env.get('PORT') ?? '${port}')`,\n `const cwd = Deno.cwd()`,\n `const serverDir = cwd + '/' + ${serverDirLiteral(opts)}`,\n `let routesCache = null`,\n `let wsRoutesCache = null`,\n `let loaderCache = null`,\n ``,\n `// #410 — the security baseline \\`theokit start\\` puts on every response,`,\n `// carried here as a literal because the deployed isolate has no`,\n `// theo.config.ts to read. Non-API paths 404 here and are served by Deno`,\n `// Deploy's static asset handler, so this covers the API and not the`,\n `// document (usetheokit/theokit#412).`,\n ...deployedEntryPreamble(runtimeConfig, agentsFragment, opts, 'deno-deploy'),\n ``,\n `function notFound() {`,\n ` return new Response(JSON.stringify({ error: { code: 'NOT_FOUND' } }), {`,\n ` status: 404,`,\n ` headers: { 'Content-Type': 'application/json' },`,\n ` })`,\n `}`,\n ``,\n `Deno.serve({ port }, async (request) => {`,\n ` // T3.3 — Detect WebSocket upgrade and delegate to the Deno bridge.`,\n ` // A 101 carries no document and no script, so the security baseline does`,\n ` // not apply to it.`,\n ` if (request.headers.get('upgrade')?.toLowerCase() === 'websocket') {`,\n ` if (!wsRoutesCache) wsRoutesCache = scanWebSocketRoutes(serverDir)`,\n ` if (wsRoutesCache.length === 0) return notFound()`,\n ` const denoWs = createDenoWsBridge({`,\n ` onOpen: () => {},`,\n ` onMessage: (ws, data) => { ws.send(data) },`,\n ` onClose: () => {},`,\n ` }, Deno)`,\n ` return denoWs.handle(request)`,\n ` }`,\n ``,\n ` // #409 — the preflight is answered BEFORE anything routes: an OPTIONS the router`,\n ` // handles is an OPTIONS the browser never gets a CORS answer to.`,\n ` const preflight = corsPreflight(request)`,\n ` if (preflight !== null) return withSecurityHeaders(preflight, SECURITY_HEADERS)`,\n ` return withCors(request, withSecurityHeaders(await handleRequest(request), SECURITY_HEADERS))`,\n `})`,\n ``,\n `async function handleRequest(request) {`,\n ` const url = new URL(request.url)`,\n ``,\n ` if (!url.pathname.startsWith('/api/')${agentsFragment.hostBypass}) {`,\n ` // Static + SPA fallback are served by Deno Deploy's static asset handler.`,\n ` return notFound()`,\n ` }`,\n ``,\n ` if (!routesCache) routesCache = scanServerRoutes(serverDir)`,\n ` if (!loaderCache) loaderCache = createProductionLoader()`,\n ``,\n ...agentsFragment.branch,\n ``,\n ` const match = matchRoute(url.pathname, routesCache)`,\n ` if (!match) return notFound()`,\n ``,\n ` const { req, res, toResponse } = createWebShim(request)`,\n ...deployedTraceFragment('request', ' '),\n ` const method = request.method.toUpperCase()`,\n ` // #382 — not awaited: toResponse() settles at the headers and carries a`,\n ` // live body, so Deno.serve streams while the handler writes.`,\n ` return toResponse(executeRoute({ route: match.route, method, params: match.params, req, res, loadModule: loaderCache, serverDir, requestId, ...CSRF_CONFIG, ${runtimeConfig.executeRouteSpread} }))`,\n `}`,\n ``,\n `console.log('Theo (Deno Deploy) listening on :' + port)`,\n ].join('\\n')\n}\n\nexport async function buildDeno(\n config: TheoConfig,\n cwd: string,\n deps: DenoBuildDeps = {},\n ctx?: AdapterBuildContext,\n): Promise<void> {\n // Wave 2 (T2.2) — reject polyglot services on this adapter.\n assertServicesUnsupported('deno-deploy', readManifest(cwd))\n\n const runNodeBuild = deps.runNodeBuild ?? nodeAdapter.build.bind(nodeAdapter)\n await runNodeBuild(config, cwd, ctx)\n\n const outputDir = resolve(cwd, '.theokit/deno')\n const ensureDir = deps.ensureDir ?? ((p: string) => mkdirSync(p, { recursive: true }))\n ensureDir(outputDir)\n\n const pluginsPlan = planDeployedPlugins(config.plugins, denoDeployAdapter.name)\n const entry = renderDenoEntry(config.port, {\n securityHeaders: config.security?.headers,\n csrf: config.security?.csrf,\n disallowed: config.security?.disallowed,\n cors: config.security?.cors,\n // #425 — a selector, not a transformer, so it rides as a literal like the values above.\n serialization: config.serialization,\n // #425 — the ONE concern that is not a literal. A closure cannot be baked, so a plugin\n // declared by module specifier is imported by the emitted module instead; a constructed one\n // is refused by name at build time rather than dropped in silence.\n runtimeConfigModule: pluginsPlan?.moduleSpecifier,\n // #95 — the configured directories, which `build.ts:210` already threads into the Vite\n // plugins. Without these two lines the literals above fall to their defaults and a project\n // with a custom dir deploys an entry that resolves a directory it does not have.\n serverDir: config.serverDir,\n agentsDir: config.agentsDir,\n })\n const write =\n deps.writeEntry ??\n ((p, c) => {\n writeFileSync(p, c)\n })\n if (pluginsPlan !== undefined) {\n // Beside the entry, so the emitted import is a sibling. Written through the same seam as\n // the entry so a test that captures one captures both (#425).\n write(resolve(outputDir, 'theo.plugins.mjs'), pluginsPlan.source)\n }\n write(resolve(outputDir, 'server.ts'), entry)\n\n // eslint-disable-next-line no-console -- CLI build progress\n console.log('\\n ✓ Deno Deploy output → .theokit/deno/server.ts')\n // eslint-disable-next-line no-console -- CLI build progress\n console.log(\n `${describeDeployedSecurityHeaders({\n target: 'deno-deploy',\n securityHeaders: config.security?.headers,\n mintsNonce: false,\n documentHeaders: 'platform-unmanaged',\n })}\\n`,\n )\n}\n\nexport const denoDeployAdapter: DeployAdapter = {\n name: 'deno-deploy',\n streamsResponses: true,\n // #409 / #410 — the generated entry calls `executeRoute` with routes, loader\n // and serverDir only. CSRF, route policy, file middleware and Zod validation\n // still run because they live inside `executeRoute`; none of the remaining\n // configurable concerns reach it. Declared explicitly rather than omitted so\n // the gap is a statement in the source and not an absence.\n //\n // `securityHeaders` IS applied -- to every response this isolate returns. The\n // document comes from Deno Deploy's static asset handler and does not pass\n // through it (usetheokit/theokit#412).\n servesAgents: true,\n appliesConfig: ['securityHeaders', 'csrf', 'disallowed', 'cors', 'serialization', 'plugins'],\n build(config, cwd, ctx) {\n return buildDeno(config, cwd, {}, ctx)\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAAS,WAAW,qBAAqB;AACzC,SAAS,eAAe;AA+BxB,IAAM,oBAAuC;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,SAAS,gBAAgB,MAAc,OAA6B,CAAC,GAAW;AACrF,QAAM,gBAAgB,8BAA8B,IAAI;AACxD,QAAM,iBAAiB,uBAAuB,uBAAuB,iBAAiB,IAAI,CAAC,GAAG;AAAA,IAC5F,UAAU;AAAA,IACV,cAAc;AAAA;AAAA;AAAA;AAAA,IAId,kBACE,KAAK,wBAAwB,SAAY,SAAY;AAAA,EACzD,CAAC;AACD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,IACH;AAAA,IACA,gDAAgD,IAAI;AAAA,IACpD;AAAA,IACA,iCAAiC,iBAAiB,IAAI,CAAC;AAAA,IACvD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG,sBAAsB,eAAe,gBAAgB,MAAM,aAAa;AAAA,IAC3E;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,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ACpB;AACF,MAAI,gBAAgB,QAAW;AAG7B,UAAM,QAAQ,WAAW,kBAAkB,GAAG,YAAY,MAAM;AAAA,EAClE;AACA,QAAM,QAAQ,WAAW,WAAW,GAAG,KAAK;AAG5C,UAAQ,IAAI,8DAAoD;AAEhE,UAAQ;AAAA,IACN,GAAG,gCAAgC;AAAA,MACjC,QAAQ;AAAA,MACR,iBAAiB,OAAO,UAAU;AAAA,MAClC,YAAY;AAAA,MACZ,iBAAiB;AAAA,IACnB,CAAC,CAAC;AAAA;AAAA,EACJ;AACF;AAEO,IAAM,oBAAmC;AAAA,EAC9C,MAAM;AAAA,EACN,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUlB,cAAc;AAAA,EACd,eAAe,CAAC,mBAAmB,QAAQ,cAAc,QAAQ,iBAAiB,SAAS;AAAA,EAC3F,MAAM,QAAQ,KAAK,KAAK;AACtB,WAAO,UAAU,QAAQ,KAAK,CAAC,GAAG,GAAG;AAAA,EACvC;AACF;","names":[]}
|
|
@@ -11,19 +11,19 @@ import {
|
|
|
11
11
|
} from "./chunk-KTMQUYED.js";
|
|
12
12
|
import {
|
|
13
13
|
theoPluginAsync
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-I2H6KRCQ.js";
|
|
15
|
+
import "./chunk-4WB62S22.js";
|
|
16
16
|
import "./chunk-BDH5GKFZ.js";
|
|
17
17
|
import "./chunk-3PWQQWT6.js";
|
|
18
18
|
import "./chunk-FDOOBTXJ.js";
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-UETVDZBE.js";
|
|
19
|
+
import "./chunk-SJ4AW54X.js";
|
|
20
|
+
import "./chunk-BINRCILF.js";
|
|
22
21
|
import "./chunk-QD5X56I3.js";
|
|
23
22
|
import "./chunk-WSMLSIS5.js";
|
|
24
|
-
import "./chunk-
|
|
23
|
+
import "./chunk-MS4A7N77.js";
|
|
25
24
|
import "./chunk-C27VRUVN.js";
|
|
26
25
|
import "./chunk-7UZZHCRN.js";
|
|
26
|
+
import "./chunk-47MM2JUK.js";
|
|
27
27
|
import "./chunk-BCFA6LHL.js";
|
|
28
28
|
import "./chunk-5NNFO7R7.js";
|
|
29
29
|
import "./chunk-NO6HA4FG.js";
|
|
@@ -128,4 +128,4 @@ export {
|
|
|
128
128
|
devCommand,
|
|
129
129
|
startDevServer
|
|
130
130
|
};
|
|
131
|
-
//# sourceMappingURL=dev-
|
|
131
|
+
//# sourceMappingURL=dev-72ISY3BP.js.map
|
|
@@ -3,10 +3,11 @@ import { IncomingMessage, ServerResponse } from 'node:http';
|
|
|
3
3
|
import { P as PluginContext, W as WebOnRequestHook, g as WebPreHandlerHook, h as WebOnResponseHook, i as WebOnErrorHook } from './plugin-types-BUVfUQ0V.js';
|
|
4
4
|
import { P as PluginRunner } from './plugin-runner-BVMOSxvb.js';
|
|
5
5
|
import { J as JobBackend } from './job-backend-CgC8Xf33.js';
|
|
6
|
-
import {
|
|
6
|
+
import { S as ServerRouteNode } from './match-DaKsL73w.js';
|
|
7
|
+
import { L as LoadModule } from './module-loader-DCip7NoL.js';
|
|
7
8
|
import { C as CsrfMode, D as DisallowedConfig } from './csrf-Dgot9qSM.js';
|
|
8
9
|
import { z } from 'zod';
|
|
9
|
-
import { R as RouteConfig } from './
|
|
10
|
+
import { a as MiddlewareNext, R as RouteConfig } from './define-middleware-BOHpPOBs.js';
|
|
10
11
|
import './action-protocol-tGm3NKRg.js';
|
|
11
12
|
|
|
12
13
|
interface ExecuteActionOptions {
|
|
@@ -461,6 +462,28 @@ declare function serverErrorToEnvelope(value: unknown): TheoErrorEnvelope;
|
|
|
461
462
|
*/
|
|
462
463
|
declare function envelopeCodeToStatus(code: string): number;
|
|
463
464
|
|
|
465
|
+
/**
|
|
466
|
+
* Render `<link rel="modulepreload">` for the chunks a route needs beyond the entry (B-035).
|
|
467
|
+
*
|
|
468
|
+
* **The single source of truth, for the Node server AND the Cloudflare worker.**
|
|
469
|
+
*
|
|
470
|
+
* An earlier revision of this file asserted that the worker had to carry a COPY because
|
|
471
|
+
* `theokit`'s package exports declare no subpath reaching `core/`. **That was false, and it was
|
|
472
|
+
* stated three times** — here, in `adapters/cloudflare.ts`, and in a commit message. `server/
|
|
473
|
+
* index.ts` already re-exports from `core/contracts/` *"for consumer ergonomics"* in its own
|
|
474
|
+
* words, `adapters/security-headers.ts` imports `generateNonce` and `buildSecurityHeaders` from
|
|
475
|
+
* here, and the generated worker imports BOTH of those subpaths. Adding a named export to an
|
|
476
|
+
* existing barrel touches no `package.json`, so the constraint never existed.
|
|
477
|
+
*
|
|
478
|
+
* The copy is gone. `theokit/server` re-exports `injectModulePreloads` and the worker imports it,
|
|
479
|
+
* which is the shape `adapters/security-headers.ts` established one directory over — and whose
|
|
480
|
+
* docblock states the reason better than this one could: *"a shape stated in two files drifts"*.
|
|
481
|
+
* It drifted the same day: the proxy fix below landed in this file and not in the copy.
|
|
482
|
+
*/
|
|
483
|
+
/** A route path mapped to the chunk file names it needs beyond the entry. */
|
|
484
|
+
type AssetsMap = Record<string, string[] | undefined>;
|
|
485
|
+
declare function injectModulePreloads(head: string, assetsMap: AssetsMap | undefined, url: string): string;
|
|
486
|
+
|
|
464
487
|
/**
|
|
465
488
|
* Canonical error handler for HTTP request pipelines (T3.4 of
|
|
466
489
|
* architecture-review-remediation-plan, PV-9 DRY).
|
|
@@ -521,6 +544,32 @@ interface MiddlewareResult {
|
|
|
521
544
|
aborted: boolean;
|
|
522
545
|
}
|
|
523
546
|
declare function _resetMiddlewareCacheForTests(): void;
|
|
547
|
+
/**
|
|
548
|
+
* Run a Web-shaped middleware — the one `middleware()` and `defineMiddleware()` produce (#345).
|
|
549
|
+
*
|
|
550
|
+
* This used to REFUSE the shape by name, because the runner could only invoke `(req, res, next)`
|
|
551
|
+
* and calling a Web handler that way hands it `res` as its `next`. Refusing was better than the
|
|
552
|
+
* blank response it replaced, and it was never the end state: the README documented the builder as
|
|
553
|
+
* the way to write middleware, so the documented path was loud instead of silent, but still broken.
|
|
554
|
+
*
|
|
555
|
+
* It runs now because the published contract became the one that fits this model:
|
|
556
|
+
* `(request, context) => Response | void`. No continuation is needed — returning a `Response`
|
|
557
|
+
* answers the request, returning nothing continues — which is exactly what a runner that executes
|
|
558
|
+
* BEFORE routing can honestly offer.
|
|
559
|
+
*
|
|
560
|
+
* The `Request` is built by the same converter the agent and action branches use, so a middleware
|
|
561
|
+
* reads the request the way every other Web-shaped surface in the framework does.
|
|
562
|
+
*/
|
|
563
|
+
/**
|
|
564
|
+
* Raised when a `server/middleware/*.ts` middleware awaits `next`.
|
|
565
|
+
*
|
|
566
|
+
* Typed rather than a bare `Error` so a caller can tell this apart from a failure inside the
|
|
567
|
+
* middleware's own body — `rules/error-handling.md` § 2, and the same shape as
|
|
568
|
+
* `http/in-process-caller.ts`'s three.
|
|
569
|
+
*/
|
|
570
|
+
declare class MiddlewareNextUnavailableError extends Error {
|
|
571
|
+
constructor();
|
|
572
|
+
}
|
|
524
573
|
declare function runMiddlewareAndContext(req: IncomingMessage, res: ServerResponse, loadModule: LoadModule, serverDir: string): Promise<MiddlewareResult>;
|
|
525
574
|
/**
|
|
526
575
|
* Run ONLY the application's `server/context.ts` factory and return what it produced.
|
|
@@ -647,8 +696,30 @@ declare function serveStaticFile(req: IncomingMessage, res: ServerResponse, clie
|
|
|
647
696
|
* Full semantic parity with the Node `defineMiddleware` contract is part of the
|
|
648
697
|
* deferred Node→Web pipeline convergence, not this slice.
|
|
649
698
|
*/
|
|
650
|
-
|
|
651
|
-
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* Run the rest of the chain and resolve to what it produced.
|
|
702
|
+
*
|
|
703
|
+
* An ALIAS, not a second declaration. The two lived as separate structurally
|
|
704
|
+
* identical types before this change and were measured on 2026-09-19 to be
|
|
705
|
+
* incompatible the moment either moved — `MiddlewareHandler` admits
|
|
706
|
+
* `Promise<void>` and `WebMiddleware` did not, so the builder's output was not
|
|
707
|
+
* assignable to the runner's parameter and `tsc` said so in SEVERAL errors that no
|
|
708
|
+
* test could see. (This said "15" until review: control gives 0, an isolated revert 3, a full
|
|
709
|
+
* revert 14, and no reconstruction gives 15 — it was measured on an uncommitted tree and
|
|
710
|
+
* published as a measurement. The mechanism holds; the figure did not, and a figure in a code
|
|
711
|
+
* comment outlives the CHANGELOG entry that carried the same one.) Two names for one contract is how that happens.
|
|
712
|
+
*/
|
|
713
|
+
type WebNext = MiddlewareNext;
|
|
714
|
+
/**
|
|
715
|
+
* A Web-path middleware: mutate `context`, return a `Response`, or call `next`.
|
|
716
|
+
*
|
|
717
|
+
* `next` is OPTIONAL in the parameter list so every middleware written against
|
|
718
|
+
* the two-parameter shape keeps compiling and keeps behaving identically — see
|
|
719
|
+
* `docs/adr/0006` clause 5, which rests that claim on a measured call site
|
|
720
|
+
* rather than on confidence.
|
|
721
|
+
*/
|
|
722
|
+
type WebMiddleware = (request: Request, context: Record<string, unknown>, next: WebNext) => Response | undefined | void | Promise<Response | undefined | void>;
|
|
652
723
|
|
|
653
724
|
/**
|
|
654
725
|
* The route module exported by a `server/routes/*.ts` file (after T2.6 G6
|
|
@@ -907,4 +978,4 @@ interface OpenApiDocsOptions {
|
|
|
907
978
|
*/
|
|
908
979
|
declare function createOpenApiHandler(opts?: OpenApiDocsOptions): (request: Request) => Response | null;
|
|
909
980
|
|
|
910
|
-
export {
|
|
981
|
+
export { extractTraceId as $, appendCookieToHeaders as A, BATCH_PATH as B, type CookieOptions as C, appendDeleteCookieToHeaders as D, type ExecuteActionOptions as E, FileTooLargeError as F, callProcedure as G, type HandleBatchOptions as H, createCorsHandler as I, createCorsWebHandler as J, createOpenApiHandler as K, createServerContext as L, MAX_ERROR_HTML_BYTES as M, NotFoundError as N, type OpenApiDocsOptions as O, type ParsedBody as P, deleteCookie as Q, type RawRouteInput as R, STRIPPED_HEADERS as S, TRACE_HEADER as T, type UploadedFile as U, envelopeCodeToStatus as V, type W3CTraceContext as W, executeAction as X, executeRoute as Y, executeWebRequest as Z, _resetMiddlewareCacheForTests as _, type BatchExecuteFn as a, extractTraceIdFromRequest as a0, extractW3CTraceContext as a1, fromUnknown as a2, getCookie as a3, getCookieFromRequest as a4, handleBatchRequest as a5, handleRequestError as a6, handleWebRequestError as a7, injectModulePreloads as a8, jsonTransformer as a9, loadCustomErrorPages as aa, matchesOrigin as ab, parseCookieHeader as ac, parseRequestBody as ad, parseTraceparent as ae, parseTraceparentContext as af, resolveTransformer as ag, runMiddlewareAndContext as ah, sendError as ai, sendJson as aj, serializeCookie as ak, serveStaticFile as al, serverErrorToEnvelope as am, setCookie as an, superjsonTransformer as ao, validateRouteInput as ap, BatchPathConflictError as b, type BatchPayload as c, type BatchRequestItem as d, type BatchResponse as e, type BatchResultItem as f, type BodyParserOptions as g, type CorsConfig as h, type CorsHandler as i, type CorsOrigin as j, type CorsWebHandler as k, type CustomErrorPages as l, type ExecuteRouteContext as m, MiddlewareNextUnavailableError as n, type MiddlewareResult as o, type ProcedureInput as p, ProcedureInputError as q, ProcedureOutputError as r, type RouteInputChannel as s, type RouteInputSchemas as t, type RouteInputValidation as u, type SendErrorInput as v, type SendErrorOptions as w, TRACE_PARENT_HEADER as x, TheoError as y, type TheoTransformer as z };
|
package/dist/index.js
CHANGED
|
@@ -8,21 +8,22 @@ import {
|
|
|
8
8
|
scanRoutes,
|
|
9
9
|
theoConfigSchema,
|
|
10
10
|
theoPlugin
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-QVXMAHZC.js";
|
|
12
12
|
import "./chunk-7NRFZBAL.js";
|
|
13
13
|
import "./chunk-SSYDEKWF.js";
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-425FJKKO.js";
|
|
15
|
+
import "./chunk-BDPD5HEO.js";
|
|
16
|
+
import "./chunk-MOGTMGGA.js";
|
|
16
17
|
import "./chunk-OIGJOYX6.js";
|
|
17
18
|
import "./chunk-U3SPBLJF.js";
|
|
18
19
|
import "./chunk-WSOAN4KN.js";
|
|
19
20
|
import "./chunk-ENSFCKP6.js";
|
|
20
21
|
import "./chunk-OGLS76RN.js";
|
|
21
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-SRJBH5E5.js";
|
|
23
|
+
import "./chunk-3T5XLDOH.js";
|
|
22
24
|
import "./chunk-P6OS7652.js";
|
|
23
25
|
import "./chunk-ZDUO4IYN.js";
|
|
24
|
-
import "./chunk-
|
|
25
|
-
import "./chunk-ENRT6DAU.js";
|
|
26
|
+
import "./chunk-IDWN2OSG.js";
|
|
26
27
|
import "./chunk-47FFT43U.js";
|
|
27
28
|
import "./chunk-NTDN54XO.js";
|
|
28
29
|
import "./chunk-PVNMLZ5G.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/config/define-config.ts","../src/config/config-builder.ts","../src/config/validate-structure.ts","../src/core/errors.ts"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/config/define-config.ts","../src/config/config-builder.ts","../src/config/validate-structure.ts","../src/core/errors.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOO,SAAS,aAAaA,SAAkD;AAC7E,SAAOA;AACT;;;ACuCA,SAAS,kBAAkB,MAA0C;AACnE,QAAM,QAAQ,CAAC,UACb,kBAAkB,EAAE,GAAG,MAAM,GAAG,MAAM,CAAC;AACzC,SAAO;AAAA,IACL,MAAM,CAAC,UAAU,MAAM,EAAE,MAAM,MAAM,CAAC;AAAA,IACtC,WAAW,CAAC,UAAU,MAAM,EAAE,WAAW,MAAM,CAAC;AAAA,IAChD,QAAQ,CAAC,UAAU,MAAM,EAAE,QAAQ,MAAM,CAAC;AAAA,IAC1C,WAAW,CAAC,UAAU,MAAM,EAAE,WAAW,MAAM,CAAC;AAAA,IAChD,SAAS,CAAC,UAAU,MAAM,EAAE,SAAS,M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AAc;AAC/B,QAAI,CAAC,WAAW,KAAK,SAAS,KAAK,IAAI,CAAC,GAAG;AACzC,aAAO,KAAK,KAAK,YAAY;AAAA,IAC/B;AAAA,EACF;AAEA,aAAW,QAAQ,gBAAgB;AACjC,QAAI,CAAC,WAAW,KAAK,SAAS,KAAK,IAAI,CAAC,GAAG;AACzC,aAAO,KAAK,KAAK,YAAY;AAAA,IAC/B;AAAA,EACF;AAEA,MAAI,OAAO,SAAS,GAAG;AACrB,UAAM,IAAI,iBAAiB,QAAQ,OAAO;AAAA,EAC5C;AACF;","names":["config"]}
|
|
@@ -16,10 +16,10 @@ import {
|
|
|
16
16
|
handleCspReport,
|
|
17
17
|
handleCsrfReadiness,
|
|
18
18
|
mountAgent
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-SJ4AW54X.js";
|
|
20
20
|
import {
|
|
21
21
|
resolveProvider
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-BINRCILF.js";
|
|
23
23
|
import {
|
|
24
24
|
dispatchControllerRequest,
|
|
25
25
|
incomingMessageToHandlerRequest,
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
import {
|
|
32
32
|
TRACE_HEADER,
|
|
33
33
|
extractTraceId
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-MS4A7N77.js";
|
|
35
35
|
import {
|
|
36
36
|
logRequest
|
|
37
37
|
} from "./chunk-C27VRUVN.js";
|
|
@@ -87,4 +87,4 @@ export {
|
|
|
87
87
|
scanWebSocketRoutes,
|
|
88
88
|
sendError
|
|
89
89
|
};
|
|
90
|
-
//# sourceMappingURL=internal-api-
|
|
90
|
+
//# sourceMappingURL=internal-api-CEZSXGRB.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
dispatchControllerRequest
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-425FJKKO.js";
|
|
4
4
|
import {
|
|
5
5
|
mountAgent
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-MOGTMGGA.js";
|
|
7
7
|
import {
|
|
8
8
|
CSP_REPORT_PATH,
|
|
9
9
|
CsrfReadinessStore,
|
|
@@ -17,14 +17,15 @@ import {
|
|
|
17
17
|
createCorsHandler,
|
|
18
18
|
executeAction,
|
|
19
19
|
executeRoute,
|
|
20
|
-
handleBatchRequest
|
|
20
|
+
handleBatchRequest
|
|
21
|
+
} from "./chunk-SRJBH5E5.js";
|
|
22
|
+
import {
|
|
21
23
|
incomingMessageToHandlerRequest,
|
|
22
24
|
sendError
|
|
23
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-3T5XLDOH.js";
|
|
24
26
|
import "./chunk-P6OS7652.js";
|
|
25
27
|
import "./chunk-ZDUO4IYN.js";
|
|
26
|
-
import "./chunk-
|
|
27
|
-
import "./chunk-ENRT6DAU.js";
|
|
28
|
+
import "./chunk-IDWN2OSG.js";
|
|
28
29
|
import "./chunk-47FFT43U.js";
|
|
29
30
|
import {
|
|
30
31
|
findSuggestion
|
|
@@ -107,4 +108,4 @@ export {
|
|
|
107
108
|
scanWebSocketRoutes,
|
|
108
109
|
sendError
|
|
109
110
|
};
|
|
110
|
-
//# sourceMappingURL=internal-api-
|
|
111
|
+
//# sourceMappingURL=internal-api-XRIBUACB.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
interface ServerRouteNode {
|
|
2
|
+
filePath: string;
|
|
3
|
+
routePath: string;
|
|
4
|
+
paramNames: string[];
|
|
5
|
+
pattern: RegExp;
|
|
6
|
+
/** HTTP methods (uppercase) the route file exports. Optional for backward
|
|
7
|
+
* compatibility with manifests generated before G1. Empty array means the
|
|
8
|
+
* file has no HTTP exports (util-only); undefined means "not detected". */
|
|
9
|
+
methods?: string[];
|
|
10
|
+
/**
|
|
11
|
+
* The subset of `methods` whose policy is the literal `'public'` (ADR 0001).
|
|
12
|
+
*
|
|
13
|
+
* `undefined` means "not detected" — a manifest built before the field existed — and is NOT the
|
|
14
|
+
* same as `[]`, which means "detected, and nothing is public". `public-exposure-gate.ts` depends
|
|
15
|
+
* on that distinction: reading absence as safety is the failure it exists to prevent.
|
|
16
|
+
*/
|
|
17
|
+
publicMethods?: string[];
|
|
18
|
+
}
|
|
19
|
+
declare function compilePattern(routePath: string): {
|
|
20
|
+
pattern: RegExp;
|
|
21
|
+
paramNames: string[];
|
|
22
|
+
};
|
|
23
|
+
declare function matchRoute(url: string, routes: ServerRouteNode[]): {
|
|
24
|
+
route: ServerRouteNode;
|
|
25
|
+
params: Record<string, string>;
|
|
26
|
+
} | null;
|
|
27
|
+
|
|
28
|
+
export { type ServerRouteNode as S, compilePattern as c, matchRoute as m };
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import "tsx/esm";
|
|
3
3
|
import {
|
|
4
4
|
createAgentSsrLoader
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-TJPENLGQ.js";
|
|
6
6
|
import {
|
|
7
7
|
extractAppResources,
|
|
8
8
|
handleMcpJsonRpc
|
|
9
9
|
} from "./chunk-BDH5GKFZ.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-BINRCILF.js";
|
|
11
11
|
import {
|
|
12
12
|
scanAgents
|
|
13
13
|
} from "./chunk-5NNFO7R7.js";
|
|
@@ -75,4 +75,4 @@ async function mcpCommand(name, deps = {}) {
|
|
|
75
75
|
export {
|
|
76
76
|
mcpCommand
|
|
77
77
|
};
|
|
78
|
-
//# sourceMappingURL=mcp-
|
|
78
|
+
//# sourceMappingURL=mcp-S2AOB3RE.js.map
|