nitro-drizzle 0.3.0 → 0.3.2
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/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 +2 -3
- package/dist/context.d.mts +12 -16
- package/dist/context.mjs +7 -8
- 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 +8 -7
- package/dist/drivers/mysql.mjs +5 -5
- package/dist/drivers/mysql.mjs.map +1 -1
- 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 +9 -12
- 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 +34 -27
- package/skills/nitro-drizzle/SKILL.md +188 -0
- 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
|
@@ -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":[],"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;
|
|
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
|
package/dist/module.d.mts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
+
import { NitroModule } from "nitropack/types";
|
|
2
|
+
import { NitroModule as NitroModule$1 } from "nitro/types";
|
|
3
|
+
import { ConfigPattern, MigrationOptions } from "nitro-drizzle/context";
|
|
1
4
|
import { updateServerAssets } from "./module/utils/assets.mjs";
|
|
2
5
|
import { addInlineExternals } from "./module/utils/externals.mjs";
|
|
3
6
|
import { isLegacy } from "./module/utils/nitro.mjs";
|
|
4
|
-
import { ConfigPattern, MigrationOptions } from "nitro-drizzle/context";
|
|
5
|
-
import { NitroModule } from "nitropack/types";
|
|
6
|
-
import { NitroModule as NitroModule$1 } from "nitro/types";
|
|
7
|
-
//#region src/module/index.d.ts
|
|
8
7
|
/**
|
|
9
8
|
* Datasource-specific configuration options mapped by datasource name.
|
|
10
9
|
*/
|
|
11
|
-
type DatasourceOptions = Record<string, {
|
|
10
|
+
export type DatasourceOptions = Record<string, {
|
|
12
11
|
drivers: readonly string[] | {
|
|
13
12
|
[name: string]: boolean;
|
|
14
13
|
};
|
|
@@ -23,7 +22,7 @@ declare module "nitro/types" {
|
|
|
23
22
|
drizzle?: ModuleOptions;
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
|
-
interface ModuleOptions {
|
|
25
|
+
export interface ModuleOptions {
|
|
27
26
|
/**
|
|
28
27
|
* Directory to search datasources
|
|
29
28
|
*/
|
|
@@ -41,14 +40,14 @@ interface ModuleOptions {
|
|
|
41
40
|
/**
|
|
42
41
|
* Resolved module configuration with required fields.
|
|
43
42
|
*/
|
|
44
|
-
type ModuleConfig = Required<ModuleOptions> & {
|
|
43
|
+
export type ModuleConfig = Required<ModuleOptions> & {
|
|
45
44
|
migrations: false | Required<MigrationOptions>;
|
|
46
45
|
};
|
|
47
46
|
/**
|
|
48
47
|
* Creates the default module configuration options.
|
|
49
48
|
* @returns The default module configuration
|
|
50
49
|
*/
|
|
51
|
-
declare function createDefaultOptions(): {
|
|
50
|
+
export declare function createDefaultOptions(): {
|
|
52
51
|
readonly baseDir: "./drizzle";
|
|
53
52
|
readonly configPattern: readonly ["drizzle.config.{js,ts}", "drizzle-*.config.{js,ts}"];
|
|
54
53
|
readonly datasources: {};
|
|
@@ -62,8 +61,6 @@ declare function createDefaultOptions(): {
|
|
|
62
61
|
* @param options - Optional module configuration overrides
|
|
63
62
|
* @returns The resolved module configuration
|
|
64
63
|
*/
|
|
65
|
-
declare function defineModuleConfig(options?: ModuleOptions): ModuleConfig;
|
|
64
|
+
export declare function defineModuleConfig(options?: ModuleOptions): ModuleConfig;
|
|
66
65
|
declare const module: NitroModule & NitroModule$1;
|
|
67
|
-
|
|
68
|
-
export { DatasourceOptions, ModuleConfig, ModuleOptions, addInlineExternals, createDefaultOptions, module as default, defineModuleConfig, isLegacy as isLegacyNitro, updateServerAssets };
|
|
69
|
-
//# sourceMappingURL=module.d.mts.map
|
|
66
|
+
export { addInlineExternals, module as default, isLegacy as isLegacyNitro, updateServerAssets };
|
package/dist/module.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { updateServerAssets } from "./module/utils/assets.mjs";
|
|
2
|
-
import { addInlineExternals, addNoExternals } from "./module/utils/externals.mjs";
|
|
3
|
-
import { isLegacy } from "./module/utils/nitro.mjs";
|
|
4
|
-
import { addAugmentations, addDeclarations } from "./module/internal/types.mjs";
|
|
5
|
-
import { createResolver } from "./module/internal/resolver.mjs";
|
|
6
|
-
import { reloadPlugin } from "./module/internal/reload.mjs";
|
|
7
|
-
import { addPlugin } from "./module/internal/rollup.mjs";
|
|
8
1
|
import { defu } from "defu";
|
|
9
2
|
import { resolve } from "pathe";
|
|
10
3
|
import { resolveAlias } from "pathe/utils";
|
|
11
4
|
import { createContext } from "nitro-drizzle/context";
|
|
12
5
|
import { pkgName } from "nitro-drizzle/meta";
|
|
13
|
-
|
|
6
|
+
import { updateServerAssets } from "./module/utils/assets.mjs";
|
|
7
|
+
import { addInlineExternals, addNoExternals } from "./module/utils/externals.mjs";
|
|
8
|
+
import { extendNitroTsConfig } from "./module/internal/types.mjs";
|
|
9
|
+
import { createResolver } from "./module/internal/resolver.mjs";
|
|
10
|
+
import { reloadPlugin } from "./module/internal/reload.mjs";
|
|
11
|
+
import { addPlugin } from "./module/internal/rollup.mjs";
|
|
12
|
+
import { isLegacy } from "./module/utils/nitro.mjs";
|
|
13
|
+
// src/module/index.ts
|
|
14
14
|
/**
|
|
15
15
|
* Creates the default module configuration options.
|
|
16
16
|
* @returns The default module configuration
|
|
@@ -81,15 +81,21 @@ const module = {
|
|
|
81
81
|
virtualModules(modules) {
|
|
82
82
|
Object.assign(nitro.options.virtual, modules);
|
|
83
83
|
},
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
84
|
+
async types(declarations) {
|
|
85
|
+
const virtual = { ...declarations.virtual };
|
|
86
|
+
const augmentations = {
|
|
87
|
+
...declarations.shared,
|
|
88
|
+
...declarations.runtime,
|
|
89
|
+
...declarations.module
|
|
90
|
+
};
|
|
91
|
+
if (isLegacy(nitro)) nitro.hooks.hook("types:extend", async (types) => {
|
|
92
|
+
const tsConfig = types.tsConfig ||= {};
|
|
93
|
+
await extendNitroTsConfig(nitro, tsConfig, augmentations, virtual);
|
|
92
94
|
});
|
|
95
|
+
else {
|
|
96
|
+
const tsConfig = nitro.options.typescript.tsConfig ||= {};
|
|
97
|
+
await extendNitroTsConfig(nitro, tsConfig, augmentations, virtual);
|
|
98
|
+
}
|
|
93
99
|
},
|
|
94
100
|
assets(assets) {
|
|
95
101
|
updateServerAssets(nitro.options, assets);
|
|
@@ -100,14 +106,16 @@ const module = {
|
|
|
100
106
|
}
|
|
101
107
|
};
|
|
102
108
|
const context = createContext(contextOptions);
|
|
103
|
-
if (nitro
|
|
104
|
-
nitro.hooks.hook("rollup:before", async (nitro, config) => {
|
|
109
|
+
if (isLegacy(nitro)) nitro.hooks.hook("rollup:before", async (nitro, config) => {
|
|
105
110
|
await addPlugin(config, reloadPlugin(nitro, { baseDir }));
|
|
106
111
|
});
|
|
112
|
+
else nitro.hooks.hook("build:config", async (nitro, config) => {
|
|
113
|
+
if ("rollup" == config.builder) await addPlugin(config.rollup, reloadPlugin(nitro, { baseDir }));
|
|
114
|
+
else logger.warn(`Watching "${baseDir}" is not yet supported using "${config.builder}" builder.`);
|
|
115
|
+
});
|
|
107
116
|
await context.init();
|
|
108
117
|
}
|
|
109
118
|
};
|
|
110
|
-
//#endregion
|
|
111
119
|
export { addInlineExternals, createDefaultOptions, module as default, defineModuleConfig, isLegacy as isLegacyNitro, updateServerAssets };
|
|
112
120
|
|
|
113
121
|
//# sourceMappingURL=module.mjs.map
|