drizzle-kit 0.21.3 → 0.21.4-b5744a6

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 (6) hide show
  1. package/bin.cjs +326 -297
  2. package/package.json +1 -1
  3. package/payload.js +354 -353
  4. package/payload.mjs +354 -353
  5. package/utils.js +29 -0
  6. package/utils.mjs +28 -0
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 = "6";
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;
@@ -5356,6 +5360,7 @@ var backwardCompatibleSqliteSchema = unionType([sqliteSchemaV5, schema2]);
5356
5360
 
5357
5361
  // src/utils.ts
5358
5362
  var import_path = require("path");
5363
+ var import_url = require("url");
5359
5364
  var copy = (it) => {
5360
5365
  return JSON.parse(JSON.stringify(it));
5361
5366
  };
@@ -5524,6 +5529,29 @@ var kloudMeta = () => {
5524
5529
  sqlite: []
5525
5530
  };
5526
5531
  };
5532
+ var normaliseSQLiteUrl = (it, type) => {
5533
+ if (type === "libsql") {
5534
+ if (it.startsWith("file:")) {
5535
+ return it;
5536
+ }
5537
+ try {
5538
+ const url = (0, import_url.parse)(it);
5539
+ if (url.protocol === null) {
5540
+ return `file:${it}`;
5541
+ }
5542
+ return it;
5543
+ } catch (e) {
5544
+ return `file:${it}`;
5545
+ }
5546
+ }
5547
+ if (type === "better-sqlite") {
5548
+ if (it.startsWith("file:")) {
5549
+ return it.substring(5);
5550
+ }
5551
+ return it;
5552
+ }
5553
+ assertUnreachable(type);
5554
+ };
5527
5555
  // Annotate the CommonJS export names for ESM import in node:
5528
5556
  0 && (module.exports = {
5529
5557
  assertV1OutFolder,
@@ -5531,6 +5559,7 @@ var kloudMeta = () => {
5531
5559
  copy,
5532
5560
  dryJournal,
5533
5561
  kloudMeta,
5562
+ normaliseSQLiteUrl,
5534
5563
  objectValues,
5535
5564
  prepareMigrationFolder,
5536
5565
  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 = "6";
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;
@@ -5347,6 +5350,7 @@ var backwardCompatibleSqliteSchema = unionType([sqliteSchemaV5, schema2]);
5347
5350
 
5348
5351
  // src/utils.ts
5349
5352
  import { join } from "path";
5353
+ import { parse } from "url";
5350
5354
  var copy = (it) => {
5351
5355
  return JSON.parse(JSON.stringify(it));
5352
5356
  };
@@ -5515,12 +5519,36 @@ var kloudMeta = () => {
5515
5519
  sqlite: []
5516
5520
  };
5517
5521
  };
5522
+ var normaliseSQLiteUrl = (it, type) => {
5523
+ if (type === "libsql") {
5524
+ if (it.startsWith("file:")) {
5525
+ return it;
5526
+ }
5527
+ try {
5528
+ const url = parse(it);
5529
+ if (url.protocol === null) {
5530
+ return `file:${it}`;
5531
+ }
5532
+ return it;
5533
+ } catch (e) {
5534
+ return `file:${it}`;
5535
+ }
5536
+ }
5537
+ if (type === "better-sqlite") {
5538
+ if (it.startsWith("file:")) {
5539
+ return it.substring(5);
5540
+ }
5541
+ return it;
5542
+ }
5543
+ assertUnreachable(type);
5544
+ };
5518
5545
  export {
5519
5546
  assertV1OutFolder,
5520
5547
  columnRenameKey,
5521
5548
  copy,
5522
5549
  dryJournal,
5523
5550
  kloudMeta,
5551
+ normaliseSQLiteUrl,
5524
5552
  objectValues,
5525
5553
  prepareMigrationFolder,
5526
5554
  prepareMigrationMeta,