@squiz/db-lib 1.2.1-alpha.100

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md ADDED
@@ -0,0 +1,80 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## [1.2.1-alpha.100](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.100) (2022-08-18)
7
+
8
+ **Note:** Version bump only for package @squiz/db-lib
9
+
10
+
11
+
12
+
13
+
14
+ ## [1.2.1-alpha.99](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.99) (2022-08-18)
15
+
16
+ **Note:** Version bump only for package @squiz/db-lib
17
+
18
+
19
+
20
+
21
+
22
+ ## [1.2.1-alpha.98](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.98) (2022-08-17)
23
+
24
+ **Note:** Version bump only for package @squiz/db-lib
25
+
26
+
27
+
28
+
29
+
30
+ ## [1.2.1-alpha.97](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.97) (2022-08-17)
31
+
32
+ **Note:** Version bump only for package @squiz/db-lib
33
+
34
+
35
+
36
+
37
+
38
+ ## [1.2.1-alpha.96](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.96) (2022-08-12)
39
+
40
+ **Note:** Version bump only for package @squiz/db-lib
41
+
42
+
43
+
44
+
45
+
46
+ ## [1.2.1-alpha.95](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.95) (2022-08-10)
47
+
48
+ **Note:** Version bump only for package @squiz/db-lib
49
+
50
+
51
+
52
+
53
+
54
+ ## [1.2.1-alpha.90](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.89...v1.2.1-alpha.90) (2022-08-05)
55
+
56
+ **Note:** Version bump only for package @squiz/db-lib
57
+
58
+
59
+
60
+
61
+
62
+ ## [1.2.1-alpha.89](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.88...v1.2.1-alpha.89) (2022-08-05)
63
+
64
+ **Note:** Version bump only for package @squiz/db-lib
65
+
66
+
67
+
68
+
69
+
70
+ ## [1.2.1-alpha.88](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.67...v1.2.1-alpha.88) (2022-08-05)
71
+
72
+ **Note:** Version bump only for package @squiz/db-lib
73
+
74
+
75
+
76
+
77
+
78
+ ## [1.2.1-alpha.87](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.67...v1.2.1-alpha.87) (2022-08-05)
79
+
80
+ **Note:** Version bump only for package @squiz/db-lib
package/README.md ADDED
@@ -0,0 +1,4 @@
1
+ # DB Lib
2
+
3
+ This lib contains the code to handle DB
4
+
package/build.js ADDED
@@ -0,0 +1,33 @@
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
2
+
3
+ require('dotenv').config();
4
+
5
+ // const rm = require('rimraf');
6
+ const esBuild = require('esbuild');
7
+
8
+ /** @type BuildOptions */
9
+ let buildSettingsMain = {
10
+ entryPoints: ['src/index.ts'],
11
+ bundle: true,
12
+ target: 'node16',
13
+ platform: 'node',
14
+ treeShaking: true,
15
+ outfile: 'lib/index.js',
16
+ sourcemap: true,
17
+ format: 'cjs',
18
+
19
+ external: ['pg-native'],
20
+ };
21
+
22
+ if (process.env.NODE_ENV == 'development' && process.env.WATCH == 'true') {
23
+ buildSettingsMain.watch = {
24
+ onRebuild(error, result) {
25
+ if (error) console.error('watch build failed:', error);
26
+ else console.log('watch build succeeded:', result);
27
+ },
28
+ };
29
+ }
30
+
31
+ // rm.sync('./lib/**');
32
+
33
+ Promise.all([esBuild.build(buildSettingsMain)]).catch(() => process.exit(1));
package/jest.config.ts ADDED
@@ -0,0 +1,14 @@
1
+ import type { Config } from 'jest';
2
+
3
+ import { config as configFunc } from 'dotenv';
4
+ configFunc();
5
+
6
+ // Sync object
7
+ const config: Config = {
8
+ preset: 'ts-jest',
9
+ testEnvironment: 'node',
10
+ testPathIgnorePatterns: ['<rootDir>/lib/'],
11
+ maxWorkers: '80%',
12
+ };
13
+
14
+ export default config;
@@ -0,0 +1,43 @@
1
+ import { PoolClient, Pool } from 'pg';
2
+ import { Repositories } from './Repositories';
3
+ export interface Reader<T> {
4
+ find(item: Partial<T>): Promise<T[]>;
5
+ findOne(id: string | Partial<T>): Promise<T | undefined>;
6
+ }
7
+ export interface Writer<T> {
8
+ create(value: Partial<T>): Promise<T>;
9
+ update(where: Partial<T>, newValue: Partial<T>): Promise<T[]>;
10
+ delete(where: Partial<T>): Promise<number>;
11
+ }
12
+ export declare type Repository<T> = Reader<T> & Writer<T>;
13
+ export declare abstract class AbstractRepository<T> implements Reader<T>, Writer<T> {
14
+ protected repositories: Repositories;
15
+ protected pool: Pool;
16
+ protected classRef: {
17
+ new (data?: Record<string, unknown>): T;
18
+ };
19
+ protected tableName: string;
20
+ /** object where the key is the model property name amd the value is sql column name */
21
+ protected modelPropertyToSqlColumn: {
22
+ [key in keyof T]: string;
23
+ };
24
+ /** object where the key is the sql column name and the value is the model property name */
25
+ protected sqlColumnToModelProperty: {
26
+ [key: string]: string;
27
+ };
28
+ constructor(repositories: Repositories, pool: Pool, tableName: string, mapping: {
29
+ [key in keyof T]: string;
30
+ }, classRef: {
31
+ new (data?: Record<string, unknown>): T;
32
+ });
33
+ protected getConnection(): Promise<PoolClient>;
34
+ create(value: Partial<T>, transactionClient?: PoolClient | null): Promise<T>;
35
+ update(where: Partial<T>, newValue: Partial<T>, transactionClient?: PoolClient | null): Promise<T[]>;
36
+ delete(where: Partial<T>, transactionClient?: PoolClient | null): Promise<number>;
37
+ protected createWhereStringFromPartialModel(values: Partial<T>, initialIndex?: number): string;
38
+ protected executeQuery(query: string, values: any[], transactionClient?: PoolClient | null): Promise<T[]>;
39
+ protected createAndHydrateModel(row: any): T;
40
+ findOne(item: Partial<T>): Promise<T | undefined>;
41
+ find(item: Partial<T>): Promise<T[]>;
42
+ findAll(): Promise<T[]>;
43
+ }
@@ -0,0 +1,25 @@
1
+ import { Pool } from 'pg';
2
+ import { PoolClient } from 'pg';
3
+ import { Repositories } from './Repositories';
4
+ export interface DbConnection {
5
+ user: string;
6
+ password: string;
7
+ host: string;
8
+ port: number;
9
+ database: string;
10
+ }
11
+ export interface ConnectionStringObj {
12
+ connectionString: string;
13
+ }
14
+ export declare type TransactionClient = PoolClient;
15
+ export declare class ConnectionManager<T extends Repositories> {
16
+ protected applicationName: string;
17
+ protected migrationDirectory: string;
18
+ protected migrationList: string[];
19
+ readonly pool: Pool;
20
+ readonly repositories: T;
21
+ constructor(applicationName: string, connection: string | DbConnection, migrationDirectory: string, migrationList: string[], repositoryCreator: (dbManager: ConnectionManager<T>) => T);
22
+ applyMigrations(): Promise<void>;
23
+ close(): Promise<void>;
24
+ executeInTransaction<T>(func: (client: TransactionClient) => Promise<T>): Promise<T>;
25
+ }
@@ -0,0 +1,18 @@
1
+ import { PoolClient } from 'pg';
2
+ export declare class Migrator {
3
+ protected migrationDir: string;
4
+ protected migrationList: string[];
5
+ protected pool: PoolClient;
6
+ constructor(migrationDir: string, migrationList: string[], pool: PoolClient);
7
+ protected ensureMigrationTableExists(): Promise<import("pg").QueryResult<any>>;
8
+ protected getAppliedMigrations(): Promise<any[]>;
9
+ protected applyMigration(migration: string, sql: string): Promise<void>;
10
+ protected getPending(migrationsList: string[], appliedMigrations: string[]): Promise<string[]>;
11
+ protected getSql(migration: string): Promise<string>;
12
+ protected tryToObtainLock(): Promise<boolean>;
13
+ protected releaseLock(): Promise<void>;
14
+ migrate(): Promise<any>;
15
+ protected runMigrations(): Promise<void>;
16
+ protected runMigration(migration: string): Promise<void>;
17
+ protected dispose(): void;
18
+ }
@@ -0,0 +1,268 @@
1
+ export declare enum PostgresErrorCode {
2
+ SUCCESSFUL_COMPLETION = "00000",
3
+ WARNING = "01000",
4
+ WARNING_DYNAMIC_RESULT_SETS_RETURNED = "0100C",
5
+ WARNING_IMPLICIT_ZERO_BIT_PADDING = "01008",
6
+ WARNING_NULL_VALUE_ELIMINATED_IN_SET_FUNCTION = "01003",
7
+ WARNING_PRIVILEGE_NOT_GRANTED = "01007",
8
+ WARNING_PRIVILEGE_NOT_REVOKED = "01006",
9
+ WARNING_STRING_DATA_RIGHT_TRUNCATION = "01004",
10
+ WARNING_DEPRECATED_FEATURE = "01P01",
11
+ NO_DATA = "02000",
12
+ NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED = "02001",
13
+ SQL_STATEMENT_NOT_YET_COMPLETE = "03000",
14
+ CONNECTION_EXCEPTION = "08000",
15
+ CONNECTION_DOES_NOT_EXIST = "08003",
16
+ CONNECTION_FAILURE = "08006",
17
+ SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION = "08001",
18
+ SQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION = "08004",
19
+ TRANSACTION_RESOLUTION_UNKNOWN = "08007",
20
+ PROTOCOL_VIOLATION = "08P01",
21
+ TRIGGERED_ACTION_EXCEPTION = "09000",
22
+ FEATURE_NOT_SUPPORTED = "0A000",
23
+ INVALID_TRANSACTION_INITIATION = "0B000",
24
+ LOCATOR_EXCEPTION = "0F000",
25
+ L_E_INVALID_SPECIFICATION = "0F001",
26
+ INVALID_GRANTOR = "0L000",
27
+ INVALID_GRANT_OPERATION = "0LP01",
28
+ INVALID_ROLE_SPECIFICATION = "0P000",
29
+ DIAGNOSTICS_EXCEPTION = "0Z000",
30
+ STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER = "0Z002",
31
+ CASE_NOT_FOUND = "20000",
32
+ CARDINALITY_VIOLATION = "21000",
33
+ DATA_EXCEPTION = "22000",
34
+ ARRAY_ELEMENT_ERROR = "2202E",
35
+ ARRAY_SUBSCRIPT_ERROR = "2202E",
36
+ CHARACTER_NOT_IN_REPERTOIRE = "22021",
37
+ DATETIME_FIELD_OVERFLOW = "22008",
38
+ DATETIME_VALUE_OUT_OF_RANGE = "22008",
39
+ DIVISION_BY_ZERO = "22012",
40
+ ERROR_IN_ASSIGNMENT = "22005",
41
+ ESCAPE_CHARACTER_CONFLICT = "2200B",
42
+ INDICATOR_OVERFLOW = "22022",
43
+ INTERVAL_FIELD_OVERFLOW = "22015",
44
+ INVALID_ARGUMENT_FOR_LOG = "2201E",
45
+ INVALID_ARGUMENT_FOR_NTILE = "22014",
46
+ INVALID_ARGUMENT_FOR_NTH_VALUE = "22016",
47
+ INVALID_ARGUMENT_FOR_POWER_FUNCTION = "2201F",
48
+ INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION = "2201G",
49
+ INVALID_CHARACTER_VALUE_FOR_CAST = "22018",
50
+ INVALID_DATETIME_FORMAT = "22007",
51
+ INVALID_ESCAPE_CHARACTER = "22019",
52
+ INVALID_ESCAPE_OCTET = "2200D",
53
+ INVALID_ESCAPE_SEQUENCE = "22025",
54
+ NONSTANDARD_USE_OF_ESCAPE_CHARACTER = "22P06",
55
+ INVALID_INDICATOR_PARAMETER_VALUE = "22010",
56
+ INVALID_PARAMETER_VALUE = "22023",
57
+ INVALID_PRECEDING_OR_FOLLOWING_SIZE = "22013",
58
+ INVALID_REGULAR_EXPRESSION = "2201B",
59
+ INVALID_ROW_COUNT_IN_LIMIT_CLAUSE = "2201W",
60
+ INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE = "2201X",
61
+ INVALID_TABLESAMPLE_ARGUMENT = "2202H",
62
+ INVALID_TABLESAMPLE_REPEAT = "2202G",
63
+ INVALID_TIME_ZONE_DISPLACEMENT_VALUE = "22009",
64
+ INVALID_USE_OF_ESCAPE_CHARACTER = "2200C",
65
+ MOST_SPECIFIC_TYPE_MISMATCH = "2200G",
66
+ NULL_VALUE_NOT_ALLOWED = "22004",
67
+ NULL_VALUE_NO_INDICATOR_PARAMETER = "22002",
68
+ NUMERIC_VALUE_OUT_OF_RANGE = "22003",
69
+ SEQUENCE_GENERATOR_LIMIT_EXCEEDED = "2200H",
70
+ STRING_DATA_LENGTH_MISMATCH = "22026",
71
+ STRING_DATA_RIGHT_TRUNCATION = "22001",
72
+ SUBSTRING_ERROR = "22011",
73
+ TRIM_ERROR = "22027",
74
+ UNTERMINATED_C_STRING = "22024",
75
+ ZERO_LENGTH_CHARACTER_STRING = "2200F",
76
+ FLOATING_POINT_EXCEPTION = "22P01",
77
+ INVALID_TEXT_REPRESENTATION = "22P02",
78
+ INVALID_BINARY_REPRESENTATION = "22P03",
79
+ BAD_COPY_FILE_FORMAT = "22P04",
80
+ UNTRANSLATABLE_CHARACTER = "22P05",
81
+ NOT_AN_XML_DOCUMENT = "2200L",
82
+ INVALID_XML_DOCUMENT = "2200M",
83
+ INVALID_XML_CONTENT = "2200N",
84
+ INVALID_XML_COMMENT = "2200S",
85
+ INVALID_XML_PROCESSING_INSTRUCTION = "2200T",
86
+ DUPLICATE_JSON_OBJECT_KEY_VALUE = "22030",
87
+ INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION = "22031",
88
+ INVALID_JSON_TEXT = "22032",
89
+ INVALID_SQL_JSON_SUBSCRIPT = "22033",
90
+ MORE_THAN_ONE_SQL_JSON_ITEM = "22034",
91
+ NO_SQL_JSON_ITEM = "22035",
92
+ NON_NUMERIC_SQL_JSON_ITEM = "22036",
93
+ NON_UNIQUE_KEYS_IN_A_JSON_OBJECT = "22037",
94
+ SINGLETON_SQL_JSON_ITEM_REQUIRED = "22038",
95
+ SQL_JSON_ARRAY_NOT_FOUND = "22039",
96
+ SQL_JSON_MEMBER_NOT_FOUND = "2203A",
97
+ SQL_JSON_NUMBER_NOT_FOUND = "2203B",
98
+ SQL_JSON_OBJECT_NOT_FOUND = "2203C",
99
+ TOO_MANY_JSON_ARRAY_ELEMENTS = "2203D",
100
+ TOO_MANY_JSON_OBJECT_MEMBERS = "2203E",
101
+ SQL_JSON_SCALAR_REQUIRED = "2203F",
102
+ SQL_JSON_ITEM_CANNOT_BE_CAST_TO_TARGET_TYPE = "2203G",
103
+ INTEGRITY_CONSTRAINT_VIOLATION = "23000",
104
+ RESTRICT_VIOLATION = "23001",
105
+ NOT_NULL_VIOLATION = "23502",
106
+ FOREIGN_KEY_VIOLATION = "23503",
107
+ UNIQUE_VIOLATION = "23505",
108
+ CHECK_VIOLATION = "23514",
109
+ EXCLUSION_VIOLATION = "23P01",
110
+ INVALID_CURSOR_STATE = "24000",
111
+ INVALID_TRANSACTION_STATE = "25000",
112
+ ACTIVE_SQL_TRANSACTION = "25001",
113
+ BRANCH_TRANSACTION_ALREADY_ACTIVE = "25002",
114
+ HELD_CURSOR_REQUIRES_SAME_ISOLATION_LEVEL = "25008",
115
+ INAPPROPRIATE_ACCESS_MODE_FOR_BRANCH_TRANSACTION = "25003",
116
+ INAPPROPRIATE_ISOLATION_LEVEL_FOR_BRANCH_TRANSACTION = "25004",
117
+ NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION = "25005",
118
+ READ_ONLY_SQL_TRANSACTION = "25006",
119
+ SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED = "25007",
120
+ NO_ACTIVE_SQL_TRANSACTION = "25P01",
121
+ IN_FAILED_SQL_TRANSACTION = "25P02",
122
+ IDLE_IN_TRANSACTION_SESSION_TIMEOUT = "25P03",
123
+ INVALID_SQL_STATEMENT_NAME = "26000",
124
+ TRIGGERED_DATA_CHANGE_VIOLATION = "27000",
125
+ INVALID_AUTHORIZATION_SPECIFICATION = "28000",
126
+ INVALID_PASSWORD = "28P01",
127
+ DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST = "2B000",
128
+ DEPENDENT_OBJECTS_STILL_EXIST = "2BP01",
129
+ INVALID_TRANSACTION_TERMINATION = "2D000",
130
+ SQL_ROUTINE_EXCEPTION = "2F000",
131
+ S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT = "2F005",
132
+ S_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED = "2F002",
133
+ S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED = "2F003",
134
+ S_R_E_READING_SQL_DATA_NOT_PERMITTED = "2F004",
135
+ INVALID_CURSOR_NAME = "34000",
136
+ EXTERNAL_ROUTINE_EXCEPTION = "38000",
137
+ E_R_E_CONTAINING_SQL_NOT_PERMITTED = "38001",
138
+ E_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED = "38002",
139
+ E_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED = "38003",
140
+ E_R_E_READING_SQL_DATA_NOT_PERMITTED = "38004",
141
+ EXTERNAL_ROUTINE_INVOCATION_EXCEPTION = "39000",
142
+ E_R_I_E_INVALID_SQLSTATE_RETURNED = "39001",
143
+ E_R_I_E_NULL_VALUE_NOT_ALLOWED = "39004",
144
+ E_R_I_E_TRIGGER_PROTOCOL_VIOLATED = "39P01",
145
+ E_R_I_E_SRF_PROTOCOL_VIOLATED = "39P02",
146
+ E_R_I_E_EVENT_TRIGGER_PROTOCOL_VIOLATED = "39P03",
147
+ SAVEPOINT_EXCEPTION = "3B000",
148
+ S_E_INVALID_SPECIFICATION = "3B001",
149
+ INVALID_CATALOG_NAME = "3D000",
150
+ INVALID_SCHEMA_NAME = "3F000",
151
+ TRANSACTION_ROLLBACK = "40000",
152
+ T_R_INTEGRITY_CONSTRAINT_VIOLATION = "40002",
153
+ T_R_SERIALIZATION_FAILURE = "40001",
154
+ T_R_STATEMENT_COMPLETION_UNKNOWN = "40003",
155
+ T_R_DEADLOCK_DETECTED = "40P01",
156
+ SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION = "42000",
157
+ SYNTAX_ERROR = "42601",
158
+ INSUFFICIENT_PRIVILEGE = "42501",
159
+ CANNOT_COERCE = "42846",
160
+ GROUPING_ERROR = "42803",
161
+ WINDOWING_ERROR = "42P20",
162
+ INVALID_RECURSION = "42P19",
163
+ INVALID_FOREIGN_KEY = "42830",
164
+ INVALID_NAME = "42602",
165
+ NAME_TOO_LONG = "42622",
166
+ RESERVED_NAME = "42939",
167
+ DATATYPE_MISMATCH = "42804",
168
+ INDETERMINATE_DATATYPE = "42P18",
169
+ COLLATION_MISMATCH = "42P21",
170
+ INDETERMINATE_COLLATION = "42P22",
171
+ WRONG_OBJECT_TYPE = "42809",
172
+ GENERATED_ALWAYS = "428C9",
173
+ UNDEFINED_COLUMN = "42703",
174
+ UNDEFINED_CURSOR = "34000",
175
+ UNDEFINED_DATABASE = "3D000",
176
+ UNDEFINED_FUNCTION = "42883",
177
+ UNDEFINED_PSTATEMENT = "26000",
178
+ UNDEFINED_SCHEMA = "3F000",
179
+ UNDEFINED_TABLE = "42P01",
180
+ UNDEFINED_PARAMETER = "42P02",
181
+ UNDEFINED_OBJECT = "42704",
182
+ DUPLICATE_COLUMN = "42701",
183
+ DUPLICATE_CURSOR = "42P03",
184
+ DUPLICATE_DATABASE = "42P04",
185
+ DUPLICATE_FUNCTION = "42723",
186
+ DUPLICATE_PSTATEMENT = "42P05",
187
+ DUPLICATE_SCHEMA = "42P06",
188
+ DUPLICATE_TABLE = "42P07",
189
+ DUPLICATE_ALIAS = "42712",
190
+ DUPLICATE_OBJECT = "42710",
191
+ AMBIGUOUS_COLUMN = "42702",
192
+ AMBIGUOUS_FUNCTION = "42725",
193
+ AMBIGUOUS_PARAMETER = "42P08",
194
+ AMBIGUOUS_ALIAS = "42P09",
195
+ INVALID_COLUMN_REFERENCE = "42P10",
196
+ INVALID_COLUMN_DEFINITION = "42611",
197
+ INVALID_CURSOR_DEFINITION = "42P11",
198
+ INVALID_DATABASE_DEFINITION = "42P12",
199
+ INVALID_FUNCTION_DEFINITION = "42P13",
200
+ INVALID_PSTATEMENT_DEFINITION = "42P14",
201
+ INVALID_SCHEMA_DEFINITION = "42P15",
202
+ INVALID_TABLE_DEFINITION = "42P16",
203
+ INVALID_OBJECT_DEFINITION = "42P17",
204
+ WITH_CHECK_OPTION_VIOLATION = "44000",
205
+ INSUFFICIENT_RESOURCES = "53000",
206
+ DISK_FULL = "53100",
207
+ OUT_OF_MEMORY = "53200",
208
+ TOO_MANY_CONNECTIONS = "53300",
209
+ CONFIGURATION_LIMIT_EXCEEDED = "53400",
210
+ PROGRAM_LIMIT_EXCEEDED = "54000",
211
+ STATEMENT_TOO_COMPLEX = "54001",
212
+ TOO_MANY_COLUMNS = "54011",
213
+ TOO_MANY_ARGUMENTS = "54023",
214
+ OBJECT_NOT_IN_PREREQUISITE_STATE = "55000",
215
+ OBJECT_IN_USE = "55006",
216
+ CANT_CHANGE_RUNTIME_PARAM = "55P02",
217
+ LOCK_NOT_AVAILABLE = "55P03",
218
+ UNSAFE_NEW_ENUM_VALUE_USAGE = "55P04",
219
+ OPERATOR_INTERVENTION = "57000",
220
+ QUERY_CANCELED = "57014",
221
+ ADMIN_SHUTDOWN = "57P01",
222
+ CRASH_SHUTDOWN = "57P02",
223
+ CANNOT_CONNECT_NOW = "57P03",
224
+ DATABASE_DROPPED = "57P04",
225
+ IDLE_SESSION_TIMEOUT = "57P05",
226
+ SYSTEM_ERROR = "58000",
227
+ IO_ERROR = "58030",
228
+ UNDEFINED_FILE = "58P01",
229
+ DUPLICATE_FILE = "58P02",
230
+ SNAPSHOT_TOO_OLD = "72000",
231
+ CONFIG_FILE_ERROR = "F0000",
232
+ LOCK_FILE_EXISTS = "F0001",
233
+ FDW_ERROR = "HV000",
234
+ FDW_COLUMN_NAME_NOT_FOUND = "HV005",
235
+ FDW_DYNAMIC_PARAMETER_VALUE_NEEDED = "HV002",
236
+ FDW_FUNCTION_SEQUENCE_ERROR = "HV010",
237
+ FDW_INCONSISTENT_DESCRIPTOR_INFORMATION = "HV021",
238
+ FDW_INVALID_ATTRIBUTE_VALUE = "HV024",
239
+ FDW_INVALID_COLUMN_NAME = "HV007",
240
+ FDW_INVALID_COLUMN_NUMBER = "HV008",
241
+ FDW_INVALID_DATA_TYPE = "HV004",
242
+ FDW_INVALID_DATA_TYPE_DESCRIPTORS = "HV006",
243
+ FDW_INVALID_DESCRIPTOR_FIELD_IDENTIFIER = "HV091",
244
+ FDW_INVALID_HANDLE = "HV00B",
245
+ FDW_INVALID_OPTION_INDEX = "HV00C",
246
+ FDW_INVALID_OPTION_NAME = "HV00D",
247
+ FDW_INVALID_STRING_LENGTH_OR_BUFFER_LENGTH = "HV090",
248
+ FDW_INVALID_STRING_FORMAT = "HV00A",
249
+ FDW_INVALID_USE_OF_NULL_POINTER = "HV009",
250
+ FDW_TOO_MANY_HANDLES = "HV014",
251
+ FDW_OUT_OF_MEMORY = "HV001",
252
+ FDW_NO_SCHEMAS = "HV00P",
253
+ FDW_OPTION_NAME_NOT_FOUND = "HV00J",
254
+ FDW_REPLY_HANDLE = "HV00K",
255
+ FDW_SCHEMA_NOT_FOUND = "HV00Q",
256
+ FDW_TABLE_NOT_FOUND = "HV00R",
257
+ FDW_UNABLE_TO_CREATE_EXECUTION = "HV00L",
258
+ FDW_UNABLE_TO_CREATE_REPLY = "HV00M",
259
+ FDW_UNABLE_TO_ESTABLISH_CONNECTION = "HV00N",
260
+ PLPGSQL_ERROR = "P0000",
261
+ RAISE_EXCEPTION = "P0001",
262
+ NO_DATA_FOUND = "P0002",
263
+ TOO_MANY_ROWS = "P0003",
264
+ ASSERT_FAILURE = "P0004",
265
+ INTERNAL_ERROR = "XX000",
266
+ DATA_CORRUPTED = "XX001",
267
+ INDEX_CORRUPTED = "XX002"
268
+ }
@@ -0,0 +1,2 @@
1
+ import { Repository } from './AbstractRepository';
2
+ export declare type Repositories = Record<string, Repository<any>>;
@@ -0,0 +1,5 @@
1
+ import { DbConnection } from './ConnectionManager';
2
+ export declare function getConnectionInfo(config: {
3
+ databaseConnectionSecret?: string | false;
4
+ databaseConnectionString?: string | false;
5
+ }): Promise<DbConnection | string>;
package/lib/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from './AbstractRepository';
2
+ export * from './ConnectionManager';
3
+ export * from './Migrator';
4
+ export * from './Repositories';
5
+ export * from './getConnectionInfo';
6
+ export * from './PostgresErrorCodes';