@buka/nestjs-kit 4.4.3 → 4.4.6
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 +23 -0
- package/dist/index.d.mts +74 -7
- package/dist/index.d.ts +74 -7
- package/dist/index.js +48 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [4.4.6](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.4.5...v4.4.6) (2026-06-30)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* wrong package depenpencies version ([2bd531a](https://github.com/buka-ltd/npm.nestjs-kit/commit/2bd531ad6a24cc80d7b72a3f566c2539d59e71d4))
|
|
9
|
+
|
|
10
|
+
## [4.4.5](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.4.4...v4.4.5) (2026-06-30)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Performance Improvements
|
|
14
|
+
|
|
15
|
+
* upgrade keq to 5.0.0-beta.14 ([8e93f73](https://github.com/buka-ltd/npm.nestjs-kit/commit/8e93f73a58dc178a0bda06ffc1dc3546db1a5885))
|
|
16
|
+
|
|
17
|
+
## [4.4.4](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.4.3...v4.4.4) (2026-06-28)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* keq module is required for open bao module ([dca3091](https://github.com/buka-ltd/npm.nestjs-kit/commit/dca30910a3de536c8a34247864b2425c0dd450b5))
|
|
23
|
+
* 修复Entity引用类重名问题 ([5bab569](https://github.com/buka-ltd/npm.nestjs-kit/commit/5bab569643f652dd6990237cafc9ae6394ddadbe))
|
|
24
|
+
* 修复isBrowserRequest的误判问题 ([17f9274](https://github.com/buka-ltd/npm.nestjs-kit/commit/17f92747fa2073bc70a2b894e1c7ba7d60dc0115))
|
|
25
|
+
|
|
3
26
|
## [4.4.3](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.4.2...v4.4.3) (2026-06-22)
|
|
4
27
|
|
|
5
28
|
|
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 { KeqConsumer, KeqModuleOptions } 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
|
*
|
|
@@ -2082,6 +2086,70 @@ declare class OpenBaoTokenManager implements OnModuleInit, OnModuleDestroy {
|
|
|
2082
2086
|
private renewToken;
|
|
2083
2087
|
}
|
|
2084
2088
|
//#endregion
|
|
2089
|
+
//#region src/apis/open-bao-http/open-bao-http.module.d.ts
|
|
2090
|
+
interface OpenBaoHttpModuleOptions extends KeqModuleOptions {
|
|
2091
|
+
/**
|
|
2092
|
+
* Whether to register the module globally.
|
|
2093
|
+
* @default false
|
|
2094
|
+
*/
|
|
2095
|
+
isGlobal?: boolean;
|
|
2096
|
+
}
|
|
2097
|
+
declare const ConfigurableModuleClass$4: _$_nestjs_common0.ConfigurableModuleCls<OpenBaoHttpModuleOptions, "register", "create", {
|
|
2098
|
+
isGlobal: boolean;
|
|
2099
|
+
}>;
|
|
2100
|
+
/**
|
|
2101
|
+
* NestJS module that provides the {@link OpenBaoHttpClient} for dependency injection.
|
|
2102
|
+
*
|
|
2103
|
+
* This module requires a `KeqRequest` instance, which can be provided in two ways:
|
|
2104
|
+
*
|
|
2105
|
+
* **Option 1: Use the global `KeqModule` (recommended)**
|
|
2106
|
+
*
|
|
2107
|
+
* Import `KeqModule` globally, then register this module.
|
|
2108
|
+
* The module will fork from the global KeqRequest and inherit its middlewares.
|
|
2109
|
+
*
|
|
2110
|
+
* ```typescript
|
|
2111
|
+
* // app.module.ts
|
|
2112
|
+
* import { KeqModule } from '@keq-request/nestjs'
|
|
2113
|
+
*
|
|
2114
|
+
* @Module({
|
|
2115
|
+
* imports: [
|
|
2116
|
+
* KeqModule,
|
|
2117
|
+
* OpenBaoHttpModule.register({
|
|
2118
|
+
* isGlobal: true, // optional, default false
|
|
2119
|
+
* middlewares: [], // module-level middlewares
|
|
2120
|
+
* }),
|
|
2121
|
+
* ],
|
|
2122
|
+
* })
|
|
2123
|
+
* export class AppModule {}
|
|
2124
|
+
* ```
|
|
2125
|
+
*
|
|
2126
|
+
* **Option 2: Provide an isolated `KeqRequest` instance**
|
|
2127
|
+
*
|
|
2128
|
+
* ```typescript
|
|
2129
|
+
* @Module({
|
|
2130
|
+
* imports: [
|
|
2131
|
+
* OpenBaoHttpModule.register({
|
|
2132
|
+
* isolate: true, // no inherited middlewares
|
|
2133
|
+
* }),
|
|
2134
|
+
* ],
|
|
2135
|
+
* })
|
|
2136
|
+
* export class SomeFeatureModule {}
|
|
2137
|
+
* ```
|
|
2138
|
+
*
|
|
2139
|
+
* Then inject `OpenBaoHttpClient` in your services:
|
|
2140
|
+
*
|
|
2141
|
+
* ```typescript
|
|
2142
|
+
* @Injectable()
|
|
2143
|
+
* export class SomeService {
|
|
2144
|
+
* constructor(private readonly client: OpenBaoHttpClient) {}
|
|
2145
|
+
* }
|
|
2146
|
+
* ```
|
|
2147
|
+
*/
|
|
2148
|
+
declare class OpenBaoHttpModule extends ConfigurableModuleClass$4 {
|
|
2149
|
+
static readonly KEQ_REQUEST: symbol;
|
|
2150
|
+
static readonly KEQ_CONSUMER: symbol;
|
|
2151
|
+
}
|
|
2152
|
+
//#endregion
|
|
2085
2153
|
//#region src/modules/open-bao/open-bao.module-definition.d.ts
|
|
2086
2154
|
declare const ConfigurableModuleClass$3: _$_nestjs_common0.ConfigurableModuleCls<OpenBaoModuleOptions, "register", "create", {}>, MODULE_OPTIONS_TOKEN: string | symbol;
|
|
2087
2155
|
//#endregion
|
|
@@ -2136,11 +2204,10 @@ declare const ConfigurableModuleClass$3: _$_nestjs_common0.ConfigurableModuleCls
|
|
|
2136
2204
|
* })
|
|
2137
2205
|
* ```
|
|
2138
2206
|
*/
|
|
2139
|
-
declare class OpenBaoModule extends ConfigurableModuleClass$3
|
|
2207
|
+
declare class OpenBaoModule extends ConfigurableModuleClass$3 {
|
|
2140
2208
|
private readonly options;
|
|
2141
2209
|
private readonly tokenManager;
|
|
2142
|
-
constructor(options: OpenBaoModuleOptions, tokenManager: OpenBaoTokenManager);
|
|
2143
|
-
configureKeqMiddleware(consumer: KeqMiddlewareConsumer): void;
|
|
2210
|
+
constructor(options: OpenBaoModuleOptions, tokenManager: OpenBaoTokenManager, consumer: KeqConsumer<typeof OpenBaoHttpModule>);
|
|
2144
2211
|
}
|
|
2145
2212
|
//#endregion
|
|
2146
2213
|
//#region src/modules/open-bao/open-bao.config.d.ts
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ 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
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";
|
|
8
|
-
import {
|
|
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";
|
|
11
11
|
import { Exception, ExceptionDetail, ExceptionDetail as ExceptionDetail$1, ExceptionOptions as ExceptionOptions$1 } from "@buka/exception";
|
|
@@ -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
|
*
|
|
@@ -2082,6 +2086,70 @@ declare class OpenBaoTokenManager implements OnModuleInit, OnModuleDestroy {
|
|
|
2082
2086
|
private renewToken;
|
|
2083
2087
|
}
|
|
2084
2088
|
//#endregion
|
|
2089
|
+
//#region src/apis/open-bao-http/open-bao-http.module.d.ts
|
|
2090
|
+
interface OpenBaoHttpModuleOptions extends KeqModuleOptions {
|
|
2091
|
+
/**
|
|
2092
|
+
* Whether to register the module globally.
|
|
2093
|
+
* @default false
|
|
2094
|
+
*/
|
|
2095
|
+
isGlobal?: boolean;
|
|
2096
|
+
}
|
|
2097
|
+
declare const ConfigurableModuleClass$4: _$_nestjs_common0.ConfigurableModuleCls<OpenBaoHttpModuleOptions, "register", "create", {
|
|
2098
|
+
isGlobal: boolean;
|
|
2099
|
+
}>;
|
|
2100
|
+
/**
|
|
2101
|
+
* NestJS module that provides the {@link OpenBaoHttpClient} for dependency injection.
|
|
2102
|
+
*
|
|
2103
|
+
* This module requires a `KeqRequest` instance, which can be provided in two ways:
|
|
2104
|
+
*
|
|
2105
|
+
* **Option 1: Use the global `KeqModule` (recommended)**
|
|
2106
|
+
*
|
|
2107
|
+
* Import `KeqModule` globally, then register this module.
|
|
2108
|
+
* The module will fork from the global KeqRequest and inherit its middlewares.
|
|
2109
|
+
*
|
|
2110
|
+
* ```typescript
|
|
2111
|
+
* // app.module.ts
|
|
2112
|
+
* import { KeqModule } from '@keq-request/nestjs'
|
|
2113
|
+
*
|
|
2114
|
+
* @Module({
|
|
2115
|
+
* imports: [
|
|
2116
|
+
* KeqModule,
|
|
2117
|
+
* OpenBaoHttpModule.register({
|
|
2118
|
+
* isGlobal: true, // optional, default false
|
|
2119
|
+
* middlewares: [], // module-level middlewares
|
|
2120
|
+
* }),
|
|
2121
|
+
* ],
|
|
2122
|
+
* })
|
|
2123
|
+
* export class AppModule {}
|
|
2124
|
+
* ```
|
|
2125
|
+
*
|
|
2126
|
+
* **Option 2: Provide an isolated `KeqRequest` instance**
|
|
2127
|
+
*
|
|
2128
|
+
* ```typescript
|
|
2129
|
+
* @Module({
|
|
2130
|
+
* imports: [
|
|
2131
|
+
* OpenBaoHttpModule.register({
|
|
2132
|
+
* isolate: true, // no inherited middlewares
|
|
2133
|
+
* }),
|
|
2134
|
+
* ],
|
|
2135
|
+
* })
|
|
2136
|
+
* export class SomeFeatureModule {}
|
|
2137
|
+
* ```
|
|
2138
|
+
*
|
|
2139
|
+
* Then inject `OpenBaoHttpClient` in your services:
|
|
2140
|
+
*
|
|
2141
|
+
* ```typescript
|
|
2142
|
+
* @Injectable()
|
|
2143
|
+
* export class SomeService {
|
|
2144
|
+
* constructor(private readonly client: OpenBaoHttpClient) {}
|
|
2145
|
+
* }
|
|
2146
|
+
* ```
|
|
2147
|
+
*/
|
|
2148
|
+
declare class OpenBaoHttpModule extends ConfigurableModuleClass$4 {
|
|
2149
|
+
static readonly KEQ_REQUEST: symbol;
|
|
2150
|
+
static readonly KEQ_CONSUMER: symbol;
|
|
2151
|
+
}
|
|
2152
|
+
//#endregion
|
|
2085
2153
|
//#region src/modules/open-bao/open-bao.module-definition.d.ts
|
|
2086
2154
|
declare const ConfigurableModuleClass$3: _$_nestjs_common0.ConfigurableModuleCls<OpenBaoModuleOptions, "register", "create", {}>, MODULE_OPTIONS_TOKEN: string | symbol;
|
|
2087
2155
|
//#endregion
|
|
@@ -2136,11 +2204,10 @@ declare const ConfigurableModuleClass$3: _$_nestjs_common0.ConfigurableModuleCls
|
|
|
2136
2204
|
* })
|
|
2137
2205
|
* ```
|
|
2138
2206
|
*/
|
|
2139
|
-
declare class OpenBaoModule extends ConfigurableModuleClass$3
|
|
2207
|
+
declare class OpenBaoModule extends ConfigurableModuleClass$3 {
|
|
2140
2208
|
private readonly options;
|
|
2141
2209
|
private readonly tokenManager;
|
|
2142
|
-
constructor(options: OpenBaoModuleOptions, tokenManager: OpenBaoTokenManager);
|
|
2143
|
-
configureKeqMiddleware(consumer: KeqMiddlewareConsumer): void;
|
|
2210
|
+
constructor(options: OpenBaoModuleOptions, tokenManager: OpenBaoTokenManager, consumer: KeqConsumer<typeof OpenBaoHttpModule>);
|
|
2144
2211
|
}
|
|
2145
2212
|
//#endregion
|
|
2146
2213
|
//#region src/modules/open-bao/open-bao.config.d.ts
|
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()
|
|
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
|
|
@@ -2717,7 +2722,7 @@ const Column = {
|
|
|
2717
2722
|
};
|
|
2718
2723
|
//#endregion
|
|
2719
2724
|
//#region src/modules/mikro-orm/models/timestamped-entity.ts
|
|
2720
|
-
var _ref$14, _ref2$
|
|
2725
|
+
var _ref$14, _ref2$4;
|
|
2721
2726
|
var TimestampedEntity = class {
|
|
2722
2727
|
[_mikro_orm_core.OptionalProps];
|
|
2723
2728
|
createdAt = /* @__PURE__ */ new Date();
|
|
@@ -2732,7 +2737,7 @@ __decorate([Column.Timestamptz({
|
|
|
2732
2737
|
onUpdate: () => /* @__PURE__ */ new Date(),
|
|
2733
2738
|
defaultRaw: "CURRENT_TIMESTAMP",
|
|
2734
2739
|
comment: "更新时间"
|
|
2735
|
-
}), __decorateMetadata("design:type", typeof (_ref2$
|
|
2740
|
+
}), __decorateMetadata("design:type", typeof (_ref2$4 = typeof Date !== "undefined" && Date) === "function" ? _ref2$4 : Object)], TimestampedEntity.prototype, "updatedAt", void 0);
|
|
2736
2741
|
//#endregion
|
|
2737
2742
|
//#region src/modules/mikro-orm/models/linear-entity.ts
|
|
2738
2743
|
var LinearEntity = class extends TimestampedEntity {
|
|
@@ -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));
|
|
@@ -3188,7 +3194,7 @@ __decorate([
|
|
|
3188
3194
|
], DatabaseConfig.prototype, "poolIdleTimeoutMillis", void 0);
|
|
3189
3195
|
//#endregion
|
|
3190
3196
|
//#region src/modules/core/pipes/validation.pipe.ts
|
|
3191
|
-
var _ref$13, _ref2$
|
|
3197
|
+
var _ref$13, _ref2$3, _ref3$1, _BukaValidationPipe;
|
|
3192
3198
|
function deepMap(obj, fn) {
|
|
3193
3199
|
if (Array.isArray(obj)) return obj.map((item) => deepMap(item, fn));
|
|
3194
3200
|
else return fn(obj);
|
|
@@ -3249,7 +3255,7 @@ let BukaValidationPipe = _BukaValidationPipe = class BukaValidationPipe extends
|
|
|
3249
3255
|
};
|
|
3250
3256
|
BukaValidationPipe = _BukaValidationPipe = __decorate([(0, _nestjs_common.Injectable)(), __decorateMetadata("design:paramtypes", [
|
|
3251
3257
|
typeof (_ref$13 = typeof _mikro_orm_core.MikroORM !== "undefined" && _mikro_orm_core.MikroORM) === "function" ? _ref$13 : Object,
|
|
3252
|
-
typeof (_ref2$
|
|
3258
|
+
typeof (_ref2$3 = typeof _mikro_orm_core.EntityManager !== "undefined" && _mikro_orm_core.EntityManager) === "function" ? _ref2$3 : Object,
|
|
3253
3259
|
typeof (_ref3$1 = typeof _nestjs_common.ValidationPipeOptions !== "undefined" && _nestjs_common.ValidationPipeOptions) === "function" ? _ref3$1 : Object
|
|
3254
3260
|
])], BukaValidationPipe);
|
|
3255
3261
|
//#endregion
|
|
@@ -6482,6 +6488,7 @@ OpenBaoHttpClient = _OpenBaoHttpClient = __decorate([(0, _nestjs_common.Injectab
|
|
|
6482
6488
|
//#endregion
|
|
6483
6489
|
//#region src/apis/open-bao-http/open-bao-http.module.ts
|
|
6484
6490
|
const KEQ_REQUEST_TOKEN = Symbol("OpenBaoHttpKeqRequest");
|
|
6491
|
+
const KEQ_CONSUMER_TOKEN = Symbol("OpenBaoHttpKeqConsumer");
|
|
6485
6492
|
const { ConfigurableModuleClass: ConfigurableModuleClass$3, MODULE_OPTIONS_TOKEN: MODULE_OPTIONS_TOKEN$3 } = new _nestjs_common.ConfigurableModuleBuilder().setExtras({ isGlobal: false }, (definition, extras) => ({
|
|
6486
6493
|
...definition,
|
|
6487
6494
|
global: extras.isGlobal
|
|
@@ -6504,12 +6511,23 @@ const CLIENT_PROVIDER = {
|
|
|
6504
6511
|
useFactory: (request) => new OpenBaoHttpClient(request),
|
|
6505
6512
|
inject: [KEQ_REQUEST_TOKEN]
|
|
6506
6513
|
};
|
|
6514
|
+
const CONSUMER_PROVIDER = {
|
|
6515
|
+
provide: KEQ_CONSUMER_TOKEN,
|
|
6516
|
+
useFactory: (request) => new _keq_request_nestjs.KeqConsumer(request),
|
|
6517
|
+
inject: [KEQ_REQUEST_TOKEN]
|
|
6518
|
+
};
|
|
6507
6519
|
let OpenBaoHttpModule = class OpenBaoHttpModule extends ConfigurableModuleClass$3 {
|
|
6508
6520
|
static KEQ_REQUEST = KEQ_REQUEST_TOKEN;
|
|
6521
|
+
static KEQ_CONSUMER = KEQ_CONSUMER_TOKEN;
|
|
6509
6522
|
};
|
|
6510
6523
|
OpenBaoHttpModule = __decorate([(0, _nestjs_common.Module)({
|
|
6511
|
-
|
|
6512
|
-
|
|
6524
|
+
imports: [_keq_request_nestjs.KeqModule],
|
|
6525
|
+
providers: [
|
|
6526
|
+
REQUEST_PROVIDER,
|
|
6527
|
+
CONSUMER_PROVIDER,
|
|
6528
|
+
CLIENT_PROVIDER
|
|
6529
|
+
],
|
|
6530
|
+
exports: [OpenBaoHttpClient, KEQ_CONSUMER_TOKEN]
|
|
6513
6531
|
})], OpenBaoHttpModule);
|
|
6514
6532
|
//#endregion
|
|
6515
6533
|
//#region src/modules/open-bao/set-open-bao-token.middleware.ts
|
|
@@ -6566,6 +6584,7 @@ function setOpenBaoToken(getToken) {
|
|
|
6566
6584
|
}
|
|
6567
6585
|
//#endregion
|
|
6568
6586
|
//#region src/modules/open-bao/request/format-error.ts
|
|
6587
|
+
const logger$1 = new _nestjs_common.Logger("ClarifyOpenbaoError");
|
|
6569
6588
|
/**
|
|
6570
6589
|
* 根据 HTTP 状态码生成中文操作建议
|
|
6571
6590
|
*/
|
|
@@ -6582,14 +6601,19 @@ function getStatusCodeGuidance(statusCode) {
|
|
|
6582
6601
|
* 必须注册在 `validateStatusCode` 之后,作为中间件链的最外层,
|
|
6583
6602
|
* 捕获 `RequestException` 并重写其错误消息,补充请求上下文和操作建议。
|
|
6584
6603
|
*
|
|
6585
|
-
* 非 RequestException
|
|
6604
|
+
* 非 RequestException 错误(网络故障、超时等)记录日志后原样透传。
|
|
6586
6605
|
*/
|
|
6587
|
-
function
|
|
6606
|
+
function clarifyOpenbaoError() {
|
|
6588
6607
|
const middleware = async (ctx, next) => {
|
|
6589
6608
|
try {
|
|
6590
6609
|
await next();
|
|
6591
6610
|
} catch (err) {
|
|
6592
|
-
if (!(err instanceof keq.RequestException))
|
|
6611
|
+
if (!(err instanceof keq.RequestException)) {
|
|
6612
|
+
const method = ctx.request.method.toUpperCase();
|
|
6613
|
+
const url = ctx.request.url.toString();
|
|
6614
|
+
logger$1.error(`OpenBaoModule API 请求异常: ${method} ${url}`, err instanceof Error ? err.stack : void 0);
|
|
6615
|
+
throw err;
|
|
6616
|
+
}
|
|
6593
6617
|
const method = ctx.request.method.toUpperCase();
|
|
6594
6618
|
const url = ctx.request.url.toString();
|
|
6595
6619
|
const statusCode = err.statusCode;
|
|
@@ -6606,31 +6630,34 @@ function formatError() {
|
|
|
6606
6630
|
throw err;
|
|
6607
6631
|
}
|
|
6608
6632
|
};
|
|
6609
|
-
middleware.__keqMiddlewareName__ = "
|
|
6633
|
+
middleware.__keqMiddlewareName__ = "clarifyOpenbaoError";
|
|
6610
6634
|
return middleware;
|
|
6611
6635
|
}
|
|
6612
6636
|
//#endregion
|
|
6613
6637
|
//#region src/modules/open-bao/open-bao.module.ts
|
|
6614
|
-
var _ref$10;
|
|
6638
|
+
var _ref$10, _ref2$2;
|
|
6615
6639
|
let OpenBaoModule = class OpenBaoModule extends ConfigurableModuleClass$4 {
|
|
6616
|
-
constructor(options, tokenManager) {
|
|
6640
|
+
constructor(options, tokenManager, consumer) {
|
|
6617
6641
|
super();
|
|
6618
6642
|
this.options = options;
|
|
6619
6643
|
this.tokenManager = tokenManager;
|
|
6620
|
-
|
|
6621
|
-
configureKeqMiddleware(consumer) {
|
|
6622
|
-
consumer.apply(formatError(), (0, _keq_request_url.setBaseUrl)(this.options.address + "/v1/"), setOpenBaoToken(() => this.tokenManager.getToken()), (0, _keq_request_exception.validateStatusCode)()).forRoutes(OpenBaoHttpModule);
|
|
6644
|
+
consumer.apply(clarifyOpenbaoError(), (0, _keq_request_url.setBaseUrl)(this.options.address + "/v1/"), setOpenBaoToken(() => this.tokenManager.getToken()), (0, _keq_request_exception.validateStatusCode)(), (0, _keq_request_exception.clarifyFetchFailed)()).forRoutes(_keq_request_nestjs.KEQ_ROUTES.ALL);
|
|
6623
6645
|
}
|
|
6624
6646
|
};
|
|
6625
6647
|
OpenBaoModule = __decorate([
|
|
6626
6648
|
(0, _nestjs_common.Global)(),
|
|
6627
6649
|
(0, _nestjs_common.Module)({
|
|
6628
|
-
imports: [OpenBaoHttpModule.register({ isGlobal: true })],
|
|
6650
|
+
imports: [_keq_request_nestjs.KeqModule, OpenBaoHttpModule.register({ isGlobal: true })],
|
|
6629
6651
|
providers: [OpenBaoTokenManager],
|
|
6630
6652
|
exports: [OpenBaoTokenManager, OpenBaoHttpModule]
|
|
6631
6653
|
}),
|
|
6632
6654
|
__decorateParam(0, (0, _nestjs_common.Inject)(MODULE_OPTIONS_TOKEN$4)),
|
|
6633
|
-
|
|
6655
|
+
__decorateParam(2, (0, _keq_request_nestjs.InjectKeqConsumer)(OpenBaoHttpModule)),
|
|
6656
|
+
__decorateMetadata("design:paramtypes", [
|
|
6657
|
+
Object,
|
|
6658
|
+
typeof (_ref$10 = typeof OpenBaoTokenManager !== "undefined" && OpenBaoTokenManager) === "function" ? _ref$10 : Object,
|
|
6659
|
+
typeof (_ref2$2 = typeof _keq_request_nestjs.KeqConsumer !== "undefined" && _keq_request_nestjs.KeqConsumer) === "function" ? _ref2$2 : Object
|
|
6660
|
+
])
|
|
6634
6661
|
], OpenBaoModule);
|
|
6635
6662
|
//#endregion
|
|
6636
6663
|
//#region src/modules/open-bao/open-bao.config.ts
|