@guren/core 1.18.0 → 1.20.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 +61 -40
- package/dist/internal/deploy-build.js +99 -55
- 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
|
/**
|
|
@@ -111,7 +136,11 @@ declare const DOCUMENT_ASSET_EXTENSIONS: readonly ['htm', 'html', 'svg', 'xhtml'
|
|
|
111
136
|
* working while a directly opened URL downloads; `nosniff` stops browser promotion.
|
|
112
137
|
*/
|
|
113
138
|
declare const DOCUMENT_ASSET_HEADERS: Readonly<Record<string, string>>;
|
|
114
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* What a dev-only module is needed for, so a plugin can word its own message.
|
|
141
|
+
* `mcp` is the `@guren/cli` entry. Deploy plugins already on npm key their message
|
|
142
|
+
* tables on these values, so renaming one breaks their builds until core 2.0.
|
|
143
|
+
*/
|
|
115
144
|
type DevOnlyModuleKind = 'sqlite' | 'vite' | 'mcp' | 'sql-driver';
|
|
116
145
|
interface DevOnlyModule {
|
|
117
146
|
readonly specifier: string;
|
|
@@ -121,6 +150,12 @@ interface DevOnlyModule {
|
|
|
121
150
|
* bundle fails with "no matching export". Empty means namespace access only.
|
|
122
151
|
*/
|
|
123
152
|
readonly exportNames: readonly string[];
|
|
153
|
+
/**
|
|
154
|
+
* The package source that reaches this module, repo-relative. An entry is here
|
|
155
|
+
* because one package imports it, so the module-graph check searches that package
|
|
156
|
+
* alone: a stale entry cannot be kept alive by an unrelated package's import.
|
|
157
|
+
*/
|
|
158
|
+
readonly importedBy: string;
|
|
124
159
|
}
|
|
125
160
|
/**
|
|
126
161
|
* Dev-only modules in the graph of any app importing `@guren/core`, listed here
|
|
@@ -133,48 +168,36 @@ declare const DEV_ONLY_MODULES: readonly [{
|
|
|
133
168
|
readonly specifier: 'bun:sqlite';
|
|
134
169
|
readonly kind: 'sqlite';
|
|
135
170
|
readonly exportNames: readonly ["Database"];
|
|
171
|
+
readonly importedBy: 'packages/orm/src';
|
|
136
172
|
}, {
|
|
137
173
|
readonly specifier: 'vite';
|
|
138
174
|
readonly kind: 'vite';
|
|
139
175
|
readonly exportNames: readonly ["createServer"];
|
|
176
|
+
readonly importedBy: 'packages/server/src';
|
|
140
177
|
}, {
|
|
141
178
|
readonly specifier: '@guren/cli';
|
|
142
179
|
readonly kind: 'mcp';
|
|
143
180
|
readonly exportNames: readonly [];
|
|
144
|
-
|
|
145
|
-
readonly specifier: '@modelcontextprotocol/sdk/server/mcp.js';
|
|
146
|
-
readonly kind: 'mcp';
|
|
147
|
-
readonly exportNames: readonly ["McpServer", "ResourceTemplate"];
|
|
148
|
-
}, {
|
|
149
|
-
readonly specifier: '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
|
|
150
|
-
readonly kind: 'mcp';
|
|
151
|
-
readonly exportNames: readonly ["WebStandardStreamableHTTPServerTransport"];
|
|
181
|
+
readonly importedBy: 'packages/server/src';
|
|
152
182
|
}];
|
|
153
183
|
/** One entry of `DEV_ONLY_MODULES`, with its `kind` still narrowed. */
|
|
154
184
|
type DevOnlyModuleEntry = (typeof DEV_ONLY_MODULES)[number];
|
|
155
|
-
/**
|
|
156
|
-
* The specifier `@guren/plugin-mcp` lazily imports for the App MCP endpoint (RFC
|
|
157
|
-
* 0016 §7): the one `DEV_ONLY_MODULES` entry whose stubbing is conditional.
|
|
158
|
-
*/
|
|
159
|
-
declare const MCP_TRANSPORT_SPECIFIER = "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
|
|
160
185
|
/** The package an app declares to opt into the App MCP endpoint. */
|
|
161
186
|
declare const MCP_PLUGIN_PACKAGE = "@guren/plugin-mcp";
|
|
187
|
+
/** @deprecated The v1 MCP transport, which no Guren package imports since RFC 0028. */
|
|
188
|
+
declare const MCP_TRANSPORT_SPECIFIER = "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
|
|
189
|
+
/** @deprecated The v1 MCP SDK subpath prefix, which no Guren package imports since RFC 0028. */
|
|
190
|
+
declare const MCP_SDK_SUBPATH_PREFIX = "@modelcontextprotocol/sdk/";
|
|
162
191
|
/**
|
|
163
|
-
* Whether
|
|
164
|
-
*
|
|
165
|
-
* can silently compile the endpoint shut. `devDependencies` do not count (they do
|
|
166
|
-
* not ship). An absent, unreadable, or malformed manifest answers `false`: the
|
|
167
|
-
* transport stays stubbed, which is the safe direction.
|
|
192
|
+
* @deprecated Whether `@guren/plugin-mcp` is a runtime dependency. No longer decides
|
|
193
|
+
* any stub: nothing imports the v1 transport it once kept out of the stub list.
|
|
168
194
|
*/
|
|
169
195
|
declare function appUsesMcpPlugin(root: string): boolean;
|
|
170
196
|
/**
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
* `MCP_TRANSPORT_SPECIFIER` compiled the endpoint shut everywhere before RFC 0016
|
|
174
|
-
* Phase 4a). `server/mcp.js` stays stubbed: that is the Dev MCP. Each entry keeps
|
|
175
|
-
* its narrow `kind` so platform `Record<kind, message>` tables stay indexable.
|
|
197
|
+
* @deprecated `DEV_ONLY_MODULES`, whatever `mcpPlugin` says: the v1 transport entry
|
|
198
|
+
* this once dropped is no longer listed.
|
|
176
199
|
*/
|
|
177
|
-
declare function stubbableDevOnlyModules(
|
|
200
|
+
declare function stubbableDevOnlyModules(_options: {
|
|
178
201
|
mcpPlugin: boolean;
|
|
179
202
|
}): readonly DevOnlyModuleEntry[];
|
|
180
203
|
/** A database `@guren/orm` can connect through, named after the factory the app's config calls. */
|
|
@@ -208,21 +231,25 @@ declare const SQL_CLIENT_MODULES: readonly [{
|
|
|
208
231
|
readonly kind: 'sql-driver';
|
|
209
232
|
readonly dialect: 'postgres';
|
|
210
233
|
readonly exportNames: readonly [];
|
|
234
|
+
readonly importedBy: 'packages/orm/src';
|
|
211
235
|
}, {
|
|
212
236
|
readonly specifier: 'mysql2';
|
|
213
237
|
readonly kind: 'sql-driver';
|
|
214
238
|
readonly dialect: 'mysql';
|
|
215
239
|
readonly exportNames: readonly [];
|
|
240
|
+
readonly importedBy: 'packages/orm/src';
|
|
216
241
|
}, {
|
|
217
242
|
readonly specifier: 'mysql2/promise';
|
|
218
243
|
readonly kind: 'sql-driver';
|
|
219
244
|
readonly dialect: 'mysql';
|
|
220
245
|
readonly exportNames: readonly ["createPool"];
|
|
246
|
+
readonly importedBy: 'packages/orm/src';
|
|
221
247
|
}, {
|
|
222
248
|
readonly specifier: '@aws-sdk/client-rds-data';
|
|
223
249
|
readonly kind: 'sql-driver';
|
|
224
250
|
readonly dialect: 'aws-data-api';
|
|
225
251
|
readonly exportNames: readonly ["RDSDataClient", "BeginTransactionCommand", "CommitTransactionCommand", "ExecuteStatementCommand", "RollbackTransactionCommand"];
|
|
252
|
+
readonly importedBy: 'packages/orm/src';
|
|
226
253
|
}];
|
|
227
254
|
type SqlClientSpecifier = (typeof SQL_CLIENT_MODULES)[number]['specifier'];
|
|
228
255
|
/**
|
|
@@ -282,12 +309,6 @@ type DevOnlySpecifier = (typeof DEV_ONLY_MODULES)[number]['specifier'];
|
|
|
282
309
|
* called without `new` would hide the real reason).
|
|
283
310
|
* @param message Platform-specific explanation, including the replacement API.
|
|
284
311
|
*/
|
|
285
|
-
declare function renderDevOnlyStub(module: DevOnlyModule, message: string): string;
|
|
286
|
-
/**
|
|
287
|
-
* The MCP SDK is reached only through subpaths, which a package-name alias does not
|
|
288
|
-
* cover (hence each one in `DEV_ONLY_MODULES`). A platform whose aliasing supports
|
|
289
|
-
* prefixes should route unlisted subpaths under this prefix to a stub too.
|
|
290
|
-
*/
|
|
291
|
-
declare const MCP_SDK_SUBPATH_PREFIX = "@modelcontextprotocol/sdk/";
|
|
312
|
+
declare function renderDevOnlyStub(module: Pick<DevOnlyModule, 'exportNames'>, message: string): string;
|
|
292
313
|
//#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 };
|
|
314
|
+
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,42 +301,31 @@ 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: []
|
|
254
|
-
|
|
255
|
-
{
|
|
256
|
-
specifier: "@modelcontextprotocol/sdk/server/mcp.js",
|
|
257
|
-
kind: "mcp",
|
|
258
|
-
exportNames: ["McpServer", "ResourceTemplate"]
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
specifier: "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js",
|
|
262
|
-
kind: "mcp",
|
|
263
|
-
exportNames: ["WebStandardStreamableHTTPServerTransport"]
|
|
316
|
+
exportNames: [],
|
|
317
|
+
importedBy: "packages/server/src"
|
|
264
318
|
}
|
|
265
319
|
];
|
|
266
|
-
/**
|
|
267
|
-
* The specifier `@guren/plugin-mcp` lazily imports for the App MCP endpoint (RFC
|
|
268
|
-
* 0016 §7): the one `DEV_ONLY_MODULES` entry whose stubbing is conditional.
|
|
269
|
-
*/
|
|
270
|
-
const MCP_TRANSPORT_SPECIFIER = "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
|
|
271
320
|
/** The package an app declares to opt into the App MCP endpoint. */
|
|
272
321
|
const MCP_PLUGIN_PACKAGE = "@guren/plugin-mcp";
|
|
322
|
+
/** @deprecated The v1 MCP transport, which no Guren package imports since RFC 0028. */
|
|
323
|
+
const MCP_TRANSPORT_SPECIFIER = "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
|
|
324
|
+
/** @deprecated The v1 MCP SDK subpath prefix, which no Guren package imports since RFC 0028. */
|
|
325
|
+
const MCP_SDK_SUBPATH_PREFIX = "@modelcontextprotocol/sdk/";
|
|
273
326
|
/**
|
|
274
|
-
* Whether
|
|
275
|
-
*
|
|
276
|
-
* can silently compile the endpoint shut. `devDependencies` do not count (they do
|
|
277
|
-
* not ship). An absent, unreadable, or malformed manifest answers `false`: the
|
|
278
|
-
* transport stays stubbed, which is the safe direction.
|
|
327
|
+
* @deprecated Whether `@guren/plugin-mcp` is a runtime dependency. No longer decides
|
|
328
|
+
* any stub: nothing imports the v1 transport it once kept out of the stub list.
|
|
279
329
|
*/
|
|
280
330
|
function appUsesMcpPlugin(root) {
|
|
281
331
|
try {
|
|
@@ -286,15 +336,11 @@ function appUsesMcpPlugin(root) {
|
|
|
286
336
|
}
|
|
287
337
|
}
|
|
288
338
|
/**
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
* `MCP_TRANSPORT_SPECIFIER` compiled the endpoint shut everywhere before RFC 0016
|
|
292
|
-
* Phase 4a). `server/mcp.js` stays stubbed: that is the Dev MCP. Each entry keeps
|
|
293
|
-
* its narrow `kind` so platform `Record<kind, message>` tables stay indexable.
|
|
339
|
+
* @deprecated `DEV_ONLY_MODULES`, whatever `mcpPlugin` says: the v1 transport entry
|
|
340
|
+
* this once dropped is no longer listed.
|
|
294
341
|
*/
|
|
295
|
-
function stubbableDevOnlyModules(
|
|
296
|
-
|
|
297
|
-
return DEV_ONLY_MODULES.filter((module) => module.specifier !== MCP_TRANSPORT_SPECIFIER);
|
|
342
|
+
function stubbableDevOnlyModules(_options) {
|
|
343
|
+
return DEV_ONLY_MODULES;
|
|
298
344
|
}
|
|
299
345
|
/**
|
|
300
346
|
* The `@guren/orm` factory names an app's config calls, with each one's dialect.
|
|
@@ -321,19 +367,22 @@ const SQL_CLIENT_MODULES = [
|
|
|
321
367
|
specifier: "postgres",
|
|
322
368
|
kind: "sql-driver",
|
|
323
369
|
dialect: "postgres",
|
|
324
|
-
exportNames: []
|
|
370
|
+
exportNames: [],
|
|
371
|
+
importedBy: "packages/orm/src"
|
|
325
372
|
},
|
|
326
373
|
{
|
|
327
374
|
specifier: "mysql2",
|
|
328
375
|
kind: "sql-driver",
|
|
329
376
|
dialect: "mysql",
|
|
330
|
-
exportNames: []
|
|
377
|
+
exportNames: [],
|
|
378
|
+
importedBy: "packages/orm/src"
|
|
331
379
|
},
|
|
332
380
|
{
|
|
333
381
|
specifier: "mysql2/promise",
|
|
334
382
|
kind: "sql-driver",
|
|
335
383
|
dialect: "mysql",
|
|
336
|
-
exportNames: ["createPool"]
|
|
384
|
+
exportNames: ["createPool"],
|
|
385
|
+
importedBy: "packages/orm/src"
|
|
337
386
|
},
|
|
338
387
|
{
|
|
339
388
|
specifier: "@aws-sdk/client-rds-data",
|
|
@@ -345,7 +394,8 @@ const SQL_CLIENT_MODULES = [
|
|
|
345
394
|
"CommitTransactionCommand",
|
|
346
395
|
"ExecuteStatementCommand",
|
|
347
396
|
"RollbackTransactionCommand"
|
|
348
|
-
]
|
|
397
|
+
],
|
|
398
|
+
importedBy: "packages/orm/src"
|
|
349
399
|
}
|
|
350
400
|
];
|
|
351
401
|
/**
|
|
@@ -444,11 +494,5 @@ function renderDevOnlyStub(module, message) {
|
|
|
444
494
|
const named = module.exportNames.length > 0 ? `, { ${module.exportNames.join(", ")} }` : "";
|
|
445
495
|
return `// ${comment}\n${throwing}\n${`function unavailable() { ${error} }`}\nexport default Object.assign(unavailable${named})\n`;
|
|
446
496
|
}
|
|
447
|
-
/**
|
|
448
|
-
* The MCP SDK is reached only through subpaths, which a package-name alias does not
|
|
449
|
-
* cover (hence each one in `DEV_ONLY_MODULES`). A platform whose aliasing supports
|
|
450
|
-
* prefixes should route unlisted subpaths under this prefix to a stub too.
|
|
451
|
-
*/
|
|
452
|
-
const MCP_SDK_SUBPATH_PREFIX = "@modelcontextprotocol/sdk/";
|
|
453
497
|
//#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 };
|
|
498
|
+
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.20.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.25.0",
|
|
92
|
+
"@guren/orm": "^2.11.0",
|
|
93
|
+
"@guren/server": "^2.25.0"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
96
96
|
"@types/node": "^20.14.10",
|