@buka/nestjs-kit 4.0.0 → 4.1.1
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 +15 -3
- package/dist/index.d.mts +75 -1
- package/dist/index.d.ts +75 -1
- package/dist/index.js +134 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +121 -16
- package/dist/index.mjs.map +1 -1
- package/docs/core/urn.md +11 -11
- package/docs/exception.md +123 -121
- package/docs/index.md +6 -0
- package/docs/logger.md +289 -0
- package/package.json +6 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [4.
|
|
3
|
+
## [4.1.1](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.1.0...v4.1.1) (2026-05-10)
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* rename buka-inc to buka-ltd ([43e72ca](https://github.com/buka-ltd/npm.nestjs-kit/commit/43e72ca4065676cc384f07daf1953f2e04565244))
|
|
9
|
+
|
|
10
|
+
## [4.1.0](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.0.0...v4.1.0) (2026-05-10)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- add logger module ([5ead6da](https://github.com/buka-ltd/npm.nestjs-kit/commit/5ead6da6c15ae46929e713063b2dd0d580d63996))
|
|
15
|
+
|
|
16
|
+
## [4.0.0](https://github.com/buka-ltd/npm.nestjs-kit/compare/v3.0.1...v4.0.0) (2026-05-06)
|
|
17
|
+
|
|
6
18
|
### ⚠ BREAKING CHANGES
|
|
7
19
|
|
|
8
|
-
|
|
20
|
+
- overhaul entire project architecture
|
|
9
21
|
|
|
10
22
|
### Code Refactoring
|
|
11
23
|
|
|
12
|
-
|
|
24
|
+
- overhaul entire project architecture ([b4047a7](https://github.com/buka-ltd/npm.nestjs-kit/commit/b4047a790498a9f4b967d33830d6786ba3b24642))
|
package/dist/index.d.mts
CHANGED
|
@@ -6,6 +6,7 @@ import { ApiPropertyOptions, OpenAPIObject } from "@nestjs/swagger";
|
|
|
6
6
|
import { Keq, KeqMiddleware, KeqOperation, KeqPathParameterInit, KeqQueryInit, KeqRequest } from "keq";
|
|
7
7
|
import { Base32, ErrorCategory, ErrorCategory as ErrorCategory$1, ErrorCode, ErrorCodeOptions } from "@buka/error-codes";
|
|
8
8
|
import { Exception, ExceptionDetail, ExceptionDetail as ExceptionDetail$1, ExceptionOptions as ExceptionOptions$1 } from "@buka/exception";
|
|
9
|
+
import { Logger, LoggerErrorInterceptor } from "nestjs-pino";
|
|
9
10
|
import { Readable } from "node:stream";
|
|
10
11
|
import * as _$type_fest0 from "type-fest";
|
|
11
12
|
import { Class, JsonValue, ValueOf } from "type-fest";
|
|
@@ -18451,6 +18452,79 @@ declare class EnvelopeEncryptionService {
|
|
|
18451
18452
|
listCiphers(): CipherMetadata[];
|
|
18452
18453
|
}
|
|
18453
18454
|
//#endregion
|
|
18455
|
+
//#region src/modules/logger/types/logger-module-options.d.ts
|
|
18456
|
+
/**
|
|
18457
|
+
* LoggerModule 配置
|
|
18458
|
+
*
|
|
18459
|
+
* 与 LoggerConfig 基类字段一一对应
|
|
18460
|
+
*/
|
|
18461
|
+
interface LoggerModuleOptions {
|
|
18462
|
+
/** 服务名称,Grafana/Loki 中按服务过滤日志 */
|
|
18463
|
+
serviceName?: string;
|
|
18464
|
+
/** 运行环境,默认取 NODE_ENV */
|
|
18465
|
+
environment?: string;
|
|
18466
|
+
/** 服务版本号,生产环境由 CI/CD 注入 */
|
|
18467
|
+
version?: string;
|
|
18468
|
+
/** 日志级别,默认 info */
|
|
18469
|
+
level?: 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace';
|
|
18470
|
+
/** 开发模式——启用 pino-pretty 彩色输出 */
|
|
18471
|
+
pretty?: boolean;
|
|
18472
|
+
}
|
|
18473
|
+
//#endregion
|
|
18474
|
+
//#region src/modules/logger/logger.module.d.ts
|
|
18475
|
+
/**
|
|
18476
|
+
* 统一日志模块
|
|
18477
|
+
*
|
|
18478
|
+
* 基于 nestjs-pino,预配置 Grafana/Loki 友好的 JSON 日志格式。
|
|
18479
|
+
*
|
|
18480
|
+
* @example
|
|
18481
|
+
* // 直接使用
|
|
18482
|
+
* LoggerModule.register({ serviceName: 'my-service' })
|
|
18483
|
+
*
|
|
18484
|
+
* // 配合 @buka/nestjs-config
|
|
18485
|
+
* ConfigModule.inject(PinoConfig, LoggerModule, (config) => ({...config}))
|
|
18486
|
+
*/
|
|
18487
|
+
declare class LoggerModule {
|
|
18488
|
+
static register(options?: LoggerModuleOptions): DynamicModule;
|
|
18489
|
+
static registerAsync(options: {
|
|
18490
|
+
imports?: any[];
|
|
18491
|
+
inject?: any[];
|
|
18492
|
+
useFactory: (...args: any[]) => LoggerModuleOptions | Promise<LoggerModuleOptions>;
|
|
18493
|
+
}): DynamicModule;
|
|
18494
|
+
/**
|
|
18495
|
+
* 将 LoggerModuleOptions 转换为 nestjs-pino 的 Params
|
|
18496
|
+
*/
|
|
18497
|
+
private static buildParams;
|
|
18498
|
+
}
|
|
18499
|
+
//#endregion
|
|
18500
|
+
//#region src/modules/logger/decorators/inject-logger.decorator.d.ts
|
|
18501
|
+
/**
|
|
18502
|
+
* 注入 Logger,自动以类名为日志上下文
|
|
18503
|
+
*
|
|
18504
|
+
* 用法:
|
|
18505
|
+
* @InjectLogger()
|
|
18506
|
+
* private readonly logger: Logger
|
|
18507
|
+
*
|
|
18508
|
+
* 等价于:
|
|
18509
|
+
* @InjectPinoLogger(MyService.name)
|
|
18510
|
+
* private readonly logger: Logger
|
|
18511
|
+
*/
|
|
18512
|
+
declare function InjectLogger(context?: string): ParameterDecorator;
|
|
18513
|
+
//#endregion
|
|
18514
|
+
//#region src/modules/logger/logger.config.d.ts
|
|
18515
|
+
/**
|
|
18516
|
+
* 日志配置基类
|
|
18517
|
+
*
|
|
18518
|
+
* 项目中的日志配置应继承此类并通过 @Configuration('xxx') 绑定环境变量前缀
|
|
18519
|
+
*/
|
|
18520
|
+
declare class LoggerConfig {
|
|
18521
|
+
pretty: boolean;
|
|
18522
|
+
level: 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace';
|
|
18523
|
+
serviceName: string;
|
|
18524
|
+
environment: string;
|
|
18525
|
+
version: string;
|
|
18526
|
+
}
|
|
18527
|
+
//#endregion
|
|
18454
18528
|
//#region src/modules/object-storage/types/options.d.ts
|
|
18455
18529
|
interface ObjectStorageOptions {
|
|
18456
18530
|
prefix?: boolean;
|
|
@@ -18578,5 +18652,5 @@ declare class ObjectStorageService implements OnModuleInit {
|
|
|
18578
18652
|
*/
|
|
18579
18653
|
declare function stableStringify(value: unknown): string;
|
|
18580
18654
|
//#endregion
|
|
18581
|
-
export { AssociationMetadata, AuthException, BUKA_MODULE_OPTIONS_TOKEN, Base32, BlindIndex, BlindIndexHasher, BlindIndexModule, BlindIndexService, BlindIndexV1Hasher, BukaConfigurableModuleClass, BukaExceptions, BukaModule, BukaModuleOptions, BukaPageQueryValidationPipe, BukaValidationPipe, BusinessException, Cardinality, type CipherMetadata, CollectionAssociationMetadata, Column, Composite, CompositePropertyMetadata, ConfigurableModuleClass, ConflictException, CursorPagination, DatabaseConfig, type DecryptCommand, DegradeException, Dictionary, DictionaryPropertyMetadata, DiscreteEntity, EagerType, type EncryptCommand, EncryptedPayload, EntityRef, Enum, EnumPropertyMetadata, EnvelopeEncryptionModule, type EnvelopeEncryptionModuleOptions, EnvelopeEncryptionService, ErrorCategory, ErrorCode, ErrorCodeController, ErrorCodeExceptionFilter, ErrorCodeDefinitionDto as ErrorCodeItemDto, ErrorCodeMetadataDto, type ErrorCodeOptions, ErrorCodePartsDto, ErrorCodeRegistry, ErrorResponseSchema, type ExceptionConstructor, type ExceptionConstructorWithArgs, type ExceptionDetail, ExceptionDetailSchema, ExceptionModule, type ExceptionModuleOptions as ExceptionNestModuleOptions, type ExceptionOptions, type ExceptionOptionsWithFactory, type ExceptionOptionsWithMessage, ExcludeDefinedOpt, ExcludeHidden, ExcludeOpt, ExcludeRef, ExcludeScalarClass, FeatureException, FilterQuery, FilterQueryOperator, FilterQueryOperators, FilterQueryOperatorsMetadataKey, FilterQueryTransformPipe, HAS_ANY_KEY, HasAnyKey, HttpException, type HttpExceptionOptions, IEntityPrimaryKey, IFilter, IFilterQuery, IFilterQueryCollectionCondition, IFilterQueryCondition, IFilterQueryNestedProperty, IFilterQueryObject, IFilterQueryProperty, IListResponseBody, IListResponseBodyMeta, INextCursorPageParameters, IOffsetPageParameters, IOrderQuery, IPageQuery, IPreviousCursorPageParameters, IResponseBody, IS_CROCKFORD_BASE32, IS_IDENTIFIER_URN, IS_NAMESPACE_URN, IS_RESOURCE_URN, IS_SCALAR_DICTIONARY, IS_URN, IdentifierUrn, IsBrowserRequest, IsCrockfordBase32, IsHidden, IsIdentifierUrn, IsNamespaceUrn, IsOpt, IsResourceUrn, IsScalar, IsScalarDictionary, IsUrn, KeyEnvelope, LinearEntity, List, ListErrorCodesResponseDto, ListPropertyMetadata, ListResponseBodyType, MATCH_JSON_SCHEMA, MODULE_OPTIONS_TOKEN, MatchJsonSchema, Model, ModelMetadata, ModelOptions, ModelRegister, ModelSchemaOptions, ModuleExceptions, type ExceptionModuleOptions$1 as ModuleExceptionsOptions, NamespaceUrn, NextCursorPageSchema, ObjectStorageModule, ObjectStorageModuleConfig, ObjectStorageModuleOptions, ObjectStorageOptions, ObjectStorageService, OffsetPageSchema, OffsetPagination, OmitType, OpenBaoAppRoleAuth, OpenBaoAppRoleAuthConfig, OpenBaoAuthMethod, OpenBaoAuthResponse, OpenBaoHttpClient, OpenBaoKubernetesAuth, OpenBaoKubernetesAuthConfig, OpenBaoModule, OpenBaoModuleConfig, OpenBaoModuleOptions, OpenBaoTokenAuth, OpenBaoTokenAuthConfig, OpenBaoTokenLookupSelfResponse, OpenBaoTokenManager, OpenBaoUserpassAuth, OpenBaoUserpassAuthConfig, OptionalPageQuery, OrderQueryType, PageQuery, ParseUUIDv7Pipe, PartialType, PendingException, PickType, PreviousCursorPageSchema, PrimaryKeyType, PrimaryKeyTypeClassMetadataPropertyKey, Property, PropertyKind, PropertyMetadata, RateLimitException, type ReencryptCommand, RefAssociationMetadata, type ResolveExceptions, ResourceUrn, ResponseBodyType, SaltedHash, SaltedHashHasher, SaltedHashModule, SaltedHashService, SaltedHashV1Hasher, ScalarClass, ScalarPropertyMetadata, type SchemaObject, Slice, SwaggerPatcher, SystemException, ThirdPartyException, TimestampedEntity, type UnifyExceptionResponsesOptions, Urn, VALIDATE_NESTED_DICTIONARY, ValidateNestedDictionary, ValidationException, getExceptionModuleId, getFilterQueryOperators, isScalarClass, serializeModel, setOpenBaoToken, stableStringify };
|
|
18655
|
+
export { AssociationMetadata, AuthException, BUKA_MODULE_OPTIONS_TOKEN, Base32, BlindIndex, BlindIndexHasher, BlindIndexModule, BlindIndexService, BlindIndexV1Hasher, BukaConfigurableModuleClass, BukaExceptions, BukaModule, BukaModuleOptions, BukaPageQueryValidationPipe, BukaValidationPipe, BusinessException, Cardinality, type CipherMetadata, CollectionAssociationMetadata, Column, Composite, CompositePropertyMetadata, ConfigurableModuleClass, ConflictException, CursorPagination, DatabaseConfig, type DecryptCommand, DegradeException, Dictionary, DictionaryPropertyMetadata, DiscreteEntity, EagerType, type EncryptCommand, EncryptedPayload, EntityRef, Enum, EnumPropertyMetadata, EnvelopeEncryptionModule, type EnvelopeEncryptionModuleOptions, EnvelopeEncryptionService, ErrorCategory, ErrorCode, ErrorCodeController, ErrorCodeExceptionFilter, ErrorCodeDefinitionDto as ErrorCodeItemDto, ErrorCodeMetadataDto, type ErrorCodeOptions, ErrorCodePartsDto, ErrorCodeRegistry, ErrorResponseSchema, type ExceptionConstructor, type ExceptionConstructorWithArgs, type ExceptionDetail, ExceptionDetailSchema, ExceptionModule, type ExceptionModuleOptions as ExceptionNestModuleOptions, type ExceptionOptions, type ExceptionOptionsWithFactory, type ExceptionOptionsWithMessage, ExcludeDefinedOpt, ExcludeHidden, ExcludeOpt, ExcludeRef, ExcludeScalarClass, FeatureException, FilterQuery, FilterQueryOperator, FilterQueryOperators, FilterQueryOperatorsMetadataKey, FilterQueryTransformPipe, HAS_ANY_KEY, HasAnyKey, HttpException, type HttpExceptionOptions, IEntityPrimaryKey, IFilter, IFilterQuery, IFilterQueryCollectionCondition, IFilterQueryCondition, IFilterQueryNestedProperty, IFilterQueryObject, IFilterQueryProperty, IListResponseBody, IListResponseBodyMeta, INextCursorPageParameters, IOffsetPageParameters, IOrderQuery, IPageQuery, IPreviousCursorPageParameters, IResponseBody, IS_CROCKFORD_BASE32, IS_IDENTIFIER_URN, IS_NAMESPACE_URN, IS_RESOURCE_URN, IS_SCALAR_DICTIONARY, IS_URN, IdentifierUrn, InjectLogger, IsBrowserRequest, IsCrockfordBase32, IsHidden, IsIdentifierUrn, IsNamespaceUrn, IsOpt, IsResourceUrn, IsScalar, IsScalarDictionary, IsUrn, KeyEnvelope, LinearEntity, List, ListErrorCodesResponseDto, ListPropertyMetadata, ListResponseBodyType, Logger, LoggerConfig, LoggerErrorInterceptor, LoggerModule, type LoggerModuleOptions, MATCH_JSON_SCHEMA, MODULE_OPTIONS_TOKEN, MatchJsonSchema, Model, ModelMetadata, ModelOptions, ModelRegister, ModelSchemaOptions, ModuleExceptions, type ExceptionModuleOptions$1 as ModuleExceptionsOptions, NamespaceUrn, NextCursorPageSchema, ObjectStorageModule, ObjectStorageModuleConfig, ObjectStorageModuleOptions, ObjectStorageOptions, ObjectStorageService, OffsetPageSchema, OffsetPagination, OmitType, OpenBaoAppRoleAuth, OpenBaoAppRoleAuthConfig, OpenBaoAuthMethod, OpenBaoAuthResponse, OpenBaoHttpClient, OpenBaoKubernetesAuth, OpenBaoKubernetesAuthConfig, OpenBaoModule, OpenBaoModuleConfig, OpenBaoModuleOptions, OpenBaoTokenAuth, OpenBaoTokenAuthConfig, OpenBaoTokenLookupSelfResponse, OpenBaoTokenManager, OpenBaoUserpassAuth, OpenBaoUserpassAuthConfig, OptionalPageQuery, OrderQueryType, PageQuery, ParseUUIDv7Pipe, PartialType, PendingException, PickType, PreviousCursorPageSchema, PrimaryKeyType, PrimaryKeyTypeClassMetadataPropertyKey, Property, PropertyKind, PropertyMetadata, RateLimitException, type ReencryptCommand, RefAssociationMetadata, type ResolveExceptions, ResourceUrn, ResponseBodyType, SaltedHash, SaltedHashHasher, SaltedHashModule, SaltedHashService, SaltedHashV1Hasher, ScalarClass, ScalarPropertyMetadata, type SchemaObject, Slice, SwaggerPatcher, SystemException, ThirdPartyException, TimestampedEntity, type UnifyExceptionResponsesOptions, Urn, VALIDATE_NESTED_DICTIONARY, ValidateNestedDictionary, ValidationException, getExceptionModuleId, getFilterQueryOperators, isScalarClass, serializeModel, setOpenBaoToken, stableStringify };
|
|
18582
18656
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { AnyEntity, Config, Cursor, DefineConfig, EmbeddedOptions, EntityManager
|
|
|
8
8
|
import { Keq, KeqMiddleware, KeqOperation, KeqPathParameterInit, KeqQueryInit, KeqRequest } from "keq";
|
|
9
9
|
import { Base32, ErrorCategory, ErrorCategory as ErrorCategory$1, ErrorCode, ErrorCodeOptions } from "@buka/error-codes";
|
|
10
10
|
import { Exception, ExceptionDetail, ExceptionDetail as ExceptionDetail$1, ExceptionOptions as ExceptionOptions$1 } from "@buka/exception";
|
|
11
|
+
import { Logger, LoggerErrorInterceptor } from "nestjs-pino";
|
|
11
12
|
import { Readable } from "node:stream";
|
|
12
13
|
|
|
13
14
|
//#region src/swagger-patcher/deep-objectify-queries.d.ts
|
|
@@ -18451,6 +18452,79 @@ declare class EnvelopeEncryptionService {
|
|
|
18451
18452
|
listCiphers(): CipherMetadata[];
|
|
18452
18453
|
}
|
|
18453
18454
|
//#endregion
|
|
18455
|
+
//#region src/modules/logger/types/logger-module-options.d.ts
|
|
18456
|
+
/**
|
|
18457
|
+
* LoggerModule 配置
|
|
18458
|
+
*
|
|
18459
|
+
* 与 LoggerConfig 基类字段一一对应
|
|
18460
|
+
*/
|
|
18461
|
+
interface LoggerModuleOptions {
|
|
18462
|
+
/** 服务名称,Grafana/Loki 中按服务过滤日志 */
|
|
18463
|
+
serviceName?: string;
|
|
18464
|
+
/** 运行环境,默认取 NODE_ENV */
|
|
18465
|
+
environment?: string;
|
|
18466
|
+
/** 服务版本号,生产环境由 CI/CD 注入 */
|
|
18467
|
+
version?: string;
|
|
18468
|
+
/** 日志级别,默认 info */
|
|
18469
|
+
level?: 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace';
|
|
18470
|
+
/** 开发模式——启用 pino-pretty 彩色输出 */
|
|
18471
|
+
pretty?: boolean;
|
|
18472
|
+
}
|
|
18473
|
+
//#endregion
|
|
18474
|
+
//#region src/modules/logger/logger.module.d.ts
|
|
18475
|
+
/**
|
|
18476
|
+
* 统一日志模块
|
|
18477
|
+
*
|
|
18478
|
+
* 基于 nestjs-pino,预配置 Grafana/Loki 友好的 JSON 日志格式。
|
|
18479
|
+
*
|
|
18480
|
+
* @example
|
|
18481
|
+
* // 直接使用
|
|
18482
|
+
* LoggerModule.register({ serviceName: 'my-service' })
|
|
18483
|
+
*
|
|
18484
|
+
* // 配合 @buka/nestjs-config
|
|
18485
|
+
* ConfigModule.inject(PinoConfig, LoggerModule, (config) => ({...config}))
|
|
18486
|
+
*/
|
|
18487
|
+
declare class LoggerModule {
|
|
18488
|
+
static register(options?: LoggerModuleOptions): DynamicModule;
|
|
18489
|
+
static registerAsync(options: {
|
|
18490
|
+
imports?: any[];
|
|
18491
|
+
inject?: any[];
|
|
18492
|
+
useFactory: (...args: any[]) => LoggerModuleOptions | Promise<LoggerModuleOptions>;
|
|
18493
|
+
}): DynamicModule;
|
|
18494
|
+
/**
|
|
18495
|
+
* 将 LoggerModuleOptions 转换为 nestjs-pino 的 Params
|
|
18496
|
+
*/
|
|
18497
|
+
private static buildParams;
|
|
18498
|
+
}
|
|
18499
|
+
//#endregion
|
|
18500
|
+
//#region src/modules/logger/decorators/inject-logger.decorator.d.ts
|
|
18501
|
+
/**
|
|
18502
|
+
* 注入 Logger,自动以类名为日志上下文
|
|
18503
|
+
*
|
|
18504
|
+
* 用法:
|
|
18505
|
+
* @InjectLogger()
|
|
18506
|
+
* private readonly logger: Logger
|
|
18507
|
+
*
|
|
18508
|
+
* 等价于:
|
|
18509
|
+
* @InjectPinoLogger(MyService.name)
|
|
18510
|
+
* private readonly logger: Logger
|
|
18511
|
+
*/
|
|
18512
|
+
declare function InjectLogger(context?: string): ParameterDecorator;
|
|
18513
|
+
//#endregion
|
|
18514
|
+
//#region src/modules/logger/logger.config.d.ts
|
|
18515
|
+
/**
|
|
18516
|
+
* 日志配置基类
|
|
18517
|
+
*
|
|
18518
|
+
* 项目中的日志配置应继承此类并通过 @Configuration('xxx') 绑定环境变量前缀
|
|
18519
|
+
*/
|
|
18520
|
+
declare class LoggerConfig {
|
|
18521
|
+
pretty: boolean;
|
|
18522
|
+
level: 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace';
|
|
18523
|
+
serviceName: string;
|
|
18524
|
+
environment: string;
|
|
18525
|
+
version: string;
|
|
18526
|
+
}
|
|
18527
|
+
//#endregion
|
|
18454
18528
|
//#region src/modules/object-storage/types/options.d.ts
|
|
18455
18529
|
interface ObjectStorageOptions {
|
|
18456
18530
|
prefix?: boolean;
|
|
@@ -18578,5 +18652,5 @@ declare class ObjectStorageService implements OnModuleInit {
|
|
|
18578
18652
|
*/
|
|
18579
18653
|
declare function stableStringify(value: unknown): string;
|
|
18580
18654
|
//#endregion
|
|
18581
|
-
export { AssociationMetadata, AuthException, BUKA_MODULE_OPTIONS_TOKEN, Base32, BlindIndex, BlindIndexHasher, BlindIndexModule, BlindIndexService, BlindIndexV1Hasher, BukaConfigurableModuleClass, BukaExceptions, BukaModule, BukaModuleOptions, BukaPageQueryValidationPipe, BukaValidationPipe, BusinessException, Cardinality, type CipherMetadata, CollectionAssociationMetadata, Column, Composite, CompositePropertyMetadata, ConfigurableModuleClass, ConflictException, CursorPagination, DatabaseConfig, type DecryptCommand, DegradeException, Dictionary, DictionaryPropertyMetadata, DiscreteEntity, EagerType, type EncryptCommand, EncryptedPayload, EntityRef, Enum, EnumPropertyMetadata, EnvelopeEncryptionModule, type EnvelopeEncryptionModuleOptions, EnvelopeEncryptionService, ErrorCategory, ErrorCode, ErrorCodeController, ErrorCodeExceptionFilter, ErrorCodeDefinitionDto as ErrorCodeItemDto, ErrorCodeMetadataDto, type ErrorCodeOptions, ErrorCodePartsDto, ErrorCodeRegistry, ErrorResponseSchema, type ExceptionConstructor, type ExceptionConstructorWithArgs, type ExceptionDetail, ExceptionDetailSchema, ExceptionModule, type ExceptionModuleOptions as ExceptionNestModuleOptions, type ExceptionOptions, type ExceptionOptionsWithFactory, type ExceptionOptionsWithMessage, ExcludeDefinedOpt, ExcludeHidden, ExcludeOpt, ExcludeRef, ExcludeScalarClass, FeatureException, FilterQuery, FilterQueryOperator, FilterQueryOperators, FilterQueryOperatorsMetadataKey, FilterQueryTransformPipe, HAS_ANY_KEY, HasAnyKey, HttpException, type HttpExceptionOptions, IEntityPrimaryKey, IFilter, IFilterQuery, IFilterQueryCollectionCondition, IFilterQueryCondition, IFilterQueryNestedProperty, IFilterQueryObject, IFilterQueryProperty, IListResponseBody, IListResponseBodyMeta, INextCursorPageParameters, IOffsetPageParameters, IOrderQuery, IPageQuery, IPreviousCursorPageParameters, IResponseBody, IS_CROCKFORD_BASE32, IS_IDENTIFIER_URN, IS_NAMESPACE_URN, IS_RESOURCE_URN, IS_SCALAR_DICTIONARY, IS_URN, IdentifierUrn, IsBrowserRequest, IsCrockfordBase32, IsHidden, IsIdentifierUrn, IsNamespaceUrn, IsOpt, IsResourceUrn, IsScalar, IsScalarDictionary, IsUrn, KeyEnvelope, LinearEntity, List, ListErrorCodesResponseDto, ListPropertyMetadata, ListResponseBodyType, MATCH_JSON_SCHEMA, MODULE_OPTIONS_TOKEN, MatchJsonSchema, Model, ModelMetadata, ModelOptions, ModelRegister, ModelSchemaOptions, ModuleExceptions, type ExceptionModuleOptions$1 as ModuleExceptionsOptions, NamespaceUrn, NextCursorPageSchema, ObjectStorageModule, ObjectStorageModuleConfig, ObjectStorageModuleOptions, ObjectStorageOptions, ObjectStorageService, OffsetPageSchema, OffsetPagination, OmitType, OpenBaoAppRoleAuth, OpenBaoAppRoleAuthConfig, OpenBaoAuthMethod, OpenBaoAuthResponse, OpenBaoHttpClient, OpenBaoKubernetesAuth, OpenBaoKubernetesAuthConfig, OpenBaoModule, OpenBaoModuleConfig, OpenBaoModuleOptions, OpenBaoTokenAuth, OpenBaoTokenAuthConfig, OpenBaoTokenLookupSelfResponse, OpenBaoTokenManager, OpenBaoUserpassAuth, OpenBaoUserpassAuthConfig, OptionalPageQuery, OrderQueryType, PageQuery, ParseUUIDv7Pipe, PartialType, PendingException, PickType, PreviousCursorPageSchema, PrimaryKeyType, PrimaryKeyTypeClassMetadataPropertyKey, Property, PropertyKind, PropertyMetadata, RateLimitException, type ReencryptCommand, RefAssociationMetadata, type ResolveExceptions, ResourceUrn, ResponseBodyType, SaltedHash, SaltedHashHasher, SaltedHashModule, SaltedHashService, SaltedHashV1Hasher, ScalarClass, ScalarPropertyMetadata, type SchemaObject, Slice, SwaggerPatcher, SystemException, ThirdPartyException, TimestampedEntity, type UnifyExceptionResponsesOptions, Urn, VALIDATE_NESTED_DICTIONARY, ValidateNestedDictionary, ValidationException, getExceptionModuleId, getFilterQueryOperators, isScalarClass, serializeModel, setOpenBaoToken, stableStringify };
|
|
18655
|
+
export { AssociationMetadata, AuthException, BUKA_MODULE_OPTIONS_TOKEN, Base32, BlindIndex, BlindIndexHasher, BlindIndexModule, BlindIndexService, BlindIndexV1Hasher, BukaConfigurableModuleClass, BukaExceptions, BukaModule, BukaModuleOptions, BukaPageQueryValidationPipe, BukaValidationPipe, BusinessException, Cardinality, type CipherMetadata, CollectionAssociationMetadata, Column, Composite, CompositePropertyMetadata, ConfigurableModuleClass, ConflictException, CursorPagination, DatabaseConfig, type DecryptCommand, DegradeException, Dictionary, DictionaryPropertyMetadata, DiscreteEntity, EagerType, type EncryptCommand, EncryptedPayload, EntityRef, Enum, EnumPropertyMetadata, EnvelopeEncryptionModule, type EnvelopeEncryptionModuleOptions, EnvelopeEncryptionService, ErrorCategory, ErrorCode, ErrorCodeController, ErrorCodeExceptionFilter, ErrorCodeDefinitionDto as ErrorCodeItemDto, ErrorCodeMetadataDto, type ErrorCodeOptions, ErrorCodePartsDto, ErrorCodeRegistry, ErrorResponseSchema, type ExceptionConstructor, type ExceptionConstructorWithArgs, type ExceptionDetail, ExceptionDetailSchema, ExceptionModule, type ExceptionModuleOptions as ExceptionNestModuleOptions, type ExceptionOptions, type ExceptionOptionsWithFactory, type ExceptionOptionsWithMessage, ExcludeDefinedOpt, ExcludeHidden, ExcludeOpt, ExcludeRef, ExcludeScalarClass, FeatureException, FilterQuery, FilterQueryOperator, FilterQueryOperators, FilterQueryOperatorsMetadataKey, FilterQueryTransformPipe, HAS_ANY_KEY, HasAnyKey, HttpException, type HttpExceptionOptions, IEntityPrimaryKey, IFilter, IFilterQuery, IFilterQueryCollectionCondition, IFilterQueryCondition, IFilterQueryNestedProperty, IFilterQueryObject, IFilterQueryProperty, IListResponseBody, IListResponseBodyMeta, INextCursorPageParameters, IOffsetPageParameters, IOrderQuery, IPageQuery, IPreviousCursorPageParameters, IResponseBody, IS_CROCKFORD_BASE32, IS_IDENTIFIER_URN, IS_NAMESPACE_URN, IS_RESOURCE_URN, IS_SCALAR_DICTIONARY, IS_URN, IdentifierUrn, InjectLogger, IsBrowserRequest, IsCrockfordBase32, IsHidden, IsIdentifierUrn, IsNamespaceUrn, IsOpt, IsResourceUrn, IsScalar, IsScalarDictionary, IsUrn, KeyEnvelope, LinearEntity, List, ListErrorCodesResponseDto, ListPropertyMetadata, ListResponseBodyType, Logger, LoggerConfig, LoggerErrorInterceptor, LoggerModule, type LoggerModuleOptions, MATCH_JSON_SCHEMA, MODULE_OPTIONS_TOKEN, MatchJsonSchema, Model, ModelMetadata, ModelOptions, ModelRegister, ModelSchemaOptions, ModuleExceptions, type ExceptionModuleOptions$1 as ModuleExceptionsOptions, NamespaceUrn, NextCursorPageSchema, ObjectStorageModule, ObjectStorageModuleConfig, ObjectStorageModuleOptions, ObjectStorageOptions, ObjectStorageService, OffsetPageSchema, OffsetPagination, OmitType, OpenBaoAppRoleAuth, OpenBaoAppRoleAuthConfig, OpenBaoAuthMethod, OpenBaoAuthResponse, OpenBaoHttpClient, OpenBaoKubernetesAuth, OpenBaoKubernetesAuthConfig, OpenBaoModule, OpenBaoModuleConfig, OpenBaoModuleOptions, OpenBaoTokenAuth, OpenBaoTokenAuthConfig, OpenBaoTokenLookupSelfResponse, OpenBaoTokenManager, OpenBaoUserpassAuth, OpenBaoUserpassAuthConfig, OptionalPageQuery, OrderQueryType, PageQuery, ParseUUIDv7Pipe, PartialType, PendingException, PickType, PreviousCursorPageSchema, PrimaryKeyType, PrimaryKeyTypeClassMetadataPropertyKey, Property, PropertyKind, PropertyMetadata, RateLimitException, type ReencryptCommand, RefAssociationMetadata, type ResolveExceptions, ResourceUrn, ResponseBodyType, SaltedHash, SaltedHashHasher, SaltedHashModule, SaltedHashService, SaltedHashV1Hasher, ScalarClass, ScalarPropertyMetadata, type SchemaObject, Slice, SwaggerPatcher, SystemException, ThirdPartyException, TimestampedEntity, type UnifyExceptionResponsesOptions, Urn, VALIDATE_NESTED_DICTIONARY, ValidateNestedDictionary, ValidationException, getExceptionModuleId, getFilterQueryOperators, isScalarClass, serializeModel, setOpenBaoToken, stableStringify };
|
|
18582
18656
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -51,11 +51,13 @@ node_fs = __toESM(node_fs);
|
|
|
51
51
|
let keq = require("keq");
|
|
52
52
|
let _keq_request_url = require("@keq-request/url");
|
|
53
53
|
let _keq_request_exception = require("@keq-request/exception");
|
|
54
|
-
let crypto = require("crypto");
|
|
54
|
+
let crypto$1 = require("crypto");
|
|
55
55
|
let bcryptjs = require("bcryptjs");
|
|
56
56
|
bcryptjs = __toESM(bcryptjs);
|
|
57
57
|
let _buka_error_codes = require("@buka/error-codes");
|
|
58
58
|
let _buka_exception = require("@buka/exception");
|
|
59
|
+
let nestjs_pino = require("nestjs-pino");
|
|
60
|
+
let pino = require("pino");
|
|
59
61
|
let _aws_sdk_client_s3 = require("@aws-sdk/client-s3");
|
|
60
62
|
let _aws_sdk_s3_request_presigner = require("@aws-sdk/s3-request-presigner");
|
|
61
63
|
let _aws_sdk_lib_storage = require("@aws-sdk/lib-storage");
|
|
@@ -506,7 +508,7 @@ function IsUrn(validationOptions) {
|
|
|
506
508
|
}
|
|
507
509
|
},
|
|
508
510
|
defaultMessage() {
|
|
509
|
-
return "$property must be a valid URN (urn:buka
|
|
511
|
+
return "$property must be a valid URN (urn:buka:<namespace>[:<resource>[:<identifier>]])";
|
|
510
512
|
}
|
|
511
513
|
}
|
|
512
514
|
});
|
|
@@ -540,7 +542,7 @@ function IsNamespaceUrn(validationOptions) {
|
|
|
540
542
|
}
|
|
541
543
|
},
|
|
542
544
|
defaultMessage() {
|
|
543
|
-
return "$property must be a namespace-level URN (urn:buka
|
|
545
|
+
return "$property must be a namespace-level URN (urn:buka:<namespace>)";
|
|
544
546
|
}
|
|
545
547
|
}
|
|
546
548
|
});
|
|
@@ -574,7 +576,7 @@ function IsResourceUrn(validationOptions) {
|
|
|
574
576
|
}
|
|
575
577
|
},
|
|
576
578
|
defaultMessage() {
|
|
577
|
-
return "$property must be a resource-level URN (urn:buka
|
|
579
|
+
return "$property must be a resource-level URN (urn:buka:<namespace>:<resource>)";
|
|
578
580
|
}
|
|
579
581
|
}
|
|
580
582
|
});
|
|
@@ -608,7 +610,7 @@ function IsIdentifierUrn(validationOptions) {
|
|
|
608
610
|
}
|
|
609
611
|
},
|
|
610
612
|
defaultMessage() {
|
|
611
|
-
return "$property must be an identifier-level URN (urn:buka
|
|
613
|
+
return "$property must be an identifier-level URN (urn:buka:<namespace>:<resource>:<identifier>)";
|
|
612
614
|
}
|
|
613
615
|
}
|
|
614
616
|
});
|
|
@@ -8248,7 +8250,7 @@ let BlindIndexV1Hasher = class BlindIndexV1Hasher {
|
|
|
8248
8250
|
if (data === null || data === void 0) throw new TypeError("Cannot hash null or undefined data");
|
|
8249
8251
|
const jsonString = stableStringify(data);
|
|
8250
8252
|
return {
|
|
8251
|
-
value: (0, crypto.createHash)("sha256").update(jsonString, "utf8").digest("hex"),
|
|
8253
|
+
value: (0, crypto$1.createHash)("sha256").update(jsonString, "utf8").digest("hex"),
|
|
8252
8254
|
version: 1
|
|
8253
8255
|
};
|
|
8254
8256
|
}
|
|
@@ -9453,8 +9455,8 @@ let EnvelopeEncryptionV1Cipher = _EnvelopeEncryptionV1Cipher = class EnvelopeEnc
|
|
|
9453
9455
|
}
|
|
9454
9456
|
async encrypt(cmd) {
|
|
9455
9457
|
const { dek, encryptedDek, kekVersion } = await this.kmsProvider.generateDek(cmd.kekId, "aes256-gcm96");
|
|
9456
|
-
const cipherIv = (0, crypto.randomBytes)(12);
|
|
9457
|
-
const cipher = (0, crypto.createCipheriv)(this.algorithm, dek, cipherIv, { authTagLength: 16 });
|
|
9458
|
+
const cipherIv = (0, crypto$1.randomBytes)(12);
|
|
9459
|
+
const cipher = (0, crypto$1.createCipheriv)(this.algorithm, dek, cipherIv, { authTagLength: 16 });
|
|
9458
9460
|
const aad = this.buildAad(cmd.kekId, cmd.extraAad);
|
|
9459
9461
|
cipher.setAAD(aad);
|
|
9460
9462
|
const cipherBlob = Buffer.concat([cipher.update(cmd.plaintext), cipher.final()]);
|
|
@@ -9474,7 +9476,7 @@ let EnvelopeEncryptionV1Cipher = _EnvelopeEncryptionV1Cipher = class EnvelopeEnc
|
|
|
9474
9476
|
async decrypt(cmd) {
|
|
9475
9477
|
if (cmd.payload.cipherVersion !== this.version) throw new Error(`Cipher version mismatch: expected ${this.version}, got ${cmd.payload.cipherVersion}`);
|
|
9476
9478
|
const dek = await this.kmsProvider.decryptDek(cmd.envelope.kekId, cmd.envelope.kekVersion, cmd.envelope.dek);
|
|
9477
|
-
const decipher = (0, crypto.createDecipheriv)(this.algorithm, dek, cmd.payload.cipherIv, { authTagLength: 16 });
|
|
9479
|
+
const decipher = (0, crypto$1.createDecipheriv)(this.algorithm, dek, cmd.payload.cipherIv, { authTagLength: 16 });
|
|
9478
9480
|
const aad = this.buildAad(cmd.envelope.kekId, cmd.extraAad);
|
|
9479
9481
|
decipher.setAAD(aad);
|
|
9480
9482
|
decipher.setAuthTag(cmd.payload.cipherTag);
|
|
@@ -9579,6 +9581,109 @@ EnvelopeEncryptionModule = __decorate([(0, _nestjs_common.Global)(), (0, _nestjs
|
|
|
9579
9581
|
exports: [EnvelopeEncryptionService]
|
|
9580
9582
|
})], EnvelopeEncryptionModule);
|
|
9581
9583
|
//#endregion
|
|
9584
|
+
//#region src/modules/logger/logger.module.ts
|
|
9585
|
+
var _LoggerModule;
|
|
9586
|
+
let LoggerModule = _LoggerModule = class LoggerModule {
|
|
9587
|
+
static register(options = {}) {
|
|
9588
|
+
return {
|
|
9589
|
+
module: _LoggerModule,
|
|
9590
|
+
imports: [nestjs_pino.LoggerModule.forRoot(this.buildParams(options))],
|
|
9591
|
+
providers: [nestjs_pino.LoggerErrorInterceptor],
|
|
9592
|
+
exports: [nestjs_pino.LoggerModule, nestjs_pino.LoggerErrorInterceptor]
|
|
9593
|
+
};
|
|
9594
|
+
}
|
|
9595
|
+
static registerAsync(options) {
|
|
9596
|
+
return {
|
|
9597
|
+
module: _LoggerModule,
|
|
9598
|
+
imports: [...options.imports || [], nestjs_pino.LoggerModule.forRootAsync({
|
|
9599
|
+
imports: options.imports || [],
|
|
9600
|
+
inject: options.inject || [],
|
|
9601
|
+
useFactory: async (...args) => {
|
|
9602
|
+
const opts = await options.useFactory(...args);
|
|
9603
|
+
return _LoggerModule.buildParams(opts);
|
|
9604
|
+
}
|
|
9605
|
+
})],
|
|
9606
|
+
providers: [nestjs_pino.LoggerErrorInterceptor],
|
|
9607
|
+
exports: [nestjs_pino.LoggerModule, nestjs_pino.LoggerErrorInterceptor]
|
|
9608
|
+
};
|
|
9609
|
+
}
|
|
9610
|
+
/**
|
|
9611
|
+
* 将 LoggerModuleOptions 转换为 nestjs-pino 的 Params
|
|
9612
|
+
*/
|
|
9613
|
+
static buildParams(options) {
|
|
9614
|
+
const { serviceName = "unknown", environment = process.env.NODE_ENV || "development", version = "0.0.0", level = "info", pretty = false } = options;
|
|
9615
|
+
return { pinoHttp: {
|
|
9616
|
+
...pretty ? { transport: { target: "pino-pretty" } } : {},
|
|
9617
|
+
level,
|
|
9618
|
+
genReqId: (req) => req.headers["x-request-id"] || crypto.randomUUID(),
|
|
9619
|
+
autoLogging: { ignore: (req) => req.url?.startsWith("/api/v1/health") ?? false },
|
|
9620
|
+
customAttributeKeys: {
|
|
9621
|
+
reqId: "reqId",
|
|
9622
|
+
responseTime: "responseTime"
|
|
9623
|
+
},
|
|
9624
|
+
serializers: {
|
|
9625
|
+
req: (req) => ({
|
|
9626
|
+
method: req.method,
|
|
9627
|
+
url: req.url
|
|
9628
|
+
}),
|
|
9629
|
+
res: (res) => ({ statusCode: res.statusCode }),
|
|
9630
|
+
err: pino.stdSerializers.err
|
|
9631
|
+
},
|
|
9632
|
+
formatters: {
|
|
9633
|
+
level: (label) => ({ level: label }),
|
|
9634
|
+
bindings: (bindings) => ({
|
|
9635
|
+
...bindings,
|
|
9636
|
+
service: serviceName,
|
|
9637
|
+
environment,
|
|
9638
|
+
version
|
|
9639
|
+
})
|
|
9640
|
+
}
|
|
9641
|
+
} };
|
|
9642
|
+
}
|
|
9643
|
+
};
|
|
9644
|
+
LoggerModule = _LoggerModule = __decorate([(0, _nestjs_common.Global)(), (0, _nestjs_common.Module)({})], LoggerModule);
|
|
9645
|
+
//#endregion
|
|
9646
|
+
//#region src/modules/logger/decorators/inject-logger.decorator.ts
|
|
9647
|
+
/**
|
|
9648
|
+
* 注入 Logger,自动以类名为日志上下文
|
|
9649
|
+
*
|
|
9650
|
+
* 用法:
|
|
9651
|
+
* @InjectLogger()
|
|
9652
|
+
* private readonly logger: Logger
|
|
9653
|
+
*
|
|
9654
|
+
* 等价于:
|
|
9655
|
+
* @InjectPinoLogger(MyService.name)
|
|
9656
|
+
* private readonly logger: Logger
|
|
9657
|
+
*/
|
|
9658
|
+
function InjectLogger(context) {
|
|
9659
|
+
return (target, propertyKey, parameterIndex) => {
|
|
9660
|
+
(0, nestjs_pino.InjectPinoLogger)(context || target.constructor.name)(target, propertyKey, parameterIndex);
|
|
9661
|
+
};
|
|
9662
|
+
}
|
|
9663
|
+
//#endregion
|
|
9664
|
+
//#region src/modules/logger/logger.config.ts
|
|
9665
|
+
/**
|
|
9666
|
+
* 日志配置基类
|
|
9667
|
+
*
|
|
9668
|
+
* 项目中的日志配置应继承此类并通过 @Configuration('xxx') 绑定环境变量前缀
|
|
9669
|
+
*/
|
|
9670
|
+
var LoggerConfig = class {
|
|
9671
|
+
pretty = false;
|
|
9672
|
+
level = "info";
|
|
9673
|
+
serviceName = "unknown";
|
|
9674
|
+
environment = process.env.NODE_ENV || "development";
|
|
9675
|
+
version = process.env.npm_package_version || "0.0.0";
|
|
9676
|
+
};
|
|
9677
|
+
__decorate([(0, _buka_class_transformer_extra.ToBoolean)(), __decorateMetadata("design:type", Boolean)], LoggerConfig.prototype, "pretty", void 0);
|
|
9678
|
+
__decorate([(0, class_validator.IsIn)([
|
|
9679
|
+
"fatal",
|
|
9680
|
+
"error",
|
|
9681
|
+
"warn",
|
|
9682
|
+
"info",
|
|
9683
|
+
"debug",
|
|
9684
|
+
"trace"
|
|
9685
|
+
]), __decorateMetadata("design:type", String)], LoggerConfig.prototype, "level", void 0);
|
|
9686
|
+
//#endregion
|
|
9582
9687
|
//#region src/modules/object-storage/object-storage.config.ts
|
|
9583
9688
|
var ObjectStorageModuleConfig = class {
|
|
9584
9689
|
endpoint;
|
|
@@ -9896,6 +10001,7 @@ exports.IS_NAMESPACE_URN = IS_NAMESPACE_URN;
|
|
|
9896
10001
|
exports.IS_RESOURCE_URN = IS_RESOURCE_URN;
|
|
9897
10002
|
exports.IS_SCALAR_DICTIONARY = IS_SCALAR_DICTIONARY;
|
|
9898
10003
|
exports.IS_URN = IS_URN;
|
|
10004
|
+
exports.InjectLogger = InjectLogger;
|
|
9899
10005
|
exports.IsBrowserRequest = IsBrowserRequest;
|
|
9900
10006
|
exports.IsCrockfordBase32 = IsCrockfordBase32;
|
|
9901
10007
|
exports.IsIdentifierUrn = IsIdentifierUrn;
|
|
@@ -9914,6 +10020,25 @@ exports.LinearEntity = LinearEntity;
|
|
|
9914
10020
|
exports.List = List;
|
|
9915
10021
|
exports.ListErrorCodesResponseDto = ListErrorCodesResponseDto;
|
|
9916
10022
|
exports.ListResponseBodyType = ListResponseBodyType;
|
|
10023
|
+
Object.defineProperty(exports, "Logger", {
|
|
10024
|
+
enumerable: true,
|
|
10025
|
+
get: function() {
|
|
10026
|
+
return nestjs_pino.Logger;
|
|
10027
|
+
}
|
|
10028
|
+
});
|
|
10029
|
+
exports.LoggerConfig = LoggerConfig;
|
|
10030
|
+
Object.defineProperty(exports, "LoggerErrorInterceptor", {
|
|
10031
|
+
enumerable: true,
|
|
10032
|
+
get: function() {
|
|
10033
|
+
return nestjs_pino.LoggerErrorInterceptor;
|
|
10034
|
+
}
|
|
10035
|
+
});
|
|
10036
|
+
Object.defineProperty(exports, "LoggerModule", {
|
|
10037
|
+
enumerable: true,
|
|
10038
|
+
get: function() {
|
|
10039
|
+
return LoggerModule;
|
|
10040
|
+
}
|
|
10041
|
+
});
|
|
9917
10042
|
exports.MATCH_JSON_SCHEMA = MATCH_JSON_SCHEMA;
|
|
9918
10043
|
exports.MODULE_OPTIONS_TOKEN = MODULE_OPTIONS_TOKEN;
|
|
9919
10044
|
exports.MatchJsonSchema = MatchJsonSchema;
|