@faasjs/knex 4.7.2 → 5.0.0-beta.1

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/README.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @faasjs/knex
2
2
 
3
+ FaasJS's sql plugin, base on [Knex](https://knexjs.org/).
4
+
5
+ [![License: MIT](https://img.shields.io/npm/l/@faasjs/knex.svg)](https://github.com/faasjs/faasjs/blob/main/packages/knex/LICENSE)
6
+ [![NPM Version](https://img.shields.io/npm/v/@faasjs/knex.svg)](https://www.npmjs.com/package/@faasjs/knex)
7
+
8
+ ## Install
9
+
10
+ ```sh
11
+ npm install @faasjs/knex
12
+ ```
13
+
3
14
  ## Functions
4
15
 
5
16
  - [originKnex](functions/originKnex.md)
package/dist/index.js CHANGED
@@ -1,20 +1,18 @@
1
1
  'use strict';
2
2
 
3
3
  var crypto = require('crypto');
4
+ var module$1 = require('module');
4
5
  var deep_merge = require('@faasjs/deep_merge');
5
6
  var func = require('@faasjs/func');
6
7
  var knex = require('knex');
7
8
 
9
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
8
10
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
11
 
10
12
  var knex__default = /*#__PURE__*/_interopDefault(knex);
11
13
 
12
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
13
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
14
- }) : x)(function(x) {
15
- if (typeof require !== "undefined") return require.apply(this, arguments);
16
- throw Error('Dynamic require of "' + x + '" is not supported');
17
- });
14
+ // src/index.ts
15
+ var require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)));
18
16
  var originKnex = knex__default.default;
19
17
  var Name = "knex";
20
18
  if (!global.FaasJS_Knex) {
@@ -86,7 +84,7 @@ var Knex = class {
86
84
  default:
87
85
  if (typeof this.config.client === "string") {
88
86
  if (this.config.client.startsWith("npm:")) {
89
- const client = __require(this.config.client.replace("npm:", ""));
87
+ const client = require2(this.config.client.replace("npm:", ""));
90
88
  if (!client) throw Error(`Invalid client: ${this.config.client}`);
91
89
  if (typeof client === "function") {
92
90
  this.config.client = client;
@@ -103,17 +101,31 @@ var Knex = class {
103
101
  }
104
102
  this.adapter = knex__default.default(this.config);
105
103
  if (this.config.client === "pg") {
106
- const pg = __require("pg");
107
- for (const t of ["INT2", "INT4", "INT8"])
108
- pg.types.setTypeParser(
109
- pg.types.builtins[t],
110
- (v) => Number.parseInt(v)
111
- );
112
- for (const t of ["FLOAT4", "FLOAT8", "NUMERIC"])
113
- pg.types.setTypeParser(
114
- pg.types.builtins[t],
115
- (v) => Number.parseFloat(v)
116
- );
104
+ const pg = require2("pg");
105
+ pg.types.setTypeParser(
106
+ pg.types.builtins.INT2,
107
+ (v) => Number.parseInt(v)
108
+ );
109
+ pg.types.setTypeParser(
110
+ pg.types.builtins.INT4,
111
+ (v) => Number.parseInt(v)
112
+ );
113
+ pg.types.setTypeParser(
114
+ pg.types.builtins.INT8,
115
+ (v) => Number.parseInt(v)
116
+ );
117
+ pg.types.setTypeParser(
118
+ pg.types.builtins.FLOAT4,
119
+ (v) => Number.parseFloat(v)
120
+ );
121
+ pg.types.setTypeParser(
122
+ pg.types.builtins.FLOAT8,
123
+ (v) => Number.parseFloat(v)
124
+ );
125
+ pg.types.setTypeParser(
126
+ pg.types.builtins.NUMERIC,
127
+ (v) => Number.parseFloat(v)
128
+ );
117
129
  }
118
130
  this.query = this.adapter;
119
131
  this.query.on("query", ({ sql, __knexQueryUid, bindings }) => {
package/dist/index.mjs CHANGED
@@ -1,14 +1,11 @@
1
1
  import { randomUUID } from 'node:crypto';
2
+ import { createRequire } from 'node:module';
2
3
  import { deepMerge } from '@faasjs/deep_merge';
3
4
  import { usePlugin } from '@faasjs/func';
4
5
  import knex from 'knex';
5
6
 
6
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
7
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
8
- }) : x)(function(x) {
9
- if (typeof require !== "undefined") return require.apply(this, arguments);
10
- throw Error('Dynamic require of "' + x + '" is not supported');
11
- });
7
+ // src/index.ts
8
+ var require2 = createRequire(import.meta.url);
12
9
  var originKnex = knex;
13
10
  var Name = "knex";
14
11
  if (!global.FaasJS_Knex) {
@@ -80,7 +77,7 @@ var Knex = class {
80
77
  default:
81
78
  if (typeof this.config.client === "string") {
82
79
  if (this.config.client.startsWith("npm:")) {
83
- const client = __require(this.config.client.replace("npm:", ""));
80
+ const client = require2(this.config.client.replace("npm:", ""));
84
81
  if (!client) throw Error(`Invalid client: ${this.config.client}`);
85
82
  if (typeof client === "function") {
86
83
  this.config.client = client;
@@ -97,17 +94,31 @@ var Knex = class {
97
94
  }
98
95
  this.adapter = knex(this.config);
99
96
  if (this.config.client === "pg") {
100
- const pg = __require("pg");
101
- for (const t of ["INT2", "INT4", "INT8"])
102
- pg.types.setTypeParser(
103
- pg.types.builtins[t],
104
- (v) => Number.parseInt(v)
105
- );
106
- for (const t of ["FLOAT4", "FLOAT8", "NUMERIC"])
107
- pg.types.setTypeParser(
108
- pg.types.builtins[t],
109
- (v) => Number.parseFloat(v)
110
- );
97
+ const pg = require2("pg");
98
+ pg.types.setTypeParser(
99
+ pg.types.builtins.INT2,
100
+ (v) => Number.parseInt(v)
101
+ );
102
+ pg.types.setTypeParser(
103
+ pg.types.builtins.INT4,
104
+ (v) => Number.parseInt(v)
105
+ );
106
+ pg.types.setTypeParser(
107
+ pg.types.builtins.INT8,
108
+ (v) => Number.parseInt(v)
109
+ );
110
+ pg.types.setTypeParser(
111
+ pg.types.builtins.FLOAT4,
112
+ (v) => Number.parseFloat(v)
113
+ );
114
+ pg.types.setTypeParser(
115
+ pg.types.builtins.FLOAT8,
116
+ (v) => Number.parseFloat(v)
117
+ );
118
+ pg.types.setTypeParser(
119
+ pg.types.builtins.NUMERIC,
120
+ (v) => Number.parseFloat(v)
121
+ );
111
122
  }
112
123
  this.query = this.adapter;
113
124
  this.query.on("query", ({ sql, __knexQueryUid, bindings }) => {
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@faasjs/knex",
3
- "version": "4.7.2",
3
+ "version": "5.0.0-beta.1",
4
4
  "license": "MIT",
5
+ "type": "module",
5
6
  "main": "dist/index.js",
6
7
  "module": "dist/index.mjs",
7
8
  "types": "dist/index.d.ts",
@@ -28,29 +29,28 @@
28
29
  },
29
30
  "funding": "https://github.com/sponsors/faasjs",
30
31
  "scripts": {
31
- "build": "tsup-node src/index.ts --config ../../tsup.config.json"
32
+ "build": "tsup-node src/index.ts --config ../../tsup.config.ts"
32
33
  },
33
34
  "files": [
34
35
  "dist"
35
36
  ],
36
37
  "peerDependencies": {
37
38
  "knex": "*",
38
- "@faasjs/deep_merge": "4.7.2",
39
- "@faasjs/func": "4.7.2",
40
- "@faasjs/logger": "4.7.2"
39
+ "@faasjs/deep_merge": "5.0.0-beta.1",
40
+ "@faasjs/func": "5.0.0-beta.1",
41
+ "@faasjs/logger": "5.0.0-beta.1"
41
42
  },
42
43
  "devDependencies": {
43
44
  "knex": "*",
44
- "@faasjs/deep_merge": "4.7.2",
45
- "@faasjs/func": "4.7.2",
46
- "@faasjs/logger": "4.7.2",
45
+ "@faasjs/deep_merge": "5.0.0-beta.1",
46
+ "@faasjs/func": "5.0.0-beta.1",
47
+ "@faasjs/logger": "5.0.0-beta.1",
47
48
  "@types/mysql": "*",
48
49
  "@types/node": "*",
49
50
  "@types/pg": "*",
50
51
  "mysql": "*",
51
52
  "pg": "*",
52
53
  "better-sqlite3": "*",
53
- "tsd": "*",
54
54
  "cloudflare-d1-http-knex": "*"
55
55
  },
56
56
  "engines": {
File without changes