@guren/plugin-lambda 0.6.1 → 0.7.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.
@@ -1,10 +1,9 @@
1
1
  import { n as LAMBDA_HANDLER_MODULE, t as LAMBDA_HANDLER_EXPORTS } from "./handlers-Dtt3k5Ue.js";
2
2
  import { cpSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
3
  import { resolve } from "node:path";
4
- import { MCP_SDK_SUBPATH_PREFIX, appUsesMcpPlugin, assertOutputDirOutsideRoot, bundledRuntimeEnv, importSpecifier, renderDevOnlyStub, resetOutputDir, resolveClientAssetEnv, resolvePathLike, resolveSsrEntryFile, ssrRuntimePaths, stageStaticAssets, stubbableDevOnlyModules, unusedSqlClients } from "@guren/core/internal/deploy-build";
4
+ import { DEV_ONLY_MODULES, assertOutputDirOutsideRoot, bundledRuntimeEnv, importSpecifier, renderDevOnlyStub, resetOutputDir, resolveClientAssetEnv, resolvePathLike, resolveSsrEntryFile, ssrRuntimePaths, stageStaticAssets, unusedSqlClients } from "@guren/core/internal/deploy-build";
5
5
  import { reportDeployRuntimeHazards } from "@guren/core/internal/deploy-check";
6
6
  //#region src/build.ts
7
- const MCP_UNAVAILABLE = "The MCP endpoint is unavailable on AWS Lambda — it generates files on disk.";
8
7
  /**
9
8
  * Why the dev-only modules in `DEV_ONLY_MODULES` cannot run here, each naming
10
9
  * the Lambda-appropriate replacement. Keyed only on the kinds this platform
@@ -14,17 +13,15 @@ const MCP_UNAVAILABLE = "The MCP endpoint is unavailable on AWS Lambda — it ge
14
13
  const UNAVAILABLE_ON_LAMBDA = {
15
14
  sqlite: "bun:sqlite is unavailable on AWS Lambda — use createAwsDataApiDatabase() or createPostgresDatabase().",
16
15
  vite: "The Vite dev server is unavailable on AWS Lambda — serve assets from S3/CloudFront.",
17
- mcp: MCP_UNAVAILABLE
16
+ mcp: "The Dev MCP endpoint and docs viewer (@guren/cli) are unavailable on AWS Lambda — they read and generate files on disk."
18
17
  };
19
18
  /**
20
19
  * Stubs rather than externals: inlining a lazily-imported module hoists its
21
- * static imports to the bundle top level, so an external reached that way (the
22
- * MCP SDK) fails at import time though no code path runs it. An app declaring
23
- * `@guren/plugin-mcp` serves the endpoint here, so its transport must reach the
24
- * bundle (RFC 0016 §7) — `stubbableDevOnlyModules` owns that split.
20
+ * static imports to the bundle top level, so an external reached that way fails
21
+ * at import time though no code path runs it.
25
22
  */
26
- function devOnlyStubs(mcpPlugin) {
27
- return Object.fromEntries(stubbableDevOnlyModules({ mcpPlugin }).map((module) => [module.specifier, renderDevOnlyStub(module, UNAVAILABLE_ON_LAMBDA[module.kind])]));
23
+ function devOnlyStubs() {
24
+ return Object.fromEntries(DEV_ONLY_MODULES.map((module) => [module.specifier, renderDevOnlyStub(module, UNAVAILABLE_ON_LAMBDA[module.kind])]));
28
25
  }
29
26
  /**
30
27
  * The dev-only stubs plus one per database client this app does not connect
@@ -33,32 +30,22 @@ function devOnlyStubs(mcpPlugin) {
33
30
  * `@aws-sdk/client-rds-data` for a Postgres app really does replace drizzle's
34
31
  * hoisted top-level import of it.
35
32
  */
36
- function stubsFor(root, dialects, mcpPlugin) {
33
+ function stubsFor(root, dialects) {
37
34
  const unused = unusedSqlClients({
38
35
  root,
39
36
  label: "Lambda build",
40
37
  dialects
41
38
  });
42
39
  return {
43
- ...devOnlyStubs(mcpPlugin),
40
+ ...devOnlyStubs(),
44
41
  ...Object.fromEntries(unused.map(({ module, message }) => [module.specifier, renderDevOnlyStub(module, message)]))
45
42
  };
46
43
  }
47
- /**
48
- * Fallback for an MCP SDK subpath `DEV_ONLY_MODULES` does not name. It cannot
49
- * know which names the importer destructures, so it throws on evaluation rather
50
- * than handing back missing exports. Reachable only for an app that does *not*
51
- * declare `@guren/plugin-mcp`, whose statically imported `server/index.js` and
52
- * `types.js` it would otherwise stub shut — see `stubFilter`.
53
- */
54
- const unlistedMcpStub = `throw new Error(${JSON.stringify(MCP_UNAVAILABLE)})\n`;
55
44
  function escapeRegExp(value) {
56
45
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
57
46
  }
58
- function stubFilter(stubs, mcpPlugin) {
59
- const terms = Object.keys(stubs).map(escapeRegExp);
60
- if (!mcpPlugin) terms.push(`${escapeRegExp(MCP_SDK_SUBPATH_PREFIX)}.+`);
61
- return new RegExp(`^(?:${terms.join("|")})$`);
47
+ function stubFilter(stubs) {
48
+ return new RegExp(`^(?:${Object.keys(stubs).map(escapeRegExp).join("|")})$`);
62
49
  }
63
50
  /**
64
51
  * Assemble a deployable AWS Lambda directory (`.lambda/`) from a built Guren
@@ -99,8 +86,7 @@ async function buildLambdaOutput(options = {}) {
99
86
  entrypoint,
100
87
  env: bakedEnv
101
88
  }));
102
- const mcpPlugin = appUsesMcpPlugin(root);
103
- await bundleHandler(wrapperPath, funcDir, stubsFor(root, options.databaseDialects, mcpPlugin), mcpPlugin);
89
+ await bundleHandler(wrapperPath, funcDir, stubsFor(root, options.databaseDialects));
104
90
  writeFileSync(resolve(funcDir, "package.json"), `${JSON.stringify({ type: "module" }, null, 2)}\n`);
105
91
  if (ssrFile) cpSync(ssrDir, resolve(funcDir, ".guren/ssr"), { recursive: true });
106
92
  if (existsSync(migrationsDir)) cpSync(migrationsDir, resolve(funcDir, "db/migrations"), { recursive: true });
@@ -131,8 +117,8 @@ function renderHandlerModule(input) {
131
117
  lines.push("");
132
118
  return lines.join("\n");
133
119
  }
134
- async function bundleHandler(handlerEntry, funcDir, stubs, mcpPlugin) {
135
- const filter = stubFilter(stubs, mcpPlugin);
120
+ async function bundleHandler(handlerEntry, funcDir, stubs) {
121
+ const filter = stubFilter(stubs);
136
122
  const result = await Bun.build({
137
123
  entrypoints: [handlerEntry],
138
124
  throw: false,
@@ -159,7 +145,7 @@ async function bundleHandler(handlerEntry, funcDir, stubs, mcpPlugin) {
159
145
  filter: /.*/,
160
146
  namespace: "guren-lambda-stub"
161
147
  }, (args) => ({
162
- contents: stubs[args.path] ?? unlistedMcpStub,
148
+ contents: stubs[args.path],
163
149
  loader: "js"
164
150
  }));
165
151
  }
package/dist/commands.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as buildLambdaOutput } from "./build-CDHl9ytl.js";
1
+ import { t as buildLambdaOutput } from "./build-Dc1x5-hH.js";
2
2
  import { DATABASE_DIALECTS, parseDatabaseDialects } from "@guren/core/internal/deploy-build";
3
3
  import { defineCommand } from "citty";
4
4
  var commands_default = { "lambda:build": defineCommand({
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { n as LAMBDA_HANDLER_MODULE, r as lambdaHandlerId, t as LAMBDA_HANDLER_EXPORTS } from "./handlers-Dtt3k5Ue.js";
2
- import { t as buildLambdaOutput } from "./build-CDHl9ytl.js";
2
+ import { t as buildLambdaOutput } from "./build-Dc1x5-hH.js";
3
3
  import { definePlugin } from "@guren/core";
4
4
  //#region src/session/dynamodb-store.ts
5
5
  var DynamoDbSessionStore = class {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guren/plugin-lambda",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -53,7 +53,7 @@
53
53
  "typecheck": "tsc --noEmit"
54
54
  },
55
55
  "dependencies": {
56
- "@guren/core": "^1.19.0",
56
+ "@guren/core": "^1.20.0",
57
57
  "citty": "^0.1.6"
58
58
  },
59
59
  "peerDependencies": {