@drizzle-adapter/d1 1.0.18 → 1.1.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/.wrangler/state/v3/d1/miniflare-D1DatabaseObject/6e148680931b1bfcb993e0463aced3b0a6d6cf50af24dea2dcc2c3b2e9ae9e3b.sqlite-shm +0 -0
- package/.wrangler/state/v3/d1/miniflare-D1DatabaseObject/6e148680931b1bfcb993e0463aced3b0a6d6cf50af24dea2dcc2c3b2e9ae9e3b.sqlite-wal +0 -0
- package/dist/Adapter/D1DrizzleAdapter.d.ts +4 -4
- package/dist/Adapter/D1DrizzleAdapter.js +3 -3
- package/dist/Adapter/D1DrizzleConnection.d.ts +2 -2
- package/dist/Adapter/D1DrizzleConnection.js +2 -1
- package/dist/Adapter/D1DrizzleMigrator.d.ts +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.js +9 -6
- package/dist/migrator.d.ts +1 -1
- package/dist/migrator.js +3 -3
- package/eslint.config.mjs +1 -1
- package/package.json +16 -16
- package/src/Adapter/D1DrizzleAdapter.ts +6 -6
- package/src/Adapter/D1DrizzleConnection.ts +17 -8
- package/src/Adapter/D1DrizzleMigrator.ts +16 -8
- package/src/Factory/D1DrizzleDataTypesFactory.ts +7 -2
- package/src/Factory/D1DrizzleMigratorFactory.ts +4 -1
- package/src/index.ts +21 -10
- package/src/migrator.ts +9 -6
- package/tests/Adapter/D1DrizzleAdapter.test.ts +2 -2
- package/tests/Adapter/D1DrizzleConnection.test.ts +1 -1
- package/tests/Adapter/D1DrizzleMigrator.test.ts +1 -1
- package/tests/Factory/D1DrizzleAdapterFactory.test.ts +3 -3
- package/tsconfig.json +1 -6
- package/dist/Adapter/D1DrizzleDataTypes.d.ts +0 -7
- package/dist/Adapter/D1DrizzleDataTypes.js +0 -7
- package/dist/Adapter/index.d.ts +0 -2
- package/dist/Adapter/index.js +0 -2
- package/dist/Factory/index.d.ts +0 -2
- package/dist/Factory/index.js +0 -2
- package/dist/Interface/index.d.ts +0 -1
- package/dist/Interface/index.js +0 -1
- package/dist/Type/index.d.ts +0 -1
- package/dist/Type/index.js +0 -1
- package/src/Adapter/D1DrizzleDataTypes.ts +0 -7
- package/src/Adapter/index.ts +0 -2
- package/src/Factory/index.ts +0 -2
- package/src/Interface/index.ts +0 -1
- package/src/Type/index.ts +0 -1
|
Binary file
|
|
Binary file
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { D1Database } from '@cloudflare/workers-types';
|
|
2
2
|
import type { DrizzleAdapterInterface } from '@drizzle-adapter/core';
|
|
3
|
+
import { SqliteCoreDrizzleDataTypes } from '@drizzle-adapter/sqlite-core';
|
|
3
4
|
import { D1DrizzleConnection } from './D1DrizzleConnection.js';
|
|
4
|
-
import { D1DrizzleDataTypes } from './D1DrizzleDataTypes.js';
|
|
5
5
|
/**
|
|
6
6
|
* D1 adapter implementation for Drizzle ORM.
|
|
7
7
|
* Provides D1-specific database operations and connection management.
|
|
8
8
|
*/
|
|
9
9
|
export declare class D1DrizzleAdapter implements DrizzleAdapterInterface {
|
|
10
|
-
private connection;
|
|
10
|
+
private readonly connection;
|
|
11
11
|
/**
|
|
12
12
|
* Constructor.
|
|
13
13
|
*
|
|
@@ -23,9 +23,9 @@ export declare class D1DrizzleAdapter implements DrizzleAdapterInterface {
|
|
|
23
23
|
/**
|
|
24
24
|
* Returns the data types.
|
|
25
25
|
*
|
|
26
|
-
* @returns {
|
|
26
|
+
* @returns {SqliteCoreDrizzleDataTypes} The SQLite core data types instance
|
|
27
27
|
*/
|
|
28
|
-
getDataTypes():
|
|
28
|
+
getDataTypes(): SqliteCoreDrizzleDataTypes;
|
|
29
29
|
/**
|
|
30
30
|
* Returns the dialect.
|
|
31
31
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { SqliteCoreDrizzleDataTypes } from '@drizzle-adapter/sqlite-core';
|
|
1
2
|
import { D1DrizzleConnection } from './D1DrizzleConnection.js';
|
|
2
|
-
import { D1DrizzleDataTypes } from './D1DrizzleDataTypes.js';
|
|
3
3
|
/**
|
|
4
4
|
* D1 adapter implementation for Drizzle ORM.
|
|
5
5
|
* Provides D1-specific database operations and connection management.
|
|
@@ -25,10 +25,10 @@ export class D1DrizzleAdapter {
|
|
|
25
25
|
/**
|
|
26
26
|
* Returns the data types.
|
|
27
27
|
*
|
|
28
|
-
* @returns {
|
|
28
|
+
* @returns {SqliteCoreDrizzleDataTypes} The SQLite core data types instance
|
|
29
29
|
*/
|
|
30
30
|
getDataTypes() {
|
|
31
|
-
return new
|
|
31
|
+
return new SqliteCoreDrizzleDataTypes();
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* Returns the dialect.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { D1Database } from '@cloudflare/workers-types';
|
|
2
2
|
import type { DrizzleConnectionInterface } from '@drizzle-adapter/core';
|
|
3
|
-
import type { D1DrizzleClientInterface } from '
|
|
3
|
+
import type { D1DrizzleClientInterface } from '../Interface/D1DrizzleClientInterface.js';
|
|
4
4
|
/**
|
|
5
5
|
* D1 connection implementation for Drizzle ORM.
|
|
6
6
|
* Manages database connections and provides client access for D1 databases.
|
|
7
7
|
*/
|
|
8
8
|
export declare class D1DrizzleConnection implements DrizzleConnectionInterface {
|
|
9
|
-
private client;
|
|
9
|
+
private readonly client;
|
|
10
10
|
/**
|
|
11
11
|
* Constructor.
|
|
12
12
|
*
|
|
@@ -13,7 +13,8 @@ export class D1DrizzleConnection {
|
|
|
13
13
|
constructor(driver) {
|
|
14
14
|
// We want to add the execute method as an alias for run
|
|
15
15
|
const database = drizzle(driver);
|
|
16
|
-
database.execute =
|
|
16
|
+
database.execute =
|
|
17
|
+
database.run;
|
|
17
18
|
// Override transaction method to provide transaction-like behavior
|
|
18
19
|
// Since D1 doesn't support real transactions, we pass the original client
|
|
19
20
|
// Users can implement their own batching if needed for atomicity
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DrizzleMigratorInterface, TypeDrizzleMigratorConfig } from '@drizzle-adapter/core';
|
|
2
|
-
import type { D1DrizzleClientInterface } from '../Interface/
|
|
2
|
+
import type { D1DrizzleClientInterface } from '../Interface/D1DrizzleClientInterface.js';
|
|
3
3
|
/**
|
|
4
4
|
* D1 migrator implementation for Drizzle ORM.
|
|
5
5
|
* Handles database migrations for D1 databases.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
|
|
1
|
+
import { D1DrizzleAdapterFactory } from './Factory/D1DrizzleAdapterFactory.js';
|
|
2
|
+
export { D1DrizzleAdapter } from './Adapter/D1DrizzleAdapter.js';
|
|
3
|
+
export { D1DrizzleConnection } from './Adapter/D1DrizzleConnection.js';
|
|
4
|
+
export { D1DrizzleAdapterFactory } from './Factory/D1DrizzleAdapterFactory.js';
|
|
5
|
+
export { D1DrizzleDataTypesFactory } from './Factory/D1DrizzleDataTypesFactory.js';
|
|
6
|
+
export * from './Interface/D1DrizzleClientInterface.js';
|
|
7
|
+
export * from './Type/Types.js';
|
|
6
8
|
export default D1DrizzleAdapterFactory;
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
export * from './Adapter/index.js';
|
|
2
|
-
export * from './Factory/index.js';
|
|
3
|
-
export * from './Interface/index.js';
|
|
4
|
-
export * from './Type/index.js';
|
|
5
1
|
// default export so that core factory can use it directly
|
|
6
|
-
import { D1DrizzleAdapterFactory, D1DrizzleDataTypesFactory } from './Factory/index.js';
|
|
7
|
-
export default D1DrizzleAdapterFactory;
|
|
8
2
|
import { DrizzleAdapterFactoryRegistry, DrizzleDataTypesFactoryRegistry } from '@drizzle-adapter/core';
|
|
3
|
+
import { D1DrizzleAdapterFactory } from './Factory/D1DrizzleAdapterFactory.js';
|
|
4
|
+
import { D1DrizzleDataTypesFactory } from './Factory/D1DrizzleDataTypesFactory.js';
|
|
5
|
+
export { D1DrizzleAdapter } from './Adapter/D1DrizzleAdapter.js';
|
|
6
|
+
export { D1DrizzleConnection } from './Adapter/D1DrizzleConnection.js';
|
|
7
|
+
export { D1DrizzleAdapterFactory } from './Factory/D1DrizzleAdapterFactory.js';
|
|
8
|
+
export { D1DrizzleDataTypesFactory } from './Factory/D1DrizzleDataTypesFactory.js';
|
|
9
|
+
export * from './Interface/D1DrizzleClientInterface.js';
|
|
10
|
+
export * from './Type/Types.js';
|
|
11
|
+
export default D1DrizzleAdapterFactory;
|
|
9
12
|
DrizzleAdapterFactoryRegistry.registerAdapterFactory('d1', D1DrizzleAdapterFactory);
|
|
10
13
|
DrizzleDataTypesFactoryRegistry.registerDataTypesFactory('d1', D1DrizzleDataTypesFactory);
|
package/dist/migrator.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
+
import { D1DrizzleMigratorFactory } from './Factory/D1DrizzleMigratorFactory.js';
|
|
1
2
|
export * from './Adapter/D1DrizzleMigrator.js';
|
|
2
3
|
export * from './Factory/D1DrizzleMigratorFactory.js';
|
|
3
|
-
import { D1DrizzleMigratorFactory } from './Factory/D1DrizzleMigratorFactory.js';
|
|
4
4
|
export default D1DrizzleMigratorFactory;
|
package/dist/migrator.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from './Adapter/D1DrizzleMigrator.js';
|
|
2
|
-
export * from './Factory/D1DrizzleMigratorFactory.js';
|
|
3
1
|
// default export so that core factory can use it directly
|
|
2
|
+
import { DrizzleMigratorFactoryRegistry } from '@drizzle-adapter/core/migrator';
|
|
4
3
|
import { D1DrizzleMigratorFactory } from './Factory/D1DrizzleMigratorFactory.js';
|
|
4
|
+
export * from './Adapter/D1DrizzleMigrator.js';
|
|
5
|
+
export * from './Factory/D1DrizzleMigratorFactory.js';
|
|
5
6
|
export default D1DrizzleMigratorFactory;
|
|
6
|
-
import { DrizzleMigratorFactoryRegistry } from '@drizzle-adapter/core/migrator';
|
|
7
7
|
DrizzleMigratorFactoryRegistry.registerMigratorFactory('d1', D1DrizzleMigratorFactory);
|
package/eslint.config.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drizzle-adapter/d1",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.1.1",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
-
"
|
|
10
|
-
"
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
11
|
},
|
|
12
12
|
"./migrator": {
|
|
13
|
-
"
|
|
14
|
-
"
|
|
13
|
+
"types": "./dist/migrator.d.ts",
|
|
14
|
+
"default": "./dist/migrator.js"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@cloudflare/workers-types": "^4.
|
|
19
|
-
"@dmitryrechkin/eslint-standard": "^1.
|
|
20
|
-
"dotenv": "^17.
|
|
21
|
-
"eslint": "^
|
|
22
|
-
"eslint-plugin-unused-imports": "^4.1
|
|
18
|
+
"@cloudflare/workers-types": "^4.20260317.1",
|
|
19
|
+
"@dmitryrechkin/eslint-standard": "^1.5.13",
|
|
20
|
+
"dotenv": "^17.3.1",
|
|
21
|
+
"eslint": "^10.1.0",
|
|
22
|
+
"eslint-plugin-unused-imports": "^4.4.1",
|
|
23
23
|
"shx": "^0.4.0",
|
|
24
24
|
"tsc-esm-fix": "^3.1.2",
|
|
25
25
|
"tsconfig-paths": "^4.2.0",
|
|
26
|
-
"typescript": "^5.
|
|
27
|
-
"vitest": "^
|
|
28
|
-
"wrangler": "^
|
|
26
|
+
"typescript": "^5.9.3",
|
|
27
|
+
"vitest": "^4.1.1",
|
|
28
|
+
"wrangler": "^4.77.0"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"drizzle-orm": "^0.
|
|
32
|
-
"@drizzle-adapter/core": "^1.
|
|
33
|
-
"@drizzle-adapter/sqlite-core": "^1.
|
|
31
|
+
"drizzle-orm": "^0.45.1",
|
|
32
|
+
"@drizzle-adapter/core": "^1.1.1",
|
|
33
|
+
"@drizzle-adapter/sqlite-core": "^1.1.1"
|
|
34
34
|
},
|
|
35
35
|
"license": "MIT",
|
|
36
36
|
"scripts": {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { D1Database } from '@cloudflare/workers-types';
|
|
2
2
|
import type { DrizzleAdapterInterface } from '@drizzle-adapter/core';
|
|
3
|
+
import { SqliteCoreDrizzleDataTypes } from '@drizzle-adapter/sqlite-core';
|
|
3
4
|
|
|
4
5
|
import { D1DrizzleConnection } from './D1DrizzleConnection';
|
|
5
|
-
import { D1DrizzleDataTypes } from './D1DrizzleDataTypes';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* D1 adapter implementation for Drizzle ORM.
|
|
@@ -10,14 +10,14 @@ import { D1DrizzleDataTypes } from './D1DrizzleDataTypes';
|
|
|
10
10
|
*/
|
|
11
11
|
export class D1DrizzleAdapter implements DrizzleAdapterInterface
|
|
12
12
|
{
|
|
13
|
-
private connection: D1DrizzleConnection;
|
|
13
|
+
private readonly connection: D1DrizzleConnection;
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Constructor.
|
|
17
17
|
*
|
|
18
18
|
* @param {D1Database} driver - The D1 database driver instance
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
constructor(driver: D1Database)
|
|
21
21
|
{
|
|
22
22
|
this.connection = new D1DrizzleConnection(driver);
|
|
23
23
|
}
|
|
@@ -35,11 +35,11 @@ export class D1DrizzleAdapter implements DrizzleAdapterInterface
|
|
|
35
35
|
/**
|
|
36
36
|
* Returns the data types.
|
|
37
37
|
*
|
|
38
|
-
* @returns {
|
|
38
|
+
* @returns {SqliteCoreDrizzleDataTypes} The SQLite core data types instance
|
|
39
39
|
*/
|
|
40
|
-
public getDataTypes():
|
|
40
|
+
public getDataTypes(): SqliteCoreDrizzleDataTypes
|
|
41
41
|
{
|
|
42
|
-
return new
|
|
42
|
+
return new SqliteCoreDrizzleDataTypes();
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { D1Database } from '@cloudflare/workers-types';
|
|
2
2
|
import type { DrizzleConnectionInterface } from '@drizzle-adapter/core';
|
|
3
3
|
import { drizzle } from 'drizzle-orm/d1';
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
import type { D1DrizzleClientInterface } from '../Interface/D1DrizzleClientInterface';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* D1 connection implementation for Drizzle ORM.
|
|
@@ -9,28 +10,36 @@ import type { D1DrizzleClientInterface } from 'src/Interface';
|
|
|
9
10
|
*/
|
|
10
11
|
export class D1DrizzleConnection implements DrizzleConnectionInterface
|
|
11
12
|
{
|
|
12
|
-
private client: D1DrizzleClientInterface;
|
|
13
|
+
private readonly client: D1DrizzleClientInterface;
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Constructor.
|
|
16
17
|
*
|
|
17
18
|
* @param {D1Database} driver - The D1 database driver instance
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
+
constructor(driver: D1Database)
|
|
20
21
|
{
|
|
21
22
|
// We want to add the execute method as an alias for run
|
|
22
|
-
const database: ReturnType<typeof drizzle> | D1DrizzleClientInterface =
|
|
23
|
-
|
|
23
|
+
const database: ReturnType<typeof drizzle> | D1DrizzleClientInterface =
|
|
24
|
+
drizzle(driver);
|
|
25
|
+
|
|
26
|
+
(database as unknown as D1DrizzleClientInterface).execute =
|
|
27
|
+
database.run;
|
|
24
28
|
|
|
25
29
|
// Override transaction method to provide transaction-like behavior
|
|
26
30
|
// Since D1 doesn't support real transactions, we pass the original client
|
|
27
31
|
// Users can implement their own batching if needed for atomicity
|
|
28
|
-
(database as unknown as D1DrizzleClientInterface).transaction = async <
|
|
32
|
+
(database as unknown as D1DrizzleClientInterface).transaction = async <
|
|
33
|
+
T
|
|
34
|
+
>(
|
|
29
35
|
callback: (tx: D1DrizzleClientInterface) => Promise<T>
|
|
30
|
-
): Promise<T> =>
|
|
36
|
+
): Promise<T> =>
|
|
37
|
+
{
|
|
31
38
|
// For now, just pass the original client - no transaction isolation
|
|
32
39
|
// This allows code to work without modifications while being explicit about the limitation
|
|
33
|
-
return await callback(
|
|
40
|
+
return await callback(
|
|
41
|
+
database as unknown as D1DrizzleClientInterface
|
|
42
|
+
);
|
|
34
43
|
};
|
|
35
44
|
|
|
36
45
|
this.client = database as unknown as D1DrizzleClientInterface;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
DrizzleMigratorInterface,
|
|
3
|
+
TypeDrizzleMigratorConfig
|
|
4
|
+
} from '@drizzle-adapter/core';
|
|
2
5
|
import { DrizzleD1Database } from 'drizzle-orm/d1/driver';
|
|
3
6
|
|
|
4
|
-
import type { D1DrizzleClientInterface } from '../Interface';
|
|
7
|
+
import type { D1DrizzleClientInterface } from '../Interface/D1DrizzleClientInterface';
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* D1 migrator implementation for Drizzle ORM.
|
|
@@ -14,7 +17,8 @@ export class D1DrizzleMigrator implements DrizzleMigratorInterface
|
|
|
14
17
|
*
|
|
15
18
|
* @param {TypeDrizzleMigratorConfig} config The migrator configuration.
|
|
16
19
|
*/
|
|
17
|
-
|
|
20
|
+
constructor(private readonly config: TypeDrizzleMigratorConfig)
|
|
21
|
+
{}
|
|
18
22
|
|
|
19
23
|
/**
|
|
20
24
|
* Migrate the database.
|
|
@@ -24,10 +28,14 @@ export class D1DrizzleMigrator implements DrizzleMigratorInterface
|
|
|
24
28
|
public async migrate(client: D1DrizzleClientInterface): Promise<void>
|
|
25
29
|
{
|
|
26
30
|
const { migrate } = await import('drizzle-orm/d1/migrator');
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
|
|
32
|
+
await migrate(
|
|
33
|
+
client as unknown as DrizzleD1Database<Record<string, unknown>>,
|
|
34
|
+
{
|
|
35
|
+
migrationsFolder: this.config.DATABASE_MIGRATIONS_FOLDER,
|
|
36
|
+
migrationsTable: this.config.DATABASE_MIGRATIONS_TABLE,
|
|
37
|
+
migrationsSchema: this.config.DATABASE_MIGRATIONS_SCHEMA
|
|
38
|
+
}
|
|
39
|
+
);
|
|
32
40
|
}
|
|
33
41
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
DrizzleDataTypesFactoryInterface,
|
|
3
|
+
TypeDrizzleDatabaseConfig
|
|
4
|
+
} from '@drizzle-adapter/core';
|
|
2
5
|
import { SqliteCoreDrizzleDataTypes } from '@drizzle-adapter/sqlite-core';
|
|
3
6
|
|
|
4
7
|
/**
|
|
@@ -13,7 +16,9 @@ export class D1DrizzleDataTypesFactory implements DrizzleDataTypesFactoryInterfa
|
|
|
13
16
|
* @param {TypeDrizzleDatabaseConfig} _config - Not used in this implementation
|
|
14
17
|
* @returns {SqliteCoreDrizzleDataTypes} A new SQLite core data types instance
|
|
15
18
|
*/
|
|
16
|
-
public create(
|
|
19
|
+
public create(
|
|
20
|
+
_config: TypeDrizzleDatabaseConfig
|
|
21
|
+
): SqliteCoreDrizzleDataTypes
|
|
17
22
|
{
|
|
18
23
|
return new SqliteCoreDrizzleDataTypes();
|
|
19
24
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
DrizzleMigratorFactoryInterface,
|
|
3
|
+
TypeDrizzleMigratorConfig
|
|
4
|
+
} from '@drizzle-adapter/core';
|
|
2
5
|
|
|
3
6
|
import { D1DrizzleMigrator } from '../migrator';
|
|
4
7
|
|
package/src/index.ts
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
export * from './Adapter';
|
|
2
|
-
export * from './Factory';
|
|
3
|
-
export * from './Interface';
|
|
4
|
-
export * from './Type';
|
|
5
|
-
|
|
6
1
|
// default export so that core factory can use it directly
|
|
7
|
-
import {
|
|
8
|
-
|
|
2
|
+
import {
|
|
3
|
+
DrizzleAdapterFactoryRegistry,
|
|
4
|
+
DrizzleDataTypesFactoryRegistry
|
|
5
|
+
} from '@drizzle-adapter/core';
|
|
9
6
|
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
DrizzleDataTypesFactoryRegistry.registerDataTypesFactory('d1', D1DrizzleDataTypesFactory);
|
|
7
|
+
import { D1DrizzleAdapterFactory } from './Factory/D1DrizzleAdapterFactory';
|
|
8
|
+
import { D1DrizzleDataTypesFactory } from './Factory/D1DrizzleDataTypesFactory';
|
|
13
9
|
|
|
10
|
+
export { D1DrizzleAdapter } from './Adapter/D1DrizzleAdapter';
|
|
11
|
+
export { D1DrizzleConnection } from './Adapter/D1DrizzleConnection';
|
|
12
|
+
export { D1DrizzleAdapterFactory } from './Factory/D1DrizzleAdapterFactory';
|
|
13
|
+
export { D1DrizzleDataTypesFactory } from './Factory/D1DrizzleDataTypesFactory';
|
|
14
|
+
export * from './Interface/D1DrizzleClientInterface';
|
|
15
|
+
export * from './Type/Types';
|
|
16
|
+
export default D1DrizzleAdapterFactory;
|
|
17
|
+
DrizzleAdapterFactoryRegistry.registerAdapterFactory(
|
|
18
|
+
'd1',
|
|
19
|
+
D1DrizzleAdapterFactory
|
|
20
|
+
);
|
|
21
|
+
DrizzleDataTypesFactoryRegistry.registerDataTypesFactory(
|
|
22
|
+
'd1',
|
|
23
|
+
D1DrizzleDataTypesFactory
|
|
24
|
+
);
|
package/src/migrator.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
export * from './Adapter/D1DrizzleMigrator';
|
|
2
|
-
export * from './Factory/D1DrizzleMigratorFactory';
|
|
3
|
-
|
|
4
1
|
// default export so that core factory can use it directly
|
|
2
|
+
import { DrizzleMigratorFactoryRegistry } from '@drizzle-adapter/core/migrator';
|
|
3
|
+
|
|
5
4
|
import { D1DrizzleMigratorFactory } from './Factory/D1DrizzleMigratorFactory';
|
|
6
|
-
export default D1DrizzleMigratorFactory;
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export * from './Adapter/D1DrizzleMigrator';
|
|
7
|
+
export * from './Factory/D1DrizzleMigratorFactory';
|
|
8
|
+
export default D1DrizzleMigratorFactory;
|
|
9
|
+
DrizzleMigratorFactoryRegistry.registerMigratorFactory(
|
|
10
|
+
'd1',
|
|
11
|
+
D1DrizzleMigratorFactory
|
|
12
|
+
);
|
|
@@ -28,8 +28,8 @@ describe('D1DrizzleAdapter', () => {
|
|
|
28
28
|
expect(dataTypes).toBeInstanceOf(SqliteCoreDrizzleDataTypes);
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
it('should return D1DrizzleConnection instance with the provided database', () => {
|
|
31
|
+
it('should return D1DrizzleConnection instance with the provided database', async () => {
|
|
32
32
|
const adapter = new D1DrizzleAdapter(mockD1Database);
|
|
33
|
-
expect(adapter.getConnection()).resolves.toBeInstanceOf(D1DrizzleConnection);
|
|
33
|
+
await expect(adapter.getConnection()).resolves.toBeInstanceOf(D1DrizzleConnection);
|
|
34
34
|
});
|
|
35
35
|
});
|
|
@@ -35,6 +35,6 @@ describe('D1DrizzleConnection', () => {
|
|
|
35
35
|
it('should return the query client', async () => {
|
|
36
36
|
const connection = new D1DrizzleConnection(mockD1Database);
|
|
37
37
|
const client = connection.getClient();
|
|
38
|
-
expect(client).
|
|
38
|
+
expect(client).toMatchObject({ mockedClient: true });
|
|
39
39
|
});
|
|
40
40
|
});
|
|
@@ -2,7 +2,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
|
2
2
|
import { D1DrizzleMigrator } from '../../src/Adapter/D1DrizzleMigrator';
|
|
3
3
|
import * as migrator from 'drizzle-orm/d1/migrator';
|
|
4
4
|
import type { TypeDrizzleMigratorConfig } from '@drizzle-adapter/core';
|
|
5
|
-
import type { D1DrizzleClientInterface } from '../../src
|
|
5
|
+
import type { D1DrizzleClientInterface } from '../../src';
|
|
6
6
|
|
|
7
7
|
// Mock the migrate function from drizzle-orm/d1/migrator
|
|
8
8
|
vi.mock('drizzle-orm/d1/migrator', () => ({
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
import { D1DrizzleAdapterFactory } from '../../src
|
|
3
|
-
import { D1DrizzleAdapter } from '../../src
|
|
2
|
+
import { D1DrizzleAdapterFactory } from '../../src';
|
|
3
|
+
import { D1DrizzleAdapter } from '../../src';
|
|
4
4
|
import { drizzle } from 'drizzle-orm/d1';
|
|
5
5
|
import type { D1Database } from '@cloudflare/workers-types';
|
|
6
|
-
import type { TypeD1DatabaseConfig } from '../../src
|
|
6
|
+
import type { TypeD1DatabaseConfig } from '../../src';
|
|
7
7
|
|
|
8
8
|
// Mock drizzle-orm/d1
|
|
9
9
|
vi.mock('drizzle-orm/d1', () => ({
|
package/tsconfig.json
CHANGED
|
@@ -26,12 +26,7 @@
|
|
|
26
26
|
// Some stricter flags (disabled by default)
|
|
27
27
|
"noUnusedLocals": true,
|
|
28
28
|
"noUnusedParameters": true,
|
|
29
|
-
"noPropertyAccessFromIndexSignature": true
|
|
30
|
-
|
|
31
|
-
"baseUrl": ".",
|
|
32
|
-
"paths": {
|
|
33
|
-
"@drizzle-adapter/*": ["../*/dist"]
|
|
34
|
-
}
|
|
29
|
+
"noPropertyAccessFromIndexSignature": true
|
|
35
30
|
},
|
|
36
31
|
"include": ["src/**/*.ts", "tests/worker.ts", "tests/worker.ts"],
|
|
37
32
|
"exclude": ["node_modules", "dist", "tests"]
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { SqliteCoreDrizzleDataTypes } from '@drizzle-adapter/sqlite-core';
|
|
2
|
-
/**
|
|
3
|
-
* D1 data types implementation for Drizzle ORM.
|
|
4
|
-
* Extends the core SQLite data types with D1-specific functionality.
|
|
5
|
-
*/
|
|
6
|
-
export declare class D1DrizzleDataTypes extends SqliteCoreDrizzleDataTypes {
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { SqliteCoreDrizzleDataTypes } from '@drizzle-adapter/sqlite-core';
|
|
2
|
-
/**
|
|
3
|
-
* D1 data types implementation for Drizzle ORM.
|
|
4
|
-
* Extends the core SQLite data types with D1-specific functionality.
|
|
5
|
-
*/
|
|
6
|
-
export class D1DrizzleDataTypes extends SqliteCoreDrizzleDataTypes {
|
|
7
|
-
}
|
package/dist/Adapter/index.d.ts
DELETED
package/dist/Adapter/index.js
DELETED
package/dist/Factory/index.d.ts
DELETED
package/dist/Factory/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './D1DrizzleClientInterface.js';
|
package/dist/Interface/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './D1DrizzleClientInterface.js';
|
package/dist/Type/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Types.js';
|
package/dist/Type/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Types.js';
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { SqliteCoreDrizzleDataTypes } from '@drizzle-adapter/sqlite-core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* D1 data types implementation for Drizzle ORM.
|
|
5
|
-
* Extends the core SQLite data types with D1-specific functionality.
|
|
6
|
-
*/
|
|
7
|
-
export class D1DrizzleDataTypes extends SqliteCoreDrizzleDataTypes {}
|
package/src/Adapter/index.ts
DELETED
package/src/Factory/index.ts
DELETED
package/src/Interface/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './D1DrizzleClientInterface';
|
package/src/Type/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Types';
|