metal-orm 1.1.8 → 1.1.9
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/README.md +1 -1
- package/dist/index.cjs +219 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +47 -2
- package/dist/index.d.ts +47 -2
- package/dist/index.js +219 -1
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/query-builder/select/cursor-pagination.ts +323 -0
- package/src/query-builder/select.ts +42 -1
package/dist/index.d.cts
CHANGED
|
@@ -4430,6 +4430,23 @@ interface PaginatedResult<T> {
|
|
|
4430
4430
|
pageSize: number;
|
|
4431
4431
|
}
|
|
4432
4432
|
|
|
4433
|
+
type CursorPageOptions = {
|
|
4434
|
+
first?: number;
|
|
4435
|
+
after?: string;
|
|
4436
|
+
last?: number;
|
|
4437
|
+
before?: string;
|
|
4438
|
+
};
|
|
4439
|
+
type CursorPageInfo = {
|
|
4440
|
+
hasNextPage: boolean;
|
|
4441
|
+
hasPreviousPage: boolean;
|
|
4442
|
+
startCursor: string | null;
|
|
4443
|
+
endCursor: string | null;
|
|
4444
|
+
};
|
|
4445
|
+
type CursorPageResult<T> = {
|
|
4446
|
+
items: T[];
|
|
4447
|
+
pageInfo: CursorPageInfo;
|
|
4448
|
+
};
|
|
4449
|
+
|
|
4433
4450
|
/**
|
|
4434
4451
|
* Facet para gerenciar estado de cache no SelectQueryBuilder
|
|
4435
4452
|
* Segue o padrão de facets existente no projeto
|
|
@@ -4927,7 +4944,35 @@ declare class SelectQueryBuilder<T = EntityInstance<TableDef>, TTable extends Ta
|
|
|
4927
4944
|
pageSize: number;
|
|
4928
4945
|
}): Promise<PaginatedResult<T>>;
|
|
4929
4946
|
/**
|
|
4930
|
-
* Executes the query
|
|
4947
|
+
* Executes the query using cursor-based (keyset) pagination.
|
|
4948
|
+
* Requires a stable ORDER BY on selected, non-null columns.
|
|
4949
|
+
* Cursor pagination currently supports simple column references only and
|
|
4950
|
+
* the cursor token is opaque: it must be reused with the same ORDER BY signature.
|
|
4951
|
+
*
|
|
4952
|
+
* @param session - ORM session context
|
|
4953
|
+
* @param options - Cursor pagination options (`first`/`after` or `last`/`before`)
|
|
4954
|
+
* @returns Promise of cursor-paginated result with items and pageInfo
|
|
4955
|
+
* @example
|
|
4956
|
+
* const page1 = await selectFrom(users)
|
|
4957
|
+
* .orderBy(users.columns.createdAt, 'DESC')
|
|
4958
|
+
* .orderBy(users.columns.id, 'DESC')
|
|
4959
|
+
* .executeCursor(session, { first: 20 });
|
|
4960
|
+
*
|
|
4961
|
+
* // Next page
|
|
4962
|
+
* const page2 = await selectFrom(users)
|
|
4963
|
+
* .orderBy(users.columns.createdAt, 'DESC')
|
|
4964
|
+
* .orderBy(users.columns.id, 'DESC')
|
|
4965
|
+
* .executeCursor(session, { first: 20, after: page1.pageInfo.endCursor });
|
|
4966
|
+
*
|
|
4967
|
+
* // Previous page from a known cursor
|
|
4968
|
+
* const prevPage = await selectFrom(users)
|
|
4969
|
+
* .orderBy(users.columns.createdAt, 'DESC')
|
|
4970
|
+
* .orderBy(users.columns.id, 'DESC')
|
|
4971
|
+
* .executeCursor(session, { last: 20, before: page2.pageInfo.startCursor });
|
|
4972
|
+
*/
|
|
4973
|
+
executeCursor(session: OrmSession, options: CursorPageOptions): Promise<CursorPageResult<T>>;
|
|
4974
|
+
/**
|
|
4975
|
+
* Executes the query and returns an array of values for a single column.
|
|
4931
4976
|
* This is a convenience method to avoid manual `.map(r => r.column)`.
|
|
4932
4977
|
*
|
|
4933
4978
|
* @param column - The column name to extract
|
|
@@ -9850,4 +9895,4 @@ declare function setTreeBounds(entity: object, config: TreeConfig, lft: number,
|
|
|
9850
9895
|
*/
|
|
9851
9896
|
declare function setTreeParentId(entity: object, config: TreeConfig, parentId: unknown): void;
|
|
9852
9897
|
|
|
9853
|
-
export { type AliasRefNode, Alphanumeric, type AnyDomainEvent, type ApiRouteDefinition, type ApplyFilterOptions, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, type AutoCorrectionResult, type AutoTransformResult, type AutoTransformableValidator, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToReferenceApi, type BelongsToRelation, type BetweenExpressionNode, BigIntTypeStrategy, type BinaryExpressionNode, BinaryTypeStrategy, type BitwiseExpressionNode, type BooleanFilter, BooleanTypeStrategy, CEP, CNPJ, CPF, type CacheCapabilities, type CacheInvalidator, type CacheOptions, type CacheProvider, type CacheReader, type CacheState, type CacheStrategy, type CacheWriter, type CallProcedureOptions, Capitalize, 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, type CompositeTransformer, ConflictBuilder, ConstructorMaterializationStrategy, type ValidationResult as CountryValidationResult, type CountryValidator, type CountryValidatorFactory, type CreateDto, type CreateTediousClientOptions, DEFAULT_TREE_CONFIG, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DatabaseView, type DateFilter, DateTimeTypeStrategy, type DbExecutor, type DbExecutorFactory, DecimalTypeStrategy, type DecoratedEntityInstance, DefaultBelongsToReference, DefaultCacheStrategy, DefaultEntityMaterializer, DefaultHasManyCollection, DefaultManyToManyCollection, DefaultTypeStrategy, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, type Dto, type Duration, Email, Entity, type EntityContext, type EntityInstance, type EntityMaterializationStrategy, type EntityMaterializer, type EntityOptions, type PrimaryKey$1 as EntityPrimaryKey, EntityStatus, type ExecuteFilteredPagedOptions, type ExecutionContext, type ExecutionPayload, type ExistsExpressionNode, type ExpressionNode, type ExpressionVisitor, type FieldFilter, type FilterOperator, type FilterValue, type FindChildrenOptions, type FindPathOptions, 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 InvalidationStrategy, type JsonArray, type JsonObject, type JsonPathNode, type JsonValue, type Jsonify, type JsonifyScalar, KeyvCacheAdapter, Length, type LiteralNode, type LiteralValue, type LogicalExpressionNode, Lower, type ManyToManyCollection, MemoryCacheAdapter, type MoveOptions, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NestedDtoOptions, type NestedSetBounds, type NestedSetRow, NestedSetStrategy, type NodeWithPk, type NullExpressionNode, type NumberFilter, type OpenApiComponent, type OpenApiDialect, type OpenApiDocument, type OpenApiDocumentInfo, type OpenApiDocumentOptions, type OpenApiOperation, type OpenApiParameter, type OpenApiParameterObject, type OpenApiResponseObject, type OpenApiSchema, type OpenApiType, type OperandNode, type OperandVisitor, Orm, type OrmCacheOptions, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, type PagedResponse, type PaginatedResult, type PaginationParams, type PatchGraphInputPayload, Pattern, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type Primitive, ProcedureCallBuilder, type ProcedureCallNode, type ProcedureDirection, type ProcedureExecutionResult, type ProcedureOutOptions, type ProcedureParamNode, type ProcedureRefNode, type PropertySanitizer, type PropertyTransformer, type PropertyValidator, PrototypeMaterializationStrategy, QueryCacheManager, type QueryContext, type QueryInterceptor, type QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type RecoverResult, RedisCacheAdapter, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationFilter, 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, TagIndex, type TargetType, type TediousColumn, type TediousConnectionLike, type TediousModule, type TediousRequest, type TediousRequestCtor, type TediousTypes, type ThreadedNode, Title, type ToJsonOptions, type TrackedEntity, type TransformContext, type TransformerConfig, type TransformerMetadata, Tree, TreeChildren, type TreeColumns, type TreeConfig, type TreeDecoratorOptions, type TreeInsertData, type TreeListEntry, type TreeListOptions, type TreeListSchemaOptions, TreeManager, type TreeManagerOptions, type TreeMetadata, type TreeMoveData, type TreeNode, type TreeNodeResult, type TreeNodeResultSchemaOptions, type TreeNodeSchemaOptions, TreeParent, type TreeQuery, type TreeScope, type TreeValidationResult, Trim, TypeMappingService, type TypeMappingStrategy, TypeScriptGenerator, type TypedExpression, type TypedLike, type UpdateDto, UpdateQueryBuilder, Upper, UuidTypeStrategy, type ValidationOptions, type ValidationResult$1 as ValidationResult, type ValidatorFactoryOptions, type ValueOperandInput, type WhereInput, type WindowFunctionNode, type WithRelations, abs, acos, add, addDomainEvent, addEntityRelation, addRelation, age, aliasRef, and, applyFilter, applyNullability, arrayAppend, asType, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bitAnd, bitLength, bitOr, bitXor, bootstrapEntities, buildFilterExpression, buildScopeConditions, calculateRowDepths, calculateTotalPages, callProcedure, canonicalizeSchema, caseWhen, cast, cbrt, ceil, ceiling, char, charLength, chr, clearExpressionDispatchers, clearOperandDispatchers, coalesce, col, collate, columnOperand, columnToFilterSchema, columnToOpenApiSchema, columnTypeToOpenApiFormat, columnTypeToOpenApiType, computePaginationMetadata, computeSchemaHash, concat, concatWs, correlateBy, cos, cot, count, countAll, createApiComponentsSection, createDeterministicNamingState, createDtoToOpenApiSchema, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createRef, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, createTreeManager, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, deepCloneSchema, defineTable, degrees, deleteFrom, denseRank, diffSchema, div, dtoToOpenApiSchema, endOfMonth, entityRef, entityRefs, eq, esel, exclude, executeFilteredPaged, executeHydrated, executeHydratedPlain, executeHydratedPlainWithContexts, executeHydratedWithContexts, executeProcedureAst, executeSchemaSql, executeSchemaSqlFor, exists, exp, extract, extractReusableSchemas, extractScopeValues, firstValue, floor, formatDuration, formatTreeList, fromUnixTime, generateComponentSchemas, generateCreateTableSql, generateOpenApiDocument, generateRelationComponents, generateSchemaSql, generateSchemaSqlFor, generateTreeComponents, getColumn, getColumnMap, getColumnType, getDateKind, getDecoratorMetadata, getDeterministicComponentName, getOpenApiVersionForDialect, getRegisteredValidators, getSchemaIntrospector, getTableDefFromEntity, getTreeBounds, getTreeColumns, getTreeConfig, getTreeMetadata, getTreeParentId, greatest, groupConcat, gt, gte, hasMany, hasNextPage as hasNextPageMeta, hasOne, hasPrevPage as hasPrevPageMeta, hasTreeBehavior, hasValidator, hour, hydrateRows, ifNull, inList, inSubquery, initcap, insertInto, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isCollateExpressionNode, isComponentReference, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isNullableColumn, isOperandNode, isTableDef, isTreeConfig, isValidDuration, 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, parseDuration, payloadResultSets, pi, pick, position, pow, power, quarter, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, registerValidator, relationFilterToOpenApiSchema, relationLoaderCache, renderColumnDefinition, renderTypeWithArgs, repeat, replace, replaceWithRefs, resolveTreeConfig, resolveValidator, responseToRef, reverse, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, schemaToJson, schemaToRef, second, sel, selectFrom, selectFromEntity, setRelations, setTreeBounds, setTreeMetadata, setTreeParentId, sha1, sha2, shiftLeft, shiftRight, sign, sin, space, sqrt, stddev, sub, substr, sum, syncTreeEntityMetadata, synchronizeSchema, tableRef, tan, threadResults, threadedNodeToOpenApiSchema, toColumnRef, toExecutionPayload, toPagedResponse, toPagedResponseBuilder, toPaginationParams, toResponse, toResponseBuilder, toTableRef, treeEntityRegistry, treeListEntryToOpenApiSchema, treeNodeResultToOpenApiSchema, treeNodeToOpenApiSchema, treeQuery, trim, trunc, truncate, typeMappingService, unixTimestamp, update, updateDtoToOpenApiSchema, updateDtoWithRelationsToOpenApiSchema, upper, utcNow, validateTreeTable, valueToOperand, variance, visitExpression, visitOperand, weekOfYear, whereInputToOpenApiSchema, whereInputWithRelationsToOpenApiSchema, windowFunction, withDefaults, withDefaultsBuilder, year };
|
|
9898
|
+
export { type AliasRefNode, Alphanumeric, type AnyDomainEvent, type ApiRouteDefinition, type ApplyFilterOptions, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, type AutoCorrectionResult, type AutoTransformResult, type AutoTransformableValidator, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToReferenceApi, type BelongsToRelation, type BetweenExpressionNode, BigIntTypeStrategy, type BinaryExpressionNode, BinaryTypeStrategy, type BitwiseExpressionNode, type BooleanFilter, BooleanTypeStrategy, CEP, CNPJ, CPF, type CacheCapabilities, type CacheInvalidator, type CacheOptions, type CacheProvider, type CacheReader, type CacheState, type CacheStrategy, type CacheWriter, type CallProcedureOptions, Capitalize, 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, type CompositeTransformer, ConflictBuilder, ConstructorMaterializationStrategy, type ValidationResult as CountryValidationResult, type CountryValidator, type CountryValidatorFactory, type CreateDto, type CreateTediousClientOptions, type CursorPageInfo, type CursorPageOptions, type CursorPageResult, DEFAULT_TREE_CONFIG, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DatabaseView, type DateFilter, DateTimeTypeStrategy, type DbExecutor, type DbExecutorFactory, DecimalTypeStrategy, type DecoratedEntityInstance, DefaultBelongsToReference, DefaultCacheStrategy, DefaultEntityMaterializer, DefaultHasManyCollection, DefaultManyToManyCollection, DefaultTypeStrategy, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, type Dto, type Duration, Email, Entity, type EntityContext, type EntityInstance, type EntityMaterializationStrategy, type EntityMaterializer, type EntityOptions, type PrimaryKey$1 as EntityPrimaryKey, EntityStatus, type ExecuteFilteredPagedOptions, type ExecutionContext, type ExecutionPayload, type ExistsExpressionNode, type ExpressionNode, type ExpressionVisitor, type FieldFilter, type FilterOperator, type FilterValue, type FindChildrenOptions, type FindPathOptions, 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 InvalidationStrategy, type JsonArray, type JsonObject, type JsonPathNode, type JsonValue, type Jsonify, type JsonifyScalar, KeyvCacheAdapter, Length, type LiteralNode, type LiteralValue, type LogicalExpressionNode, Lower, type ManyToManyCollection, MemoryCacheAdapter, type MoveOptions, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NestedDtoOptions, type NestedSetBounds, type NestedSetRow, NestedSetStrategy, type NodeWithPk, type NullExpressionNode, type NumberFilter, type OpenApiComponent, type OpenApiDialect, type OpenApiDocument, type OpenApiDocumentInfo, type OpenApiDocumentOptions, type OpenApiOperation, type OpenApiParameter, type OpenApiParameterObject, type OpenApiResponseObject, type OpenApiSchema, type OpenApiType, type OperandNode, type OperandVisitor, Orm, type OrmCacheOptions, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, type PagedResponse, type PaginatedResult, type PaginationParams, type PatchGraphInputPayload, Pattern, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type Primitive, ProcedureCallBuilder, type ProcedureCallNode, type ProcedureDirection, type ProcedureExecutionResult, type ProcedureOutOptions, type ProcedureParamNode, type ProcedureRefNode, type PropertySanitizer, type PropertyTransformer, type PropertyValidator, PrototypeMaterializationStrategy, QueryCacheManager, type QueryContext, type QueryInterceptor, type QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type RecoverResult, RedisCacheAdapter, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationFilter, 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, TagIndex, type TargetType, type TediousColumn, type TediousConnectionLike, type TediousModule, type TediousRequest, type TediousRequestCtor, type TediousTypes, type ThreadedNode, Title, type ToJsonOptions, type TrackedEntity, type TransformContext, type TransformerConfig, type TransformerMetadata, Tree, TreeChildren, type TreeColumns, type TreeConfig, type TreeDecoratorOptions, type TreeInsertData, type TreeListEntry, type TreeListOptions, type TreeListSchemaOptions, TreeManager, type TreeManagerOptions, type TreeMetadata, type TreeMoveData, type TreeNode, type TreeNodeResult, type TreeNodeResultSchemaOptions, type TreeNodeSchemaOptions, TreeParent, type TreeQuery, type TreeScope, type TreeValidationResult, Trim, TypeMappingService, type TypeMappingStrategy, TypeScriptGenerator, type TypedExpression, type TypedLike, type UpdateDto, UpdateQueryBuilder, Upper, UuidTypeStrategy, type ValidationOptions, type ValidationResult$1 as ValidationResult, type ValidatorFactoryOptions, type ValueOperandInput, type WhereInput, type WindowFunctionNode, type WithRelations, abs, acos, add, addDomainEvent, addEntityRelation, addRelation, age, aliasRef, and, applyFilter, applyNullability, arrayAppend, asType, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bitAnd, bitLength, bitOr, bitXor, bootstrapEntities, buildFilterExpression, buildScopeConditions, calculateRowDepths, calculateTotalPages, callProcedure, canonicalizeSchema, caseWhen, cast, cbrt, ceil, ceiling, char, charLength, chr, clearExpressionDispatchers, clearOperandDispatchers, coalesce, col, collate, columnOperand, columnToFilterSchema, columnToOpenApiSchema, columnTypeToOpenApiFormat, columnTypeToOpenApiType, computePaginationMetadata, computeSchemaHash, concat, concatWs, correlateBy, cos, cot, count, countAll, createApiComponentsSection, createDeterministicNamingState, createDtoToOpenApiSchema, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createRef, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, createTreeManager, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, deepCloneSchema, defineTable, degrees, deleteFrom, denseRank, diffSchema, div, dtoToOpenApiSchema, endOfMonth, entityRef, entityRefs, eq, esel, exclude, executeFilteredPaged, executeHydrated, executeHydratedPlain, executeHydratedPlainWithContexts, executeHydratedWithContexts, executeProcedureAst, executeSchemaSql, executeSchemaSqlFor, exists, exp, extract, extractReusableSchemas, extractScopeValues, firstValue, floor, formatDuration, formatTreeList, fromUnixTime, generateComponentSchemas, generateCreateTableSql, generateOpenApiDocument, generateRelationComponents, generateSchemaSql, generateSchemaSqlFor, generateTreeComponents, getColumn, getColumnMap, getColumnType, getDateKind, getDecoratorMetadata, getDeterministicComponentName, getOpenApiVersionForDialect, getRegisteredValidators, getSchemaIntrospector, getTableDefFromEntity, getTreeBounds, getTreeColumns, getTreeConfig, getTreeMetadata, getTreeParentId, greatest, groupConcat, gt, gte, hasMany, hasNextPage as hasNextPageMeta, hasOne, hasPrevPage as hasPrevPageMeta, hasTreeBehavior, hasValidator, hour, hydrateRows, ifNull, inList, inSubquery, initcap, insertInto, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isCollateExpressionNode, isComponentReference, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isNullableColumn, isOperandNode, isTableDef, isTreeConfig, isValidDuration, 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, parseDuration, payloadResultSets, pi, pick, position, pow, power, quarter, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, registerValidator, relationFilterToOpenApiSchema, relationLoaderCache, renderColumnDefinition, renderTypeWithArgs, repeat, replace, replaceWithRefs, resolveTreeConfig, resolveValidator, responseToRef, reverse, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, schemaToJson, schemaToRef, second, sel, selectFrom, selectFromEntity, setRelations, setTreeBounds, setTreeMetadata, setTreeParentId, sha1, sha2, shiftLeft, shiftRight, sign, sin, space, sqrt, stddev, sub, substr, sum, syncTreeEntityMetadata, synchronizeSchema, tableRef, tan, threadResults, threadedNodeToOpenApiSchema, toColumnRef, toExecutionPayload, toPagedResponse, toPagedResponseBuilder, toPaginationParams, toResponse, toResponseBuilder, toTableRef, treeEntityRegistry, treeListEntryToOpenApiSchema, treeNodeResultToOpenApiSchema, treeNodeToOpenApiSchema, treeQuery, trim, trunc, truncate, typeMappingService, unixTimestamp, update, updateDtoToOpenApiSchema, updateDtoWithRelationsToOpenApiSchema, upper, utcNow, validateTreeTable, valueToOperand, variance, visitExpression, visitOperand, weekOfYear, whereInputToOpenApiSchema, whereInputWithRelationsToOpenApiSchema, windowFunction, withDefaults, withDefaultsBuilder, year };
|
package/dist/index.d.ts
CHANGED
|
@@ -4430,6 +4430,23 @@ interface PaginatedResult<T> {
|
|
|
4430
4430
|
pageSize: number;
|
|
4431
4431
|
}
|
|
4432
4432
|
|
|
4433
|
+
type CursorPageOptions = {
|
|
4434
|
+
first?: number;
|
|
4435
|
+
after?: string;
|
|
4436
|
+
last?: number;
|
|
4437
|
+
before?: string;
|
|
4438
|
+
};
|
|
4439
|
+
type CursorPageInfo = {
|
|
4440
|
+
hasNextPage: boolean;
|
|
4441
|
+
hasPreviousPage: boolean;
|
|
4442
|
+
startCursor: string | null;
|
|
4443
|
+
endCursor: string | null;
|
|
4444
|
+
};
|
|
4445
|
+
type CursorPageResult<T> = {
|
|
4446
|
+
items: T[];
|
|
4447
|
+
pageInfo: CursorPageInfo;
|
|
4448
|
+
};
|
|
4449
|
+
|
|
4433
4450
|
/**
|
|
4434
4451
|
* Facet para gerenciar estado de cache no SelectQueryBuilder
|
|
4435
4452
|
* Segue o padrão de facets existente no projeto
|
|
@@ -4927,7 +4944,35 @@ declare class SelectQueryBuilder<T = EntityInstance<TableDef>, TTable extends Ta
|
|
|
4927
4944
|
pageSize: number;
|
|
4928
4945
|
}): Promise<PaginatedResult<T>>;
|
|
4929
4946
|
/**
|
|
4930
|
-
* Executes the query
|
|
4947
|
+
* Executes the query using cursor-based (keyset) pagination.
|
|
4948
|
+
* Requires a stable ORDER BY on selected, non-null columns.
|
|
4949
|
+
* Cursor pagination currently supports simple column references only and
|
|
4950
|
+
* the cursor token is opaque: it must be reused with the same ORDER BY signature.
|
|
4951
|
+
*
|
|
4952
|
+
* @param session - ORM session context
|
|
4953
|
+
* @param options - Cursor pagination options (`first`/`after` or `last`/`before`)
|
|
4954
|
+
* @returns Promise of cursor-paginated result with items and pageInfo
|
|
4955
|
+
* @example
|
|
4956
|
+
* const page1 = await selectFrom(users)
|
|
4957
|
+
* .orderBy(users.columns.createdAt, 'DESC')
|
|
4958
|
+
* .orderBy(users.columns.id, 'DESC')
|
|
4959
|
+
* .executeCursor(session, { first: 20 });
|
|
4960
|
+
*
|
|
4961
|
+
* // Next page
|
|
4962
|
+
* const page2 = await selectFrom(users)
|
|
4963
|
+
* .orderBy(users.columns.createdAt, 'DESC')
|
|
4964
|
+
* .orderBy(users.columns.id, 'DESC')
|
|
4965
|
+
* .executeCursor(session, { first: 20, after: page1.pageInfo.endCursor });
|
|
4966
|
+
*
|
|
4967
|
+
* // Previous page from a known cursor
|
|
4968
|
+
* const prevPage = await selectFrom(users)
|
|
4969
|
+
* .orderBy(users.columns.createdAt, 'DESC')
|
|
4970
|
+
* .orderBy(users.columns.id, 'DESC')
|
|
4971
|
+
* .executeCursor(session, { last: 20, before: page2.pageInfo.startCursor });
|
|
4972
|
+
*/
|
|
4973
|
+
executeCursor(session: OrmSession, options: CursorPageOptions): Promise<CursorPageResult<T>>;
|
|
4974
|
+
/**
|
|
4975
|
+
* Executes the query and returns an array of values for a single column.
|
|
4931
4976
|
* This is a convenience method to avoid manual `.map(r => r.column)`.
|
|
4932
4977
|
*
|
|
4933
4978
|
* @param column - The column name to extract
|
|
@@ -9850,4 +9895,4 @@ declare function setTreeBounds(entity: object, config: TreeConfig, lft: number,
|
|
|
9850
9895
|
*/
|
|
9851
9896
|
declare function setTreeParentId(entity: object, config: TreeConfig, parentId: unknown): void;
|
|
9852
9897
|
|
|
9853
|
-
export { type AliasRefNode, Alphanumeric, type AnyDomainEvent, type ApiRouteDefinition, type ApplyFilterOptions, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, type AutoCorrectionResult, type AutoTransformResult, type AutoTransformableValidator, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToReferenceApi, type BelongsToRelation, type BetweenExpressionNode, BigIntTypeStrategy, type BinaryExpressionNode, BinaryTypeStrategy, type BitwiseExpressionNode, type BooleanFilter, BooleanTypeStrategy, CEP, CNPJ, CPF, type CacheCapabilities, type CacheInvalidator, type CacheOptions, type CacheProvider, type CacheReader, type CacheState, type CacheStrategy, type CacheWriter, type CallProcedureOptions, Capitalize, 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, type CompositeTransformer, ConflictBuilder, ConstructorMaterializationStrategy, type ValidationResult as CountryValidationResult, type CountryValidator, type CountryValidatorFactory, type CreateDto, type CreateTediousClientOptions, DEFAULT_TREE_CONFIG, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DatabaseView, type DateFilter, DateTimeTypeStrategy, type DbExecutor, type DbExecutorFactory, DecimalTypeStrategy, type DecoratedEntityInstance, DefaultBelongsToReference, DefaultCacheStrategy, DefaultEntityMaterializer, DefaultHasManyCollection, DefaultManyToManyCollection, DefaultTypeStrategy, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, type Dto, type Duration, Email, Entity, type EntityContext, type EntityInstance, type EntityMaterializationStrategy, type EntityMaterializer, type EntityOptions, type PrimaryKey$1 as EntityPrimaryKey, EntityStatus, type ExecuteFilteredPagedOptions, type ExecutionContext, type ExecutionPayload, type ExistsExpressionNode, type ExpressionNode, type ExpressionVisitor, type FieldFilter, type FilterOperator, type FilterValue, type FindChildrenOptions, type FindPathOptions, 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 InvalidationStrategy, type JsonArray, type JsonObject, type JsonPathNode, type JsonValue, type Jsonify, type JsonifyScalar, KeyvCacheAdapter, Length, type LiteralNode, type LiteralValue, type LogicalExpressionNode, Lower, type ManyToManyCollection, MemoryCacheAdapter, type MoveOptions, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NestedDtoOptions, type NestedSetBounds, type NestedSetRow, NestedSetStrategy, type NodeWithPk, type NullExpressionNode, type NumberFilter, type OpenApiComponent, type OpenApiDialect, type OpenApiDocument, type OpenApiDocumentInfo, type OpenApiDocumentOptions, type OpenApiOperation, type OpenApiParameter, type OpenApiParameterObject, type OpenApiResponseObject, type OpenApiSchema, type OpenApiType, type OperandNode, type OperandVisitor, Orm, type OrmCacheOptions, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, type PagedResponse, type PaginatedResult, type PaginationParams, type PatchGraphInputPayload, Pattern, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type Primitive, ProcedureCallBuilder, type ProcedureCallNode, type ProcedureDirection, type ProcedureExecutionResult, type ProcedureOutOptions, type ProcedureParamNode, type ProcedureRefNode, type PropertySanitizer, type PropertyTransformer, type PropertyValidator, PrototypeMaterializationStrategy, QueryCacheManager, type QueryContext, type QueryInterceptor, type QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type RecoverResult, RedisCacheAdapter, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationFilter, 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, TagIndex, type TargetType, type TediousColumn, type TediousConnectionLike, type TediousModule, type TediousRequest, type TediousRequestCtor, type TediousTypes, type ThreadedNode, Title, type ToJsonOptions, type TrackedEntity, type TransformContext, type TransformerConfig, type TransformerMetadata, Tree, TreeChildren, type TreeColumns, type TreeConfig, type TreeDecoratorOptions, type TreeInsertData, type TreeListEntry, type TreeListOptions, type TreeListSchemaOptions, TreeManager, type TreeManagerOptions, type TreeMetadata, type TreeMoveData, type TreeNode, type TreeNodeResult, type TreeNodeResultSchemaOptions, type TreeNodeSchemaOptions, TreeParent, type TreeQuery, type TreeScope, type TreeValidationResult, Trim, TypeMappingService, type TypeMappingStrategy, TypeScriptGenerator, type TypedExpression, type TypedLike, type UpdateDto, UpdateQueryBuilder, Upper, UuidTypeStrategy, type ValidationOptions, type ValidationResult$1 as ValidationResult, type ValidatorFactoryOptions, type ValueOperandInput, type WhereInput, type WindowFunctionNode, type WithRelations, abs, acos, add, addDomainEvent, addEntityRelation, addRelation, age, aliasRef, and, applyFilter, applyNullability, arrayAppend, asType, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bitAnd, bitLength, bitOr, bitXor, bootstrapEntities, buildFilterExpression, buildScopeConditions, calculateRowDepths, calculateTotalPages, callProcedure, canonicalizeSchema, caseWhen, cast, cbrt, ceil, ceiling, char, charLength, chr, clearExpressionDispatchers, clearOperandDispatchers, coalesce, col, collate, columnOperand, columnToFilterSchema, columnToOpenApiSchema, columnTypeToOpenApiFormat, columnTypeToOpenApiType, computePaginationMetadata, computeSchemaHash, concat, concatWs, correlateBy, cos, cot, count, countAll, createApiComponentsSection, createDeterministicNamingState, createDtoToOpenApiSchema, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createRef, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, createTreeManager, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, deepCloneSchema, defineTable, degrees, deleteFrom, denseRank, diffSchema, div, dtoToOpenApiSchema, endOfMonth, entityRef, entityRefs, eq, esel, exclude, executeFilteredPaged, executeHydrated, executeHydratedPlain, executeHydratedPlainWithContexts, executeHydratedWithContexts, executeProcedureAst, executeSchemaSql, executeSchemaSqlFor, exists, exp, extract, extractReusableSchemas, extractScopeValues, firstValue, floor, formatDuration, formatTreeList, fromUnixTime, generateComponentSchemas, generateCreateTableSql, generateOpenApiDocument, generateRelationComponents, generateSchemaSql, generateSchemaSqlFor, generateTreeComponents, getColumn, getColumnMap, getColumnType, getDateKind, getDecoratorMetadata, getDeterministicComponentName, getOpenApiVersionForDialect, getRegisteredValidators, getSchemaIntrospector, getTableDefFromEntity, getTreeBounds, getTreeColumns, getTreeConfig, getTreeMetadata, getTreeParentId, greatest, groupConcat, gt, gte, hasMany, hasNextPage as hasNextPageMeta, hasOne, hasPrevPage as hasPrevPageMeta, hasTreeBehavior, hasValidator, hour, hydrateRows, ifNull, inList, inSubquery, initcap, insertInto, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isCollateExpressionNode, isComponentReference, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isNullableColumn, isOperandNode, isTableDef, isTreeConfig, isValidDuration, 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, parseDuration, payloadResultSets, pi, pick, position, pow, power, quarter, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, registerValidator, relationFilterToOpenApiSchema, relationLoaderCache, renderColumnDefinition, renderTypeWithArgs, repeat, replace, replaceWithRefs, resolveTreeConfig, resolveValidator, responseToRef, reverse, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, schemaToJson, schemaToRef, second, sel, selectFrom, selectFromEntity, setRelations, setTreeBounds, setTreeMetadata, setTreeParentId, sha1, sha2, shiftLeft, shiftRight, sign, sin, space, sqrt, stddev, sub, substr, sum, syncTreeEntityMetadata, synchronizeSchema, tableRef, tan, threadResults, threadedNodeToOpenApiSchema, toColumnRef, toExecutionPayload, toPagedResponse, toPagedResponseBuilder, toPaginationParams, toResponse, toResponseBuilder, toTableRef, treeEntityRegistry, treeListEntryToOpenApiSchema, treeNodeResultToOpenApiSchema, treeNodeToOpenApiSchema, treeQuery, trim, trunc, truncate, typeMappingService, unixTimestamp, update, updateDtoToOpenApiSchema, updateDtoWithRelationsToOpenApiSchema, upper, utcNow, validateTreeTable, valueToOperand, variance, visitExpression, visitOperand, weekOfYear, whereInputToOpenApiSchema, whereInputWithRelationsToOpenApiSchema, windowFunction, withDefaults, withDefaultsBuilder, year };
|
|
9898
|
+
export { type AliasRefNode, Alphanumeric, type AnyDomainEvent, type ApiRouteDefinition, type ApplyFilterOptions, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, type AutoCorrectionResult, type AutoTransformResult, type AutoTransformableValidator, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToReferenceApi, type BelongsToRelation, type BetweenExpressionNode, BigIntTypeStrategy, type BinaryExpressionNode, BinaryTypeStrategy, type BitwiseExpressionNode, type BooleanFilter, BooleanTypeStrategy, CEP, CNPJ, CPF, type CacheCapabilities, type CacheInvalidator, type CacheOptions, type CacheProvider, type CacheReader, type CacheState, type CacheStrategy, type CacheWriter, type CallProcedureOptions, Capitalize, 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, type CompositeTransformer, ConflictBuilder, ConstructorMaterializationStrategy, type ValidationResult as CountryValidationResult, type CountryValidator, type CountryValidatorFactory, type CreateDto, type CreateTediousClientOptions, type CursorPageInfo, type CursorPageOptions, type CursorPageResult, DEFAULT_TREE_CONFIG, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DatabaseView, type DateFilter, DateTimeTypeStrategy, type DbExecutor, type DbExecutorFactory, DecimalTypeStrategy, type DecoratedEntityInstance, DefaultBelongsToReference, DefaultCacheStrategy, DefaultEntityMaterializer, DefaultHasManyCollection, DefaultManyToManyCollection, DefaultTypeStrategy, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, type Dto, type Duration, Email, Entity, type EntityContext, type EntityInstance, type EntityMaterializationStrategy, type EntityMaterializer, type EntityOptions, type PrimaryKey$1 as EntityPrimaryKey, EntityStatus, type ExecuteFilteredPagedOptions, type ExecutionContext, type ExecutionPayload, type ExistsExpressionNode, type ExpressionNode, type ExpressionVisitor, type FieldFilter, type FilterOperator, type FilterValue, type FindChildrenOptions, type FindPathOptions, 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 InvalidationStrategy, type JsonArray, type JsonObject, type JsonPathNode, type JsonValue, type Jsonify, type JsonifyScalar, KeyvCacheAdapter, Length, type LiteralNode, type LiteralValue, type LogicalExpressionNode, Lower, type ManyToManyCollection, MemoryCacheAdapter, type MoveOptions, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NestedDtoOptions, type NestedSetBounds, type NestedSetRow, NestedSetStrategy, type NodeWithPk, type NullExpressionNode, type NumberFilter, type OpenApiComponent, type OpenApiDialect, type OpenApiDocument, type OpenApiDocumentInfo, type OpenApiDocumentOptions, type OpenApiOperation, type OpenApiParameter, type OpenApiParameterObject, type OpenApiResponseObject, type OpenApiSchema, type OpenApiType, type OperandNode, type OperandVisitor, Orm, type OrmCacheOptions, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, type PagedResponse, type PaginatedResult, type PaginationParams, type PatchGraphInputPayload, Pattern, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type Primitive, ProcedureCallBuilder, type ProcedureCallNode, type ProcedureDirection, type ProcedureExecutionResult, type ProcedureOutOptions, type ProcedureParamNode, type ProcedureRefNode, type PropertySanitizer, type PropertyTransformer, type PropertyValidator, PrototypeMaterializationStrategy, QueryCacheManager, type QueryContext, type QueryInterceptor, type QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type RecoverResult, RedisCacheAdapter, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationFilter, 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, TagIndex, type TargetType, type TediousColumn, type TediousConnectionLike, type TediousModule, type TediousRequest, type TediousRequestCtor, type TediousTypes, type ThreadedNode, Title, type ToJsonOptions, type TrackedEntity, type TransformContext, type TransformerConfig, type TransformerMetadata, Tree, TreeChildren, type TreeColumns, type TreeConfig, type TreeDecoratorOptions, type TreeInsertData, type TreeListEntry, type TreeListOptions, type TreeListSchemaOptions, TreeManager, type TreeManagerOptions, type TreeMetadata, type TreeMoveData, type TreeNode, type TreeNodeResult, type TreeNodeResultSchemaOptions, type TreeNodeSchemaOptions, TreeParent, type TreeQuery, type TreeScope, type TreeValidationResult, Trim, TypeMappingService, type TypeMappingStrategy, TypeScriptGenerator, type TypedExpression, type TypedLike, type UpdateDto, UpdateQueryBuilder, Upper, UuidTypeStrategy, type ValidationOptions, type ValidationResult$1 as ValidationResult, type ValidatorFactoryOptions, type ValueOperandInput, type WhereInput, type WindowFunctionNode, type WithRelations, abs, acos, add, addDomainEvent, addEntityRelation, addRelation, age, aliasRef, and, applyFilter, applyNullability, arrayAppend, asType, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bitAnd, bitLength, bitOr, bitXor, bootstrapEntities, buildFilterExpression, buildScopeConditions, calculateRowDepths, calculateTotalPages, callProcedure, canonicalizeSchema, caseWhen, cast, cbrt, ceil, ceiling, char, charLength, chr, clearExpressionDispatchers, clearOperandDispatchers, coalesce, col, collate, columnOperand, columnToFilterSchema, columnToOpenApiSchema, columnTypeToOpenApiFormat, columnTypeToOpenApiType, computePaginationMetadata, computeSchemaHash, concat, concatWs, correlateBy, cos, cot, count, countAll, createApiComponentsSection, createDeterministicNamingState, createDtoToOpenApiSchema, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createRef, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, createTreeManager, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, deepCloneSchema, defineTable, degrees, deleteFrom, denseRank, diffSchema, div, dtoToOpenApiSchema, endOfMonth, entityRef, entityRefs, eq, esel, exclude, executeFilteredPaged, executeHydrated, executeHydratedPlain, executeHydratedPlainWithContexts, executeHydratedWithContexts, executeProcedureAst, executeSchemaSql, executeSchemaSqlFor, exists, exp, extract, extractReusableSchemas, extractScopeValues, firstValue, floor, formatDuration, formatTreeList, fromUnixTime, generateComponentSchemas, generateCreateTableSql, generateOpenApiDocument, generateRelationComponents, generateSchemaSql, generateSchemaSqlFor, generateTreeComponents, getColumn, getColumnMap, getColumnType, getDateKind, getDecoratorMetadata, getDeterministicComponentName, getOpenApiVersionForDialect, getRegisteredValidators, getSchemaIntrospector, getTableDefFromEntity, getTreeBounds, getTreeColumns, getTreeConfig, getTreeMetadata, getTreeParentId, greatest, groupConcat, gt, gte, hasMany, hasNextPage as hasNextPageMeta, hasOne, hasPrevPage as hasPrevPageMeta, hasTreeBehavior, hasValidator, hour, hydrateRows, ifNull, inList, inSubquery, initcap, insertInto, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isCollateExpressionNode, isComponentReference, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isNullableColumn, isOperandNode, isTableDef, isTreeConfig, isValidDuration, 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, parseDuration, payloadResultSets, pi, pick, position, pow, power, quarter, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, registerValidator, relationFilterToOpenApiSchema, relationLoaderCache, renderColumnDefinition, renderTypeWithArgs, repeat, replace, replaceWithRefs, resolveTreeConfig, resolveValidator, responseToRef, reverse, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, schemaToJson, schemaToRef, second, sel, selectFrom, selectFromEntity, setRelations, setTreeBounds, setTreeMetadata, setTreeParentId, sha1, sha2, shiftLeft, shiftRight, sign, sin, space, sqrt, stddev, sub, substr, sum, syncTreeEntityMetadata, synchronizeSchema, tableRef, tan, threadResults, threadedNodeToOpenApiSchema, toColumnRef, toExecutionPayload, toPagedResponse, toPagedResponseBuilder, toPaginationParams, toResponse, toResponseBuilder, toTableRef, treeEntityRegistry, treeListEntryToOpenApiSchema, treeNodeResultToOpenApiSchema, treeNodeToOpenApiSchema, treeQuery, trim, trunc, truncate, typeMappingService, unixTimestamp, update, updateDtoToOpenApiSchema, updateDtoWithRelationsToOpenApiSchema, upper, utcNow, validateTreeTable, valueToOperand, variance, visitExpression, visitOperand, weekOfYear, whereInputToOpenApiSchema, whereInputWithRelationsToOpenApiSchema, windowFunction, withDefaults, withDefaultsBuilder, year };
|
package/dist/index.js
CHANGED
|
@@ -7310,6 +7310,193 @@ function buildWhereHasPredicate(env, context, relationFacet, createChildBuilder,
|
|
|
7310
7310
|
return negate ? notExists(finalSubAst) : exists(finalSubAst);
|
|
7311
7311
|
}
|
|
7312
7312
|
|
|
7313
|
+
// src/query-builder/select/cursor-pagination.ts
|
|
7314
|
+
function encodeCursor(payload) {
|
|
7315
|
+
return Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
7316
|
+
}
|
|
7317
|
+
function decodeCursor(cursor) {
|
|
7318
|
+
let parsed;
|
|
7319
|
+
try {
|
|
7320
|
+
parsed = JSON.parse(Buffer.from(cursor, "base64url").toString("utf8"));
|
|
7321
|
+
} catch {
|
|
7322
|
+
throw new Error("executeCursor: invalid cursor format");
|
|
7323
|
+
}
|
|
7324
|
+
if (typeof parsed !== "object" || parsed === null || parsed.v !== 2 || !Array.isArray(parsed.values) || typeof parsed.orderSig !== "string") {
|
|
7325
|
+
throw new Error("executeCursor: invalid cursor payload");
|
|
7326
|
+
}
|
|
7327
|
+
return parsed;
|
|
7328
|
+
}
|
|
7329
|
+
function buildOrderSignature(specs) {
|
|
7330
|
+
return specs.map((s) => `${s.table}.${s.column}:${s.direction}`).join(",");
|
|
7331
|
+
}
|
|
7332
|
+
function extractOrderSpecs(ast) {
|
|
7333
|
+
if (!ast.orderBy || ast.orderBy.length === 0) {
|
|
7334
|
+
throw new Error("executeCursor: ORDER BY is required for cursor pagination");
|
|
7335
|
+
}
|
|
7336
|
+
return ast.orderBy.map((ob) => {
|
|
7337
|
+
if (ob.nulls) {
|
|
7338
|
+
throw new Error("executeCursor: NULLS FIRST/LAST is not supported for cursor pagination");
|
|
7339
|
+
}
|
|
7340
|
+
const term = ob.term;
|
|
7341
|
+
if (!term || term.type !== "Column") {
|
|
7342
|
+
throw new Error(
|
|
7343
|
+
"executeCursor: only column references are supported in ORDER BY for cursor pagination"
|
|
7344
|
+
);
|
|
7345
|
+
}
|
|
7346
|
+
const col2 = term;
|
|
7347
|
+
return {
|
|
7348
|
+
table: col2.table,
|
|
7349
|
+
column: col2.name,
|
|
7350
|
+
valueKey: resolveOrderValueKey(ast, col2),
|
|
7351
|
+
direction: ob.direction
|
|
7352
|
+
};
|
|
7353
|
+
});
|
|
7354
|
+
}
|
|
7355
|
+
function resolveOrderValueKey(ast, col2) {
|
|
7356
|
+
const projectedColumn = ast.columns.find(
|
|
7357
|
+
(candidate) => candidate.type === "Column" && candidate.table === col2.table && candidate.name === col2.name
|
|
7358
|
+
);
|
|
7359
|
+
return projectedColumn?.alias ?? projectedColumn?.name ?? col2.alias ?? col2.name;
|
|
7360
|
+
}
|
|
7361
|
+
function buildKeysetPredicate(specs, values, mode) {
|
|
7362
|
+
if (values.length !== specs.length) {
|
|
7363
|
+
throw new Error("executeCursor: invalid cursor payload");
|
|
7364
|
+
}
|
|
7365
|
+
const branches = [];
|
|
7366
|
+
for (let i = 0; i < specs.length; i++) {
|
|
7367
|
+
const spec = specs[i];
|
|
7368
|
+
const colNode = { type: "Column", table: spec.table, name: spec.column };
|
|
7369
|
+
const value = values[i];
|
|
7370
|
+
if (value === null || value === void 0) {
|
|
7371
|
+
throw new Error("executeCursor: invalid cursor payload");
|
|
7372
|
+
}
|
|
7373
|
+
const literal = { type: "Literal", value };
|
|
7374
|
+
let operator;
|
|
7375
|
+
if (mode === "after") {
|
|
7376
|
+
operator = spec.direction === "ASC" ? ">" : "<";
|
|
7377
|
+
} else {
|
|
7378
|
+
operator = spec.direction === "ASC" ? "<" : ">";
|
|
7379
|
+
}
|
|
7380
|
+
const eqParts = [];
|
|
7381
|
+
for (let j = 0; j < i; j++) {
|
|
7382
|
+
const prevSpec = specs[j];
|
|
7383
|
+
const prevCol = { type: "Column", table: prevSpec.table, name: prevSpec.column };
|
|
7384
|
+
const prevValue = values[j];
|
|
7385
|
+
if (prevValue === null || prevValue === void 0) {
|
|
7386
|
+
throw new Error("executeCursor: invalid cursor payload");
|
|
7387
|
+
}
|
|
7388
|
+
const prevVal = { type: "Literal", value: prevValue };
|
|
7389
|
+
eqParts.push({
|
|
7390
|
+
type: "BinaryExpression",
|
|
7391
|
+
left: prevCol,
|
|
7392
|
+
operator: "=",
|
|
7393
|
+
right: prevVal
|
|
7394
|
+
});
|
|
7395
|
+
}
|
|
7396
|
+
const breakExpr = {
|
|
7397
|
+
type: "BinaryExpression",
|
|
7398
|
+
left: colNode,
|
|
7399
|
+
operator,
|
|
7400
|
+
right: literal
|
|
7401
|
+
};
|
|
7402
|
+
if (eqParts.length === 0) {
|
|
7403
|
+
branches.push(breakExpr);
|
|
7404
|
+
} else {
|
|
7405
|
+
branches.push(and(...eqParts, breakExpr));
|
|
7406
|
+
}
|
|
7407
|
+
}
|
|
7408
|
+
return branches.length === 1 ? branches[0] : or(...branches);
|
|
7409
|
+
}
|
|
7410
|
+
function buildCursorFromRow(row, specs) {
|
|
7411
|
+
const values = specs.map((spec) => {
|
|
7412
|
+
const value = row[spec.valueKey];
|
|
7413
|
+
if (value === null || value === void 0) {
|
|
7414
|
+
throw new Error("executeCursor: cursor pagination requires non-null ORDER BY values");
|
|
7415
|
+
}
|
|
7416
|
+
return value;
|
|
7417
|
+
});
|
|
7418
|
+
return encodeCursor({ v: 2, values, orderSig: buildOrderSignature(specs) });
|
|
7419
|
+
}
|
|
7420
|
+
function reverseDirection(direction) {
|
|
7421
|
+
return direction === "ASC" ? "DESC" : "ASC";
|
|
7422
|
+
}
|
|
7423
|
+
function createExecutionBuilder(builder, options) {
|
|
7424
|
+
const internals = builder.getInternals();
|
|
7425
|
+
const baseAst = internals.context.state.ast;
|
|
7426
|
+
const orderBy = options.reverseOrder && baseAst.orderBy ? baseAst.orderBy.map((order) => ({
|
|
7427
|
+
...order,
|
|
7428
|
+
direction: reverseDirection(order.direction)
|
|
7429
|
+
})) : baseAst.orderBy;
|
|
7430
|
+
const nextAst = {
|
|
7431
|
+
...baseAst,
|
|
7432
|
+
where: options.predicate ? baseAst.where ? and(baseAst.where, options.predicate) : options.predicate : baseAst.where,
|
|
7433
|
+
orderBy,
|
|
7434
|
+
limit: options.limit
|
|
7435
|
+
};
|
|
7436
|
+
const nextContext = {
|
|
7437
|
+
...internals.context,
|
|
7438
|
+
state: new SelectQueryState(builder.getTable(), nextAst)
|
|
7439
|
+
};
|
|
7440
|
+
return internals.clone(nextContext, internals.includeTree);
|
|
7441
|
+
}
|
|
7442
|
+
async function executeCursorQuery(builder, session, options) {
|
|
7443
|
+
const { first, after, last, before } = options;
|
|
7444
|
+
if (first != null && last != null) {
|
|
7445
|
+
throw new Error('executeCursor: "first" and "last" cannot be used together');
|
|
7446
|
+
}
|
|
7447
|
+
if (after != null && before != null) {
|
|
7448
|
+
throw new Error('executeCursor: "after" and "before" cannot be used together');
|
|
7449
|
+
}
|
|
7450
|
+
if (first == null && last == null) {
|
|
7451
|
+
throw new Error('executeCursor: either "first" or "last" must be provided');
|
|
7452
|
+
}
|
|
7453
|
+
const limit = first ?? last;
|
|
7454
|
+
if (!Number.isInteger(limit) || limit < 1) {
|
|
7455
|
+
throw new Error(`executeCursor: "${first != null ? "first" : "last"}" must be an integer >= 1`);
|
|
7456
|
+
}
|
|
7457
|
+
const isBackward = last != null;
|
|
7458
|
+
const cursor = after ?? before;
|
|
7459
|
+
const ast = builder.getInternals().context.state.ast;
|
|
7460
|
+
const specs = extractOrderSpecs(ast);
|
|
7461
|
+
let predicate;
|
|
7462
|
+
if (cursor) {
|
|
7463
|
+
const decoded = decodeCursor(cursor);
|
|
7464
|
+
const expectedSig = buildOrderSignature(specs);
|
|
7465
|
+
if (decoded.orderSig !== expectedSig) {
|
|
7466
|
+
throw new Error(
|
|
7467
|
+
"executeCursor: cursor ORDER BY signature does not match the current query. The ORDER BY clause must remain the same between paginated requests."
|
|
7468
|
+
);
|
|
7469
|
+
}
|
|
7470
|
+
predicate = buildKeysetPredicate(specs, decoded.values, isBackward ? "before" : "after");
|
|
7471
|
+
}
|
|
7472
|
+
const executionBuilder = createExecutionBuilder(builder, {
|
|
7473
|
+
predicate,
|
|
7474
|
+
limit: limit + 1,
|
|
7475
|
+
reverseOrder: isBackward
|
|
7476
|
+
});
|
|
7477
|
+
const rows = await executionBuilder.execute(session);
|
|
7478
|
+
const hasExtraItem = rows.length > limit;
|
|
7479
|
+
if (hasExtraItem) {
|
|
7480
|
+
rows.pop();
|
|
7481
|
+
}
|
|
7482
|
+
const orderedRows = isBackward ? rows.reverse() : rows;
|
|
7483
|
+
const items = orderedRows;
|
|
7484
|
+
const hasItems = items.length > 0;
|
|
7485
|
+
const hasNextPage2 = hasItems ? isBackward ? before != null : hasExtraItem : false;
|
|
7486
|
+
const hasPreviousPage = hasItems ? isBackward ? hasExtraItem : after != null : false;
|
|
7487
|
+
const startCursor = hasItems ? buildCursorFromRow(items[0], specs) : null;
|
|
7488
|
+
const endCursor = hasItems ? buildCursorFromRow(items[items.length - 1], specs) : null;
|
|
7489
|
+
return {
|
|
7490
|
+
items,
|
|
7491
|
+
pageInfo: {
|
|
7492
|
+
hasNextPage: hasNextPage2,
|
|
7493
|
+
hasPreviousPage,
|
|
7494
|
+
startCursor,
|
|
7495
|
+
endCursor
|
|
7496
|
+
}
|
|
7497
|
+
};
|
|
7498
|
+
}
|
|
7499
|
+
|
|
7313
7500
|
// src/query-builder/select/from-facet.ts
|
|
7314
7501
|
var SelectFromFacet = class {
|
|
7315
7502
|
/**
|
|
@@ -8336,7 +8523,38 @@ var SelectQueryBuilder = class _SelectQueryBuilder {
|
|
|
8336
8523
|
return executePagedQuery(builder, session, options, (sess) => builder.count(sess));
|
|
8337
8524
|
}
|
|
8338
8525
|
/**
|
|
8339
|
-
* Executes the query
|
|
8526
|
+
* Executes the query using cursor-based (keyset) pagination.
|
|
8527
|
+
* Requires a stable ORDER BY on selected, non-null columns.
|
|
8528
|
+
* Cursor pagination currently supports simple column references only and
|
|
8529
|
+
* the cursor token is opaque: it must be reused with the same ORDER BY signature.
|
|
8530
|
+
*
|
|
8531
|
+
* @param session - ORM session context
|
|
8532
|
+
* @param options - Cursor pagination options (`first`/`after` or `last`/`before`)
|
|
8533
|
+
* @returns Promise of cursor-paginated result with items and pageInfo
|
|
8534
|
+
* @example
|
|
8535
|
+
* const page1 = await selectFrom(users)
|
|
8536
|
+
* .orderBy(users.columns.createdAt, 'DESC')
|
|
8537
|
+
* .orderBy(users.columns.id, 'DESC')
|
|
8538
|
+
* .executeCursor(session, { first: 20 });
|
|
8539
|
+
*
|
|
8540
|
+
* // Next page
|
|
8541
|
+
* const page2 = await selectFrom(users)
|
|
8542
|
+
* .orderBy(users.columns.createdAt, 'DESC')
|
|
8543
|
+
* .orderBy(users.columns.id, 'DESC')
|
|
8544
|
+
* .executeCursor(session, { first: 20, after: page1.pageInfo.endCursor });
|
|
8545
|
+
*
|
|
8546
|
+
* // Previous page from a known cursor
|
|
8547
|
+
* const prevPage = await selectFrom(users)
|
|
8548
|
+
* .orderBy(users.columns.createdAt, 'DESC')
|
|
8549
|
+
* .orderBy(users.columns.id, 'DESC')
|
|
8550
|
+
* .executeCursor(session, { last: 20, before: page2.pageInfo.startCursor });
|
|
8551
|
+
*/
|
|
8552
|
+
async executeCursor(session, options) {
|
|
8553
|
+
const builder = this.ensureDefaultSelection();
|
|
8554
|
+
return executeCursorQuery(builder, session, options);
|
|
8555
|
+
}
|
|
8556
|
+
/**
|
|
8557
|
+
* Executes the query and returns an array of values for a single column.
|
|
8340
8558
|
* This is a convenience method to avoid manual `.map(r => r.column)`.
|
|
8341
8559
|
*
|
|
8342
8560
|
* @param column - The column name to extract
|