@devmoods/express-extras 0.13.9 → 0.14.0
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/bin/migrate.js +10 -0
- package/dist/__tests__/auth.spec.jsx +3 -5
- package/dist/auth.d.ts +2 -2
- package/dist/auth.js +33 -45
- package/dist/context.d.ts +1 -1
- package/dist/context.js +10 -17
- package/dist/email.js +4 -31
- package/dist/errors.js +16 -51
- package/dist/index.d.ts +13 -13
- package/dist/index.js +14 -32
- package/dist/listen.d.ts +4 -4
- package/dist/listen.js +5 -11
- package/dist/logger.d.ts +1 -1
- package/dist/logger.js +12 -22
- package/dist/middleware.d.ts +5 -3
- package/dist/middleware.js +20 -54
- package/dist/migrate.d.ts +1 -1
- package/dist/migrate.js +25 -31
- package/dist/postgres.d.ts +109 -109
- package/dist/postgres.js +7 -16
- package/dist/redis.d.ts +262 -262
- package/dist/redis.js +3 -7
- package/dist/routes.d.ts +1 -1
- package/dist/routes.js +3 -7
- package/dist/sentry.d.ts +3 -3
- package/dist/sentry.js +4 -32
- package/dist/slack.js +5 -9
- package/dist/validate.d.ts +2 -2
- package/dist/validate.js +13 -23
- package/package.json +24 -7
- package/bin/migrate +0 -9
package/dist/postgres.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { SQL, SQLStatement } from 'sql-template-strings';
|
|
3
|
-
export interface PostgresOptions extends PoolConfig {
|
|
1
|
+
import pg from 'pg';
|
|
2
|
+
import { SQL, type SQLStatement } from 'sql-template-strings';
|
|
3
|
+
export interface PostgresOptions extends pg.PoolConfig {
|
|
4
4
|
onError?: (error: Error, client: any) => void;
|
|
5
5
|
}
|
|
6
6
|
export declare class DoesNotExistError extends Error {
|
|
@@ -19,168 +19,168 @@ export declare class MultipleRowsReturnedError extends Error {
|
|
|
19
19
|
export declare function createPostgres({ onError, ...config }?: PostgresOptions): {
|
|
20
20
|
withConnection: (callback: (query: {
|
|
21
21
|
query: {
|
|
22
|
-
<T extends
|
|
23
|
-
<R extends any[] = any[], I extends any[] = any[]>(queryConfig:
|
|
24
|
-
<R_1 extends
|
|
25
|
-
<R_2 extends
|
|
26
|
-
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig:
|
|
27
|
-
<R_4 extends
|
|
28
|
-
<R_5 extends
|
|
22
|
+
<T extends pg.Submittable>(queryStream: T): T;
|
|
23
|
+
<R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
|
|
24
|
+
<R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
|
|
25
|
+
<R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
|
|
26
|
+
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
|
|
27
|
+
<R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
|
|
28
|
+
<R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
|
|
29
29
|
};
|
|
30
30
|
first: <T_1>(text: string | SQLStatement, values?: (null | string | number | Date)[], options?: {
|
|
31
31
|
query: {
|
|
32
|
-
<T extends
|
|
33
|
-
<R extends any[] = any[], I extends any[] = any[]>(queryConfig:
|
|
34
|
-
<R_1 extends
|
|
35
|
-
<R_2 extends
|
|
36
|
-
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig:
|
|
37
|
-
<R_4 extends
|
|
38
|
-
<R_5 extends
|
|
32
|
+
<T extends pg.Submittable>(queryStream: T): T;
|
|
33
|
+
<R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
|
|
34
|
+
<R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
|
|
35
|
+
<R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
|
|
36
|
+
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
|
|
37
|
+
<R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
|
|
38
|
+
<R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
|
|
39
39
|
};
|
|
40
40
|
}) => Promise<T_1 | null>;
|
|
41
41
|
all: <T_2>(text: string | SQLStatement, values?: (null | string | number | Date)[], options?: {
|
|
42
42
|
query: {
|
|
43
|
-
<T extends
|
|
44
|
-
<R extends any[] = any[], I extends any[] = any[]>(queryConfig:
|
|
45
|
-
<R_1 extends
|
|
46
|
-
<R_2 extends
|
|
47
|
-
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig:
|
|
48
|
-
<R_4 extends
|
|
49
|
-
<R_5 extends
|
|
43
|
+
<T extends pg.Submittable>(queryStream: T): T;
|
|
44
|
+
<R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
|
|
45
|
+
<R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
|
|
46
|
+
<R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
|
|
47
|
+
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
|
|
48
|
+
<R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
|
|
49
|
+
<R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
|
|
50
50
|
};
|
|
51
51
|
}) => Promise<T_2[]>;
|
|
52
52
|
get: <T_3>(text: string | SQLStatement, values?: (null | string | number | Date)[], options?: {
|
|
53
53
|
query: {
|
|
54
|
-
<T extends
|
|
55
|
-
<R extends any[] = any[], I extends any[] = any[]>(queryConfig:
|
|
56
|
-
<R_1 extends
|
|
57
|
-
<R_2 extends
|
|
58
|
-
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig:
|
|
59
|
-
<R_4 extends
|
|
60
|
-
<R_5 extends
|
|
54
|
+
<T extends pg.Submittable>(queryStream: T): T;
|
|
55
|
+
<R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
|
|
56
|
+
<R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
|
|
57
|
+
<R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
|
|
58
|
+
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
|
|
59
|
+
<R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
|
|
60
|
+
<R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
|
|
61
61
|
};
|
|
62
62
|
}) => Promise<T_3>;
|
|
63
63
|
insert: <T_1>(text: string | SQLStatement, values?: (null | string | number | Date)[], options?: {
|
|
64
64
|
query: {
|
|
65
|
-
<T extends
|
|
66
|
-
<R extends any[] = any[], I extends any[] = any[]>(queryConfig:
|
|
67
|
-
<R_1 extends
|
|
68
|
-
<R_2 extends
|
|
69
|
-
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig:
|
|
70
|
-
<R_4 extends
|
|
71
|
-
<R_5 extends
|
|
65
|
+
<T extends pg.Submittable>(queryStream: T): T;
|
|
66
|
+
<R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
|
|
67
|
+
<R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
|
|
68
|
+
<R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
|
|
69
|
+
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
|
|
70
|
+
<R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
|
|
71
|
+
<R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
|
|
72
72
|
};
|
|
73
73
|
}) => Promise<T_1 | null>;
|
|
74
74
|
}) => Promise<void>) => Promise<void>;
|
|
75
75
|
transaction: <T_4>(callback: (query: {
|
|
76
76
|
query: {
|
|
77
|
-
<T extends
|
|
78
|
-
<R extends any[] = any[], I extends any[] = any[]>(queryConfig:
|
|
79
|
-
<R_1 extends
|
|
80
|
-
<R_2 extends
|
|
81
|
-
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig:
|
|
82
|
-
<R_4 extends
|
|
83
|
-
<R_5 extends
|
|
77
|
+
<T extends pg.Submittable>(queryStream: T): T;
|
|
78
|
+
<R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
|
|
79
|
+
<R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
|
|
80
|
+
<R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
|
|
81
|
+
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
|
|
82
|
+
<R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
|
|
83
|
+
<R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
|
|
84
84
|
};
|
|
85
85
|
first: <T_1>(text: string | SQLStatement, values?: (null | string | number | Date)[], options?: {
|
|
86
86
|
query: {
|
|
87
|
-
<T extends
|
|
88
|
-
<R extends any[] = any[], I extends any[] = any[]>(queryConfig:
|
|
89
|
-
<R_1 extends
|
|
90
|
-
<R_2 extends
|
|
91
|
-
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig:
|
|
92
|
-
<R_4 extends
|
|
93
|
-
<R_5 extends
|
|
87
|
+
<T extends pg.Submittable>(queryStream: T): T;
|
|
88
|
+
<R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
|
|
89
|
+
<R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
|
|
90
|
+
<R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
|
|
91
|
+
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
|
|
92
|
+
<R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
|
|
93
|
+
<R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
|
|
94
94
|
};
|
|
95
95
|
}) => Promise<T_1 | null>;
|
|
96
96
|
all: <T_2>(text: string | SQLStatement, values?: (null | string | number | Date)[], options?: {
|
|
97
97
|
query: {
|
|
98
|
-
<T extends
|
|
99
|
-
<R extends any[] = any[], I extends any[] = any[]>(queryConfig:
|
|
100
|
-
<R_1 extends
|
|
101
|
-
<R_2 extends
|
|
102
|
-
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig:
|
|
103
|
-
<R_4 extends
|
|
104
|
-
<R_5 extends
|
|
98
|
+
<T extends pg.Submittable>(queryStream: T): T;
|
|
99
|
+
<R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
|
|
100
|
+
<R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
|
|
101
|
+
<R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
|
|
102
|
+
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
|
|
103
|
+
<R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
|
|
104
|
+
<R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
|
|
105
105
|
};
|
|
106
106
|
}) => Promise<T_2[]>;
|
|
107
107
|
get: <T_3>(text: string | SQLStatement, values?: (null | string | number | Date)[], options?: {
|
|
108
108
|
query: {
|
|
109
|
-
<T extends
|
|
110
|
-
<R extends any[] = any[], I extends any[] = any[]>(queryConfig:
|
|
111
|
-
<R_1 extends
|
|
112
|
-
<R_2 extends
|
|
113
|
-
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig:
|
|
114
|
-
<R_4 extends
|
|
115
|
-
<R_5 extends
|
|
109
|
+
<T extends pg.Submittable>(queryStream: T): T;
|
|
110
|
+
<R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
|
|
111
|
+
<R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
|
|
112
|
+
<R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
|
|
113
|
+
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
|
|
114
|
+
<R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
|
|
115
|
+
<R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
|
|
116
116
|
};
|
|
117
117
|
}) => Promise<T_3>;
|
|
118
118
|
insert: <T_1>(text: string | SQLStatement, values?: (null | string | number | Date)[], options?: {
|
|
119
119
|
query: {
|
|
120
|
-
<T extends
|
|
121
|
-
<R extends any[] = any[], I extends any[] = any[]>(queryConfig:
|
|
122
|
-
<R_1 extends
|
|
123
|
-
<R_2 extends
|
|
124
|
-
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig:
|
|
125
|
-
<R_4 extends
|
|
126
|
-
<R_5 extends
|
|
120
|
+
<T extends pg.Submittable>(queryStream: T): T;
|
|
121
|
+
<R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
|
|
122
|
+
<R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
|
|
123
|
+
<R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
|
|
124
|
+
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
|
|
125
|
+
<R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
|
|
126
|
+
<R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
|
|
127
127
|
};
|
|
128
128
|
}) => Promise<T_1 | null>;
|
|
129
129
|
}) => T_4 | Promise<T_4>) => Promise<T_4>;
|
|
130
|
-
instance: Pool;
|
|
130
|
+
instance: pg.Pool;
|
|
131
131
|
clear: (force?: boolean) => Promise<void>;
|
|
132
132
|
end(): Promise<void>;
|
|
133
133
|
query: {
|
|
134
|
-
<T extends
|
|
135
|
-
<R extends any[] = any[], I extends any[] = any[]>(queryConfig:
|
|
136
|
-
<R_1 extends
|
|
137
|
-
<R_2 extends
|
|
138
|
-
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig:
|
|
139
|
-
<R_4 extends
|
|
140
|
-
<R_5 extends
|
|
134
|
+
<T extends pg.Submittable>(queryStream: T): T;
|
|
135
|
+
<R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
|
|
136
|
+
<R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
|
|
137
|
+
<R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
|
|
138
|
+
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
|
|
139
|
+
<R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
|
|
140
|
+
<R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
|
|
141
141
|
};
|
|
142
142
|
first: <T_1>(text: string | SQLStatement, values?: (null | string | number | Date)[], options?: {
|
|
143
143
|
query: {
|
|
144
|
-
<T extends
|
|
145
|
-
<R extends any[] = any[], I extends any[] = any[]>(queryConfig:
|
|
146
|
-
<R_1 extends
|
|
147
|
-
<R_2 extends
|
|
148
|
-
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig:
|
|
149
|
-
<R_4 extends
|
|
150
|
-
<R_5 extends
|
|
144
|
+
<T extends pg.Submittable>(queryStream: T): T;
|
|
145
|
+
<R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
|
|
146
|
+
<R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
|
|
147
|
+
<R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
|
|
148
|
+
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
|
|
149
|
+
<R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
|
|
150
|
+
<R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
|
|
151
151
|
};
|
|
152
152
|
}) => Promise<T_1 | null>;
|
|
153
153
|
all: <T_2>(text: string | SQLStatement, values?: (null | string | number | Date)[], options?: {
|
|
154
154
|
query: {
|
|
155
|
-
<T extends
|
|
156
|
-
<R extends any[] = any[], I extends any[] = any[]>(queryConfig:
|
|
157
|
-
<R_1 extends
|
|
158
|
-
<R_2 extends
|
|
159
|
-
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig:
|
|
160
|
-
<R_4 extends
|
|
161
|
-
<R_5 extends
|
|
155
|
+
<T extends pg.Submittable>(queryStream: T): T;
|
|
156
|
+
<R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
|
|
157
|
+
<R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
|
|
158
|
+
<R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
|
|
159
|
+
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
|
|
160
|
+
<R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
|
|
161
|
+
<R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
|
|
162
162
|
};
|
|
163
163
|
}) => Promise<T_2[]>;
|
|
164
164
|
get: <T_3>(text: string | SQLStatement, values?: (null | string | number | Date)[], options?: {
|
|
165
165
|
query: {
|
|
166
|
-
<T extends
|
|
167
|
-
<R extends any[] = any[], I extends any[] = any[]>(queryConfig:
|
|
168
|
-
<R_1 extends
|
|
169
|
-
<R_2 extends
|
|
170
|
-
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig:
|
|
171
|
-
<R_4 extends
|
|
172
|
-
<R_5 extends
|
|
166
|
+
<T extends pg.Submittable>(queryStream: T): T;
|
|
167
|
+
<R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
|
|
168
|
+
<R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
|
|
169
|
+
<R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
|
|
170
|
+
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
|
|
171
|
+
<R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
|
|
172
|
+
<R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
|
|
173
173
|
};
|
|
174
174
|
}) => Promise<T_3>;
|
|
175
175
|
insert: <T_1>(text: string | SQLStatement, values?: (null | string | number | Date)[], options?: {
|
|
176
176
|
query: {
|
|
177
|
-
<T extends
|
|
178
|
-
<R extends any[] = any[], I extends any[] = any[]>(queryConfig:
|
|
179
|
-
<R_1 extends
|
|
180
|
-
<R_2 extends
|
|
181
|
-
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig:
|
|
182
|
-
<R_4 extends
|
|
183
|
-
<R_5 extends
|
|
177
|
+
<T extends pg.Submittable>(queryStream: T): T;
|
|
178
|
+
<R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
|
|
179
|
+
<R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
|
|
180
|
+
<R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
|
|
181
|
+
<R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
|
|
182
|
+
<R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
|
|
183
|
+
<R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
|
|
184
184
|
};
|
|
185
185
|
}) => Promise<T_1 | null>;
|
|
186
186
|
};
|
package/dist/postgres.js
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const pg_1 = require("pg");
|
|
5
|
-
const sql_template_strings_1 = require("sql-template-strings");
|
|
6
|
-
class DoesNotExistError extends Error {
|
|
1
|
+
import pg from 'pg';
|
|
2
|
+
import { SQL } from 'sql-template-strings';
|
|
3
|
+
export class DoesNotExistError extends Error {
|
|
7
4
|
constructor(message) {
|
|
8
5
|
super(message);
|
|
9
6
|
this.name = 'DoesNotExistError';
|
|
10
7
|
}
|
|
11
8
|
}
|
|
12
|
-
|
|
13
|
-
class MultipleRowsReturnedError extends Error {
|
|
9
|
+
export class MultipleRowsReturnedError extends Error {
|
|
14
10
|
constructor(message) {
|
|
15
11
|
super(message);
|
|
16
12
|
this.name = 'MultipleRowsReturnedError';
|
|
17
13
|
}
|
|
18
14
|
}
|
|
19
|
-
exports.MultipleRowsReturnedError = MultipleRowsReturnedError;
|
|
20
15
|
/**
|
|
21
16
|
* Create a new Postgres connection pool with
|
|
22
17
|
* conveience methods for executing queries using
|
|
@@ -24,8 +19,8 @@ exports.MultipleRowsReturnedError = MultipleRowsReturnedError;
|
|
|
24
19
|
*
|
|
25
20
|
* @param config
|
|
26
21
|
*/
|
|
27
|
-
function createPostgres({ onError = () => { }, ...config } = {}) {
|
|
28
|
-
const pool = new
|
|
22
|
+
export function createPostgres({ onError = () => { }, ...config } = {}) {
|
|
23
|
+
const pool = new pg.Pool(config);
|
|
29
24
|
pool.on('error', onError);
|
|
30
25
|
const defaultQuery = pool.query.bind(pool);
|
|
31
26
|
async function withConnection(callback) {
|
|
@@ -34,9 +29,6 @@ function createPostgres({ onError = () => { }, ...config } = {}) {
|
|
|
34
29
|
const result = await callback(makeQueryFunctions(client.query.bind(client)));
|
|
35
30
|
return result;
|
|
36
31
|
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
throw error;
|
|
39
|
-
}
|
|
40
32
|
finally {
|
|
41
33
|
client.release();
|
|
42
34
|
}
|
|
@@ -106,5 +98,4 @@ function createPostgres({ onError = () => { }, ...config } = {}) {
|
|
|
106
98
|
},
|
|
107
99
|
};
|
|
108
100
|
}
|
|
109
|
-
|
|
110
|
-
exports.sql = sql_template_strings_1.SQL;
|
|
101
|
+
export const sql = SQL;
|