ismx-nexo-node-app 0.3.52 → 0.3.53

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.
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
26
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
27
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -12,7 +35,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
36
  };
14
37
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const pg_1 = __importDefault(require("pg"));
16
38
  const PostgresUtils_1 = __importDefault(require("./utils/PostgresUtils"));
17
39
  const RepositoryDatabase_1 = __importDefault(require("./RepositoryDatabase"));
18
40
  class RepositoryDatabasePostgres extends RepositoryDatabase_1.default {
@@ -28,20 +50,22 @@ class RepositoryDatabasePostgres extends RepositoryDatabase_1.default {
28
50
  super.init(chain);
29
51
  this.connect(chain);
30
52
  }
31
- addOnIntrospectedListener(listener) {
32
- this.onIntrospectedListeners.push(listener);
33
- }
34
53
  connect(connection) {
35
54
  return __awaiter(this, void 0, void 0, function* () {
36
- this.client = new pg_1.default.Client(connection);
37
- return this.client.connect().then(() => __awaiter(this, void 0, void 0, function* () {
38
- yield this.introspect();
39
- setInterval(this.introspect, this.introspectIntervalTime);
40
- this.connected = true;
41
- this.onConnectListeners.map(l => l());
42
- }));
55
+ Promise.resolve().then(() => __importStar(require("pg"))).then(({ default: pg }) => {
56
+ this.client = new pg.Client(connection);
57
+ return this.client.connect().then(() => __awaiter(this, void 0, void 0, function* () {
58
+ yield this.introspect();
59
+ setInterval(this.introspect, this.introspectIntervalTime);
60
+ this.connected = true;
61
+ this.onConnectListeners.map(l => l());
62
+ }));
63
+ });
43
64
  });
44
65
  }
66
+ addOnIntrospectedListener(listener) {
67
+ this.onIntrospectedListeners.push(listener);
68
+ }
45
69
  native(query_1) {
46
70
  return __awaiter(this, arguments, void 0, function* (query, values = [], options = {}) {
47
71
  this.onQueryWillExecuteListeners.forEach((l) => l(query));
@@ -1,4 +1,3 @@
1
- import pg, { QueryResult } from "pg";
2
1
  import RepositoryDatabase, { Chain, Primitive, QueryOptions } from "./RepositoryDatabase";
3
2
  import { Pagination } from "./Repository";
4
3
  export interface Column {
@@ -8,16 +7,16 @@ export interface Column {
8
7
  }
9
8
  export default class RepositoryDatabasePostgres extends RepositoryDatabase {
10
9
  private readonly introspectIntervalTime;
11
- protected client: pg.Client;
10
+ protected client: any;
12
11
  private tables;
13
12
  constructor();
14
13
  init(chain: Chain): void;
14
+ connect(connection: Chain): Promise<void>;
15
15
  private onIntrospectedListeners;
16
16
  addOnIntrospectedListener(listener: (tables: {
17
17
  [key: string]: Column[];
18
18
  }) => void): void;
19
- connect(connection: Chain): Promise<void>;
20
- native(query: string, values?: any[], options?: QueryOptions): Promise<QueryResult>;
19
+ native(query: string, values?: any[], options?: QueryOptions): Promise<any>;
21
20
  query<E>(query: string, values?: any[], options?: QueryOptions): Promise<E[]>;
22
21
  one<E>(tableName: string, id: string): Promise<E>;
23
22
  any<E>(tableName: string, filters?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ismx-nexo-node-app",
3
- "version": "0.3.52",
3
+ "version": "0.3.53",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "rm -rf ./dist && npx tsc",
@@ -1,4 +1,3 @@
1
- import pg, {ClientConfig, QueryResult, QueryResultRow} from "pg";
2
1
  import PostgresUtils from "./utils/PostgresUtils";
3
2
  import RepositoryDatabase, {Chain, Primitive, QueryOptions} from "./RepositoryDatabase";
4
3
  import {Pagination} from "./Repository";
@@ -13,7 +12,7 @@ export default class RepositoryDatabasePostgres extends RepositoryDatabase
13
12
  {
14
13
  private readonly introspectIntervalTime: number = 60 * 60 * 1000;
15
14
 
16
- protected client!: pg.Client;
15
+ protected client!: any;
17
16
 
18
17
  private tables: { [key: string]: Column[] } = {};
19
18
 
@@ -29,22 +28,26 @@ export default class RepositoryDatabasePostgres extends RepositoryDatabase
29
28
  this.connect(chain);
30
29
  }
31
30
 
31
+ async connect(connection: Chain): Promise<void> {
32
+
33
+ import("pg").then(({ default: pg }) => {
34
+ this.client = new pg.Client(connection);
35
+ return this.client.connect().then(async () => {
36
+ await this.introspect();
37
+ setInterval(this.introspect, this.introspectIntervalTime);
38
+ this.connected = true;
39
+ this.onConnectListeners.map(l => l());
40
+ });
41
+ });
42
+ }
43
+
32
44
  private onIntrospectedListeners: ((tables: {[key: string]:Column[]})=>void)[] = [];
45
+
33
46
  addOnIntrospectedListener(listener: (tables: {[key: string]:Column[]})=>void): void {
34
47
  this.onIntrospectedListeners.push(listener);
35
48
  }
36
49
 
37
- async connect(connection: Chain): Promise<void> {
38
- this.client = new pg.Client(connection);
39
- return this.client.connect().then(async () => {
40
- await this.introspect();
41
- setInterval(this.introspect, this.introspectIntervalTime);
42
- this.connected = true;
43
- this.onConnectListeners.map(l => l());
44
- });
45
- }
46
-
47
- async native(query: string, values: any[] = [], options: QueryOptions = {}): Promise<QueryResult>
50
+ async native(query: string, values: any[] = [], options: QueryOptions = {}): Promise<any>
48
51
  {
49
52
  this.onQueryWillExecuteListeners.forEach((l) => l(query));
50
53
  let cursor = this.client.query(query, values);