@ereo/db-drizzle 0.1.6

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.
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @ereo/db-drizzle - Drizzle Adapter Implementation
3
+ *
4
+ * Implements the DatabaseAdapter interface for Drizzle ORM
5
+ * with support for multiple database drivers.
6
+ */
7
+ import { type DatabaseAdapter } from '@ereo/db';
8
+ import type { DrizzleConfig } from './types';
9
+ /**
10
+ * Create a Drizzle database adapter.
11
+ *
12
+ * @param config - Drizzle configuration
13
+ * @returns A configured DatabaseAdapter instance
14
+ *
15
+ * @example
16
+ * const adapter = createDrizzleAdapter({
17
+ * driver: 'postgres-js',
18
+ * url: process.env.DATABASE_URL,
19
+ * schema,
20
+ * });
21
+ */
22
+ export declare function createDrizzleAdapter<TSchema = unknown>(config: DrizzleConfig): DatabaseAdapter<TSchema>;
23
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,KAAK,eAAe,EAgBrB,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EACV,aAAa,EAUd,MAAM,SAAS,CAAC;AAyQjB;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAG,OAAO,EACpD,MAAM,EAAE,aAAa,GACpB,eAAe,CAAC,OAAO,CAAC,CAE1B"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * @ereo/db-drizzle - Configuration Helpers
3
+ *
4
+ * Type-safe configuration builders for Drizzle adapters.
5
+ */
6
+ import type { DrizzleConfig, DrizzleDriver, PostgresConfig, NeonHttpConfig, NeonWebSocketConfig, PlanetScaleConfig, LibSQLConfig, BunSQLiteConfig, BetterSQLite3Config, D1Config } from './types';
7
+ /**
8
+ * Type-safe configuration builder for Drizzle adapters.
9
+ * Provides autocomplete and validation based on the selected driver.
10
+ *
11
+ * @example
12
+ * const config = defineDrizzleConfig({
13
+ * driver: 'postgres-js',
14
+ * url: process.env.DATABASE_URL,
15
+ * schema,
16
+ * connection: {
17
+ * ssl: 'require',
18
+ * max: 10,
19
+ * },
20
+ * });
21
+ */
22
+ export declare function defineDrizzleConfig<T extends DrizzleConfig>(config: T): T;
23
+ /**
24
+ * Create a PostgreSQL configuration with sensible defaults.
25
+ */
26
+ export declare function definePostgresConfig(config: Omit<PostgresConfig, 'driver'>): PostgresConfig;
27
+ /**
28
+ * Create a Neon HTTP configuration (edge-compatible).
29
+ */
30
+ export declare function defineNeonHttpConfig(config: Omit<NeonHttpConfig, 'driver'>): NeonHttpConfig;
31
+ /**
32
+ * Create a Neon WebSocket configuration.
33
+ */
34
+ export declare function defineNeonWebSocketConfig(config: Omit<NeonWebSocketConfig, 'driver'>): NeonWebSocketConfig;
35
+ /**
36
+ * Create a PlanetScale configuration (edge-compatible).
37
+ */
38
+ export declare function definePlanetScaleConfig(config: Omit<PlanetScaleConfig, 'driver'>): PlanetScaleConfig;
39
+ /**
40
+ * Create a LibSQL/Turso configuration.
41
+ */
42
+ export declare function defineLibSQLConfig(config: Omit<LibSQLConfig, 'driver'>): LibSQLConfig;
43
+ /**
44
+ * Create a Bun SQLite configuration.
45
+ */
46
+ export declare function defineBunSQLiteConfig(config: Omit<BunSQLiteConfig, 'driver'>): BunSQLiteConfig;
47
+ /**
48
+ * Create a better-sqlite3 configuration.
49
+ */
50
+ export declare function defineBetterSQLite3Config(config: Omit<BetterSQLite3Config, 'driver'>): BetterSQLite3Config;
51
+ /**
52
+ * Create a Cloudflare D1 configuration.
53
+ */
54
+ export declare function defineD1Config(config: Omit<D1Config, 'driver'>): D1Config;
55
+ /**
56
+ * Configuration options for edge environments.
57
+ */
58
+ export interface EdgeConfigOptions {
59
+ /**
60
+ * The edge-compatible driver to use.
61
+ */
62
+ driver: 'neon-http' | 'neon-websocket' | 'planetscale' | 'libsql' | 'd1';
63
+ /**
64
+ * Database connection URL.
65
+ */
66
+ url: string;
67
+ /**
68
+ * The Drizzle schema object.
69
+ */
70
+ schema?: Record<string, unknown>;
71
+ /**
72
+ * Auth token (for LibSQL/Turso).
73
+ */
74
+ authToken?: string;
75
+ /**
76
+ * Enable debug logging.
77
+ */
78
+ debug?: boolean;
79
+ }
80
+ /**
81
+ * Create an edge-optimized Drizzle configuration.
82
+ * Automatically selects appropriate settings for edge runtimes.
83
+ *
84
+ * @example
85
+ * const config = defineEdgeConfig({
86
+ * driver: 'neon-http',
87
+ * url: process.env.DATABASE_URL,
88
+ * schema,
89
+ * });
90
+ */
91
+ export declare function defineEdgeConfig(options: EdgeConfigOptions): DrizzleConfig;
92
+ /**
93
+ * Detect the current runtime environment.
94
+ */
95
+ export type RuntimeEnvironment = 'bun' | 'node' | 'cloudflare-workers' | 'vercel-edge' | 'deno' | 'unknown';
96
+ /**
97
+ * Detect the current runtime environment.
98
+ */
99
+ export declare function detectRuntime(): RuntimeEnvironment;
100
+ /**
101
+ * Check if the current environment is edge-compatible.
102
+ */
103
+ export declare function isEdgeRuntime(): boolean;
104
+ /**
105
+ * Suggest appropriate drivers for the current environment.
106
+ */
107
+ export declare function suggestDrivers(): DrizzleDriver[];
108
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,QAAQ,EAET,MAAM,SAAS,CAAC;AAMjB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,aAAa,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAEzE;AAMD;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EA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AAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,aAAa,CAgC1E;AAMD;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,KAAK,GACL,MAAM,GACN,oBAAoB,GACpB,aAAa,GACb,MAAM,GACN,SAAS,CAAC;AAEd;;GAEG;AACH,wBAAgB,aAAa,IAAI,kBAAkB,CA+BlD;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAGvC;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,aAAa,EAAE,CAsBhD"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @ereo/db-drizzle - Drizzle ORM Adapter
3
+ *
4
+ * Provides Drizzle ORM integration for the EreoJS database abstraction layer.
5
+ * Supports multiple database drivers including edge-compatible options.
6
+ *
7
+ * @example
8
+ * // PostgreSQL setup
9
+ * import { createDrizzleAdapter, definePostgresConfig } from '@ereo/db-drizzle';
10
+ * import { createDatabasePlugin } from '@ereo/db';
11
+ * import * as schema from './db/schema';
12
+ *
13
+ * const config = definePostgresConfig({
14
+ * url: process.env.DATABASE_URL,
15
+ * schema,
16
+ * });
17
+ *
18
+ * const adapter = createDrizzleAdapter(config);
19
+ *
20
+ * export default defineConfig({
21
+ * plugins: [createDatabasePlugin(adapter)],
22
+ * });
23
+ *
24
+ * @example
25
+ * // Edge-compatible setup with Neon
26
+ * import { createDrizzleAdapter, defineEdgeConfig } from '@ereo/db-drizzle';
27
+ * import { createDatabasePlugin } from '@ereo/db';
28
+ *
29
+ * const adapter = createDrizzleAdapter(defineEdgeConfig({
30
+ * driver: 'neon-http',
31
+ * url: process.env.DATABASE_URL,
32
+ * schema,
33
+ * }));
34
+ *
35
+ * @packageDocumentation
36
+ */
37
+ export { createDrizzleAdapter } from './adapter';
38
+ export { defineDrizzleConfig, definePostgresConfig, defineNeonHttpConfig, defineNeonWebSocketConfig, definePlanetScaleConfig, defineLibSQLConfig, defineBunSQLiteConfig, defineBetterSQLite3Config, defineD1Config, defineEdgeConfig, detectRuntime, isEdgeRuntime, suggestDrivers, type EdgeConfigOptions, type RuntimeEnvironment, } from './config';
39
+ export { type DrizzleDriver, type DrizzleConfig, type DrizzleClient, type PostgresConfig, type NeonHttpConfig, type NeonWebSocketConfig, type PlanetScaleConfig, type LibSQLConfig, type BunSQLiteConfig, type BetterSQLite3Config, type D1Config, EDGE_COMPATIBLE_DRIVERS, type D1Database, type D1PreparedStatement, type D1Result, type D1ExecResult, } from './types';
40
+ export { createDatabasePlugin, useDb, useAdapter, getDb, withTransaction, type DatabaseAdapter, type RequestScopedClient, type QueryResult, type MutationResult, type DedupResult, type DedupStats, type TransactionOptions, } from '@ereo/db';
41
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAMH,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAMjD,OAAO,EAEL,mBAAmB,EAEnB,oBAAoB,EACpB,oBAAoB,EACpB,yBAAyB,EACzB,uBAAuB,EACvB,kBAAkB,EAClB,qBAAqB,EACrB,yBAAyB,EACzB,cAAc,EAEd,gBAAgB,EAEhB,aAAa,EACb,aAAa,EACb,cAAc,EAEd,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,UAAU,CAAC;AAMlB,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAElB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,QAAQ,EAEb,uBAAuB,EAEvB,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,QAAQ,EACb,KAAK,YAAY,GAClB,MAAM,SAAS,CAAC;AAMjB,OAAO,EAEL,oBAAoB,EACpB,KAAK,EACL,UAAU,EACV,KAAK,EACL,eAAe,EAEf,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,kBAAkB,GACxB,MAAM,UAAU,CAAC"}