Socket
Socket
Sign inDemoInstall

slonik

Package Overview
Dependencies
Maintainers
1
Versions
395
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slonik - npm Package Compare versions

Comparing version 41.1.0 to 41.2.0

3

dist/factories/createClientConfiguration.js

@@ -20,2 +20,5 @@ "use strict";

queryRetryLimit: 5,
resetConnection: ({ query }) => {
return query(`DISCARD ALL`);
},
statementTimeout: 60000,

@@ -22,0 +25,0 @@ transactionRetryLimit: 5,

@@ -7,2 +7,5 @@ /// <reference types="node" />

import { type StrictEventEmitter } from 'strict-event-emitter-types';
type BasicConnection = {
readonly query: (query: string) => Promise<void>;
};
export type DriverConfiguration = {

@@ -15,2 +18,3 @@ readonly connectionTimeout: number | 'DISABLE_TIMEOUT';

readonly maximumPoolSize?: number;
readonly resetConnection?: (connection: BasicConnection) => Promise<void>;
readonly ssl?: TlsConnectionOptions;

@@ -17,0 +21,0 @@ readonly statementTimeout: number | 'DISABLE_TIMEOUT';

@@ -14,2 +14,3 @@ "use strict";

return async ({ driverConfiguration }) => {
const { resetConnection } = driverConfiguration;
const driverEventEmitter = new node_events_1.default();

@@ -114,3 +115,9 @@ const { createPoolClient } = await setup({

}
await query('DISCARD ALL');
if (resetConnection) {
await resetConnection({
query: async (sql) => {
await query(sql);
},
});
}
if (driverConfiguration.idleTimeout !== 'DISABLE_TIMEOUT') {

@@ -117,0 +124,0 @@ clearIdleTimeout();

2

dist/factories/createPool.js

@@ -17,3 +17,3 @@ "use strict";

const driver = await createDriver({
// TODO resolve name conflict
// TODO resolve name conflict between ClientConfiguration and DriverConfiguration
driverConfiguration: clientConfiguration,

@@ -20,0 +20,0 @@ });

@@ -33,2 +33,24 @@ "use strict";

const createIntegrationTests = (test, driverFactory) => {
test('uses resetConnection after implicit connection release', async (t) => {
const resetConnection = sinon.spy();
const pool = await (0, __1.createPool)(t.context.dsn, {
driverFactory,
resetConnection,
});
await pool.query(__1.sql.unsafe `SELECT 1`);
t.true(resetConnection.calledOnce);
await pool.end();
});
test('uses resetConnection after explicit connection release', async (t) => {
const resetConnection = sinon.spy();
const pool = await (0, __1.createPool)(t.context.dsn, {
driverFactory,
resetConnection,
});
await pool.connect(async () => {
return null;
});
t.true(resetConnection.calledOnce);
await pool.end();
});
test('does not allow to reference a non-transaction connection inside of a transaction', async (t) => {

@@ -35,0 +57,0 @@ const pool = await (0, __1.createPool)(t.context.dsn, {

@@ -58,2 +58,5 @@ /// <reference types="node" />

};
type BasicConnection = {
readonly query: (query: string) => Promise<void>;
};
export type ClientConfiguration = {

@@ -109,2 +112,7 @@ /**

/**
* Routine that's invoked to reset the connection.
* The default routine invokes `DISCARD ALL`.
*/
readonly resetConnection?: (basicConnection: BasicConnection) => Promise<void>;
/**
* tls.connect options *

@@ -111,0 +119,0 @@ */

@@ -95,3 +95,3 @@ {

"types": "./dist/index.d.ts",
"version": "41.1.0"
"version": "41.2.0"
}

@@ -27,6 +27,8 @@ import { InvalidConfigurationError } from '../errors';

queryRetryLimit: 5,
resetConnection: ({ query }) => {
return query(`DISCARD ALL`);
},
statementTimeout: 60_000,
transactionRetryLimit: 5,
typeParsers,
...clientUserConfigurationInput,

@@ -33,0 +35,0 @@ };

@@ -10,2 +10,6 @@ import { Logger } from '../Logger';

type BasicConnection = {
readonly query: (query: string) => Promise<void>;
};
export type DriverConfiguration = {

@@ -18,2 +22,3 @@ readonly connectionTimeout: number | 'DISABLE_TIMEOUT';

readonly maximumPoolSize?: number;
readonly resetConnection?: (connection: BasicConnection) => Promise<void>;
readonly ssl?: TlsConnectionOptions;

@@ -131,2 +136,4 @@ readonly statementTimeout: number | 'DISABLE_TIMEOUT';

return async ({ driverConfiguration }): Promise<Driver> => {
const { resetConnection } = driverConfiguration;
const driverEventEmitter: DriverEventEmitter = new EventEmitter();

@@ -270,3 +277,9 @@

await query('DISCARD ALL');
if (resetConnection) {
await resetConnection({
query: async (sql) => {
await query(sql);
},
});
}

@@ -273,0 +286,0 @@ if (driverConfiguration.idleTimeout !== 'DISABLE_TIMEOUT') {

@@ -26,3 +26,3 @@ import { bindPool } from '../binders/bindPool';

const driver = await createDriver({
// TODO resolve name conflict
// TODO resolve name conflict between ClientConfiguration and DriverConfiguration
driverConfiguration: clientConfiguration,

@@ -29,0 +29,0 @@ });

@@ -35,2 +35,34 @@ /* eslint-disable id-length */

) => {
test('uses resetConnection after implicit connection release', async (t) => {
const resetConnection = sinon.spy();
const pool = await createPool(t.context.dsn, {
driverFactory,
resetConnection,
});
await pool.query(sql.unsafe`SELECT 1`);
t.true(resetConnection.calledOnce);
await pool.end();
});
test('uses resetConnection after explicit connection release', async (t) => {
const resetConnection = sinon.spy();
const pool = await createPool(t.context.dsn, {
driverFactory,
resetConnection,
});
await pool.connect(async () => {
return null;
});
t.true(resetConnection.calledOnce);
await pool.end();
});
test('does not allow to reference a non-transaction connection inside of a transaction', async (t) => {

@@ -37,0 +69,0 @@ const pool = await createPool(t.context.dsn, {

@@ -91,2 +91,6 @@ import { type SlonikError } from './errors';

type BasicConnection = {
readonly query: (query: string) => Promise<void>;
};
export type ClientConfiguration = {

@@ -142,2 +146,9 @@ /**

/**
* Routine that's invoked to reset the connection.
* The default routine invokes `DISCARD ALL`.
*/
readonly resetConnection?: (
basicConnection: BasicConnection,
) => Promise<void>;
/**
* tls.connect options *

@@ -144,0 +155,0 @@ */

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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