@mrnafisia/type-query 1.0.0 → 1.0.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/dist/pool.d.ts +4 -2
- package/dist/pool.d.ts.map +1 -1
- package/dist/pool.js +26 -0
- package/dist/pool.js.map +1 -1
- package/dist/types/pool.d.ts +11 -1
- package/dist/types/pool.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/pool.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { Pool } from './types/pool';
|
|
1
|
+
import type { AddHook, Pool, RemoveHook } from './types/pool';
|
|
2
|
+
declare const addHook: AddHook;
|
|
3
|
+
declare const removeHook: RemoveHook;
|
|
2
4
|
declare const createPool: (connectionString: string) => Pool;
|
|
3
|
-
export {
|
|
5
|
+
export { addHook, removeHook };
|
|
4
6
|
export default createPool;
|
|
5
7
|
//# sourceMappingURL=pool.d.ts.map
|
package/dist/pool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,OAAO,EAAmB,IAAI,EAAE,UAAU,EAAC,MAAM,cAAc,CAAC;AAU7E,QAAA,MAAM,OAAO,EAAE,OAMd,CAAC;AACF,QAAA,MAAM,UAAU,EAAE,UAMjB,CAAC;AAEF,QAAA,MAAM,UAAU,qBAAsB,MAAM,KAAG,IAyB9C,CAAC;AAEF,OAAO,EAAC,OAAO,EAAE,UAAU,EAAC,CAAC;AAC7B,eAAe,UAAU,CAAC"}
|
package/dist/pool.js
CHANGED
|
@@ -36,8 +36,34 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.removeHook = exports.addHook = void 0;
|
|
39
40
|
var pg_1 = require("pg");
|
|
40
41
|
var dictionary_1 = require("./dictionary");
|
|
42
|
+
var submit = pg_1.Query.prototype.submit;
|
|
43
|
+
pg_1.Query.prototype.submit = function () {
|
|
44
|
+
var _this = this;
|
|
45
|
+
onSendQueryHooks.forEach(function (hook) { return hook(_this.text, _this.values); });
|
|
46
|
+
submit.apply(this, arguments);
|
|
47
|
+
};
|
|
48
|
+
var onSendQueryHooks = [];
|
|
49
|
+
var addHook = function (_a) {
|
|
50
|
+
var event = _a.event, hook = _a.hook;
|
|
51
|
+
switch (event) {
|
|
52
|
+
case 'on-send-query':
|
|
53
|
+
onSendQueryHooks.push(hook);
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
exports.addHook = addHook;
|
|
58
|
+
var removeHook = function (_a) {
|
|
59
|
+
var event = _a.event, hook = _a.hook;
|
|
60
|
+
switch (event) {
|
|
61
|
+
case 'on-send-query':
|
|
62
|
+
onSendQueryHooks.splice(onSendQueryHooks.indexOf(hook), 1);
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
exports.removeHook = removeHook;
|
|
41
67
|
var createPool = function (connectionString) {
|
|
42
68
|
var pool = new pg_1.Pool({ connectionString: connectionString });
|
|
43
69
|
return {
|
package/dist/pool.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.js","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pool.js","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yBAAyC;AAEzC,2CAAyD;AAEzD,IAAM,MAAM,GAAG,UAAK,CAAC,SAAS,CAAC,MAAM,CAAC;AACtC,UAAK,C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C,EAAA;;gCAA/B,MAAM,GAAG,SAAsB;qCACjC,MAAM,CAAC,EAAE,EAAT,wBAAS;gCACT,qBAAM,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,EAAA;;gCAA9B,SAA8B,CAAC;;oCAE/B,qBAAM,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,EAAA;;gCAAhC,SAAgC,CAAC;;;gCAErC,MAAM,CAAC,OAAO,EAAE,CAAC;;;;qBACpB,CAAC;qBACD,KAAK,CAAC,UAAO,GAAG;;;;;;gCAET,qBAAM,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,EAAA;;gCAAhC,SAAgC,CAAC;;;;;;gCAGrC,MAAM,CAAC,OAAO,EAAE,CAAC;gCACjB,MAAM,GAAG,CAAC;;;qBACb,CAAC;YAjBN,CAiBM,CACT;QAnB2D,CAmB3D;KACK,CAAC;AACf,CAAC,CAAC;AAGF,kBAAe,UAAU,CAAC"}
|
package/dist/types/pool.d.ts
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import type { Result } from 'never-catch';
|
|
2
2
|
import type { Pool as PgPool, PoolClient } from 'pg';
|
|
3
|
+
import { Param } from "./entity";
|
|
3
4
|
declare type TransactionIsolationLevel = 'read-uncommitted' | 'read-committed' | 'repeatable-read' | 'serializable';
|
|
4
5
|
declare type Pool = {
|
|
5
6
|
$: PgPool;
|
|
6
7
|
transaction: (callback: (client: PoolClient) => Promise<Result<any, any>>, isolationLevel?: TransactionIsolationLevel) => Promise<void>;
|
|
7
8
|
};
|
|
8
|
-
|
|
9
|
+
declare type OnSendQueryHook = (query: string, params: Param[]) => void;
|
|
10
|
+
declare type AddHook = (hookAndEvent: {
|
|
11
|
+
event: 'on-send-query';
|
|
12
|
+
hook: OnSendQueryHook;
|
|
13
|
+
}) => void;
|
|
14
|
+
declare type RemoveHook = (hookAndEvent: {
|
|
15
|
+
event: 'on-send-query';
|
|
16
|
+
hook: OnSendQueryHook;
|
|
17
|
+
}) => void;
|
|
18
|
+
export type { TransactionIsolationLevel, Pool, OnSendQueryHook, AddHook, RemoveHook };
|
|
9
19
|
//# sourceMappingURL=pool.d.ts.map
|
package/dist/types/pool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../src/types/pool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAC,IAAI,IAAI,MAAM,EAAE,UAAU,EAAC,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../src/types/pool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAC,IAAI,IAAI,MAAM,EAAE,UAAU,EAAC,MAAM,IAAI,CAAC;AACnD,OAAO,EAAC,KAAK,EAAC,MAAM,UAAU,CAAC;AAE/B,aAAK,yBAAyB,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,cAAc,CAAC;AAE5G,aAAK,IAAI,GAAG;IACR,CAAC,EAAE,MAAM,CAAC;IACV,WAAW,EAAE,CACT,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,EAC3D,cAAc,CAAC,EAAE,yBAAyB,KACzC,OAAO,CAAC,IAAI,CAAC,CAAC;CACtB,CAAC;AAEF,aAAK,eAAe,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,IAAI,CAAC;AAChE,aAAK,OAAO,GAAG,CAAC,YAAY,EAAE;IAAE,KAAK,EAAE,eAAe,CAAC;IAAC,IAAI,EAAE,eAAe,CAAA;CAAE,KAAK,IAAI,CAAC;AACzF,aAAK,UAAU,GAAG,CAAC,YAAY,EAAE;IAAE,KAAK,EAAE,eAAe,CAAC;IAAC,IAAI,EAAE,eAAe,CAAA;CAAE,KAAK,IAAI,CAAC;AAE5F,YAAY,EACR,yBAAyB,EACzB,IAAI,EACJ,eAAe,EACf,OAAO,EACP,UAAU,EACb,CAAC"}
|