metal-orm 1.0.88 → 1.0.90
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.cjs +3818 -3783
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +765 -236
- package/dist/index.d.ts +765 -236
- package/dist/index.js +3763 -3775
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/src/codegen/typescript.ts +29 -40
- package/src/core/ast/expression-builders.ts +34 -53
- package/src/core/ast/expression-nodes.ts +51 -72
- package/src/core/ast/expression-visitor.ts +219 -252
- package/src/core/ast/expression.ts +20 -21
- package/src/core/dialect/abstract.ts +55 -81
- package/src/core/execution/db-executor.ts +4 -5
- package/src/core/execution/executors/mysql-executor.ts +7 -9
- package/src/decorators/bootstrap.ts +11 -8
- package/src/dto/apply-filter.ts +281 -0
- package/src/dto/dto-types.ts +229 -0
- package/src/dto/filter-types.ts +193 -0
- package/src/dto/index.ts +97 -0
- package/src/dto/openapi/generators/base.ts +29 -0
- package/src/dto/openapi/generators/column.ts +34 -0
- package/src/dto/openapi/generators/dto.ts +94 -0
- package/src/dto/openapi/generators/filter.ts +74 -0
- package/src/dto/openapi/generators/nested-dto.ts +532 -0
- package/src/dto/openapi/generators/pagination.ts +111 -0
- package/src/dto/openapi/generators/relation-filter.ts +210 -0
- package/src/dto/openapi/index.ts +17 -0
- package/src/dto/openapi/type-mappings.ts +191 -0
- package/src/dto/openapi/types.ts +83 -0
- package/src/dto/openapi/utilities.ts +45 -0
- package/src/dto/pagination-utils.ts +150 -0
- package/src/dto/transform.ts +193 -0
- package/src/index.ts +67 -65
- package/src/orm/unit-of-work.ts +13 -25
- package/src/query-builder/query-ast-service.ts +287 -300
- package/src/query-builder/relation-filter-utils.ts +159 -160
- package/src/query-builder/select.ts +137 -192
- package/src/core/ast/ast-validation.ts +0 -19
- package/src/core/ast/param-proxy.ts +0 -47
- package/src/core/ast/query-visitor.ts +0 -273
- package/src/openapi/index.ts +0 -4
- package/src/openapi/query-parameters.ts +0 -207
- package/src/openapi/schema-extractor-input.ts +0 -139
- package/src/openapi/schema-extractor-output.ts +0 -427
- package/src/openapi/schema-extractor-utils.ts +0 -110
- package/src/openapi/schema-extractor.ts +0 -111
- package/src/openapi/schema-types.ts +0 -176
- package/src/openapi/type-mappers.ts +0 -227
package/dist/index.d.ts
CHANGED
|
@@ -656,14 +656,6 @@ interface LiteralNode {
|
|
|
656
656
|
/** The literal value (string, number, boolean, Date, or null) */
|
|
657
657
|
value: string | number | boolean | Date | null;
|
|
658
658
|
}
|
|
659
|
-
/**
|
|
660
|
-
* AST node representing a named parameter placeholder
|
|
661
|
-
*/
|
|
662
|
-
interface ParamNode {
|
|
663
|
-
type: 'Param';
|
|
664
|
-
/** Stable parameter name */
|
|
665
|
-
name: string;
|
|
666
|
-
}
|
|
667
659
|
/**
|
|
668
660
|
* AST node representing a reference to a SELECT alias (for ORDER BY / GROUP BY).
|
|
669
661
|
*/
|
|
@@ -794,7 +786,7 @@ interface ArithmeticExpressionNode {
|
|
|
794
786
|
/**
|
|
795
787
|
* Union type representing any operand that can be used in expressions
|
|
796
788
|
*/
|
|
797
|
-
type OperandNode = AliasRefNode | ColumnNode | LiteralNode |
|
|
789
|
+
type OperandNode = AliasRefNode | ColumnNode | LiteralNode | FunctionNode | JsonPathNode | ScalarSubqueryNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode | ArithmeticExpressionNode | BitwiseExpressionNode | CollateExpressionNode;
|
|
798
790
|
declare const isOperandNode: (node: unknown) => node is OperandNode;
|
|
799
791
|
declare const isFunctionNode: (node: unknown) => node is FunctionNode;
|
|
800
792
|
declare const isCaseExpressionNode: (node: unknown) => node is CaseExpressionNode;
|
|
@@ -1446,8 +1438,6 @@ interface ExpressionVisitor<R> {
|
|
|
1446
1438
|
visitBetweenExpression?(node: BetweenExpressionNode): R;
|
|
1447
1439
|
visitArithmeticExpression?(node: ArithmeticExpressionNode): R;
|
|
1448
1440
|
visitBitwiseExpression?(node: BitwiseExpressionNode): R;
|
|
1449
|
-
visitOperand?(node: OperandNode): R;
|
|
1450
|
-
visitSelectQuery?(node: SelectQueryNode): R;
|
|
1451
1441
|
otherwise?(node: ExpressionNode): R;
|
|
1452
1442
|
}
|
|
1453
1443
|
/**
|
|
@@ -1456,17 +1446,12 @@ interface ExpressionVisitor<R> {
|
|
|
1456
1446
|
interface OperandVisitor<R> {
|
|
1457
1447
|
visitColumn?(node: ColumnNode): R;
|
|
1458
1448
|
visitLiteral?(node: LiteralNode): R;
|
|
1459
|
-
visitParam?(node: ParamNode): R;
|
|
1460
1449
|
visitFunction?(node: FunctionNode): R;
|
|
1461
1450
|
visitJsonPath?(node: JsonPathNode): R;
|
|
1462
1451
|
visitScalarSubquery?(node: ScalarSubqueryNode): R;
|
|
1463
1452
|
visitCaseExpression?(node: CaseExpressionNode): R;
|
|
1464
1453
|
visitCast?(node: CastExpressionNode): R;
|
|
1465
1454
|
visitWindowFunction?(node: WindowFunctionNode): R;
|
|
1466
|
-
visitArithmeticExpression?(node: ArithmeticExpressionNode): R;
|
|
1467
|
-
visitBitwiseExpression?(node: BitwiseExpressionNode): R;
|
|
1468
|
-
visitExpression?(node: ExpressionNode): R;
|
|
1469
|
-
visitSelectQuery?(node: SelectQueryNode): R;
|
|
1470
1455
|
visitCollate?(node: CollateExpressionNode): R;
|
|
1471
1456
|
visitAliasRef?(node: AliasRefNode): R;
|
|
1472
1457
|
otherwise?(node: OperandNode): R;
|
|
@@ -1483,8 +1468,6 @@ declare const registerExpressionDispatcher: (type: string, dispatcher: Expressio
|
|
|
1483
1468
|
* Allows new node kinds without modifying the core switch.
|
|
1484
1469
|
*/
|
|
1485
1470
|
declare const registerOperandDispatcher: (type: string, dispatcher: OperandDispatch) => void;
|
|
1486
|
-
declare const hasExpressionDispatcher: (type: string) => boolean;
|
|
1487
|
-
declare const hasOperandDispatcher: (type: string) => boolean;
|
|
1488
1471
|
/**
|
|
1489
1472
|
* Clears all registered dispatchers. Primarily for tests.
|
|
1490
1473
|
*/
|
|
@@ -1503,14 +1486,6 @@ declare const visitExpression: <R>(node: ExpressionNode, visitor: ExpressionVisi
|
|
|
1503
1486
|
*/
|
|
1504
1487
|
declare const visitOperand: <R>(node: OperandNode, visitor: OperandVisitor<R>) => R;
|
|
1505
1488
|
|
|
1506
|
-
type ParamProxy = ParamNode & {
|
|
1507
|
-
[key: string]: ParamProxy;
|
|
1508
|
-
};
|
|
1509
|
-
type ParamProxyRoot = {
|
|
1510
|
-
[key: string]: ParamProxy;
|
|
1511
|
-
};
|
|
1512
|
-
declare const createParamProxy: () => ParamProxyRoot;
|
|
1513
|
-
|
|
1514
1489
|
/**
|
|
1515
1490
|
* Adapts a schema ColumnDef to an AST-friendly ColumnRef.
|
|
1516
1491
|
*/
|
|
@@ -1828,8 +1803,6 @@ interface CompilerContext {
|
|
|
1828
1803
|
params: unknown[];
|
|
1829
1804
|
/** Function to add a parameter and get its placeholder */
|
|
1830
1805
|
addParameter(value: unknown): string;
|
|
1831
|
-
/** Whether Param operands are allowed (for schema generation) */
|
|
1832
|
-
allowParams?: boolean;
|
|
1833
1806
|
}
|
|
1834
1807
|
/**
|
|
1835
1808
|
* Result of SQL compilation
|
|
@@ -1864,9 +1837,6 @@ declare abstract class Dialect implements SelectCompiler, InsertCompiler, Update
|
|
|
1864
1837
|
* @returns Compiled query with SQL and parameters
|
|
1865
1838
|
*/
|
|
1866
1839
|
compileSelect(ast: SelectQueryNode): CompiledQuery;
|
|
1867
|
-
compileSelectWithOptions(ast: SelectQueryNode, options?: {
|
|
1868
|
-
allowParams?: boolean;
|
|
1869
|
-
}): CompiledQuery;
|
|
1870
1840
|
compileInsert(ast: InsertQueryNode): CompiledQuery;
|
|
1871
1841
|
compileUpdate(ast: UpdateQueryNode): CompiledQuery;
|
|
1872
1842
|
compileDelete(ast: DeleteQueryNode): CompiledQuery;
|
|
@@ -1907,12 +1877,9 @@ declare abstract class Dialect implements SelectCompiler, InsertCompiler, Update
|
|
|
1907
1877
|
protected compileSelectForExists(ast: SelectQueryNode, ctx: CompilerContext): string;
|
|
1908
1878
|
/**
|
|
1909
1879
|
* Creates a new compiler context
|
|
1910
|
-
* @param options - Optional compiler context options
|
|
1911
1880
|
* @returns Compiler context with parameter management
|
|
1912
1881
|
*/
|
|
1913
|
-
protected createCompilerContext(
|
|
1914
|
-
allowParams?: boolean;
|
|
1915
|
-
}): CompilerContext;
|
|
1882
|
+
protected createCompilerContext(): CompilerContext;
|
|
1916
1883
|
/**
|
|
1917
1884
|
* Formats a parameter placeholder
|
|
1918
1885
|
* @param index - Parameter index
|
|
@@ -2400,7 +2367,6 @@ declare class QueryAstService {
|
|
|
2400
2367
|
* @returns Normalized ordering term
|
|
2401
2368
|
*/
|
|
2402
2369
|
private normalizeOrderingTerm;
|
|
2403
|
-
private toParamNode;
|
|
2404
2370
|
}
|
|
2405
2371
|
|
|
2406
2372
|
/**
|
|
@@ -2710,7 +2676,6 @@ type NormalizedRelationIncludeTree = Record<string, NormalizedRelationIncludeNod
|
|
|
2710
2676
|
type QueryResult = {
|
|
2711
2677
|
columns: string[];
|
|
2712
2678
|
values: unknown[][];
|
|
2713
|
-
insertId?: number;
|
|
2714
2679
|
};
|
|
2715
2680
|
interface DbExecutor {
|
|
2716
2681
|
/** Capability flags so the runtime can make correct decisions without relying on optional methods. */
|
|
@@ -3264,7 +3229,6 @@ declare class UnitOfWork {
|
|
|
3264
3229
|
* @param results - Query results
|
|
3265
3230
|
*/
|
|
3266
3231
|
private applyReturningResults;
|
|
3267
|
-
private applyInsertId;
|
|
3268
3232
|
/**
|
|
3269
3233
|
* Normalizes a column name by removing quotes and table prefixes.
|
|
3270
3234
|
* @param column - The column name to normalize
|
|
@@ -3813,181 +3777,6 @@ interface PaginatedResult<T> {
|
|
|
3813
3777
|
pageSize: number;
|
|
3814
3778
|
}
|
|
3815
3779
|
|
|
3816
|
-
/**
|
|
3817
|
-
* OpenAPI 3.1 JSON Schema type representation
|
|
3818
|
-
*/
|
|
3819
|
-
type JsonSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
|
|
3820
|
-
/**
|
|
3821
|
-
* Common OpenAPI 3.1 JSON Schema formats
|
|
3822
|
-
*/
|
|
3823
|
-
type JsonSchemaFormat = 'date-time' | 'date' | 'time' | 'email' | 'uuid' | 'uri' | 'binary' | 'base64';
|
|
3824
|
-
/**
|
|
3825
|
-
* OpenAPI 3.1 JSON Schema property definition
|
|
3826
|
-
*/
|
|
3827
|
-
interface JsonSchemaProperty {
|
|
3828
|
-
type?: JsonSchemaType | JsonSchemaType[];
|
|
3829
|
-
format?: JsonSchemaFormat;
|
|
3830
|
-
description?: string;
|
|
3831
|
-
nullable?: boolean;
|
|
3832
|
-
readOnly?: boolean;
|
|
3833
|
-
writeOnly?: boolean;
|
|
3834
|
-
minimum?: number;
|
|
3835
|
-
maximum?: number;
|
|
3836
|
-
minLength?: number;
|
|
3837
|
-
maxLength?: number;
|
|
3838
|
-
pattern?: string;
|
|
3839
|
-
enum?: (string | number | boolean)[];
|
|
3840
|
-
default?: unknown;
|
|
3841
|
-
example?: unknown;
|
|
3842
|
-
properties?: Record<string, JsonSchemaProperty>;
|
|
3843
|
-
required?: string[];
|
|
3844
|
-
items?: JsonSchemaProperty;
|
|
3845
|
-
$ref?: string;
|
|
3846
|
-
anyOf?: JsonSchemaProperty[];
|
|
3847
|
-
allOf?: JsonSchemaProperty[];
|
|
3848
|
-
oneOf?: JsonSchemaProperty[];
|
|
3849
|
-
[key: string]: unknown;
|
|
3850
|
-
}
|
|
3851
|
-
/**
|
|
3852
|
-
* OpenAPI 3.1 parameter definition
|
|
3853
|
-
*/
|
|
3854
|
-
interface OpenApiParameter {
|
|
3855
|
-
name: string;
|
|
3856
|
-
in: 'query' | 'path' | 'header' | 'cookie';
|
|
3857
|
-
description?: string;
|
|
3858
|
-
required?: boolean;
|
|
3859
|
-
deprecated?: boolean;
|
|
3860
|
-
allowEmptyValue?: boolean;
|
|
3861
|
-
style?: string;
|
|
3862
|
-
explode?: boolean;
|
|
3863
|
-
schema?: JsonSchemaProperty;
|
|
3864
|
-
[key: string]: unknown;
|
|
3865
|
-
}
|
|
3866
|
-
/**
|
|
3867
|
-
* Complete OpenAPI 3.1 Schema for an entity or query result
|
|
3868
|
-
*/
|
|
3869
|
-
interface OpenApiSchema {
|
|
3870
|
-
type: 'object';
|
|
3871
|
-
properties: Record<string, JsonSchemaProperty>;
|
|
3872
|
-
required: string[];
|
|
3873
|
-
description?: string;
|
|
3874
|
-
}
|
|
3875
|
-
/**
|
|
3876
|
-
* OpenAPI 3.1 components container
|
|
3877
|
-
*/
|
|
3878
|
-
interface OpenApiComponents {
|
|
3879
|
-
schemas: Record<string, OpenApiSchema>;
|
|
3880
|
-
}
|
|
3881
|
-
/**
|
|
3882
|
-
* Column-level schema flags
|
|
3883
|
-
*/
|
|
3884
|
-
interface ColumnSchemaOptions {
|
|
3885
|
-
/** Include description from column comments */
|
|
3886
|
-
includeDescriptions?: boolean;
|
|
3887
|
-
/** Include enum values for enum columns */
|
|
3888
|
-
includeEnums?: boolean;
|
|
3889
|
-
/** Include column examples if available */
|
|
3890
|
-
includeExamples?: boolean;
|
|
3891
|
-
/** Include column defaults */
|
|
3892
|
-
includeDefaults?: boolean;
|
|
3893
|
-
/** Include nullable flag when applicable */
|
|
3894
|
-
includeNullable?: boolean;
|
|
3895
|
-
}
|
|
3896
|
-
/**
|
|
3897
|
-
* Output schema generation options (query result)
|
|
3898
|
-
*/
|
|
3899
|
-
interface OutputSchemaOptions extends ColumnSchemaOptions {
|
|
3900
|
-
/** Use selected columns only (from select/include) vs full entity */
|
|
3901
|
-
mode?: 'selected' | 'full';
|
|
3902
|
-
/** Maximum depth for relation recursion */
|
|
3903
|
-
maxDepth?: number;
|
|
3904
|
-
/** Inline schemas vs $ref components */
|
|
3905
|
-
refMode?: 'inline' | 'components';
|
|
3906
|
-
/** Selected schemas inline vs components when refMode is components */
|
|
3907
|
-
selectedRefMode?: 'inline' | 'components';
|
|
3908
|
-
/** Customize component names */
|
|
3909
|
-
componentName?: (table: TableDef) => string;
|
|
3910
|
-
}
|
|
3911
|
-
type InputRelationMode = 'ids' | 'objects' | 'mixed';
|
|
3912
|
-
type InputSchemaMode = 'create' | 'update';
|
|
3913
|
-
/**
|
|
3914
|
-
* Input schema generation options (write payloads)
|
|
3915
|
-
*/
|
|
3916
|
-
interface InputSchemaOptions extends ColumnSchemaOptions {
|
|
3917
|
-
/** Create vs update payload shape */
|
|
3918
|
-
mode?: InputSchemaMode;
|
|
3919
|
-
/** Include relation payloads */
|
|
3920
|
-
includeRelations?: boolean;
|
|
3921
|
-
/** How relations are represented (ids, nested objects, or both) */
|
|
3922
|
-
relationMode?: InputRelationMode;
|
|
3923
|
-
/** Maximum depth for relation recursion */
|
|
3924
|
-
maxDepth?: number;
|
|
3925
|
-
/** Omit read-only/generated columns from input */
|
|
3926
|
-
omitReadOnly?: boolean;
|
|
3927
|
-
/** Exclude primary key columns from input */
|
|
3928
|
-
excludePrimaryKey?: boolean;
|
|
3929
|
-
/** Require primary key columns on update payloads */
|
|
3930
|
-
requirePrimaryKey?: boolean;
|
|
3931
|
-
}
|
|
3932
|
-
/**
|
|
3933
|
-
* Schema generation options
|
|
3934
|
-
*/
|
|
3935
|
-
interface SchemaOptions extends OutputSchemaOptions {
|
|
3936
|
-
/** Input schema options, or false to skip input generation */
|
|
3937
|
-
input?: InputSchemaOptions | false;
|
|
3938
|
-
}
|
|
3939
|
-
/**
|
|
3940
|
-
* Input + output schema bundle
|
|
3941
|
-
*/
|
|
3942
|
-
interface OpenApiSchemaBundle {
|
|
3943
|
-
output: OpenApiSchema;
|
|
3944
|
-
input?: OpenApiSchema;
|
|
3945
|
-
parameters?: OpenApiParameter[];
|
|
3946
|
-
components?: OpenApiComponents;
|
|
3947
|
-
}
|
|
3948
|
-
/**
|
|
3949
|
-
* Schema extraction context for handling circular references
|
|
3950
|
-
*/
|
|
3951
|
-
interface SchemaExtractionContext {
|
|
3952
|
-
/** Set of already visited tables to detect cycles */
|
|
3953
|
-
visitedTables: Set<string>;
|
|
3954
|
-
/** Map of table names to their generated schemas */
|
|
3955
|
-
schemaCache: Map<string, OpenApiSchema>;
|
|
3956
|
-
/** Current extraction depth */
|
|
3957
|
-
depth: number;
|
|
3958
|
-
/** Maximum depth to recurse */
|
|
3959
|
-
maxDepth: number;
|
|
3960
|
-
/** Component registry when using refMode=components */
|
|
3961
|
-
components?: OpenApiComponents;
|
|
3962
|
-
}
|
|
3963
|
-
|
|
3964
|
-
/**
|
|
3965
|
-
* Maps SQL column types to OpenAPI JSON Schema types
|
|
3966
|
-
*/
|
|
3967
|
-
declare const mapColumnType: (column: ColumnDef, options?: ColumnSchemaOptions) => JsonSchemaProperty;
|
|
3968
|
-
/**
|
|
3969
|
-
* Maps relation type to array or single object
|
|
3970
|
-
*/
|
|
3971
|
-
declare const mapRelationType: (relationType: string) => {
|
|
3972
|
-
type: "object" | "array";
|
|
3973
|
-
isNullable: boolean;
|
|
3974
|
-
};
|
|
3975
|
-
/**
|
|
3976
|
-
* Gets the OpenAPI format for temporal columns
|
|
3977
|
-
*/
|
|
3978
|
-
declare const getTemporalFormat: (sqlType: string) => JsonSchemaFormat | undefined;
|
|
3979
|
-
|
|
3980
|
-
/**
|
|
3981
|
-
* Extracts OpenAPI 3.1 schemas for output and optional input payloads.
|
|
3982
|
-
*/
|
|
3983
|
-
declare const extractSchema: (table: TableDef, plan: HydrationPlan | undefined, projectionNodes: ProjectionNode[] | undefined, options?: SchemaOptions) => OpenApiSchemaBundle;
|
|
3984
|
-
/**
|
|
3985
|
-
* Converts a schema to a JSON string with optional pretty printing
|
|
3986
|
-
*/
|
|
3987
|
-
declare const schemaToJson: (schema: OpenApiSchema, pretty?: boolean) => string;
|
|
3988
|
-
|
|
3989
|
-
declare const buildFilterParameters: (table: TableDef, where: ExpressionNode | undefined, from: TableSourceNode | undefined, options?: ColumnSchemaOptions) => OpenApiParameter[];
|
|
3990
|
-
|
|
3991
3780
|
type SelectDialectInput = Dialect | DialectKey;
|
|
3992
3781
|
|
|
3993
3782
|
type ColumnSelectionValue = ColumnDef | FunctionNode | CaseExpressionNode | WindowFunctionNode | TypedExpression<unknown>;
|
|
@@ -3995,9 +3784,6 @@ type SelectionValueType<TValue> = TValue extends TypedExpression<infer TRuntime>
|
|
|
3995
3784
|
type SelectionResult<TSelection extends Record<string, ColumnSelectionValue>> = {
|
|
3996
3785
|
[K in keyof TSelection]: SelectionValueType<TSelection[K]>;
|
|
3997
3786
|
};
|
|
3998
|
-
type ParamOperandCompileOptions = {
|
|
3999
|
-
allowParamOperands?: boolean;
|
|
4000
|
-
};
|
|
4001
3787
|
type SelectionFromKeys<TTable extends TableDef, K extends keyof TTable['columns'] & string> = Pick<InferRow<TTable>, K>;
|
|
4002
3788
|
type DeepSelectEntry<TTable extends TableDef> = {
|
|
4003
3789
|
type: 'root';
|
|
@@ -4347,11 +4133,6 @@ declare class SelectQueryBuilder<T = EntityInstance<TableDef>, TTable extends Ta
|
|
|
4347
4133
|
* Ensures that if no columns are selected, all columns from the table are selected by default.
|
|
4348
4134
|
*/
|
|
4349
4135
|
private ensureDefaultSelection;
|
|
4350
|
-
/**
|
|
4351
|
-
* Validates that the query does not contain Param operands.
|
|
4352
|
-
* Param proxies are only for schema generation, not execution.
|
|
4353
|
-
*/
|
|
4354
|
-
private validateNoParamOperands;
|
|
4355
4136
|
/**
|
|
4356
4137
|
* Executes the query and returns hydrated results.
|
|
4357
4138
|
* If the builder was created with an entity constructor (e.g. via selectFromEntity),
|
|
@@ -4591,7 +4372,7 @@ declare class SelectQueryBuilder<T = EntityInstance<TableDef>, TTable extends Ta
|
|
|
4591
4372
|
* .compile('postgres');
|
|
4592
4373
|
* console.log(compiled.sql); // SELECT "id", "name" FROM "users" WHERE "active" = true
|
|
4593
4374
|
*/
|
|
4594
|
-
compile(dialect: SelectDialectInput
|
|
4375
|
+
compile(dialect: SelectDialectInput): CompiledQuery;
|
|
4595
4376
|
/**
|
|
4596
4377
|
* Converts the query to SQL string for a specific dialect
|
|
4597
4378
|
* @param dialect - Database dialect to generate SQL for
|
|
@@ -4602,24 +4383,15 @@ declare class SelectQueryBuilder<T = EntityInstance<TableDef>, TTable extends Ta
|
|
|
4602
4383
|
* .toSql('postgres');
|
|
4603
4384
|
* console.log(sql); // SELECT "id", "name" FROM "users" WHERE "active" = true
|
|
4604
4385
|
*/
|
|
4605
|
-
toSql(dialect: SelectDialectInput
|
|
4386
|
+
toSql(dialect: SelectDialectInput): string;
|
|
4606
4387
|
/**
|
|
4607
|
-
* Gets hydration plan for query
|
|
4388
|
+
* Gets the hydration plan for the query
|
|
4608
4389
|
* @returns Hydration plan or undefined if none exists
|
|
4609
4390
|
* @example
|
|
4610
4391
|
* const plan = qb.include('posts').getHydrationPlan();
|
|
4611
4392
|
* console.log(plan?.relations); // Information about included relations
|
|
4612
4393
|
*/
|
|
4613
4394
|
getHydrationPlan(): HydrationPlan | undefined;
|
|
4614
|
-
/**
|
|
4615
|
-
* Gets OpenAPI 3.1 JSON Schemas for query output and optional input payloads
|
|
4616
|
-
* @param options - Schema generation options
|
|
4617
|
-
* @returns OpenAPI 3.1 JSON Schemas for query output and input payloads
|
|
4618
|
-
* @example
|
|
4619
|
-
* const { output } = qb.select('id', 'title', 'author').getSchema();
|
|
4620
|
-
* console.log(JSON.stringify(output, null, 2));
|
|
4621
|
-
*/
|
|
4622
|
-
getSchema(options?: SchemaOptions): OpenApiSchemaBundle;
|
|
4623
4395
|
/**
|
|
4624
4396
|
* Gets the Abstract Syntax Tree (AST) representation of the query
|
|
4625
4397
|
* @returns Query AST with hydration applied
|
|
@@ -6383,7 +6155,6 @@ declare class TypeScriptGenerator implements ExpressionVisitor<string>, OperandV
|
|
|
6383
6155
|
visitArithmeticExpression(arithExpr: ArithmeticExpressionNode): string;
|
|
6384
6156
|
visitColumn(node: ColumnNode): string;
|
|
6385
6157
|
visitLiteral(node: LiteralNode): string;
|
|
6386
|
-
visitParam(node: ParamNode): string;
|
|
6387
6158
|
visitFunction(node: FunctionNode): string;
|
|
6388
6159
|
visitJsonPath(node: JsonPathNode): string;
|
|
6389
6160
|
visitScalarSubquery(node: ScalarSubqueryNode): string;
|
|
@@ -6441,7 +6212,6 @@ declare class TypeScriptGenerator implements ExpressionVisitor<string>, OperandV
|
|
|
6441
6212
|
* @returns TypeScript code representation
|
|
6442
6213
|
*/
|
|
6443
6214
|
private printLiteralOperand;
|
|
6444
|
-
private printParamOperand;
|
|
6445
6215
|
/**
|
|
6446
6216
|
* Prints a function operand to TypeScript code
|
|
6447
6217
|
* @param fn - Function node
|
|
@@ -7246,4 +7016,763 @@ type PooledExecutorFactoryOptions<TConn> = {
|
|
|
7246
7016
|
*/
|
|
7247
7017
|
declare function createPooledExecutorFactory<TConn>(opts: PooledExecutorFactoryOptions<TConn>): DbExecutorFactory;
|
|
7248
7018
|
|
|
7249
|
-
|
|
7019
|
+
/**
|
|
7020
|
+
* DTO (Data Transfer Object) type utilities for metal-orm.
|
|
7021
|
+
* Derives API types from TableDef/Entity metadata.
|
|
7022
|
+
*/
|
|
7023
|
+
|
|
7024
|
+
/**
|
|
7025
|
+
* Checks if a type is a TableDef.
|
|
7026
|
+
*/
|
|
7027
|
+
type IsTableDef$1<T> = T extends {
|
|
7028
|
+
name: string;
|
|
7029
|
+
columns: any;
|
|
7030
|
+
} ? true : false;
|
|
7031
|
+
/**
|
|
7032
|
+
* Extracts the row type from either a TableDef or EntityConstructor.
|
|
7033
|
+
*/
|
|
7034
|
+
type ExtractRow<T> = IsTableDef$1<T> extends true ? InferRow<T extends TableDef<infer C> ? TableDef<C> : never> : T extends EntityConstructor<infer E> ? E : never;
|
|
7035
|
+
/**
|
|
7036
|
+
* Utility to flatten intersection types for better IDE display.
|
|
7037
|
+
*/
|
|
7038
|
+
type Simplify<T> = {
|
|
7039
|
+
[K in keyof T]: T[K];
|
|
7040
|
+
} & {};
|
|
7041
|
+
/**
|
|
7042
|
+
* Response DTO - excludes specified columns from the entity.
|
|
7043
|
+
* Use this to hide sensitive fields like passwordHash, apiKey, etc.
|
|
7044
|
+
*
|
|
7045
|
+
* @example
|
|
7046
|
+
* ```ts
|
|
7047
|
+
* // With TableDef
|
|
7048
|
+
* type UserResponse = Dto<typeof usersTable, 'passwordHash'>;
|
|
7049
|
+
*
|
|
7050
|
+
* // With Entity class
|
|
7051
|
+
* type UserResponse = Dto<User, 'passwordHash'>;
|
|
7052
|
+
*
|
|
7053
|
+
* // Exclude multiple fields
|
|
7054
|
+
* type UserPublic = Dto<User, 'passwordHash' | 'email'>;
|
|
7055
|
+
*
|
|
7056
|
+
* // Include all fields (no exclusions)
|
|
7057
|
+
* type UserFull = Dto<User>;
|
|
7058
|
+
* ```
|
|
7059
|
+
*/
|
|
7060
|
+
type Dto<T extends TableDef | EntityConstructor, TExclude extends keyof ExtractRow<T> = never> = Simplify<Omit<ExtractRow<T>, TExclude>>;
|
|
7061
|
+
/**
|
|
7062
|
+
* Compose a DTO with relations.
|
|
7063
|
+
*
|
|
7064
|
+
* @example
|
|
7065
|
+
* ```ts
|
|
7066
|
+
* type UserWithPosts = WithRelations<UserResponse, {
|
|
7067
|
+
* posts: PostResponse[]
|
|
7068
|
+
* }>;
|
|
7069
|
+
*
|
|
7070
|
+
* type PostWithAuthor = WithRelations<PostResponse, {
|
|
7071
|
+
* author: Dto<User, 'passwordHash' | 'email'>
|
|
7072
|
+
* }>;
|
|
7073
|
+
* ```
|
|
7074
|
+
*/
|
|
7075
|
+
type WithRelations<TBase, TRelations> = Simplify<TBase & TRelations>;
|
|
7076
|
+
type ColumnMap<T extends TableDef> = T['columns'];
|
|
7077
|
+
/**
|
|
7078
|
+
* Checks if a column has a default value.
|
|
7079
|
+
*/
|
|
7080
|
+
type HasDefault<TCol extends ColumnDef> = TCol['default'] extends undefined ? false : true;
|
|
7081
|
+
/**
|
|
7082
|
+
* Checks if a column is auto-generated (autoIncrement or generated always/byDefault).
|
|
7083
|
+
*/
|
|
7084
|
+
type IsAutoGenerated<TCol extends ColumnDef> = TCol['autoIncrement'] extends true ? true : TCol['generated'] extends 'always' | 'byDefault' ? true : false;
|
|
7085
|
+
/**
|
|
7086
|
+
* Checks if a column is insertable (not auto-generated).
|
|
7087
|
+
*/
|
|
7088
|
+
type IsInsertable<TCol extends ColumnDef> = IsAutoGenerated<TCol> extends true ? false : true;
|
|
7089
|
+
/**
|
|
7090
|
+
* Checks if a column is required for insert (notNull, no default, not auto-generated).
|
|
7091
|
+
*/
|
|
7092
|
+
type IsRequiredInsert<TCol extends ColumnDef> = TCol['notNull'] extends true ? IsAutoGenerated<TCol> extends true ? false : HasDefault<TCol> extends true ? false : true : false;
|
|
7093
|
+
/**
|
|
7094
|
+
* Keys that are required for insert (notNull, no default, not auto-generated).
|
|
7095
|
+
*/
|
|
7096
|
+
type RequiredInsertKeys<T extends TableDef> = {
|
|
7097
|
+
[K in keyof ColumnMap<T>]: ColumnMap<T>[K] extends ColumnDef ? IsInsertable<ColumnMap<T>[K]> extends true ? IsRequiredInsert<ColumnMap<T>[K]> extends true ? K : never : never : never;
|
|
7098
|
+
}[keyof ColumnMap<T>];
|
|
7099
|
+
/**
|
|
7100
|
+
* Keys that are optional for insert (nullable, has default, or optional).
|
|
7101
|
+
*/
|
|
7102
|
+
type OptionalInsertKeys<T extends TableDef> = {
|
|
7103
|
+
[K in keyof ColumnMap<T>]: ColumnMap<T>[K] extends ColumnDef ? IsInsertable<ColumnMap<T>[K]> extends true ? IsRequiredInsert<ColumnMap<T>[K]> extends false ? K : never : never : never;
|
|
7104
|
+
}[keyof ColumnMap<T>];
|
|
7105
|
+
/**
|
|
7106
|
+
* Create DTO - includes only insertable columns with proper optionality.
|
|
7107
|
+
* Auto-generated columns (autoIncrement, generated) are excluded.
|
|
7108
|
+
* Columns with defaults or nullable are optional.
|
|
7109
|
+
*
|
|
7110
|
+
* Works with both TableDef and EntityConstructor:
|
|
7111
|
+
* - For TableDef: Uses column metadata to determine required/optional fields
|
|
7112
|
+
* - For EntityConstructor: All fields are optional (simpler type inference)
|
|
7113
|
+
*
|
|
7114
|
+
* @example
|
|
7115
|
+
* ```ts
|
|
7116
|
+
* // With TableDef - auto-excludes id (autoIncrement), createdAt (has default)
|
|
7117
|
+
* type CreateUserDto = CreateDto<typeof usersTable>;
|
|
7118
|
+
* // → { name: string; email: string; bio?: string }
|
|
7119
|
+
*
|
|
7120
|
+
* // With Entity class - simpler inference, all fields optional
|
|
7121
|
+
* type CreateUserDto = CreateDto<User>;
|
|
7122
|
+
*
|
|
7123
|
+
* // Exclude additional fields (e.g., authorId comes from context)
|
|
7124
|
+
* type CreatePostDto = CreateDto<typeof Post, 'authorId'>;
|
|
7125
|
+
* ```
|
|
7126
|
+
*/
|
|
7127
|
+
type CreateDto<T extends TableDef | EntityConstructor, TExclude extends keyof ExtractRow<T> = never> = T extends TableDef<any> ? Simplify<{
|
|
7128
|
+
[K in Exclude<RequiredInsertKeys<T>, TExclude>]: ColumnToTs<ColumnMap<T>[K]>;
|
|
7129
|
+
} & {
|
|
7130
|
+
[K in Exclude<OptionalInsertKeys<T>, TExclude>]?: ColumnToTs<ColumnMap<T>[K]>;
|
|
7131
|
+
}> : Simplify<{
|
|
7132
|
+
[K in Exclude<keyof ExtractRow<T>, TExclude>]?: ExtractRow<T>[K];
|
|
7133
|
+
}>;
|
|
7134
|
+
/**
|
|
7135
|
+
* Update DTO - all columns are optional (partial update).
|
|
7136
|
+
* Excludes specified columns (e.g., id, createdAt).
|
|
7137
|
+
*
|
|
7138
|
+
* @example
|
|
7139
|
+
* ```ts
|
|
7140
|
+
* // With TableDef
|
|
7141
|
+
* type UpdateUserDto = UpdateDto<typeof User>;
|
|
7142
|
+
* // → { name?: string; email?: string; bio?: string; ... }
|
|
7143
|
+
*
|
|
7144
|
+
* // With Entity class
|
|
7145
|
+
* type UpdateUserDto = UpdateDto<User>;
|
|
7146
|
+
*
|
|
7147
|
+
* // Exclude fields that shouldn't be updated
|
|
7148
|
+
* type UpdateUserDto = UpdateDto<typeof User, 'id' | 'createdAt'>;
|
|
7149
|
+
* ```
|
|
7150
|
+
*/
|
|
7151
|
+
type UpdateDto<T extends TableDef | EntityConstructor, TExclude extends keyof ExtractRow<T> = never> = T extends TableDef<any> ? Simplify<{
|
|
7152
|
+
[K in Exclude<keyof ColumnMap<T>, TExclude>]?: ColumnToTs<ColumnMap<T>[K]>;
|
|
7153
|
+
}> : Simplify<{
|
|
7154
|
+
[K in Exclude<keyof ExtractRow<T>, TExclude>]?: ExtractRow<T>[K];
|
|
7155
|
+
}>;
|
|
7156
|
+
/**
|
|
7157
|
+
* Enhanced paginated response with computed navigation metadata.
|
|
7158
|
+
* Extends the basic PaginatedResult with additional convenience fields.
|
|
7159
|
+
*
|
|
7160
|
+
* @example
|
|
7161
|
+
* ```ts
|
|
7162
|
+
* type UsersPagedResponse = PagedResponse<UserResponse>;
|
|
7163
|
+
*
|
|
7164
|
+
* // Response:
|
|
7165
|
+
* // {
|
|
7166
|
+
* // items: UserResponse[];
|
|
7167
|
+
* // totalItems: number;
|
|
7168
|
+
* // page: number;
|
|
7169
|
+
* // pageSize: number;
|
|
7170
|
+
* // totalPages: number;
|
|
7171
|
+
* // hasNextPage: boolean;
|
|
7172
|
+
* // hasPrevPage: boolean;
|
|
7173
|
+
* // }
|
|
7174
|
+
* ```
|
|
7175
|
+
*/
|
|
7176
|
+
type PagedResponse<T> = {
|
|
7177
|
+
items: T[];
|
|
7178
|
+
totalItems: number;
|
|
7179
|
+
page: number;
|
|
7180
|
+
pageSize: number;
|
|
7181
|
+
totalPages: number;
|
|
7182
|
+
hasNextPage: boolean;
|
|
7183
|
+
hasPrevPage: boolean;
|
|
7184
|
+
};
|
|
7185
|
+
|
|
7186
|
+
/**
|
|
7187
|
+
* Filter types for building type-safe query filters from JSON input.
|
|
7188
|
+
* Designed for REST API query parameters.
|
|
7189
|
+
*/
|
|
7190
|
+
|
|
7191
|
+
/**
|
|
7192
|
+
* Checks if a type is a TableDef.
|
|
7193
|
+
*/
|
|
7194
|
+
type IsTableDef<T> = T extends {
|
|
7195
|
+
name: string;
|
|
7196
|
+
columns: any;
|
|
7197
|
+
} ? true : false;
|
|
7198
|
+
/**
|
|
7199
|
+
* Maps TypeScript types to SQL column types for EntityConstructor columns.
|
|
7200
|
+
*/
|
|
7201
|
+
type TsTypeToColumnType<T> = T extends string ? 'VARCHAR' : T extends number ? 'INT' : T extends boolean ? 'BOOLEAN' : T extends Date ? 'TIMESTAMP' : 'VARCHAR';
|
|
7202
|
+
/**
|
|
7203
|
+
* Extracts the column map from either a TableDef or EntityConstructor.
|
|
7204
|
+
* For EntityConstructor, infers column type from TypeScript property type.
|
|
7205
|
+
*/
|
|
7206
|
+
type ExtractColumns<T> = IsTableDef<T> extends true ? T extends TableDef<infer C> ? C : never : T extends EntityConstructor<infer E> ? {
|
|
7207
|
+
[K in keyof E]: ColumnDef<TsTypeToColumnType<E[K]>, E[K]>;
|
|
7208
|
+
} : never;
|
|
7209
|
+
/**
|
|
7210
|
+
* Filter operators for string columns.
|
|
7211
|
+
*/
|
|
7212
|
+
interface StringFilter {
|
|
7213
|
+
equals?: string;
|
|
7214
|
+
not?: string;
|
|
7215
|
+
in?: string[];
|
|
7216
|
+
notIn?: string[];
|
|
7217
|
+
contains?: string;
|
|
7218
|
+
startsWith?: string;
|
|
7219
|
+
endsWith?: string;
|
|
7220
|
+
/** Case-insensitive matching (for contains, startsWith, endsWith) */
|
|
7221
|
+
mode?: 'default' | 'insensitive';
|
|
7222
|
+
}
|
|
7223
|
+
/**
|
|
7224
|
+
* Filter operators for numeric columns (number, bigint).
|
|
7225
|
+
*/
|
|
7226
|
+
interface NumberFilter {
|
|
7227
|
+
equals?: number;
|
|
7228
|
+
not?: number;
|
|
7229
|
+
in?: number[];
|
|
7230
|
+
notIn?: number[];
|
|
7231
|
+
lt?: number;
|
|
7232
|
+
lte?: number;
|
|
7233
|
+
gt?: number;
|
|
7234
|
+
gte?: number;
|
|
7235
|
+
}
|
|
7236
|
+
/**
|
|
7237
|
+
* Filter operators for boolean columns.
|
|
7238
|
+
*/
|
|
7239
|
+
interface BooleanFilter {
|
|
7240
|
+
equals?: boolean;
|
|
7241
|
+
not?: boolean;
|
|
7242
|
+
}
|
|
7243
|
+
/**
|
|
7244
|
+
* Filter operators for date/datetime columns.
|
|
7245
|
+
* Accepts ISO date strings.
|
|
7246
|
+
*/
|
|
7247
|
+
interface DateFilter {
|
|
7248
|
+
equals?: string;
|
|
7249
|
+
not?: string;
|
|
7250
|
+
in?: string[];
|
|
7251
|
+
notIn?: string[];
|
|
7252
|
+
lt?: string;
|
|
7253
|
+
lte?: string;
|
|
7254
|
+
gt?: string;
|
|
7255
|
+
gte?: string;
|
|
7256
|
+
}
|
|
7257
|
+
type NormalizedType<T extends ColumnDef> = Lowercase<T['type'] & string>;
|
|
7258
|
+
/**
|
|
7259
|
+
* Maps a column definition to its appropriate filter type.
|
|
7260
|
+
*/
|
|
7261
|
+
type FieldFilter<TCol extends ColumnDef> = NormalizedType<TCol> extends 'int' | 'integer' | 'bigint' | 'decimal' | 'float' | 'double' ? NumberFilter : NormalizedType<TCol> extends 'boolean' ? BooleanFilter : NormalizedType<TCol> extends 'date' | 'datetime' | 'timestamp' | 'timestamptz' ? DateFilter : StringFilter;
|
|
7262
|
+
/**
|
|
7263
|
+
* Full where input with all columns filterable.
|
|
7264
|
+
* All conditions are implicitly AND-ed.
|
|
7265
|
+
* Works with both TableDef and EntityConstructor.
|
|
7266
|
+
*
|
|
7267
|
+
* @example
|
|
7268
|
+
* ```ts
|
|
7269
|
+
* // With TableDef
|
|
7270
|
+
* type UserFilter = WhereInput<typeof usersTable>;
|
|
7271
|
+
*
|
|
7272
|
+
* // With Entity class
|
|
7273
|
+
* type UserFilter = WhereInput<User>;
|
|
7274
|
+
* ```
|
|
7275
|
+
*/
|
|
7276
|
+
type WhereInput<T extends TableDef | EntityConstructor> = {
|
|
7277
|
+
[K in keyof ExtractColumns<T>]?: ExtractColumns<T>[K] extends ColumnDef<any, any> ? FieldFilter<ExtractColumns<T>[K]> : FieldFilter<ColumnDef<any, any>>;
|
|
7278
|
+
};
|
|
7279
|
+
/**
|
|
7280
|
+
* Restricted where input - only specified columns are filterable.
|
|
7281
|
+
* Use this to limit which fields can be filtered via API.
|
|
7282
|
+
*
|
|
7283
|
+
* Works with both TableDef and EntityConstructor.
|
|
7284
|
+
*
|
|
7285
|
+
* @example
|
|
7286
|
+
* ```ts
|
|
7287
|
+
* // With TableDef - only allow filtering by name and email
|
|
7288
|
+
* type UserFilter = SimpleWhereInput<typeof usersTable, 'name' | 'email'>;
|
|
7289
|
+
*
|
|
7290
|
+
* // With Entity class
|
|
7291
|
+
* type UserFilter = SimpleWhereInput<User, 'name' | 'email'>;
|
|
7292
|
+
*
|
|
7293
|
+
* // Request: { "name": { "contains": "john" }, "email": { "endsWith": "@gmail.com" } }
|
|
7294
|
+
* ```
|
|
7295
|
+
*/
|
|
7296
|
+
type SimpleWhereInput<T extends TableDef | EntityConstructor, K extends keyof ExtractColumns<T>> = {
|
|
7297
|
+
[P in K]?: ExtractColumns<T>[P] extends ColumnDef<any, any> ? FieldFilter<ExtractColumns<T>[P]> : FieldFilter<ColumnDef<any, any>>;
|
|
7298
|
+
};
|
|
7299
|
+
/**
|
|
7300
|
+
* All possible filter operators.
|
|
7301
|
+
*/
|
|
7302
|
+
type FilterOperator = 'equals' | 'not' | 'in' | 'notIn' | 'lt' | 'lte' | 'gt' | 'gte' | 'contains' | 'startsWith' | 'endsWith';
|
|
7303
|
+
/**
|
|
7304
|
+
* Generic filter value that covers all operator types.
|
|
7305
|
+
*/
|
|
7306
|
+
type FilterValue = StringFilter | NumberFilter | BooleanFilter | DateFilter;
|
|
7307
|
+
|
|
7308
|
+
/**
|
|
7309
|
+
* Runtime filter application - converts JSON filter objects to query builder conditions.
|
|
7310
|
+
*/
|
|
7311
|
+
|
|
7312
|
+
/**
|
|
7313
|
+
* Applies a filter object to a SelectQueryBuilder.
|
|
7314
|
+
* All conditions are AND-ed together.
|
|
7315
|
+
*
|
|
7316
|
+
* @param qb - The query builder to apply filters to
|
|
7317
|
+
* @param tableOrEntity - The table definition or entity constructor (used to resolve column references)
|
|
7318
|
+
* @param where - The filter object from: API request
|
|
7319
|
+
* @returns The query builder with filters applied
|
|
7320
|
+
*
|
|
7321
|
+
* @example
|
|
7322
|
+
* ```ts
|
|
7323
|
+
* // In a controller - using Entity class
|
|
7324
|
+
* @Get()
|
|
7325
|
+
* async list(@Query() where?: UserFilter): Promise<UserResponse[]> {
|
|
7326
|
+
* let query = selectFromEntity(User);
|
|
7327
|
+
* query = applyFilter(query, User, where);
|
|
7328
|
+
* return query.execute(db);
|
|
7329
|
+
* }
|
|
7330
|
+
*
|
|
7331
|
+
* // Using TableDef directly
|
|
7332
|
+
* @Get()
|
|
7333
|
+
* async list(@Query() where?: UserFilter): Promise<UserResponse[]> {
|
|
7334
|
+
* let query = selectFrom(usersTable);
|
|
7335
|
+
* query = applyFilter(query, usersTable, where);
|
|
7336
|
+
* return query.execute(db);
|
|
7337
|
+
* }
|
|
7338
|
+
*
|
|
7339
|
+
* // Request: { "name": { "contains": "john" }, "email": { "endsWith": "@gmail.com" } }
|
|
7340
|
+
* // SQL: WHERE name LIKE '%john%' AND email LIKE '%@gmail.com'
|
|
7341
|
+
* ```
|
|
7342
|
+
*/
|
|
7343
|
+
declare function applyFilter<T, TTable extends TableDef>(qb: SelectQueryBuilder<T, TTable>, tableOrEntity: TTable | EntityConstructor, where?: WhereInput<any> | null): SelectQueryBuilder<T, TTable>;
|
|
7344
|
+
/**
|
|
7345
|
+
* Builds an expression tree from a filter object without applying it.
|
|
7346
|
+
* Useful for combining with other conditions.
|
|
7347
|
+
*
|
|
7348
|
+
* @param tableOrEntity - The table definition or entity constructor
|
|
7349
|
+
* @param where - The filter object
|
|
7350
|
+
* @returns An expression node or null if no filters
|
|
7351
|
+
*
|
|
7352
|
+
* @example
|
|
7353
|
+
* ```ts
|
|
7354
|
+
* // Using Entity class
|
|
7355
|
+
* const filterExpr = buildFilterExpression(User, { name: { contains: "john" } });
|
|
7356
|
+
*
|
|
7357
|
+
* // Using TableDef directly
|
|
7358
|
+
* const filterExpr = buildFilterExpression(usersTable, { name: { contains: "john" } });
|
|
7359
|
+
*
|
|
7360
|
+
* if (filterExpr) {
|
|
7361
|
+
* qb = qb.where(and(filterExpr, eq(users.columns.active, true)));
|
|
7362
|
+
* }
|
|
7363
|
+
* ```
|
|
7364
|
+
*/
|
|
7365
|
+
declare function buildFilterExpression(tableOrEntity: TableDef | EntityConstructor, where?: WhereInput<any> | null): ExpressionNode | null;
|
|
7366
|
+
|
|
7367
|
+
/**
|
|
7368
|
+
* DTO transformation utilities for working with DTO instances.
|
|
7369
|
+
*
|
|
7370
|
+
* These helpers make it easier to convert between DTO types, apply defaults,
|
|
7371
|
+
* and handle auto-generated fields without manual object construction.
|
|
7372
|
+
*/
|
|
7373
|
+
/**
|
|
7374
|
+
* Transforms a CreateDto or UpdateDto into a ResponseDto by merging with auto-generated fields.
|
|
7375
|
+
*
|
|
7376
|
+
* @example
|
|
7377
|
+
* ```ts
|
|
7378
|
+
* const newUser: UserResponse = toResponse(body, {
|
|
7379
|
+
* id: newId,
|
|
7380
|
+
* createdAt: new Date().toISOString()
|
|
7381
|
+
* });
|
|
7382
|
+
*
|
|
7383
|
+
* // Or use the curried form for reuse
|
|
7384
|
+
* const createUserResponse = toResponseBuilder<UserCreateDto, UserResponse>({
|
|
7385
|
+
* id: () => nextId++,
|
|
7386
|
+
* createdAt: () => new Date().toISOString()
|
|
7387
|
+
* });
|
|
7388
|
+
* const user = createUserResponse(body);
|
|
7389
|
+
* ```
|
|
7390
|
+
*/
|
|
7391
|
+
declare function toResponse<TInput, TOutput>(input: TInput, autoFields: Partial<TOutput>): TOutput;
|
|
7392
|
+
/**
|
|
7393
|
+
* Creates a toResponse function with pre-configured auto-fields.
|
|
7394
|
+
* Useful for reusing same transformation logic across multiple endpoints.
|
|
7395
|
+
*
|
|
7396
|
+
* @example
|
|
7397
|
+
* ```ts
|
|
7398
|
+
* const userResponseBuilder = toResponseBuilder<CreateUserDto, UserResponse>({
|
|
7399
|
+
* id: () => generateId(),
|
|
7400
|
+
* createdAt: () => new Date().toISOString(),
|
|
7401
|
+
* active: true
|
|
7402
|
+
* });
|
|
7403
|
+
*
|
|
7404
|
+
* app.post('/users', (req, res) => {
|
|
7405
|
+
* const user = userResponseBuilder(req.body);
|
|
7406
|
+
* res.status(201).json(user);
|
|
7407
|
+
* });
|
|
7408
|
+
* ```
|
|
7409
|
+
*/
|
|
7410
|
+
declare function toResponseBuilder<TInput, TOutput>(autoFields: Partial<TOutput> | (() => Partial<TOutput>)): (input: TInput) => TOutput;
|
|
7411
|
+
/**
|
|
7412
|
+
* Merges default values into a DTO. Returns a complete object with all defaults applied.
|
|
7413
|
+
*
|
|
7414
|
+
* @example
|
|
7415
|
+
* ```ts
|
|
7416
|
+
* const user = withDefaults(body, {
|
|
7417
|
+
* active: true,
|
|
7418
|
+
* createdAt: new Date().toISOString()
|
|
7419
|
+
* });
|
|
7420
|
+
* ```
|
|
7421
|
+
*/
|
|
7422
|
+
declare function withDefaults<T>(dto: Partial<T>, defaults: T): T;
|
|
7423
|
+
/**
|
|
7424
|
+
* Creates a withDefaults function with pre-configured defaults.
|
|
7425
|
+
*
|
|
7426
|
+
* @example
|
|
7427
|
+
* ```ts
|
|
7428
|
+
* const userWithDefaults = withDefaultsBuilder<CreateUserDto>({
|
|
7429
|
+
* active: true
|
|
7430
|
+
* });
|
|
7431
|
+
*
|
|
7432
|
+
* app.post('/users', (req, res) => {
|
|
7433
|
+
* const userInput = userWithDefaults(req.body);
|
|
7434
|
+
* // ...
|
|
7435
|
+
* });
|
|
7436
|
+
* ```
|
|
7437
|
+
*/
|
|
7438
|
+
declare function withDefaultsBuilder<T>(defaults: T | (() => T)): (dto: Partial<T>) => T;
|
|
7439
|
+
/**
|
|
7440
|
+
* Excludes specified fields from an object. Useful for removing sensitive fields
|
|
7441
|
+
* from database results before sending to the client.
|
|
7442
|
+
*
|
|
7443
|
+
* @example
|
|
7444
|
+
* ```ts
|
|
7445
|
+
* const userFromDb = await db.select().from(users).where(...).first();
|
|
7446
|
+
* const userResponse = exclude(userFromDb, 'passwordHash', 'apiKey');
|
|
7447
|
+
* ```
|
|
7448
|
+
*/
|
|
7449
|
+
declare function exclude<T extends object, K extends keyof T>(obj: T, ...keys: K[]): Omit<T, K>;
|
|
7450
|
+
/**
|
|
7451
|
+
* Picks only specified fields from an object. Useful for creating DTOs from
|
|
7452
|
+
* larger database entities.
|
|
7453
|
+
*
|
|
7454
|
+
* @example
|
|
7455
|
+
* ```ts
|
|
7456
|
+
* const userFromDb = await db.select().from(users).where(...).first();
|
|
7457
|
+
* const userResponse = pick(userFromDb, 'id', 'name', 'email');
|
|
7458
|
+
* ```
|
|
7459
|
+
*/
|
|
7460
|
+
declare function pick<T extends object, K extends keyof T>(obj: T, ...keys: K[]): Pick<T, K>;
|
|
7461
|
+
/**
|
|
7462
|
+
* Maps field names from one DTO to another. Useful when your DTO has different
|
|
7463
|
+
* field names than your entity (e.g., camelCase vs snake_case).
|
|
7464
|
+
*
|
|
7465
|
+
* @example
|
|
7466
|
+
* ```ts
|
|
7467
|
+
* type ApiUser = { firstName: string; lastName: string };
|
|
7468
|
+
* type DbUser = { first_name: string; last_name: string };
|
|
7469
|
+
*
|
|
7470
|
+
* const dbUser = mapFields(apiUser, {
|
|
7471
|
+
* firstName: 'first_name',
|
|
7472
|
+
* lastName: 'last_name'
|
|
7473
|
+
* });
|
|
7474
|
+
* ```
|
|
7475
|
+
*/
|
|
7476
|
+
declare function mapFields<T extends object>(obj: T, fieldMap: Partial<Record<keyof T, string>>): Record<string, unknown>;
|
|
7477
|
+
|
|
7478
|
+
/**
|
|
7479
|
+
* Pagination utility functions for DTO responses.
|
|
7480
|
+
* Converts basic PaginatedResult to enhanced PagedResponse with computed metadata.
|
|
7481
|
+
*/
|
|
7482
|
+
|
|
7483
|
+
/**
|
|
7484
|
+
* Converts PaginatedResult to PagedResponse with computed metadata.
|
|
7485
|
+
*
|
|
7486
|
+
* @param result - The basic paginated result from executePaged()
|
|
7487
|
+
* @returns Enhanced paginated response with totalPages, hasNextPage, hasPrevPage
|
|
7488
|
+
*
|
|
7489
|
+
* @example
|
|
7490
|
+
* ```ts
|
|
7491
|
+
* // In your controller
|
|
7492
|
+
* const basic = await qb.executePaged(session, { page: 2, pageSize: 20 });
|
|
7493
|
+
* const response = toPagedResponse(basic);
|
|
7494
|
+
* return res.json(response);
|
|
7495
|
+
* // → { items: [...], totalItems: 150, page: 2, pageSize: 20,
|
|
7496
|
+
* // totalPages: 8, hasNextPage: true, hasPrevPage: true }
|
|
7497
|
+
* ```
|
|
7498
|
+
*/
|
|
7499
|
+
declare function toPagedResponse<T>(result: PaginatedResult<T>): PagedResponse<T>;
|
|
7500
|
+
/**
|
|
7501
|
+
* Creates a reusable toPagedResponse function with fixed pageSize.
|
|
7502
|
+
* Useful when your API uses a consistent page size across all endpoints.
|
|
7503
|
+
*
|
|
7504
|
+
* @param fixedPageSize - The fixed page size to use
|
|
7505
|
+
* @returns A function that converts PaginatedResult to PagedResponse
|
|
7506
|
+
*
|
|
7507
|
+
* @example
|
|
7508
|
+
* ```ts
|
|
7509
|
+
* const toUserPagedResponse = toPagedResponseBuilder<UserResponse>(20);
|
|
7510
|
+
*
|
|
7511
|
+
* app.get('/users', async (req, res) => {
|
|
7512
|
+
* const basic = await qb.executePaged(session, { page: req.query.page || 1, pageSize: 20 });
|
|
7513
|
+
* const response = toUserPagedResponse(basic);
|
|
7514
|
+
* res.json(response);
|
|
7515
|
+
* });
|
|
7516
|
+
* ```
|
|
7517
|
+
*/
|
|
7518
|
+
declare function toPagedResponseBuilder<T>(fixedPageSize: number): (result: Omit<PaginatedResult<T>, 'pageSize'> & {
|
|
7519
|
+
pageSize?: number;
|
|
7520
|
+
}) => PagedResponse<T>;
|
|
7521
|
+
/**
|
|
7522
|
+
* Calculates total pages from total items and page size.
|
|
7523
|
+
*
|
|
7524
|
+
* @param totalItems - Total number of items
|
|
7525
|
+
* @param pageSize - Number of items per page
|
|
7526
|
+
* @returns Total number of pages (minimum 1)
|
|
7527
|
+
*
|
|
7528
|
+
* @example
|
|
7529
|
+
* ```ts
|
|
7530
|
+
* const totalPages = calculateTotalPages(150, 20); // → 8
|
|
7531
|
+
* const totalPages = calculateTotalPages(150, 50); // → 3
|
|
7532
|
+
* ```
|
|
7533
|
+
*/
|
|
7534
|
+
declare function calculateTotalPages(totalItems: number, pageSize: number): number;
|
|
7535
|
+
/**
|
|
7536
|
+
* Checks if there is a next page.
|
|
7537
|
+
*
|
|
7538
|
+
* @param currentPage - Current page number (1-based)
|
|
7539
|
+
* @param totalPages - Total number of pages
|
|
7540
|
+
* @returns true if there is a next page
|
|
7541
|
+
*
|
|
7542
|
+
* @example
|
|
7543
|
+
* ```ts
|
|
7544
|
+
* const hasNext = hasNextPage(2, 8); // → true
|
|
7545
|
+
* const hasNext = hasNextPage(8, 8); // → false
|
|
7546
|
+
* ```
|
|
7547
|
+
*/
|
|
7548
|
+
declare function hasNextPage(currentPage: number, totalPages: number): boolean;
|
|
7549
|
+
/**
|
|
7550
|
+
* Checks if there is a previous page.
|
|
7551
|
+
*
|
|
7552
|
+
* @param currentPage - Current page number (1-based)
|
|
7553
|
+
* @returns true if there is a previous page
|
|
7554
|
+
*
|
|
7555
|
+
* @example
|
|
7556
|
+
* ```ts
|
|
7557
|
+
* const hasPrev = hasPrevPage(2); // → true
|
|
7558
|
+
* const hasPrev = hasPrevPage(1); // → false
|
|
7559
|
+
* ```
|
|
7560
|
+
*/
|
|
7561
|
+
declare function hasPrevPage(currentPage: number): boolean;
|
|
7562
|
+
/**
|
|
7563
|
+
* Computes all pagination metadata from basic pagination info.
|
|
7564
|
+
*
|
|
7565
|
+
* @param totalItems - Total number of items
|
|
7566
|
+
* @param page - Current page number (1-based)
|
|
7567
|
+
* @param pageSize - Number of items per page
|
|
7568
|
+
* @returns Object with totalPages, hasNextPage, hasPrevPage
|
|
7569
|
+
*
|
|
7570
|
+
* @example
|
|
7571
|
+
* ```ts
|
|
7572
|
+
* const meta = computePaginationMetadata(150, 2, 20);
|
|
7573
|
+
* // → { totalPages: 8, hasNextPage: true, hasPrevPage: true }
|
|
7574
|
+
* ```
|
|
7575
|
+
*/
|
|
7576
|
+
declare function computePaginationMetadata(totalItems: number, page: number, pageSize: number): Pick<PagedResponse<unknown>, 'totalPages' | 'hasNextPage' | 'hasPrevPage'>;
|
|
7577
|
+
|
|
7578
|
+
type OpenApiType = 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object' | 'null';
|
|
7579
|
+
interface OpenApiSchema {
|
|
7580
|
+
type?: OpenApiType | OpenApiType[];
|
|
7581
|
+
properties?: Record<string, OpenApiSchema>;
|
|
7582
|
+
items?: OpenApiSchema;
|
|
7583
|
+
required?: string[];
|
|
7584
|
+
enum?: unknown[];
|
|
7585
|
+
format?: string;
|
|
7586
|
+
description?: string;
|
|
7587
|
+
example?: unknown;
|
|
7588
|
+
nullable?: boolean;
|
|
7589
|
+
minimum?: number;
|
|
7590
|
+
maximum?: number;
|
|
7591
|
+
default?: unknown;
|
|
7592
|
+
$ref?: string;
|
|
7593
|
+
allOf?: OpenApiSchema[];
|
|
7594
|
+
oneOf?: OpenApiSchema[];
|
|
7595
|
+
}
|
|
7596
|
+
interface OpenApiParameter {
|
|
7597
|
+
name: string;
|
|
7598
|
+
in: 'query' | 'path' | 'header' | 'cookie';
|
|
7599
|
+
required?: boolean;
|
|
7600
|
+
schema?: OpenApiSchema;
|
|
7601
|
+
description?: string;
|
|
7602
|
+
}
|
|
7603
|
+
interface OpenApiOperation {
|
|
7604
|
+
summary?: string;
|
|
7605
|
+
description?: string;
|
|
7606
|
+
parameters?: OpenApiParameter[];
|
|
7607
|
+
requestBody?: {
|
|
7608
|
+
description?: string;
|
|
7609
|
+
required?: boolean;
|
|
7610
|
+
content: {
|
|
7611
|
+
'application/json': {
|
|
7612
|
+
schema: OpenApiSchema;
|
|
7613
|
+
};
|
|
7614
|
+
};
|
|
7615
|
+
};
|
|
7616
|
+
responses?: Record<string, {
|
|
7617
|
+
description: string;
|
|
7618
|
+
content?: {
|
|
7619
|
+
'application/json': {
|
|
7620
|
+
schema: OpenApiSchema;
|
|
7621
|
+
};
|
|
7622
|
+
};
|
|
7623
|
+
}>;
|
|
7624
|
+
}
|
|
7625
|
+
interface OpenApiDocumentInfo {
|
|
7626
|
+
title: string;
|
|
7627
|
+
version: string;
|
|
7628
|
+
description?: string;
|
|
7629
|
+
}
|
|
7630
|
+
interface ApiRouteDefinition {
|
|
7631
|
+
path: string;
|
|
7632
|
+
method: 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
7633
|
+
operation: OpenApiOperation;
|
|
7634
|
+
}
|
|
7635
|
+
interface OpenApiComponent {
|
|
7636
|
+
schemas?: Record<string, OpenApiSchema>;
|
|
7637
|
+
parameters?: Record<string, OpenApiSchema>;
|
|
7638
|
+
responses?: Record<string, OpenApiSchema>;
|
|
7639
|
+
securitySchemes?: Record<string, unknown>;
|
|
7640
|
+
}
|
|
7641
|
+
|
|
7642
|
+
interface TypeMappingStrategy {
|
|
7643
|
+
supports(columnType: string): boolean;
|
|
7644
|
+
getOpenApiType(): OpenApiType;
|
|
7645
|
+
getFormat(columnType: string): string | undefined;
|
|
7646
|
+
}
|
|
7647
|
+
declare class IntegerTypeStrategy implements TypeMappingStrategy {
|
|
7648
|
+
private readonly types;
|
|
7649
|
+
supports(type: string): boolean;
|
|
7650
|
+
getOpenApiType(): OpenApiType;
|
|
7651
|
+
getFormat(): string | undefined;
|
|
7652
|
+
}
|
|
7653
|
+
declare class BigIntTypeStrategy implements TypeMappingStrategy {
|
|
7654
|
+
private readonly types;
|
|
7655
|
+
supports(type: string): boolean;
|
|
7656
|
+
getOpenApiType(): OpenApiType;
|
|
7657
|
+
getFormat(): string | undefined;
|
|
7658
|
+
}
|
|
7659
|
+
declare class DecimalTypeStrategy implements TypeMappingStrategy {
|
|
7660
|
+
private readonly types;
|
|
7661
|
+
supports(type: string): boolean;
|
|
7662
|
+
getOpenApiType(): OpenApiType;
|
|
7663
|
+
getFormat(): string | undefined;
|
|
7664
|
+
}
|
|
7665
|
+
declare class BooleanTypeStrategy implements TypeMappingStrategy {
|
|
7666
|
+
private readonly types;
|
|
7667
|
+
supports(type: string): boolean;
|
|
7668
|
+
getOpenApiType(): OpenApiType;
|
|
7669
|
+
getFormat(): undefined;
|
|
7670
|
+
}
|
|
7671
|
+
declare class UuidTypeStrategy implements TypeMappingStrategy {
|
|
7672
|
+
private readonly types;
|
|
7673
|
+
supports(type: string): boolean;
|
|
7674
|
+
getOpenApiType(): OpenApiType;
|
|
7675
|
+
getFormat(): string;
|
|
7676
|
+
}
|
|
7677
|
+
declare class DateTimeTypeStrategy implements TypeMappingStrategy {
|
|
7678
|
+
private readonly types;
|
|
7679
|
+
supports(type: string): boolean;
|
|
7680
|
+
getOpenApiType(): OpenApiType;
|
|
7681
|
+
getFormat(columnType?: string): string;
|
|
7682
|
+
}
|
|
7683
|
+
declare class StringTypeStrategy implements TypeMappingStrategy {
|
|
7684
|
+
private readonly types;
|
|
7685
|
+
supports(type: string): boolean;
|
|
7686
|
+
getOpenApiType(): OpenApiType;
|
|
7687
|
+
getFormat(): undefined;
|
|
7688
|
+
}
|
|
7689
|
+
declare class DefaultTypeStrategy implements TypeMappingStrategy {
|
|
7690
|
+
supports(): boolean;
|
|
7691
|
+
getOpenApiType(): OpenApiType;
|
|
7692
|
+
getFormat(): undefined;
|
|
7693
|
+
}
|
|
7694
|
+
declare class TypeMappingService {
|
|
7695
|
+
private readonly strategies;
|
|
7696
|
+
constructor();
|
|
7697
|
+
getOpenApiType(column: ColumnDef): OpenApiType;
|
|
7698
|
+
getFormat(column: ColumnDef): string | undefined;
|
|
7699
|
+
private findStrategy;
|
|
7700
|
+
registerStrategy(strategy: TypeMappingStrategy, index?: number): void;
|
|
7701
|
+
}
|
|
7702
|
+
declare const typeMappingService: TypeMappingService;
|
|
7703
|
+
declare function columnTypeToOpenApiType(col: ColumnDef): OpenApiType;
|
|
7704
|
+
declare function columnTypeToOpenApiFormat(col: ColumnDef): string | undefined;
|
|
7705
|
+
|
|
7706
|
+
declare function schemaToJson(schema: OpenApiSchema): string;
|
|
7707
|
+
declare function deepCloneSchema(schema: OpenApiSchema): OpenApiSchema;
|
|
7708
|
+
declare function mergeSchemas(base: OpenApiSchema, override: Partial<OpenApiSchema>): OpenApiSchema;
|
|
7709
|
+
declare function generateOpenApiDocument(info: OpenApiDocumentInfo, routes: ApiRouteDefinition[]): Record<string, unknown>;
|
|
7710
|
+
|
|
7711
|
+
declare function isTableDef(target: TableDef | EntityConstructor): target is TableDef;
|
|
7712
|
+
declare function getColumnMap(target: TableDef | EntityConstructor): Record<string, ColumnDef>;
|
|
7713
|
+
type TargetType<T extends TableDef | EntityConstructor> = T;
|
|
7714
|
+
|
|
7715
|
+
declare function columnToOpenApiSchema(col: ColumnDef): OpenApiSchema;
|
|
7716
|
+
|
|
7717
|
+
declare function dtoToOpenApiSchema<T extends TableDef | EntityConstructor, TExclude extends keyof any>(target: T, exclude?: TExclude[]): OpenApiSchema;
|
|
7718
|
+
declare function createDtoToOpenApiSchema<T extends TableDef | EntityConstructor, TExclude extends keyof any>(target: T, exclude?: TExclude[]): OpenApiSchema;
|
|
7719
|
+
declare function updateDtoToOpenApiSchema<T extends TableDef | EntityConstructor, TExclude extends keyof any>(target: T, exclude?: TExclude[]): OpenApiSchema;
|
|
7720
|
+
|
|
7721
|
+
declare function whereInputToOpenApiSchema<T extends TableDef | EntityConstructor>(target: T): OpenApiSchema;
|
|
7722
|
+
|
|
7723
|
+
declare function relationFilterToOpenApiSchema(relation: RelationDef, options?: {
|
|
7724
|
+
exclude?: string[];
|
|
7725
|
+
include?: string[];
|
|
7726
|
+
}): OpenApiSchema;
|
|
7727
|
+
declare function whereInputWithRelationsToOpenApiSchema<T extends TableDef | EntityConstructor>(target: T, options?: {
|
|
7728
|
+
columnExclude?: string[];
|
|
7729
|
+
columnInclude?: string[];
|
|
7730
|
+
relationExclude?: string[];
|
|
7731
|
+
relationInclude?: string[];
|
|
7732
|
+
maxDepth?: number;
|
|
7733
|
+
}): OpenApiSchema;
|
|
7734
|
+
declare function nestedWhereInputToOpenApiSchema<T extends TableDef | EntityConstructor>(target: T, depth?: number): OpenApiSchema;
|
|
7735
|
+
|
|
7736
|
+
interface ComponentOptions {
|
|
7737
|
+
prefix?: string;
|
|
7738
|
+
exclude?: string[];
|
|
7739
|
+
include?: string[];
|
|
7740
|
+
}
|
|
7741
|
+
interface NestedDtoOptions {
|
|
7742
|
+
maxDepth?: number;
|
|
7743
|
+
includeRelations?: boolean;
|
|
7744
|
+
componentOptions?: ComponentOptions;
|
|
7745
|
+
}
|
|
7746
|
+
interface ComponentReference {
|
|
7747
|
+
$ref: string;
|
|
7748
|
+
}
|
|
7749
|
+
declare function isComponentReference(schema: OpenApiSchema): schema is ComponentReference;
|
|
7750
|
+
declare function nestedDtoToOpenApiSchema<T extends TableDef | EntityConstructor>(target: T, options?: NestedDtoOptions): OpenApiSchema;
|
|
7751
|
+
declare function updateDtoWithRelationsToOpenApiSchema<T extends TableDef | EntityConstructor>(target: T, _options?: NestedDtoOptions): OpenApiSchema;
|
|
7752
|
+
declare function generateComponentSchemas(targets: Array<{
|
|
7753
|
+
name: string;
|
|
7754
|
+
table: TableDef | EntityConstructor;
|
|
7755
|
+
}>, options?: ComponentOptions): Record<string, OpenApiSchema>;
|
|
7756
|
+
declare function generateRelationComponents(tables: Array<{
|
|
7757
|
+
name: string;
|
|
7758
|
+
table: TableDef;
|
|
7759
|
+
}>, options?: ComponentOptions): Record<string, OpenApiSchema>;
|
|
7760
|
+
declare function createApiComponentsSection(schemas: Record<string, OpenApiSchema>, parameters?: Record<string, OpenApiSchema>, responses?: Record<string, OpenApiSchema>): OpenApiComponent;
|
|
7761
|
+
declare function createRef(path: string): ComponentReference;
|
|
7762
|
+
declare function schemaToRef(schemaName: string): ComponentReference;
|
|
7763
|
+
declare function parameterToRef(paramName: string): ComponentReference;
|
|
7764
|
+
declare function responseToRef(responseName: string): ComponentReference;
|
|
7765
|
+
declare function replaceWithRefs(schema: OpenApiSchema, schemaMap: Record<string, OpenApiSchema>, path?: string): OpenApiSchema;
|
|
7766
|
+
declare function extractReusableSchemas(schema: OpenApiSchema, existing?: Record<string, OpenApiSchema>, prefix?: string): Record<string, OpenApiSchema>;
|
|
7767
|
+
|
|
7768
|
+
interface PaginationParams {
|
|
7769
|
+
page?: number;
|
|
7770
|
+
pageSize?: number;
|
|
7771
|
+
sortBy?: string;
|
|
7772
|
+
sortOrder?: 'asc' | 'desc';
|
|
7773
|
+
}
|
|
7774
|
+
declare const paginationParamsSchema: OpenApiSchema;
|
|
7775
|
+
declare function toPaginationParams(): OpenApiParameter[];
|
|
7776
|
+
declare function pagedResponseToOpenApiSchema<T extends OpenApiSchema>(itemSchema: T): OpenApiSchema;
|
|
7777
|
+
|
|
7778
|
+
export { type AliasRefNode, type AnyDomainEvent, type ApiRouteDefinition, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToReferenceApi, type BelongsToRelation, type BetweenExpressionNode, BigIntTypeStrategy, type BinaryExpressionNode, type BitwiseExpressionNode, type BooleanFilter, BooleanTypeStrategy, type CascadeMode, type CaseExpressionNode, type CastExpressionNode, type CheckConstraint, type CollateExpressionNode, Column, type ColumnDef, type ColumnDiff, type ColumnInput, type ColumnNode, type ColumnOptions, type ColumnRef, type ColumnToTs, type ColumnType, type ComponentOptions, type ComponentReference, ConstructorMaterializationStrategy, type CreateDto, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DateFilter, DateTimeTypeStrategy, type DbExecutor, type DbExecutorFactory, DecimalTypeStrategy, type DecoratedEntityInstance, DefaultBelongsToReference, DefaultEntityMaterializer, DefaultHasManyCollection, DefaultManyToManyCollection, DefaultTypeStrategy, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, type Dto, Entity, type EntityContext, type EntityInstance, type EntityMaterializationStrategy, type EntityMaterializer, type EntityOptions, type PrimaryKey$1 as EntityPrimaryKey, EntityStatus, type ExecutionContext, type ExistsExpressionNode, type ExpressionNode, type ExpressionVisitor, type FieldFilter, type FilterOperator, type FilterValue, type ForeignKeyReference, type FunctionNode, type GroupConcatOptions, type HasDomainEvents, HasMany, type HasManyCollection, type HasManyOptions, type HasManyRelation, HasOne, type HasOneOptions, type HasOneReference, type HasOneReferenceApi, type HasOneRelation, type HydrationContext, type HydrationMetadata, type HydrationPivotPlan, type HydrationPlan, type HydrationRelationPlan, type InExpressionNode, type InExpressionRight, type IndexColumn, type IndexDef, type InferRow, type InitialHandlers, InsertQueryBuilder, IntegerTypeStrategy, InterceptorPipeline, type IntrospectOptions, type JsonPathNode, type Jsonify, type JsonifyScalar, type LiteralNode, type LiteralValue, type LogicalExpressionNode, type ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NestedDtoOptions, type NullExpressionNode, type NumberFilter, type OpenApiComponent, type OpenApiDocumentInfo, type OpenApiOperation, type OpenApiParameter, type OpenApiSchema, type OpenApiType, type OperandNode, type OperandVisitor, Orm, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, type PagedResponse, type PaginatedResult, type PaginationParams, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type Primitive, PrototypeMaterializationStrategy, type QueryContext, type QueryInterceptor, type QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationKey$1 as RelationKey, RelationKinds, type RelationMap, type RelationTargetTable, type RelationType, type RenderColumnOptions, STANDARD_COLUMN_TYPES, type SaveGraphInputPayload, type SaveGraphInputScalar, type SaveGraphJsonScalar, type SaveGraphSessionOptions, type ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaGenerateResult, type SchemaIntrospector, type SchemaPlan, SelectQueryBuilder, type SelectQueryInput, type SelectableKeys, type SimpleQueryRunner, type SimpleWhereInput, type Simplify, SqlServerDialect, type SqliteClientLike, SqliteDialect, type StandardColumnType, type StringFilter, StringTypeStrategy, type SynchronizeOptions, type TableDef, type TableHooks, type TableOptions, type TableRef$1 as TableRef, type TargetType, type TediousColumn, type TediousConnectionLike, type TediousModule, type TediousRequest, type TediousRequestCtor, type TediousTypes, type TrackedEntity, TypeMappingService, type TypeMappingStrategy, TypeScriptGenerator, type TypedExpression, type TypedLike, type UpdateDto, UpdateQueryBuilder, UuidTypeStrategy, type ValueOperandInput, type WhereInput, type WindowFunctionNode, type WithRelations, abs, acos, add, addDomainEvent, age, aliasRef, and, applyFilter, arrayAppend, asType, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bitAnd, bitLength, bitOr, bitXor, bootstrapEntities, buildFilterExpression, calculateTotalPages, caseWhen, cast, cbrt, ceil, ceiling, char, charLength, chr, clearExpressionDispatchers, clearOperandDispatchers, coalesce, col, collate, columnOperand, columnToOpenApiSchema, columnTypeToOpenApiFormat, columnTypeToOpenApiType, computePaginationMetadata, concat, concatWs, correlateBy, cos, cot, count, countAll, createApiComponentsSection, createDtoToOpenApiSchema, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createRef, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, deepCloneSchema, defineTable, degrees, deleteFrom, denseRank, diffSchema, div, dtoToOpenApiSchema, endOfMonth, entityRef, entityRefs, eq, esel, exclude, executeHydrated, executeHydratedPlain, executeHydratedPlainWithContexts, executeHydratedWithContexts, executeSchemaSql, executeSchemaSqlFor, exists, exp, extract, extractReusableSchemas, firstValue, floor, fromUnixTime, generateComponentSchemas, generateCreateTableSql, generateOpenApiDocument, generateRelationComponents, generateSchemaSql, generateSchemaSqlFor, getColumn, getColumnMap, getDecoratorMetadata, getSchemaIntrospector, getTableDefFromEntity, greatest, groupConcat, gt, gte, hasMany, hasNextPage as hasNextPageMeta, hasOne, hasPrevPage as hasPrevPageMeta, hour, hydrateRows, ifNull, inList, inSubquery, initcap, insertInto, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isCollateExpressionNode, isComponentReference, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isTableDef, isValueOperandInput, isWindowFunctionNode, jsonArrayAgg, jsonContains, jsonLength, jsonPath, jsonSet, jsonify, lag, lastValue, lead, least, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, localTime, localTimestamp, locate, log, log10, log2, logBase, lower, lpad, lt, lte, ltrim, mapFields, materializeAs, max, md5, mergeSchemas, min, minute, mod, month, mul, neq, nestedDtoToOpenApiSchema, nestedWhereInputToOpenApiSchema, normalizeColumnType, notBetween, notExists, notInList, notInSubquery, notLike, now, ntile, nullif, octetLength, or, outerRef, pagedResponseToOpenApiSchema, paginationParamsSchema, parameterToRef, pi, pick, position, pow, power, quarter, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, relationFilterToOpenApiSchema, relationLoaderCache, renderColumnDefinition, renderTypeWithArgs, repeat, replace, replaceWithRefs, responseToRef, reverse, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, schemaToJson, schemaToRef, second, sel, selectFrom, selectFromEntity, setRelations, sha1, sha2, shiftLeft, shiftRight, sign, sin, space, sqrt, stddev, sub, substr, sum, synchronizeSchema, tableRef, tan, toColumnRef, toPagedResponse, toPagedResponseBuilder, toPaginationParams, toResponse, toResponseBuilder, toTableRef, trim, trunc, truncate, typeMappingService, unixTimestamp, update, updateDtoToOpenApiSchema, updateDtoWithRelationsToOpenApiSchema, upper, utcNow, valueToOperand, variance, visitExpression, visitOperand, weekOfYear, whereInputToOpenApiSchema, whereInputWithRelationsToOpenApiSchema, windowFunction, withDefaults, withDefaultsBuilder, year };
|