nitro-drizzle 0.3.0-beta.6 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/config/defineConfig.d.mts +2 -6
- package/dist/config/defineConfig.mjs +1 -2
- package/dist/config.mjs +1 -2
- package/dist/context/internal/async.mjs +1 -2
- package/dist/context/internal/codegen.mjs +1 -2
- package/dist/context/internal/config.mjs +2 -3
- package/dist/context/internal/format.mjs +1 -2
- package/dist/context/internal/fs.mjs +1 -2
- package/dist/context/internal/logger.mjs +1 -2
- package/dist/context/internal/templates.mjs +3 -4
- package/dist/context/internal/templates.mjs.map +1 -1
- package/dist/context/internal/virtual.mjs +4 -3
- package/dist/context/internal/virtual.mjs.map +1 -1
- package/dist/context.d.mts +13 -16
- package/dist/context.mjs +34 -13
- package/dist/context.mjs.map +1 -1
- package/dist/dialects/index.d.mts +9 -12
- package/dist/dialects/mysql.d.mts +4 -8
- package/dist/dialects/mysql.mjs +1 -2
- package/dist/dialects/postgresql.d.mts +4 -8
- package/dist/dialects/postgresql.mjs +1 -2
- package/dist/dialects/sqlite.d.mts +4 -8
- package/dist/dialects/sqlite.mjs +1 -2
- package/dist/drivers/d1/dialect.mjs +1 -2
- package/dist/drivers/d1-http.d.mts +7 -10
- package/dist/drivers/d1-http.mjs +3 -4
- package/dist/drivers/d1-http.mjs.map +1 -1
- package/dist/drivers/d1.d.mts +3 -7
- package/dist/drivers/d1.mjs +4 -5
- package/dist/drivers/d1.mjs.map +1 -1
- package/dist/drivers/index.d.mts +6 -10
- package/dist/drivers/index.mjs +1 -2
- package/dist/drivers/internal/sql.mjs +1 -2
- package/dist/drivers/mysql.d.mts +2 -5
- package/dist/drivers/mysql.mjs +3 -4
- package/dist/drivers/pglite.d.mts +2 -5
- package/dist/drivers/pglite.mjs +2 -3
- package/dist/drivers/postgresql.d.mts +3 -6
- package/dist/drivers/postgresql.mjs +3 -4
- package/dist/drivers/sqlite.d.mts +3 -6
- package/dist/drivers/sqlite.mjs +3 -4
- package/dist/index.mjs +1 -2
- package/dist/meta.d.mts +2 -5
- package/dist/meta.mjs +1 -2
- package/dist/middleware/context.d.mts +7 -21
- package/dist/middleware/context.mjs +5 -25
- package/dist/middleware/context.mjs.map +1 -1
- package/dist/migrations/internal/migrate.d.mts +3 -7
- package/dist/migrations/internal/migrate.mjs +1 -2
- package/dist/migrations/internal/migrate.mjs.map +1 -1
- package/dist/migrations/migrate.d.mts +4 -7
- package/dist/migrations/migrate.mjs +3 -4
- package/dist/migrations/task.d.mts +1 -4
- package/dist/migrations/task.mjs +1 -2
- package/dist/migrations/useMigrations.d.mts +8 -12
- package/dist/migrations/useMigrations.mjs +3 -4
- package/dist/module/internal/fs.mjs +5 -6
- package/dist/module/internal/fs.mjs.map +1 -1
- package/dist/module/internal/path.mjs +1 -2
- package/dist/module/internal/reload.mjs +1 -2
- package/dist/module/internal/reload.mjs.map +1 -1
- package/dist/module/internal/resolver.mjs +1 -2
- package/dist/module/internal/resolver.mjs.map +1 -1
- package/dist/module/internal/rollup.mjs +1 -2
- package/dist/module/internal/types.mjs +21 -19
- package/dist/module/internal/types.mjs.map +1 -1
- package/dist/module/utils/assets.d.mts +1 -5
- package/dist/module/utils/assets.mjs +1 -2
- package/dist/module/utils/externals.d.mts +1 -5
- package/dist/module/utils/externals.mjs +1 -2
- package/dist/module/utils/nitro.d.mts +1 -5
- package/dist/module/utils/nitro.mjs +1 -2
- package/dist/module.d.mts +11 -21
- package/dist/module.mjs +27 -19
- package/dist/module.mjs.map +1 -1
- package/dist/plugins/init/index.d.mts +6 -0
- package/dist/plugins/init/index.mjs +20 -0
- package/dist/plugins/init/index.mjs.map +1 -0
- package/dist/plugins/init/legacy.d.mts +15 -0
- package/dist/plugins/init/legacy.mjs +26 -0
- package/dist/plugins/init/legacy.mjs.map +1 -0
- package/dist/plugins/{migrate.d.mts → migrate/hooks.d.mts} +3 -16
- package/dist/plugins/migrate/hooks.mjs +10 -0
- package/dist/plugins/migrate/hooks.mjs.map +1 -0
- package/dist/plugins/migrate/index.d.mts +11 -0
- package/dist/plugins/{migrate.mjs → migrate/index.mjs} +10 -10
- package/dist/plugins/migrate/index.mjs.map +1 -0
- package/dist/plugins/migrate/legacy.d.mts +11 -0
- package/dist/plugins/migrate/legacy.mjs +25 -0
- package/dist/plugins/migrate/legacy.mjs.map +1 -0
- package/dist/runtime/callInitHook.d.mts +8 -0
- package/dist/runtime/callInitHook.mjs +27 -0
- package/dist/runtime/callInitHook.mjs.map +1 -0
- package/dist/runtime/internal/config.mjs +1 -2
- package/dist/runtime/internal/createDatasource.mjs +4 -5
- package/dist/runtime/internal/hooks.d.mts +14 -0
- package/dist/runtime/internal/hooks.mjs +5 -0
- package/dist/runtime/internal/hooks.mjs.map +1 -0
- package/dist/runtime/internal/state.d.mts +10 -0
- package/dist/runtime/internal/state.mjs +28 -0
- package/dist/runtime/internal/state.mjs.map +1 -0
- package/dist/runtime/useConfig.d.mts +2 -6
- package/dist/runtime/useConfig.mjs +1 -2
- package/dist/runtime/useDatasource.d.mts +3 -7
- package/dist/runtime/useDatasource.mjs +2 -3
- package/dist/runtime/useDialect.d.mts +5 -8
- package/dist/runtime/useDialect.mjs +2 -3
- package/dist/runtime.d.mts +22 -22
- package/dist/runtime.mjs +4 -1
- package/dist/shared/variants.d.mts +7 -10
- package/dist/shared/variants.mjs +1 -2
- package/dist/shared.d.mts +7 -10
- package/dist/shared.mjs +1 -2
- package/dist/utils/usePrimaryKey.d.mts +1 -5
- package/dist/utils/usePrimaryKey.mjs +1 -2
- package/dist/utils.mjs +1 -2
- package/package.json +35 -31
- package/dist/drivers/db0.d.mts +0 -21
- package/dist/drivers/db0.mjs +0 -28
- package/dist/drivers/db0.mjs.map +0 -1
- package/dist/plugins/init.d.mts +0 -15
- package/dist/plugins/init.mjs +0 -13
- package/dist/plugins/init.mjs.map +0 -1
- package/dist/plugins/legacy/init.d.mts +0 -24
- package/dist/plugins/legacy/init.mjs +0 -50
- package/dist/plugins/legacy/init.mjs.map +0 -1
- package/dist/plugins/legacy/migrate.d.mts +0 -21
- package/dist/plugins/legacy/migrate.mjs +0 -25
- package/dist/plugins/legacy/migrate.mjs.map +0 -1
- package/dist/plugins/migrate.mjs.map +0 -1
package/dist/meta.d.mts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
//#region src/meta.d.ts
|
|
2
1
|
declare const pkgName: string;
|
|
3
2
|
/** Directory path of the package. */
|
|
4
|
-
declare const pkgDir: string;
|
|
5
|
-
|
|
6
|
-
export { pkgDir, pkgName };
|
|
7
|
-
//# sourceMappingURL=meta.d.mts.map
|
|
3
|
+
export declare const pkgDir: string;
|
|
4
|
+
export { pkgName };
|
package/dist/meta.mjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { URL, fileURLToPath } from "node:url";
|
|
2
2
|
import packageJson from "nitro-drizzle/package.json" with { type: "json" };
|
|
3
|
-
|
|
3
|
+
// src/meta.ts
|
|
4
4
|
const { name: pkgName } = packageJson;
|
|
5
5
|
/** Directory path of the package. */
|
|
6
6
|
const pkgDir = fileURLToPath(new URL(".", import.meta.resolve("nitro-drizzle/package.json")));
|
|
7
|
-
//#endregion
|
|
8
7
|
export { pkgDir, pkgName };
|
|
9
8
|
|
|
10
9
|
//# sourceMappingURL=meta.mjs.map
|
|
@@ -1,32 +1,18 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import { DrizzleInitHooks, DrizzleInitState } from "nitro-drizzle/runtime";
|
|
2
2
|
import { Middleware } from "nitro/h3";
|
|
3
|
-
//#region src/middleware/context.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Nitro middleware that initializes the Drizzle context on each request.
|
|
6
5
|
* Sets up the `drizzle` property on the event context with readiness state and wait capability.
|
|
7
6
|
*/
|
|
8
7
|
declare const middleware: Middleware;
|
|
9
|
-
/** The readiness state of the Drizzle initialization. */
|
|
10
|
-
type ReadyState = "pending" | "done" | "error";
|
|
11
|
-
/** Hooks for Drizzle initialization. */
|
|
12
|
-
type InitHooks = {
|
|
13
|
-
"drizzle:init": () => void;
|
|
14
|
-
};
|
|
15
8
|
declare module "nitro/types" {
|
|
16
|
-
interface NitroRuntimeHooks extends
|
|
17
|
-
}
|
|
18
|
-
/** Context provided by the Drizzle middleware on the event context. */
|
|
19
|
-
interface DrizzleContext {
|
|
20
|
-
readonly readyState: ReadyState;
|
|
21
|
-
readonly waitReady: () => Promise<void>;
|
|
9
|
+
interface NitroRuntimeHooks extends DrizzleInitHooks {}
|
|
22
10
|
}
|
|
23
11
|
/** Event context extension for Drizzle. */
|
|
24
|
-
interface
|
|
25
|
-
drizzle:
|
|
12
|
+
export interface DrizzleEventContext {
|
|
13
|
+
drizzle: DrizzleInitState;
|
|
26
14
|
}
|
|
27
|
-
declare module "
|
|
28
|
-
interface
|
|
15
|
+
declare module "nitro/h3" {
|
|
16
|
+
interface H3EventContext extends DrizzleEventContext {}
|
|
29
17
|
}
|
|
30
|
-
|
|
31
|
-
export { DrizzleContext, EventContext, InitHooks, ReadyState, middleware as default };
|
|
32
|
-
//# sourceMappingURL=context.d.mts.map
|
|
18
|
+
export { middleware as default };
|
|
@@ -1,35 +1,15 @@
|
|
|
1
1
|
import { defineMiddleware } from "nitro";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
//#region src/middleware/context.ts
|
|
5
|
-
let eventContext;
|
|
2
|
+
import { useInitState } from "nitro-drizzle/runtime";
|
|
3
|
+
// src/middleware/context.ts
|
|
6
4
|
/**
|
|
7
5
|
* Nitro middleware that initializes the Drizzle context on each request.
|
|
8
6
|
* Sets up the `drizzle` property on the event context with readiness state and wait capability.
|
|
9
7
|
*/
|
|
10
8
|
const middleware = defineMiddleware((event) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
let initHook;
|
|
15
|
-
initHook = Promise.resolve(hooks.callHook("drizzle:init")).then(() => {
|
|
16
|
-
readyState = "done";
|
|
17
|
-
}).catch((err) => {
|
|
18
|
-
readyState = "error";
|
|
19
|
-
throw err;
|
|
20
|
-
});
|
|
21
|
-
eventContext = {
|
|
22
|
-
get readyState() {
|
|
23
|
-
return readyState;
|
|
24
|
-
},
|
|
25
|
-
waitReady: async () => {
|
|
26
|
-
await initHook;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
event.context.drizzle = eventContext;
|
|
9
|
+
const state = useInitState();
|
|
10
|
+
event.context.drizzle = state;
|
|
11
|
+
event.waitUntil(state.waitReady());
|
|
31
12
|
});
|
|
32
|
-
//#endregion
|
|
33
13
|
export { middleware as default };
|
|
34
14
|
|
|
35
15
|
//# sourceMappingURL=context.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.mjs","names":[],"sources":["../../src/middleware/context.ts"],"sourcesContent":["import { defineMiddleware } from \"nitro\";\nimport {
|
|
1
|
+
{"version":3,"file":"context.mjs","names":[],"sources":["../../src/middleware/context.ts"],"sourcesContent":["import { defineMiddleware } from \"nitro\";\nimport { useInitState, type DrizzleInitHooks, type DrizzleInitState } from \"nitro-drizzle/runtime\";\nimport type { Middleware } from \"nitro/h3\";\n\n/**\n * Nitro middleware that initializes the Drizzle context on each request.\n * Sets up the `drizzle` property on the event context with readiness state and wait capability.\n */\nconst middleware: Middleware = defineMiddleware((event): void => {\n const state = useInitState();\n event.context.drizzle = state;\n event.waitUntil(state.waitReady());\n});\n\nexport default middleware;\n\ndeclare module \"nitro/types\" {\n interface NitroRuntimeHooks extends DrizzleInitHooks {}\n}\n\n/** Event context extension for Drizzle. */\nexport interface DrizzleEventContext {\n drizzle: DrizzleInitState;\n}\n\ndeclare module \"nitro/h3\" {\n interface H3EventContext extends DrizzleEventContext {}\n}\n"],"mappings":";;;;;;;AAQA,MAAM,aAAyB,kBAAkB,UAAgB;CAC/D,MAAM,QAAQ,aAAa;CAC3B,MAAM,QAAQ,UAAU;CACxB,MAAM,UAAU,MAAM,UAAU,CAAC;AACnC,CAAC"}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import { MigrationMeta } from "drizzle-orm/migrator";
|
|
2
|
-
//#region src/migrations/internal/migrate.d.ts
|
|
3
2
|
/** Configuration options for database migrations. */
|
|
4
|
-
type MigrationConfig = Partial<{
|
|
3
|
+
export type MigrationConfig = Partial<{
|
|
5
4
|
/** Schema name for migrations. */
|
|
6
5
|
schema: string;
|
|
7
6
|
/** Table name for storing migration metadata. */
|
|
8
7
|
table: string;
|
|
9
8
|
}>;
|
|
10
9
|
/** Migration information including SQL statements and metadata. */
|
|
11
|
-
interface Migration extends MigrationMeta {
|
|
10
|
+
export interface Migration extends MigrationMeta {
|
|
12
11
|
idx: number;
|
|
13
12
|
filename: string;
|
|
14
|
-
}
|
|
15
|
-
//#endregion
|
|
16
|
-
export { Migration, MigrationConfig };
|
|
17
|
-
//# sourceMappingURL=migrate.d.mts.map
|
|
13
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/migrations/internal/migrate.ts
|
|
2
2
|
/**
|
|
3
3
|
* Migrates a database using the provided migrations.
|
|
4
4
|
* @template TSession - The session type
|
|
@@ -27,7 +27,6 @@ var MigrationError = class extends Error {
|
|
|
27
27
|
this.data = data;
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
|
-
//#endregion
|
|
31
30
|
export { MigrationError, migrateDatabase };
|
|
32
31
|
|
|
33
32
|
//# sourceMappingURL=migrate.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.mjs","names":[],"sources":["../../../src/migrations/internal/migrate.ts"],"sourcesContent":["import type {\n MigrationConfig as DrizzleMigrationConfig,\n MigrationMeta,\n} from \"drizzle-orm/migrator\";\n\n/** Configuration options for database migrations. */\nexport type MigrationConfig = Partial<{\n /** Schema name for migrations. */\n schema: string;\n /** Table name for storing migration metadata. */\n table: string;\n}>;\n\n/**\n * Migrates a database using the provided migrations.\n * @template TSession - The session type\n * @param database - The Drizzle database instance\n * @param migrations - Iterable or async iterable of migrations\n * @param config - Migration configuration options\n */\nexport async function migrateDatabase<TSession = any>(\n database: DrizzleDatabase<TSession>,\n migrations: Iterable<Migration> | AsyncIterable<Migration>,\n config?: MigrationConfig,\n) {\n for await (const { filename, idx, ...migrationsMeta } of migrations) {\n try {\n await database.dialect.migrate([migrationsMeta], database.session, {\n migrationsSchema: config?.schema,\n migrationsTable: config?.table,\n });\n } catch (cause) {\n throw new MigrationError({ migration: { idx, filename } }, cause);\n }\n }\n}\n\n/** Options for creating a MigrationError. */\nexport interface MigrationErrorOptions {\n migration: Pick<Migration, \"idx\" | \"filename\">;\n}\n\n/** Error thrown when a migration fails. */\nexport class MigrationError extends Error {\n constructor(\n readonly data: MigrationErrorOptions,\n cause: unknown,\n ) {\n super(`Migration failed: ${data.migration.filename}#${data.migration.idx}`, { cause });\n }\n}\n\n/** Interface for a Drizzle database dialect with migrate capabilities. */\nexport interface DrizzleDatabaseDialect<TSession = any> {\n migrate(\n migrations: Iterable<MigrationMeta>,\n session: TSession,\n config: Partial<DrizzleMigrationConfig> | string,\n ): any;\n}\n\n/** Interface for a Drizzle database instance. */\nexport interface DrizzleDatabase<TSession = any> {\n dialect: DrizzleDatabaseDialect<TSession>;\n session: TSession;\n}\n\n/** Migration information including SQL statements and metadata. */\nexport interface Migration extends MigrationMeta {\n idx: number;\n filename: string;\n}\n"],"mappings":";;;;;;;;AAoBA,eAAsB,gBACpB,UACA,YACA,QACA;CACA,WAAW,MAAM,EAAE,UAAU,KAAK,GAAG,oBAAoB,YACvD,IAAI;EACF,MAAM,SAAS,QAAQ,QAAQ,CAAC,cAAc,GAAG,SAAS,SAAS;GACjE,kBAAkB,QAAQ;GAC1B,iBAAiB,QAAQ;EAC3B,CAAC;CACH,SAAS,OAAO;EACd,MAAM,IAAI,eAAe,EAAE,WAAW;GAAE;GAAK;EAAS,EAAE,GAAG,KAAK;CAClE;AAEJ;;AAQA,IAAa,iBAAb,cAAoC,MAAM;CAE7B;CADX,
|
|
1
|
+
{"version":3,"file":"migrate.mjs","names":[],"sources":["../../../src/migrations/internal/migrate.ts"],"sourcesContent":["import type {\n MigrationConfig as DrizzleMigrationConfig,\n MigrationMeta,\n} from \"drizzle-orm/migrator\";\n\n/** Configuration options for database migrations. */\nexport type MigrationConfig = Partial<{\n /** Schema name for migrations. */\n schema: string;\n /** Table name for storing migration metadata. */\n table: string;\n}>;\n\n/**\n * Migrates a database using the provided migrations.\n * @template TSession - The session type\n * @param database - The Drizzle database instance\n * @param migrations - Iterable or async iterable of migrations\n * @param config - Migration configuration options\n */\nexport async function migrateDatabase<TSession = any>(\n database: DrizzleDatabase<TSession>,\n migrations: Iterable<Migration> | AsyncIterable<Migration>,\n config?: MigrationConfig,\n) {\n for await (const { filename, idx, ...migrationsMeta } of migrations) {\n try {\n await database.dialect.migrate([migrationsMeta], database.session, {\n migrationsSchema: config?.schema,\n migrationsTable: config?.table,\n });\n } catch (cause) {\n throw new MigrationError({ migration: { idx, filename } }, cause);\n }\n }\n}\n\n/** Options for creating a MigrationError. */\nexport interface MigrationErrorOptions {\n migration: Pick<Migration, \"idx\" | \"filename\">;\n}\n\n/** Error thrown when a migration fails. */\nexport class MigrationError extends Error {\n constructor(\n readonly data: MigrationErrorOptions,\n cause: unknown,\n ) {\n super(`Migration failed: ${data.migration.filename}#${data.migration.idx}`, { cause });\n }\n}\n\n/** Interface for a Drizzle database dialect with migrate capabilities. */\nexport interface DrizzleDatabaseDialect<TSession = any> {\n migrate(\n migrations: Iterable<MigrationMeta>,\n session: TSession,\n config: Partial<DrizzleMigrationConfig> | string,\n ): any;\n}\n\n/** Interface for a Drizzle database instance. */\nexport interface DrizzleDatabase<TSession = any> {\n dialect: DrizzleDatabaseDialect<TSession>;\n session: TSession;\n}\n\n/** Migration information including SQL statements and metadata. */\nexport interface Migration extends MigrationMeta {\n idx: number;\n filename: string;\n}\n"],"mappings":";;;;;;;;AAoBA,eAAsB,gBACpB,UACA,YACA,QACA;CACA,WAAW,MAAM,EAAE,UAAU,KAAK,GAAG,oBAAoB,YACvD,IAAI;EACF,MAAM,SAAS,QAAQ,QAAQ,CAAC,cAAc,GAAG,SAAS,SAAS;GACjE,kBAAkB,QAAQ;GAC1B,iBAAiB,QAAQ;EAC3B,CAAC;CACH,SAAS,OAAO;EACd,MAAM,IAAI,eAAe,EAAE,WAAW;GAAE;GAAK;EAAS,EAAE,GAAG,KAAK;CAClE;AAEJ;;AAQA,IAAa,iBAAb,cAAoC,MAAM;CAE7B;CADX,YACW,MACT,OACA;EACA,MAAM,qBAAqB,KAAK,UAAU,SAAS,GAAG,KAAK,UAAU,OAAO,EAAE,MAAM,CAAC;EAH5E,KAAA,OAAA;CAIX;AACF"}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import { MigrationConfig } from "./internal/migrate.mjs";
|
|
2
1
|
import { DatasourceRegistry } from "nitro-drizzle/runtime";
|
|
3
|
-
|
|
2
|
+
import { MigrationConfig } from "./internal/migrate.mjs";
|
|
4
3
|
/** Result of a migration operation. */
|
|
5
|
-
type MigrationResult = {};
|
|
4
|
+
export type MigrationResult = {};
|
|
6
5
|
/**
|
|
7
6
|
* Runs migrations for a specific datasource.
|
|
8
7
|
* @template TName - The datasource name
|
|
9
8
|
* @param name - The datasource name to migrate
|
|
10
9
|
* @returns Migration result
|
|
11
10
|
*/
|
|
12
|
-
declare function migrate<TName extends keyof DatasourceRegistry & string>(name: TName): Promise<MigrationResult>;
|
|
13
|
-
|
|
14
|
-
export { type MigrationConfig, MigrationResult, migrate };
|
|
15
|
-
//# sourceMappingURL=migrate.d.mts.map
|
|
11
|
+
export declare function migrate<TName extends keyof DatasourceRegistry & string>(name: TName): Promise<MigrationResult>;
|
|
12
|
+
export type { MigrationConfig };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { useMigrations } from "./useMigrations.mjs";
|
|
2
|
-
import { migrateDatabase } from "./internal/migrate.mjs";
|
|
3
1
|
import { useConfig, useDatasource } from "nitro-drizzle/runtime";
|
|
4
2
|
import { migrationConfig } from "#nitro-drizzle/migrations";
|
|
5
|
-
|
|
3
|
+
import { useMigrations } from "./useMigrations.mjs";
|
|
4
|
+
import { migrateDatabase } from "./internal/migrate.mjs";
|
|
5
|
+
// src/migrations/migrate.ts
|
|
6
6
|
/**
|
|
7
7
|
* Runs migrations for a specific datasource.
|
|
8
8
|
* @template TName - The datasource name
|
|
@@ -18,7 +18,6 @@ async function migrate(name) {
|
|
|
18
18
|
await migrateDatabase(database, migrations, config);
|
|
19
19
|
return {};
|
|
20
20
|
}
|
|
21
|
-
//#endregion
|
|
22
21
|
export { migrate };
|
|
23
22
|
|
|
24
23
|
//# sourceMappingURL=migrate.mjs.map
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { MigrationResult } from "./migrate.mjs";
|
|
2
2
|
import { Task } from "nitropack/types";
|
|
3
3
|
import { Task as Task$1 } from "nitro/types";
|
|
4
|
-
//#region src/migrations/task.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Nitro task that runs Drizzle migrations for a datasource.
|
|
7
6
|
* Invoked via `npx nitro task drizzle:migrate` with the datasource name in the payload.
|
|
8
7
|
*/
|
|
9
8
|
declare const task: Task$1<MigrationResult> | Task<MigrationResult>;
|
|
10
|
-
|
|
11
|
-
export { task as default };
|
|
12
|
-
//# sourceMappingURL=task.d.mts.map
|
|
9
|
+
export { task as default };
|
package/dist/migrations/task.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { migrate } from "./migrate.mjs";
|
|
2
|
-
|
|
2
|
+
// src/migrations/task.ts
|
|
3
3
|
/**
|
|
4
4
|
* Nitro task that runs Drizzle migrations for a datasource.
|
|
5
5
|
* Invoked via `npx nitro task drizzle:migrate` with the datasource name in the payload.
|
|
@@ -8,7 +8,6 @@ const task = { async run(event) {
|
|
|
8
8
|
const { name } = event.payload;
|
|
9
9
|
return { result: await migrate(name) };
|
|
10
10
|
} };
|
|
11
|
-
//#endregion
|
|
12
11
|
export { task as default };
|
|
13
12
|
|
|
14
13
|
//# sourceMappingURL=task.mjs.map
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { Migration } from "./internal/migrate.mjs";
|
|
2
|
-
import { DatasourceRegistry } from "nitro-drizzle/runtime";
|
|
3
1
|
import { Storage } from "unstorage";
|
|
4
|
-
|
|
2
|
+
import { DatasourceRegistry } from "nitro-drizzle/runtime";
|
|
3
|
+
import { Migration } from "./internal/migrate.mjs";
|
|
5
4
|
/**
|
|
6
5
|
* Gets the storage for a specific datasource's migrations.
|
|
7
6
|
* @template TName - The datasource name
|
|
8
7
|
* @param name - The datasource name
|
|
9
8
|
* @returns Storage instance for migrations
|
|
10
9
|
*/
|
|
11
|
-
declare function useMigrationsStorage<TName extends keyof DatasourceRegistry & string>(name: TName): Storage<string>;
|
|
10
|
+
export declare function useMigrationsStorage<TName extends keyof DatasourceRegistry & string>(name: TName): Storage<string>;
|
|
12
11
|
/** Storage key for the migration journal. */
|
|
13
|
-
declare const JOURNAL_STORAGE_KEY: "meta/_journal.json";
|
|
12
|
+
export declare const JOURNAL_STORAGE_KEY: "meta/_journal.json";
|
|
14
13
|
/**
|
|
15
14
|
* Gets an async iterable of migrations for a specific datasource.
|
|
16
15
|
* @template TName - The datasource name
|
|
@@ -18,9 +17,9 @@ declare const JOURNAL_STORAGE_KEY: "meta/_journal.json";
|
|
|
18
17
|
* @returns Async iterable of migrations
|
|
19
18
|
* @throws If migration journal is not found
|
|
20
19
|
*/
|
|
21
|
-
declare function useMigrations<TName extends keyof DatasourceRegistry & string>(name: TName): Promise<AsyncIterable<Migration>>;
|
|
20
|
+
export declare function useMigrations<TName extends keyof DatasourceRegistry & string>(name: TName): Promise<AsyncIterable<Migration>>;
|
|
22
21
|
/** Single entry in the migration journal. */
|
|
23
|
-
interface MigrationJournalItem {
|
|
22
|
+
export interface MigrationJournalItem {
|
|
24
23
|
/** Migration index/order number. */
|
|
25
24
|
idx: number;
|
|
26
25
|
/** Migration version string. */
|
|
@@ -36,10 +35,7 @@ interface MigrationJournalItem {
|
|
|
36
35
|
* Migration journal containing all migration entries.
|
|
37
36
|
* @see https://github.com/drizzle-team/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/utils.ts#L63
|
|
38
37
|
*/
|
|
39
|
-
interface MigrationJournal {
|
|
38
|
+
export interface MigrationJournal {
|
|
40
39
|
/** List of migration entries. */
|
|
41
40
|
entries: Iterable<MigrationJournalItem>;
|
|
42
|
-
}
|
|
43
|
-
//#endregion
|
|
44
|
-
export { JOURNAL_STORAGE_KEY, MigrationJournal, MigrationJournalItem, useMigrations, useMigrationsStorage };
|
|
45
|
-
//# sourceMappingURL=useMigrations.d.mts.map
|
|
41
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { useStorage } from "#nitro-drizzle/runtime";
|
|
2
|
-
import { useConfig } from "nitro-drizzle/runtime";
|
|
3
1
|
import { digest } from "ohash";
|
|
4
2
|
import { MIGRATIONS_STORAGE_BASE } from "#nitro-drizzle/migrations";
|
|
5
|
-
|
|
3
|
+
import { useStorage } from "#nitro-drizzle/runtime";
|
|
4
|
+
import { useConfig } from "nitro-drizzle/runtime";
|
|
5
|
+
// src/migrations/useMigrations.ts
|
|
6
6
|
/**
|
|
7
7
|
* Gets the storage for a specific datasource's migrations.
|
|
8
8
|
* @template TName - The datasource name
|
|
@@ -44,7 +44,6 @@ async function* generate(journal, storage) {
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
//#endregion
|
|
48
47
|
export { JOURNAL_STORAGE_KEY, useMigrations, useMigrationsStorage };
|
|
49
48
|
|
|
50
49
|
//# sourceMappingURL=useMigrations.mjs.map
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
+
import { mkdir, writeFile as writeFile$1 } from "node:fs/promises";
|
|
1
2
|
import { dirname } from "pathe";
|
|
2
|
-
|
|
3
|
-
//#region src/module/internal/fs.ts
|
|
3
|
+
// src/module/internal/fs.ts
|
|
4
4
|
/**
|
|
5
5
|
* Writes a file to disk, creating parent directories as needed.
|
|
6
6
|
* @param file - The file path to write
|
|
7
7
|
* @param contents - The content to write
|
|
8
8
|
*/
|
|
9
|
-
async function writeFile
|
|
9
|
+
async function writeFile(file, contents) {
|
|
10
10
|
await mkdir(dirname(file), { recursive: true });
|
|
11
|
-
await writeFile(file, contents, typeof contents === "string" ? "utf8" : void 0);
|
|
11
|
+
await writeFile$1(file, contents, typeof contents === "string" ? "utf8" : void 0);
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
export { writeFile$1 as writeFile };
|
|
13
|
+
export { writeFile };
|
|
15
14
|
|
|
16
15
|
//# sourceMappingURL=fs.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.mjs","names":["
|
|
1
|
+
{"version":3,"file":"fs.mjs","names":["fspWriteFile"],"sources":["../../../src/module/internal/fs.ts"],"sourcesContent":["import { mkdir, writeFile as fspWriteFile } from \"node:fs/promises\";\nimport { dirname } from \"pathe\";\n\n/**\n * Writes a file to disk, creating parent directories as needed.\n * @param file - The file path to write\n * @param contents - The content to write\n */\nexport async function writeFile(file: string, contents: Buffer | string) {\n await mkdir(dirname(file), { recursive: true });\n await fspWriteFile(file, contents, typeof contents === \"string\" ? \"utf8\" : undefined);\n}\n"],"mappings":";;;;;;;;AAQA,eAAsB,UAAU,MAAc,UAA2B;CACvE,MAAM,MAAM,QAAQ,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;CAC9C,MAAMA,YAAa,MAAM,UAAU,OAAO,aAAa,WAAW,SAAS,KAAA,CAAS;AACtF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { relative } from "pathe";
|
|
2
|
-
|
|
2
|
+
// src/module/internal/path.ts
|
|
3
3
|
const RELATIVE_RE = /^\.{1,2}\//;
|
|
4
4
|
/**
|
|
5
5
|
* Computes a relative path from one directory to another, ensuring it starts with `./`.
|
|
@@ -11,7 +11,6 @@ function relativeWithDot(from, to) {
|
|
|
11
11
|
const rel = relative(from, to);
|
|
12
12
|
return RELATIVE_RE.test(rel) ? rel : "./" + rel;
|
|
13
13
|
}
|
|
14
|
-
//#endregion
|
|
15
14
|
export { relativeWithDot };
|
|
16
15
|
|
|
17
16
|
//# sourceMappingURL=path.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { pkgName } from "nitro-drizzle/meta";
|
|
2
|
-
|
|
2
|
+
// src/module/internal/reload.ts
|
|
3
3
|
/**
|
|
4
4
|
* Creates a Rollup plugin that watches the base directory and triggers a Nitro restart on changes.
|
|
5
5
|
* @param nitro - The Nitro instance
|
|
@@ -17,7 +17,6 @@ function reloadPlugin(nitro, options) {
|
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
//#endregion
|
|
21
20
|
export { reloadPlugin };
|
|
22
21
|
|
|
23
22
|
//# sourceMappingURL=reload.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reload.mjs","names":[],"sources":["../../../src/module/internal/reload.ts"],"sourcesContent":["import type { Nitro as
|
|
1
|
+
{"version":3,"file":"reload.mjs","names":[],"sources":["../../../src/module/internal/reload.ts"],"sourcesContent":["import type { Nitro as LegacyNitro } from \"nitropack/core\";\nimport type { Nitro } from \"nitro/types\";\nimport type { Plugin } from \"rollup\";\nimport { pkgName } from \"nitro-drizzle/meta\";\nimport type { ContextOptions } from \"nitro-drizzle/context\";\n\n/** Options for the reload plugin. */\nexport type ReloadPluginOptions = Pick<ContextOptions, \"baseDir\">;\n\n/**\n * Creates a Rollup plugin that watches the base directory and triggers a Nitro restart on changes.\n * @param nitro - The Nitro instance\n * @param options - Reload plugin options\n * @returns A Rollup plugin\n */\nexport function reloadPlugin(nitro: Nitro | LegacyNitro, options: ReloadPluginOptions): Plugin {\n return {\n name: `${pkgName}:rollup:watch`,\n\n buildStart() {\n this.addWatchFile(options.baseDir);\n },\n\n async watchChange(id) {\n if (id.startsWith(options.baseDir)) {\n // @ts-expect-error\n await nitro.hooks.callHook(\"restart\");\n }\n },\n };\n}\n"],"mappings":";;;;;;;;AAeA,SAAgB,aAAa,OAA4B,SAAsC;CAC7F,OAAO;EACL,MAAM,GAAG,QAAQ;EAEjB,aAAa;GACX,KAAK,aAAa,QAAQ,OAAO;EACnC;EAEA,MAAM,YAAY,IAAI;GACpB,IAAI,GAAG,WAAW,QAAQ,OAAO,GAE/B,MAAM,MAAM,MAAM,SAAS,SAAS;EAExC;CACF;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createJiti } from "jiti";
|
|
2
2
|
import { fileURLToPath } from "url";
|
|
3
|
-
|
|
3
|
+
// src/module/internal/resolver.ts
|
|
4
4
|
/**
|
|
5
5
|
* Creates a module resolver using jiti.
|
|
6
6
|
* @param id - The base module ID for resolution
|
|
@@ -19,7 +19,6 @@ var JitiResolver = class {
|
|
|
19
19
|
return fileURLToPath(this.#jiti.esmResolve(id));
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
//#endregion
|
|
23
22
|
export { createResolver };
|
|
24
23
|
|
|
25
24
|
//# sourceMappingURL=resolver.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.mjs","names":[
|
|
1
|
+
{"version":3,"file":"resolver.mjs","names":[],"sources":["../../../src/module/internal/resolver.ts"],"sourcesContent":["import { createJiti, type Jiti, type JitiOptions } from \"jiti\";\nimport type { Resolver } from \"nitro-drizzle/context\";\nimport { fileURLToPath } from \"url\";\n\n/**\n * Creates a module resolver using jiti.\n * @param id - The base module ID for resolution\n * @param options - Optional resolver configuration\n * @returns A Resolver instance\n */\nexport function createResolver(id: string, options?: { alias?: Record<string, string> }): Resolver {\n return new JitiResolver(id, {\n alias: options?.alias,\n });\n}\n\nclass JitiResolver implements Resolver {\n readonly #jiti: Jiti;\n\n constructor(id: string, options?: JitiOptions) {\n this.#jiti = createJiti(id, options);\n }\n\n resolve(id: string): string {\n return fileURLToPath(this.#jiti.esmResolve(id));\n }\n}\n"],"mappings":";;;;;;;;;AAUA,SAAgB,eAAe,IAAY,SAAwD;CACjG,OAAO,IAAI,aAAa,IAAI,EAC1B,OAAO,SAAS,MAClB,CAAC;AACH;AAEA,IAAM,eAAN,MAAuC;CAC5B;CAET,YAAY,IAAY,SAAuB;EAC7C,KAAK,QAAQ,WAAW,IAAI,OAAO;CACrC;CAEA,QAAQ,IAAoB;EAC1B,OAAO,cAAc,KAAK,MAAM,WAAW,EAAE,CAAC;CAChD;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/module/internal/rollup.ts
|
|
2
2
|
/**
|
|
3
3
|
* Adds a Rollup plugin to the Nitro rollup configuration.
|
|
4
4
|
* @param rollupConfig - The Rollup configuration
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
async function addPlugin(rollupConfig, plugin) {
|
|
8
8
|
rollupConfig.plugins = [...[await rollupConfig.plugins].flat(), plugin];
|
|
9
9
|
}
|
|
10
|
-
//#endregion
|
|
11
10
|
export { addPlugin };
|
|
12
11
|
|
|
13
12
|
//# sourceMappingURL=rollup.mjs.map
|
|
@@ -1,46 +1,49 @@
|
|
|
1
|
+
import { dirname, join, resolve } from "pathe";
|
|
1
2
|
import { relativeWithDot } from "./path.mjs";
|
|
2
3
|
import { writeFile } from "./fs.mjs";
|
|
3
4
|
import { isLegacy } from "../utils/nitro.mjs";
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
// src/module/internal/types.ts
|
|
6
|
+
async function extendNitroTsConfig(nitro, tsConfig, augmentations, declarations) {
|
|
7
|
+
await addAugmentations(nitro, tsConfig, augmentations);
|
|
8
|
+
await addDeclarations(nitro, tsConfig, declarations);
|
|
9
|
+
}
|
|
6
10
|
/**
|
|
7
11
|
* Adds paths to the tsconfig include array.
|
|
8
|
-
* @param
|
|
12
|
+
* @param tsConfig - The TypeScript config to augment
|
|
9
13
|
* @param paths - The paths to add
|
|
10
14
|
*/
|
|
11
|
-
function addTsConfigInclude(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
nitroTypes.tsConfig.include.push(...paths);
|
|
15
|
+
function addTsConfigInclude(tsConfig, paths) {
|
|
16
|
+
tsConfig.include ||= [];
|
|
17
|
+
tsConfig.include.push(...paths);
|
|
15
18
|
}
|
|
16
19
|
/**
|
|
17
20
|
* Writes type declaration files and adds them to the tsconfig include.
|
|
18
|
-
* @param
|
|
21
|
+
* @param nitro - The Nitro instance
|
|
22
|
+
* @param tsConfig - The TypeScript config to augment
|
|
19
23
|
* @param augmentations - The virtual modules containing type declarations
|
|
20
24
|
*/
|
|
21
|
-
async function addAugmentations(
|
|
22
|
-
addTsConfigInclude(
|
|
25
|
+
async function addAugmentations(nitro, tsConfig, augmentations) {
|
|
26
|
+
addTsConfigInclude(tsConfig, await writeTypeFiles(nitro, augmentations));
|
|
23
27
|
}
|
|
24
28
|
/**
|
|
25
29
|
* Adds type declaration path mappings to the tsconfig compiler options.
|
|
26
30
|
* @param nitro - The Nitro instance
|
|
27
|
-
* @param
|
|
31
|
+
* @param tsConfig - The TypeScript config to augment
|
|
28
32
|
* @param declarations - The virtual modules to write as type declarations
|
|
29
33
|
*/
|
|
30
|
-
async function addDeclarations(nitro,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
nitroTypes.tsConfig.compilerOptions.paths ||= {};
|
|
34
|
+
async function addDeclarations(nitro, tsConfig, declarations) {
|
|
35
|
+
tsConfig.compilerOptions ||= {};
|
|
36
|
+
tsConfig.compilerOptions.paths ||= {};
|
|
34
37
|
for (const alias in declarations) {
|
|
35
38
|
const paths = await writeTypeFiles(nitro, declarations[alias]);
|
|
36
|
-
|
|
39
|
+
tsConfig.compilerOptions.paths[alias] = paths.map((path) => path.replace(/\.d\.ts$/, ""));
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
42
|
function getTypesDir(nitroOptions) {
|
|
40
43
|
return join(nitroOptions.buildDir, "types");
|
|
41
44
|
}
|
|
42
45
|
function getTsConfigDir(nitro) {
|
|
43
|
-
const tsConfigPath = resolve(isLegacy(nitro) ? nitro.options.buildDir : getTypesDir(nitro.options), nitro.options.typescript.tsconfigPath || "tsconfig.json");
|
|
46
|
+
const tsConfigPath = resolve(isLegacy(nitro) ? nitro.options.buildDir : getTypesDir(nitro.options), (isLegacy(nitro) ? nitro.options.typescript.tsconfigPath : void 0) || "tsconfig.json");
|
|
44
47
|
return dirname(tsConfigPath);
|
|
45
48
|
}
|
|
46
49
|
async function writeTypeFiles(nitro, modules) {
|
|
@@ -58,7 +61,6 @@ async function writeTypeFiles(nitro, modules) {
|
|
|
58
61
|
async function getContent(module) {
|
|
59
62
|
return "string" == typeof module ? module : await module();
|
|
60
63
|
}
|
|
61
|
-
|
|
62
|
-
export { addAugmentations, addDeclarations, addTsConfigInclude };
|
|
64
|
+
export { addAugmentations, addDeclarations, addTsConfigInclude, extendNitroTsConfig };
|
|
63
65
|
|
|
64
66
|
//# sourceMappingURL=types.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","names":[],"sources":["../../../src/module/internal/types.ts"],"sourcesContent":["import type {\n Nitro as LegacyNitro,\n NitroOptions as LegacyNitroOptions,\n
|
|
1
|
+
{"version":3,"file":"types.mjs","names":[],"sources":["../../../src/module/internal/types.ts"],"sourcesContent":["import type {\n Nitro as LegacyNitro,\n NitroOptions as LegacyNitroOptions,\n VirtualModule,\n} from \"nitropack/types\";\nimport type { Nitro, NitroOptions } from \"nitro/types\";\nimport { dirname, join, resolve } from \"pathe\";\nimport { relativeWithDot } from \"./path\";\nimport { writeFile } from \"./fs\";\nimport type { VirtualModules } from \"nitro-drizzle/shared\";\nimport { isLegacy } from \"../utils/nitro\";\n\n/**\n * A TypeScript config object with the fields this module mutates.\n *\n * Compatible with both the legacy `nitro.types.tsConfig` shape and the\n * Nitro v3 `nitro.options.typescript.tsConfig` (`Partial<TSConfig>`).\n */\nexport type NitroTsConfig = Exclude<\n (NitroOptions | LegacyNitroOptions)[\"typescript\"][\"tsConfig\"],\n undefined\n>;\n\nexport async function extendNitroTsConfig(\n nitro: Nitro | LegacyNitro,\n tsConfig: NitroTsConfig,\n augmentations: VirtualModules<`${string}.d.ts`>,\n declarations: Record<string, VirtualModules<`${string}.d.ts`>>,\n) {\n await addAugmentations(nitro, tsConfig, augmentations);\n await addDeclarations(nitro, tsConfig, declarations);\n}\n\n/**\n * Adds paths to the tsconfig include array.\n * @param tsConfig - The TypeScript config to augment\n * @param paths - The paths to add\n */\nexport function addTsConfigInclude(tsConfig: NitroTsConfig, paths: readonly string[]) {\n tsConfig.include ||= [];\n tsConfig.include.push(...paths);\n}\n\n/**\n * Writes type declaration files and adds them to the tsconfig include.\n * @param nitro - The Nitro instance\n * @param tsConfig - The TypeScript config to augment\n * @param augmentations - The virtual modules containing type declarations\n */\nexport async function addAugmentations(\n nitro: Nitro | LegacyNitro,\n tsConfig: NitroTsConfig,\n augmentations: VirtualModules<`${string}.d.ts`>,\n) {\n const paths = await writeTypeFiles(nitro, augmentations);\n addTsConfigInclude(tsConfig, paths);\n}\n\n/**\n * Adds type declaration path mappings to the tsconfig compiler options.\n * @param nitro - The Nitro instance\n * @param tsConfig - The TypeScript config to augment\n * @param declarations - The virtual modules to write as type declarations\n */\nexport async function addDeclarations(\n nitro: Nitro | LegacyNitro,\n tsConfig: NitroTsConfig,\n declarations: Record<string, VirtualModules<`${string}.d.ts`>>,\n) {\n tsConfig.compilerOptions ||= {};\n tsConfig.compilerOptions.paths ||= {};\n\n for (const alias in declarations) {\n const paths = await writeTypeFiles(nitro, declarations[alias]);\n\n tsConfig.compilerOptions.paths[alias] = paths.map((path) => path.replace(/\\.d\\.ts$/, \"\"));\n }\n}\n\nfunction getTypesDir(nitroOptions: NitroOptions | LegacyNitroOptions) {\n return join(nitroOptions.buildDir, \"types\");\n}\n\nfunction getTsConfigDir(nitro: Nitro | LegacyNitro) {\n const tsConfigPath = resolve(\n isLegacy(nitro) ? nitro.options.buildDir : getTypesDir(nitro.options),\n (isLegacy(nitro) ? nitro.options.typescript.tsconfigPath : void 0) || \"tsconfig.json\",\n );\n const tsconfigDir = dirname(tsConfigPath);\n return tsconfigDir;\n}\n\nasync function writeTypeFiles(nitro: Nitro | LegacyNitro, modules: VirtualModules) {\n const paths: string[] = [];\n const typesDir = getTypesDir(nitro.options);\n const tsConfigDir = getTsConfigDir(nitro);\n for (const filename in modules) {\n const typesFilename = join(typesDir, filename);\n await writeFile(typesFilename, await getContent(modules[filename]));\n const relativeFilename = relativeWithDot(tsConfigDir, typesFilename);\n paths.push(relativeFilename);\n }\n return paths;\n}\n\nasync function getContent(module: VirtualModule) {\n return \"string\" == typeof module ? module : await module();\n}\n"],"mappings":";;;;;AAuBA,eAAsB,oBACpB,OACA,UACA,eACA,cACA;CACA,MAAM,iBAAiB,OAAO,UAAU,aAAa;CACrD,MAAM,gBAAgB,OAAO,UAAU,YAAY;AACrD;;;;;;AAOA,SAAgB,mBAAmB,UAAyB,OAA0B;CACpF,SAAS,YAAY,CAAC;CACtB,SAAS,QAAQ,KAAK,GAAG,KAAK;AAChC;;;;;;;AAQA,eAAsB,iBACpB,OACA,UACA,eACA;CAEA,mBAAmB,UAAU,MADT,eAAe,OAAO,aAAa,CACrB;AACpC;;;;;;;AAQA,eAAsB,gBACpB,OACA,UACA,cACA;CACA,SAAS,oBAAoB,CAAC;CAC9B,SAAS,gBAAgB,UAAU,CAAC;CAEpC,KAAK,MAAM,SAAS,cAAc;EAChC,MAAM,QAAQ,MAAM,eAAe,OAAO,aAAa,MAAM;EAE7D,SAAS,gBAAgB,MAAM,SAAS,MAAM,KAAK,SAAS,KAAK,QAAQ,YAAY,EAAE,CAAC;CAC1F;AACF;AAEA,SAAS,YAAY,cAAiD;CACpE,OAAO,KAAK,aAAa,UAAU,OAAO;AAC5C;AAEA,SAAS,eAAe,OAA4B;CAClD,MAAM,eAAe,QACnB,SAAS,KAAK,IAAI,MAAM,QAAQ,WAAW,YAAY,MAAM,OAAO,IACnE,SAAS,KAAK,IAAI,MAAM,QAAQ,WAAW,eAAe,KAAK,MAAM,eACxE;CAEA,OADoB,QAAQ,YACX;AACnB;AAEA,eAAe,eAAe,OAA4B,SAAyB;CACjF,MAAM,QAAkB,CAAC;CACzB,MAAM,WAAW,YAAY,MAAM,OAAO;CAC1C,MAAM,cAAc,eAAe,KAAK;CACxC,KAAK,MAAM,YAAY,SAAS;EAC9B,MAAM,gBAAgB,KAAK,UAAU,QAAQ;EAC7C,MAAM,UAAU,eAAe,MAAM,WAAW,QAAQ,SAAS,CAAC;EAClE,MAAM,mBAAmB,gBAAgB,aAAa,aAAa;EACnE,MAAM,KAAK,gBAAgB;CAC7B;CACA,OAAO;AACT;AAEA,eAAe,WAAW,QAAuB;CAC/C,OAAO,YAAY,OAAO,SAAS,SAAS,MAAM,OAAO;AAC3D"}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { NitroConfig, ServerAssetDir } from "nitropack/types";
|
|
2
2
|
import { NitroConfig as NitroConfig$1, ServerAssetDir as ServerAssetDir$1 } from "nitro/types";
|
|
3
|
-
//#region src/module/utils/assets.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Updates the server assets configuration, ensuring no duplicates.
|
|
6
5
|
* @param config - The Nitro configuration to update
|
|
7
6
|
* @param assets - The assets to add
|
|
8
7
|
*/
|
|
9
|
-
declare function updateServerAssets(config: NitroConfig$1 | NitroConfig, assets: readonly (ServerAssetDir$1 | ServerAssetDir)[]): void;
|
|
10
|
-
//#endregion
|
|
11
|
-
export { updateServerAssets };
|
|
12
|
-
//# sourceMappingURL=assets.d.mts.map
|
|
8
|
+
export declare function updateServerAssets(config: NitroConfig$1 | NitroConfig, assets: readonly (ServerAssetDir$1 | ServerAssetDir)[]): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { consola } from "consola";
|
|
2
|
-
|
|
2
|
+
// src/module/utils/assets.ts
|
|
3
3
|
/**
|
|
4
4
|
* Updates the server assets configuration, ensuring no duplicates.
|
|
5
5
|
* @param config - The Nitro configuration to update
|
|
@@ -14,7 +14,6 @@ function updateServerAssets(config, assets) {
|
|
|
14
14
|
return assets.some((assets) => baseName == assets.baseName);
|
|
15
15
|
}).concat(assets);
|
|
16
16
|
}
|
|
17
|
-
//#endregion
|
|
18
17
|
export { updateServerAssets };
|
|
19
18
|
|
|
20
19
|
//# sourceMappingURL=assets.mjs.map
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { NitroOptions } from "nitropack/types";
|
|
2
2
|
import "nitro/types";
|
|
3
|
-
//#region src/module/utils/externals.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Adds module IDs to the inline externals list for legacy Nitro.
|
|
6
5
|
* @param nitroOptions - The legacy Nitro options
|
|
7
6
|
* @param moduleIds - The module IDs to add as inline externals
|
|
8
7
|
*/
|
|
9
|
-
declare function addInlineExternals(nitroOptions: NitroOptions, moduleIds: readonly string[]): void;
|
|
10
|
-
//#endregion
|
|
11
|
-
export { addInlineExternals };
|
|
12
|
-
//# sourceMappingURL=externals.d.mts.map
|
|
8
|
+
export declare function addInlineExternals(nitroOptions: NitroOptions, moduleIds: readonly string[]): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/module/utils/externals.ts
|
|
2
2
|
/**
|
|
3
3
|
* Adds module IDs to the inline externals list for legacy Nitro.
|
|
4
4
|
* @param nitroOptions - The legacy Nitro options
|
|
@@ -19,7 +19,6 @@ function addNoExternals(nitroOptions, moduleIds) {
|
|
|
19
19
|
nitroOptions.noExternals ||= [];
|
|
20
20
|
nitroOptions.noExternals.push(...moduleIds);
|
|
21
21
|
}
|
|
22
|
-
//#endregion
|
|
23
22
|
export { addInlineExternals, addNoExternals };
|
|
24
23
|
|
|
25
24
|
//# sourceMappingURL=externals.mjs.map
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { Nitro } from "nitropack/types";
|
|
2
2
|
import { Nitro as Nitro$1 } from "nitro/types";
|
|
3
|
-
//#region src/module/utils/nitro.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Checks if the given Nitro instance is using the legacy API (nitropack).
|
|
6
5
|
* @param nitro - The Nitro instance to check
|
|
7
6
|
* @returns `true` if the Nitro instance is legacy (major version < 3)
|
|
8
7
|
*/
|
|
9
|
-
declare function isLegacy(nitro: Nitro$1 | Nitro): nitro is Nitro;
|
|
10
|
-
//#endregion
|
|
11
|
-
export { isLegacy };
|
|
12
|
-
//# sourceMappingURL=nitro.d.mts.map
|
|
8
|
+
export declare function isLegacy(nitro: Nitro$1 | Nitro): nitro is Nitro;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/module/utils/nitro.ts
|
|
2
2
|
/**
|
|
3
3
|
* Checks if the given Nitro instance is using the legacy API (nitropack).
|
|
4
4
|
* @param nitro - The Nitro instance to check
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
function isLegacy(nitro) {
|
|
8
8
|
return nitro.meta.majorVersion < 3;
|
|
9
9
|
}
|
|
10
|
-
//#endregion
|
|
11
10
|
export { isLegacy };
|
|
12
11
|
|
|
13
12
|
//# sourceMappingURL=nitro.mjs.map
|