@nestjs-kitchen/connextion-postgres 2.0.2 → 2.0.3
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/define-postgres.js +18 -19
- package/dist/errors.js +2 -8
- package/dist/postgres.instance.js +16 -23
- package/dist/transaction.js +33 -29
- package/dist/utils.js +43 -55
- package/package.json +4 -4
package/dist/define-postgres.js
CHANGED
|
@@ -2,7 +2,6 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
5
|
var __export = (target, all) => {
|
|
7
6
|
for (var name in all)
|
|
8
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -30,33 +29,33 @@ const innerDefinePostgres = (0, import_connextion.defineConnextionBuilder)({
|
|
|
30
29
|
InstanceClass: import_postgres.PostgresInstance,
|
|
31
30
|
defaultInstanceName: import_constants.DEFAULT_INSTANCE_NAME
|
|
32
31
|
});
|
|
33
|
-
const definePostgres =
|
|
32
|
+
const definePostgres = () => {
|
|
34
33
|
const { Postgres, PostgresModule } = innerDefinePostgres();
|
|
35
34
|
return {
|
|
36
35
|
/**
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
* The Postgres service, responsible for managing all postgres connection instances registered by the module.
|
|
37
|
+
*/
|
|
39
38
|
Postgres,
|
|
40
39
|
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
* The Postgres module, used to register and create postgres connection instances with options.
|
|
41
|
+
*
|
|
42
|
+
* This module can be configured using 2 static methods:
|
|
43
|
+
*
|
|
44
|
+
* - `register`
|
|
45
|
+
* - `registerAsync`
|
|
46
|
+
*
|
|
47
|
+
*/
|
|
49
48
|
PostgresModule,
|
|
50
49
|
/**
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
* A decorator that automatically enables transactions for the specific Postgres
|
|
51
|
+
* service instances associated with the decorated method.
|
|
52
|
+
*
|
|
53
|
+
* - By default, transactions are enabled for all instances of the associated Postgres service.
|
|
54
|
+
* - If specific instances are specified, only those instances will have transactions enabled.
|
|
55
|
+
*/
|
|
57
56
|
Transaction: (0, import_transaction.createTransaction)(Postgres)
|
|
58
57
|
};
|
|
59
|
-
}
|
|
58
|
+
};
|
|
60
59
|
// Annotate the CommonJS export names for ESM import in node:
|
|
61
60
|
0 && (module.exports = {
|
|
62
61
|
definePostgres
|
package/dist/errors.js
CHANGED
|
@@ -2,8 +2,6 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all)
|
|
9
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -17,24 +15,20 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
return to;
|
|
18
16
|
};
|
|
19
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
18
|
var errors_exports = {};
|
|
22
19
|
__export(errors_exports, {
|
|
23
20
|
PostgresError: () => PostgresError
|
|
24
21
|
});
|
|
25
22
|
module.exports = __toCommonJS(errors_exports);
|
|
26
23
|
var import_connextion = require("@nestjs-kitchen/connextion");
|
|
27
|
-
|
|
24
|
+
class PostgresError extends import_connextion.ConnextionError {
|
|
28
25
|
constructor(message, cause) {
|
|
29
26
|
super(typeof message === "string" ? message : message?.message);
|
|
30
|
-
__publicField(this, "cause");
|
|
31
27
|
this.name = "PostgresError";
|
|
32
28
|
this.cause = cause;
|
|
33
29
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
34
30
|
}
|
|
35
|
-
}
|
|
36
|
-
__name(_PostgresError, "PostgresError");
|
|
37
|
-
let PostgresError = _PostgresError;
|
|
31
|
+
}
|
|
38
32
|
// Annotate the CommonJS export names for ESM import in node:
|
|
39
33
|
0 && (module.exports = {
|
|
40
34
|
PostgresError
|
|
@@ -2,8 +2,6 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all)
|
|
9
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -17,7 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
return to;
|
|
18
16
|
};
|
|
19
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
18
|
var postgres_instance_exports = {};
|
|
22
19
|
__export(postgres_instance_exports, {
|
|
23
20
|
PostgresInstance: () => PostgresInstance
|
|
@@ -32,20 +29,18 @@ var import_constants = require("./constants");
|
|
|
32
29
|
var import_errors = require("./errors");
|
|
33
30
|
var import_utils = require("./utils");
|
|
34
31
|
var _a;
|
|
35
|
-
|
|
32
|
+
class PostgresInstance extends import_connextion.ConnextionInstance {
|
|
36
33
|
constructor(name, options) {
|
|
37
34
|
super(name, options);
|
|
38
|
-
|
|
39
|
-
__publicField(this, "logger");
|
|
40
|
-
__publicField(this, "debug");
|
|
35
|
+
this.pool = void 0;
|
|
41
36
|
// Every instance should have its own als to avoid accessing wrong context.
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
this[_a] = new import_node_async_hooks.AsyncLocalStorage();
|
|
38
|
+
this.listener1 = (_cli) => {
|
|
44
39
|
_cli.on("error", this.listener2);
|
|
45
|
-
}
|
|
46
|
-
|
|
40
|
+
};
|
|
41
|
+
this.listener2 = (err) => {
|
|
47
42
|
this.logger.error(err);
|
|
48
|
-
}
|
|
43
|
+
};
|
|
49
44
|
this.logger = new import_common.Logger(`Postgres][${name}`);
|
|
50
45
|
this.debug = Boolean(process.env[import_constants.CONNEXTION_POSTGRES_DEBUG]) || options?.debug;
|
|
51
46
|
}
|
|
@@ -164,14 +159,14 @@ const _PostgresInstance = class _PostgresInstance extends import_connextion.Conn
|
|
|
164
159
|
throw err;
|
|
165
160
|
} finally {
|
|
166
161
|
if (res) {
|
|
167
|
-
const onError =
|
|
162
|
+
const onError = (error) => {
|
|
168
163
|
res.off("end", onEnd);
|
|
169
164
|
client.release(new import_errors.PostgresError(error, error));
|
|
170
|
-
}
|
|
171
|
-
const onEnd =
|
|
165
|
+
};
|
|
166
|
+
const onEnd = () => {
|
|
172
167
|
res.off("error", onError);
|
|
173
168
|
client.release(true);
|
|
174
|
-
}
|
|
169
|
+
};
|
|
175
170
|
res.once("end", onEnd);
|
|
176
171
|
res.once("error", onError);
|
|
177
172
|
} else {
|
|
@@ -194,14 +189,14 @@ const _PostgresInstance = class _PostgresInstance extends import_connextion.Conn
|
|
|
194
189
|
throw err;
|
|
195
190
|
} finally {
|
|
196
191
|
if (res) {
|
|
197
|
-
const onError =
|
|
192
|
+
const onError = (error) => {
|
|
198
193
|
res.off("end", onEnd);
|
|
199
194
|
resolve(new import_errors.PostgresError(error, error));
|
|
200
|
-
}
|
|
201
|
-
const onEnd =
|
|
195
|
+
};
|
|
196
|
+
const onEnd = () => {
|
|
202
197
|
res.off("error", onError);
|
|
203
198
|
resolve(true);
|
|
204
|
-
}
|
|
199
|
+
};
|
|
205
200
|
res.once("end", onEnd);
|
|
206
201
|
res.once("error", onError);
|
|
207
202
|
} else {
|
|
@@ -209,9 +204,7 @@ const _PostgresInstance = class _PostgresInstance extends import_connextion.Conn
|
|
|
209
204
|
}
|
|
210
205
|
}
|
|
211
206
|
}
|
|
212
|
-
}
|
|
213
|
-
__name(_PostgresInstance, "PostgresInstance");
|
|
214
|
-
let PostgresInstance = _PostgresInstance;
|
|
207
|
+
}
|
|
215
208
|
// Annotate the CommonJS export names for ESM import in node:
|
|
216
209
|
0 && (module.exports = {
|
|
217
210
|
PostgresInstance
|
package/dist/transaction.js
CHANGED
|
@@ -2,7 +2,6 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
5
|
var __export = (target, all) => {
|
|
7
6
|
for (var name in all)
|
|
8
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -25,7 +24,7 @@ var import_common = require("@nestjs/common");
|
|
|
25
24
|
var import_constants = require("./constants");
|
|
26
25
|
var import_errors = require("./errors");
|
|
27
26
|
var import_utils = require("./utils");
|
|
28
|
-
const createTransaction =
|
|
27
|
+
const createTransaction = (Postgres) => {
|
|
29
28
|
const postgresPropName = Symbol("postgres");
|
|
30
29
|
return (...rest) => {
|
|
31
30
|
const injectPostgres = (0, import_common.Inject)(Postgres);
|
|
@@ -63,47 +62,52 @@ const createTransaction = /* @__PURE__ */ __name((Postgres) => {
|
|
|
63
62
|
inited: false
|
|
64
63
|
};
|
|
65
64
|
});
|
|
66
|
-
const initClients =
|
|
65
|
+
const initClients = async () => {
|
|
67
66
|
for (const ele of list) {
|
|
68
67
|
await ele.store.client;
|
|
69
68
|
ele.inited = true;
|
|
70
69
|
}
|
|
71
|
-
}
|
|
72
|
-
const runWithClients =
|
|
70
|
+
};
|
|
71
|
+
const runWithClients = async (fn) => {
|
|
73
72
|
for (const ele of list) {
|
|
74
73
|
if (ele.inited) {
|
|
75
74
|
const client = await ele.store.client;
|
|
76
75
|
await fn(client);
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
|
-
}
|
|
80
|
-
const releaseClients =
|
|
78
|
+
};
|
|
79
|
+
const releaseClients = async (err2) => runWithClients((client) => client.release(err2 ?? true));
|
|
81
80
|
const [_, initErr] = await (0, import_utils.plainPromise)(initClients());
|
|
82
81
|
if (initErr) {
|
|
83
82
|
await releaseClients();
|
|
84
83
|
throw initErr;
|
|
85
84
|
}
|
|
86
|
-
const executeQueries = list.reduce(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
85
|
+
const executeQueries = list.reduce(
|
|
86
|
+
(next, ele) => () => ele.als.run(ele.store, next),
|
|
87
|
+
() => originalMethod.apply(that, args)
|
|
88
|
+
);
|
|
89
|
+
const [result, err] = await (0, import_utils.plainPromise)(
|
|
90
|
+
(async () => {
|
|
91
|
+
const [result2, err2] = await (0, import_utils.plainPromise)(
|
|
92
|
+
// Start transaction and execute queries.
|
|
93
|
+
(async () => {
|
|
94
|
+
await runWithClients((client) => client.query("BEGIN"));
|
|
95
|
+
const result3 = await executeQueries();
|
|
96
|
+
const queryResults = await Promise.all(list.flatMap((c) => c.store.queries));
|
|
97
|
+
const queryFailures = queryResults.filter((res) => res !== true);
|
|
98
|
+
if (queryFailures.length) {
|
|
99
|
+
throw queryFailures[0];
|
|
100
|
+
}
|
|
101
|
+
return result3;
|
|
102
|
+
})()
|
|
103
|
+
);
|
|
104
|
+
await runWithClients((client) => client.query(err2 ? "ROLLBACK" : "COMMIT"));
|
|
105
|
+
if (err2) {
|
|
106
|
+
throw err2;
|
|
107
|
+
}
|
|
108
|
+
return result2;
|
|
109
|
+
})()
|
|
110
|
+
);
|
|
107
111
|
await releaseClients(err);
|
|
108
112
|
if (err) {
|
|
109
113
|
throw err;
|
|
@@ -114,7 +118,7 @@ const createTransaction = /* @__PURE__ */ __name((Postgres) => {
|
|
|
114
118
|
return propertyDescriptor;
|
|
115
119
|
};
|
|
116
120
|
};
|
|
117
|
-
}
|
|
121
|
+
};
|
|
118
122
|
// Annotate the CommonJS export names for ESM import in node:
|
|
119
123
|
0 && (module.exports = {
|
|
120
124
|
createTransaction
|
package/dist/utils.js
CHANGED
|
@@ -4,7 +4,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
7
|
var __export = (target, all) => {
|
|
9
8
|
for (var name in all)
|
|
10
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -47,19 +46,19 @@ __export(utils_exports, {
|
|
|
47
46
|
module.exports = __toCommonJS(utils_exports);
|
|
48
47
|
var import_dayjs = __toESM(require("dayjs"));
|
|
49
48
|
var import_constants = require("./constants");
|
|
50
|
-
const isSubmittable =
|
|
49
|
+
const isSubmittable = (val) => {
|
|
51
50
|
return val && typeof val.submit === "function";
|
|
52
|
-
}
|
|
53
|
-
const isObject =
|
|
51
|
+
};
|
|
52
|
+
const isObject = (val) => {
|
|
54
53
|
return Object.prototype.toString.call(val) === "[object Object]";
|
|
55
|
-
}
|
|
56
|
-
const normalizeStrings =
|
|
54
|
+
};
|
|
55
|
+
const normalizeStrings = (strs) => {
|
|
57
56
|
if (!strs) {
|
|
58
57
|
return [];
|
|
59
58
|
}
|
|
60
59
|
return Array.from(new Set(strs.filter(Boolean).map((ele) => ele.trim())));
|
|
61
|
-
}
|
|
62
|
-
const plainPromise =
|
|
60
|
+
};
|
|
61
|
+
const plainPromise = async (promise) => {
|
|
63
62
|
let result = void 0;
|
|
64
63
|
let err = void 0;
|
|
65
64
|
try {
|
|
@@ -67,12 +66,9 @@ const plainPromise = /* @__PURE__ */ __name(async (promise) => {
|
|
|
67
66
|
} catch (error) {
|
|
68
67
|
err = error;
|
|
69
68
|
}
|
|
70
|
-
return [
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
];
|
|
74
|
-
}, "plainPromise");
|
|
75
|
-
const truncateString = /* @__PURE__ */ __name((str, maxLength) => {
|
|
69
|
+
return [result, err];
|
|
70
|
+
};
|
|
71
|
+
const truncateString = (str, maxLength) => {
|
|
76
72
|
if (str.length <= maxLength) {
|
|
77
73
|
return str;
|
|
78
74
|
}
|
|
@@ -81,39 +77,35 @@ const truncateString = /* @__PURE__ */ __name((str, maxLength) => {
|
|
|
81
77
|
return "...";
|
|
82
78
|
}
|
|
83
79
|
return str.slice(0, truncatedLength) + "...";
|
|
84
|
-
}
|
|
85
|
-
const printTable =
|
|
80
|
+
};
|
|
81
|
+
const printTable = (logData) => {
|
|
86
82
|
const maxKeyLength = import_constants.MAX_LENGTH / 3;
|
|
87
83
|
const maxValueLength = import_constants.MAX_LENGTH;
|
|
88
84
|
const separatorTop = "\u2500".repeat(maxKeyLength + 2) + "\u252C" + "\u2500".repeat(maxValueLength + 2);
|
|
89
85
|
const separatorBottom = "\u2500".repeat(maxKeyLength + 2) + "\u2534" + "\u2500".repeat(maxValueLength + 2);
|
|
90
86
|
const lines = [
|
|
91
87
|
`\u250C${separatorTop}\u2510`,
|
|
92
|
-
...Object.entries(logData).filter(([_, value]) => value).map(
|
|
88
|
+
...Object.entries(logData).filter(([_, value]) => value).map(
|
|
89
|
+
([key, value]) => `\u2502 ${key.padEnd(maxKeyLength)} \u2502 ${truncateString(String(value), import_constants.MAX_LENGTH).padEnd(maxValueLength)} \u2502`
|
|
90
|
+
),
|
|
93
91
|
`\u2514${separatorBottom}\u2518`
|
|
94
92
|
];
|
|
95
93
|
return lines.join("\n");
|
|
96
|
-
}
|
|
97
|
-
const getCurrentDateStr =
|
|
94
|
+
};
|
|
95
|
+
const getCurrentDateStr = () => {
|
|
98
96
|
return (0, import_dayjs.default)().format(import_constants.DATE_FORMAT);
|
|
99
|
-
}
|
|
100
|
-
const formatArray =
|
|
97
|
+
};
|
|
98
|
+
const formatArray = (arr) => {
|
|
101
99
|
return Array.isArray(arr) ? `[${arr.map(String).join(", ")}]` : "null";
|
|
102
|
-
}
|
|
103
|
-
const extraceQueryTextAndValues =
|
|
100
|
+
};
|
|
101
|
+
const extraceQueryTextAndValues = (...rest) => {
|
|
104
102
|
const [arg0, arg1] = rest;
|
|
105
103
|
if (arg0 && (isSubmittable(arg0) || isObject(arg0))) {
|
|
106
|
-
return [
|
|
107
|
-
arg0.text,
|
|
108
|
-
arg1 ?? arg0.values
|
|
109
|
-
];
|
|
104
|
+
return [arg0.text, arg1 ?? arg0.values];
|
|
110
105
|
}
|
|
111
|
-
return [
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
];
|
|
115
|
-
}, "extraceQueryTextAndValues");
|
|
116
|
-
const createDebugLogger = /* @__PURE__ */ __name((defaultLogger, customFormater) => {
|
|
106
|
+
return [arg0, arg1];
|
|
107
|
+
};
|
|
108
|
+
const createDebugLogger = (defaultLogger, customFormater) => {
|
|
117
109
|
if (typeof customFormater === "function") {
|
|
118
110
|
return (data) => {
|
|
119
111
|
defaultLogger(customFormater(data));
|
|
@@ -124,11 +116,11 @@ const createDebugLogger = /* @__PURE__ */ __name((defaultLogger, customFormater)
|
|
|
124
116
|
`;
|
|
125
117
|
defaultLogger(firstLine + printTable(data));
|
|
126
118
|
};
|
|
127
|
-
}
|
|
128
|
-
const debugFactroy =
|
|
119
|
+
};
|
|
120
|
+
const debugFactroy = (name, queryId, logger) => {
|
|
129
121
|
return {
|
|
130
122
|
pool: {
|
|
131
|
-
connect:
|
|
123
|
+
connect: (callback) => {
|
|
132
124
|
return async () => {
|
|
133
125
|
const startOn = getCurrentDateStr();
|
|
134
126
|
let err = void 0;
|
|
@@ -149,10 +141,10 @@ const debugFactroy = /* @__PURE__ */ __name((name, queryId, logger) => {
|
|
|
149
141
|
});
|
|
150
142
|
}
|
|
151
143
|
};
|
|
152
|
-
}
|
|
144
|
+
}
|
|
153
145
|
},
|
|
154
146
|
client: {
|
|
155
|
-
query:
|
|
147
|
+
query: (callback) => {
|
|
156
148
|
return async (...rest) => {
|
|
157
149
|
const [text, values] = extraceQueryTextAndValues(...rest);
|
|
158
150
|
const submittable = isSubmittable(rest[0]);
|
|
@@ -206,8 +198,8 @@ const debugFactroy = /* @__PURE__ */ __name((name, queryId, logger) => {
|
|
|
206
198
|
}
|
|
207
199
|
}
|
|
208
200
|
};
|
|
209
|
-
},
|
|
210
|
-
release:
|
|
201
|
+
},
|
|
202
|
+
release: (callback) => {
|
|
211
203
|
return (...rest) => {
|
|
212
204
|
const startOn = getCurrentDateStr();
|
|
213
205
|
let err = void 0;
|
|
@@ -228,36 +220,32 @@ const debugFactroy = /* @__PURE__ */ __name((name, queryId, logger) => {
|
|
|
228
220
|
});
|
|
229
221
|
}
|
|
230
222
|
};
|
|
231
|
-
}
|
|
223
|
+
}
|
|
232
224
|
}
|
|
233
225
|
};
|
|
234
|
-
}
|
|
235
|
-
const copyMethodMetadata =
|
|
226
|
+
};
|
|
227
|
+
const copyMethodMetadata = (from, to) => {
|
|
236
228
|
const metadataKeys = Reflect.getMetadataKeys(from);
|
|
237
229
|
metadataKeys.map((key) => {
|
|
238
230
|
const value = Reflect.getMetadata(key, from);
|
|
239
231
|
Reflect.defineMetadata(key, value, to);
|
|
240
232
|
});
|
|
241
|
-
}
|
|
242
|
-
const getTransactionMetdata =
|
|
233
|
+
};
|
|
234
|
+
const getTransactionMetdata = (target) => {
|
|
243
235
|
return Reflect.getMetadata(import_constants.TRANSACTION_META, target);
|
|
244
|
-
}
|
|
245
|
-
const setTransactionMetdata =
|
|
236
|
+
};
|
|
237
|
+
const setTransactionMetdata = (target) => {
|
|
246
238
|
return Reflect.defineMetadata(import_constants.TRANSACTION_META, true, target);
|
|
247
|
-
}
|
|
248
|
-
const withResolvers =
|
|
239
|
+
};
|
|
240
|
+
const withResolvers = () => {
|
|
249
241
|
let resolve;
|
|
250
242
|
let reject;
|
|
251
243
|
const promise = new Promise((res, rej) => {
|
|
252
244
|
resolve = res;
|
|
253
245
|
reject = rej;
|
|
254
246
|
});
|
|
255
|
-
return {
|
|
256
|
-
|
|
257
|
-
resolve,
|
|
258
|
-
reject
|
|
259
|
-
};
|
|
260
|
-
}, "withResolvers");
|
|
247
|
+
return { promise, resolve, reject };
|
|
248
|
+
};
|
|
261
249
|
// Annotate the CommonJS export names for ESM import in node:
|
|
262
250
|
0 && (module.exports = {
|
|
263
251
|
copyMethodMetadata,
|
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.3",
|
|
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,12 @@
|
|
|
26
26
|
"@types/jest": "^29.5.14",
|
|
27
27
|
"@types/node": "^22.13.9",
|
|
28
28
|
"jest": "^29.7.0",
|
|
29
|
-
"ts-jest": "^29.
|
|
29
|
+
"ts-jest": "^29.3.0",
|
|
30
30
|
"ts-node": "^10.9.2",
|
|
31
31
|
"tsconfig-paths": "^4.2.0",
|
|
32
32
|
"tsup": "^8.4.0",
|
|
33
33
|
"typescript": "^5.8.2",
|
|
34
|
-
"@nestjs-kitchen/connextion": "2.0.
|
|
34
|
+
"@nestjs-kitchen/connextion": "2.0.3"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
37
|
"node": ">=20.13.0"
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@types/pg": "^8.11.10",
|
|
52
52
|
"pg": "^8.13.1",
|
|
53
53
|
"reflect-metadata": "^0.2.2",
|
|
54
|
-
"@nestjs-kitchen/connextion": "2.0.
|
|
54
|
+
"@nestjs-kitchen/connextion": "2.0.3"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"build": "tsup",
|