Skip to content

Commit

Permalink
fix: suffix all function types with Function
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Jul 1, 2018
1 parent 1328b7f commit 767a3eb
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 50 deletions.
40 changes: 20 additions & 20 deletions src/index.js
Expand Up @@ -33,16 +33,16 @@ import type {
DatabaseConfigurationType,
DatabasePoolType,
DatabaseSingleConnectionType,
InternalQueryAnyFirstType,
InternalQueryAnyType,
InternalQueryManyFirstType,
InternalQueryManyType,
InternalQueryMaybeOneFirstType,
InternalQueryMaybeOneType,
InternalQueryOneFirstType,
InternalQueryOneType,
InternalQueryType,
InternalTransactionType,
InternalQueryAnyFirstFunctionType,
InternalQueryAnyFunctionType,
InternalQueryManyFirstFunctionType,
InternalQueryManyFunctionType,
InternalQueryMaybeOneFirstFunctionType,
InternalQueryMaybeOneFunctionType,
InternalQueryOneFirstFunctionType,
InternalQueryOneFunctionType,
InternalQueryFunctionType,
InternalTransactionFunctionType,
TaggledTemplateLiteralInvocationType
} from './types';
import Logger from './Logger';
Expand Down Expand Up @@ -90,7 +90,7 @@ export {
};

// eslint-disable-next-line complexity
export const query: InternalQueryType<*> = async (connection, rawSql, values, queryId) => {
export const query: InternalQueryFunctionType<*> = async (connection, rawSql, values, queryId) => {
let stackTrace;

if (SLONIK_LOG_STACK_TRACE) {
Expand Down Expand Up @@ -175,7 +175,7 @@ export const query: InternalQueryType<*> = async (connection, rawSql, values, qu
* @throws NotFoundError If query returns no rows.
* @throws DataIntegrityError If query returns multiple rows.
*/
export const one: InternalQueryOneType = async (connection, clientConfiguration, rawSql, values, queryId = ulid()) => {
export const one: InternalQueryOneFunctionType = async (connection, clientConfiguration, rawSql, values, queryId = ulid()) => {
const {
rows
} = await query(connection, rawSql, values, queryId);
Expand Down Expand Up @@ -206,7 +206,7 @@ export const one: InternalQueryOneType = async (connection, clientConfiguration,
*
* @throws DataIntegrityError If query returns multiple rows.
*/
export const maybeOne: InternalQueryMaybeOneType = async (connection, clientConfiguration, rawSql, values, queryId = ulid()) => {
export const maybeOne: InternalQueryMaybeOneFunctionType = async (connection, clientConfiguration, rawSql, values, queryId = ulid()) => {
const {
rows
} = await query(connection, rawSql, values, queryId);
Expand All @@ -233,7 +233,7 @@ export const maybeOne: InternalQueryMaybeOneType = async (connection, clientConf
* @throws NotFoundError If query returns no rows.
* @throws DataIntegrityError If query returns multiple rows.
*/
export const oneFirst: InternalQueryOneFirstType = async (connection, clientConfiguration, rawSql, values, queryId = ulid()) => {
export const oneFirst: InternalQueryOneFirstFunctionType = async (connection, clientConfiguration, rawSql, values, queryId = ulid()) => {
const row = await one(connection, clientConfiguration, rawSql, values, queryId);

const keys = Object.keys(row);
Expand All @@ -255,7 +255,7 @@ export const oneFirst: InternalQueryOneFirstType = async (connection, clientConf
*
* @throws DataIntegrityError If query returns multiple rows.
*/
export const maybeOneFirst: InternalQueryMaybeOneFirstType = async (connection, clientConfiguration, rawSql, values, queryId = ulid()) => {
export const maybeOneFirst: InternalQueryMaybeOneFirstFunctionType = async (connection, clientConfiguration, rawSql, values, queryId = ulid()) => {
const row = await maybeOne(connection, clientConfiguration, rawSql, values, queryId);

if (!row) {
Expand All @@ -280,7 +280,7 @@ export const maybeOneFirst: InternalQueryMaybeOneFirstType = async (connection,
*
* @throws NotFoundError If query returns no rows.
*/
export const many: InternalQueryManyType = async (connection, clientConfiguration, rawSql, values, queryId = ulid()) => {
export const many: InternalQueryManyFunctionType = async (connection, clientConfiguration, rawSql, values, queryId = ulid()) => {
const {
rows
} = await query(connection, rawSql, values, queryId);
Expand All @@ -298,7 +298,7 @@ export const many: InternalQueryManyType = async (connection, clientConfiguratio
return rows;
};

export const manyFirst: InternalQueryManyFirstType = async (connection, clientConfigurationType, rawSql, values, queryId = ulid()) => {
export const manyFirst: InternalQueryManyFirstFunctionType = async (connection, clientConfigurationType, rawSql, values, queryId = ulid()) => {
const rows = await many(connection, clientConfigurationType, rawSql, values, queryId);

if (rows.length === 0) {
Expand Down Expand Up @@ -337,15 +337,15 @@ export const manyFirst: InternalQueryManyFirstType = async (connection, clientCo
/**
* Makes a query and expects any number of results.
*/
export const any: InternalQueryAnyType = async (connection, clientConfiguration, rawSql, values, queryId = ulid()) => {
export const any: InternalQueryAnyFunctionType = async (connection, clientConfiguration, rawSql, values, queryId = ulid()) => {
const {
rows
} = await query(connection, rawSql, values, queryId);

return rows;
};

export const anyFirst: InternalQueryAnyFirstType = async (connection, clientConfigurationType, rawSql, values, queryId = ulid()) => {
export const anyFirst: InternalQueryAnyFirstFunctionType = async (connection, clientConfigurationType, rawSql, values, queryId = ulid()) => {
const rows = await any(connection, clientConfigurationType, rawSql, values, queryId);

if (rows.length === 0) {
Expand Down Expand Up @@ -377,7 +377,7 @@ export const anyFirst: InternalQueryAnyFirstType = async (connection, clientConf
});
};

export const transaction: InternalTransactionType = async (connection, handler) => {
export const transaction: InternalTransactionFunctionType = async (connection, handler) => {
await connection.query('START TRANSACTION');

try {
Expand Down
60 changes: 30 additions & 30 deletions src/types.js
Expand Up @@ -47,16 +47,16 @@ export type DatabaseConfigurationType =
|};

export type DatabaseConnectionType = {
+any: QueryAnyType<*>,
+anyFirst: QueryAnyFirstType<*>,
+many: QueryManyType<*>,
+manyFirst: QueryManyFirstType<*>,
+maybeOne: QueryMaybeOneType<*>,
+maybeOneFirst: QueryMaybeOneFirstType<*>,
+one: QueryOneType<*>,
+oneFirst: QueryOneFirstType<*>,
+query: QueryType<*>,
+transaction: TransactionType
+any: QueryAnyFunctionType<*>,
+anyFirst: QueryAnyFirstFunctionType<*>,
+many: QueryManyFunctionType<*>,
+manyFirst: QueryManyFirstFunctionType<*>,
+maybeOne: QueryMaybeOneFunctionType<*>,
+maybeOneFirst: QueryMaybeOneFirstFunctionType<*>,
+one: QueryOneFunctionType<*>,
+oneFirst: QueryOneFirstFunctionType<*>,
+query: QueryFunctionType<*>,
+transaction: TransactionFunctionType
};

export type DatabaseSingleConnectionType = {
Expand Down Expand Up @@ -106,63 +106,63 @@ export type TaggledTemplateLiteralInvocationType = {
values: $ReadOnlyArray<AnonymouseValuePlaceholderValueType>
};

export type InternalQueryAnyType = (
export type InternalQueryAnyFunctionType = (
connection: InternalDatabaseConnectionType,
clientConfiguration: ClientConfigurationType,
sql: string,
values?: DatabaseQueryValuesType,
queryId?: string
) => Promise<$ReadOnlyArray<QueryResultRowType>>;

export type InternalQueryAnyFirstType = (
export type InternalQueryAnyFirstFunctionType = (
connection: InternalDatabaseConnectionType,
clientConfiguration: ClientConfigurationType,
sql: string,
values?: DatabaseQueryValuesType,
queryId?: string
) => Promise<$ReadOnlyArray<QueryResultRowColumnType>>;

export type InternalQueryManyType = (
export type InternalQueryManyFunctionType = (
connection: InternalDatabaseConnectionType,
clientConfiguration: ClientConfigurationType,
sql: string,
values?: DatabaseQueryValuesType,
queryId?: string
) => Promise<$ReadOnlyArray<QueryResultRowType>>;

export type InternalQueryManyFirstType = (
export type InternalQueryManyFirstFunctionType = (
connection: InternalDatabaseConnectionType,
clientConfiguration: ClientConfigurationType,
sql: string,
values?: DatabaseQueryValuesType,
queryId?: string
) => Promise<$ReadOnlyArray<QueryResultRowColumnType>>;

export type InternalQueryMaybeOneFirstType = (
export type InternalQueryMaybeOneFirstFunctionType = (
connection: InternalDatabaseConnectionType,
clientConfiguration: ClientConfigurationType,
sql: string,
values?: DatabaseQueryValuesType,
queryId?: string
) => Promise<QueryResultRowColumnType | null>;

export type InternalQueryMaybeOneType = (
export type InternalQueryMaybeOneFunctionType = (
connection: InternalDatabaseConnectionType,
clientConfiguration: ClientConfigurationType,
sql: string,
values?: DatabaseQueryValuesType,
queryId?: string
) => Promise<QueryResultRowType | null>;

export type InternalQueryOneFirstType = (
export type InternalQueryOneFirstFunctionType = (
connection: InternalDatabaseConnectionType,
clientConfiguration: ClientConfigurationType,
sql: string,
values?: DatabaseQueryValuesType,
queryId?: string
) => Promise<QueryResultRowColumnType>;

export type InternalQueryOneType = (
export type InternalQueryOneFunctionType = (
connection: InternalDatabaseConnectionType,
clientConfiguration: ClientConfigurationType,
sql: string,
Expand All @@ -172,17 +172,17 @@ export type InternalQueryOneType = (

export type TransactionHandlerType = (connection: DatabaseConnectionType) => Promise<*>;

export type InternalTransactionType = (connection: InternalDatabaseConnectionType, handler: TransactionHandlerType) => Promise<*>;
export type InternalTransactionFunctionType = (connection: InternalDatabaseConnectionType, handler: TransactionHandlerType) => Promise<*>;

export type InternalQueryType<T: QueryResultRowType> = (connection: InternalDatabaseConnectionType, sql: string, values?: DatabaseQueryValuesType, queryId?: string) => Promise<QueryResultType<T>>;
export type InternalQueryFunctionType<T: QueryResultRowType> = (connection: InternalDatabaseConnectionType, sql: string, values?: DatabaseQueryValuesType, queryId?: string) => Promise<QueryResultType<T>>;

export type QueryAnyFirstType<T: QueryResultRowColumnType> = (sql: string | TaggledTemplateLiteralInvocationType, values?: DatabaseQueryValuesType) => Promise<$ReadOnlyArray<T>>;
export type QueryAnyType<T: QueryResultRowType> = (sql: string | TaggledTemplateLiteralInvocationType, values?: DatabaseQueryValuesType) => Promise<$ReadOnlyArray<T>>;
export type QueryManyFirstType<T: QueryResultRowColumnType> = (sql: string | TaggledTemplateLiteralInvocationType, values?: DatabaseQueryValuesType) => Promise<$ReadOnlyArray<T>>;
export type QueryManyType<T: QueryResultRowType> = (sql: string | TaggledTemplateLiteralInvocationType, values?: DatabaseQueryValuesType) => Promise<$ReadOnlyArray<T>>;
export type QueryMaybeOneFirstType<T: QueryResultRowColumnType> = (sql: string | TaggledTemplateLiteralInvocationType, values?: DatabaseQueryValuesType) => Promise<T>;
export type QueryMaybeOneType<T: QueryResultRowType | null> = (sql: string | TaggledTemplateLiteralInvocationType, values?: DatabaseQueryValuesType) => Promise<T>;
export type QueryOneFirstType<T: QueryResultRowColumnType> = (sql: string | TaggledTemplateLiteralInvocationType, values?: DatabaseQueryValuesType) => Promise<T>;
export type QueryOneType<T: QueryResultRowType> = (sql: string | TaggledTemplateLiteralInvocationType, values?: DatabaseQueryValuesType) => Promise<T>;
export type QueryType<T: QueryResultRowType> = (sql: string | TaggledTemplateLiteralInvocationType, values?: DatabaseQueryValuesType) => Promise<QueryResultType<T>>;
export type TransactionType = (handler: TransactionHandlerType) => Promise<*>;
export type QueryAnyFirstFunctionType<T: QueryResultRowColumnType> = (sql: string | TaggledTemplateLiteralInvocationType, values?: DatabaseQueryValuesType) => Promise<$ReadOnlyArray<T>>;
export type QueryAnyFunctionType<T: QueryResultRowType> = (sql: string | TaggledTemplateLiteralInvocationType, values?: DatabaseQueryValuesType) => Promise<$ReadOnlyArray<T>>;
export type QueryManyFirstFunctionType<T: QueryResultRowColumnType> = (sql: string | TaggledTemplateLiteralInvocationType, values?: DatabaseQueryValuesType) => Promise<$ReadOnlyArray<T>>;
export type QueryManyFunctionType<T: QueryResultRowType> = (sql: string | TaggledTemplateLiteralInvocationType, values?: DatabaseQueryValuesType) => Promise<$ReadOnlyArray<T>>;
export type QueryMaybeOneFirstFunctionType<T: QueryResultRowColumnType> = (sql: string | TaggledTemplateLiteralInvocationType, values?: DatabaseQueryValuesType) => Promise<T>;
export type QueryMaybeOneFunctionType<T: QueryResultRowType | null> = (sql: string | TaggledTemplateLiteralInvocationType, values?: DatabaseQueryValuesType) => Promise<T>;
export type QueryOneFirstFunctionType<T: QueryResultRowColumnType> = (sql: string | TaggledTemplateLiteralInvocationType, values?: DatabaseQueryValuesType) => Promise<T>;
export type QueryOneFunctionType<T: QueryResultRowType> = (sql: string | TaggledTemplateLiteralInvocationType, values?: DatabaseQueryValuesType) => Promise<T>;
export type QueryFunctionType<T: QueryResultRowType> = (sql: string | TaggledTemplateLiteralInvocationType, values?: DatabaseQueryValuesType) => Promise<QueryResultType<T>>;
export type TransactionFunctionType = (handler: TransactionHandlerType) => Promise<*>;

0 comments on commit 767a3eb

Please sign in to comment.