pqb 0.48.6 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +16 -7
- package/dist/index.js +14 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PoolConfig, Pool, PoolClient } from 'pg';
|
|
2
2
|
import * as orchid_core from 'orchid-core';
|
|
3
|
-
import { QueryResultRow, AdapterConfigBase, AdapterBase, QueryInput, SingleSqlItem, Sql, IsQuery, PickQueryReturnType, RecordUnknown, Expression, MaybeArray, ColumnTypesBase, TemplateLiteralArgs, EmptyObject, QueryColumns, QueryColumn, MaybePromise, FnUnknownToUnknown, QueryMetaBase, QueryReturnType, RecordString, ColumnsShapeBase, ColumnsParsers, PickQueryTable, HookSelect, BatchParsers, QueryLogObject, QueryLogger, QueryDataTransform, ExpressionChain, PickQueryShape, ColumnSchemaConfig, RawSQLBase, RawSQLValues, ExpressionTypeMethod, DynamicSQLArg, ExpressionData, StaticSQLArgs, SQLQueryArgs, PickQueryTableMetaResult, EmptyTuple, PickQueryMeta, PickQueryMetaResultReturnType, QueryColumnToNullable, QueryThenByQuery, ColumnShapeInput, SelectableBase, PickQueryMetaShape, PickQueryTableMetaResultShape, PickQueryMetaResultWindows, PickOutputTypeAndOperators, PickQueryResult, ValExpression, PickOutputType, QueryThen, DateColumnData, ColumnToCodeCtx, Code, TimeInterval, ColumnTypeSchemaArg, ColumnDataBase, ArrayMethodsData, ForeignKeyTable, ColumnNameOfTable, BaseNumberData, PickColumnBaseData, ColumnWithDefault, StringTypeData, PrimaryKeyColumn, ColumnTypeBase, ParseColumn, ParseNullColumn, EncodeColumn, QueryColumnsInit, QueryLogOptions, DefaultSelectColumns, DefaultSelectOutput, QueryThenShallowSimplifyArr, QueryCatch, TransactionState, QueryColumnOfDataType, PickQueryUniqueProperties, PickQueryMetaResult, PickQueryTableMetaResultInputType, UnionToIntersection, getValueKey, QueryThenByReturnType, QueryMetaIsSubQuery, QueryThenShallowSimplifyOptional, QueryThenShallowSimplify, PickQueryResultReturnType, PickQueryResultReturnTypeUniqueColumns, QueryInternalBase, PickType, RecordKeyTrue, ColumnShapeOutput, OperatorsNullable, PickQueryMetaReturnType, UniqueColumn, TimestampHelpers, ShallowSimplify, Codes, ColumnDataCheckBase } from 'orchid-core';
|
|
3
|
+
import { QueryResultRow, AdapterConfigBase, AdapterBase, QueryInput, SingleSqlItem, Sql, IsQuery, PickQueryReturnType, RecordUnknown, Expression, MaybeArray, ColumnTypesBase, TemplateLiteralArgs, EmptyObject, QueryColumns, QueryColumn, MaybePromise, FnUnknownToUnknown, QueryMetaBase, QueryReturnType, RecordString, ColumnsShapeBase, ColumnsParsers, PickQueryTable, HookSelect, BatchParsers, QueryLogObject, QueryLogger, QueryDataTransform, ExpressionChain, PickQueryShape, ColumnSchemaConfig, RawSQLBase, RawSQLValues, ExpressionTypeMethod, DynamicSQLArg, ExpressionData, StaticSQLArgs, SQLQueryArgs, PickQueryTableMetaResult, EmptyTuple, PickQueryMeta, PickQueryMetaResultReturnType, QueryColumnToNullable, QueryThenByQuery, ColumnShapeInput, SelectableBase, PickQueryMetaShape, PickQueryTableMetaResultShape, PickQueryMetaResultWindows, PickOutputTypeAndOperators, PickQueryResult, ValExpression, PickOutputType, QueryThen, DateColumnData, ColumnToCodeCtx, Code, TimeInterval, ColumnTypeSchemaArg, ColumnDataBase, ArrayMethodsData, ForeignKeyTable, ColumnNameOfTable, BaseNumberData, PickColumnBaseData, ColumnWithDefault, StringTypeData, PrimaryKeyColumn, ColumnTypeBase, ParseColumn, ParseNullColumn, EncodeColumn, QueryColumnsInit, QueryLogOptions, DefaultSelectColumns, DefaultSelectOutput, QueryThenShallowSimplifyArr, QueryCatch, TransactionState, QueryColumnOfDataType, PickQueryUniqueProperties, PickQueryMetaResult, PickQueryTableMetaResultInputType, UnionToIntersection, getValueKey, QueryThenByReturnType, QueryMetaIsSubQuery, QueryReturnTypeAll, QueryReturnTypeOptional, QueryThenShallowSimplifyOptional, QueryThenShallowSimplify, PickQueryResultReturnType, PickQueryResultReturnTypeUniqueColumns, QueryInternalBase, PickType, RecordKeyTrue, ColumnShapeOutput, OperatorsNullable, PickQueryMetaReturnType, UniqueColumn, TimestampHelpers, ShallowSimplify, Codes, ColumnDataCheckBase } from 'orchid-core';
|
|
4
4
|
import { inspect } from 'node:util';
|
|
5
5
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
6
6
|
|
|
@@ -7105,22 +7105,31 @@ declare class QueryMap {
|
|
|
7105
7105
|
*
|
|
7106
7106
|
* @param fn - function to transform an individual record
|
|
7107
7107
|
*/
|
|
7108
|
-
map<T extends PickQueryReturnType, Result>(this: T, fn:
|
|
7108
|
+
map<T extends PickQueryReturnType, Result>(this: T, fn: T extends {
|
|
7109
|
+
returnType: 'valueOrThrow';
|
|
7110
|
+
then: QueryThen<infer Data | null>;
|
|
7111
|
+
} ? (input: Data) => Result : (input: T['returnType'] extends QueryReturnTypeAll | 'pluck' ? T extends {
|
|
7109
7112
|
then: QueryThen<(infer Data)[]>;
|
|
7110
7113
|
} ? Data : never : T extends {
|
|
7111
7114
|
then: QueryThen<infer Data | undefined>;
|
|
7112
7115
|
} ? Data : never) => Result): Result extends RecordUnknown ? {
|
|
7113
7116
|
[K in keyof T]: K extends 'result' ? {
|
|
7114
7117
|
[K in keyof Result]: QueryColumn<Result[K]>;
|
|
7115
|
-
} : K extends 'then' ? QueryThen<T['returnType'] extends
|
|
7118
|
+
} : K extends 'then' ? QueryThen<T['returnType'] extends QueryReturnTypeAll ? Result[] : T['returnType'] extends QueryReturnTypeOptional ? Result | undefined : Result> : T[K];
|
|
7116
7119
|
} : {
|
|
7117
|
-
[K in keyof T]: K extends 'returnType' ? T['returnType'] extends
|
|
7120
|
+
[K in keyof T]: K extends 'returnType' ? T['returnType'] extends QueryReturnTypeAll | 'pluck' ? 'pluck' : T['returnType'] extends 'one' ? 'value' : 'valueOrThrow' : K extends 'result' ? T['returnType'] extends QueryReturnTypeAll | 'pluck' ? {
|
|
7118
7121
|
pluck: QueryColumn<Result>;
|
|
7119
|
-
} : T['returnType'] extends
|
|
7122
|
+
} : T['returnType'] extends QueryReturnTypeOptional ? {
|
|
7120
7123
|
value: QueryColumn<Result | undefined>;
|
|
7121
7124
|
} : {
|
|
7122
|
-
value: QueryColumn<
|
|
7123
|
-
|
|
7125
|
+
value: QueryColumn<T extends {
|
|
7126
|
+
returnType: 'valueOrThrow';
|
|
7127
|
+
then: QueryThen<unknown | null>;
|
|
7128
|
+
} ? Result | null : Result>;
|
|
7129
|
+
} : K extends 'then' ? QueryThen<T['returnType'] extends QueryReturnTypeAll | 'pluck' ? Result[] : T['returnType'] extends QueryReturnTypeOptional ? Result | undefined : T extends {
|
|
7130
|
+
returnType: 'valueOrThrow';
|
|
7131
|
+
then: QueryThen<unknown | null>;
|
|
7132
|
+
} ? Result | null : Result> : T[K];
|
|
7124
7133
|
};
|
|
7125
7134
|
}
|
|
7126
7135
|
|
package/dist/index.js
CHANGED
|
@@ -3002,7 +3002,12 @@ const runAfterCommit = async (afterCommit, result) => {
|
|
|
3002
3002
|
const applyBatchTransforms = (q, batches) => {
|
|
3003
3003
|
if (q.transform) {
|
|
3004
3004
|
for (const item of batches) {
|
|
3005
|
-
item.parent[item.key] =
|
|
3005
|
+
item.parent[item.key] = orchidCore.applyTransforms(
|
|
3006
|
+
q,
|
|
3007
|
+
q.returnType,
|
|
3008
|
+
q.transform,
|
|
3009
|
+
item.data
|
|
3010
|
+
);
|
|
3006
3011
|
}
|
|
3007
3012
|
}
|
|
3008
3013
|
};
|
|
@@ -3784,8 +3789,9 @@ const addParserForSelectItem = (q, as, key, arg, joinQuery) => {
|
|
|
3784
3789
|
const { parsers } = query;
|
|
3785
3790
|
if (parsers) {
|
|
3786
3791
|
if (returnType === "one") {
|
|
3787
|
-
for (const
|
|
3788
|
-
if (data) parseRecord(parsers, data);
|
|
3792
|
+
for (const batch of batches) {
|
|
3793
|
+
if (batch.data) parseRecord(parsers, batch.data);
|
|
3794
|
+
else batch.data = void 0;
|
|
3789
3795
|
}
|
|
3790
3796
|
} else {
|
|
3791
3797
|
for (const { data } of batches) {
|
|
@@ -3793,7 +3799,11 @@ const addParserForSelectItem = (q, as, key, arg, joinQuery) => {
|
|
|
3793
3799
|
parseRecord(parsers, data);
|
|
3794
3800
|
}
|
|
3795
3801
|
}
|
|
3796
|
-
} else if (returnType
|
|
3802
|
+
} else if (returnType === "one") {
|
|
3803
|
+
for (const batch of batches) {
|
|
3804
|
+
if (!batch.data) batch.data = void 0;
|
|
3805
|
+
}
|
|
3806
|
+
} else {
|
|
3797
3807
|
for (const { data } of batches) {
|
|
3798
3808
|
if (!data) throw new NotFoundError(arg);
|
|
3799
3809
|
}
|