@nestjs-kitchen/connextion-postgres 2.0.3 → 2.0.4
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/constants.d.ts +7 -9
- package/dist/constants.js +12 -45
- package/dist/define-postgres.d.ts +6 -14
- package/dist/define-postgres.js +40 -59
- package/dist/errors.d.ts +1 -4
- package/dist/errors.js +15 -34
- package/dist/index.d.ts +3 -9
- package/dist/index.js +8 -31
- package/dist/polyfill.d.ts +1 -2
- package/dist/polyfill.js +4 -2
- package/dist/postgres.instance.d.ts +4 -7
- package/dist/postgres.instance.js +191 -199
- package/dist/transaction.d.ts +3 -4
- package/dist/transaction.js +104 -120
- package/dist/types.d.ts +4 -7
- package/dist/types.js +2 -15
- package/dist/utils.d.ts +16 -19
- package/dist/utils.js +199 -235
- package/package.json +6 -5
package/dist/types.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
interface ALSType {
|
|
1
|
+
import type { PoolClient, PoolConfig } from 'pg';
|
|
2
|
+
export type ALSQueryType = Error | true;
|
|
3
|
+
export interface ALSType {
|
|
5
4
|
client: Promise<PoolClient>;
|
|
6
5
|
queries: Promise<ALSQueryType>[];
|
|
7
6
|
}
|
|
8
|
-
type PostgresInstanceOptions = PoolConfig & {
|
|
7
|
+
export type PostgresInstanceOptions = PoolConfig & {
|
|
9
8
|
debug?: boolean | ((data: Record<any, any>) => void);
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
export type { ALSQueryType, ALSType, PostgresInstanceOptions };
|
package/dist/types.js
CHANGED
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
-
}
|
|
11
|
-
return to;
|
|
12
|
-
};
|
|
13
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
-
var types_exports = {};
|
|
15
|
-
module.exports = __toCommonJS(types_exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
declare const
|
|
4
|
-
declare const
|
|
5
|
-
declare const
|
|
6
|
-
declare const
|
|
7
|
-
declare const
|
|
8
|
-
declare const
|
|
9
|
-
declare const
|
|
10
|
-
declare const
|
|
11
|
-
declare const
|
|
12
|
-
declare const
|
|
13
|
-
declare const debugFactroy: (name: string, queryId: string, logger: (data: Record<any, any>) => void) => {
|
|
1
|
+
import { type PoolClient, type Submittable } from 'pg';
|
|
2
|
+
export declare const isSubmittable: (val: any) => val is Submittable;
|
|
3
|
+
export declare const isObject: (val: any) => val is object;
|
|
4
|
+
export declare const normalizeStrings: (strs?: string[]) => string[];
|
|
5
|
+
export declare const plainPromise: <T>(promise: Promise<T> | T) => Promise<[T, undefined] | [undefined, any]>;
|
|
6
|
+
export declare const truncateString: (str: string, maxLength: number) => string;
|
|
7
|
+
export declare const printTable: (logData: Record<string, any>) => string;
|
|
8
|
+
export declare const getCurrentDateStr: () => string;
|
|
9
|
+
export declare const formatArray: (arr?: any) => string;
|
|
10
|
+
export declare const extraceQueryTextAndValues: (...rest: any[]) => [text: string, values: any[]];
|
|
11
|
+
export declare const createDebugLogger: (defaultLogger: (...rest: any) => void, customFormater?: Boolean | ((data: Record<any, any>) => void)) => (data: Record<any, any>) => void;
|
|
12
|
+
export declare const debugFactroy: (name: string, queryId: string, logger: (data: Record<any, any>) => void) => {
|
|
14
13
|
pool: {
|
|
15
14
|
connect: <T extends () => Promise<PoolClient>>(callback: T) => () => Promise<PoolClient>;
|
|
16
15
|
};
|
|
@@ -19,13 +18,11 @@ declare const debugFactroy: (name: string, queryId: string, logger: (data: Recor
|
|
|
19
18
|
release: <T extends (...rest: unknown[]) => void>(callback: T) => (...rest: Parameters<T>) => void;
|
|
20
19
|
};
|
|
21
20
|
};
|
|
22
|
-
declare const copyMethodMetadata: (from: any, to: any) => void;
|
|
23
|
-
declare const getTransactionMetdata: (target: any) => any;
|
|
24
|
-
declare const setTransactionMetdata: (target: any) => void;
|
|
25
|
-
declare const withResolvers: <T>() => {
|
|
21
|
+
export declare const copyMethodMetadata: (from: any, to: any) => void;
|
|
22
|
+
export declare const getTransactionMetdata: (target: any) => any;
|
|
23
|
+
export declare const setTransactionMetdata: (target: any) => void;
|
|
24
|
+
export declare const withResolvers: <T>() => {
|
|
26
25
|
promise: Promise<T>;
|
|
27
26
|
resolve: (value: T | PromiseLike<T>) => void;
|
|
28
27
|
reject: (reason?: any) => void;
|
|
29
28
|
};
|
|
30
|
-
|
|
31
|
-
export { copyMethodMetadata, createDebugLogger, debugFactroy, extraceQueryTextAndValues, formatArray, getCurrentDateStr, getTransactionMetdata, isObject, isSubmittable, normalizeStrings, plainPromise, printTable, setTransactionMetdata, truncateString, withResolvers };
|
package/dist/utils.js
CHANGED
|
@@ -1,266 +1,230 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var utils_exports = {};
|
|
29
|
-
__export(utils_exports, {
|
|
30
|
-
copyMethodMetadata: () => copyMethodMetadata,
|
|
31
|
-
createDebugLogger: () => createDebugLogger,
|
|
32
|
-
debugFactroy: () => debugFactroy,
|
|
33
|
-
extraceQueryTextAndValues: () => extraceQueryTextAndValues,
|
|
34
|
-
formatArray: () => formatArray,
|
|
35
|
-
getCurrentDateStr: () => getCurrentDateStr,
|
|
36
|
-
getTransactionMetdata: () => getTransactionMetdata,
|
|
37
|
-
isObject: () => isObject,
|
|
38
|
-
isSubmittable: () => isSubmittable,
|
|
39
|
-
normalizeStrings: () => normalizeStrings,
|
|
40
|
-
plainPromise: () => plainPromise,
|
|
41
|
-
printTable: () => printTable,
|
|
42
|
-
setTransactionMetdata: () => setTransactionMetdata,
|
|
43
|
-
truncateString: () => truncateString,
|
|
44
|
-
withResolvers: () => withResolvers
|
|
45
|
-
});
|
|
46
|
-
module.exports = __toCommonJS(utils_exports);
|
|
47
|
-
var import_dayjs = __toESM(require("dayjs"));
|
|
48
|
-
var import_constants = require("./constants");
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.withResolvers = exports.setTransactionMetdata = exports.getTransactionMetdata = exports.copyMethodMetadata = exports.debugFactroy = exports.createDebugLogger = exports.extraceQueryTextAndValues = exports.formatArray = exports.getCurrentDateStr = exports.printTable = exports.truncateString = exports.plainPromise = exports.normalizeStrings = exports.isObject = exports.isSubmittable = void 0;
|
|
7
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
|
+
const constants_1 = require("./constants");
|
|
49
9
|
const isSubmittable = (val) => {
|
|
50
|
-
|
|
10
|
+
return val && typeof val.submit === 'function';
|
|
51
11
|
};
|
|
12
|
+
exports.isSubmittable = isSubmittable;
|
|
52
13
|
const isObject = (val) => {
|
|
53
|
-
|
|
14
|
+
return Object.prototype.toString.call(val) === '[object Object]';
|
|
54
15
|
};
|
|
16
|
+
exports.isObject = isObject;
|
|
55
17
|
const normalizeStrings = (strs) => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
18
|
+
if (!strs) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
return Array.from(new Set(strs.filter(Boolean).map((ele) => ele.trim())));
|
|
60
22
|
};
|
|
23
|
+
exports.normalizeStrings = normalizeStrings;
|
|
61
24
|
const plainPromise = async (promise) => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
25
|
+
let result = undefined;
|
|
26
|
+
let err = undefined;
|
|
27
|
+
try {
|
|
28
|
+
result = await promise;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
err = error;
|
|
32
|
+
}
|
|
33
|
+
return [result, err];
|
|
70
34
|
};
|
|
35
|
+
exports.plainPromise = plainPromise;
|
|
71
36
|
const truncateString = (str, maxLength) => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
37
|
+
if (str.length <= maxLength) {
|
|
38
|
+
return str;
|
|
39
|
+
}
|
|
40
|
+
const truncatedLength = maxLength - 3;
|
|
41
|
+
if (truncatedLength <= 0) {
|
|
42
|
+
return '...';
|
|
43
|
+
}
|
|
44
|
+
return str.slice(0, truncatedLength) + '...';
|
|
80
45
|
};
|
|
46
|
+
exports.truncateString = truncateString;
|
|
81
47
|
const printTable = (logData) => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
};
|
|
48
|
+
const maxKeyLength = constants_1.MAX_LENGTH / 3;
|
|
49
|
+
const maxValueLength = constants_1.MAX_LENGTH;
|
|
50
|
+
const separatorTop = '─'.repeat(maxKeyLength + 2) + '┬' + '─'.repeat(maxValueLength + 2);
|
|
51
|
+
const separatorBottom = '─'.repeat(maxKeyLength + 2) + '┴' + '─'.repeat(maxValueLength + 2);
|
|
52
|
+
const lines = [
|
|
53
|
+
`┌${separatorTop}┐`,
|
|
54
|
+
...Object.entries(logData)
|
|
55
|
+
.filter(([_, value]) => value)
|
|
56
|
+
.map(([key, value]) => `│ ${key.padEnd(maxKeyLength)} │ ${(0, exports.truncateString)(String(value), constants_1.MAX_LENGTH).padEnd(maxValueLength)} │`),
|
|
57
|
+
`└${separatorBottom}┘`
|
|
58
|
+
];
|
|
59
|
+
return lines.join('\n');
|
|
60
|
+
};
|
|
61
|
+
exports.printTable = printTable;
|
|
95
62
|
const getCurrentDateStr = () => {
|
|
96
|
-
|
|
63
|
+
return (0, dayjs_1.default)().format(constants_1.DATE_FORMAT);
|
|
97
64
|
};
|
|
65
|
+
exports.getCurrentDateStr = getCurrentDateStr;
|
|
98
66
|
const formatArray = (arr) => {
|
|
99
|
-
|
|
67
|
+
return Array.isArray(arr) ? `[${arr.map(String).join(', ')}]` : 'null';
|
|
100
68
|
};
|
|
69
|
+
exports.formatArray = formatArray;
|
|
101
70
|
const extraceQueryTextAndValues = (...rest) => {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
71
|
+
const [arg0, arg1] = rest;
|
|
72
|
+
if (arg0 && ((0, exports.isSubmittable)(arg0) || (0, exports.isObject)(arg0))) {
|
|
73
|
+
return [arg0.text, arg1 ?? arg0.values];
|
|
74
|
+
}
|
|
75
|
+
return [arg0, arg1];
|
|
107
76
|
};
|
|
77
|
+
exports.extraceQueryTextAndValues = extraceQueryTextAndValues;
|
|
108
78
|
const createDebugLogger = (defaultLogger, customFormater) => {
|
|
109
|
-
|
|
79
|
+
if (typeof customFormater === 'function') {
|
|
80
|
+
return (data) => {
|
|
81
|
+
defaultLogger(customFormater(data));
|
|
82
|
+
};
|
|
83
|
+
}
|
|
110
84
|
return (data) => {
|
|
111
|
-
|
|
85
|
+
const firstLine = `Executing Postgres command\n`;
|
|
86
|
+
defaultLogger(firstLine + (0, exports.printTable)(data));
|
|
112
87
|
};
|
|
113
|
-
}
|
|
114
|
-
return (data) => {
|
|
115
|
-
const firstLine = `Executing Postgres command
|
|
116
|
-
`;
|
|
117
|
-
defaultLogger(firstLine + printTable(data));
|
|
118
|
-
};
|
|
119
88
|
};
|
|
89
|
+
exports.createDebugLogger = createDebugLogger;
|
|
120
90
|
const debugFactroy = (name, queryId, logger) => {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
client: {
|
|
147
|
-
query: (callback) => {
|
|
148
|
-
return async (...rest) => {
|
|
149
|
-
const [text, values] = extraceQueryTextAndValues(...rest);
|
|
150
|
-
const submittable = isSubmittable(rest[0]);
|
|
151
|
-
const startOn = getCurrentDateStr();
|
|
152
|
-
let err = void 0;
|
|
153
|
-
if (submittable) {
|
|
154
|
-
rest[0].on("end", () => {
|
|
155
|
-
logger({
|
|
156
|
-
Instance: name,
|
|
157
|
-
Client: queryId,
|
|
158
|
-
Type: "Submittable",
|
|
159
|
-
Text: text,
|
|
160
|
-
Values: formatArray(values),
|
|
161
|
-
"Started On": startOn,
|
|
162
|
-
"Ended On": getCurrentDateStr(),
|
|
163
|
-
Status: "Successful"
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
rest[0].on("error", (err2) => {
|
|
167
|
-
logger({
|
|
168
|
-
Instance: name,
|
|
169
|
-
Client: queryId,
|
|
170
|
-
Type: "Submittable",
|
|
171
|
-
Text: text,
|
|
172
|
-
Values: formatArray(values),
|
|
173
|
-
"Started On": startOn,
|
|
174
|
-
"Ended On": getCurrentDateStr(),
|
|
175
|
-
Status: "Failed",
|
|
176
|
-
Error: err2
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
try {
|
|
181
|
-
return await callback(...rest);
|
|
182
|
-
} catch (error) {
|
|
183
|
-
err = error;
|
|
184
|
-
throw err;
|
|
185
|
-
} finally {
|
|
186
|
-
if (!submittable) {
|
|
187
|
-
logger({
|
|
188
|
-
Instance: name,
|
|
189
|
-
Client: queryId,
|
|
190
|
-
Type: "Query",
|
|
191
|
-
Text: text,
|
|
192
|
-
Values: formatArray(values),
|
|
193
|
-
"Started On": startOn,
|
|
194
|
-
"Ended On": getCurrentDateStr(),
|
|
195
|
-
Status: err ? "Failed" : "Successful",
|
|
196
|
-
Error: err
|
|
197
|
-
});
|
|
91
|
+
return {
|
|
92
|
+
pool: {
|
|
93
|
+
connect: (callback) => {
|
|
94
|
+
return async () => {
|
|
95
|
+
const startOn = (0, exports.getCurrentDateStr)();
|
|
96
|
+
let err = undefined;
|
|
97
|
+
try {
|
|
98
|
+
return await callback();
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
err = error;
|
|
102
|
+
throw err;
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
logger({
|
|
106
|
+
Instance: name,
|
|
107
|
+
Client: queryId,
|
|
108
|
+
Type: 'Request new client',
|
|
109
|
+
'Started On': startOn,
|
|
110
|
+
'Ended On': (0, exports.getCurrentDateStr)(),
|
|
111
|
+
Status: err ? 'Failed' : 'Successful',
|
|
112
|
+
Error: err
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
};
|
|
198
116
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
117
|
+
},
|
|
118
|
+
client: {
|
|
119
|
+
query: (callback) => {
|
|
120
|
+
return async (...rest) => {
|
|
121
|
+
const [text, values] = (0, exports.extraceQueryTextAndValues)(...rest);
|
|
122
|
+
const submittable = (0, exports.isSubmittable)(rest[0]);
|
|
123
|
+
const startOn = (0, exports.getCurrentDateStr)();
|
|
124
|
+
let err = undefined;
|
|
125
|
+
if (submittable) {
|
|
126
|
+
rest[0].on('end', () => {
|
|
127
|
+
logger({
|
|
128
|
+
Instance: name,
|
|
129
|
+
Client: queryId,
|
|
130
|
+
Type: 'Submittable',
|
|
131
|
+
Text: text,
|
|
132
|
+
Values: (0, exports.formatArray)(values),
|
|
133
|
+
'Started On': startOn,
|
|
134
|
+
'Ended On': (0, exports.getCurrentDateStr)(),
|
|
135
|
+
Status: 'Successful'
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
rest[0].on('error', (err) => {
|
|
139
|
+
logger({
|
|
140
|
+
Instance: name,
|
|
141
|
+
Client: queryId,
|
|
142
|
+
Type: 'Submittable',
|
|
143
|
+
Text: text,
|
|
144
|
+
Values: (0, exports.formatArray)(values),
|
|
145
|
+
'Started On': startOn,
|
|
146
|
+
'Ended On': (0, exports.getCurrentDateStr)(),
|
|
147
|
+
Status: 'Failed',
|
|
148
|
+
Error: err
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
try {
|
|
153
|
+
return await callback(...rest);
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
err = error;
|
|
157
|
+
throw err;
|
|
158
|
+
}
|
|
159
|
+
finally {
|
|
160
|
+
if (!submittable) {
|
|
161
|
+
logger({
|
|
162
|
+
Instance: name,
|
|
163
|
+
Client: queryId,
|
|
164
|
+
Type: 'Query',
|
|
165
|
+
Text: text,
|
|
166
|
+
Values: (0, exports.formatArray)(values),
|
|
167
|
+
'Started On': startOn,
|
|
168
|
+
'Ended On': (0, exports.getCurrentDateStr)(),
|
|
169
|
+
Status: err ? 'Failed' : 'Successful',
|
|
170
|
+
Error: err
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
},
|
|
176
|
+
release: (callback) => {
|
|
177
|
+
return (...rest) => {
|
|
178
|
+
const startOn = (0, exports.getCurrentDateStr)();
|
|
179
|
+
let err = undefined;
|
|
180
|
+
try {
|
|
181
|
+
return callback(...rest);
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
err = error;
|
|
185
|
+
throw err;
|
|
186
|
+
}
|
|
187
|
+
finally {
|
|
188
|
+
logger({
|
|
189
|
+
Instance: name,
|
|
190
|
+
Client: queryId,
|
|
191
|
+
Type: 'Release client',
|
|
192
|
+
'Started On': startOn,
|
|
193
|
+
'Ended On': (0, exports.getCurrentDateStr)(),
|
|
194
|
+
Status: err ? 'Failed' : 'Successful',
|
|
195
|
+
Error: err
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
};
|
|
226
202
|
};
|
|
203
|
+
exports.debugFactroy = debugFactroy;
|
|
204
|
+
// Ref: https://github.com/Papooch/nestjs-cls/blob/main/packages/core/src/utils/copy-method-metadata.ts#L10
|
|
227
205
|
const copyMethodMetadata = (from, to) => {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
206
|
+
const metadataKeys = Reflect.getMetadataKeys(from);
|
|
207
|
+
metadataKeys.map((key) => {
|
|
208
|
+
const value = Reflect.getMetadata(key, from);
|
|
209
|
+
Reflect.defineMetadata(key, value, to);
|
|
210
|
+
});
|
|
233
211
|
};
|
|
212
|
+
exports.copyMethodMetadata = copyMethodMetadata;
|
|
234
213
|
const getTransactionMetdata = (target) => {
|
|
235
|
-
|
|
214
|
+
return Reflect.getMetadata(constants_1.TRANSACTION_META, target);
|
|
236
215
|
};
|
|
216
|
+
exports.getTransactionMetdata = getTransactionMetdata;
|
|
237
217
|
const setTransactionMetdata = (target) => {
|
|
238
|
-
|
|
218
|
+
return Reflect.defineMetadata(constants_1.TRANSACTION_META, true, target);
|
|
239
219
|
};
|
|
220
|
+
exports.setTransactionMetdata = setTransactionMetdata;
|
|
240
221
|
const withResolvers = () => {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
0 && (module.exports = {
|
|
251
|
-
copyMethodMetadata,
|
|
252
|
-
createDebugLogger,
|
|
253
|
-
debugFactroy,
|
|
254
|
-
extraceQueryTextAndValues,
|
|
255
|
-
formatArray,
|
|
256
|
-
getCurrentDateStr,
|
|
257
|
-
getTransactionMetdata,
|
|
258
|
-
isObject,
|
|
259
|
-
isSubmittable,
|
|
260
|
-
normalizeStrings,
|
|
261
|
-
plainPromise,
|
|
262
|
-
printTable,
|
|
263
|
-
setTransactionMetdata,
|
|
264
|
-
truncateString,
|
|
265
|
-
withResolvers
|
|
266
|
-
});
|
|
222
|
+
let resolve;
|
|
223
|
+
let reject;
|
|
224
|
+
const promise = new Promise((res, rej) => {
|
|
225
|
+
resolve = res;
|
|
226
|
+
reject = rej;
|
|
227
|
+
});
|
|
228
|
+
return { promise, resolve: resolve, reject: reject };
|
|
229
|
+
};
|
|
230
|
+
exports.withResolvers = withResolvers;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@nestjs-kitchen/connextion-postgres",
|
|
3
3
|
"private": false,
|
|
4
4
|
"description": "A flexible module to provide node-postgres interface in NextJS.",
|
|
5
|
-
"version": "2.0.
|
|
5
|
+
"version": "2.0.4",
|
|
6
6
|
"homepage": "https://github.com/yikenman/nestjs-kitchen",
|
|
7
7
|
"repository": "https://github.com/yikenman/nestjs-kitchen",
|
|
8
8
|
"author": "yikenman",
|
|
@@ -26,12 +26,13 @@
|
|
|
26
26
|
"@types/jest": "^29.5.14",
|
|
27
27
|
"@types/node": "^22.13.9",
|
|
28
28
|
"jest": "^29.7.0",
|
|
29
|
+
"rimraf": "^6.0.1",
|
|
29
30
|
"ts-jest": "^29.3.0",
|
|
30
31
|
"ts-node": "^10.9.2",
|
|
31
32
|
"tsconfig-paths": "^4.2.0",
|
|
32
33
|
"tsup": "^8.4.0",
|
|
33
34
|
"typescript": "^5.8.2",
|
|
34
|
-
"@nestjs-kitchen/connextion": "2.0.
|
|
35
|
+
"@nestjs-kitchen/connextion": "2.0.4"
|
|
35
36
|
},
|
|
36
37
|
"engines": {
|
|
37
38
|
"node": ">=20.13.0"
|
|
@@ -51,11 +52,11 @@
|
|
|
51
52
|
"@types/pg": "^8.11.10",
|
|
52
53
|
"pg": "^8.13.1",
|
|
53
54
|
"reflect-metadata": "^0.2.2",
|
|
54
|
-
"@nestjs-kitchen/connextion": "2.0.
|
|
55
|
+
"@nestjs-kitchen/connextion": "2.0.4"
|
|
55
56
|
},
|
|
56
57
|
"scripts": {
|
|
57
|
-
"build": "
|
|
58
|
-
"dev": "
|
|
58
|
+
"build": "rimraf dist && tsc -p tsconfig.build.json",
|
|
59
|
+
"dev": "rimraf dist && tsc -p tsconfig.build.json --watch",
|
|
59
60
|
"test": "jest",
|
|
60
61
|
"test:ci": "jest --coverage",
|
|
61
62
|
"test:cov": "jest --coverage",
|