@drizzle-adapter/d1 1.0.1 → 1.0.4

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.
Files changed (76) hide show
  1. package/.wrangler/state/v3/d1/miniflare-D1DatabaseObject/6e148680931b1bfcb993e0463aced3b0a6d6cf50af24dea2dcc2c3b2e9ae9e3b.sqlite +0 -0
  2. package/.wrangler/state/v3/d1/miniflare-D1DatabaseObject/6e148680931b1bfcb993e0463aced3b0a6d6cf50af24dea2dcc2c3b2e9ae9e3b.sqlite-shm +0 -0
  3. package/.wrangler/state/v3/d1/miniflare-D1DatabaseObject/6e148680931b1bfcb993e0463aced3b0a6d6cf50af24dea2dcc2c3b2e9ae9e3b.sqlite-wal +0 -0
  4. package/.wrangler/tmp/dev-0nPmAG/worker.js +5 -5
  5. package/.wrangler/tmp/dev-0nPmAG/worker.js.map +1 -1
  6. package/.wrangler/tmp/dev-1aTYmG/worker.js +5 -5
  7. package/.wrangler/tmp/dev-1aTYmG/worker.js.map +1 -1
  8. package/.wrangler/tmp/dev-1osU6W/worker.js +5 -5
  9. package/.wrangler/tmp/dev-1osU6W/worker.js.map +1 -1
  10. package/.wrangler/tmp/dev-21Njjx/worker.js +5 -5
  11. package/.wrangler/tmp/dev-21Njjx/worker.js.map +1 -1
  12. package/.wrangler/tmp/dev-26GSGQ/worker.js +6 -6
  13. package/.wrangler/tmp/dev-26GSGQ/worker.js.map +1 -1
  14. package/.wrangler/tmp/dev-31oRGo/worker.js +5 -5
  15. package/.wrangler/tmp/dev-31oRGo/worker.js.map +1 -1
  16. package/.wrangler/tmp/dev-3PUe1f/worker.js +5 -5
  17. package/.wrangler/tmp/dev-3PUe1f/worker.js.map +1 -1
  18. package/.wrangler/tmp/dev-49noGf/worker.js +6 -6
  19. package/.wrangler/tmp/dev-49noGf/worker.js.map +1 -1
  20. package/.wrangler/tmp/dev-4IHUrW/worker.js +5 -5
  21. package/.wrangler/tmp/dev-4IHUrW/worker.js.map +1 -1
  22. package/.wrangler/tmp/dev-A9zJjT/worker.js +5 -5
  23. package/.wrangler/tmp/dev-A9zJjT/worker.js.map +1 -1
  24. package/.wrangler/tmp/dev-IAjPvs/worker.js +5 -5
  25. package/.wrangler/tmp/dev-IAjPvs/worker.js.map +1 -1
  26. package/.wrangler/tmp/dev-RAb75q/worker.js +5 -5
  27. package/.wrangler/tmp/dev-RAb75q/worker.js.map +1 -1
  28. package/.wrangler/tmp/dev-SzA1fi/worker.js +5 -5
  29. package/.wrangler/tmp/dev-SzA1fi/worker.js.map +1 -1
  30. package/.wrangler/tmp/dev-Z6uo4O/worker.js +5 -5
  31. package/.wrangler/tmp/dev-Z6uo4O/worker.js.map +1 -1
  32. package/.wrangler/tmp/dev-b6RHui/worker.js +6 -6
  33. package/.wrangler/tmp/dev-b6RHui/worker.js.map +1 -1
  34. package/.wrangler/tmp/dev-eD5RAO/worker.js +6 -6
  35. package/.wrangler/tmp/dev-eD5RAO/worker.js.map +1 -1
  36. package/.wrangler/tmp/dev-h1SJ6S/worker.js +6 -6
  37. package/.wrangler/tmp/dev-h1SJ6S/worker.js.map +1 -1
  38. package/.wrangler/tmp/dev-ivThQ6/worker.js +6 -6
  39. package/.wrangler/tmp/dev-ivThQ6/worker.js.map +1 -1
  40. package/.wrangler/tmp/dev-iwU6dw/worker.js +5 -5
  41. package/.wrangler/tmp/dev-iwU6dw/worker.js.map +1 -1
  42. package/.wrangler/tmp/dev-iwvsJt/worker.js +6 -6
  43. package/.wrangler/tmp/dev-iwvsJt/worker.js.map +1 -1
  44. package/.wrangler/tmp/dev-kYVP9x/worker.js +6 -6
  45. package/.wrangler/tmp/dev-kYVP9x/worker.js.map +1 -1
  46. package/.wrangler/tmp/dev-l39YAw/worker.js +5 -5
  47. package/.wrangler/tmp/dev-l39YAw/worker.js.map +1 -1
  48. package/.wrangler/tmp/dev-vT7ODU/worker.js +6 -6
  49. package/.wrangler/tmp/dev-vT7ODU/worker.js.map +1 -1
  50. package/.wrangler/tmp/dev-w6wgcm/worker.js +5 -5
  51. package/.wrangler/tmp/dev-w6wgcm/worker.js.map +1 -1
  52. package/.wrangler/tmp/dev-yxONWu/worker.js +5 -5
  53. package/.wrangler/tmp/dev-yxONWu/worker.js.map +1 -1
  54. package/README.md +14 -2
  55. package/dist/Adapter/D1DrizzleMigrator.d.ts +9 -4
  56. package/dist/Adapter/D1DrizzleMigrator.js +15 -3
  57. package/dist/Adapter/index.d.ts +1 -0
  58. package/dist/Adapter/index.js +1 -0
  59. package/dist/Factory/D1DrizzleAdapterFactory.d.ts +2 -2
  60. package/dist/Factory/D1DrizzleAdapterFactory.js +2 -2
  61. package/dist/Factory/D1DrizzleMigratorFactory.d.ts +11 -0
  62. package/dist/Factory/D1DrizzleMigratorFactory.js +12 -0
  63. package/dist/Factory/index.d.ts +1 -0
  64. package/dist/Factory/index.js +1 -0
  65. package/dist/index.js +3 -1
  66. package/package.json +4 -3
  67. package/src/Adapter/D1DrizzleMigrator.ts +14 -5
  68. package/src/Adapter/index.ts +1 -0
  69. package/src/Factory/D1DrizzleAdapterFactory.ts +2 -2
  70. package/src/Factory/D1DrizzleMigratorFactory.ts +16 -0
  71. package/src/Factory/index.ts +1 -0
  72. package/src/index.ts +4 -1
  73. package/tests/Adapter/D1DrizzleMigrator.test.ts +18 -10
  74. package/tests/Factory/D1DrizzleAdapterFactory.test.ts +1 -1
  75. package/tests/Factory/D1DrizzleMigratorFactory.test.ts +36 -0
  76. package/tests/worker.ts +5 -5
package/README.md CHANGED
@@ -34,6 +34,18 @@ D1 offers unique advantages for Cloudflare Workers:
34
34
  pnpm install @drizzle-adapter/core @drizzle-adapter/d1
35
35
  ```
36
36
 
37
+ ## Important: Adapter Registration
38
+
39
+ For the adapter to work correctly with the DrizzleAdapterFactory, you must import it for its self-registration side effects:
40
+
41
+ ```typescript
42
+ // Import for side effects - adapter will self-register
43
+ import '@drizzle-adapter/d1';
44
+
45
+ // Now you can use the factory
46
+ import { DrizzleAdapterFactory } from '@drizzle-adapter/core';
47
+ ```
48
+
37
49
  ## Usage
38
50
 
39
51
  ### Cloudflare Workers Setup
@@ -67,7 +79,7 @@ const config: TypeDrizzleDatabaseConfig = {
67
79
  };
68
80
 
69
81
  const factory = new DrizzleAdapterFactory();
70
- const adapter = await factory.create(config);
82
+ const adapter = factory.create(config);
71
83
  ```
72
84
 
73
85
  ### Important Note About Connections
@@ -201,7 +213,7 @@ interface Env {
201
213
  export default {
202
214
  async fetch(request: Request, env: Env): Promise<Response> {
203
215
  const factory = new DrizzleAdapterFactory();
204
- const adapter = await factory.create({
216
+ const adapter = factory.create({
205
217
  DATABASE_DRIVER: 'd1',
206
218
  DATABASE: env.DB
207
219
  });
@@ -1,12 +1,17 @@
1
- import type { DrizzleMigratorInterface } from '@drizzle-adapter/core';
2
- import type { MigrationConfig } from 'drizzle-orm/migrator';
1
+ import type { DrizzleMigratorInterface, TypeDrizzleMigratorConfig } from '@drizzle-adapter/core';
3
2
  import type { D1DrizzleClientInterface } from '../Interface/index.js';
4
3
  export declare class D1DrizzleMigrator implements DrizzleMigratorInterface {
4
+ private readonly config;
5
+ /**
6
+ * Constructor.
7
+ *
8
+ * @param {TypeDrizzleMigratorConfig} config The migrator configuration.
9
+ */
10
+ constructor(config: TypeDrizzleMigratorConfig);
5
11
  /**
6
12
  * Migrate the database.
7
13
  *
8
14
  * @param {DrizzleClientInterface} client The Drizzle client.
9
- * @param {MigrationConfig} config The migration configuration.
10
15
  */
11
- migrate(client: D1DrizzleClientInterface, config: MigrationConfig): Promise<void>;
16
+ migrate(client: D1DrizzleClientInterface): Promise<void>;
12
17
  }
@@ -1,13 +1,25 @@
1
1
  import { DrizzleD1Database } from 'drizzle-orm/d1/driver';
2
2
  import { migrate } from 'drizzle-orm/d1/migrator';
3
3
  export class D1DrizzleMigrator {
4
+ config;
5
+ /**
6
+ * Constructor.
7
+ *
8
+ * @param {TypeDrizzleMigratorConfig} config The migrator configuration.
9
+ */
10
+ constructor(config) {
11
+ this.config = config;
12
+ }
4
13
  /**
5
14
  * Migrate the database.
6
15
  *
7
16
  * @param {DrizzleClientInterface} client The Drizzle client.
8
- * @param {MigrationConfig} config The migration configuration.
9
17
  */
10
- async migrate(client, config) {
11
- await migrate(client, config);
18
+ async migrate(client) {
19
+ await migrate(client, {
20
+ migrationsFolder: this.config.DATABASE_MIGRATIONS_FOLDER,
21
+ migrationsTable: this.config.DATABASE_MIGRATIONS_TABLE,
22
+ migrationsSchema: this.config.DATABASE_MIGRATIONS_SCHEMA
23
+ });
12
24
  }
13
25
  }
@@ -1,2 +1,3 @@
1
1
  export * from './D1DrizzleAdapter.js';
2
2
  export * from './D1DrizzleConnection.js';
3
+ export * from './D1DrizzleMigrator.js';
@@ -1,2 +1,3 @@
1
1
  export * from './D1DrizzleAdapter.js';
2
2
  export * from './D1DrizzleConnection.js';
3
+ export * from './D1DrizzleMigrator.js';
@@ -6,7 +6,7 @@ export declare class D1DrizzleAdapterFactory implements DrizzleAdapterFactoryInt
6
6
  * Returns a adapter.
7
7
  *
8
8
  * @param {TypeD1DatabaseConfig} databaseConfig
9
- * @returns {Promise<D1DrizzleAdapter>}
9
+ * @returns {D1DrizzleAdapter}
10
10
  */
11
- create(databaseConfig: TypeD1DatabaseConfig): Promise<D1DrizzleAdapter>;
11
+ create(databaseConfig: TypeD1DatabaseConfig): D1DrizzleAdapter;
12
12
  }
@@ -4,9 +4,9 @@ export class D1DrizzleAdapterFactory {
4
4
  * Returns a adapter.
5
5
  *
6
6
  * @param {TypeD1DatabaseConfig} databaseConfig
7
- * @returns {Promise<D1DrizzleAdapter>}
7
+ * @returns {D1DrizzleAdapter}
8
8
  */
9
- async create(databaseConfig) {
9
+ create(databaseConfig) {
10
10
  return new D1DrizzleAdapter(databaseConfig.DATABASE);
11
11
  }
12
12
  }
@@ -0,0 +1,11 @@
1
+ import type { DrizzleMigratorFactoryInterface, TypeDrizzleMigratorConfig } from '@drizzle-adapter/core';
2
+ import { D1DrizzleMigrator } from '../Adapter/index.js';
3
+ export declare class D1DrizzleMigratorFactory implements DrizzleMigratorFactoryInterface {
4
+ /**
5
+ * Returns a new migrator.
6
+ *
7
+ * @param {TypeDrizzleMigratorConfig} config
8
+ * @returns {D1DrizzleMigrator}
9
+ */
10
+ create(config: TypeDrizzleMigratorConfig): D1DrizzleMigrator;
11
+ }
@@ -0,0 +1,12 @@
1
+ import { D1DrizzleMigrator } from '../Adapter/index.js';
2
+ export class D1DrizzleMigratorFactory {
3
+ /**
4
+ * Returns a new migrator.
5
+ *
6
+ * @param {TypeDrizzleMigratorConfig} config
7
+ * @returns {D1DrizzleMigrator}
8
+ */
9
+ create(config) {
10
+ return new D1DrizzleMigrator(config);
11
+ }
12
+ }
@@ -1 +1,2 @@
1
1
  export * from './D1DrizzleAdapterFactory.js';
2
+ export * from './D1DrizzleMigratorFactory.js';
@@ -1 +1,2 @@
1
1
  export * from './D1DrizzleAdapterFactory.js';
2
+ export * from './D1DrizzleMigratorFactory.js';
package/dist/index.js CHANGED
@@ -3,5 +3,7 @@ export * from './Factory/index.js';
3
3
  export * from './Interface/index.js';
4
4
  export * from './Type/index.js';
5
5
  // default export so that core factory can use it directly
6
- import { D1DrizzleAdapterFactory } from './Factory/index.js';
6
+ import { D1DrizzleAdapterFactory, D1DrizzleMigratorFactory } from './Factory/index.js';
7
7
  export default D1DrizzleAdapterFactory;
8
+ import { DrizzleAdapterFactoryRegistry } from '@drizzle-adapter/core';
9
+ DrizzleAdapterFactoryRegistry.register('d1', D1DrizzleAdapterFactory, D1DrizzleMigratorFactory);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@drizzle-adapter/d1",
3
3
  "type": "module",
4
- "version": "1.0.1",
4
+ "version": "1.0.4",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "devDependencies": {
@@ -18,9 +18,10 @@
18
18
  "wrangler": "^3.91.0"
19
19
  },
20
20
  "dependencies": {
21
+ "@drizzle-adapter/core": ">=1.0.4",
22
+ "@drizzle-adapter/sqlite-core": ">=1.0.4",
21
23
  "@libsql/client": "^0.5.6",
22
- "drizzle-orm": "^0.36.4",
23
- "@drizzle-adapter/sqlite-core": "1.0.0"
24
+ "drizzle-orm": "^0.36.4"
24
25
  },
25
26
  "scripts": {
26
27
  "lint": "eslint src/",
@@ -1,19 +1,28 @@
1
- import type { DrizzleMigratorInterface } from '@drizzle-adapter/core';
2
- import type { MigrationConfig } from 'drizzle-orm/migrator';
1
+ import type { DrizzleMigratorInterface, TypeDrizzleMigratorConfig } from '@drizzle-adapter/core';
3
2
  import { DrizzleD1Database } from 'drizzle-orm/d1/driver';
4
3
  import { migrate } from 'drizzle-orm/d1/migrator';
5
4
  import type { D1DrizzleClientInterface } from '../Interface';
6
5
 
7
6
  export class D1DrizzleMigrator implements DrizzleMigratorInterface
8
7
  {
8
+ /**
9
+ * Constructor.
10
+ *
11
+ * @param {TypeDrizzleMigratorConfig} config The migrator configuration.
12
+ */
13
+ public constructor(private readonly config: TypeDrizzleMigratorConfig) {}
14
+
9
15
  /**
10
16
  * Migrate the database.
11
17
  *
12
18
  * @param {DrizzleClientInterface} client The Drizzle client.
13
- * @param {MigrationConfig} config The migration configuration.
14
19
  */
15
- public async migrate(client: D1DrizzleClientInterface, config: MigrationConfig): Promise<void>
20
+ public async migrate(client: D1DrizzleClientInterface): Promise<void>
16
21
  {
17
- await migrate(client as unknown as DrizzleD1Database<Record<string, unknown>>, config);
22
+ await migrate(client as unknown as DrizzleD1Database<Record<string, unknown>>, {
23
+ migrationsFolder: this.config.DATABASE_MIGRATIONS_FOLDER,
24
+ migrationsTable: this.config.DATABASE_MIGRATIONS_TABLE,
25
+ migrationsSchema: this.config.DATABASE_MIGRATIONS_SCHEMA
26
+ });
18
27
  }
19
28
  }
@@ -1,2 +1,3 @@
1
1
  export * from './D1DrizzleAdapter';
2
2
  export * from './D1DrizzleConnection';
3
+ export * from './D1DrizzleMigrator';
@@ -8,9 +8,9 @@ export class D1DrizzleAdapterFactory implements DrizzleAdapterFactoryInterface
8
8
  * Returns a adapter.
9
9
  *
10
10
  * @param {TypeD1DatabaseConfig} databaseConfig
11
- * @returns {Promise<D1DrizzleAdapter>}
11
+ * @returns {D1DrizzleAdapter}
12
12
  */
13
- public async create(databaseConfig: TypeD1DatabaseConfig): Promise<D1DrizzleAdapter>
13
+ public create(databaseConfig: TypeD1DatabaseConfig): D1DrizzleAdapter
14
14
  {
15
15
  return new D1DrizzleAdapter(databaseConfig.DATABASE);
16
16
  }
@@ -0,0 +1,16 @@
1
+ import type { DrizzleMigratorFactoryInterface, TypeDrizzleMigratorConfig } from '@drizzle-adapter/core';
2
+ import { D1DrizzleMigrator } from '../Adapter';
3
+
4
+ export class D1DrizzleMigratorFactory implements DrizzleMigratorFactoryInterface
5
+ {
6
+ /**
7
+ * Returns a new migrator.
8
+ *
9
+ * @param {TypeDrizzleMigratorConfig} config
10
+ * @returns {D1DrizzleMigrator}
11
+ */
12
+ public create(config: TypeDrizzleMigratorConfig): D1DrizzleMigrator
13
+ {
14
+ return new D1DrizzleMigrator(config);
15
+ }
16
+ }
@@ -1 +1,2 @@
1
1
  export * from './D1DrizzleAdapterFactory';
2
+ export * from './D1DrizzleMigratorFactory';
package/src/index.ts CHANGED
@@ -4,5 +4,8 @@ export * from './Interface';
4
4
  export * from './Type';
5
5
 
6
6
  // default export so that core factory can use it directly
7
- import { D1DrizzleAdapterFactory } from './Factory';
7
+ import { D1DrizzleAdapterFactory, D1DrizzleMigratorFactory } from './Factory';
8
8
  export default D1DrizzleAdapterFactory;
9
+
10
+ import { DrizzleAdapterFactoryRegistry } from '@drizzle-adapter/core';
11
+ DrizzleAdapterFactoryRegistry.register('d1', D1DrizzleAdapterFactory, D1DrizzleMigratorFactory);
@@ -1,7 +1,7 @@
1
1
  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
- import type { MigrationConfig } from 'drizzle-orm/migrator';
4
+ import type { TypeDrizzleMigratorConfig } from '@drizzle-adapter/core';
5
5
  import type { D1DrizzleClientInterface } from '../../src/Interface';
6
6
 
7
7
  // Mock the migrate function from drizzle-orm/d1/migrator
@@ -19,39 +19,47 @@ describe('D1DrizzleMigrator', () => {
19
19
  mockedClient: true
20
20
  } as unknown as D1DrizzleClientInterface;
21
21
 
22
- const mockConfig: MigrationConfig = {
23
- migrationsFolder: './drizzle'
22
+ const mockConfig: TypeDrizzleMigratorConfig = {
23
+ DATABASE_DRIVER: 'd1',
24
+ DATABASE_URL: 'file:./test.db',
25
+ DATABASE_MIGRATIONS_FOLDER: './drizzle',
26
+ DATABASE_MIGRATIONS_TABLE: 'drizzle_migrations',
27
+ DATABASE_MIGRATIONS_SCHEMA: 'public'
24
28
  };
25
29
 
26
30
  beforeEach(() => {
27
31
  vi.clearAllMocks();
28
32
  });
29
33
 
30
- it('should create an instance with a D1 client', () => {
31
- const migratorInstance = new D1DrizzleMigrator();
34
+ it('should create an instance with config', () => {
35
+ const migratorInstance = new D1DrizzleMigrator(mockConfig);
32
36
  expect(migratorInstance).toBeInstanceOf(D1DrizzleMigrator);
33
37
  });
34
38
 
35
39
  it('should call migrate with correct parameters', async () => {
36
- const migratorInstance = new D1DrizzleMigrator();
37
- await migratorInstance.migrate(mockClient, mockConfig);
40
+ const migratorInstance = new D1DrizzleMigrator(mockConfig);
41
+ await migratorInstance.migrate(mockClient);
38
42
 
39
43
  expect(migrator.migrate).toHaveBeenCalledWith(
40
44
  expect.objectContaining({ mockedClient: true }),
41
- mockConfig
45
+ {
46
+ migrationsFolder: mockConfig.DATABASE_MIGRATIONS_FOLDER,
47
+ migrationsTable: mockConfig.DATABASE_MIGRATIONS_TABLE,
48
+ migrationsSchema: mockConfig.DATABASE_MIGRATIONS_SCHEMA,
49
+ }
42
50
  );
43
51
  expect(migrator.migrate).toHaveBeenCalledTimes(1);
44
52
  });
45
53
 
46
54
  it('should handle migration errors', async () => {
47
- const migratorInstance = new D1DrizzleMigrator();
55
+ const migratorInstance = new D1DrizzleMigrator(mockConfig);
48
56
 
49
57
  // Mock migrate to throw an error
50
58
  vi.mocked(migrator.migrate).mockImplementationOnce(async () => {
51
59
  throw new Error('Migration failed');
52
60
  });
53
61
 
54
- await expect(migratorInstance.migrate(mockClient, mockConfig))
62
+ await expect(migratorInstance.migrate(mockClient))
55
63
  .rejects
56
64
  .toThrow('Migration failed');
57
65
  });
@@ -34,7 +34,7 @@ describe('D1DrizzleAdapterFactory', () => {
34
34
 
35
35
  it('should create a D1DrizzleAdapter instance', async () => {
36
36
  const factory = new D1DrizzleAdapterFactory();
37
- const adapter = await factory.create(mockDatabaseConfig);
37
+ const adapter = factory.create(mockDatabaseConfig);
38
38
 
39
39
  expect(adapter).toBeInstanceOf(D1DrizzleAdapter);
40
40
  });
@@ -0,0 +1,36 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { D1DrizzleMigratorFactory } from '../../src/Factory';
3
+ import { D1DrizzleMigrator } from '../../src/Adapter';
4
+ import type { TypeDrizzleMigratorConfig } from '@drizzle-adapter/core';
5
+
6
+ describe('D1DrizzleMigratorFactory', () => {
7
+ const mockMigratorConfig: TypeDrizzleMigratorConfig = {
8
+ DATABASE_DRIVER: 'd1',
9
+ DATABASE_URL: 'file:./test.db',
10
+ DATABASE_MIGRATIONS_FOLDER: './drizzle',
11
+ DATABASE_MIGRATIONS_TABLE: 'drizzle_migrations',
12
+ DATABASE_MIGRATIONS_SCHEMA: 'public'
13
+ };
14
+
15
+ it('should be instantiable', () => {
16
+ const factory = new D1DrizzleMigratorFactory();
17
+ expect(factory).toBeInstanceOf(D1DrizzleMigratorFactory);
18
+ });
19
+
20
+ it('should create a D1DrizzleMigrator instance', () => {
21
+ const factory = new D1DrizzleMigratorFactory();
22
+ const migrator = factory.create(mockMigratorConfig);
23
+
24
+ expect(migrator).toBeInstanceOf(D1DrizzleMigrator);
25
+ });
26
+
27
+ it('should pass the config to the migrator', () => {
28
+ const factory = new D1DrizzleMigratorFactory();
29
+ const migrator = factory.create(mockMigratorConfig);
30
+
31
+ // Verify the migrator was created with the correct config
32
+ expect(migrator).toBeInstanceOf(D1DrizzleMigrator);
33
+ // @ts-expect-error Accessing private property for testing
34
+ expect(migrator.config).toEqual(mockMigratorConfig);
35
+ });
36
+ });
package/tests/worker.ts CHANGED
@@ -21,7 +21,7 @@ export default {
21
21
  case '/test/create-record': {
22
22
  try {
23
23
  const factory = new D1DrizzleAdapterFactory();
24
- const adapter = await factory.create({
24
+ const adapter = factory.create({
25
25
  DATABASE: env.DB
26
26
  }) as D1DrizzleAdapter;
27
27
 
@@ -65,7 +65,7 @@ export default {
65
65
  case '/test/update-record': {
66
66
  try {
67
67
  const factory = new D1DrizzleAdapterFactory();
68
- const adapter = await factory.create({
68
+ const adapter = factory.create({
69
69
  DATABASE: env.DB
70
70
  }) as D1DrizzleAdapter;
71
71
 
@@ -116,7 +116,7 @@ export default {
116
116
  case '/test/select-records': {
117
117
  try {
118
118
  const factory = new D1DrizzleAdapterFactory();
119
- const adapter = await factory.create({
119
+ const adapter = factory.create({
120
120
  DATABASE: env.DB
121
121
  }) as D1DrizzleAdapter;
122
122
 
@@ -174,7 +174,7 @@ export default {
174
174
  case '/test/migrations': {
175
175
  try {
176
176
  const factory = new D1DrizzleAdapterFactory();
177
- const adapter = await factory.create({
177
+ const adapter = factory.create({
178
178
  DATABASE: env.DB
179
179
  }) as D1DrizzleAdapter;
180
180
 
@@ -277,7 +277,7 @@ export default {
277
277
  case '/test/text-type': {
278
278
  try {
279
279
  const factory = new D1DrizzleAdapterFactory();
280
- const adapter = await factory.create({
280
+ const adapter = factory.create({
281
281
  DATABASE: env.DB
282
282
  }) as D1DrizzleAdapter;
283
283