@prisma/adapter-d1 6.20.0-integration-next.3 → 6.20.0-integration-merge-release-workflows.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -3,37 +3,14 @@ import { SqlDriverAdapter } from '@prisma/driver-adapter-utils';
3
3
  import { SqlDriverAdapterFactory } from '@prisma/driver-adapter-utils';
4
4
  import { SqlMigrationAwareDriverAdapterFactory } from '@prisma/driver-adapter-utils';
5
5
 
6
- declare type D1HttpParams = {
6
+ declare type D1HTTPParams = {
7
7
  CLOUDFLARE_D1_TOKEN: string;
8
8
  CLOUDFLARE_ACCOUNT_ID: string;
9
9
  CLOUDFLARE_DATABASE_ID: string;
10
10
  CLOUDFLARE_SHADOW_DATABASE_ID?: string;
11
11
  };
12
12
 
13
- /**
14
- * Lists all local D1 databases found in the Wrangler state directory.
15
- *
16
- * This function scans the `.wrangler/state/v3/d1/miniflare-D1DatabaseObject` directory
17
- * for SQLite database files and returns their paths.
18
- *
19
- * @returns An array of file paths to local D1 database files
20
- *
21
- * @example
22
- * ```typescript
23
- * import { defineConfig } from '@prisma/config'
24
- * import { listLocalDatabases } from '@prisma/adapter-d1'
25
- *
26
- * export default defineConfig({
27
- * engine: 'classic',
28
- * datasource: {
29
- * url: `file:${listLocalDatabases().pop()}`,
30
- * },
31
- * })
32
- * ```
33
- */
34
- export declare function listLocalDatabases(): string[];
35
-
36
- export declare class PrismaD1<Args extends D1Database_2 | D1HttpParams = D1Database_2> implements PrismaD1Interface<Args> {
13
+ export declare class PrismaD1<Args extends D1Database_2 | D1HTTPParams = D1Database_2> implements PrismaD1Interface<Args> {
37
14
  readonly provider = "sqlite";
38
15
  readonly adapterName: string;
39
16
  connect: PrismaD1Interface<Args>['connect'];
@@ -42,17 +19,17 @@ export declare class PrismaD1<Args extends D1Database_2 | D1HttpParams = D1Datab
42
19
  }
43
20
 
44
21
  /** @deprecated Use PrismaD1 instead */
45
- export declare class PrismaD1Http implements SqlMigrationAwareDriverAdapterFactory {
22
+ export declare class PrismaD1HTTP implements SqlMigrationAwareDriverAdapterFactory {
46
23
  private params;
47
24
  readonly provider = "sqlite";
48
25
  readonly adapterName: string;
49
- constructor(params: D1HttpParams);
26
+ constructor(params: D1HTTPParams);
50
27
  connect(): Promise<SqlDriverAdapter>;
51
28
  connectToShadowDb(): Promise<SqlDriverAdapter>;
52
29
  }
53
30
 
54
31
  declare type PrismaD1Interface<Params> = SqlDriverAdapterFactory & {
55
- connectToShadowDb: Params extends D1HttpParams ? () => Promise<SqlDriverAdapter> : undefined;
32
+ connectToShadowDb: Params extends D1HTTPParams ? () => Promise<SqlDriverAdapter> : undefined;
56
33
  };
57
34
 
58
35
  export { }
package/dist/index.d.ts CHANGED
@@ -3,37 +3,14 @@ import { SqlDriverAdapter } from '@prisma/driver-adapter-utils';
3
3
  import { SqlDriverAdapterFactory } from '@prisma/driver-adapter-utils';
4
4
  import { SqlMigrationAwareDriverAdapterFactory } from '@prisma/driver-adapter-utils';
5
5
 
6
- declare type D1HttpParams = {
6
+ declare type D1HTTPParams = {
7
7
  CLOUDFLARE_D1_TOKEN: string;
8
8
  CLOUDFLARE_ACCOUNT_ID: string;
9
9
  CLOUDFLARE_DATABASE_ID: string;
10
10
  CLOUDFLARE_SHADOW_DATABASE_ID?: string;
11
11
  };
12
12
 
13
- /**
14
- * Lists all local D1 databases found in the Wrangler state directory.
15
- *
16
- * This function scans the `.wrangler/state/v3/d1/miniflare-D1DatabaseObject` directory
17
- * for SQLite database files and returns their paths.
18
- *
19
- * @returns An array of file paths to local D1 database files
20
- *
21
- * @example
22
- * ```typescript
23
- * import { defineConfig } from '@prisma/config'
24
- * import { listLocalDatabases } from '@prisma/adapter-d1'
25
- *
26
- * export default defineConfig({
27
- * engine: 'classic',
28
- * datasource: {
29
- * url: `file:${listLocalDatabases().pop()}`,
30
- * },
31
- * })
32
- * ```
33
- */
34
- export declare function listLocalDatabases(): string[];
35
-
36
- export declare class PrismaD1<Args extends D1Database_2 | D1HttpParams = D1Database_2> implements PrismaD1Interface<Args> {
13
+ export declare class PrismaD1<Args extends D1Database_2 | D1HTTPParams = D1Database_2> implements PrismaD1Interface<Args> {
37
14
  readonly provider = "sqlite";
38
15
  readonly adapterName: string;
39
16
  connect: PrismaD1Interface<Args>['connect'];
@@ -42,17 +19,17 @@ export declare class PrismaD1<Args extends D1Database_2 | D1HttpParams = D1Datab
42
19
  }
43
20
 
44
21
  /** @deprecated Use PrismaD1 instead */
45
- export declare class PrismaD1Http implements SqlMigrationAwareDriverAdapterFactory {
22
+ export declare class PrismaD1HTTP implements SqlMigrationAwareDriverAdapterFactory {
46
23
  private params;
47
24
  readonly provider = "sqlite";
48
25
  readonly adapterName: string;
49
- constructor(params: D1HttpParams);
26
+ constructor(params: D1HTTPParams);
50
27
  connect(): Promise<SqlDriverAdapter>;
51
28
  connectToShadowDb(): Promise<SqlDriverAdapter>;
52
29
  }
53
30
 
54
31
  declare type PrismaD1Interface<Params> = SqlDriverAdapterFactory & {
55
- connectToShadowDb: Params extends D1HttpParams ? () => Promise<SqlDriverAdapter> : undefined;
32
+ connectToShadowDb: Params extends D1HTTPParams ? () => Promise<SqlDriverAdapter> : undefined;
56
33
  };
57
34
 
58
35
  export { }
package/dist/index.js CHANGED
@@ -31,15 +31,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
33
  PrismaD1: () => PrismaD1,
34
- PrismaD1Http: () => PrismaD1HttpAdapterFactory,
35
- listLocalDatabases: () => listLocalDatabases
34
+ PrismaD1HTTP: () => PrismaD1HTTPAdapterFactory
36
35
  });
37
36
  module.exports = __toCommonJS(index_exports);
38
37
 
39
- // src/d1.ts
40
- var import_node_fs = __toESM(require("node:fs"));
41
- var import_node_path = __toESM(require("node:path"));
42
-
43
38
  // package.json
44
39
  var name = "@prisma/adapter-d1";
45
40
 
@@ -290,12 +285,12 @@ function isDriverError(error) {
290
285
 
291
286
  // src/d1-http.ts
292
287
  var debug = (0, import_driver_adapter_utils2.Debug)("prisma:driver-adapter:d1-http");
293
- function onUnsuccessfulD1HttpResponse({ errors }) {
288
+ function onUnsuccessfulD1HTTPResponse({ errors }) {
294
289
  debug("D1 HTTP Errors: %O", errors);
295
290
  const error = errors.at(0) ?? { message: "Unknown error", code: GENERIC_SQLITE_ERROR };
296
291
  throw new import_driver_adapter_utils2.DriverAdapterError(convertDriverError(error));
297
292
  }
298
- function onGenericD1HttpError(error) {
293
+ function onGenericD1HTTPError(error) {
299
294
  debug("HTTP Error: %O", error);
300
295
  throw new import_driver_adapter_utils2.DriverAdapterError(convertDriverError(error));
301
296
  }
@@ -314,17 +309,17 @@ async function performRawQuery(client, options) {
314
309
  result: response.result
315
310
  });
316
311
  if (!response.success) {
317
- onUnsuccessfulD1HttpResponse(response);
312
+ onUnsuccessfulD1HTTPResponse(response);
318
313
  }
319
314
  return response.result;
320
315
  } catch (e) {
321
- onGenericD1HttpError(e);
316
+ onGenericD1HTTPError(e);
322
317
  }
323
318
  }
324
- function isD1HttpParams(params) {
319
+ function isD1HTTPParams(params) {
325
320
  return typeof params === "object" && params !== null && "CLOUDFLARE_D1_TOKEN" in params && "CLOUDFLARE_ACCOUNT_ID" in params && "CLOUDFLARE_DATABASE_ID" in params;
326
321
  }
327
- var D1HttpQueryable = class {
322
+ var D1HTTPQueryable = class {
328
323
  constructor(client) {
329
324
  this.client = client;
330
325
  }
@@ -390,7 +385,7 @@ var D1HttpQueryable = class {
390
385
  }
391
386
  }
392
387
  };
393
- var D1HttpTransaction = class extends D1HttpQueryable {
388
+ var D1HTTPTransaction = class extends D1HTTPQueryable {
394
389
  constructor(client, options) {
395
390
  super(client);
396
391
  this.options = options;
@@ -402,7 +397,7 @@ var D1HttpTransaction = class extends D1HttpQueryable {
402
397
  debug(`[js::rollback]`);
403
398
  }
404
399
  };
405
- var PrismaD1HttpAdapter = class extends D1HttpQueryable {
400
+ var PrismaD1HTTPAdapter = class extends D1HTTPQueryable {
406
401
  constructor(params, release) {
407
402
  const D1_API_BASE_URL = `https://api.cloudflare.com/client/v4/accounts/${params.CLOUDFLARE_ACCOUNT_ID}/d1/database/${params.CLOUDFLARE_DATABASE_ID}`;
408
403
  const client = import_ky.default.create({
@@ -472,20 +467,20 @@ var PrismaD1HttpAdapter = class extends D1HttpQueryable {
472
467
  };
473
468
  const tag = "[js::startTransaction]";
474
469
  debug("%s options: %O", tag, options);
475
- return new D1HttpTransaction(this.client, options);
470
+ return new D1HTTPTransaction(this.client, options);
476
471
  }
477
472
  async dispose() {
478
473
  await this.release?.();
479
474
  }
480
475
  };
481
- var PrismaD1HttpAdapterFactory = class {
476
+ var PrismaD1HTTPAdapterFactory = class {
482
477
  constructor(params) {
483
478
  this.params = params;
484
479
  }
485
480
  provider = "sqlite";
486
481
  adapterName = `${name}-http`;
487
482
  async connect() {
488
- return new PrismaD1HttpAdapter(this.params, async () => {
483
+ return new PrismaD1HTTPAdapter(this.params, async () => {
489
484
  });
490
485
  }
491
486
  async connectToShadowDb() {
@@ -510,13 +505,13 @@ var PrismaD1HttpAdapterFactory = class {
510
505
  }).json();
511
506
  debug(`${tag} %O`, response);
512
507
  if (!response.success) {
513
- onUnsuccessfulD1HttpResponse(response);
508
+ onUnsuccessfulD1HTTPResponse(response);
514
509
  }
515
510
  const { uuid: CLOUDFLARE_SHADOW_DATABASE_ID2 } = response.result;
516
511
  debug(`${tag} created database %s with ID %s`, CLOUDFLARE_SHADOW_DATABASE_NAME, CLOUDFLARE_SHADOW_DATABASE_ID2);
517
512
  return CLOUDFLARE_SHADOW_DATABASE_ID2;
518
513
  } catch (e) {
519
- onGenericD1HttpError(e);
514
+ onGenericD1HTTPError(e);
520
515
  }
521
516
  };
522
517
  const CLOUDFLARE_SHADOW_DATABASE_ID = this.params.CLOUDFLARE_SHADOW_DATABASE_ID ?? await createShadowDatabase();
@@ -527,13 +522,13 @@ var PrismaD1HttpAdapterFactory = class {
527
522
  const response = await client.delete(`${D1_API_BASE_URL}/${CLOUDFLARE_SHADOW_DATABASE_ID}`).json();
528
523
  debug(`${tag} %O`, response);
529
524
  if (!response.success) {
530
- onUnsuccessfulD1HttpResponse(response);
525
+ onUnsuccessfulD1HTTPResponse(response);
531
526
  }
532
527
  } catch (e) {
533
- onGenericD1HttpError(e);
528
+ onGenericD1HTTPError(e);
534
529
  }
535
530
  };
536
- return new PrismaD1HttpAdapter(this.params, dispose);
531
+ return new PrismaD1HTTPAdapter(this.params, dispose);
537
532
  }
538
533
  };
539
534
 
@@ -702,8 +697,8 @@ var PrismaD1 = class {
702
697
  connect;
703
698
  connectToShadowDb;
704
699
  constructor(params) {
705
- if (isD1HttpParams(params)) {
706
- const factory = new PrismaD1HttpAdapterFactory(params);
700
+ if (isD1HTTPParams(params)) {
701
+ const factory = new PrismaD1HTTPAdapterFactory(params);
707
702
  const self = this;
708
703
  self.connect = factory.connect.bind(factory);
709
704
  self.connectToShadowDb = factory.connectToShadowDb.bind(factory);
@@ -714,16 +709,8 @@ var PrismaD1 = class {
714
709
  }
715
710
  }
716
711
  };
717
- var localD1DatabasePath = import_node_path.default.join(".wrangler", "state", "v3", "d1", "miniflare-D1DatabaseObject");
718
- function listLocalDatabases() {
719
- const cwd = process.cwd();
720
- const d1DirPath = import_node_path.default.join(cwd, localD1DatabasePath);
721
- const files = import_node_fs.default.readdirSync(d1DirPath);
722
- return files.filter((file) => file.endsWith(".sqlite")).map((file) => import_node_path.default.join(d1DirPath, file));
723
- }
724
712
  // Annotate the CommonJS export names for ESM import in node:
725
713
  0 && (module.exports = {
726
714
  PrismaD1,
727
- PrismaD1Http,
728
- listLocalDatabases
715
+ PrismaD1HTTP
729
716
  });
package/dist/index.mjs CHANGED
@@ -1,7 +1,3 @@
1
- // src/d1.ts
2
- import fs from "node:fs";
3
- import path from "node:path";
4
-
5
1
  // package.json
6
2
  var name = "@prisma/adapter-d1";
7
3
 
@@ -255,12 +251,12 @@ function isDriverError(error) {
255
251
 
256
252
  // src/d1-http.ts
257
253
  var debug = Debug("prisma:driver-adapter:d1-http");
258
- function onUnsuccessfulD1HttpResponse({ errors }) {
254
+ function onUnsuccessfulD1HTTPResponse({ errors }) {
259
255
  debug("D1 HTTP Errors: %O", errors);
260
256
  const error = errors.at(0) ?? { message: "Unknown error", code: GENERIC_SQLITE_ERROR };
261
257
  throw new DriverAdapterError(convertDriverError(error));
262
258
  }
263
- function onGenericD1HttpError(error) {
259
+ function onGenericD1HTTPError(error) {
264
260
  debug("HTTP Error: %O", error);
265
261
  throw new DriverAdapterError(convertDriverError(error));
266
262
  }
@@ -279,17 +275,17 @@ async function performRawQuery(client, options) {
279
275
  result: response.result
280
276
  });
281
277
  if (!response.success) {
282
- onUnsuccessfulD1HttpResponse(response);
278
+ onUnsuccessfulD1HTTPResponse(response);
283
279
  }
284
280
  return response.result;
285
281
  } catch (e) {
286
- onGenericD1HttpError(e);
282
+ onGenericD1HTTPError(e);
287
283
  }
288
284
  }
289
- function isD1HttpParams(params) {
285
+ function isD1HTTPParams(params) {
290
286
  return typeof params === "object" && params !== null && "CLOUDFLARE_D1_TOKEN" in params && "CLOUDFLARE_ACCOUNT_ID" in params && "CLOUDFLARE_DATABASE_ID" in params;
291
287
  }
292
- var D1HttpQueryable = class {
288
+ var D1HTTPQueryable = class {
293
289
  constructor(client) {
294
290
  this.client = client;
295
291
  }
@@ -355,7 +351,7 @@ var D1HttpQueryable = class {
355
351
  }
356
352
  }
357
353
  };
358
- var D1HttpTransaction = class extends D1HttpQueryable {
354
+ var D1HTTPTransaction = class extends D1HTTPQueryable {
359
355
  constructor(client, options) {
360
356
  super(client);
361
357
  this.options = options;
@@ -367,7 +363,7 @@ var D1HttpTransaction = class extends D1HttpQueryable {
367
363
  debug(`[js::rollback]`);
368
364
  }
369
365
  };
370
- var PrismaD1HttpAdapter = class extends D1HttpQueryable {
366
+ var PrismaD1HTTPAdapter = class extends D1HTTPQueryable {
371
367
  constructor(params, release) {
372
368
  const D1_API_BASE_URL = `https://api.cloudflare.com/client/v4/accounts/${params.CLOUDFLARE_ACCOUNT_ID}/d1/database/${params.CLOUDFLARE_DATABASE_ID}`;
373
369
  const client = ky.create({
@@ -437,20 +433,20 @@ var PrismaD1HttpAdapter = class extends D1HttpQueryable {
437
433
  };
438
434
  const tag = "[js::startTransaction]";
439
435
  debug("%s options: %O", tag, options);
440
- return new D1HttpTransaction(this.client, options);
436
+ return new D1HTTPTransaction(this.client, options);
441
437
  }
442
438
  async dispose() {
443
439
  await this.release?.();
444
440
  }
445
441
  };
446
- var PrismaD1HttpAdapterFactory = class {
442
+ var PrismaD1HTTPAdapterFactory = class {
447
443
  constructor(params) {
448
444
  this.params = params;
449
445
  }
450
446
  provider = "sqlite";
451
447
  adapterName = `${name}-http`;
452
448
  async connect() {
453
- return new PrismaD1HttpAdapter(this.params, async () => {
449
+ return new PrismaD1HTTPAdapter(this.params, async () => {
454
450
  });
455
451
  }
456
452
  async connectToShadowDb() {
@@ -475,13 +471,13 @@ var PrismaD1HttpAdapterFactory = class {
475
471
  }).json();
476
472
  debug(`${tag} %O`, response);
477
473
  if (!response.success) {
478
- onUnsuccessfulD1HttpResponse(response);
474
+ onUnsuccessfulD1HTTPResponse(response);
479
475
  }
480
476
  const { uuid: CLOUDFLARE_SHADOW_DATABASE_ID2 } = response.result;
481
477
  debug(`${tag} created database %s with ID %s`, CLOUDFLARE_SHADOW_DATABASE_NAME, CLOUDFLARE_SHADOW_DATABASE_ID2);
482
478
  return CLOUDFLARE_SHADOW_DATABASE_ID2;
483
479
  } catch (e) {
484
- onGenericD1HttpError(e);
480
+ onGenericD1HTTPError(e);
485
481
  }
486
482
  };
487
483
  const CLOUDFLARE_SHADOW_DATABASE_ID = this.params.CLOUDFLARE_SHADOW_DATABASE_ID ?? await createShadowDatabase();
@@ -492,13 +488,13 @@ var PrismaD1HttpAdapterFactory = class {
492
488
  const response = await client.delete(`${D1_API_BASE_URL}/${CLOUDFLARE_SHADOW_DATABASE_ID}`).json();
493
489
  debug(`${tag} %O`, response);
494
490
  if (!response.success) {
495
- onUnsuccessfulD1HttpResponse(response);
491
+ onUnsuccessfulD1HTTPResponse(response);
496
492
  }
497
493
  } catch (e) {
498
- onGenericD1HttpError(e);
494
+ onGenericD1HTTPError(e);
499
495
  }
500
496
  };
501
- return new PrismaD1HttpAdapter(this.params, dispose);
497
+ return new PrismaD1HTTPAdapter(this.params, dispose);
502
498
  }
503
499
  };
504
500
 
@@ -670,8 +666,8 @@ var PrismaD1 = class {
670
666
  connect;
671
667
  connectToShadowDb;
672
668
  constructor(params) {
673
- if (isD1HttpParams(params)) {
674
- const factory = new PrismaD1HttpAdapterFactory(params);
669
+ if (isD1HTTPParams(params)) {
670
+ const factory = new PrismaD1HTTPAdapterFactory(params);
675
671
  const self = this;
676
672
  self.connect = factory.connect.bind(factory);
677
673
  self.connectToShadowDb = factory.connectToShadowDb.bind(factory);
@@ -682,15 +678,7 @@ var PrismaD1 = class {
682
678
  }
683
679
  }
684
680
  };
685
- var localD1DatabasePath = path.join(".wrangler", "state", "v3", "d1", "miniflare-D1DatabaseObject");
686
- function listLocalDatabases() {
687
- const cwd = process.cwd();
688
- const d1DirPath = path.join(cwd, localD1DatabasePath);
689
- const files = fs.readdirSync(d1DirPath);
690
- return files.filter((file) => file.endsWith(".sqlite")).map((file) => path.join(d1DirPath, file));
691
- }
692
681
  export {
693
682
  PrismaD1,
694
- PrismaD1HttpAdapterFactory as PrismaD1Http,
695
- listLocalDatabases
683
+ PrismaD1HTTPAdapterFactory as PrismaD1HTTP
696
684
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/adapter-d1",
3
- "version": "6.20.0-integration-next.3",
3
+ "version": "6.20.0-integration-merge-release-workflows.2",
4
4
  "description": "Prisma's driver adapter for Cloudflare D1",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -35,9 +35,9 @@
35
35
  "license": "Apache-2.0",
36
36
  "sideEffects": false,
37
37
  "dependencies": {
38
- "@cloudflare/workers-types": "^4.20251014.0",
38
+ "@cloudflare/workers-types": "^4.20250408.0",
39
39
  "ky": "1.7.5",
40
- "@prisma/driver-adapter-utils": "6.20.0-integration-next.3"
40
+ "@prisma/driver-adapter-utils": "6.20.0-integration-merge-release-workflows.2"
41
41
  },
42
42
  "scripts": {
43
43
  "dev": "DEV=true tsx helpers/build.ts",