@guren/core 1.12.0 → 1.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.d.ts +1 -0
- package/dist/agent.js +2 -0
- package/dist/index.d.ts +174 -429
- package/dist/index.js +165 -395
- package/dist/internal/deploy-build.d.ts +123 -196
- package/dist/internal/deploy-build.js +166 -279
- package/package.json +8 -4
|
@@ -7,59 +7,34 @@ type ManifestEntry = {
|
|
|
7
7
|
type Manifest = Record<string, ManifestEntry>;
|
|
8
8
|
declare function resolvePathLike(value: PathLike): string;
|
|
9
9
|
/**
|
|
10
|
-
* Read the first manifest that parses,
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* is part of the result because a caller publishing the manifest location to
|
|
15
|
-
* the runtime has to name the file that was actually parsed: testing which one
|
|
16
|
-
* *exists* picks the malformed one that was just skipped.
|
|
10
|
+
* Read the first manifest that parses, in either Vite layout (`.vite/manifest.json`,
|
|
11
|
+
* then flat `manifest.json`), and report its path: a caller publishing the location
|
|
12
|
+
* must name the file actually parsed, not the malformed one that was skipped. What a
|
|
13
|
+
* missing manifest means is the caller's call.
|
|
17
14
|
*/
|
|
18
15
|
declare function readManifest(...paths: string[]): {
|
|
19
16
|
manifest: Manifest;
|
|
20
17
|
path: string;
|
|
21
18
|
} | undefined;
|
|
22
19
|
/**
|
|
23
|
-
* Throw unless `out` is safe to delete:
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* delete that follows resolves the links regardless.
|
|
29
|
-
*
|
|
30
|
-
* Containment is then decided with `relative` rather than a string prefix
|
|
31
|
-
* because `out + sep` is `//` at the filesystem root, which no absolute path
|
|
32
|
-
* is prefixed by — a prefix test lets `outputDir: '/'` through. The escape
|
|
33
|
-
* test is `'..'` exactly or a `'../'` prefix, not `startsWith('..')`: a
|
|
34
|
-
* directory legitimately named `..-source` inside `out` yields the relative
|
|
35
|
-
* path `..-source`, which the looser test would read as an escape.
|
|
36
|
-
*
|
|
37
|
-
* Exported separately from `resetOutputDir` so a caller can validate the
|
|
38
|
-
* option early and delete later, but the delete itself should always go
|
|
39
|
-
* through `resetOutputDir`.
|
|
40
|
-
*
|
|
41
|
-
* @param label Platform name for the error message, e.g. `'Lambda build'`.
|
|
20
|
+
* Throw unless `out` is safe to delete: neither the app root nor a directory
|
|
21
|
+
* containing it. Both paths are canonicalized (a lexical compare accepts an
|
|
22
|
+
* `outputDir` that reaches the root through links). Containment uses `relative`,
|
|
23
|
+
* not a prefix test (`out + sep` is `//` at the root, letting `'/'` through), and
|
|
24
|
+
* escape means `'..'` or a `'../'` prefix, so `..-source` inside `out` is not one.
|
|
42
25
|
*/
|
|
43
26
|
declare function assertOutputDirOutsideRoot(out: string, root: string, label: string): void;
|
|
44
27
|
/**
|
|
45
|
-
* Delete the output directory
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* The check and the delete are one call on purpose: they were separate
|
|
49
|
-
* statements in each plugin, and a plugin that had only the delete has already
|
|
50
|
-
* shipped.
|
|
51
|
-
*
|
|
28
|
+
* Delete the output directory after checking it is safe to delete. One call on
|
|
29
|
+
* purpose: a plugin that carried only the delete has already shipped.
|
|
52
30
|
* @param label Platform name for the error message, e.g. `'Lambda build'`.
|
|
53
31
|
*/
|
|
54
32
|
declare function resetOutputDir(out: string, root: string, label: string): void;
|
|
55
33
|
/**
|
|
56
|
-
*
|
|
57
|
-
* `fromDir
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* emitted module from its real path, and a link that changes depth would
|
|
61
|
-
* otherwise leave the specifier short a `..` segment.
|
|
62
|
-
*
|
|
34
|
+
* POSIX relative specifier for importing `target` from a module written into
|
|
35
|
+
* `fromDir`. Both paths are canonicalized: the bundler resolves the emitted module
|
|
36
|
+
* from its real path, and a link that changes depth would leave the specifier a
|
|
37
|
+
* `..` short.
|
|
63
38
|
* @param label Platform name for the error message, e.g. `'Lambda build'`.
|
|
64
39
|
*/
|
|
65
40
|
declare function importSpecifier(fromDir: string, target: string, label: string): string;
|
|
@@ -68,112 +43,84 @@ interface ClientAssetEnv {
|
|
|
68
43
|
styles?: string;
|
|
69
44
|
}
|
|
70
45
|
/**
|
|
71
|
-
* Locate the built client entry and its CSS in the Vite client manifest, as
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* Takes the public directory rather than the app root so a caller passing a
|
|
75
|
-
* custom `publicDir` is honoured.
|
|
76
|
-
*
|
|
46
|
+
* Locate the built client entry and its CSS in the Vite client manifest, as the
|
|
47
|
+
* `/assets/`-prefixed URLs the Inertia head expects. Takes the public directory so
|
|
48
|
+
* a custom `publicDir` is honoured.
|
|
77
49
|
* @param label Platform name for the warning message, e.g. `'Lambda build'`.
|
|
78
50
|
*/
|
|
79
51
|
declare function resolveClientAssetEnv(publicDir: string, clientEntryKey: string, label: string): ClientAssetEnv;
|
|
80
52
|
/**
|
|
81
|
-
* The client
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* assignment, a bundler `define`); *what* the payload is, is this.
|
|
87
|
-
*
|
|
88
|
-
* Separate from `resolveClientAssetEnv` because that helper answers only for
|
|
89
|
-
* the client *entry*: a content-page app can have a manifest of CSS build
|
|
90
|
-
* inputs and no `resources/js/app.tsx` at all, and its `viteAsset()` calls
|
|
91
|
-
* still need the whole manifest.
|
|
92
|
-
*
|
|
93
|
-
* The payload is trimmed to the fields the runtime rule reads — `file` and
|
|
94
|
-
* `css` per entry (`getManifestFile`/`getManifestCss` in @guren/server's
|
|
95
|
-
* vite-manifest.ts) — because it ships inside executable code: a large app's
|
|
96
|
-
* manifest is dominated by per-chunk `imports`/`dynamicImports` graph
|
|
97
|
-
* metadata nothing consumes, and Workers caps bundle size. Trimming also
|
|
98
|
-
* validates the shape at build time, so a parseable-but-not-a-manifest file
|
|
99
|
-
* (`null`, an array) is reported as "no manifest" here instead of being baked
|
|
100
|
-
* in to fail at first render. String and array entry forms pass through
|
|
101
|
-
* untrimmed — the runtime accepts them, and the two paths must not diverge.
|
|
53
|
+
* The client manifest as JSON for runtime injection (`GUREN_VITE_MANIFEST`): a
|
|
54
|
+
* bundled function has no `public/assets/manifest.json`. Separate from
|
|
55
|
+
* `resolveClientAssetEnv`, which answers only for the client entry. Trimmed to
|
|
56
|
+
* `file`/`css` per entry (all the runtime reads; chunk graph metadata dominates
|
|
57
|
+
* size and Workers caps bundles); a parseable non-manifest is rejected here.
|
|
102
58
|
*/
|
|
103
59
|
declare function clientManifestJson(publicDir: string): string | undefined;
|
|
104
60
|
/**
|
|
105
|
-
* Absolute path of the built SSR entry chunk, or undefined
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* acceptable.
|
|
109
|
-
*
|
|
61
|
+
* Absolute path of the built SSR entry chunk, or undefined without an SSR build.
|
|
62
|
+
* Whether the chunk exports a renderer is the caller's check: platforms disagree
|
|
63
|
+
* on importing it during a build.
|
|
110
64
|
* @param label Platform name for the error messages, e.g. `'Lambda build'`.
|
|
111
65
|
*/
|
|
112
66
|
declare function resolveSsrEntryFile(ssrDir: string, ssrEntryKey: string, label: string): string | undefined;
|
|
113
67
|
/**
|
|
114
|
-
* Runtime locations of a staged SSR bundle, for platforms that copy `ssrDir`
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
* The manifest path is derived from the file that parsed rather than the
|
|
121
|
-
* first one that exists: both Vite layouts occur in the wild, and a malformed
|
|
122
|
-
* `.vite/manifest.json` alongside a valid flat one would otherwise publish the
|
|
123
|
-
* path to the file that was skipped. It is optional only for the mid-build
|
|
124
|
-
* race where the manifest vanishes between `resolveSsrEntryFile` and this
|
|
125
|
-
* call — callers already hold a chunk path that manifest produced.
|
|
68
|
+
* Runtime locations of a staged SSR bundle, for platforms that copy `ssrDir` under
|
|
69
|
+
* the function root; `prefix` is where the caller stages it. The manifest path is
|
|
70
|
+
* the file that parsed, not the first that exists (a malformed `.vite/` file beside
|
|
71
|
+
* a valid flat one). Optional only for the race where the manifest vanishes after
|
|
72
|
+
* `resolveSsrEntryFile`.
|
|
126
73
|
*/
|
|
127
74
|
declare function ssrRuntimePaths(ssrDir: string, ssrFile: string, prefix: string): {
|
|
128
75
|
entry: string;
|
|
129
76
|
manifest?: string;
|
|
130
77
|
};
|
|
131
78
|
/**
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
79
|
+
* Delete the dev-mode `index.html` shell from a statically served directory: every
|
|
80
|
+
* deploy target answers for its static directory before the function runs, so the
|
|
81
|
+
* shell shadows the app's root route. Exact name only (the framework writes it).
|
|
82
|
+
* Separate from `stageStaticAssets` because `@guren/plugin-vercel` stages `public/`
|
|
83
|
+
* itself and needs this rule alone.
|
|
84
|
+
*/
|
|
85
|
+
declare function removeShadowingIndex(assetsOut: string): void;
|
|
86
|
+
/**
|
|
87
|
+
* Copy `public/` into a platform's static staging directory. Built assets
|
|
88
|
+
* self-reference `/public/assets/` while HTML uses `/assets/`, so on a host without
|
|
89
|
+
* rewrites the assets directory must appear under both prefixes. Also applies
|
|
90
|
+
* `removeShadowingIndex`.
|
|
140
91
|
*/
|
|
141
92
|
declare function stageStaticAssets(publicDir: string, assetsOut: string): void;
|
|
93
|
+
/**
|
|
94
|
+
* Extensions a browser renders as a document, for platforms serving `public/`
|
|
95
|
+
* before the app runs: exactly what `@guren/server`'s `rendersAsDocument` matches
|
|
96
|
+
* over Hono's mime table (`tests/http/static-documents.test.ts` fails on drift).
|
|
97
|
+
* Like the framework it misses `.xsl` (Hono names no extension) and extension
|
|
98
|
+
* case, which each plugin closes as its own matcher allows.
|
|
99
|
+
*/
|
|
100
|
+
declare const DOCUMENT_ASSET_EXTENSIONS: readonly ['htm', 'html', 'svg', 'xhtml', 'xml'];
|
|
101
|
+
/**
|
|
102
|
+
* The headers `applyDocumentDisposition` sets: `attachment` is honoured for
|
|
103
|
+
* navigations and ignored for subresource loads, so `<img>` and CSS `url()` keep
|
|
104
|
+
* working while a directly opened URL downloads; `nosniff` stops browser promotion.
|
|
105
|
+
*/
|
|
106
|
+
declare const DOCUMENT_ASSET_HEADERS: Readonly<Record<string, string>>;
|
|
142
107
|
/** What a dev-only module is needed for, so a plugin can word its own message. */
|
|
143
108
|
type DevOnlyModuleKind = 'sqlite' | 'vite' | 'mcp' | 'sql-driver';
|
|
144
109
|
interface DevOnlyModule {
|
|
145
110
|
readonly specifier: string;
|
|
146
111
|
readonly kind: DevOnlyModuleKind;
|
|
147
112
|
/**
|
|
148
|
-
* Names the importing code destructures
|
|
149
|
-
*
|
|
150
|
-
* than at runtime. Empty means the module is only ever read through
|
|
151
|
-
* namespace property access, so an empty module suffices.
|
|
113
|
+
* Names the importing code destructures; a stub must declare every one or the
|
|
114
|
+
* bundle fails with "no matching export". Empty means namespace access only.
|
|
152
115
|
*/
|
|
153
116
|
readonly exportNames: readonly string[];
|
|
154
117
|
}
|
|
155
118
|
/**
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* Bundlers follow these imports even when they are dynamic, so without stubs
|
|
163
|
-
* the build either fails to resolve them or ships megabytes of dev tooling.
|
|
164
|
-
*
|
|
165
|
-
* - `sqlite` — the local sqlite ORM factory, opposite the platform's own
|
|
166
|
-
* database branch in `config/database.ts`.
|
|
167
|
-
* - `vite` — the dev asset server `Application` starts when serving locally.
|
|
168
|
-
* - `mcp` — the opt-in MCP endpoint's lazy imports, which drag the CLI
|
|
169
|
-
* generators (and Babel) plus the MCP SDK in behind them.
|
|
170
|
-
*
|
|
171
|
-
* SQL client libraries are deliberately *not* here: they are dev-only on
|
|
172
|
-
* Workers, where D1 is the only database, and load-bearing on Lambda and
|
|
173
|
-
* Vercel, which connect to Postgres. See `SQL_CLIENT_MODULES`.
|
|
174
|
-
*
|
|
175
|
-
* `as const` so a consumer can key an exhaustive table on the specifiers and
|
|
176
|
-
* have a new entry here surface as a compile error there.
|
|
119
|
+
* Dev-only modules in the graph of any app importing `@guren/core`, listed here
|
|
120
|
+
* because core alone sees the whole set (two plugin copies had drifted). Bundlers
|
|
121
|
+
* follow even dynamic imports, so unstubbed they fail the build or ship dev tooling.
|
|
122
|
+
* SQL clients are deliberately elsewhere (`SQL_CLIENT_MODULES`): dev-only on
|
|
123
|
+
* Workers, load-bearing on Lambda/Vercel. `as const` keys consumers' exhaustive tables.
|
|
177
124
|
*/
|
|
178
125
|
declare const DEV_ONLY_MODULES: readonly [{
|
|
179
126
|
readonly specifier: 'bun:sqlite';
|
|
@@ -196,21 +143,40 @@ declare const DEV_ONLY_MODULES: readonly [{
|
|
|
196
143
|
readonly kind: 'mcp';
|
|
197
144
|
readonly exportNames: readonly ["WebStandardStreamableHTTPServerTransport"];
|
|
198
145
|
}];
|
|
146
|
+
/** One entry of `DEV_ONLY_MODULES`, with its `kind` still narrowed. */
|
|
147
|
+
type DevOnlyModuleEntry = (typeof DEV_ONLY_MODULES)[number];
|
|
199
148
|
/**
|
|
200
|
-
*
|
|
201
|
-
*
|
|
149
|
+
* The specifier `@guren/plugin-mcp` lazily imports for the App MCP endpoint (RFC
|
|
150
|
+
* 0016 §7): the one `DEV_ONLY_MODULES` entry whose stubbing is conditional.
|
|
202
151
|
*/
|
|
152
|
+
declare const MCP_TRANSPORT_SPECIFIER = "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
|
|
153
|
+
/** The package an app declares to opt into the App MCP endpoint. */
|
|
154
|
+
declare const MCP_PLUGIN_PACKAGE = "@guren/plugin-mcp";
|
|
155
|
+
/**
|
|
156
|
+
* Whether the app opted into the App MCP endpoint (RFC 0016 §7, Open Question 5):
|
|
157
|
+
* declaring `@guren/plugin-mcp` in `dependencies` is the opt-in, so no build flag
|
|
158
|
+
* can silently compile the endpoint shut. `devDependencies` do not count (they do
|
|
159
|
+
* not ship). An absent, unreadable, or malformed manifest answers `false`: the
|
|
160
|
+
* transport stays stubbed, which is the safe direction.
|
|
161
|
+
*/
|
|
162
|
+
declare function appUsesMcpPlugin(root: string): boolean;
|
|
163
|
+
/**
|
|
164
|
+
* The dev-only modules that must stay stubbed for this app: `DEV_ONLY_MODULES`
|
|
165
|
+
* minus the transport entry when the app declared `@guren/plugin-mcp` (stubbing
|
|
166
|
+
* `MCP_TRANSPORT_SPECIFIER` compiled the endpoint shut everywhere before RFC 0016
|
|
167
|
+
* Phase 4a). `server/mcp.js` stays stubbed: that is the Dev MCP. Each entry keeps
|
|
168
|
+
* its narrow `kind` so platform `Record<kind, message>` tables stay indexable.
|
|
169
|
+
*/
|
|
170
|
+
declare function stubbableDevOnlyModules(options: {
|
|
171
|
+
mcpPlugin: boolean;
|
|
172
|
+
}): readonly DevOnlyModuleEntry[];
|
|
173
|
+
/** A database `@guren/orm` can connect through, named after the factory the app's config calls. */
|
|
203
174
|
type DatabaseDialect = 'postgres' | 'mysql' | 'sqlite' | 'aws-data-api' | 'd1';
|
|
204
175
|
/**
|
|
205
|
-
* The `@guren/orm` factory names an app's
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
* implementation files, and pinned there by a test: a list built from the
|
|
210
|
-
* implementation admits names that were never exported and misses the aliases
|
|
211
|
-
* that were. The spelling is `createMySqlDatabase`, not `createMysqlDatabase`
|
|
212
|
-
* — a build that filters on a name nobody exports detects nothing and stubs
|
|
213
|
-
* nothing, which is silent.
|
|
176
|
+
* The `@guren/orm` factory names an app's config calls, with each one's dialect.
|
|
177
|
+
* Taken from `@guren/core`'s export allowlist (pinned by a test), not the ORM's
|
|
178
|
+
* files: it is `createMySqlDatabase`, and a filter on a name nobody exports stubs
|
|
179
|
+
* nothing, silently.
|
|
214
180
|
*/
|
|
215
181
|
declare const DATABASE_FACTORIES: {
|
|
216
182
|
readonly createPostgresDatabase: 'postgres';
|
|
@@ -224,29 +190,11 @@ interface SqlClientModule extends DevOnlyModule {
|
|
|
224
190
|
readonly dialect: DatabaseDialect;
|
|
225
191
|
}
|
|
226
192
|
/**
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
* every one of these is unreachable; on Lambda and Vercel the app connects to
|
|
233
|
-
* Postgres through them and stubbing them would break a working deploy.
|
|
234
|
-
*
|
|
235
|
-
* That makes the list itself the wrong granularity for a platform that hosts
|
|
236
|
-
* more than one dialect. Workers stubs all of it; Lambda and Vercel stub the
|
|
237
|
-
* entries whose `dialect` the app's config does not declare, which is what
|
|
238
|
-
* `unusedSqlClients` decides.
|
|
239
|
-
*
|
|
240
|
-
* A platform where they are unreachable has to stub them rather than ignore
|
|
241
|
-
* them. `@guren/orm` names them in *literal* dynamic imports, which a bundler
|
|
242
|
-
* follows whether or not the branch can be taken — so a D1 app failed to
|
|
243
|
-
* bundle on `Could not resolve "postgres"`, naming a database its author had
|
|
244
|
-
* deliberately not chosen. Both the client and the drizzle entry point that
|
|
245
|
-
* imports it need stubbing: aliasing only the client leaves drizzle's own
|
|
246
|
-
* `import pgClient from "postgres"` to resolve.
|
|
247
|
-
*
|
|
248
|
-
* Export names are read off drizzle-orm's driver and session modules, which
|
|
249
|
-
* is what a bundler checks a stub against.
|
|
193
|
+
* Client libraries the Postgres, MySQL and Aurora Data API factories reach for.
|
|
194
|
+
* Apart from `DEV_ONLY_MODULES` because their fate is per platform: unreachable on
|
|
195
|
+
* Workers (D1 only), load-bearing on Lambda/Vercel, which stub only undeclared
|
|
196
|
+
* dialects (`unusedSqlClients`). Stub the client *and* drizzle's entry importing it,
|
|
197
|
+
* or a D1 app fails on `Could not resolve "postgres"`; export names mirror drizzle-orm's.
|
|
250
198
|
*/
|
|
251
199
|
declare const SQL_CLIENT_MODULES: readonly [{
|
|
252
200
|
readonly specifier: 'postgres';
|
|
@@ -271,13 +219,9 @@ declare const SQL_CLIENT_MODULES: readonly [{
|
|
|
271
219
|
}];
|
|
272
220
|
type SqlClientSpecifier = (typeof SQL_CLIENT_MODULES)[number]['specifier'];
|
|
273
221
|
/**
|
|
274
|
-
* Where an app declares its database, in
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
* `realpathOfNearestExisting` above is one: this module must not import
|
|
278
|
-
* beyond node builtins, and cli cannot be imported from core. If the two ever
|
|
279
|
-
* disagree, a build would stub clients for an app whose config the doctor
|
|
280
|
-
* says is fine — so a change to either belongs in both.
|
|
222
|
+
* Where an app declares its database, in lookup order. Same pair `guren doctor`
|
|
223
|
+
* checks, copied because this module imports only node builtins; a change to
|
|
224
|
+
* either belongs in both.
|
|
281
225
|
*/
|
|
282
226
|
declare const DATABASE_CONFIG_CANDIDATES: readonly ['config/database.ts', 'db/config.ts'];
|
|
283
227
|
interface DatabaseDialectDetection {
|
|
@@ -291,22 +235,11 @@ interface DatabaseDialectDetection {
|
|
|
291
235
|
source?: string;
|
|
292
236
|
}
|
|
293
237
|
/**
|
|
294
|
-
* Which databases an app connects to, read off its
|
|
295
|
-
*
|
|
296
|
-
* A
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
* development, and a Lambda app can pair Postgres with sqlite the same way.
|
|
300
|
-
* Taking the first match would stub a client the app really does reach for.
|
|
301
|
-
*
|
|
302
|
-
* Matching is a scan for the factory names, not a parse: every way of being
|
|
303
|
-
* wrong about a name that *is* in the file — mentioned in a comment, imported
|
|
304
|
-
* but never called, called in a branch this deploy will not take — errs
|
|
305
|
-
* toward reporting a dialect the app might not use, and the caller stubs
|
|
306
|
-
* fewer clients as a result. The opposite error is the dangerous one, so the
|
|
307
|
-
* cheap reading is the right one. A config that reaches a factory without
|
|
308
|
-
* naming it (a re-export, an indirection through another module) reports
|
|
309
|
-
* nothing, and the caller stubs nothing.
|
|
238
|
+
* Which databases an app connects to, read off its config. A union, never a single
|
|
239
|
+
* answer: a config may name two factories and pick at runtime (D1 plus sqlite).
|
|
240
|
+
* A name scan, not a parse: every way of being wrong about a name that is in the
|
|
241
|
+
* file errs toward reporting an unused dialect, which only stubs fewer clients.
|
|
242
|
+
* A factory reached without being named reports nothing, and nothing is stubbed.
|
|
310
243
|
*/
|
|
311
244
|
declare function detectDatabaseDialects(root: string): DatabaseDialectDetection;
|
|
312
245
|
/** Every dialect name `databaseDialects` accepts, for validation and messages. */
|
|
@@ -323,22 +256,11 @@ interface UnusedSqlClient {
|
|
|
323
256
|
readonly message: string;
|
|
324
257
|
}
|
|
325
258
|
/**
|
|
326
|
-
* The database clients an app does not connect through, for
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
* Fails open: when the dialects cannot be read, this warns and returns
|
|
332
|
-
* nothing to stub. The two errors are not symmetric. Under-stubbing leaves
|
|
333
|
-
* today's behaviour — the build fails to resolve a client the app never
|
|
334
|
-
* installed, loudly, at build time. Over-stubbing produces a bundle that
|
|
335
|
-
* builds clean and then cannot reach its own database, at runtime, in
|
|
336
|
-
* production. Only the second is worth protecting against, so anything less
|
|
337
|
-
* than positive evidence means stub nothing.
|
|
338
|
-
*
|
|
339
|
-
* @param dialects Overrides detection when the caller already knows, for an
|
|
340
|
-
* app whose config the scan cannot read.
|
|
341
|
-
* @param label Platform name for the messages, e.g. `'Lambda build'`.
|
|
259
|
+
* The database clients an app does not connect through, for Lambda and Vercel
|
|
260
|
+
* (on Workers every client is unreachable). Fails open: unreadable dialects warn
|
|
261
|
+
* and stub nothing, because under-stubbing fails loudly at build time while
|
|
262
|
+
* over-stubbing ships a bundle that cannot reach its database in production.
|
|
263
|
+
* @param dialects Overrides detection when the caller already knows.
|
|
342
264
|
*/
|
|
343
265
|
declare function unusedSqlClients(input: {
|
|
344
266
|
root: string;
|
|
@@ -346,14 +268,19 @@ declare function unusedSqlClients(input: {
|
|
|
346
268
|
dialects?: readonly DatabaseDialect[];
|
|
347
269
|
}): readonly UnusedSqlClient[];
|
|
348
270
|
type DevOnlySpecifier = (typeof DEV_ONLY_MODULES)[number]['specifier'];
|
|
271
|
+
/**
|
|
272
|
+
* Source for a stub replacing one dev-only module. Every destructured name must be
|
|
273
|
+
* present or the bundle fails with "no matching export", and each is a throwing
|
|
274
|
+
* *function* because stubbed names mix constructors and plain calls (a class
|
|
275
|
+
* called without `new` would hide the real reason).
|
|
276
|
+
* @param message Platform-specific explanation, including the replacement API.
|
|
277
|
+
*/
|
|
349
278
|
declare function renderDevOnlyStub(module: DevOnlyModule, message: string): string;
|
|
350
279
|
/**
|
|
351
|
-
* The MCP SDK is only
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
* unlisted subpaths under this prefix to a stub, so a new subpath added
|
|
355
|
-
* upstream cannot pull the real SDK into a deployed bundle.
|
|
280
|
+
* The MCP SDK is reached only through subpaths, which a package-name alias does not
|
|
281
|
+
* cover (hence each one in `DEV_ONLY_MODULES`). A platform whose aliasing supports
|
|
282
|
+
* prefixes should route unlisted subpaths under this prefix to a stub too.
|
|
356
283
|
*/
|
|
357
284
|
declare const MCP_SDK_SUBPATH_PREFIX = "@modelcontextprotocol/sdk/";
|
|
358
285
|
//#endregion
|
|
359
|
-
export { ClientAssetEnv, DATABASE_CONFIG_CANDIDATES, DATABASE_DIALECTS, DATABASE_FACTORIES, DEV_ONLY_MODULES, DatabaseDialect, DatabaseDialectDetection, DevOnlyModule, DevOnlyModuleKind, DevOnlySpecifier, MCP_SDK_SUBPATH_PREFIX, Manifest, ManifestEntry, PathLike, SQL_CLIENT_MODULES, SqlClientModule, SqlClientSpecifier, UnusedSqlClient, assertOutputDirOutsideRoot, clientManifestJson, detectDatabaseDialects, importSpecifier, parseDatabaseDialects, readManifest, renderDevOnlyStub, resetOutputDir, resolveClientAssetEnv, resolvePathLike, resolveSsrEntryFile, ssrRuntimePaths, stageStaticAssets, unusedSqlClients };
|
|
286
|
+
export { ClientAssetEnv, DATABASE_CONFIG_CANDIDATES, DATABASE_DIALECTS, DATABASE_FACTORIES, DEV_ONLY_MODULES, DOCUMENT_ASSET_EXTENSIONS, DOCUMENT_ASSET_HEADERS, DatabaseDialect, DatabaseDialectDetection, DevOnlyModule, DevOnlyModuleEntry, DevOnlyModuleKind, DevOnlySpecifier, MCP_PLUGIN_PACKAGE, MCP_SDK_SUBPATH_PREFIX, MCP_TRANSPORT_SPECIFIER, Manifest, ManifestEntry, PathLike, SQL_CLIENT_MODULES, SqlClientModule, SqlClientSpecifier, UnusedSqlClient, appUsesMcpPlugin, assertOutputDirOutsideRoot, clientManifestJson, detectDatabaseDialects, importSpecifier, parseDatabaseDialects, readManifest, removeShadowingIndex, renderDevOnlyStub, resetOutputDir, resolveClientAssetEnv, resolvePathLike, resolveSsrEntryFile, ssrRuntimePaths, stageStaticAssets, stubbableDevOnlyModules, unusedSqlClients };
|