Comparing version 37.2.0 to 37.2.1
@@ -33,3 +33,3 @@ "use strict"; | ||
objectMode: true, | ||
transform(datum, enc, callback) { | ||
async transform(datum, enc, callback) { | ||
if (!fields) { | ||
@@ -40,6 +40,5 @@ callback(new Error('Fields not available')); | ||
let finalRow = datum; | ||
if (rowTransformers.length) { | ||
for (const rowTransformer of rowTransformers) { | ||
finalRow = rowTransformer(queryContext, query, finalRow, fields); | ||
} | ||
// apply row transformers. Note this is done sequentially, as one transformer's result will be passed to the next. | ||
for (const rowTransformer of rowTransformers) { | ||
finalRow = await rowTransformer(queryContext, query, finalRow, fields); | ||
} | ||
@@ -46,0 +45,0 @@ // eslint-disable-next-line @babel/no-invalid-this |
/// <reference types="node" /> | ||
import { type ArraySqlToken, type BinarySqlToken, type DateSqlToken, type IdentifierSqlToken, type IntervalInput, type IntervalSqlToken, type JsonBinarySqlToken, type JsonSqlToken, type ListSqlToken, type PrimitiveValueExpression, type SerializableValue, type SqlFragment, type SqlToken as SqlTokenType, type TimestampSqlToken, type TypeNameIdentifier, type UnnestSqlToken, type ValueExpression } from '../types'; | ||
import { type ArraySqlToken, type BinarySqlToken, type DateSqlToken, type FragmentSqlToken, type IdentifierSqlToken, type IntervalInput, type IntervalSqlToken, type JsonBinarySqlToken, type JsonSqlToken, type ListSqlToken, type PrimitiveValueExpression, type SerializableValue, type SqlFragment, type SqlToken as SqlTokenType, type TimestampSqlToken, type TypeNameIdentifier, type UnnestSqlToken, type ValueExpression } from '../types'; | ||
import { z } from 'zod'; | ||
export declare const createSqlTag: <K extends PropertyKey, P extends z.ZodTypeAny, Z extends Record<K, P>>(configuration?: { | ||
typeAliases?: Z | undefined; | ||
typeAliases?: Z; | ||
}) => { | ||
@@ -10,7 +10,3 @@ array: (values: readonly PrimitiveValueExpression[], memberType: SqlTokenType | TypeNameIdentifier) => ArraySqlToken; | ||
date: (date: Date) => DateSqlToken; | ||
fragment: (parts: readonly string[], ...args: readonly ValueExpression[]) => Readonly<{ | ||
type: "SLONIK_TOKEN_FRAGMENT"; | ||
sql: string; | ||
values: PrimitiveValueExpression[]; | ||
}>; | ||
fragment: (parts: readonly string[], ...args: readonly ValueExpression[]) => FragmentSqlToken; | ||
identifier: (names: readonly string[]) => IdentifierSqlToken; | ||
@@ -17,0 +13,0 @@ interval: (interval: IntervalInput) => IntervalSqlToken; |
/// <reference types="node" /> | ||
export declare const sql: { | ||
array: (values: readonly import("./types").PrimitiveValueExpression[], memberType: string | import("./types").SqlToken) => import("./types").ArraySqlToken; | ||
array: (values: readonly import("./types").QueryResultRowColumn[], memberType: string | import("./types").SqlToken) => import("./types").ArraySqlToken; | ||
binary: (data: Buffer) => import("./types").BinarySqlToken; | ||
date: (date: Date) => import("./types").DateSqlToken; | ||
fragment: (parts: readonly string[], ...args: readonly import("./types").ValueExpression[]) => Readonly<{ | ||
type: "SLONIK_TOKEN_FRAGMENT"; | ||
sql: string; | ||
values: import("./types").PrimitiveValueExpression[]; | ||
}>; | ||
fragment: (parts: readonly string[], ...args: readonly import("./types").ValueExpression[]) => import("./types").FragmentSqlToken; | ||
identifier: (names: readonly string[]) => import("./types").IdentifierSqlToken; | ||
@@ -22,3 +18,3 @@ interval: (interval: import("./types").IntervalInput) => import("./types").IntervalSqlToken; | ||
sql: string; | ||
values: import("./types").PrimitiveValueExpression[]; | ||
values: import("./types").QueryResultRowColumn[]; | ||
}>; | ||
@@ -29,5 +25,5 @@ typeAlias: <Y extends PropertyKey>(parserAlias: Y) => (parts: readonly string[], ...args: readonly import("./types").ValueExpression[]) => Readonly<{ | ||
sql: string; | ||
values: import("./types").PrimitiveValueExpression[]; | ||
values: import("./types").QueryResultRowColumn[]; | ||
}>; | ||
unnest: (tuples: readonly (readonly import("./types").PrimitiveValueExpression[])[], columnTypes: [...string[], string][] | (string | import("./types").SqlFragment)[]) => import("./types").UnnestSqlToken; | ||
unnest: (tuples: readonly (readonly import("./types").QueryResultRowColumn[])[], columnTypes: [...string[], string][] | (string | import("./types").SqlFragment)[]) => import("./types").UnnestSqlToken; | ||
unsafe: (parts: readonly string[], ...args: readonly import("./types").ValueExpression[]) => Readonly<{ | ||
@@ -37,3 +33,3 @@ parser: import("zod").ZodAny; | ||
sql: string; | ||
values: import("./types").PrimitiveValueExpression[]; | ||
values: import("./types").QueryResultRowColumn[]; | ||
}>; | ||
@@ -40,0 +36,0 @@ }; |
@@ -217,6 +217,3 @@ "use strict"; | ||
const { fields } = result; | ||
const rows = []; | ||
for (const row of result.rows) { | ||
rows.push(transformRow(executionContext, actualQuery, row, fields)); | ||
} | ||
const rows = await Promise.all(result.rows.map((row) => transformRow(executionContext, actualQuery, row, fields))); | ||
result = { | ||
@@ -223,0 +220,0 @@ ...result, |
@@ -329,3 +329,3 @@ /// <reference types="node" /> | ||
readonly transformQuery?: (queryContext: QueryContext, query: Query) => Query; | ||
readonly transformRow?: (queryContext: QueryContext, query: Query, row: QueryResultRow, fields: readonly Field[]) => QueryResultRow; | ||
readonly transformRow?: (queryContext: QueryContext, query: Query, row: QueryResultRow, fields: readonly Field[]) => MaybePromise<QueryResultRow>; | ||
}; | ||
@@ -332,0 +332,0 @@ export type IdentifierNormalizer = (identifierName: string) => string; |
@@ -5,3 +5,2 @@ "use strict"; | ||
const Logger_1 = require("../Logger"); | ||
const node_url_1 = require("node:url"); | ||
const log = Logger_1.Logger.child({ | ||
@@ -14,3 +13,3 @@ namespace: 'parseDsn', | ||
} | ||
const url = new node_url_1.URL(dsn); | ||
const url = new URL(dsn); | ||
const connectionOptions = {}; | ||
@@ -17,0 +16,0 @@ if (url.host) { |
@@ -102,3 +102,3 @@ { | ||
"types": "./dist/index.d.ts", | ||
"version": "37.2.0" | ||
"version": "37.2.1" | ||
} |
@@ -50,3 +50,3 @@ import { executeQuery, type ExecutionRoutine } from '../routines/executeQuery'; | ||
objectMode: true, | ||
transform(datum, enc, callback) { | ||
async transform(datum, enc, callback) { | ||
if (!fields) { | ||
@@ -60,6 +60,5 @@ callback(new Error('Fields not available')); | ||
if (rowTransformers.length) { | ||
for (const rowTransformer of rowTransformers) { | ||
finalRow = rowTransformer(queryContext, query, finalRow, fields); | ||
} | ||
// apply row transformers. Note this is done sequentially, as one transformer's result will be passed to the next. | ||
for (const rowTransformer of rowTransformers) { | ||
finalRow = await rowTransformer(queryContext, query, finalRow, fields); | ||
} | ||
@@ -66,0 +65,0 @@ |
@@ -21,2 +21,3 @@ import { InvalidInputError } from '../errors'; | ||
type DateSqlToken, | ||
type FragmentSqlToken, | ||
type IdentifierSqlToken, | ||
@@ -152,3 +153,3 @@ type IntervalInput, | ||
...args: readonly ValueExpression[] | ||
) => { | ||
): FragmentSqlToken => { | ||
return Object.freeze({ | ||
@@ -155,0 +156,0 @@ ...createFragment(parts, args), |
@@ -378,8 +378,8 @@ import { TRANSACTION_ROLLBACK_ERROR_PREFIX } from '../constants'; | ||
const rows: QueryResultRow[] = []; | ||
const rows: QueryResultRow[] = await Promise.all( | ||
result.rows.map((row) => | ||
transformRow(executionContext, actualQuery, row, fields), | ||
), | ||
); | ||
for (const row of result.rows) { | ||
rows.push(transformRow(executionContext, actualQuery, row, fields)); | ||
} | ||
result = { | ||
@@ -386,0 +386,0 @@ ...result, |
@@ -557,3 +557,3 @@ import { type SlonikError } from './errors'; | ||
fields: readonly Field[], | ||
) => QueryResultRow; | ||
) => MaybePromise<QueryResultRow>; | ||
}; | ||
@@ -560,0 +560,0 @@ |
import { Logger } from '../Logger'; | ||
import { type ConnectionOptions } from '../types'; | ||
import { URL } from 'node:url'; | ||
@@ -5,0 +4,0 @@ const log = Logger.child({ |
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 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 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 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 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 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 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
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
512770
3056
7435