@squiz/db-lib 1.2.1-alpha.87 → 1.2.1-alpha.89

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [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)
7
+
8
+ **Note:** Version bump only for package @squiz/db-lib
9
+
10
+
11
+
12
+
13
+
14
+ ## [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)
15
+
16
+ **Note:** Version bump only for package @squiz/db-lib
17
+
18
+
19
+
20
+
21
+
6
22
  ## [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)
7
23
 
8
24
  **Note:** Version bump only for package @squiz/db-lib
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squiz/db-lib",
3
- "version": "1.2.1-alpha.87",
3
+ "version": "1.2.1-alpha.89",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -33,5 +33,5 @@
33
33
  "dotenv": "16.0.1",
34
34
  "pg": "^8.7.3"
35
35
  },
36
- "gitHead": "9fab33400739f1a068955ffb5c09834271c1c7ee"
36
+ "gitHead": "d42ff3393c6e336ee05519872dbb58112ef045d1"
37
37
  }
@@ -1,41 +0,0 @@
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 (): T;
18
- };
19
- protected tableName: string;
20
- protected modelPropertyToSqlColumn: {
21
- [key in keyof T]: string;
22
- };
23
- protected sqlColumnToModelProperty: {
24
- [key: string]: keyof T;
25
- };
26
- constructor(repositories: Repositories, pool: Pool, tableName: string, mapping: {
27
- [key in keyof T]: string;
28
- }, classRef: {
29
- new (): T;
30
- });
31
- protected getConnection(): Promise<PoolClient>;
32
- create(value: Partial<T>, transactionClient?: PoolClient | null): Promise<T>;
33
- update(where: Partial<T>, newValue: Partial<T>, transactionClient?: PoolClient | null): Promise<T[]>;
34
- delete(where: Partial<T>, transactionClient?: PoolClient | null): Promise<number>;
35
- protected createWhereStringFromPartialModel(values: Partial<T>, initialIndex?: number): string;
36
- protected executeQuery(query: string, values: any[], transactionClient?: PoolClient | null): Promise<T[]>;
37
- protected createAndHydrateModel(row: any): T;
38
- findOne(item: Partial<T>): Promise<T | undefined>;
39
- find(item: Partial<T>): Promise<T[]>;
40
- findAll(): Promise<T[]>;
41
- }
@@ -1,25 +0,0 @@
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
- }
package/lib/Migrator.d.ts DELETED
@@ -1,18 +0,0 @@
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
- }
@@ -1,2 +0,0 @@
1
- import { Repository } from './AbstractRepository';
2
- export declare type Repositories = Record<string, Repository<any>>;
@@ -1,5 +0,0 @@
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 DELETED
@@ -1,5 +0,0 @@
1
- export * from './AbstractRepository';
2
- export * from './ConnectionManager';
3
- export * from './Migrator';
4
- export * from './Repositories';
5
- export * from './getConnectionInfo';