Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pg-promise

Package Overview
Dependencies
Maintainers
1
Versions
629
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-promise - npm Package Compare versions

Comparing version 10.15.4 to 11.0.0

45

lib/events.js

@@ -31,10 +31,12 @@ /*

*
* @param {external:Client} client
* @param {{}} e Event Properties
*
* @param {external:Client} e.client
* $[pg.Client] object that represents the connection.
*
* @param {*} dc
* @param {*} e.dc
* Database Context that was used when creating the database object (see {@link Database}).
*
* @param {number} useCount
* Number of times the connection has been previously used, starting with 0 for a freshly
* @param {number} e.useCount
* Number of times the connection has been previously used, starting with 0, for a freshly
* allocated physical connection.

@@ -51,4 +53,4 @@ *

*
* connect(client, dc, useCount) {
* const cp = client.connectionParameters;
* connect(e) {
* const cp = e.client.connectionParameters;
* console.log('Connected to database:', cp.database);

@@ -62,3 +64,3 @@ * }

try {
ctx.options.connect(client, ctx.dc, useCount);
ctx.options.connect({client, dc: ctx.dc, useCount});
} catch (e) {

@@ -83,6 +85,8 @@ // have to silence errors here;

*
* @param {external:Client} client - $[pg.Client] object that represents connection with the database.
* @param {{}} e Event Properties
*
* @param {*} dc - Database Context that was used when creating the database object (see {@link Database}).
* @param {external:Client} e.client - $[pg.Client] object that represents connection with the database.
*
* @param {*} e.dc - Database Context that was used when creating the database object (see {@link Database}).
*
* @example

@@ -94,4 +98,4 @@ *

*
* disconnect(client, dc) {
* const cp = client.connectionParameters;
* disconnect(e) {
* const cp = e.client.connectionParameters;
* console.log('Disconnecting from database:', cp.database);

@@ -105,3 +109,3 @@ * }

try {
ctx.options.disconnect(client, ctx.dc);
ctx.options.disconnect({client, dc: ctx.dc});
} catch (e) {

@@ -170,3 +174,5 @@ // have to silence errors here;

*
* @param {Array<Object>} data
* @param {{}} e Event Properties
*
* @param {Array<Object>} e.data
* Array of received objects/rows.

@@ -176,3 +182,3 @@ *

*
* @param {external:Result} result
* @param {external:Result} e.result
* - Original $[Result] object, if the data is from a non-stream query, in which case `data = result.rows`.

@@ -183,3 +189,3 @@ * For single-query requests, $[Result] object is extended with property `duration` - number of milliseconds

*
* @param {EventContext} e
* @param {EventContext} e.ctx
* Event Context Object.

@@ -196,4 +202,4 @@ *

*
* receive(data, result, e) {
* camelizeColumns(data);
* receive(e) {
* camelizeColumns(e.data);
* }

@@ -216,6 +222,6 @@ * };

*/
static receive(options, data, result, context) {
static receive(options, data, result, ctx) {
if (typeof options.receive === `function`) {
try {
options.receive(data, result, context);
options.receive({data, result, ctx});
} catch (e) {

@@ -541,3 +547,2 @@ // throwing an error during event 'receive'

* inside a task or transaction.
*
*/

@@ -672,3 +672,3 @@ /*

* Top-level empty arrays are formatted as literal `{}`, to avoid the necessity of explicit type casting,
* as the server cannot automatically infer type of an empty non-literal array.
* as the server cannot automatically infer type of empty non-literal array.
*

@@ -675,0 +675,0 @@ * @param {Array|function} arr

@@ -14,3 +14,2 @@ /*

const method = require(`./methods`);
const utils = require(`../utils`);

@@ -72,4 +71,3 @@ /**

};
utils.lock(res, true, config.options);
return res;
};

@@ -15,6 +15,7 @@ /*

// istanbul ignore next
if (highVer < 12) {
if (highVer < 14) {
// From pg-promise v10.15.0, the oldest supported Node.js is v12.0.0
// From pg-promise v11.0.0, the oldest supported Node.js is v14.0.0
// Node.js v12.0.0 was supported up to pg-promise v10.15.4
// Node.js v8.0.0 was supported up to pg-promise v10.14.2

@@ -25,5 +26,5 @@ // Node.js v7.6.0 was supported up to pg-promise v10.3.5

throw new Error(`Minimum Node.js version supported by pg-promise is 12.0.0`);
throw new Error(`Minimum Node.js version supported by pg-promise is 14.0.0`);
}
module.exports = require(`./main`);

@@ -39,3 +39,3 @@ /*

* @description
* ## pg-promise v10.15
* ## pg-promise v11.0
* All documentation here is for the latest official release only.

@@ -54,6 +54,6 @@ *

*
* @param {{}} [options]
* @property {{}} [options]
* Library Initialization Options.
*
* @param {boolean} [options.pgFormatting=false]
* @property {boolean} [options.pgFormatting=false]
* Redirects all query formatting to the $[pg] driver.

@@ -68,3 +68,3 @@ *

*
* @param {boolean} [options.pgNative=false]
* @property {boolean} [options.pgNative=false]
* Use $[Native Bindings]. Library $[pg-native] must be included and installed independently, or else there will

@@ -75,3 +75,3 @@ * be an error thrown: {@link external:Error Error} = `Failed to initialize Native Bindings.`

*
* @param {object|function} [options.promiseLib=Promise]
* @property {object|function} [options.promiseLib=Promise]
* Overrides the default (ES6 Promise) promise library for its internal use.

@@ -95,16 +95,3 @@ *

*
* @param {boolean} [options.noLocking=false]
* Prevents protocol locking.
*
* By default, the library locks much of its protocol to read-only access, as a fool-proof mechanism.
* Specifically for the {@link event:extend extend} event this serves as a protection against overriding existing
* properties or trying to set them at the wrong time.
*
* If this provision gets in the way of using a mock-up framework for your tests, you can force
* the library to deactivate most of the locks by setting `noLocking` = `true` within the options.
*
* This option is dynamic (can be set before or after initialization). However, changing it after the library's
* initialization will not affect {@link Database} objects that have already been created.
*
* @param {boolean} [options.capSQL=false]
* @property {boolean} [options.capSQL=false]
* Capitalizes any SQL generated by the library.

@@ -119,3 +106,3 @@ *

*
* @param {string|Array<string>|null|undefined|function} [options.schema]
* @property {string|Array<string>|null|undefined|function} [options.schema]
* Forces change of the default database schema(s) for every fresh connection, i.e.

@@ -137,3 +124,3 @@ * the library will execute `SET search_path TO schema_1, schema_2, ...` in the background

*
* @param {boolean} [options.noWarnings=false]
* @property {boolean} [options.noWarnings=false]
* Disables all diagnostic warnings in the library (it is ill-advised).

@@ -143,3 +130,3 @@ *

*
* @param {function} [options.connect]
* @property {function} [options.connect]
* Global event {@link event:connect connect} handler.

@@ -149,3 +136,3 @@ *

*
* @param {function} [options.disconnect]
* @property {function} [options.disconnect]
* Global event {@link event:disconnect disconnect} handler.

@@ -155,3 +142,3 @@ *

*
* @param {function} [options.query]
* @property {function} [options.query]
* Global event {@link event:query query} handler.

@@ -161,3 +148,3 @@ *

*
* @param {function} [options.receive]
* @property {function} [options.receive]
* Global event {@link event:receive receive} handler.

@@ -167,3 +154,3 @@ *

*
* @param {function} [options.task]
* @property {function} [options.task]
* Global event {@link event:task task} handler.

@@ -173,3 +160,3 @@ *

*
* @param {function} [options.transact]
* @property {function} [options.transact]
* Global event {@link event:transact transact} handler.

@@ -179,3 +166,3 @@ *

*
* @param {function} [options.error]
* @property {function} [options.error]
* Global event {@link event:error error} handler.

@@ -185,3 +172,3 @@ *

*
* @param {function} [options.extend]
* @property {function} [options.extend]
* Global event {@link event:extend extend} handler.

@@ -209,3 +196,3 @@ *

options = assert(options, [`pgFormatting`, `pgNative`, `promiseLib`, `noLocking`, `capSQL`, `noWarnings`,
options = assert(options, [`pgFormatting`, `pgNative`, `promiseLib`, `capSQL`, `noWarnings`,
`connect`, `disconnect`, `query`, `receive`, `task`, `transact`, `error`, `extend`, `schema`]);

@@ -322,3 +309,2 @@

config.pgp = inst;
npm.utils.lock(config, true, options);

@@ -325,0 +311,0 @@ return inst;

@@ -163,4 +163,4 @@ /*

}
err.query = err.query || query;
err.params = err.params || params;
err.query ??= query;
err.params ??= params;
error = err;

@@ -167,0 +167,0 @@ } else {

@@ -241,3 +241,2 @@ /*

c.duration = c.finish - c.start;
npm.utils.lock(c, true);
}

@@ -244,0 +243,0 @@ (isTX ? Events.transact : Events.task)(ctx.options, {

@@ -13,4 +13,3 @@ /*

util: require(`util`),
patterns: require(`../patterns`),
os: require(`os`)
patterns: require(`../patterns`)
};

@@ -40,23 +39,2 @@

///////////////////////////////////////////////////
// Locks all properties in an object to read-only,
// or freezes the entire object for any changes.
function lock(obj, freeze, options) {
if (options && options.noLocking) {
return;
}
if (freeze) {
Object.freeze(obj); // freeze the entire object, permanently;
} else {
const desc = {
writable: false,
configurable: false,
enumerable: true
};
for (const p in obj) {
Object.defineProperty(obj, p, desc);
}
}
}
/////////////////////////////////////////////

@@ -208,4 +186,2 @@ // Adds properties from source to the target,

const platform = npm.os.platform();
const exp = {

@@ -217,10 +193,5 @@ toJson,

getLocalStack,
lock,
isText,
isNull,
isDev,
platform: {
isWindows: platform === `win32`,
isMac: platform === `darwin`
},
addReadProp,

@@ -227,0 +198,0 @@ addReadProperties,

{
"name": "pg-promise",
"version": "10.15.4",
"version": "11.0.0",
"description": "PostgreSQL interface for Node.js",

@@ -40,3 +40,3 @@ "main": "lib/index.js",

"engines": {
"node": ">=12.0"
"node": ">=14.0"
},

@@ -50,15 +50,16 @@ "dependencies": {

"devDependencies": {
"@types/node": "18.11.9",
"@babel/eslint-parser": "7.19.1",
"@types/node": "18.11.18",
"bluebird": "3.7.2",
"coveralls": "3.1.1",
"cspell": "6.15.0",
"eslint": "8.28.0",
"cspell": "6.18.1",
"eslint": "8.30.0",
"istanbul": "0.4.5",
"jasmine-node": "3.0.0",
"jsdoc": "3.6.11",
"jsdoc": "4.0.0",
"JSONStream": "1.3.5",
"pg-query-stream": "4.2.4",
"tslint": "6.1.3",
"typescript": "4.9.3"
"typescript": "4.9.4"
}
}

@@ -37,3 +37,2 @@ pg-promise

- [Library de-initialization]
* [History](#history)

@@ -1034,11 +1033,2 @@ ---

### update
Version 10.11.0 added support for connection option `allowExitOnIdle`, to let process exit when pool is idle.
# History
Although this project formally maintains a [CHANGELOG], for a short list of the top-level changes,
for detailed changes between versions you should see the corresponding release notes.
<!-- Internal Menu Links -->

@@ -1136,4 +1126,4 @@

[Symbol]:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol
[idleTimeoutMillis]:https://github.com/brianc/node-postgres/blob/master/packages/pg/lib/defaults.js#L46
[connection pool]:https://github.com/brianc/node-pg-pool
[idleTimeoutMillis]:https://github.com/brianc/node-postgres/blob/master/packages/pg/lib/defaults.js
[connection pool]:https://github.com/brianc/node-postgres/tree/master/packages/pg-pool
[Error]:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error

@@ -11,3 +11,3 @@ /*

/////////////////////////////////////////
// Requires pg-promise v10.14.0 or later.
// Requires pg-promise v11.0.0 or later.
/////////////////////////////////////////

@@ -577,9 +577,8 @@

promiseLib?: any
noLocking?: boolean
capSQL?: boolean
schema?: ValidSchema | ((dc: any) => ValidSchema)
connect?(client: C, dc: any, useCount: number): void
connect?(e: { client: C, dc: any, useCount: number }): void
disconnect?(client: C, dc: any): void
disconnect?(e: { client: C, dc: any }): void

@@ -589,3 +588,3 @@ query?(e: IEventContext<C>): void

// NOTE: result is undefined when data comes from QueryStream, i.e. via method Database.stream
receive?(data: any[], result: IResultExt | void, e: IEventContext<C>): void
receive?(e: { data: any[], result: IResultExt | void, ctx: IEventContext<C> }): void

@@ -592,0 +591,0 @@ task?(e: IEventContext<C>): void

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc