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
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { DatasourceVariants } from "../runtime.mjs";
|
|
2
2
|
import { ConnectorSpecifier, UnwrapVariant } from "nitro-drizzle/shared";
|
|
3
|
-
//#region src/runtime/useDatasource.d.ts
|
|
4
3
|
/** Options for datasource creation and lifecycle management. */
|
|
5
|
-
type UseDatasourceOptions = Partial<{
|
|
4
|
+
export type UseDatasourceOptions = Partial<{
|
|
6
5
|
/** Whether to automatically close the datasource when Nitro app closes. */
|
|
7
6
|
autoClose: boolean;
|
|
8
7
|
}>;
|
|
@@ -14,9 +13,6 @@ type UseDatasourceOptions = Partial<{
|
|
|
14
13
|
* @param options - Lifecycle options
|
|
15
14
|
* @returns The datasource instance
|
|
16
15
|
*/
|
|
17
|
-
declare function useDatasource<TName extends ConnectorSpecifier["name"]>(name: TName, options?: UseDatasourceOptions): Promise<UnwrapVariant<DatasourceVariants, ConnectorSpecifier & {
|
|
16
|
+
export declare function useDatasource<TName extends ConnectorSpecifier["name"]>(name: TName, options?: UseDatasourceOptions): Promise<UnwrapVariant<DatasourceVariants, ConnectorSpecifier & {
|
|
18
17
|
name: TName;
|
|
19
|
-
}>>;
|
|
20
|
-
//#endregion
|
|
21
|
-
export { UseDatasourceOptions, useDatasource };
|
|
22
|
-
//# sourceMappingURL=useDatasource.d.mts.map
|
|
18
|
+
}>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { clearCachedConfig } from "./internal/config.mjs";
|
|
2
1
|
import { createDatasource } from "./internal/createDatasource.mjs";
|
|
2
|
+
import { clearCachedConfig } from "./internal/config.mjs";
|
|
3
3
|
import { onServerClose } from "#nitro-drizzle/runtime";
|
|
4
|
-
|
|
4
|
+
// src/runtime/useDatasource.ts
|
|
5
5
|
const datasources = {};
|
|
6
6
|
/**
|
|
7
7
|
* Gets or creates a datasource instance by name.
|
|
@@ -34,7 +34,6 @@ async function useDatasource(name, options = {}) {
|
|
|
34
34
|
function cleanCachedDatasource(name) {
|
|
35
35
|
delete datasources[name];
|
|
36
36
|
}
|
|
37
|
-
//#endregion
|
|
38
37
|
export { useDatasource };
|
|
39
38
|
|
|
40
39
|
//# sourceMappingURL=useDatasource.mjs.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { ConnectorSpecifier, UnwrapVariant, Variant } from "nitro-drizzle/shared";
|
|
2
|
-
import { DatasourceVariants, Datasources } from "nitro-drizzle/runtime";
|
|
3
1
|
import { Datasource, Schema } from "nitro-drizzle/drivers";
|
|
4
|
-
|
|
2
|
+
import { DatasourceVariants, Datasources } from "nitro-drizzle/runtime";
|
|
3
|
+
import { ConnectorSpecifier, UnwrapVariant, Variant } from "nitro-drizzle/shared";
|
|
5
4
|
/**
|
|
6
5
|
* Executes a callback with type-safe context (datasource, driver, dialect) for the specified datasource.
|
|
7
6
|
* Automatically resolves the active datasource, driver, and dialect based on the runtime configuration.
|
|
@@ -12,7 +11,7 @@ import { Datasource, Schema } from "nitro-drizzle/drivers";
|
|
|
12
11
|
* @param callback - The callback function receiving `{ datasource, driver, dialect }`
|
|
13
12
|
* @returns A promise that resolves to the return value of the callback
|
|
14
13
|
*/
|
|
15
|
-
declare function useDialect<TName extends keyof Datasources & string, TArgs extends DialectCallbackArgs<TName>, TReturn>(name: TName, callback: DialectCallback<TName, TArgs, TReturn>): Promise<TReturn>;
|
|
14
|
+
export declare function useDialect<TName extends keyof Datasources & string, TArgs extends DialectCallbackArgs<TName>, TReturn>(name: TName, callback: DialectCallback<TName, TArgs, TReturn>): Promise<TReturn>;
|
|
16
15
|
type DialectCallbackArgsMapper<T extends Variant<Datasource<string, any, Schema>, ConnectorSpecifier>> = T extends Variant<infer V, infer S> ? Variant<Pick<S, "dialect" | "driver"> & {
|
|
17
16
|
datasource: V;
|
|
18
17
|
}, Pick<S, "name">> : never;
|
|
@@ -26,9 +25,7 @@ type DialectCallbackArgs<TName extends keyof Datasources & string> = UnwrapVaria
|
|
|
26
25
|
* @template TArgs - The callback argument types
|
|
27
26
|
* @template TReturn - The return type of the callback
|
|
28
27
|
*/
|
|
29
|
-
type DialectCallback<TName extends keyof Datasources & string, TArgs extends DialectCallbackArgs<TName>, TReturn> = {
|
|
28
|
+
export type DialectCallback<TName extends keyof Datasources & string, TArgs extends DialectCallbackArgs<TName>, TReturn> = {
|
|
30
29
|
(args: TArgs): TReturn;
|
|
31
30
|
};
|
|
32
|
-
|
|
33
|
-
export { DialectCallback, useDialect };
|
|
34
|
-
//# sourceMappingURL=useDialect.d.mts.map
|
|
31
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useDatasourceProvider } from "./internal/createDatasource.mjs";
|
|
2
1
|
import { useConfig, useDatasource } from "nitro-drizzle/runtime";
|
|
3
|
-
|
|
2
|
+
import { useDatasourceProvider } from "./internal/createDatasource.mjs";
|
|
3
|
+
// src/runtime/useDialect.ts
|
|
4
4
|
/**
|
|
5
5
|
* Executes a callback with type-safe context (datasource, driver, dialect) for the specified datasource.
|
|
6
6
|
* Automatically resolves the active datasource, driver, and dialect based on the runtime configuration.
|
|
@@ -21,7 +21,6 @@ async function useDialect(name, callback) {
|
|
|
21
21
|
dialect
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
//#endregion
|
|
25
24
|
export { useDialect };
|
|
26
25
|
|
|
27
26
|
//# sourceMappingURL=useDialect.mjs.map
|
package/dist/runtime.d.mts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
import { Connector, Datasource } from "nitro-drizzle/drivers";
|
|
2
|
+
import { ConnectorSpecifier, ConnectorVariants, ExpandVariants, MaybePromise, Selector, Variant } from "nitro-drizzle/shared";
|
|
1
3
|
import { UseDatasourceOptions, useDatasource } from "./runtime/useDatasource.mjs";
|
|
2
4
|
import { DialectCallback, useDialect } from "./runtime/useDialect.mjs";
|
|
3
5
|
import { useConfig } from "./runtime/useConfig.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
6
|
+
import { CallInitHookOptions, CallInitHookReturn, callInitHook } from "./runtime/callInitHook.mjs";
|
|
7
|
+
import { DrizzleInitHooks, drizzleInitHooks } from "./runtime/internal/hooks.mjs";
|
|
8
|
+
import { DrizzleInitState, ReadyState, useInitState } from "./runtime/internal/state.mjs";
|
|
7
9
|
/**
|
|
8
10
|
* Provider interface for creating Drizzle datasource instances.
|
|
9
11
|
* @template TConfig - The configuration type for the datasource
|
|
10
12
|
* @template TDatasource - The datasource type that extends Datasource
|
|
11
13
|
*/
|
|
12
|
-
interface DatasourceProvider<TDialect, TConfig, TDatasource extends Datasource<any, any, any>> {
|
|
14
|
+
export interface DatasourceProvider<TDialect, TConfig, TDatasource extends Datasource<any, any, any>> {
|
|
13
15
|
dialect: TDialect;
|
|
14
16
|
create(config: TConfig): MaybePromise<TDatasource>;
|
|
15
17
|
}
|
|
@@ -18,26 +20,26 @@ type ConfigVariants = ConfigMapper<ConnectorVariants>;
|
|
|
18
20
|
type RuntimeConfigMapper<T extends Variant<any, Selector>> = T extends any ? Variant<PrimitiveProps<T["value"]>, T["selector"]> : never;
|
|
19
21
|
type RuntimeConfigVariants = RuntimeConfigMapper<ConfigVariants>;
|
|
20
22
|
type DatasourceProviderMapper<T extends Variant<Connector<any, any, any, any>, ConnectorSpecifier>> = T extends Variant<infer V, infer S> ? Variant<V extends Connector<infer TDialect, any, infer TConfig, any> ? DatasourceProvider<TDialect, TConfig, DatasourceOf<V>> : never, S> : never;
|
|
21
|
-
type DatasourceProviderVariants = DatasourceProviderMapper<ConnectorVariants>;
|
|
23
|
+
export type DatasourceProviderVariants = DatasourceProviderMapper<ConnectorVariants>;
|
|
22
24
|
/**
|
|
23
25
|
* Registry interface for datasource providers.
|
|
24
26
|
*/
|
|
25
|
-
type DatasourceRegistry = ExpandVariants<DatasourceProviderVariants, ["name", "driver"]>;
|
|
27
|
+
export type DatasourceRegistry = ExpandVariants<DatasourceProviderVariants, ["name", "driver"]>;
|
|
26
28
|
/**
|
|
27
29
|
* Extracts the configuration type from a Connector.
|
|
28
30
|
* @template T - The Connector type
|
|
29
31
|
*/
|
|
30
|
-
type ConfigOf<T extends Connector<any, any, any, any>> = T extends Connector<any, any, any, infer TConfig> ? TConfig : never;
|
|
32
|
+
export type ConfigOf<T extends Connector<any, any, any, any>> = T extends Connector<any, any, any, infer TConfig> ? TConfig : never;
|
|
31
33
|
/**
|
|
32
34
|
* Extracts the datasource type from a Connector factory.
|
|
33
35
|
* @template T - The Connector type
|
|
34
36
|
*/
|
|
35
|
-
type DatasourceOf<T extends Connector<any, any, any, any>> = T extends ((...args: any) => MaybePromise<infer R>) ? R extends Datasource<any, any, any> ? R : never : T extends ((...args: any) => any) ? Parameters<Parameters<T>[0]>[0] : never;
|
|
37
|
+
export type DatasourceOf<T extends Connector<any, any, any, any>> = T extends ((...args: any) => MaybePromise<infer R>) ? R extends Datasource<any, any, any> ? R : never : T extends ((...args: any) => any) ? Parameters<Parameters<T>[0]>[0] : never;
|
|
36
38
|
/**
|
|
37
39
|
* Infers the transaction type from a datasource, database instance, or transaction function.
|
|
38
40
|
* @template T - The datasource, database instance, or transaction function type
|
|
39
41
|
*/
|
|
40
|
-
type TransactionOf<T> = T extends {
|
|
42
|
+
export type TransactionOf<T> = T extends {
|
|
41
43
|
transaction: (transaction: (tx: infer TTx, ...args: any[]) => any, ...args: any[]) => any;
|
|
42
44
|
} ? TTx : never;
|
|
43
45
|
type DatasourceMapper<T extends Variant<Connector<any, any, any, any>, ConnectorSpecifier>> = T extends any ? Variant<DatasourceOf<T["value"]>, T["selector"]> : never;
|
|
@@ -45,31 +47,31 @@ type DatasourceMapper<T extends Variant<Connector<any, any, any, any>, Connector
|
|
|
45
47
|
* Mapped type of all datasources from the registry.
|
|
46
48
|
* Provides access to datasource instances by name.
|
|
47
49
|
*/
|
|
48
|
-
type DatasourceVariants = DatasourceMapper<ConnectorVariants>;
|
|
49
|
-
type Datasources = ExpandVariants<DatasourceVariants, ["name", "driver"]>;
|
|
50
|
+
export type DatasourceVariants = DatasourceMapper<ConnectorVariants>;
|
|
51
|
+
export type Datasources = ExpandVariants<DatasourceVariants, ["name", "driver"]>;
|
|
50
52
|
/**
|
|
51
53
|
* Recursively extracts primitive properties from a type.
|
|
52
54
|
* @template T - The type to extract primitive properties from
|
|
53
55
|
*/
|
|
54
|
-
type PrimitiveProps<T extends Record<string, any>> = { [K in keyof T]: T[K] extends Record<string, any> ? PrimitiveProps<T[K]> : T[K] extends Primitive ? T[K] : never; };
|
|
56
|
+
export type PrimitiveProps<T extends Record<string, any>> = { [K in keyof T]: T[K] extends Record<string, any> ? PrimitiveProps<T[K]> : T[K] extends Primitive ? T[K] : never; };
|
|
55
57
|
/**
|
|
56
58
|
* Primitive types supported by the runtime configuration.
|
|
57
59
|
*/
|
|
58
|
-
type Primitive = string | number | boolean | null | undefined;
|
|
60
|
+
export type Primitive = string | number | boolean | null | undefined;
|
|
59
61
|
/**
|
|
60
62
|
* Extracts the configuration type from a DatasourceProvider.
|
|
61
63
|
* @template T - The DatasourceProvider type
|
|
62
64
|
*/
|
|
63
|
-
type DatasourceProviderConfig<T extends DatasourceProvider<any, any, any>> = T extends DatasourceProvider<any, infer TConfig, any> ? TConfig : never;
|
|
65
|
+
export type DatasourceProviderConfig<T extends DatasourceProvider<any, any, any>> = T extends DatasourceProvider<any, infer TConfig, any> ? TConfig : never;
|
|
64
66
|
/**
|
|
65
67
|
* Configuration type mapping datasource names to their configurations.
|
|
66
68
|
*/
|
|
67
|
-
type DatasourceConfig = ExpandVariants<ConfigVariants, ["name", "driver"]>;
|
|
69
|
+
export type DatasourceConfig = ExpandVariants<ConfigVariants, ["name", "driver"]>;
|
|
68
70
|
/**
|
|
69
71
|
* Runtime configuration type with primitive values for each datasource.
|
|
70
72
|
* Used for Nitro runtime config.
|
|
71
73
|
*/
|
|
72
|
-
type DriverRuntimeConfig = ExpandVariants<RuntimeConfigVariants, ["name", "driver"]>;
|
|
74
|
+
export type DriverRuntimeConfig = ExpandVariants<RuntimeConfigVariants, ["name", "driver"]>;
|
|
73
75
|
type DriverNameMapper<T extends Variant<any, Selector>> = T extends Variant<any, infer S> ? Variant<{
|
|
74
76
|
driver?: S["driver"] | "";
|
|
75
77
|
}, Pick<S, "name">> : never;
|
|
@@ -77,7 +79,7 @@ type DriverNameVariants = DriverNameMapper<RuntimeConfigVariants>;
|
|
|
77
79
|
/**
|
|
78
80
|
* Runtime config type including driver name variants for each datasource.
|
|
79
81
|
*/
|
|
80
|
-
type RuntimeConfig = DriverRuntimeConfig & ExpandVariants<DriverNameVariants, ["name"]>;
|
|
82
|
+
export type RuntimeConfig = DriverRuntimeConfig & ExpandVariants<DriverNameVariants, ["name"]>;
|
|
81
83
|
declare module "nitropack/types" {
|
|
82
84
|
interface NitroRuntimeConfig {
|
|
83
85
|
drizzle?: RuntimeConfig;
|
|
@@ -92,11 +94,11 @@ type ConfigHookArgsMapper<T extends Variant<any, Selector>> = T extends Variant<
|
|
|
92
94
|
/**
|
|
93
95
|
* Arguments passed to the `drizzle:config` hook.
|
|
94
96
|
*/
|
|
95
|
-
type ConfigHookArgs = ConfigHookArgsMapper<ConfigVariants>;
|
|
97
|
+
export type ConfigHookArgs = ConfigHookArgsMapper<ConfigVariants>;
|
|
96
98
|
/**
|
|
97
99
|
* Hooks for Drizzle datasource configuration.
|
|
98
100
|
*/
|
|
99
|
-
interface ConfigHooks {
|
|
101
|
+
export interface ConfigHooks {
|
|
100
102
|
"drizzle:config": (...args: ConfigHookArgs) => void | Promise<void>;
|
|
101
103
|
}
|
|
102
104
|
declare module "nitropack/types" {
|
|
@@ -105,6 +107,4 @@ declare module "nitropack/types" {
|
|
|
105
107
|
declare module "nitro/types" {
|
|
106
108
|
interface NitroRuntimeHooks extends ConfigHooks {}
|
|
107
109
|
}
|
|
108
|
-
|
|
109
|
-
export { ConfigHookArgs, ConfigHooks, ConfigOf, DatasourceConfig, DatasourceOf, DatasourceProvider, DatasourceProviderConfig, DatasourceProviderVariants, DatasourceRegistry, DatasourceVariants, Datasources, DialectCallback, DriverRuntimeConfig, Primitive, PrimitiveProps, RuntimeConfig, TransactionOf, UseDatasourceOptions, useConfig, useDatasource, useDialect };
|
|
110
|
-
//# sourceMappingURL=runtime.d.mts.map
|
|
110
|
+
export { CallInitHookOptions, CallInitHookReturn, DialectCallback, type DrizzleInitHooks, type DrizzleInitState, type ReadyState, UseDatasourceOptions, callInitHook, drizzleInitHooks, useConfig, useDatasource, useDialect, useInitState };
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { useDatasource } from "./runtime/useDatasource.mjs";
|
|
2
2
|
import { useDialect } from "./runtime/useDialect.mjs";
|
|
3
3
|
import { useConfig } from "./runtime/useConfig.mjs";
|
|
4
|
-
|
|
4
|
+
import { callInitHook } from "./runtime/callInitHook.mjs";
|
|
5
|
+
import { drizzleInitHooks } from "./runtime/internal/hooks.mjs";
|
|
6
|
+
import { useInitState } from "./runtime/internal/state.mjs";
|
|
7
|
+
export { callInitHook, drizzleInitHooks, useConfig, useDatasource, useDialect, useInitState };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
//#region src/shared/variants.d.ts
|
|
2
1
|
/** A key-value mapping of selector dimensions. */
|
|
3
|
-
type Selector = Record<string, string>;
|
|
2
|
+
export type Selector = Record<string, string>;
|
|
4
3
|
/** A variant type with a value and selector dimensions. */
|
|
5
|
-
type Variant<TValue, TSelector extends Selector> = {
|
|
4
|
+
export type Variant<TValue, TSelector extends Selector> = {
|
|
6
5
|
value: TValue;
|
|
7
6
|
selector: TSelector;
|
|
8
7
|
};
|
|
@@ -11,7 +10,7 @@ type Variant<TValue, TSelector extends Selector> = {
|
|
|
11
10
|
* @template T - The variant type
|
|
12
11
|
* @template D - The selector dimensions to match
|
|
13
12
|
*/
|
|
14
|
-
type UnwrapVariant<T extends Variant<any, any>, D extends T["selector"]> = T extends Variant<infer V, D> ? V : never;
|
|
13
|
+
export type UnwrapVariant<T extends Variant<any, any>, D extends T["selector"]> = T extends Variant<infer V, D> ? V : never;
|
|
15
14
|
type Dimensions<TVariant extends Variant<any, any>> = readonly (keyof TVariant["selector"] & string)[];
|
|
16
15
|
type OmitNever<T> = { [K in keyof T as T[K] extends never ? never : K]: T[K]; } & {};
|
|
17
16
|
type ExpandVariantsRecursive<TVariant extends Variant<any, any>, TOrder extends Dimensions<TVariant>, TSelector extends TVariant["selector"]> = TOrder extends [infer TDimension extends string, ...other: infer TOtherDimensions extends readonly string[]] ? OmitNever<{ [K in TVariant["selector"][TDimension]]: ExpandVariantsRecursive<TVariant, TOtherDimensions, TSelector & Record<TDimension, K>>; }> : UnwrapVariant<TVariant, TSelector>;
|
|
@@ -20,8 +19,8 @@ type ExpandVariantsRecursive<TVariant extends Variant<any, any>, TOrder extends
|
|
|
20
19
|
* @template TVariant - The variant type
|
|
21
20
|
* @template TOrder - The order of dimensions to expand
|
|
22
21
|
*/
|
|
23
|
-
type ExpandVariants<TVariant extends Variant<any, any>, TOrder extends Dimensions<TVariant>> = ExpandVariantsRecursive<TVariant, TOrder, {}>;
|
|
24
|
-
type GenVariantsOptions = {
|
|
22
|
+
export type ExpandVariants<TVariant extends Variant<any, any>, TOrder extends Dimensions<TVariant>> = ExpandVariantsRecursive<TVariant, TOrder, {}>;
|
|
23
|
+
export type GenVariantsOptions = {
|
|
25
24
|
variants: [type: string, dimensions: Selector][];
|
|
26
25
|
};
|
|
27
26
|
/**
|
|
@@ -29,7 +28,5 @@ type GenVariantsOptions = {
|
|
|
29
28
|
* @param options - The variant options
|
|
30
29
|
* @returns A TypeScript type string
|
|
31
30
|
*/
|
|
32
|
-
declare function genVariants({ variants }: GenVariantsOptions): string;
|
|
33
|
-
|
|
34
|
-
export { ExpandVariants, GenVariantsOptions, Selector, UnwrapVariant, Variant, genVariants };
|
|
35
|
-
//# sourceMappingURL=variants.d.mts.map
|
|
31
|
+
export declare function genVariants({ variants }: GenVariantsOptions): string;
|
|
32
|
+
export {};
|
package/dist/shared/variants.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { genObjectFromValues } from "knitwork";
|
|
2
|
-
|
|
2
|
+
// src/shared/variants.ts
|
|
3
3
|
/**
|
|
4
4
|
* Generates a TypeScript union type string from variant definitions.
|
|
5
5
|
* @param options - The variant options
|
|
@@ -11,7 +11,6 @@ function genVariants({ variants }) {
|
|
|
11
11
|
return `Variant<${type}, ${genObjectFromValues(selector)}>`;
|
|
12
12
|
}).join(" | ");
|
|
13
13
|
}
|
|
14
|
-
//#endregion
|
|
15
14
|
export { genVariants };
|
|
16
15
|
|
|
17
16
|
//# sourceMappingURL=variants.mjs.map
|
package/dist/shared.d.mts
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { ExpandVariants, GenVariantsOptions, Selector, UnwrapVariant, Variant, genVariants } from "./shared/variants.mjs";
|
|
2
1
|
import { NitroRuntimeHooks, VirtualModule } from "nitropack/types";
|
|
3
2
|
import { NitroRuntimeHooks as NitroRuntimeHooks$1 } from "nitro/types";
|
|
4
|
-
|
|
3
|
+
import { ExpandVariants, GenVariantsOptions, Selector, UnwrapVariant, Variant, genVariants } from "./shared/variants.mjs";
|
|
5
4
|
/**
|
|
6
5
|
* A type that can be either a value or a promise resolving to that value.
|
|
7
6
|
* @template T - The underlying type
|
|
8
7
|
*/
|
|
9
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
10
|
-
type VirtualModules<TName extends string = string> = Record<TName, VirtualModule>;
|
|
11
|
-
type NitroHookName = keyof NitroRuntimeHooks$1 | keyof NitroRuntimeHooks;
|
|
12
|
-
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
8
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
9
|
+
export type VirtualModules<TName extends string = string> = Record<TName, VirtualModule>;
|
|
10
|
+
export type NitroHookName = keyof NitroRuntimeHooks$1 | keyof NitroRuntimeHooks;
|
|
11
|
+
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
13
12
|
/**
|
|
14
13
|
* Metadata associated with a datasource.
|
|
15
14
|
*/
|
|
16
|
-
interface DatasourceMetadata {}
|
|
17
|
-
|
|
18
|
-
export { DatasourceMetadata, ExpandVariants, GenVariantsOptions, MaybePromise, NitroHookName, Selector, UnionToIntersection, UnwrapVariant, Variant, VirtualModules, genVariants };
|
|
19
|
-
//# sourceMappingURL=shared.d.mts.map
|
|
15
|
+
export interface DatasourceMetadata {}
|
|
16
|
+
export { ExpandVariants, GenVariantsOptions, Selector, UnwrapVariant, Variant, genVariants };
|
package/dist/shared.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { genVariants };
|
|
1
|
+
export { genVariants } from "./shared/variants.mjs";
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { Table } from "drizzle-orm";
|
|
2
2
|
import { InferPrimaryColumns } from "nitro-drizzle/dialects";
|
|
3
|
-
//#region src/utils/usePrimaryKey.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Extracts primary key columns from a Drizzle table.
|
|
6
5
|
* @template T - The table type
|
|
7
6
|
* @param table - The Drizzle table
|
|
8
7
|
* @returns Object containing only primary key columns
|
|
9
8
|
*/
|
|
10
|
-
declare function usePrimaryColumns<T extends Table>(table: T): InferPrimaryColumns<T>;
|
|
11
|
-
//#endregion
|
|
12
|
-
export { usePrimaryColumns };
|
|
13
|
-
//# sourceMappingURL=usePrimaryKey.d.mts.map
|
|
9
|
+
export declare function usePrimaryColumns<T extends Table>(table: T): InferPrimaryColumns<T>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Table } from "drizzle-orm";
|
|
2
|
-
|
|
2
|
+
// src/utils/usePrimaryKey.ts
|
|
3
3
|
const ColumnsSymbol = Table.Symbol.Columns;
|
|
4
4
|
/**
|
|
5
5
|
* Extracts primary key columns from a Drizzle table.
|
|
@@ -13,7 +13,6 @@ function usePrimaryColumns(table) {
|
|
|
13
13
|
return column.primary;
|
|
14
14
|
}));
|
|
15
15
|
}
|
|
16
|
-
//#endregion
|
|
17
16
|
export { usePrimaryColumns };
|
|
18
17
|
|
|
19
18
|
//# sourceMappingURL=usePrimaryKey.mjs.map
|
package/dist/utils.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { usePrimaryColumns };
|
|
1
|
+
export { usePrimaryColumns } from "./utils/usePrimaryKey.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nitro-drizzle",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Nitro module to integrate Drizzle ORM with ease.",
|
|
5
5
|
"homepage": "https://github.com/myshkouski/nitro-drizzle#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
18
|
"type": "module",
|
|
19
|
+
"imports": {
|
|
20
|
+
"#nitro-drizzle/runtime": "./src/runtime/virtual.ts",
|
|
21
|
+
"#nitro-drizzle/migrations": "./src/migrations/virtual.ts"
|
|
22
|
+
},
|
|
19
23
|
"exports": {
|
|
20
24
|
".": "./dist/index.mjs",
|
|
21
25
|
"./shared": "./dist/shared.mjs",
|
|
@@ -30,8 +34,8 @@
|
|
|
30
34
|
"./meta": "./dist/meta.mjs",
|
|
31
35
|
"./module": "./dist/module.mjs",
|
|
32
36
|
"./middleware/*": "./dist/middleware/*.mjs",
|
|
33
|
-
"./plugins/*": "./dist/plugins
|
|
34
|
-
"./plugins
|
|
37
|
+
"./plugins/*": "./dist/plugins/*/index.mjs",
|
|
38
|
+
"./plugins/*/legacy": "./dist/plugins/*/legacy.mjs",
|
|
35
39
|
"./runtime": "./dist/runtime.mjs",
|
|
36
40
|
"./utils": "./dist/utils.mjs",
|
|
37
41
|
"./package.json": "./package.json"
|
|
@@ -40,50 +44,49 @@
|
|
|
40
44
|
"@types/better-sqlite3": "^9.6.0",
|
|
41
45
|
"c12": "^3.3.4",
|
|
42
46
|
"consola": "^3.4.2",
|
|
43
|
-
"db0": "^0.
|
|
47
|
+
"db0": "^0.4.2",
|
|
44
48
|
"defu": "^6.1.7",
|
|
45
49
|
"jiti": "^2.7.0",
|
|
46
50
|
"knitwork": "^1.3.0",
|
|
47
|
-
"nitro": "3.0.
|
|
48
|
-
"nitropack": "^2.
|
|
49
|
-
"ohash": "^2.0.
|
|
51
|
+
"nitro": "^3.0.261103-rc",
|
|
52
|
+
"nitropack": "^2.14.0",
|
|
53
|
+
"ohash": "^2.0.12",
|
|
50
54
|
"pathe": "^2.0.3",
|
|
51
|
-
"rollup": "^4.
|
|
55
|
+
"rollup": "^4.69.0",
|
|
52
56
|
"strip-indent": "^4.1.1",
|
|
53
57
|
"tinyglobby": "^0.2.17",
|
|
54
|
-
"unstorage": "^1.17.
|
|
58
|
+
"unstorage": "^1.17.6"
|
|
55
59
|
},
|
|
56
60
|
"devDependencies": {
|
|
57
61
|
"@arethetypeswrong/core": "^0.18.5",
|
|
58
|
-
"@testcontainers/mysql": "^12.
|
|
59
|
-
"@testcontainers/postgresql": "^12.
|
|
60
|
-
"@types/node": "^26.
|
|
61
|
-
"@vitest/coverage-v8": "^
|
|
62
|
-
"@vitest/ui": "^
|
|
62
|
+
"@testcontainers/mysql": "^12.2.2",
|
|
63
|
+
"@testcontainers/postgresql": "^12.2.2",
|
|
64
|
+
"@types/node": "^26.6.11",
|
|
65
|
+
"@vitest/coverage-v8": "^5.1.2",
|
|
66
|
+
"@vitest/ui": "^5.1.2",
|
|
63
67
|
"changelogen": "^0.6.2",
|
|
64
|
-
"lefthook": "^2.
|
|
68
|
+
"lefthook": "^2.2.4",
|
|
65
69
|
"listhen": "^1.10.1",
|
|
66
|
-
"oxfmt": "^0.
|
|
67
|
-
"oxlint": "^1.
|
|
68
|
-
"oxlint-tsgolint": "^7.0.
|
|
69
|
-
"publint": "^0.3.
|
|
70
|
-
"testcontainers": "^12.
|
|
71
|
-
"tsdown": "^0.
|
|
70
|
+
"oxfmt": "^0.81.0",
|
|
71
|
+
"oxlint": "^1.95.0",
|
|
72
|
+
"oxlint-tsgolint": "^7.0.2009",
|
|
73
|
+
"publint": "^0.3.25",
|
|
74
|
+
"testcontainers": "^12.2.2",
|
|
75
|
+
"tsdown": "^0.23.7",
|
|
72
76
|
"typescript": "^7.0.2",
|
|
73
|
-
"unplugin-unused": "^0.
|
|
74
|
-
"vitest": "^
|
|
75
|
-
"wrangler": "^4.
|
|
77
|
+
"unplugin-unused": "^0.6.0",
|
|
78
|
+
"vitest": "^5.1.2",
|
|
79
|
+
"wrangler": "^4.169.1"
|
|
76
80
|
},
|
|
77
81
|
"peerDependencies": {
|
|
78
|
-
"@cloudflare/workers-types": "^5.
|
|
79
|
-
"@electric-sql/pglite": "^0.5.
|
|
82
|
+
"@cloudflare/workers-types": "^5.20260826.1",
|
|
83
|
+
"@electric-sql/pglite": "^0.5.8",
|
|
80
84
|
"better-sqlite3": "^12.11.1",
|
|
81
85
|
"drizzle-kit": "^0.31.10",
|
|
82
86
|
"drizzle-orm": "^0.45.2",
|
|
83
87
|
"h3": "^1.15.11",
|
|
84
|
-
"mysql2": "^3.
|
|
85
|
-
"postgres": "^3.4.9"
|
|
86
|
-
"srvx": "^0.12.5"
|
|
88
|
+
"mysql2": "^3.24.2",
|
|
89
|
+
"postgres": "^3.4.9"
|
|
87
90
|
},
|
|
88
91
|
"peerDependenciesMeta": {
|
|
89
92
|
"@cloudflare/workers-types": {
|
|
@@ -103,12 +106,13 @@
|
|
|
103
106
|
}
|
|
104
107
|
},
|
|
105
108
|
"scripts": {
|
|
106
|
-
"build": "tsdown",
|
|
107
109
|
"build:dev": "tsdown --watch",
|
|
108
110
|
"fmt": "oxfmt",
|
|
109
111
|
"fmt:check": "oxfmt --check",
|
|
110
112
|
"lint": "oxlint",
|
|
111
|
-
"
|
|
113
|
+
"lint:fix": "oxlint --fix",
|
|
114
|
+
"playground:legacy": "nitropack dev fixtures/blog-api-legacy",
|
|
115
|
+
"playground": "nitro dev --dir fixtures/blog-api",
|
|
112
116
|
"test:dev": "vitest",
|
|
113
117
|
"test": "vitest run",
|
|
114
118
|
"test:coverage": "vitest run --coverage",
|
package/dist/drivers/db0.d.mts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Schema } from "./index.mjs";
|
|
2
|
-
//#region src/drivers/db0.d.ts
|
|
3
|
-
/**
|
|
4
|
-
* DB0 datasource driver for Nitro's built-in database configuration.
|
|
5
|
-
* @template TSchema - The schema type
|
|
6
|
-
* @returns A Datasource instance using Nitro's database configuration
|
|
7
|
-
*/
|
|
8
|
-
declare const _default: <TSchema extends Schema>(options: Options, schema: TSchema) => {
|
|
9
|
-
dialect: string;
|
|
10
|
-
database: import("db0/integrations/drizzle").DrizzleDatabase<TSchema>;
|
|
11
|
-
schema: TSchema;
|
|
12
|
-
close: () => Promise<void>;
|
|
13
|
-
waitReady: () => Promise<void>;
|
|
14
|
-
};
|
|
15
|
-
type Options = {
|
|
16
|
-
/** The name of the database to use from Nitro's built-in database configuration. */
|
|
17
|
-
name?: string;
|
|
18
|
-
};
|
|
19
|
-
//#endregion
|
|
20
|
-
export { Options, _default as default };
|
|
21
|
-
//# sourceMappingURL=db0.d.mts.map
|
package/dist/drivers/db0.mjs
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { defineConnector } from "./index.mjs";
|
|
2
|
-
import { SELECT_1 } from "./internal/sql.mjs";
|
|
3
|
-
import { useDatabase } from "nitropack/runtime";
|
|
4
|
-
import { drizzle } from "db0/integrations/drizzle";
|
|
5
|
-
//#region src/drivers/db0.ts
|
|
6
|
-
/**
|
|
7
|
-
* DB0 datasource driver for Nitro's built-in database configuration.
|
|
8
|
-
* @template TSchema - The schema type
|
|
9
|
-
* @returns A Datasource instance using Nitro's database configuration
|
|
10
|
-
*/
|
|
11
|
-
var db0_default = defineConnector((options, schema) => {
|
|
12
|
-
const db0 = useDatabase(options.name);
|
|
13
|
-
return {
|
|
14
|
-
dialect: "sqlite",
|
|
15
|
-
database: drizzle(db0),
|
|
16
|
-
schema,
|
|
17
|
-
close: async () => {
|
|
18
|
-
await db0.dispose();
|
|
19
|
-
},
|
|
20
|
-
waitReady: async () => {
|
|
21
|
-
await db0.exec(SELECT_1);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
});
|
|
25
|
-
//#endregion
|
|
26
|
-
export { db0_default as default };
|
|
27
|
-
|
|
28
|
-
//# sourceMappingURL=db0.mjs.map
|
package/dist/drivers/db0.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"db0.mjs","names":[],"sources":["../../src/drivers/db0.ts"],"sourcesContent":["import { useDatabase } from \"nitropack/runtime\";\nimport { defineConnector, type Schema } from \".\";\nimport { drizzle } from \"db0/integrations/drizzle\";\nimport { SELECT_1 } from \"./internal/sql\";\n\n/**\n * DB0 datasource driver for Nitro's built-in database configuration.\n * @template TSchema - The schema type\n * @returns A Datasource instance using Nitro's database configuration\n */\nexport default defineConnector(<TSchema extends Schema>(options: Options, schema: TSchema) => {\n const db0 = useDatabase(options.name);\n const database = drizzle<TSchema>(db0);\n return {\n dialect: \"sqlite\",\n database,\n schema,\n close: async () => {\n await db0.dispose();\n },\n waitReady: async () => {\n await db0.exec(SELECT_1);\n },\n };\n});\n\nexport type Options = {\n /** The name of the database to use from Nitro's built-in database configuration. */\n name?: string;\n};\n"],"mappings":";;;;;;;;;;AAUA,IAAA,cAAe,iBAAyC,SAAkB,WAAoB;CAC5F,MAAM,MAAM,YAAY,QAAQ,IAAI;CAEpC,OAAO;EACL,SAAS;EACT,UAHe,QAAiB,GAGzB;EACP;EACA,OAAO,YAAY;GACjB,MAAM,IAAI,QAAQ;EACpB;EACA,WAAW,YAAY;GACrB,MAAM,IAAI,KAAK,QAAQ;EACzB;CACF;AACF,CAAC"}
|
package/dist/plugins/init.d.mts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//#region src/plugins/init.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Nitro plugin that triggers the 'drizzle:init' hook during server initialization.
|
|
4
|
-
* Used to run migration plugins at startup.
|
|
5
|
-
*/
|
|
6
|
-
declare const _default: import("nitro/types").NitroAppPlugin;
|
|
7
|
-
type InitHooks = {
|
|
8
|
-
"drizzle:init": () => void;
|
|
9
|
-
};
|
|
10
|
-
declare module "nitro/types" {
|
|
11
|
-
interface NitroRuntimeHooks extends InitHooks {}
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
|
-
export { InitHooks, _default as default };
|
|
15
|
-
//# sourceMappingURL=init.d.mts.map
|
package/dist/plugins/init.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { definePlugin } from "nitro";
|
|
2
|
-
//#region src/plugins/init.ts
|
|
3
|
-
/**
|
|
4
|
-
* Nitro plugin that triggers the 'drizzle:init' hook during server initialization.
|
|
5
|
-
* Used to run migration plugins at startup.
|
|
6
|
-
*/
|
|
7
|
-
var init_default = definePlugin(async (nitro) => {
|
|
8
|
-
await nitro.hooks.callHook("drizzle:init");
|
|
9
|
-
});
|
|
10
|
-
//#endregion
|
|
11
|
-
export { init_default as default };
|
|
12
|
-
|
|
13
|
-
//# sourceMappingURL=init.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"init.mjs","names":[],"sources":["../../src/plugins/init.ts"],"sourcesContent":["import { definePlugin } from \"nitro\";\n\n/**\n * Nitro plugin that triggers the 'drizzle:init' hook during server initialization.\n * Used to run migration plugins at startup.\n */\nexport default definePlugin(async (nitro) => {\n await nitro.hooks.callHook(\"drizzle:init\");\n});\n\nexport type InitHooks = {\n \"drizzle:init\": () => void;\n};\n\ndeclare module \"nitro/types\" {\n interface NitroRuntimeHooks extends InitHooks {}\n}\n"],"mappings":";;;;;;AAMA,IAAA,eAAe,aAAa,OAAO,UAAU;CAC3C,MAAM,MAAM,MAAM,SAAS,cAAc;AAC3C,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
//#region src/plugins/legacy/init.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Nitro plugin that triggers the 'drizzle:init' hook during server initialization.
|
|
4
|
-
* Used to run migration plugins at startup.
|
|
5
|
-
*/
|
|
6
|
-
declare const _default: import("nitropack").NitroAppPlugin;
|
|
7
|
-
type ReadyState = "pending" | "done" | "error";
|
|
8
|
-
type InitHooks = {
|
|
9
|
-
"drizzle:init": () => void;
|
|
10
|
-
};
|
|
11
|
-
declare module "nitropack/types" {
|
|
12
|
-
interface NitroRuntimeHooks extends InitHooks {}
|
|
13
|
-
}
|
|
14
|
-
declare module "h3" {
|
|
15
|
-
interface H3EventContext {
|
|
16
|
-
drizzle: {
|
|
17
|
-
readyState: ReadyState;
|
|
18
|
-
waitReady: () => Promise<void>;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
23
|
-
export { InitHooks, ReadyState, _default as default };
|
|
24
|
-
//# sourceMappingURL=init.d.mts.map
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { initHooks } from "#nitro-drizzle/runtime";
|
|
2
|
-
import { defineNitroPlugin } from "nitropack/runtime";
|
|
3
|
-
//#region src/plugins/legacy/init.ts
|
|
4
|
-
/**
|
|
5
|
-
* Nitro plugin that triggers the 'drizzle:init' hook during server initialization.
|
|
6
|
-
* Used to run migration plugins at startup.
|
|
7
|
-
*/
|
|
8
|
-
var init_default = defineNitroPlugin(async (nitro) => {
|
|
9
|
-
let initHook;
|
|
10
|
-
let readyState = "pending";
|
|
11
|
-
const waitReady = async () => {
|
|
12
|
-
await initHook;
|
|
13
|
-
};
|
|
14
|
-
nitro.hooks.hook("request", (event) => {
|
|
15
|
-
event.context.drizzle = {
|
|
16
|
-
get readyState() {
|
|
17
|
-
return readyState;
|
|
18
|
-
},
|
|
19
|
-
waitReady
|
|
20
|
-
};
|
|
21
|
-
});
|
|
22
|
-
const cleanup = [];
|
|
23
|
-
async function callInitHook() {
|
|
24
|
-
if (!initHook) {
|
|
25
|
-
initHook = new Promise((resolve, reject) => {
|
|
26
|
-
nitro.hooks.callHook("drizzle:init").then(() => {
|
|
27
|
-
readyState = "done";
|
|
28
|
-
resolve(readyState);
|
|
29
|
-
}).catch((err) => {
|
|
30
|
-
readyState = "error";
|
|
31
|
-
reject(err);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
for (const fn of cleanup) fn();
|
|
35
|
-
}
|
|
36
|
-
await initHook;
|
|
37
|
-
}
|
|
38
|
-
if (initHooks?.length) {
|
|
39
|
-
const cleanups = initHooks.map((hookName) => {
|
|
40
|
-
return nitro.hooks.hook(hookName, async () => {
|
|
41
|
-
await callInitHook();
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
cleanup.push(...cleanups);
|
|
45
|
-
} else await callInitHook();
|
|
46
|
-
});
|
|
47
|
-
//#endregion
|
|
48
|
-
export { init_default as default };
|
|
49
|
-
|
|
50
|
-
//# sourceMappingURL=init.mjs.map
|