@buka/nestjs-kit 4.4.3 → 4.4.4

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,14 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.4.4](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.4.3...v4.4.4) (2026-06-28)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * keq module is required for open bao module ([dca3091](https://github.com/buka-ltd/npm.nestjs-kit/commit/dca30910a3de536c8a34247864b2425c0dd450b5))
9
+ * 修复Entity引用类重名问题 ([5bab569](https://github.com/buka-ltd/npm.nestjs-kit/commit/5bab569643f652dd6990237cafc9ae6394ddadbe))
10
+ * 修复isBrowserRequest的误判问题 ([17f9274](https://github.com/buka-ltd/npm.nestjs-kit/commit/17f92747fa2073bc70a2b894e1c7ba7d60dc0115))
11
+
3
12
  ## [4.4.3](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.4.2...v4.4.3) (2026-06-22)
4
13
 
5
14
 
package/dist/index.d.mts CHANGED
@@ -4,13 +4,13 @@ import { AnyEntity, Collection, Config, Cursor, DefineConfig, EmbeddedOptions, E
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";
7
+ import { KeqMiddlewareConsumer, KeqMiddlewareModule } from "@keq-request/nestjs";
7
8
  import { Base32, ErrorCategory, ErrorCategory as ErrorCategory$1, ErrorCode, ErrorCode as ErrorCode$1, ErrorCodeOptions } from "@buka/error-codes";
8
9
  import { Exception, ExceptionDetail, ExceptionDetail as ExceptionDetail$1, ExceptionOptions as ExceptionOptions$1 } from "@buka/exception";
9
10
  import { Logger, LoggerErrorInterceptor } from "nestjs-pino";
10
11
  import { Readable } from "node:stream";
11
12
  import * as _$type_fest0 from "type-fest";
12
13
  import { Class, JsonValue, ValueOf } from "type-fest";
13
- import { KeqMiddlewareConsumer, KeqMiddlewareModule } from "@keq-request/nestjs";
14
14
  import { IncomingMessage } from "http";
15
15
 
16
16
  //#region src/swagger-patcher/deep-objectify-queries.d.ts
@@ -347,12 +347,16 @@ declare function ValidateNestedDictionary(typeFunc: () => Class<object>, validat
347
347
  //#endregion
348
348
  //#region src/modules/core/decorators/is-browser-request.d.ts
349
349
  /**
350
- * 参数装饰器,通过检测请求头中是否存在 `Sec-Fetch-*` 系列头,
350
+ * 参数装饰器,通过检测请求头中是否存在 `Sec-Fetch-Site` 头,
351
351
  * 判断请求是否来自浏览器。
352
352
  *
353
353
  * 浏览器在发起请求时会自动附加 `Sec-Fetch-Site`、`Sec-Fetch-Mode`、
354
- * `Sec-Fetch-Dest` 等头([Fetch Metadata Request Headers](https://www.w3.org/TR/fetch-metadata/)),
355
- * 非浏览器客户端(如 curl、Postman、服务端调用)通常不会携带这些头。
354
+ * `Sec-Fetch-Dest` 等头([Fetch Metadata Request Headers](https://www.w3.org/TR/fetch-metadata/))。
355
+ * 非浏览器客户端(如 curl、Postman)通常不会携带这些头。
356
+ *
357
+ * **注意:** Node.js 的 undici(globalThis.fetch)会自动添加 `Sec-Fetch-Mode: cors`,
358
+ * 但不会添加 `Sec-Fetch-Site`。因此使用 `Sec-Fetch-Site` 而非任意 `Sec-Fetch-*`
359
+ * 头来区分真正的浏览器请求和服务端 fetch 调用。
356
360
  *
357
361
  * 装饰的参数类型应为 `boolean`。
358
362
  *
package/dist/index.d.ts CHANGED
@@ -347,12 +347,16 @@ declare function ValidateNestedDictionary(typeFunc: () => Class<object>, validat
347
347
  //#endregion
348
348
  //#region src/modules/core/decorators/is-browser-request.d.ts
349
349
  /**
350
- * 参数装饰器,通过检测请求头中是否存在 `Sec-Fetch-*` 系列头,
350
+ * 参数装饰器,通过检测请求头中是否存在 `Sec-Fetch-Site` 头,
351
351
  * 判断请求是否来自浏览器。
352
352
  *
353
353
  * 浏览器在发起请求时会自动附加 `Sec-Fetch-Site`、`Sec-Fetch-Mode`、
354
- * `Sec-Fetch-Dest` 等头([Fetch Metadata Request Headers](https://www.w3.org/TR/fetch-metadata/)),
355
- * 非浏览器客户端(如 curl、Postman、服务端调用)通常不会携带这些头。
354
+ * `Sec-Fetch-Dest` 等头([Fetch Metadata Request Headers](https://www.w3.org/TR/fetch-metadata/))。
355
+ * 非浏览器客户端(如 curl、Postman)通常不会携带这些头。
356
+ *
357
+ * **注意:** Node.js 的 undici(globalThis.fetch)会自动添加 `Sec-Fetch-Mode: cors`,
358
+ * 但不会添加 `Sec-Fetch-Site`。因此使用 `Sec-Fetch-Site` 而非任意 `Sec-Fetch-*`
359
+ * 头来区分真正的浏览器请求和服务端 fetch 调用。
356
360
  *
357
361
  * 装饰的参数类型应为 `boolean`。
358
362
  *
package/dist/index.js CHANGED
@@ -44,6 +44,7 @@ node_fs = __toESM(node_fs);
44
44
  let keq = require("keq");
45
45
  let _keq_request_url = require("@keq-request/url");
46
46
  let _keq_request_exception = require("@keq-request/exception");
47
+ let _keq_request_nestjs = require("@keq-request/nestjs");
47
48
  let crypto$1 = require("crypto");
48
49
  let bcryptjs = require("bcryptjs");
49
50
  bcryptjs = __toESM(bcryptjs);
@@ -756,12 +757,16 @@ function ValidateNestedDictionary(typeFunc, validationOptions) {
756
757
  //#endregion
757
758
  //#region src/modules/core/decorators/is-browser-request.ts
758
759
  /**
759
- * 参数装饰器,通过检测请求头中是否存在 `Sec-Fetch-*` 系列头,
760
+ * 参数装饰器,通过检测请求头中是否存在 `Sec-Fetch-Site` 头,
760
761
  * 判断请求是否来自浏览器。
761
762
  *
762
763
  * 浏览器在发起请求时会自动附加 `Sec-Fetch-Site`、`Sec-Fetch-Mode`、
763
- * `Sec-Fetch-Dest` 等头([Fetch Metadata Request Headers](https://www.w3.org/TR/fetch-metadata/)),
764
- * 非浏览器客户端(如 curl、Postman、服务端调用)通常不会携带这些头。
764
+ * `Sec-Fetch-Dest` 等头([Fetch Metadata Request Headers](https://www.w3.org/TR/fetch-metadata/))。
765
+ * 非浏览器客户端(如 curl、Postman)通常不会携带这些头。
766
+ *
767
+ * **注意:** Node.js 的 undici(globalThis.fetch)会自动添加 `Sec-Fetch-Mode: cors`,
768
+ * 但不会添加 `Sec-Fetch-Site`。因此使用 `Sec-Fetch-Site` 而非任意 `Sec-Fetch-*`
769
+ * 头来区分真正的浏览器请求和服务端 fetch 调用。
765
770
  *
766
771
  * 装饰的参数类型应为 `boolean`。
767
772
  *
@@ -780,7 +785,7 @@ function ValidateNestedDictionary(typeFunc, validationOptions) {
780
785
  */
781
786
  const IsBrowserRequest = (0, _nestjs_common.createParamDecorator)((_data, ctx) => {
782
787
  const request = ctx.switchToHttp().getRequest();
783
- return Object.keys(request.headers).some((key) => key.toLowerCase().startsWith("sec-fetch-"));
788
+ return Object.keys(request.headers).some((key) => key.toLowerCase() === "sec-fetch-site");
784
789
  });
785
790
  //#endregion
786
791
  //#region src/modules/core/decorators/model/model.register.ts
@@ -2863,6 +2868,7 @@ function PrimaryKeyType(classRef) {
2863
2868
  const primaryProperties = getMetadata(classRef).filter((prop) => prop.primary).map((prop) => prop.name);
2864
2869
  if (!primaryProperties.length) throw new Error(`Cannot create PrimaryKeyType for ${classRef.name} because it has no primary properties.`);
2865
2870
  class PrimaryKeyTypeClass {}
2871
+ Object.defineProperty(PrimaryKeyTypeClass, "name", { value: `${classRef.name}PrimaryKeyType` });
2866
2872
  PrimaryKeyTypeClass[PrimaryKeyTypeClassMetadataPropertyKey] = classRef;
2867
2873
  cloneMetadata(PrimaryKeyTypeClass, classRef, primaryProperties);
2868
2874
  (0, _nestjs_mapped_types.inheritValidationMetadata)(classRef, PrimaryKeyTypeClass, (key) => primaryProperties.includes(key));
@@ -6625,7 +6631,7 @@ let OpenBaoModule = class OpenBaoModule extends ConfigurableModuleClass$4 {
6625
6631
  OpenBaoModule = __decorate([
6626
6632
  (0, _nestjs_common.Global)(),
6627
6633
  (0, _nestjs_common.Module)({
6628
- imports: [OpenBaoHttpModule.register({ isGlobal: true })],
6634
+ imports: [_keq_request_nestjs.KeqModule, OpenBaoHttpModule.register({ isGlobal: true })],
6629
6635
  providers: [OpenBaoTokenManager],
6630
6636
  exports: [OpenBaoTokenManager, OpenBaoHttpModule]
6631
6637
  }),