pg-promise 10.4.3 → 10.5.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/README.md CHANGED
@@ -555,15 +555,15 @@ The only difference from [Explicit CTF] is that we set `toPostgres` and `rawType
555
555
  defined in the [ctf] namespace:
556
556
 
557
557
  ```js
558
- const ctf = pgp.as.ctf; // Global CTF symbols
558
+ const {toPostgres, rawType} = pgp.as.ctf; // Global CTF symbols
559
559
 
560
560
  const obj = {
561
- [ctf.toPostgres](self) {
561
+ [toPostgres](self) {
562
562
  // self = this = obj
563
563
 
564
564
  // return a pre-formatted value that does not need escaping
565
565
  },
566
- [ctf.rawType]: true // use result from toPostgres directly, as Raw Text
566
+ [rawType]: true // use result from toPostgres directly, as Raw Text
567
567
  };
568
568
  ```
569
569
 
@@ -885,8 +885,7 @@ savepoint names, based on the transaction level.
885
885
  [TransactionMode] type can extend your `BEGIN` command with transaction configuration:
886
886
 
887
887
  ```js
888
- const TransactionMode = pgp.txMode.TransactionMode;
889
- const isolationLevel = pgp.txMode.isolationLevel;
888
+ const {TransactionMode, isolationLevel} = pgp.txMode;
890
889
 
891
890
  // Create a reusable transaction mode (serializable + read-only + deferrable):
892
891
  const mode = new TransactionMode({
@@ -975,8 +974,7 @@ db.txIf({cnd}, t => {
975
974
  This library manages all database connections via the [connection pool], which internally caches them.
976
975
 
977
976
  Connections in the cache expire due to inactivity after [idleTimeoutMillis] number of milliseconds, which you
978
- can adjust when creating the [Database] object, or override the default via `pgp.pg.defaults.idleTimeoutMillis`
979
- before creating the [Database] object.
977
+ can set only when creating the [Database] object.
980
978
 
981
979
  While there is a single open connection in the pool, the process cannot terminate by itself, only via `process.exit()`.
982
980
  If you want the process to finish by itself, without waiting for all connections in the pool to expire, you need
@@ -1110,6 +1108,6 @@ for detailed changes between versions you should see the corresponding release n
1110
1108
  [Bluebird]:https://github.com/petkaantonov/bluebird
1111
1109
  [SQL injection]:https://en.wikipedia.org/wiki/SQL_injection
1112
1110
  [Symbol]:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol
1113
- [idleTimeoutMillis]:https://github.com/brianc/node-postgres/blob/master/lib/defaults.js#L46
1111
+ [idleTimeoutMillis]:https://github.com/brianc/node-postgres/blob/master/packages/pg/lib/defaults.js#L46
1114
1112
  [connection pool]:https://github.com/brianc/node-pg-pool
1115
1113
  [Error]:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
package/lib/connect.js CHANGED
@@ -45,7 +45,6 @@ function poolConnect(ctx, db, config) {
45
45
  enumerable: false,
46
46
  writable: true
47
47
  });
48
- hidePassword(client); // See: https://github.com/brianc/node-postgres/issues/1568
49
48
  setSchema(client, ctx);
50
49
  }
51
50
  setCtx(client, ctx);
@@ -78,7 +77,6 @@ function directConnect(ctx, config) {
78
77
  });
79
78
  reject(err);
80
79
  } else {
81
- hidePassword(client); // See: https://github.com/brianc/node-postgres/issues/1568
82
80
  setSchema(client, ctx);
83
81
  setCtx(client, ctx);
84
82
  const end = lockClientEnd(client);
@@ -142,16 +140,6 @@ function setCtx(client, ctx) {
142
140
  });
143
141
  }
144
142
 
145
- // See: https://github.com/brianc/node-postgres/issues/1568
146
- function hidePassword(client) {
147
- hideProperty(client, `password`);
148
- hideProperty(client.connectionParameters, `password`);
149
- }
150
-
151
- function hideProperty(obj, prop) {
152
- Object.defineProperty(obj, prop, {value: obj[prop], enumerable: false});
153
- }
154
-
155
143
  function setSchema(client, ctx) {
156
144
  let s = ctx.options.schema;
157
145
  if (!s) {
@@ -23,6 +23,7 @@ class ColorConsole {
23
23
  }
24
24
 
25
25
  static writeNormal(params, color) {
26
+ // istanbul ignore else
26
27
  if (process.stdout.isTTY) {
27
28
  console.log.apply(null, ColorConsole.formatColor(params, color)); // eslint-disable-line no-console
28
29
  } else {
@@ -31,6 +32,7 @@ class ColorConsole {
31
32
  }
32
33
 
33
34
  static writeError(params, color) {
35
+ // istanbul ignore else
34
36
  if (process.stderr.isTTY) {
35
37
  console.error.apply(null, ColorConsole.formatColor(params, color)); // eslint-disable-line no-console
36
38
  } else {
@@ -80,6 +80,7 @@ function addReadProp(obj, name, value, hidden) {
80
80
  // Converts a connection string or object into its safe copy:
81
81
  // if password is present, it is masked with symbol '#'.
82
82
  function getSafeConnection(cn) {
83
+ const maskPassword = cs => cs.replace(/:(?![/])([^@]+)/, (_, m) => `:` + new Array(m.length + 1).join(`#`));
83
84
  if (typeof cn === `object`) {
84
85
  const copy = Object.assign({}, cn);
85
86
  if (typeof copy.password === `string`) {
@@ -93,14 +94,6 @@ function getSafeConnection(cn) {
93
94
  return maskPassword(cn);
94
95
  }
95
96
 
96
- ///////////////////////////////////////////////////////////
97
- // Replaces password letters with # in a connection string.
98
- function maskPassword(connectionString) {
99
- return connectionString.replace(/:(?![/])([^@]+)/, (_, m) => {
100
- return `:` + new Array(m.length + 1).join(`#`);
101
- });
102
- }
103
-
104
97
  ///////////////////////////////////////////
105
98
  // Returns a space gap for console output;
106
99
  function messageGap(level) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg-promise",
3
- "version": "10.4.3",
3
+ "version": "10.5.0",
4
4
  "description": "PostgreSQL interface for Node.js",
5
5
  "main": "lib/index.js",
6
6
  "typings": "typescript/pg-promise.d.ts",
@@ -8,9 +8,9 @@
8
8
  "test": "jasmine-node --captureExceptions test",
9
9
  "test:native": "jasmine-node test --config PG_NATIVE true",
10
10
  "doc": "./node_modules/.bin/jsdoc -c ./jsdoc/jsdoc.js ./jsdoc/README.md -t ./jsdoc/templates/custom",
11
- "coverage": "istanbul cover ./node_modules/jasmine-node/bin/jasmine-node test -x lib/utils/color.js",
11
+ "coverage": "istanbul cover ./node_modules/jasmine-node/bin/jasmine-node test",
12
12
  "travis": "npm run lint && npm run tslint && npm run coverage --captureExceptions && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
13
- "lint": "./node_modules/.bin/eslint ./lib ./test/*.js ./test/db",
13
+ "lint": "./node_modules/.bin/eslint ./lib ./test/*.js ./test/db --fix",
14
14
  "tslint": "./node_modules/.bin/tslint ./typescript/*.ts"
15
15
  },
16
16
  "files": [
@@ -41,21 +41,21 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "assert-options": "0.6.1",
44
- "pg": "7.18.1",
44
+ "pg": "8.0.0",
45
45
  "pg-minify": "1.5.2",
46
46
  "spex": "3.0.1"
47
47
  },
48
48
  "devDependencies": {
49
- "@types/node": "13.7.0",
49
+ "@types/node": "13.9.8",
50
50
  "JSONStream": "1.3.5",
51
51
  "bluebird": "3.7.2",
52
- "coveralls": "3.0.9",
52
+ "coveralls": "3.0.11",
53
53
  "eslint": "6.8.0",
54
- "tslint": "6.0.0",
54
+ "tslint": "6.1.0",
55
55
  "istanbul": "0.4.5",
56
56
  "jasmine-node": "3.0.0",
57
57
  "jsdoc": "3.6.3",
58
- "pg-query-stream": "3.0.2",
59
- "typescript": "3.7.5"
58
+ "pg-query-stream": "3.0.4",
59
+ "typescript": "3.8.3"
60
60
  }
61
61
  }
@@ -13,7 +13,7 @@
13
13
  // Calling it 'pg-subset' to avoid a conflict in case the application also
14
14
  // includes the official 'pg' typings.
15
15
  //
16
- // Supported version of pg: 7.14.0 and later.
16
+ // Supported version of pg: 8.0.0 and later.
17
17
  //
18
18
  // pg: https://github.com/brianc/node-postgres
19
19
  //////////////////////////////////////////////////////////////////////////////
@@ -74,7 +74,7 @@ declare namespace pg {
74
74
  type DynamicPassword = string | (() => string) | (() => Promise<string>);
75
75
 
76
76
  // See:
77
- // 1) https://github.com/brianc/node-postgres/blob/master/lib/defaults.js
77
+ // 1) https://github.com/brianc/node-postgres/blob/master/packages/pg/lib/defaults.js
78
78
  // 2) https://github.com/brianc/node-pg-pool
79
79
  interface IConnectionParameters<C extends IClient = IClient> {
80
80
  connectionString?: string
@@ -212,9 +212,13 @@ declare namespace pg {
212
212
  // 0 will disable connection pooling
213
213
  max: number
214
214
 
215
- // max milliseconds a client can go unused before it is removed
216
- // from the pool and destroyed
217
- idleTimeoutMillis: number
215
+ // max milliseconds a client can go unused before it is removed from the pool and destroyed;
216
+ //
217
+ // Made unavailable in v10.5.0, due to the following:
218
+ // - https://github.com/brianc/node-postgres/issues/2139
219
+ // - https://github.com/vitaly-t/pg-promise/issues/703
220
+ //
221
+ // idleTimeoutMillis: number
218
222
 
219
223
  client_encoding: string
220
224