@guren/core 1.18.0 → 1.19.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/dist/index.d.ts +58 -3
- package/dist/index.js +59 -2
- package/dist/internal/deploy-build.d.ts +60 -16
- package/dist/internal/deploy-build.js +103 -31
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ApiToken, ApiTokenStore, Command, Container, Controller, Job, OAuthStatePayload, OAuthStateStore, QueueManager, Router, SessionConfig, SessionData, SessionManager, SessionStore, StorageManager } from "@guren/server";
|
|
2
|
-
import { AccessorDefinitions, AccessorFn, AwsDataApiDatabase, AwsDataApiDatabaseOptions, AwsDataApiSeederContext, BelongsToManyRecord, BelongsToManyRelationResult, BelongsToRecord, BelongsToRelationResult, BelongsToRequiredRecord, CastType, D1DatabaseHandle, D1DatabaseOptions, DrizzleAdapter, EagerLoadConstraint, FindManyOptions, GroupCondition, HasManyRecord, HasManyRelationResult, HasManyThroughRecord, HasManyThroughRelationResult, HasOneRecord, HasOneRelationResult, HookCallback, HookName, InferModelInsert, InferModelRecord, MassAssignmentException, MigrationRunSummary, MigrationStatusEntry, Model, Model as Model$1, ModelHooks, ModelNotFoundException, ModelObserver, ModelObserverConstructor, ModelPaginationMeta, ModelQueryOptions, MorphManyRecord, MorphManyRelationResult, MorphToRecord, MorphToRelationResult, MutatorDefinitions, MutatorFn, MySqlDatabase, MySqlDatabaseOptions, MySqlSeederContext, ORMAdapter, ORMAdapterAdvanced, OrderByClause, OrderByInput, OrderDefinition, OrderDirection, PaginateOptions, PaginatedResult, PlainObject, PlainObject as PlainObject$1, PostgresDatabase, PostgresDatabaseOptions, PostgresSeederContext, QueryBuilder, QueryBuilderOptions, ScopeFunction, SeederContext, SeederHandler, SeederRunSummary, SimpleCondition, SoftDeletes, SoftDeletesStatic, SqliteDatabase, SqliteDatabaseOptions, SqliteSeederContext, TransactionHandle, TransactionModelScope, WhereClause, WhereCondition, WhereGroupCallback, WhereOperator, WithRelations, createAwsDataApiDatabase, createD1Database, createMySqlDatabase, createPostgresDatabase, createSqliteDatabase, defineModel, defineSeeder, runSeeders } from "@guren/orm";
|
|
1
|
+
import { ApiToken, ApiTokenStore, AppEnv, Command, ConfigDefinition, Container, Controller, Job, OAuthStatePayload, OAuthStateStore, QueueManager, Router, SessionConfig, SessionData, SessionManager, SessionStore, StorageManager } from "@guren/server";
|
|
2
|
+
import { AccessorDefinitions, AccessorFn, AggregateFunction, AvgValue, AwsDataApiDatabase, AwsDataApiDatabaseOptions, AwsDataApiSeederContext, BelongsToManyRecord, BelongsToManyRelationResult, BelongsToRecord, BelongsToRelationResult, BelongsToRequiredRecord, CastType, ConnectionContext, ConnectionContext as ConnectionContext$1, D1DatabaseHandle, D1DatabaseOptions, DrizzleAdapter, DrizzleSelectQuery, EagerLoadConstraint, FindManyOptions, GroupCondition, HasManyRecord, HasManyRelationResult, HasManyThroughRecord, HasManyThroughRelationResult, HasOneRecord, HasOneRelationResult, HookCallback, HookName, InferModelInsert, InferModelRecord, MassAssignmentException, MigrationRunSummary, MigrationStatusEntry, Model, Model as Model$1, ModelHooks, ModelNotFoundException, ModelObserver, ModelObserverConstructor, ModelPaginationMeta, ModelQueryOptions, MorphManyRecord, MorphManyRelationResult, MorphToRecord, MorphToRelationResult, MutatorDefinitions, MutatorFn, MySqlDatabase, MySqlDatabaseOptions, MySqlSeederContext, ORMAdapter, ORMAdapterAdvanced, OrderByClause, OrderByInput, OrderDefinition, OrderDirection, PaginateOptions, PaginatedResult, PlainObject, PlainObject as PlainObject$1, PostgresDatabase, PostgresDatabaseOptions, PostgresSeederContext, QueryBuilder, QueryBuilderOptions, ScopeFunction, SeederContext, SeederHandler, SeederRunSummary, SimpleCondition, SoftDeletes, SoftDeletesStatic, SqliteDatabase, SqliteDatabaseOptions, SqliteSeederContext, SumValue, TransactionHandle, TransactionModelScope, WhereClause, WhereCondition, WhereGroupCallback, WhereOperator, WithRelations, createAwsDataApiDatabase, createD1Database, createMySqlDatabase, createPostgresDatabase, createSqliteDatabase, defineModel, defineSeeder, runSeeders } from "@guren/orm";
|
|
3
3
|
export * from "@guren/server";
|
|
4
4
|
//#region src/api-token-store.d.ts
|
|
5
5
|
interface DatabaseApiTokenStoreOptions {
|
|
@@ -115,6 +115,47 @@ declare class SessionsPruneCommand extends Command {
|
|
|
115
115
|
handle(): Promise<void>;
|
|
116
116
|
}
|
|
117
117
|
//#endregion
|
|
118
|
+
//#region src/config.d.ts
|
|
119
|
+
/** What `defineDatabaseConfig()` needs from a dialect factory's result. */
|
|
120
|
+
interface ConfigurableDatabase {
|
|
121
|
+
configureOrm(context?: ConnectionContext$1): Promise<void>;
|
|
122
|
+
seedDatabase(): Promise<unknown>;
|
|
123
|
+
hasMigrations(): boolean;
|
|
124
|
+
}
|
|
125
|
+
interface DatabaseConfig {
|
|
126
|
+
readonly database: ConfigurableDatabase;
|
|
127
|
+
/** Run the seeders at boot when the migrations folder holds migrations. */
|
|
128
|
+
readonly seedOnBoot: boolean;
|
|
129
|
+
}
|
|
130
|
+
declare module '@guren/server' {
|
|
131
|
+
interface ConfigDefinitions {
|
|
132
|
+
session: SessionConfig;
|
|
133
|
+
database: DatabaseConfig;
|
|
134
|
+
}
|
|
135
|
+
interface ServiceBindings {
|
|
136
|
+
/** Bound by `defineDatabaseConfig()` (RFC 0027 §2). */
|
|
137
|
+
database: ConfigurableDatabase;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
declare module '@guren/orm' {
|
|
141
|
+
interface OrmConnectionEnv extends AppEnv {}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* `config/session.ts` (RFC 0027 §2). Written in core because the manager it
|
|
145
|
+
* binds knows the `database` driver, which `@guren/server` cannot resolve, and
|
|
146
|
+
* it binds the same `session` key an app's SessionProvider does (RFC 0020 §2).
|
|
147
|
+
*/
|
|
148
|
+
declare function defineSessionConfig(resolve: (env: AppEnv) => SessionConfig): ConfigDefinition<'session'>;
|
|
149
|
+
/**
|
|
150
|
+
* `config/database.ts` (RFC 0027 §2). Binds `database`, and at boot connects
|
|
151
|
+
* through `configureOrm({ env })`, so a connection resolver reads the validated
|
|
152
|
+
* env (a test's `envSource` included) rather than `process.env`. Without an env
|
|
153
|
+
* schema the context is omitted, so a resolver's own fallback runs.
|
|
154
|
+
*/
|
|
155
|
+
declare function defineDatabaseConfig(database: ConfigurableDatabase, options?: {
|
|
156
|
+
readonly seedOnBoot?: boolean;
|
|
157
|
+
}): ConfigDefinition<'database'>;
|
|
158
|
+
//#endregion
|
|
118
159
|
//#region src/oauth-state-store.d.ts
|
|
119
160
|
/**
|
|
120
161
|
* Database-backed OAuth state store built on the Guren ORM, for serverless, where
|
|
@@ -146,6 +187,20 @@ declare class DatabaseOAuthStateStore implements OAuthStateStore {
|
|
|
146
187
|
deleteExpired(now?: Date): Promise<void>;
|
|
147
188
|
}
|
|
148
189
|
//#endregion
|
|
190
|
+
//#region src/oauth-states-prune-command.d.ts
|
|
191
|
+
/**
|
|
192
|
+
* Console sweeper for the OAuth state store. `handleCallback()` already rejects
|
|
193
|
+
* an expired state, so this only keeps the table from growing; schedule it. A
|
|
194
|
+
* flow abandoned before the callback is never looked up again, so its row is
|
|
195
|
+
* only removed here. Stores that expire their own entries (Redis, memory) are
|
|
196
|
+
* skipped by the manager.
|
|
197
|
+
*/
|
|
198
|
+
declare class OAuthStatesPruneCommand extends Command {
|
|
199
|
+
static signature: string;
|
|
200
|
+
static description: string;
|
|
201
|
+
handle(): Promise<void>;
|
|
202
|
+
}
|
|
203
|
+
//#endregion
|
|
149
204
|
//#region src/attachments/types.d.ts
|
|
150
205
|
/**
|
|
151
206
|
* Public types for the attachments layer (RFC 0013): attachments ride the ORM's
|
|
@@ -786,4 +841,4 @@ declare class GenerateVariantsJob extends Job<GenerateVariantsPayload> {
|
|
|
786
841
|
failed(payload: GenerateVariantsPayload, _error: Error): Promise<void>;
|
|
787
842
|
}
|
|
788
843
|
//#endregion
|
|
789
|
-
export { ATTACHMENT_OBJECT_PREFIX, type AccessorDefinitions, type AccessorFn, type AttachOptions, Attachable, type AttachableRecordId, type AttachableStatic, type AttachedCollectionOptions, type AttachmentCollectionSpec, type AttachmentData, AttachmentDeliveryController, type AttachmentEngine, type AttachmentRecord, type AttachmentSource, type AttachmentUrlOptions, type AttachmentVariantRecord, type AttachmentsDeclaration, AttachmentsPruneCommand, type AwsDataApiDatabase, type AwsDataApiDatabaseOptions, type AwsDataApiSeederContext, type BelongsToManyRecord, type BelongsToManyRelationResult, type BelongsToRecord, type BelongsToRelationResult, type BelongsToRequiredRecord, type CastType, type ConfigureAttachmentsOptions, type ConfiguredAttachments, type D1DatabaseHandle, type D1DatabaseOptions, DEFAULT_DELIVERY_ROUTE_NAME, DatabaseApiTokenStore, type DatabaseApiTokenStoreOptions, DatabaseOAuthStateStore, type DatabaseSessionDriverOptions, DatabaseSessionStore, type DatabaseSessionStoreOptions, type DeliveryOptions, type DeliveryServeMode, type DiskDeliveryConfig, DrizzleAdapter, type EagerLoadConstraint, type FindManyOptions, GenerateVariantsJob, type GenerateVariantsPayload, type GroupCondition, type HasManyRecord, type HasManyRelationResult, type HasManyThroughRecord, type HasManyThroughRelationResult, type HasOneRecord, type HasOneRelationResult, type HeicPolicy, type HookCallback, type HookName, type ImagePolicy, type ImageProcessor, type InferModelInsert, type InferModelRecord, MassAssignmentException, type MigrationRunSummary, type MigrationStatusEntry, Model, type ModelHooks, ModelNotFoundException, type ModelObserver, type ModelObserverConstructor, type ModelPaginationMeta, type ModelQueryOptions, type MorphManyRecord, type MorphManyRelationResult, type MorphToRecord, type MorphToRelationResult, type MutatorDefinitions, type MutatorFn, type MySqlDatabase, type MySqlDatabaseOptions, type MySqlSeederContext, type ORMAdapter, type ORMAdapterAdvanced, type OrderByClause, type OrderByInput, type OrderDefinition, type OrderDirection, type PaginateOptions, type PaginatedResult, type PlainObject, type PostgresDatabase, type PostgresDatabaseOptions, type PostgresSeederContext, type PruneOptions, type PruneReport, QueryBuilder, type QueryBuilderOptions, type ScopeFunction, type SeederContext, type SeederHandler, type SeederRunSummary, SessionsPruneCommand, type SimpleCondition, SoftDeletes, type SoftDeletesStatic, type SqliteDatabase, type SqliteDatabaseOptions, type SqliteSeederContext, type TransactionHandle, type TransactionModelScope, type VariantSpec, type WhereClause, type WhereCondition, type WhereGroupCallback, type WhereOperator, type WithRelations, configureAttachments, createAwsDataApiDatabase, createD1Database, createMySqlDatabase, createPostgresDatabase, createSessionManager, createSqliteDatabase, defineModel, defineSeeder, hasManyAttached, hasOneAttached, registerAttachmentRoutes, registerDatabaseSessionDriver, runSeeders };
|
|
844
|
+
export { ATTACHMENT_OBJECT_PREFIX, type AccessorDefinitions, type AccessorFn, type AggregateFunction, type AttachOptions, Attachable, type AttachableRecordId, type AttachableStatic, type AttachedCollectionOptions, type AttachmentCollectionSpec, type AttachmentData, AttachmentDeliveryController, type AttachmentEngine, type AttachmentRecord, type AttachmentSource, type AttachmentUrlOptions, type AttachmentVariantRecord, type AttachmentsDeclaration, AttachmentsPruneCommand, type AvgValue, type AwsDataApiDatabase, type AwsDataApiDatabaseOptions, type AwsDataApiSeederContext, type BelongsToManyRecord, type BelongsToManyRelationResult, type BelongsToRecord, type BelongsToRelationResult, type BelongsToRequiredRecord, type CastType, type ConfigureAttachmentsOptions, type ConfiguredAttachments, type ConnectionContext, type D1DatabaseHandle, type D1DatabaseOptions, DEFAULT_DELIVERY_ROUTE_NAME, DatabaseApiTokenStore, type DatabaseApiTokenStoreOptions, DatabaseOAuthStateStore, type DatabaseSessionDriverOptions, DatabaseSessionStore, type DatabaseSessionStoreOptions, type DeliveryOptions, type DeliveryServeMode, type DiskDeliveryConfig, DrizzleAdapter, type DrizzleSelectQuery, type EagerLoadConstraint, type FindManyOptions, GenerateVariantsJob, type GenerateVariantsPayload, type GroupCondition, type HasManyRecord, type HasManyRelationResult, type HasManyThroughRecord, type HasManyThroughRelationResult, type HasOneRecord, type HasOneRelationResult, type HeicPolicy, type HookCallback, type HookName, type ImagePolicy, type ImageProcessor, type InferModelInsert, type InferModelRecord, MassAssignmentException, type MigrationRunSummary, type MigrationStatusEntry, Model, type ModelHooks, ModelNotFoundException, type ModelObserver, type ModelObserverConstructor, type ModelPaginationMeta, type ModelQueryOptions, type MorphManyRecord, type MorphManyRelationResult, type MorphToRecord, type MorphToRelationResult, type MutatorDefinitions, type MutatorFn, type MySqlDatabase, type MySqlDatabaseOptions, type MySqlSeederContext, OAuthStatesPruneCommand, type ORMAdapter, type ORMAdapterAdvanced, type OrderByClause, type OrderByInput, type OrderDefinition, type OrderDirection, type PaginateOptions, type PaginatedResult, type PlainObject, type PostgresDatabase, type PostgresDatabaseOptions, type PostgresSeederContext, type PruneOptions, type PruneReport, QueryBuilder, type QueryBuilderOptions, type ScopeFunction, type SeederContext, type SeederHandler, type SeederRunSummary, SessionsPruneCommand, type SimpleCondition, SoftDeletes, type SoftDeletesStatic, type SqliteDatabase, type SqliteDatabaseOptions, type SqliteSeederContext, type SumValue, type TransactionHandle, type TransactionModelScope, type VariantSpec, type WhereClause, type WhereCondition, type WhereGroupCallback, type WhereOperator, type WithRelations, configureAttachments, createAwsDataApiDatabase, createD1Database, createMySqlDatabase, createPostgresDatabase, createSessionManager, createSqliteDatabase, defineDatabaseConfig, defineModel, defineSeeder, defineSessionConfig, hasManyAttached, hasOneAttached, registerAttachmentRoutes, registerDatabaseSessionDriver, runSeeders };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Command, Controller, HttpException, Job, SessionManager, ValidationException, ambientBinding, ambientContainer, deriveAppKeyring, getAppKeyringFromEnv, registerJob, resolveQueueDriver, signUrl, tryGetRequestContainer, verifySignedUrl } from "@guren/server";
|
|
1
|
+
import { Command, Controller, HttpException, Job, SessionManager, ValidationException, ambientBinding, ambientContainer, defineConfig, deriveAppKeyring, getAppKeyringFromEnv, registerJob, resolveQueueDriver, signUrl, tryGetRequestContainer, verifySignedUrl } from "@guren/server";
|
|
2
2
|
import { DrizzleAdapter, MassAssignmentException, Model, Model as Model$1, ModelNotFoundException, QueryBuilder, SoftDeletes, createAwsDataApiDatabase, createD1Database, createMySqlDatabase, createPostgresDatabase, createSqliteDatabase, defineModel, defineSeeder, runSeeders } from "@guren/orm";
|
|
3
3
|
import { isExpired, toDate, toOptionalExpiry } from "@guren/server/support/expiry";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
@@ -188,6 +188,44 @@ var SessionsPruneCommand = class extends Command {
|
|
|
188
188
|
}
|
|
189
189
|
};
|
|
190
190
|
//#endregion
|
|
191
|
+
//#region src/config.ts
|
|
192
|
+
/**
|
|
193
|
+
* `config/session.ts` (RFC 0027 §2). Written in core because the manager it
|
|
194
|
+
* binds knows the `database` driver, which `@guren/server` cannot resolve, and
|
|
195
|
+
* it binds the same `session` key an app's SessionProvider does (RFC 0020 §2).
|
|
196
|
+
*/
|
|
197
|
+
function defineSessionConfig(resolve) {
|
|
198
|
+
return defineConfig({
|
|
199
|
+
key: "session",
|
|
200
|
+
resolve,
|
|
201
|
+
bind: (container, config) => {
|
|
202
|
+
container.singleton("session", () => createSessionManager(config));
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* `config/database.ts` (RFC 0027 §2). Binds `database`, and at boot connects
|
|
208
|
+
* through `configureOrm({ env })`, so a connection resolver reads the validated
|
|
209
|
+
* env (a test's `envSource` included) rather than `process.env`. Without an env
|
|
210
|
+
* schema the context is omitted, so a resolver's own fallback runs.
|
|
211
|
+
*/
|
|
212
|
+
function defineDatabaseConfig(database, options = {}) {
|
|
213
|
+
return defineConfig({
|
|
214
|
+
key: "database",
|
|
215
|
+
resolve: () => ({
|
|
216
|
+
database,
|
|
217
|
+
seedOnBoot: options.seedOnBoot ?? false
|
|
218
|
+
}),
|
|
219
|
+
bind: (container, config) => {
|
|
220
|
+
container.instance("database", config.database);
|
|
221
|
+
},
|
|
222
|
+
boot: async (container, config, env) => {
|
|
223
|
+
await config.database.configureOrm(container.has("env") ? { env } : void 0);
|
|
224
|
+
if (config.seedOnBoot && config.database.hasMigrations()) await config.database.seedDatabase();
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
//#endregion
|
|
191
229
|
//#region src/oauth-state-store.ts
|
|
192
230
|
/**
|
|
193
231
|
* Database-backed OAuth state store built on the Guren ORM, for serverless, where
|
|
@@ -285,6 +323,25 @@ function deleteRemovedRow(result) {
|
|
|
285
323
|
return Boolean(result);
|
|
286
324
|
}
|
|
287
325
|
//#endregion
|
|
326
|
+
//#region src/oauth-states-prune-command.ts
|
|
327
|
+
/**
|
|
328
|
+
* Console sweeper for the OAuth state store. `handleCallback()` already rejects
|
|
329
|
+
* an expired state, so this only keeps the table from growing; schedule it. A
|
|
330
|
+
* flow abandoned before the callback is never looked up again, so its row is
|
|
331
|
+
* only removed here. Stores that expire their own entries (Redis, memory) are
|
|
332
|
+
* skipped by the manager.
|
|
333
|
+
*/
|
|
334
|
+
var OAuthStatesPruneCommand = class extends Command {
|
|
335
|
+
static signature = "oauth-states:prune";
|
|
336
|
+
static description = "Delete expired OAuth states from the configured state store";
|
|
337
|
+
async handle() {
|
|
338
|
+
const manager = this.resolveOptional("oauth");
|
|
339
|
+
if (!manager) throw new Error("oauth-states:prune requires an OAuth manager. Register a provider that binds createOAuthManager({ stateStore }) as `oauth` (run `bunx guren add oauth`).");
|
|
340
|
+
await manager.pruneExpiredStates();
|
|
341
|
+
this.info("Expired OAuth states removed.");
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
//#endregion
|
|
288
345
|
//#region src/attachments/bun-image-processor.ts
|
|
289
346
|
/**
|
|
290
347
|
* The default {@link ImageProcessor}, backed by `Bun.Image`. Resolved by feature
|
|
@@ -1729,4 +1786,4 @@ function hasManyAttached(options = {}) {
|
|
|
1729
1786
|
return buildSpec("many", options);
|
|
1730
1787
|
}
|
|
1731
1788
|
//#endregion
|
|
1732
|
-
export { ATTACHMENT_OBJECT_PREFIX, Attachable, AttachmentDeliveryController, AttachmentsPruneCommand, DEFAULT_DELIVERY_ROUTE_NAME, DatabaseApiTokenStore, DatabaseOAuthStateStore, DatabaseSessionStore, DrizzleAdapter, GenerateVariantsJob, MassAssignmentException, Model, ModelNotFoundException, QueryBuilder, SessionsPruneCommand, SoftDeletes, configureAttachments, createAwsDataApiDatabase, createD1Database, createMySqlDatabase, createPostgresDatabase, createSessionManager, createSqliteDatabase, defineModel, defineSeeder, hasManyAttached, hasOneAttached, registerAttachmentRoutes, registerDatabaseSessionDriver, runSeeders };
|
|
1789
|
+
export { ATTACHMENT_OBJECT_PREFIX, Attachable, AttachmentDeliveryController, AttachmentsPruneCommand, DEFAULT_DELIVERY_ROUTE_NAME, DatabaseApiTokenStore, DatabaseOAuthStateStore, DatabaseSessionStore, DrizzleAdapter, GenerateVariantsJob, MassAssignmentException, Model, ModelNotFoundException, OAuthStatesPruneCommand, QueryBuilder, SessionsPruneCommand, SoftDeletes, configureAttachments, createAwsDataApiDatabase, createD1Database, createMySqlDatabase, createPostgresDatabase, createSessionManager, createSqliteDatabase, defineDatabaseConfig, defineModel, defineSeeder, defineSessionConfig, hasManyAttached, hasOneAttached, registerAttachmentRoutes, registerDatabaseSessionDriver, runSeeders };
|
|
@@ -45,14 +45,22 @@ declare function resetOutputDir(out: string, root: string, label: string): void;
|
|
|
45
45
|
* @param label Platform name for the error message, e.g. `'Lambda build'`.
|
|
46
46
|
*/
|
|
47
47
|
declare function importSpecifier(fromDir: string, target: string, label: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* The URL prefix built client assets are addressed by: the Vite `base` the Guren
|
|
50
|
+
* plugin derives from `outDir: 'public/assets'`, which its modulepreload helper
|
|
51
|
+
* prefixes. Must equal `PUBLIC_ASSETS_URL_PREFIX` in @guren/server's
|
|
52
|
+
* http/vite-manifest.ts; an entry under another prefix loads every lazy chunk
|
|
53
|
+
* twice, once per URL. `deploy-build.test.ts` pins it against the Vite plugin.
|
|
54
|
+
*/
|
|
55
|
+
declare const CLIENT_ASSETS_URL_PREFIX = "/public/assets/";
|
|
48
56
|
interface ClientAssetEnv {
|
|
49
57
|
entry?: string;
|
|
50
58
|
styles?: string;
|
|
51
59
|
}
|
|
52
60
|
/**
|
|
53
|
-
* Locate the built client entry and its CSS in the Vite client manifest, as
|
|
54
|
-
*
|
|
55
|
-
* a custom `publicDir` is honoured.
|
|
61
|
+
* Locate the built client entry and its CSS in the Vite client manifest, as
|
|
62
|
+
* `CLIENT_ASSETS_URL_PREFIX` URLs for the Inertia head. Takes the public directory
|
|
63
|
+
* so a custom `publicDir` is honoured.
|
|
56
64
|
* @param label Platform name for the warning message, e.g. `'Lambda build'`.
|
|
57
65
|
*/
|
|
58
66
|
declare function resolveClientAssetEnv(publicDir: string, clientEntryKey: string, label: string): ClientAssetEnv;
|
|
@@ -64,6 +72,22 @@ declare function resolveClientAssetEnv(publicDir: string, clientEntryKey: string
|
|
|
64
72
|
* size and Workers caps bundles); a parseable non-manifest is rejected here.
|
|
65
73
|
*/
|
|
66
74
|
declare function clientManifestJson(publicDir: string): string | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Every `lang/<locale>/<namespace>.json` as `{ locale: { namespace: messages } }`
|
|
77
|
+
* JSON, for runtime injection (`GUREN_TRANSLATIONS`): no deploy target ships
|
|
78
|
+
* `lang/`. Same walk and parse tolerance as `JsonLoader` in @guren/server and
|
|
79
|
+
* `readTranslationCatalogs` in @guren/cli. Undefined when nothing is readable.
|
|
80
|
+
* @param label Platform name for the warning message, e.g. `'Lambda build'`.
|
|
81
|
+
*/
|
|
82
|
+
declare function translationCatalogJson(root: string, label: string): string | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* What a deploy build bakes into the bundle, keyed by the `process.env` name
|
|
85
|
+
* @guren/server reads: the client manifest for viteAsset() and the lang/ catalogs
|
|
86
|
+
* for createApp({ i18n }). No target ships those files, and platform environment
|
|
87
|
+
* configuration is size-capped (Lambda: 4KB total), so neither goes there.
|
|
88
|
+
* @param label Platform name for warning messages, e.g. `'Lambda build'`.
|
|
89
|
+
*/
|
|
90
|
+
declare function bundledRuntimeEnv(root: string, publicDir: string, label: string): Record<string, string>;
|
|
67
91
|
/**
|
|
68
92
|
* Absolute path of the built SSR entry chunk, or undefined without an SSR build.
|
|
69
93
|
* Whether the chunk exports a renderer is the caller's check: platforms disagree
|
|
@@ -91,10 +115,11 @@ declare function ssrRuntimePaths(ssrDir: string, ssrFile: string, prefix: string
|
|
|
91
115
|
*/
|
|
92
116
|
declare function removeShadowingIndex(assetsOut: string): void;
|
|
93
117
|
/**
|
|
94
|
-
* Copy `public/` into a platform's static staging directory
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* `
|
|
118
|
+
* Copy `public/` into a platform's static staging directory, with the built assets
|
|
119
|
+
* only under `CLIENT_ASSETS_URL_PREFIX`, the one prefix the HTML and the chunks
|
|
120
|
+
* address: a second copy at `assets/` would answer, and so hide, a URL that drifted
|
|
121
|
+
* off it. Vite empties `public/assets/` on every build, so it holds nothing else.
|
|
122
|
+
* Also applies `removeShadowingIndex`.
|
|
98
123
|
*/
|
|
99
124
|
declare function stageStaticAssets(publicDir: string, assetsOut: string): void;
|
|
100
125
|
/**
|
|
@@ -121,6 +146,14 @@ interface DevOnlyModule {
|
|
|
121
146
|
* bundle fails with "no matching export". Empty means namespace access only.
|
|
122
147
|
*/
|
|
123
148
|
readonly exportNames: readonly string[];
|
|
149
|
+
/**
|
|
150
|
+
* The package source that reaches this module, repo-relative. An entry is here
|
|
151
|
+
* because one package imports it, so the module-graph check searches that package
|
|
152
|
+
* alone: a stale entry cannot be kept alive by an unrelated package's import.
|
|
153
|
+
* `null`: no package imports it any more, and it stays only so the stub file a
|
|
154
|
+
* committed `wrangler.jsonc` aliases keeps being written (RFC 0028 §4).
|
|
155
|
+
*/
|
|
156
|
+
readonly importedBy: string | null;
|
|
124
157
|
}
|
|
125
158
|
/**
|
|
126
159
|
* Dev-only modules in the graph of any app importing `@guren/core`, listed here
|
|
@@ -133,28 +166,34 @@ declare const DEV_ONLY_MODULES: readonly [{
|
|
|
133
166
|
readonly specifier: 'bun:sqlite';
|
|
134
167
|
readonly kind: 'sqlite';
|
|
135
168
|
readonly exportNames: readonly ["Database"];
|
|
169
|
+
readonly importedBy: 'packages/orm/src';
|
|
136
170
|
}, {
|
|
137
171
|
readonly specifier: 'vite';
|
|
138
172
|
readonly kind: 'vite';
|
|
139
173
|
readonly exportNames: readonly ["createServer"];
|
|
174
|
+
readonly importedBy: 'packages/server/src';
|
|
140
175
|
}, {
|
|
141
176
|
readonly specifier: '@guren/cli';
|
|
142
177
|
readonly kind: 'mcp';
|
|
143
178
|
readonly exportNames: readonly [];
|
|
179
|
+
readonly importedBy: 'packages/server/src';
|
|
144
180
|
}, {
|
|
145
181
|
readonly specifier: '@modelcontextprotocol/sdk/server/mcp.js';
|
|
146
182
|
readonly kind: 'mcp';
|
|
147
183
|
readonly exportNames: readonly ["McpServer", "ResourceTemplate"];
|
|
184
|
+
readonly importedBy: 'packages/server/src';
|
|
148
185
|
}, {
|
|
149
186
|
readonly specifier: '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
|
|
150
187
|
readonly kind: 'mcp';
|
|
151
188
|
readonly exportNames: readonly ["WebStandardStreamableHTTPServerTransport"];
|
|
189
|
+
readonly importedBy: null;
|
|
152
190
|
}];
|
|
153
191
|
/** One entry of `DEV_ONLY_MODULES`, with its `kind` still narrowed. */
|
|
154
192
|
type DevOnlyModuleEntry = (typeof DEV_ONLY_MODULES)[number];
|
|
155
193
|
/**
|
|
156
|
-
* The
|
|
157
|
-
*
|
|
194
|
+
* The v1 transport `@guren/plugin-mcp` imported before SDK v2 (RFC 0016 §7): the
|
|
195
|
+
* one `DEV_ONLY_MODULES` entry whose stubbing is conditional. Nothing imports it
|
|
196
|
+
* now, so the condition changes no bundle; it goes in RFC 0028's removal PR.
|
|
158
197
|
*/
|
|
159
198
|
declare const MCP_TRANSPORT_SPECIFIER = "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
|
|
160
199
|
/** The package an app declares to opt into the App MCP endpoint. */
|
|
@@ -169,9 +208,9 @@ declare const MCP_PLUGIN_PACKAGE = "@guren/plugin-mcp";
|
|
|
169
208
|
declare function appUsesMcpPlugin(root: string): boolean;
|
|
170
209
|
/**
|
|
171
210
|
* The dev-only modules that must stay stubbed for this app: `DEV_ONLY_MODULES`
|
|
172
|
-
* minus the transport entry when the app declared `@guren/plugin-mcp` (
|
|
173
|
-
*
|
|
174
|
-
*
|
|
211
|
+
* minus the v1 transport entry when the app declared `@guren/plugin-mcp` (RFC 0016
|
|
212
|
+
* Phase 4a). Since the plugin moved to SDK v2 that entry has no importer, so the
|
|
213
|
+
* split changes no bundle (RFC 0028 §4). `server/mcp.js` stays stubbed: the Dev MCP. Each entry keeps
|
|
175
214
|
* its narrow `kind` so platform `Record<kind, message>` tables stay indexable.
|
|
176
215
|
*/
|
|
177
216
|
declare function stubbableDevOnlyModules(options: {
|
|
@@ -208,21 +247,25 @@ declare const SQL_CLIENT_MODULES: readonly [{
|
|
|
208
247
|
readonly kind: 'sql-driver';
|
|
209
248
|
readonly dialect: 'postgres';
|
|
210
249
|
readonly exportNames: readonly [];
|
|
250
|
+
readonly importedBy: 'packages/orm/src';
|
|
211
251
|
}, {
|
|
212
252
|
readonly specifier: 'mysql2';
|
|
213
253
|
readonly kind: 'sql-driver';
|
|
214
254
|
readonly dialect: 'mysql';
|
|
215
255
|
readonly exportNames: readonly [];
|
|
256
|
+
readonly importedBy: 'packages/orm/src';
|
|
216
257
|
}, {
|
|
217
258
|
readonly specifier: 'mysql2/promise';
|
|
218
259
|
readonly kind: 'sql-driver';
|
|
219
260
|
readonly dialect: 'mysql';
|
|
220
261
|
readonly exportNames: readonly ["createPool"];
|
|
262
|
+
readonly importedBy: 'packages/orm/src';
|
|
221
263
|
}, {
|
|
222
264
|
readonly specifier: '@aws-sdk/client-rds-data';
|
|
223
265
|
readonly kind: 'sql-driver';
|
|
224
266
|
readonly dialect: 'aws-data-api';
|
|
225
267
|
readonly exportNames: readonly ["RDSDataClient", "BeginTransactionCommand", "CommitTransactionCommand", "ExecuteStatementCommand", "RollbackTransactionCommand"];
|
|
268
|
+
readonly importedBy: 'packages/orm/src';
|
|
226
269
|
}];
|
|
227
270
|
type SqlClientSpecifier = (typeof SQL_CLIENT_MODULES)[number]['specifier'];
|
|
228
271
|
/**
|
|
@@ -284,10 +327,11 @@ type DevOnlySpecifier = (typeof DEV_ONLY_MODULES)[number]['specifier'];
|
|
|
284
327
|
*/
|
|
285
328
|
declare function renderDevOnlyStub(module: DevOnlyModule, message: string): string;
|
|
286
329
|
/**
|
|
287
|
-
* The MCP SDK is reached only through subpaths, which a package-name alias does
|
|
288
|
-
* cover (hence each one in `DEV_ONLY_MODULES`). A platform whose aliasing supports
|
|
289
|
-
* prefixes
|
|
330
|
+
* The v1 MCP SDK is reached only through subpaths, which a package-name alias does
|
|
331
|
+
* not cover (hence each one in `DEV_ONLY_MODULES`). A platform whose aliasing supports
|
|
332
|
+
* prefixes routes unlisted subpaths under this prefix to a stub too. SDK v2 lives
|
|
333
|
+
* under other package names, so `@guren/plugin-mcp`'s import is never matched.
|
|
290
334
|
*/
|
|
291
335
|
declare const MCP_SDK_SUBPATH_PREFIX = "@modelcontextprotocol/sdk/";
|
|
292
336
|
//#endregion
|
|
293
|
-
export { AGENTS_CONFIG_FILE, 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 };
|
|
337
|
+
export { AGENTS_CONFIG_FILE, CLIENT_ASSETS_URL_PREFIX, 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, bundledRuntimeEnv, clientManifestJson, detectDatabaseDialects, importSpecifier, parseDatabaseDialects, readManifest, removeShadowingIndex, renderDevOnlyStub, resetOutputDir, resolveClientAssetEnv, resolvePathLike, resolveSsrEntryFile, ssrRuntimePaths, stageStaticAssets, stubbableDevOnlyModules, translationCatalogJson, unusedSqlClients };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { cpSync, existsSync, mkdirSync, readFileSync, realpathSync, rmSync } from "node:fs";
|
|
2
|
-
import { basename, dirname, isAbsolute, relative, resolve, sep } from "node:path";
|
|
1
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync } from "node:fs";
|
|
2
|
+
import { basename, dirname, extname, isAbsolute, relative, resolve, sep } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
//#region src/internal/deploy-build.ts
|
|
5
5
|
/**
|
|
@@ -111,9 +111,17 @@ function importSpecifier(fromDir, target, label) {
|
|
|
111
111
|
return specifier.startsWith(".") ? specifier : `./${specifier}`;
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
114
|
+
* The URL prefix built client assets are addressed by: the Vite `base` the Guren
|
|
115
|
+
* plugin derives from `outDir: 'public/assets'`, which its modulepreload helper
|
|
116
|
+
* prefixes. Must equal `PUBLIC_ASSETS_URL_PREFIX` in @guren/server's
|
|
117
|
+
* http/vite-manifest.ts; an entry under another prefix loads every lazy chunk
|
|
118
|
+
* twice, once per URL. `deploy-build.test.ts` pins it against the Vite plugin.
|
|
119
|
+
*/
|
|
120
|
+
const CLIENT_ASSETS_URL_PREFIX = "/public/assets/";
|
|
121
|
+
/**
|
|
122
|
+
* Locate the built client entry and its CSS in the Vite client manifest, as
|
|
123
|
+
* `CLIENT_ASSETS_URL_PREFIX` URLs for the Inertia head. Takes the public directory
|
|
124
|
+
* so a custom `publicDir` is honoured.
|
|
117
125
|
* @param label Platform name for the warning message, e.g. `'Lambda build'`.
|
|
118
126
|
*/
|
|
119
127
|
function resolveClientAssetEnv(publicDir, clientEntryKey, label) {
|
|
@@ -123,8 +131,8 @@ function resolveClientAssetEnv(publicDir, clientEntryKey, label) {
|
|
|
123
131
|
return {};
|
|
124
132
|
}
|
|
125
133
|
return {
|
|
126
|
-
entry:
|
|
127
|
-
styles: entry.css?.length ? entry.css.map((file) =>
|
|
134
|
+
entry: `${CLIENT_ASSETS_URL_PREFIX}${entry.file}`,
|
|
135
|
+
styles: entry.css?.length ? entry.css.map((file) => `${CLIENT_ASSETS_URL_PREFIX}${file}`).join(",") : void 0
|
|
128
136
|
};
|
|
129
137
|
}
|
|
130
138
|
/**
|
|
@@ -152,6 +160,55 @@ function clientManifestJson(publicDir) {
|
|
|
152
160
|
}
|
|
153
161
|
return JSON.stringify(trimmed);
|
|
154
162
|
}
|
|
163
|
+
const TRANSLATIONS_DIR = "lang";
|
|
164
|
+
/**
|
|
165
|
+
* Every `lang/<locale>/<namespace>.json` as `{ locale: { namespace: messages } }`
|
|
166
|
+
* JSON, for runtime injection (`GUREN_TRANSLATIONS`): no deploy target ships
|
|
167
|
+
* `lang/`. Same walk and parse tolerance as `JsonLoader` in @guren/server and
|
|
168
|
+
* `readTranslationCatalogs` in @guren/cli. Undefined when nothing is readable.
|
|
169
|
+
* @param label Platform name for the warning message, e.g. `'Lambda build'`.
|
|
170
|
+
*/
|
|
171
|
+
function translationCatalogJson(root, label) {
|
|
172
|
+
const base = resolve(root, TRANSLATIONS_DIR);
|
|
173
|
+
let locales;
|
|
174
|
+
try {
|
|
175
|
+
locales = readdirSync(base, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort();
|
|
176
|
+
} catch {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
const catalog = {};
|
|
180
|
+
for (const locale of locales) {
|
|
181
|
+
const messages = {};
|
|
182
|
+
let files;
|
|
183
|
+
try {
|
|
184
|
+
files = readdirSync(resolve(base, locale)).filter((file) => extname(file) === ".json").sort();
|
|
185
|
+
} catch {
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
for (const file of files) try {
|
|
189
|
+
messages[basename(file, ".json")] = JSON.parse(readFileSync(resolve(base, locale, file), "utf8"));
|
|
190
|
+
} catch {
|
|
191
|
+
console.warn(`${label}: ${TRANSLATIONS_DIR}/${locale}/${file} is not valid JSON and is left out of the deployed translations.`);
|
|
192
|
+
}
|
|
193
|
+
if (Object.keys(messages).length > 0) catalog[locale] = messages;
|
|
194
|
+
}
|
|
195
|
+
return Object.keys(catalog).length > 0 ? JSON.stringify(catalog) : void 0;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* What a deploy build bakes into the bundle, keyed by the `process.env` name
|
|
199
|
+
* @guren/server reads: the client manifest for viteAsset() and the lang/ catalogs
|
|
200
|
+
* for createApp({ i18n }). No target ships those files, and platform environment
|
|
201
|
+
* configuration is size-capped (Lambda: 4KB total), so neither goes there.
|
|
202
|
+
* @param label Platform name for warning messages, e.g. `'Lambda build'`.
|
|
203
|
+
*/
|
|
204
|
+
function bundledRuntimeEnv(root, publicDir, label) {
|
|
205
|
+
const env = {};
|
|
206
|
+
const manifest = clientManifestJson(publicDir);
|
|
207
|
+
if (manifest) env.GUREN_VITE_MANIFEST = manifest;
|
|
208
|
+
const translations = translationCatalogJson(root, label);
|
|
209
|
+
if (translations) env.GUREN_TRANSLATIONS = translations;
|
|
210
|
+
return env;
|
|
211
|
+
}
|
|
155
212
|
/**
|
|
156
213
|
* Absolute path of the built SSR entry chunk, or undefined without an SSR build.
|
|
157
214
|
* Whether the chunk exports a renderer is the caller's check: platforms disagree
|
|
@@ -193,17 +250,21 @@ function removeShadowingIndex(assetsOut) {
|
|
|
193
250
|
if (existsSync(shadowingIndex)) rmSync(shadowingIndex);
|
|
194
251
|
}
|
|
195
252
|
/**
|
|
196
|
-
* Copy `public/` into a platform's static staging directory
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
* `
|
|
253
|
+
* Copy `public/` into a platform's static staging directory, with the built assets
|
|
254
|
+
* only under `CLIENT_ASSETS_URL_PREFIX`, the one prefix the HTML and the chunks
|
|
255
|
+
* address: a second copy at `assets/` would answer, and so hide, a URL that drifted
|
|
256
|
+
* off it. Vite empties `public/assets/` on every build, so it holds nothing else.
|
|
257
|
+
* Also applies `removeShadowingIndex`.
|
|
200
258
|
*/
|
|
201
259
|
function stageStaticAssets(publicDir, assetsOut) {
|
|
202
260
|
mkdirSync(assetsOut, { recursive: true });
|
|
203
261
|
if (!existsSync(publicDir)) return;
|
|
204
|
-
cpSync(publicDir, assetsOut, { recursive: true });
|
|
205
|
-
removeShadowingIndex(assetsOut);
|
|
206
262
|
const clientAssetsDir = resolve(publicDir, "assets");
|
|
263
|
+
cpSync(publicDir, assetsOut, {
|
|
264
|
+
recursive: true,
|
|
265
|
+
filter: (source) => resolve(source) !== clientAssetsDir
|
|
266
|
+
});
|
|
267
|
+
removeShadowingIndex(assetsOut);
|
|
207
268
|
if (existsSync(clientAssetsDir)) cpSync(clientAssetsDir, resolve(assetsOut, "public/assets"), { recursive: true });
|
|
208
269
|
}
|
|
209
270
|
/**
|
|
@@ -240,32 +301,38 @@ const DEV_ONLY_MODULES = [
|
|
|
240
301
|
{
|
|
241
302
|
specifier: "bun:sqlite",
|
|
242
303
|
kind: "sqlite",
|
|
243
|
-
exportNames: ["Database"]
|
|
304
|
+
exportNames: ["Database"],
|
|
305
|
+
importedBy: "packages/orm/src"
|
|
244
306
|
},
|
|
245
307
|
{
|
|
246
308
|
specifier: "vite",
|
|
247
309
|
kind: "vite",
|
|
248
|
-
exportNames: ["createServer"]
|
|
310
|
+
exportNames: ["createServer"],
|
|
311
|
+
importedBy: "packages/server/src"
|
|
249
312
|
},
|
|
250
313
|
{
|
|
251
314
|
specifier: "@guren/cli",
|
|
252
315
|
kind: "mcp",
|
|
253
|
-
exportNames: []
|
|
316
|
+
exportNames: [],
|
|
317
|
+
importedBy: "packages/server/src"
|
|
254
318
|
},
|
|
255
319
|
{
|
|
256
320
|
specifier: "@modelcontextprotocol/sdk/server/mcp.js",
|
|
257
321
|
kind: "mcp",
|
|
258
|
-
exportNames: ["McpServer", "ResourceTemplate"]
|
|
322
|
+
exportNames: ["McpServer", "ResourceTemplate"],
|
|
323
|
+
importedBy: "packages/server/src"
|
|
259
324
|
},
|
|
260
325
|
{
|
|
261
326
|
specifier: "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js",
|
|
262
327
|
kind: "mcp",
|
|
263
|
-
exportNames: ["WebStandardStreamableHTTPServerTransport"]
|
|
328
|
+
exportNames: ["WebStandardStreamableHTTPServerTransport"],
|
|
329
|
+
importedBy: null
|
|
264
330
|
}
|
|
265
331
|
];
|
|
266
332
|
/**
|
|
267
|
-
* The
|
|
268
|
-
*
|
|
333
|
+
* The v1 transport `@guren/plugin-mcp` imported before SDK v2 (RFC 0016 §7): the
|
|
334
|
+
* one `DEV_ONLY_MODULES` entry whose stubbing is conditional. Nothing imports it
|
|
335
|
+
* now, so the condition changes no bundle; it goes in RFC 0028's removal PR.
|
|
269
336
|
*/
|
|
270
337
|
const MCP_TRANSPORT_SPECIFIER = "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
|
|
271
338
|
/** The package an app declares to opt into the App MCP endpoint. */
|
|
@@ -287,9 +354,9 @@ function appUsesMcpPlugin(root) {
|
|
|
287
354
|
}
|
|
288
355
|
/**
|
|
289
356
|
* The dev-only modules that must stay stubbed for this app: `DEV_ONLY_MODULES`
|
|
290
|
-
* minus the transport entry when the app declared `@guren/plugin-mcp` (
|
|
291
|
-
*
|
|
292
|
-
*
|
|
357
|
+
* minus the v1 transport entry when the app declared `@guren/plugin-mcp` (RFC 0016
|
|
358
|
+
* Phase 4a). Since the plugin moved to SDK v2 that entry has no importer, so the
|
|
359
|
+
* split changes no bundle (RFC 0028 §4). `server/mcp.js` stays stubbed: the Dev MCP. Each entry keeps
|
|
293
360
|
* its narrow `kind` so platform `Record<kind, message>` tables stay indexable.
|
|
294
361
|
*/
|
|
295
362
|
function stubbableDevOnlyModules(options) {
|
|
@@ -321,19 +388,22 @@ const SQL_CLIENT_MODULES = [
|
|
|
321
388
|
specifier: "postgres",
|
|
322
389
|
kind: "sql-driver",
|
|
323
390
|
dialect: "postgres",
|
|
324
|
-
exportNames: []
|
|
391
|
+
exportNames: [],
|
|
392
|
+
importedBy: "packages/orm/src"
|
|
325
393
|
},
|
|
326
394
|
{
|
|
327
395
|
specifier: "mysql2",
|
|
328
396
|
kind: "sql-driver",
|
|
329
397
|
dialect: "mysql",
|
|
330
|
-
exportNames: []
|
|
398
|
+
exportNames: [],
|
|
399
|
+
importedBy: "packages/orm/src"
|
|
331
400
|
},
|
|
332
401
|
{
|
|
333
402
|
specifier: "mysql2/promise",
|
|
334
403
|
kind: "sql-driver",
|
|
335
404
|
dialect: "mysql",
|
|
336
|
-
exportNames: ["createPool"]
|
|
405
|
+
exportNames: ["createPool"],
|
|
406
|
+
importedBy: "packages/orm/src"
|
|
337
407
|
},
|
|
338
408
|
{
|
|
339
409
|
specifier: "@aws-sdk/client-rds-data",
|
|
@@ -345,7 +415,8 @@ const SQL_CLIENT_MODULES = [
|
|
|
345
415
|
"CommitTransactionCommand",
|
|
346
416
|
"ExecuteStatementCommand",
|
|
347
417
|
"RollbackTransactionCommand"
|
|
348
|
-
]
|
|
418
|
+
],
|
|
419
|
+
importedBy: "packages/orm/src"
|
|
349
420
|
}
|
|
350
421
|
];
|
|
351
422
|
/**
|
|
@@ -445,10 +516,11 @@ function renderDevOnlyStub(module, message) {
|
|
|
445
516
|
return `// ${comment}\n${throwing}\n${`function unavailable() { ${error} }`}\nexport default Object.assign(unavailable${named})\n`;
|
|
446
517
|
}
|
|
447
518
|
/**
|
|
448
|
-
* The MCP SDK is reached only through subpaths, which a package-name alias does
|
|
449
|
-
* cover (hence each one in `DEV_ONLY_MODULES`). A platform whose aliasing supports
|
|
450
|
-
* prefixes
|
|
519
|
+
* The v1 MCP SDK is reached only through subpaths, which a package-name alias does
|
|
520
|
+
* not cover (hence each one in `DEV_ONLY_MODULES`). A platform whose aliasing supports
|
|
521
|
+
* prefixes routes unlisted subpaths under this prefix to a stub too. SDK v2 lives
|
|
522
|
+
* under other package names, so `@guren/plugin-mcp`'s import is never matched.
|
|
451
523
|
*/
|
|
452
524
|
const MCP_SDK_SUBPATH_PREFIX = "@modelcontextprotocol/sdk/";
|
|
453
525
|
//#endregion
|
|
454
|
-
export { AGENTS_CONFIG_FILE, DATABASE_CONFIG_CANDIDATES, DATABASE_DIALECTS, DATABASE_FACTORIES, DEV_ONLY_MODULES, DOCUMENT_ASSET_EXTENSIONS, DOCUMENT_ASSET_HEADERS, MCP_PLUGIN_PACKAGE, MCP_SDK_SUBPATH_PREFIX, MCP_TRANSPORT_SPECIFIER, SQL_CLIENT_MODULES, appUsesMcpPlugin, assertOutputDirOutsideRoot, clientManifestJson, detectDatabaseDialects, importSpecifier, parseDatabaseDialects, readManifest, removeShadowingIndex, renderDevOnlyStub, resetOutputDir, resolveClientAssetEnv, resolvePathLike, resolveSsrEntryFile, ssrRuntimePaths, stageStaticAssets, stubbableDevOnlyModules, unusedSqlClients };
|
|
526
|
+
export { AGENTS_CONFIG_FILE, CLIENT_ASSETS_URL_PREFIX, DATABASE_CONFIG_CANDIDATES, DATABASE_DIALECTS, DATABASE_FACTORIES, DEV_ONLY_MODULES, DOCUMENT_ASSET_EXTENSIONS, DOCUMENT_ASSET_HEADERS, MCP_PLUGIN_PACKAGE, MCP_SDK_SUBPATH_PREFIX, MCP_TRANSPORT_SPECIFIER, SQL_CLIENT_MODULES, appUsesMcpPlugin, assertOutputDirOutsideRoot, bundledRuntimeEnv, clientManifestJson, detectDatabaseDialects, importSpecifier, parseDatabaseDialects, readManifest, removeShadowingIndex, renderDevOnlyStub, resetOutputDir, resolveClientAssetEnv, resolvePathLike, resolveSsrEntryFile, ssrRuntimePaths, stageStaticAssets, stubbableDevOnlyModules, translationCatalogJson, unusedSqlClients };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guren/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"./src/bin.ts",
|
|
@@ -88,9 +88,9 @@
|
|
|
88
88
|
"typecheck": "tsc --noEmit"
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
|
-
"@guren/cli": "^2.
|
|
92
|
-
"@guren/orm": "^2.
|
|
93
|
-
"@guren/server": "^2.
|
|
91
|
+
"@guren/cli": "^2.24.0",
|
|
92
|
+
"@guren/orm": "^2.11.0",
|
|
93
|
+
"@guren/server": "^2.24.0"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
96
96
|
"@types/node": "^20.14.10",
|