drizzle-kit 0.22.0-3b0ba5f → 0.22.0-407e2e6

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/utils.js CHANGED
@@ -569,6 +569,7 @@ __export(utils_exports, {
569
569
  copy: () => copy,
570
570
  dryJournal: () => dryJournal,
571
571
  kloudMeta: () => kloudMeta,
572
+ normaliseSQLiteUrl: () => normaliseSQLiteUrl,
572
573
  objectValues: () => objectValues,
573
574
  prepareMigrationFolder: () => prepareMigrationFolder,
574
575
  prepareMigrationMeta: () => prepareMigrationMeta,
@@ -1078,6 +1079,9 @@ var info = (msg, greyMsg = "") => {
1078
1079
  // src/global.ts
1079
1080
  var originUUID = "00000000-0000-0000-0000-000000000000";
1080
1081
  var snapshotVersion = "7";
1082
+ function assertUnreachable(x) {
1083
+ throw new Error("Didn't expect to get here");
1084
+ }
1081
1085
 
1082
1086
  // node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.mjs
1083
1087
  var util;
@@ -5437,6 +5441,7 @@ var backwardCompatibleSqliteSchema = unionType([sqliteSchemaV5, schema2]);
5437
5441
 
5438
5442
  // src/utils.ts
5439
5443
  var import_path = require("path");
5444
+ var import_url = require("url");
5440
5445
  var copy = (it) => {
5441
5446
  return JSON.parse(JSON.stringify(it));
5442
5447
  };
@@ -5503,7 +5508,6 @@ var validateWithReport = (snapshots, dialect3) => {
5503
5508
  }
5504
5509
  const result2 = validator.safeParse(raw);
5505
5510
  if (!result2.success) {
5506
- console.error(result2.error);
5507
5511
  accum.malformed.push(it);
5508
5512
  return accum;
5509
5513
  }
@@ -5606,6 +5610,29 @@ var kloudMeta = () => {
5606
5610
  sqlite: []
5607
5611
  };
5608
5612
  };
5613
+ var normaliseSQLiteUrl = (it, type) => {
5614
+ if (type === "libsql") {
5615
+ if (it.startsWith("file:")) {
5616
+ return it;
5617
+ }
5618
+ try {
5619
+ const url = (0, import_url.parse)(it);
5620
+ if (url.protocol === null) {
5621
+ return `file:${it}`;
5622
+ }
5623
+ return it;
5624
+ } catch (e) {
5625
+ return `file:${it}`;
5626
+ }
5627
+ }
5628
+ if (type === "better-sqlite") {
5629
+ if (it.startsWith("file:")) {
5630
+ return it.substring(5);
5631
+ }
5632
+ return it;
5633
+ }
5634
+ assertUnreachable(type);
5635
+ };
5609
5636
  // Annotate the CommonJS export names for ESM import in node:
5610
5637
  0 && (module.exports = {
5611
5638
  assertV1OutFolder,
@@ -5613,6 +5640,7 @@ var kloudMeta = () => {
5613
5640
  copy,
5614
5641
  dryJournal,
5615
5642
  kloudMeta,
5643
+ normaliseSQLiteUrl,
5616
5644
  objectValues,
5617
5645
  prepareMigrationFolder,
5618
5646
  prepareMigrationMeta,
package/utils.mjs CHANGED
@@ -1069,6 +1069,9 @@ var info = (msg, greyMsg = "") => {
1069
1069
  // src/global.ts
1070
1070
  var originUUID = "00000000-0000-0000-0000-000000000000";
1071
1071
  var snapshotVersion = "7";
1072
+ function assertUnreachable(x) {
1073
+ throw new Error("Didn't expect to get here");
1074
+ }
1072
1075
 
1073
1076
  // node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.mjs
1074
1077
  var util;
@@ -5428,6 +5431,7 @@ var backwardCompatibleSqliteSchema = unionType([sqliteSchemaV5, schema2]);
5428
5431
 
5429
5432
  // src/utils.ts
5430
5433
  import { join } from "path";
5434
+ import { parse } from "url";
5431
5435
  var copy = (it) => {
5432
5436
  return JSON.parse(JSON.stringify(it));
5433
5437
  };
@@ -5494,7 +5498,6 @@ var validateWithReport = (snapshots, dialect3) => {
5494
5498
  }
5495
5499
  const result2 = validator.safeParse(raw);
5496
5500
  if (!result2.success) {
5497
- console.error(result2.error);
5498
5501
  accum.malformed.push(it);
5499
5502
  return accum;
5500
5503
  }
@@ -5597,12 +5600,36 @@ var kloudMeta = () => {
5597
5600
  sqlite: []
5598
5601
  };
5599
5602
  };
5603
+ var normaliseSQLiteUrl = (it, type) => {
5604
+ if (type === "libsql") {
5605
+ if (it.startsWith("file:")) {
5606
+ return it;
5607
+ }
5608
+ try {
5609
+ const url = parse(it);
5610
+ if (url.protocol === null) {
5611
+ return `file:${it}`;
5612
+ }
5613
+ return it;
5614
+ } catch (e) {
5615
+ return `file:${it}`;
5616
+ }
5617
+ }
5618
+ if (type === "better-sqlite") {
5619
+ if (it.startsWith("file:")) {
5620
+ return it.substring(5);
5621
+ }
5622
+ return it;
5623
+ }
5624
+ assertUnreachable(type);
5625
+ };
5600
5626
  export {
5601
5627
  assertV1OutFolder,
5602
5628
  columnRenameKey,
5603
5629
  copy,
5604
5630
  dryJournal,
5605
5631
  kloudMeta,
5632
+ normaliseSQLiteUrl,
5606
5633
  objectValues,
5607
5634
  prepareMigrationFolder,
5608
5635
  prepareMigrationMeta,