@faasjs/knex 3.0.0 → 3.1.0

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.js CHANGED
@@ -64,25 +64,46 @@ var Knex = class {
64
64
  data.config.plugins[this.name].config,
65
65
  this.config
66
66
  );
67
- if (this.config.client === "sqlite3") {
68
- this.config.client = "better-sqlite3";
69
- this.config.useNullAsDefault = true;
70
- }
71
- if (this.config.client === "pg") {
72
- if (!this.config.pool) this.config.pool = /* @__PURE__ */ Object.create(null);
73
- this.config.pool = Object.assign(
74
- {
75
- propagateCreateError: false,
76
- min: 0,
77
- max: 10,
78
- acquireTimeoutMillis: 5e3,
79
- idleTimeoutMillis: 3e4
80
- },
81
- this.config.pool
82
- );
83
- if (typeof this.config.connection === "string" && !this.config.connection.includes("json=true"))
84
- this.config.connection = `${this.config.connection}?json=true`;
67
+ switch (this.config.client) {
68
+ case "sqlite3":
69
+ this.config.client = "better-sqlite3";
70
+ this.config.useNullAsDefault = true;
71
+ break;
72
+ case "pg":
73
+ if (!this.config.pool) this.config.pool = /* @__PURE__ */ Object.create(null);
74
+ this.config.pool = Object.assign(
75
+ {
76
+ propagateCreateError: false,
77
+ min: 0,
78
+ max: 10,
79
+ acquireTimeoutMillis: 5e3,
80
+ idleTimeoutMillis: 3e4
81
+ },
82
+ this.config.pool
83
+ );
84
+ if (typeof this.config.connection === "string" && !this.config.connection.includes("json=true"))
85
+ this.config.connection = `${this.config.connection}?json=true`;
86
+ break;
87
+ default:
88
+ if (typeof this.config.client === "string") {
89
+ if (this.config.client.startsWith("npm:")) {
90
+ const client = __require(this.config.client.replace("npm:", ""));
91
+ if (!client) throw Error(`Invalid client: ${this.config.client}`);
92
+ if (typeof client === "function") {
93
+ this.config.client = client;
94
+ break;
95
+ }
96
+ if (client.default && typeof client.default === "function") {
97
+ this.config.client = client.default;
98
+ break;
99
+ }
100
+ console.log(client);
101
+ throw Error(`Invalid client: ${this.config.client}`);
102
+ }
103
+ }
104
+ break;
85
105
  }
106
+ console.log(this.config);
86
107
  this.adapter = knex__default.default(this.config);
87
108
  if (this.config.client === "pg") {
88
109
  const pg = __require("pg");
package/dist/index.mjs CHANGED
@@ -58,25 +58,46 @@ var Knex = class {
58
58
  data.config.plugins[this.name].config,
59
59
  this.config
60
60
  );
61
- if (this.config.client === "sqlite3") {
62
- this.config.client = "better-sqlite3";
63
- this.config.useNullAsDefault = true;
64
- }
65
- if (this.config.client === "pg") {
66
- if (!this.config.pool) this.config.pool = /* @__PURE__ */ Object.create(null);
67
- this.config.pool = Object.assign(
68
- {
69
- propagateCreateError: false,
70
- min: 0,
71
- max: 10,
72
- acquireTimeoutMillis: 5e3,
73
- idleTimeoutMillis: 3e4
74
- },
75
- this.config.pool
76
- );
77
- if (typeof this.config.connection === "string" && !this.config.connection.includes("json=true"))
78
- this.config.connection = `${this.config.connection}?json=true`;
61
+ switch (this.config.client) {
62
+ case "sqlite3":
63
+ this.config.client = "better-sqlite3";
64
+ this.config.useNullAsDefault = true;
65
+ break;
66
+ case "pg":
67
+ if (!this.config.pool) this.config.pool = /* @__PURE__ */ Object.create(null);
68
+ this.config.pool = Object.assign(
69
+ {
70
+ propagateCreateError: false,
71
+ min: 0,
72
+ max: 10,
73
+ acquireTimeoutMillis: 5e3,
74
+ idleTimeoutMillis: 3e4
75
+ },
76
+ this.config.pool
77
+ );
78
+ if (typeof this.config.connection === "string" && !this.config.connection.includes("json=true"))
79
+ this.config.connection = `${this.config.connection}?json=true`;
80
+ break;
81
+ default:
82
+ if (typeof this.config.client === "string") {
83
+ if (this.config.client.startsWith("npm:")) {
84
+ const client = __require(this.config.client.replace("npm:", ""));
85
+ if (!client) throw Error(`Invalid client: ${this.config.client}`);
86
+ if (typeof client === "function") {
87
+ this.config.client = client;
88
+ break;
89
+ }
90
+ if (client.default && typeof client.default === "function") {
91
+ this.config.client = client.default;
92
+ break;
93
+ }
94
+ console.log(client);
95
+ throw Error(`Invalid client: ${this.config.client}`);
96
+ }
97
+ }
98
+ break;
79
99
  }
100
+ console.log(this.config);
80
101
  this.adapter = knex(this.config);
81
102
  if (this.config.client === "pg") {
82
103
  const pg = __require("pg");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/knex",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -34,9 +34,9 @@
34
34
  "dist"
35
35
  ],
36
36
  "dependencies": {
37
- "@faasjs/deep_merge": "3.0.0",
38
- "@faasjs/func": "3.0.0",
39
- "@faasjs/logger": "3.0.0"
37
+ "@faasjs/deep_merge": "3.1.0",
38
+ "@faasjs/func": "3.1.0",
39
+ "@faasjs/logger": "3.1.0"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "knex": "*"
@@ -49,7 +49,8 @@
49
49
  "mysql": "*",
50
50
  "pg": "*",
51
51
  "better-sqlite3": "*",
52
- "tsd": "*"
52
+ "tsd": "*",
53
+ "cloudflare-d1-http-knex": "*"
53
54
  },
54
55
  "engines": {
55
56
  "node": ">=22.0.0",