@faasjs/knex 0.0.3-beta.86 → 0.0.3-beta.88

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.
@@ -0,0 +1,40 @@
1
+ import { Plugin, DeployData, Next, MountData, InvokeData, UseifyPlugin } from '@faasjs/func';
2
+ import { Knex as Knex$1 } from 'knex';
3
+ export { Knex as K } from 'knex';
4
+
5
+ type KnexConfig = {
6
+ name?: string;
7
+ config?: Knex$1.Config;
8
+ };
9
+
10
+ declare class Knex implements Plugin {
11
+ readonly type: string;
12
+ readonly name: string;
13
+ config: Knex$1.Config;
14
+ adapter: Knex$1;
15
+ query: Knex$1;
16
+ private logger;
17
+ constructor(config?: KnexConfig);
18
+ onDeploy(data: DeployData, next: Next): Promise<void>;
19
+ onMount(data: MountData, next: Next): Promise<void>;
20
+ onInvoke(data: InvokeData<any, any, any>, next: Next): Promise<void>;
21
+ raw<TResult = any>(sql: string, bindings?: Knex$1.RawBinding[] | Knex$1.ValueDict): Promise<Knex$1.Raw<TResult>>;
22
+ transaction<TResult = any>(scope: (trx: Knex$1.Transaction<any, any>) => Promise<TResult> | void, config?: any): Promise<TResult>;
23
+ schema(): Knex$1.SchemaBuilder;
24
+ quit(): Promise<void>;
25
+ }
26
+ declare function useKnex(config?: KnexConfig): UseifyPlugin<Knex>;
27
+ declare function query<TName extends Knex$1.TableNames>(table: TName): Knex$1.QueryBuilder<Knex$1.TableType<TName>, {
28
+ _base: Knex$1.ResolveTableType<Knex$1.TableType<TName>, 'base'>;
29
+ _hasSelection: false;
30
+ _keys: never;
31
+ _aliases: {};
32
+ _single: false;
33
+ _intersectProps: {};
34
+ _unionProps: never;
35
+ }[]>;
36
+ declare function query<TName extends {} = any, TResult = any[]>(table: string): Knex$1.QueryBuilder<TName, TResult>;
37
+ declare function transaction<TResult = any>(scope: (trx: Knex$1.Transaction<any, any>) => Promise<TResult> | void, config?: any): Promise<TResult>;
38
+ declare function raw<TResult = any>(sql: string, bindings?: Knex$1.RawBinding[] | Knex$1.ValueDict): Promise<TResult>;
39
+
40
+ export { Knex, KnexConfig, query, raw, transaction, useKnex };
package/dist/index.js CHANGED
@@ -1,42 +1,21 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ 'use strict';
2
+
3
+ var func = require('@faasjs/func');
4
+ var logger = require('@faasjs/logger');
5
+ var deep_merge = require('@faasjs/deep_merge');
6
+ var knex = require('knex');
25
7
 
26
- // src/index.ts
27
- var src_exports = {};
28
- __export(src_exports, {
29
- Knex: () => Knex,
30
- query: () => query,
31
- raw: () => raw,
32
- transaction: () => transaction,
33
- useKnex: () => useKnex
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
+
10
+ var knex__default = /*#__PURE__*/_interopDefault(knex);
11
+
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")
16
+ return require.apply(this, arguments);
17
+ throw Error('Dynamic require of "' + x + '" is not supported');
34
18
  });
35
- module.exports = __toCommonJS(src_exports);
36
- var import_func = require("@faasjs/func");
37
- var import_logger = require("@faasjs/logger");
38
- var import_deep_merge = require("@faasjs/deep_merge");
39
- var import_knex = __toESM(require("knex"));
40
19
  var Name = "knex";
41
20
  if (!global["FaasJS_Knex"]) {
42
21
  global.FaasJS_Knex = {};
@@ -62,7 +41,7 @@ var Knex = class {
62
41
  data.dependencies["better-sqlite3"] = "*";
63
42
  else
64
43
  data.dependencies[client] = "*";
65
- new import_logger.Logger(this.name).debug("add dependencies: " + client);
44
+ new logger.Logger(this.name).debug("add dependencies: " + client);
66
45
  await next();
67
46
  }
68
47
  async onMount(data, next) {
@@ -90,7 +69,7 @@ var Knex = class {
90
69
  this.config[key] = value;
91
70
  }
92
71
  if (data.config.plugins && ((_a = data.config.plugins[this.name]) == null ? void 0 : _a.config))
93
- this.config = (0, import_deep_merge.deepMerge)(data.config.plugins[this.name].config, this.config);
72
+ this.config = deep_merge.deepMerge(data.config.plugins[this.name].config, this.config);
94
73
  if (this.config.client === "sqlite3")
95
74
  this.config.client = "better-sqlite3";
96
75
  if (this.config.client === "pg" && typeof ((_b = this.config.pool) == null ? void 0 : _b.propagateCreateError) === "undefined") {
@@ -106,9 +85,9 @@ var Knex = class {
106
85
  if (typeof this.config.connection === "string" && !this.config.connection.includes("json=true"))
107
86
  this.config.connection = this.config.connection + "?json=true";
108
87
  }
109
- this.adapter = (0, import_knex.default)(this.config);
88
+ this.adapter = knex__default.default(this.config);
110
89
  if (this.config.client === "pg") {
111
- const pg = require("pg");
90
+ const pg = __require("pg");
112
91
  const intTypes = [
113
92
  "INT2",
114
93
  "INT4",
@@ -184,8 +163,8 @@ var Knex = class {
184
163
  function useKnex(config) {
185
164
  const name = (config == null ? void 0 : config.name) || Name;
186
165
  if (global.FaasJS_Knex[name])
187
- return (0, import_func.usePlugin)(global.FaasJS_Knex[name]);
188
- return (0, import_func.usePlugin)(new Knex(config));
166
+ return func.usePlugin(global.FaasJS_Knex[name]);
167
+ return func.usePlugin(new Knex(config));
189
168
  }
190
169
  function query(table) {
191
170
  return useKnex().query(table);
@@ -196,11 +175,9 @@ async function transaction(scope, config) {
196
175
  async function raw(sql, bindings = []) {
197
176
  return useKnex().raw(sql, bindings);
198
177
  }
199
- // Annotate the CommonJS export names for ESM import in node:
200
- 0 && (module.exports = {
201
- Knex,
202
- query,
203
- raw,
204
- transaction,
205
- useKnex
206
- });
178
+
179
+ exports.Knex = Knex;
180
+ exports.query = query;
181
+ exports.raw = raw;
182
+ exports.transaction = transaction;
183
+ exports.useKnex = useKnex;
package/dist/index.mjs CHANGED
@@ -1,18 +1,15 @@
1
+ import { usePlugin } from '@faasjs/func';
2
+ import { Logger } from '@faasjs/logger';
3
+ import { deepMerge } from '@faasjs/deep_merge';
4
+ import knex from 'knex';
5
+
1
6
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
7
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
8
  }) : x)(function(x) {
4
9
  if (typeof require !== "undefined")
5
10
  return require.apply(this, arguments);
6
- throw new Error('Dynamic require of "' + x + '" is not supported');
11
+ throw Error('Dynamic require of "' + x + '" is not supported');
7
12
  });
8
-
9
- // src/index.ts
10
- import {
11
- usePlugin
12
- } from "@faasjs/func";
13
- import { Logger } from "@faasjs/logger";
14
- import { deepMerge } from "@faasjs/deep_merge";
15
- import knex from "knex";
16
13
  var Name = "knex";
17
14
  if (!global["FaasJS_Knex"]) {
18
15
  global.FaasJS_Knex = {};
@@ -172,10 +169,5 @@ async function transaction(scope, config) {
172
169
  async function raw(sql, bindings = []) {
173
170
  return useKnex().raw(sql, bindings);
174
171
  }
175
- export {
176
- Knex,
177
- query,
178
- raw,
179
- transaction,
180
- useKnex
181
- };
172
+
173
+ export { Knex, query, raw, transaction, useKnex };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/knex",
3
- "version": "0.0.3-beta.86",
3
+ "version": "0.0.3-beta.88",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,15 +15,15 @@
15
15
  },
16
16
  "funding": "https://github.com/sponsors/faasjs",
17
17
  "scripts": {
18
- "build": "tsup-node src/index.ts --format esm,cjs --dts --clean"
18
+ "build": "tsup-node src/index.ts --config ../../tsup.config.json"
19
19
  },
20
20
  "files": [
21
21
  "dist"
22
22
  ],
23
23
  "dependencies": {
24
- "@faasjs/deep_merge": "^0.0.3-beta.86",
25
- "@faasjs/func": "^0.0.3-beta.86",
26
- "@faasjs/logger": "^0.0.3-beta.86",
24
+ "@faasjs/deep_merge": "^0.0.3-beta.88",
25
+ "@faasjs/func": "^0.0.3-beta.88",
26
+ "@faasjs/logger": "^0.0.3-beta.88",
27
27
  "knex": "*"
28
28
  },
29
29
  "devDependencies": {