Comparing version 8.0.4 to 8.1.0
@@ -14,4 +14,2 @@ "use strict"; | ||
var _bindIsolatedPoolConnection = _interopRequireDefault(require("./bindIsolatedPoolConnection")); | ||
var _bindPoolConnection = _interopRequireDefault(require("./bindPoolConnection")); | ||
@@ -25,18 +23,5 @@ | ||
anyFirst: (0, _utilities.mapTaggedTemplateLiteralInvocation)(_connectionMethods.anyFirst.bind(null, parentLog, pool, clientConfiguration)), | ||
// @see https://stackoverflow.com/questions/42539202/flowtype-how-can-i-overload-function-return-types-by-argument-count-types | ||
// eslint-disable-next-line consistent-return, flowtype/no-weak-types | ||
connect: async handler => { | ||
if (handler) { | ||
const connection = await pool.connect(); | ||
try { | ||
await handler((0, _bindIsolatedPoolConnection.default)(parentLog, pool, connection, clientConfiguration)); | ||
} catch (error) { | ||
connection.release(); | ||
throw error; | ||
} | ||
} else { | ||
const connection = await pool.connect(); | ||
return (0, _bindPoolConnection.default)(parentLog, pool, connection, clientConfiguration); | ||
} | ||
connect: async () => { | ||
const connection = await pool.connect(); | ||
return (0, _bindPoolConnection.default)(parentLog, pool, connection, clientConfiguration); | ||
}, | ||
@@ -43,0 +28,0 @@ many: (0, _utilities.mapTaggedTemplateLiteralInvocation)(_connectionMethods.many.bind(null, parentLog, pool, clientConfiguration)), |
@@ -6,8 +6,2 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "bindIsolatedPoolConnection", { | ||
enumerable: true, | ||
get: function () { | ||
return _bindIsolatedPoolConnection.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "bindPool", { | ||
@@ -38,4 +32,2 @@ enumerable: true, | ||
var _bindIsolatedPoolConnection = _interopRequireDefault(require("./bindIsolatedPoolConnection")); | ||
var _bindPool = _interopRequireDefault(require("./bindPool")); | ||
@@ -42,0 +34,0 @@ |
@@ -93,3 +93,3 @@ { | ||
}, | ||
"version": "8.0.4" | ||
"version": "8.1.0" | ||
} |
@@ -25,3 +25,2 @@ // @flow | ||
import createPoolTransaction from '../factories/createPoolTransaction'; | ||
import bindIsolatedPoolConnection from './bindIsolatedPoolConnection'; | ||
import bindPoolConnection from './bindPoolConnection'; | ||
@@ -37,21 +36,6 @@ | ||
anyFirst: mapTaggedTemplateLiteralInvocation(anyFirst.bind(null, parentLog, pool, clientConfiguration)), | ||
connect: async () => { | ||
const connection: InternalDatabaseConnectionType = await pool.connect(); | ||
// @see https://stackoverflow.com/questions/42539202/flowtype-how-can-i-overload-function-return-types-by-argument-count-types | ||
// eslint-disable-next-line consistent-return, flowtype/no-weak-types | ||
connect: async (handler): any => { | ||
if (handler) { | ||
const connection: InternalDatabaseConnectionType = await pool.connect(); | ||
try { | ||
await handler(bindIsolatedPoolConnection(parentLog, pool, connection, clientConfiguration)); | ||
} catch (error) { | ||
connection.release(); | ||
throw error; | ||
} | ||
} else { | ||
const connection: InternalDatabaseConnectionType = await pool.connect(); | ||
return bindPoolConnection(parentLog, pool, connection, clientConfiguration); | ||
} | ||
return bindPoolConnection(parentLog, pool, connection, clientConfiguration); | ||
}, | ||
@@ -58,0 +42,0 @@ many: mapTaggedTemplateLiteralInvocation(many.bind(null, parentLog, pool, clientConfiguration)), |
// @flow | ||
export {default as bindIsolatedPoolConnection} from './bindIsolatedPoolConnection'; | ||
export {default as bindPool} from './bindPool'; | ||
@@ -5,0 +4,0 @@ export {default as bindPoolConnection} from './bindPoolConnection'; |
@@ -26,3 +26,2 @@ // @flow | ||
DatabaseConnectionType, | ||
DatabaseIsolatedPoolConnectionType, | ||
DatabasePoolConnectionType, | ||
@@ -29,0 +28,0 @@ DatabasePoolType, |
@@ -58,3 +58,3 @@ // @flow | ||
export type DatabaseConnectionType = {| | ||
type CommonQueryMethodsType = {| | ||
+any: QueryAnyFunctionType<*>, | ||
@@ -72,3 +72,3 @@ +anyFirst: QueryAnyFirstFunctionType<*>, | ||
export type DatabaseTransactionConnectionType = {| | ||
...DatabaseConnectionType | ||
...CommonQueryMethodsType | ||
|}; | ||
@@ -79,3 +79,3 @@ | ||
export type DatabaseSingleConnectionType = {| | ||
...DatabaseConnectionType, | ||
...CommonQueryMethodsType, | ||
+end: () => Promise<void>, | ||
@@ -86,3 +86,3 @@ +transaction: (handler: TransactionFunctionType) => Promise<*> | ||
export type DatabasePoolConnectionType = {| | ||
...DatabaseConnectionType, | ||
...CommonQueryMethodsType, | ||
+release: () => Promise<void>, | ||
@@ -92,18 +92,19 @@ +transaction: (handler: TransactionFunctionType) => Promise<*> | ||
export type DatabaseIsolatedPoolConnectionType = {| | ||
...DatabaseConnectionType, | ||
export type DatabasePoolType = {| | ||
...CommonQueryMethodsType, | ||
+connect: () => Promise<DatabasePoolConnectionType>, | ||
+transaction: (handler: TransactionFunctionType) => Promise<*> | ||
|}; | ||
// @todo Document `((connection: DatabaseIsolatedPoolConnectionType) => Promise<void>) => Promise<void>` API. | ||
type DataPoolConnectMethodType = | ||
() => Promise<DatabasePoolConnectionType> & | ||
((connection: DatabaseIsolatedPoolConnectionType) => Promise<void>) => Promise<void>; | ||
/** | ||
* This appears to be the only sane way to have a generic database connection type | ||
* that can be refined, i.e. DatabaseConnectionType => DatabasePoolType. | ||
*/ | ||
export type DatabaseConnectionType = | ||
$Shape<{ | ||
...DatabasePoolConnectionType, | ||
...DatabasePoolType, | ||
...DatabaseSingleConnectionType | ||
}>; | ||
export type DatabasePoolType = {| | ||
...DatabaseConnectionType, | ||
+connect: DataPoolConnectMethodType, | ||
+transaction: (handler: TransactionFunctionType) => Promise<*> | ||
|}; | ||
type QueryResultRowColumnType = string | number; | ||
@@ -110,0 +111,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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
227390
143
2512