@buka/nestjs-kit 4.4.6 → 4.4.8

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.4.8](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.4.7...v4.4.8) (2026-07-05)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * 修复cursor格式无法获取首页的问题 ([f13c11d](https://github.com/buka-ltd/npm.nestjs-kit/commit/f13c11d8088f432a408209ac7d7cf97259521c87))
9
+
10
+ ## [4.4.7](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.4.6...v4.4.7) (2026-07-05)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * 修复Slice未正确处理Cursor泛型的问题 ([85414ee](https://github.com/buka-ltd/npm.nestjs-kit/commit/85414eee102f309bdcc91325d98be5b9ff93bdda))
16
+
3
17
  ## [4.4.6](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.4.5...v4.4.6) (2026-06-30)
4
18
 
5
19
 
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _$_nestjs_common0 from "@nestjs/common";
2
2
  import { ArgumentMetadata, ArgumentsHost, DynamicModule, ExceptionFilter, HttpStatus, OnApplicationBootstrap, OnModuleDestroy, OnModuleInit, PipeTransform, Type, ValidationPipe, ValidationPipeOptions } from "@nestjs/common";
3
- import { AnyEntity, Collection, Config, Cursor, DefineConfig, EmbeddedOptions, EntityManager, EntityName, EnumOptions, Hidden, HiddenProps, ManyToManyOptions, ManyToOneOptions, MikroORM, OneToManyOptions, OneToOneOptions, Opt, OptionalProps, Options, Primary, PrimaryKeyProp, PrimaryProperty, PropertyOptions, QueryOrderMap, Ref } from "@mikro-orm/core";
3
+ import { AnyEntity, Collection, Config, Cursor, DefineConfig, EmbeddedOptions, EntityManager, EntityName, EnumOptions, Hidden, HiddenProps, Loaded, ManyToManyOptions, ManyToOneOptions, MikroORM, OneToManyOptions, OneToOneOptions, Opt, OptionalProps, Options, Primary, PrimaryKeyProp, PrimaryProperty, PropertyOptions, QueryOrderMap, Ref } from "@mikro-orm/core";
4
4
  import { ValidationOptions } from "class-validator";
5
5
  import { ApiPropertyOptions, OpenAPIObject } from "@nestjs/swagger";
6
6
  import { Keq, KeqMiddleware, KeqOperation, KeqPathParameterInit, KeqQueryInit, KeqRequest, RequestException } from "keq";
@@ -958,12 +958,12 @@ type IOffsetPageParameters = {
958
958
  offset: number;
959
959
  };
960
960
  type INextCursorPageParameters = {
961
- first: number;
962
- after: string;
961
+ first: number; /** 首次加载无需传递 cursor */
962
+ after?: string;
963
963
  };
964
964
  type IPreviousCursorPageParameters = {
965
965
  last: number;
966
- before: string;
966
+ before?: string;
967
967
  };
968
968
  type IPageQuery<T extends 'cursor' | 'offset' = 'cursor' | 'offset'> = {
969
969
  page: T extends 'cursor' ? INextCursorPageParameters | IPreviousCursorPageParameters : T extends 'offset' ? IOffsetPageParameters : INextCursorPageParameters | IPreviousCursorPageParameters | IOffsetPageParameters;
@@ -998,7 +998,7 @@ declare class Slice<T extends object> {
998
998
  constructor(data: Array<T>, pagination: OffsetPagination | CursorPagination);
999
999
  [Symbol.iterator](): Iterator<T>;
1000
1000
  static fromOffset<T extends object>(data: Array<T>, total: number, parameters: IOffsetPageParameters): Slice<T>;
1001
- static fromCursor<T extends object>(cursor: Cursor<T>): Slice<T>;
1001
+ static fromCursor<T extends object, Hint extends string = never, Fields extends string = never, Excludes extends string = never>(cursor: Cursor<T, Hint, Fields, Excludes>): Slice<Loaded<T, Hint, Fields, Excludes>>;
1002
1002
  map<R extends object>(fn: (item: T, index: number) => R): Slice<R>;
1003
1003
  }
1004
1004
  //#endregion
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { Class, JsonValue, ValueOf } from "type-fest";
4
4
  import * as _$_nestjs_common0 from "@nestjs/common";
5
5
  import { ArgumentMetadata, ArgumentsHost, DynamicModule, ExceptionFilter, HttpStatus, OnApplicationBootstrap, OnModuleDestroy, OnModuleInit, PipeTransform, Type, ValidationPipe, ValidationPipeOptions } from "@nestjs/common";
6
6
  import { ValidationOptions } from "class-validator";
7
- import { AnyEntity, Collection, Config, Cursor, DefineConfig, EmbeddedOptions, EntityManager, EntityName, EnumOptions, Hidden, HiddenProps, ManyToManyOptions, ManyToOneOptions, MikroORM, OneToManyOptions, OneToOneOptions, Opt, OptionalProps, Options, Primary, PrimaryKeyProp, PrimaryProperty, PropertyOptions, QueryOrderMap, Ref } from "@mikro-orm/core";
7
+ import { AnyEntity, Collection, Config, Cursor, DefineConfig, EmbeddedOptions, EntityManager, EntityName, EnumOptions, Hidden, HiddenProps, Loaded, ManyToManyOptions, ManyToOneOptions, MikroORM, OneToManyOptions, OneToOneOptions, Opt, OptionalProps, Options, Primary, PrimaryKeyProp, PrimaryProperty, PropertyOptions, QueryOrderMap, Ref } from "@mikro-orm/core";
8
8
  import { KeqConsumer, KeqModuleOptions } from "@keq-request/nestjs";
9
9
  import { Keq, KeqMiddleware, KeqOperation, KeqPathParameterInit, KeqQueryInit, KeqRequest, RequestException } from "keq";
10
10
  import { Base32, ErrorCategory, ErrorCategory as ErrorCategory$1, ErrorCode, ErrorCode as ErrorCode$1, ErrorCodeOptions } from "@buka/error-codes";
@@ -958,12 +958,12 @@ type IOffsetPageParameters = {
958
958
  offset: number;
959
959
  };
960
960
  type INextCursorPageParameters = {
961
- first: number;
962
- after: string;
961
+ first: number; /** 首次加载无需传递 cursor */
962
+ after?: string;
963
963
  };
964
964
  type IPreviousCursorPageParameters = {
965
965
  last: number;
966
- before: string;
966
+ before?: string;
967
967
  };
968
968
  type IPageQuery<T extends 'cursor' | 'offset' = 'cursor' | 'offset'> = {
969
969
  page: T extends 'cursor' ? INextCursorPageParameters | IPreviousCursorPageParameters : T extends 'offset' ? IOffsetPageParameters : INextCursorPageParameters | IPreviousCursorPageParameters | IOffsetPageParameters;
@@ -998,7 +998,7 @@ declare class Slice<T extends object> {
998
998
  constructor(data: Array<T>, pagination: OffsetPagination | CursorPagination);
999
999
  [Symbol.iterator](): Iterator<T>;
1000
1000
  static fromOffset<T extends object>(data: Array<T>, total: number, parameters: IOffsetPageParameters): Slice<T>;
1001
- static fromCursor<T extends object>(cursor: Cursor<T>): Slice<T>;
1001
+ static fromCursor<T extends object, Hint extends string = never, Fields extends string = never, Excludes extends string = never>(cursor: Cursor<T, Hint, Fields, Excludes>): Slice<Loaded<T, Hint, Fields, Excludes>>;
1002
1002
  map<R extends object>(fn: (item: T, index: number) => R): Slice<R>;
1003
1003
  }
1004
1004
  //#endregion
package/dist/index.js CHANGED
@@ -1308,7 +1308,7 @@ const NextCursorPageSchema = {
1308
1308
  after: { type: "string" },
1309
1309
  first: { type: "number" }
1310
1310
  },
1311
- required: ["after", "first"],
1311
+ required: ["first"],
1312
1312
  additionalProperties: false
1313
1313
  };
1314
1314
  //#endregion
@@ -1319,7 +1319,7 @@ const PreviousCursorPageSchema = {
1319
1319
  before: { type: "string" },
1320
1320
  last: { type: "number" }
1321
1321
  },
1322
- required: ["before", "last"],
1322
+ required: ["last"],
1323
1323
  additionalProperties: false
1324
1324
  };
1325
1325
  //#endregion
@@ -1363,9 +1363,9 @@ let BukaPageQueryValidationPipe = class BukaPageQueryValidationPipe {
1363
1363
  if ("after" in value.page || "first" in value.page) {
1364
1364
  if ("limit" in value.page || "offset" in value.page) throw new _nestjs_common.BadRequestException(mixedOffsetAndCursorError);
1365
1365
  if ("before" in value.page || "last" in value.page) throw new _nestjs_common.BadRequestException(mixedNextAndLastCursorError);
1366
- const after = value.page.after;
1366
+ const after = value.page.after ?? "";
1367
1367
  const first = parseInt(value.page.first, 10);
1368
- if (typeof after !== "string") throw new _nestjs_common.BadRequestException("Invalid page query: after must be a string.");
1368
+ if (value.page.after !== void 0 && typeof value.page.after !== "string") throw new _nestjs_common.BadRequestException("Invalid page query: after must be a string.");
1369
1369
  if (isNaN(first) || first <= 0) throw new _nestjs_common.BadRequestException("Invalid page query: first must be a positive integer.");
1370
1370
  return { page: {
1371
1371
  after,
@@ -1375,9 +1375,9 @@ let BukaPageQueryValidationPipe = class BukaPageQueryValidationPipe {
1375
1375
  if ("before" in value.page || "last" in value.page) {
1376
1376
  if ("limit" in value.page || "offset" in value.page) throw new _nestjs_common.BadRequestException(mixedOffsetAndCursorError);
1377
1377
  if ("after" in value.page || "first" in value.page) throw new _nestjs_common.BadRequestException(mixedNextAndLastCursorError);
1378
- const before = value.page.before;
1378
+ const before = value.page.before ?? "";
1379
1379
  const last = parseInt(value.page.last, 10);
1380
- if (typeof before !== "string") throw new _nestjs_common.BadRequestException("Invalid page query: before must be a string.");
1380
+ if (value.page.before !== void 0 && typeof value.page.before !== "string") throw new _nestjs_common.BadRequestException("Invalid page query: before must be a string.");
1381
1381
  if (isNaN(last) || last <= 0) throw new _nestjs_common.BadRequestException("Invalid page query: last must be a positive integer.");
1382
1382
  return { page: {
1383
1383
  before,