@nestjs-kitchen/connextion-postgres 2.0.3 → 2.0.5
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 +9 -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/constants.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
declare const ALS: unique symbol;
|
|
2
|
-
declare const GET_CLIENT: unique symbol;
|
|
3
|
-
declare const DEFAULT_INSTANCE_NAME = "default";
|
|
4
|
-
declare const MAX_LENGTH = 42;
|
|
5
|
-
declare const CONNEXTION_POSTGRES_DEBUG = "CONNEXTION_POSTGRES_DEBUG";
|
|
6
|
-
declare const DATE_FORMAT = "YYYY-MM-DD HH:mm:sssZ";
|
|
7
|
-
declare const TRANSACTION_META = "postgres:transaction";
|
|
8
|
-
|
|
9
|
-
export { ALS, CONNEXTION_POSTGRES_DEBUG, DATE_FORMAT, DEFAULT_INSTANCE_NAME, GET_CLIENT, MAX_LENGTH, TRANSACTION_META };
|
|
1
|
+
export declare const ALS: unique symbol;
|
|
2
|
+
export declare const GET_CLIENT: unique symbol;
|
|
3
|
+
export declare const DEFAULT_INSTANCE_NAME = "default";
|
|
4
|
+
export declare const MAX_LENGTH = 42;
|
|
5
|
+
export declare const CONNEXTION_POSTGRES_DEBUG = "CONNEXTION_POSTGRES_DEBUG";
|
|
6
|
+
export declare const DATE_FORMAT = "YYYY-MM-DD HH:mm:sssZ";
|
|
7
|
+
export declare const TRANSACTION_META = "postgres:transaction";
|
package/dist/constants.js
CHANGED
|
@@ -1,45 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var constants_exports = {};
|
|
19
|
-
__export(constants_exports, {
|
|
20
|
-
ALS: () => ALS,
|
|
21
|
-
CONNEXTION_POSTGRES_DEBUG: () => CONNEXTION_POSTGRES_DEBUG,
|
|
22
|
-
DATE_FORMAT: () => DATE_FORMAT,
|
|
23
|
-
DEFAULT_INSTANCE_NAME: () => DEFAULT_INSTANCE_NAME,
|
|
24
|
-
GET_CLIENT: () => GET_CLIENT,
|
|
25
|
-
MAX_LENGTH: () => MAX_LENGTH,
|
|
26
|
-
TRANSACTION_META: () => TRANSACTION_META
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(constants_exports);
|
|
29
|
-
const ALS = Symbol(`ALS`);
|
|
30
|
-
const GET_CLIENT = Symbol(`GET_CLIENT`);
|
|
31
|
-
const DEFAULT_INSTANCE_NAME = "default";
|
|
32
|
-
const MAX_LENGTH = 42;
|
|
33
|
-
const CONNEXTION_POSTGRES_DEBUG = "CONNEXTION_POSTGRES_DEBUG";
|
|
34
|
-
const DATE_FORMAT = "YYYY-MM-DD HH:mm:sssZ";
|
|
35
|
-
const TRANSACTION_META = "postgres:transaction";
|
|
36
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
-
0 && (module.exports = {
|
|
38
|
-
ALS,
|
|
39
|
-
CONNEXTION_POSTGRES_DEBUG,
|
|
40
|
-
DATE_FORMAT,
|
|
41
|
-
DEFAULT_INSTANCE_NAME,
|
|
42
|
-
GET_CLIENT,
|
|
43
|
-
MAX_LENGTH,
|
|
44
|
-
TRANSACTION_META
|
|
45
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TRANSACTION_META = exports.DATE_FORMAT = exports.CONNEXTION_POSTGRES_DEBUG = exports.MAX_LENGTH = exports.DEFAULT_INSTANCE_NAME = exports.GET_CLIENT = exports.ALS = void 0;
|
|
4
|
+
exports.ALS = Symbol(`ALS`);
|
|
5
|
+
exports.GET_CLIENT = Symbol(`GET_CLIENT`);
|
|
6
|
+
exports.DEFAULT_INSTANCE_NAME = 'default';
|
|
7
|
+
// Answer to the universe.
|
|
8
|
+
exports.MAX_LENGTH = 42;
|
|
9
|
+
// Env debug flag
|
|
10
|
+
exports.CONNEXTION_POSTGRES_DEBUG = 'CONNEXTION_POSTGRES_DEBUG';
|
|
11
|
+
exports.DATE_FORMAT = 'YYYY-MM-DD HH:mm:sssZ';
|
|
12
|
+
exports.TRANSACTION_META = 'postgres:transaction';
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import 'pg';
|
|
7
|
-
import 'node:async_hooks';
|
|
8
|
-
|
|
1
|
+
import { type AsyncModuleOptions, type ConnectionOptionName, type ConnextionInstance, type ModuleOptions } from '@nestjs-kitchen/connextion';
|
|
2
|
+
import type { DynamicModule, Type } from '@nestjs/common';
|
|
3
|
+
import { DEFAULT_INSTANCE_NAME } from './constants';
|
|
4
|
+
import { PostgresInstance } from './postgres.instance';
|
|
5
|
+
import type { PostgresInstanceOptions } from './types';
|
|
9
6
|
/**
|
|
10
7
|
* Creates a set of Postgres services, modules, and their associated Transaction decorator.
|
|
11
8
|
*/
|
|
12
|
-
declare const definePostgres: <T extends string = typeof DEFAULT_INSTANCE_NAME>() => {
|
|
9
|
+
export declare const definePostgres: <T extends string = typeof DEFAULT_INSTANCE_NAME>() => {
|
|
13
10
|
/**
|
|
14
11
|
* The Postgres service, responsible for managing all postgres connection instances registered by the module.
|
|
15
12
|
*/
|
|
16
|
-
Postgres:
|
|
13
|
+
Postgres: Type<Record<ConnectionOptionName<T>, Omit<PostgresInstance, keyof ConnextionInstance<unknown>>>>;
|
|
17
14
|
/**
|
|
18
15
|
* The Postgres module, used to register and create postgres connection instances with options.
|
|
19
16
|
*
|
|
@@ -25,8 +22,8 @@ declare const definePostgres: <T extends string = typeof DEFAULT_INSTANCE_NAME>(
|
|
|
25
22
|
*/
|
|
26
23
|
PostgresModule: {
|
|
27
24
|
new (): {};
|
|
28
|
-
register(options:
|
|
29
|
-
registerAsync(options:
|
|
25
|
+
register(options: ModuleOptions<T, PostgresInstanceOptions>): DynamicModule;
|
|
26
|
+
registerAsync(options: AsyncModuleOptions<T, PostgresInstanceOptions>): DynamicModule;
|
|
30
27
|
};
|
|
31
28
|
/**
|
|
32
29
|
* A decorator that automatically enables transactions for the specific Postgres
|
|
@@ -37,5 +34,3 @@ declare const definePostgres: <T extends string = typeof DEFAULT_INSTANCE_NAME>(
|
|
|
37
34
|
*/
|
|
38
35
|
Transaction: (...rest: T[]) => (target: any, _propertyKey: string, propertyDescriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
39
36
|
};
|
|
40
|
-
|
|
41
|
-
export { definePostgres };
|
package/dist/define-postgres.js
CHANGED
|
@@ -1,62 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var define_postgres_exports = {};
|
|
19
|
-
__export(define_postgres_exports, {
|
|
20
|
-
definePostgres: () => definePostgres
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(define_postgres_exports);
|
|
23
|
-
var import_connextion = require("@nestjs-kitchen/connextion");
|
|
24
|
-
var import_constants = require("./constants");
|
|
25
|
-
var import_postgres = require("./postgres.instance");
|
|
26
|
-
var import_transaction = require("./transaction");
|
|
27
|
-
const innerDefinePostgres = (0, import_connextion.defineConnextionBuilder)({
|
|
28
|
-
connextionName: "Postgres",
|
|
29
|
-
InstanceClass: import_postgres.PostgresInstance,
|
|
30
|
-
defaultInstanceName: import_constants.DEFAULT_INSTANCE_NAME
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.definePostgres = void 0;
|
|
4
|
+
const connextion_1 = require("@nestjs-kitchen/connextion");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
const postgres_instance_1 = require("./postgres.instance");
|
|
7
|
+
const transaction_1 = require("./transaction");
|
|
8
|
+
const innerDefinePostgres = (0, connextion_1.defineConnextionBuilder)({
|
|
9
|
+
connextionName: 'Postgres',
|
|
10
|
+
InstanceClass: postgres_instance_1.PostgresInstance,
|
|
11
|
+
defaultInstanceName: constants_1.DEFAULT_INSTANCE_NAME
|
|
31
12
|
});
|
|
13
|
+
/**
|
|
14
|
+
* Creates a set of Postgres services, modules, and their associated Transaction decorator.
|
|
15
|
+
*/
|
|
32
16
|
const definePostgres = () => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
17
|
+
const { Postgres, PostgresModule } = innerDefinePostgres();
|
|
18
|
+
return {
|
|
19
|
+
/**
|
|
20
|
+
* The Postgres service, responsible for managing all postgres connection instances registered by the module.
|
|
21
|
+
*/
|
|
22
|
+
Postgres,
|
|
23
|
+
/**
|
|
24
|
+
* The Postgres module, used to register and create postgres connection instances with options.
|
|
25
|
+
*
|
|
26
|
+
* This module can be configured using 2 static methods:
|
|
27
|
+
*
|
|
28
|
+
* - `register`
|
|
29
|
+
* - `registerAsync`
|
|
30
|
+
*
|
|
31
|
+
*/
|
|
32
|
+
PostgresModule,
|
|
33
|
+
/**
|
|
34
|
+
* A decorator that automatically enables transactions for the specific Postgres
|
|
35
|
+
* service instances associated with the decorated method.
|
|
36
|
+
*
|
|
37
|
+
* - By default, transactions are enabled for all instances of the associated Postgres service.
|
|
38
|
+
* - If specific instances are specified, only those instances will have transactions enabled.
|
|
39
|
+
*/
|
|
40
|
+
Transaction: (0, transaction_1.createTransaction)(Postgres)
|
|
41
|
+
};
|
|
58
42
|
};
|
|
59
|
-
|
|
60
|
-
0 && (module.exports = {
|
|
61
|
-
definePostgres
|
|
62
|
-
});
|
|
43
|
+
exports.definePostgres = definePostgres;
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { ConnextionError } from '@nestjs-kitchen/connextion';
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* Internal error type.
|
|
5
4
|
*/
|
|
6
|
-
declare class PostgresError extends ConnextionError {
|
|
5
|
+
export declare class PostgresError extends ConnextionError {
|
|
7
6
|
cause?: unknown;
|
|
8
7
|
constructor(message?: string | Error, cause?: unknown);
|
|
9
8
|
}
|
|
10
|
-
|
|
11
|
-
export { PostgresError };
|
package/dist/errors.js
CHANGED
|
@@ -1,35 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var errors_exports = {};
|
|
19
|
-
__export(errors_exports, {
|
|
20
|
-
PostgresError: () => PostgresError
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(errors_exports);
|
|
23
|
-
var import_connextion = require("@nestjs-kitchen/connextion");
|
|
24
|
-
class PostgresError extends import_connextion.ConnextionError {
|
|
25
|
-
constructor(message, cause) {
|
|
26
|
-
super(typeof message === "string" ? message : message?.message);
|
|
27
|
-
this.name = "PostgresError";
|
|
28
|
-
this.cause = cause;
|
|
29
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
30
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PostgresError = void 0;
|
|
4
|
+
const connextion_1 = require("@nestjs-kitchen/connextion");
|
|
5
|
+
/**
|
|
6
|
+
* Internal error type.
|
|
7
|
+
*/
|
|
8
|
+
class PostgresError extends connextion_1.ConnextionError {
|
|
9
|
+
constructor(message, cause) {
|
|
10
|
+
super(typeof message === 'string' ? message : message?.message);
|
|
11
|
+
this.name = 'PostgresError';
|
|
12
|
+
this.cause = cause;
|
|
13
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
14
|
+
}
|
|
31
15
|
}
|
|
32
|
-
|
|
33
|
-
0 && (module.exports = {
|
|
34
|
-
PostgresError
|
|
35
|
-
});
|
|
16
|
+
exports.PostgresError = PostgresError;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
import 'pg';
|
|
5
|
-
import '@nestjs/common';
|
|
6
|
-
import '@nestjs-kitchen/connextion';
|
|
7
|
-
import './constants.js';
|
|
8
|
-
import './postgres.instance.js';
|
|
9
|
-
import 'node:async_hooks';
|
|
1
|
+
import './polyfill';
|
|
2
|
+
export { definePostgres } from './define-postgres';
|
|
3
|
+
export { PostgresError } from './errors';
|
package/dist/index.js
CHANGED
|
@@ -1,31 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var index_exports = {};
|
|
19
|
-
__export(index_exports, {
|
|
20
|
-
PostgresError: () => import_errors.PostgresError,
|
|
21
|
-
definePostgres: () => import_define_postgres.definePostgres
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(index_exports);
|
|
24
|
-
var import_polyfill = require("./polyfill");
|
|
25
|
-
var import_define_postgres = require("./define-postgres");
|
|
26
|
-
var import_errors = require("./errors");
|
|
27
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
-
0 && (module.exports = {
|
|
29
|
-
PostgresError,
|
|
30
|
-
definePostgres
|
|
31
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PostgresError = exports.definePostgres = void 0;
|
|
4
|
+
require("./polyfill");
|
|
5
|
+
var define_postgres_1 = require("./define-postgres");
|
|
6
|
+
Object.defineProperty(exports, "definePostgres", { enumerable: true, get: function () { return define_postgres_1.definePostgres; } });
|
|
7
|
+
var errors_1 = require("./errors");
|
|
8
|
+
Object.defineProperty(exports, "PostgresError", { enumerable: true, get: function () { return errors_1.PostgresError; } });
|
package/dist/polyfill.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { }
|
|
1
|
+
export {};
|
package/dist/polyfill.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
2
|
import { ConnextionInstance } from '@nestjs-kitchen/connextion';
|
|
3
|
-
import { PoolClient,
|
|
4
|
-
import { ALS, GET_CLIENT } from './constants
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
declare class PostgresInstance extends ConnextionInstance<PostgresInstanceOptions> {
|
|
3
|
+
import { type PoolClient, type QueryArrayConfig, type QueryArrayResult, type QueryConfig, type QueryConfigValues, type QueryResult, type QueryResultRow, type Submittable } from 'pg';
|
|
4
|
+
import { ALS, GET_CLIENT } from './constants';
|
|
5
|
+
import type { ALSType, PostgresInstanceOptions } from './types';
|
|
6
|
+
export declare class PostgresInstance extends ConnextionInstance<PostgresInstanceOptions> {
|
|
8
7
|
private pool;
|
|
9
8
|
private logger;
|
|
10
9
|
private debug;
|
|
@@ -25,5 +24,3 @@ declare class PostgresInstance extends ConnextionInstance<PostgresInstanceOption
|
|
|
25
24
|
private queryWithSubmittable;
|
|
26
25
|
private transactionQueryWithSubmittable;
|
|
27
26
|
}
|
|
28
|
-
|
|
29
|
-
export { PostgresInstance };
|