@guren/server 2.28.0 → 2.29.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guren/server",
3
- "version": "2.28.0",
3
+ "version": "2.29.0",
4
4
  "description": "HTTP layer of the Guren framework, on Hono: routing, controllers, middleware, auth, sessions, queues and the AWS Lambda adapter. Applications import it through @guren/core.",
5
5
  "keywords": [
6
6
  "guren",
@@ -164,13 +164,13 @@
164
164
  "test": "bun test"
165
165
  },
166
166
  "dependencies": {
167
- "@guren/orm": "^2.13.0",
167
+ "@guren/orm": "^2.13.1",
168
168
  "chalk": "^5.3.0",
169
169
  "consola": "^3.4.2",
170
170
  "figlet": "^1.7.0",
171
171
  "hono": "^4.13.7",
172
172
  "ioredis": "^5.11.1",
173
- "nodemailer": "^9.1.1"
173
+ "nodemailer": "^10.0.2"
174
174
  },
175
175
  "peerDependencies": {
176
176
  "@aws-sdk/client-s3": "^3.0.0",
@@ -1,26 +0,0 @@
1
- import { t as createLoopbackGuard } from "./loopback-guard-CG8xB4v0.js";
2
- //#region src/mcp/endpoint.ts
3
- const MCP_ENDPOINT_PATH = "/_guren/mcp";
4
- /**
5
- * Whether the MCP endpoint is mounted: opt-in via `GUREN_MCP=1`, never in
6
- * production (it exposes project introspection and code generation). The env
7
- * reads are plain member access on purpose: the deploy plugins settle NODE_ENV
8
- * with `--define`, which matches one exact expression, so an optional chain
9
- * leaves a runtime read that reopens the gate on workerd; `tests/mcp/endpoint.test.ts` pins the form.
10
- */
11
- function isMcpEndpointEnabled() {
12
- if (typeof process === "undefined") return false;
13
- if (process.env.NODE_ENV === "production") return false;
14
- return process.env.GUREN_MCP === "1";
15
- }
16
- /**
17
- * Restricts the MCP endpoint to the developer's own machine. The endpoint is
18
- * CSRF-exempt (agent clients carry no token), so this guard takes over: a web
19
- * page is rejected unless its `Origin` is loopback, and every caller unless its
20
- * socket peer is. It fails closed when the runtime reports no peer at all.
21
- */
22
- function createMcpAccessGuard() {
23
- return createLoopbackGuard("the MCP endpoint");
24
- }
25
- //#endregion
26
- export { createMcpAccessGuard as n, isMcpEndpointEnabled as r, MCP_ENDPOINT_PATH as t };
@@ -1,146 +0,0 @@
1
- import { a as trimTrailingSlashes } from "./contained-path-BkNSBljW.js";
2
- import { resolve } from "node:path";
3
- import { readFileSync } from "node:fs";
4
- //#region src/http/vite-dev-server.ts
5
- /**
6
- * Build the inline config the managed dev server starts with. `server.host` is
7
- * left undefined unless asked for, so Vite's config merge drops it and the
8
- * project's own `vite.config.ts` decides.
9
- */
10
- function resolveViteDevServerConfig(options = {}) {
11
- const { root = process.cwd(), config = {}, host, port } = options;
12
- return {
13
- clearScreen: false,
14
- ...config,
15
- root: config.root ?? root,
16
- server: {
17
- host,
18
- port,
19
- ...config.server
20
- }
21
- };
22
- }
23
- async function startViteDevServer(options = {}) {
24
- const { host, port } = options;
25
- const { createServer } = await import("vite");
26
- const server = await createServer(resolveViteDevServerConfig(options));
27
- await server.listen();
28
- const resolved = server.resolvedUrls;
29
- const localUrls = resolved?.local?.length ? resolved.local : [`http://${typeof host === "string" ? host : "localhost"}:${server.config.server.port ?? port ?? 5173}`];
30
- const networkUrls = resolved?.network ?? [];
31
- return {
32
- server,
33
- localUrl: localUrls[0],
34
- networkUrls
35
- };
36
- }
37
- //#endregion
38
- //#region src/http/vite-manifest.ts
39
- /**
40
- * The one rule for how Vite build output is found and addressed, shared by the
41
- * Inertia asset wiring (`inertia-assets.ts`) and `viteAsset()` (`vite-assets.ts`,
42
- * RFC 0014) so the two cannot drift: what counts as a manifest, where one may
43
- * live, which URL prefix serves the hashed files, and what "the dev server is
44
- * on" means.
45
- */
46
- /**
47
- * Where `configureInertiaAssets` serves hashed build output from. The deploy
48
- * builds restate it as `CLIENT_ASSETS_URL_PREFIX` in @guren/core's
49
- * internal/deploy-build.ts; tests/http/vite-manifest.test.ts pins the two equal.
50
- */
51
- const PUBLIC_ASSETS_URL_PREFIX = "/public/assets/";
52
- /** The Vite default the framework assumes when no dev-server URL is set. */
53
- const DEFAULT_DEV_SERVER_URL = "http://localhost:5173";
54
- /**
55
- * Production for *asset* purposes: `NODE_ENV` says so and no dev server is
56
- * configured — a configured dev server means dev asset serving even when
57
- * `NODE_ENV` is `production` (E2E runs do exactly this).
58
- */
59
- function isViteProduction(devServerUrl = process.env.VITE_DEV_SERVER_URL) {
60
- return process.env.NODE_ENV === "production" && typeof devServerUrl !== "string";
61
- }
62
- function normalizeDevServerUrl(value) {
63
- if (!value) return value;
64
- const trimmed = value.trim();
65
- if (!trimmed) return trimmed;
66
- const stripped = trimTrailingSlashes(trimmed);
67
- return stripped.length > 0 ? stripped : "/";
68
- }
69
- /**
70
- * Candidate client-manifest locations, `.vite/manifest.json` first: Vite >= 5
71
- * writes it there, so a flat `manifest.json` is likely a stale leftover. The
72
- * deploy plugins order the same pair through `@guren/core`'s deploy-build
73
- * helpers and must agree, or an app with both layouts resolves different asset
74
- * versions after a serverless deploy; `tests/http/vite-manifest.test.ts` pins it.
75
- */
76
- function clientManifestCandidates(baseDir) {
77
- const root = baseDir ?? process.cwd();
78
- return [resolve(root, "public/assets/.vite/manifest.json"), resolve(root, "public/assets/manifest.json")];
79
- }
80
- /**
81
- * `__path__` label for an injected manifest, so "entry not in the manifest"
82
- * errors name the real source rather than a path that was never read.
83
- */
84
- const INJECTED_CLIENT_MANIFEST_SOURCE = "GUREN_VITE_MANIFEST (injected by the deploy build)";
85
- const INJECTED_MANIFEST_HINT = "It must hold the Vite client manifest text (deploy plugins inject it at build time), not a path.";
86
- /**
87
- * Attach one of the manifest's bookkeeping fields. `enumerable: false` is the
88
- * invariant: a stamped field must never leak into `Object.keys` or a
89
- * re-serialization of the manifest.
90
- */
91
- function defineHidden(manifest, key, value) {
92
- Object.defineProperty(manifest, key, {
93
- value,
94
- enumerable: false
95
- });
96
- }
97
- /**
98
- * The client manifest a deploy build injected for runtimes that do not ship
99
- * `public/assets/manifest.json`: `GUREN_VITE_MANIFEST` holds the manifest *JSON
100
- * text*, not a path. Fails loudly on a value that is set but not a manifest,
101
- * because falling through to the filesystem would end in "run `bunx vite build`"
102
- * — a diagnosis pointing away from the variable that is actually broken.
103
- */
104
- function injectedClientManifest() {
105
- const raw = process.env.GUREN_VITE_MANIFEST;
106
- if (typeof raw !== "string" || raw.length === 0) return;
107
- let parsed;
108
- try {
109
- parsed = JSON.parse(raw);
110
- } catch (error) {
111
- throw new Error(`GUREN_VITE_MANIFEST is set but is not valid JSON. ${INJECTED_MANIFEST_HINT}`, { cause: error });
112
- }
113
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error(`GUREN_VITE_MANIFEST is set but does not hold a manifest object. ${INJECTED_MANIFEST_HINT}`);
114
- const manifest = parsed;
115
- defineHidden(manifest, "__path__", INJECTED_CLIENT_MANIFEST_SOURCE);
116
- return manifest;
117
- }
118
- function loadViteManifest(candidatePaths, label, options = {}) {
119
- const warnOnMissing = options.warnOnMissing ?? true;
120
- const command = label === "SSR" ? "bunx vite build --ssr" : "bunx vite build";
121
- for (const manifestPath of candidatePaths) try {
122
- const raw = readFileSync(manifestPath, "utf8");
123
- const manifest = JSON.parse(raw);
124
- defineHidden(manifest, "__path__", manifestPath);
125
- if (options.includeRaw) defineHidden(manifest, "__raw__", raw);
126
- return manifest;
127
- } catch (error) {
128
- if (error.code !== "ENOENT") {
129
- console.warn(`Unable to load ${label} Vite manifest at ${manifestPath}.`, error);
130
- return;
131
- }
132
- }
133
- if (warnOnMissing && candidatePaths.length) console.warn(`Unable to load ${label} Vite manifest. Checked paths:\n${candidatePaths.map((p) => ` - ${p}`).join("\n")}\nRun \`${command}\` before starting in production.`);
134
- }
135
- function getManifestFile(entry) {
136
- if (!entry) return;
137
- if (Array.isArray(entry)) return entry[0];
138
- if (typeof entry === "string") return entry;
139
- if ("file" in entry && typeof entry.file === "string") return entry.file;
140
- }
141
- function getManifestCss(entry) {
142
- if (!entry || Array.isArray(entry) || typeof entry === "string") return;
143
- return entry.css;
144
- }
145
- //#endregion
146
- export { getManifestCss as a, isViteProduction as c, startViteDevServer as d, clientManifestCandidates as i, loadViteManifest as l, INJECTED_CLIENT_MANIFEST_SOURCE as n, getManifestFile as o, PUBLIC_ASSETS_URL_PREFIX as r, injectedClientManifest as s, DEFAULT_DEV_SERVER_URL as t, normalizeDevServerUrl as u };