@buka/nestjs-kit 4.1.5 → 4.1.7

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.1.7](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.1.6...v4.1.7) (2026-05-23)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * 修复预热dek和openbao初始化鉴权冲突的问题 ([4e75b91](https://github.com/buka-ltd/npm.nestjs-kit/commit/4e75b914cfa8d2a503b277215fb88ef0eaef136f))
9
+
10
+ ## [4.1.6](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.1.5...v4.1.6) (2026-05-23)
11
+
12
+
13
+ ### Performance Improvements
14
+
15
+ * 控制数据库连接数 ([55ea1ed](https://github.com/buka-ltd/npm.nestjs-kit/commit/55ea1ed660e5c948d6591d6c7605b525e399b5a5))
16
+
3
17
  ## [4.1.5](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.1.4...v4.1.5) (2026-05-23)
4
18
 
5
19
 
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _$_nestjs_common0 from "@nestjs/common";
2
- import { ArgumentMetadata, ArgumentsHost, DynamicModule, ExceptionFilter, HttpStatus, OnModuleDestroy, OnModuleInit, PipeTransform, Type, ValidationPipe, ValidationPipeOptions } from "@nestjs/common";
2
+ import { ArgumentMetadata, ArgumentsHost, DynamicModule, ExceptionFilter, HttpStatus, OnApplicationBootstrap, OnModuleDestroy, OnModuleInit, PipeTransform, Type, ValidationPipe, ValidationPipeOptions } from "@nestjs/common";
3
3
  import { AnyEntity, 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";
4
4
  import { ValidationOptions } from "class-validator";
5
5
  import { ApiPropertyOptions, OpenAPIObject } from "@nestjs/swagger";
@@ -1860,6 +1860,9 @@ declare class DatabaseConfig {
1860
1860
  user: string;
1861
1861
  password: string;
1862
1862
  timezone?: string | undefined;
1863
+ poolMax: number;
1864
+ poolMin: number;
1865
+ poolIdleTimeoutMillis: number;
1863
1866
  toMikroOrmOptions(config?: Partial<Options>): Partial<Options>;
1864
1867
  }
1865
1868
  //#endregion
@@ -18344,7 +18347,7 @@ interface GeneratedDek {
18344
18347
  encryptedDek: Buffer;
18345
18348
  kekVersion: number;
18346
18349
  }
18347
- declare class KmsProvider implements OnModuleInit, OnModuleDestroy {
18350
+ declare class KmsProvider implements OnApplicationBootstrap, OnModuleDestroy {
18348
18351
  private readonly openbao;
18349
18352
  private readonly options;
18350
18353
  private readonly logger;
@@ -18354,7 +18357,7 @@ declare class KmsProvider implements OnModuleInit, OnModuleDestroy {
18354
18357
  private dekDecryptingPromises;
18355
18358
  private dekCacheCleanupTimer;
18356
18359
  constructor(openbao: OpenBaoHttpClient, options: EnvelopeEncryptionModuleOptions);
18357
- onModuleInit(): Promise<void>;
18360
+ onApplicationBootstrap(): Promise<void>;
18358
18361
  onModuleDestroy(): void;
18359
18362
  private getOrLoadKekMetadata;
18360
18363
  generateDek(kekId: string, _type: 'aes128-gcm96' | 'aes256-gcm96' | 'chacha20-poly1305'): Promise<GeneratedDek>;
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { ApiPropertyOptions, OpenAPIObject } from "@nestjs/swagger";
2
2
  import * as _$type_fest0 from "type-fest";
3
3
  import { Class, JsonValue, ValueOf } from "type-fest";
4
4
  import * as _$_nestjs_common0 from "@nestjs/common";
5
- import { ArgumentMetadata, ArgumentsHost, DynamicModule, ExceptionFilter, HttpStatus, OnModuleDestroy, OnModuleInit, PipeTransform, Type, ValidationPipe, ValidationPipeOptions } from "@nestjs/common";
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, 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
8
  import { Keq, KeqMiddleware, KeqOperation, KeqPathParameterInit, KeqQueryInit, KeqRequest } from "keq";
@@ -1860,6 +1860,9 @@ declare class DatabaseConfig {
1860
1860
  user: string;
1861
1861
  password: string;
1862
1862
  timezone?: string | undefined;
1863
+ poolMax: number;
1864
+ poolMin: number;
1865
+ poolIdleTimeoutMillis: number;
1863
1866
  toMikroOrmOptions(config?: Partial<Options>): Partial<Options>;
1864
1867
  }
1865
1868
  //#endregion
@@ -18344,7 +18347,7 @@ interface GeneratedDek {
18344
18347
  encryptedDek: Buffer;
18345
18348
  kekVersion: number;
18346
18349
  }
18347
- declare class KmsProvider implements OnModuleInit, OnModuleDestroy {
18350
+ declare class KmsProvider implements OnApplicationBootstrap, OnModuleDestroy {
18348
18351
  private readonly openbao;
18349
18352
  private readonly options;
18350
18353
  private readonly logger;
@@ -18354,7 +18357,7 @@ declare class KmsProvider implements OnModuleInit, OnModuleDestroy {
18354
18357
  private dekDecryptingPromises;
18355
18358
  private dekCacheCleanupTimer;
18356
18359
  constructor(openbao: OpenBaoHttpClient, options: EnvelopeEncryptionModuleOptions);
18357
- onModuleInit(): Promise<void>;
18360
+ onApplicationBootstrap(): Promise<void>;
18358
18361
  onModuleDestroy(): void;
18359
18362
  private getOrLoadKekMetadata;
18360
18363
  generateDek(kekId: string, _type: 'aes128-gcm96' | 'aes256-gcm96' | 'chacha20-poly1305'): Promise<GeneratedDek>;
package/dist/index.js CHANGED
@@ -2936,6 +2936,9 @@ var DatabaseConfig = class {
2936
2936
  user;
2937
2937
  password;
2938
2938
  timezone = "+08:00";
2939
+ poolMax = 10;
2940
+ poolMin = 0;
2941
+ poolIdleTimeoutMillis = 3e4;
2939
2942
  toMikroOrmOptions(config) {
2940
2943
  let options = {
2941
2944
  host: this.host,
@@ -2948,6 +2951,11 @@ var DatabaseConfig = class {
2948
2951
  forceUndefined: true,
2949
2952
  populateAfterFlush: false,
2950
2953
  flushMode: _mikro_orm_core.FlushMode.COMMIT,
2954
+ pool: {
2955
+ max: this.poolMax,
2956
+ min: this.poolMin,
2957
+ idleTimeoutMillis: this.poolIdleTimeoutMillis
2958
+ },
2951
2959
  serialization: { forceObject: true },
2952
2960
  findOneOrFailHandler: (entityName, where) => new _nestjs_common.BadRequestException(`Cannot find ${entityName} where ${util.inspect(where)}`)
2953
2961
  };
@@ -2974,6 +2982,21 @@ __decorate([
2974
2982
  __decorate([(0, class_validator.IsString)(), __decorateMetadata("design:type", String)], DatabaseConfig.prototype, "user", void 0);
2975
2983
  __decorate([(0, class_validator.IsString)(), __decorateMetadata("design:type", String)], DatabaseConfig.prototype, "password", void 0);
2976
2984
  __decorate([(0, class_validator.IsString)(), __decorateMetadata("design:type", Object)], DatabaseConfig.prototype, "timezone", void 0);
2985
+ __decorate([
2986
+ (0, _buka_class_transformer_extra.ToNumber)(),
2987
+ (0, class_validator.IsNumber)({ allowNaN: false }),
2988
+ __decorateMetadata("design:type", Number)
2989
+ ], DatabaseConfig.prototype, "poolMax", void 0);
2990
+ __decorate([
2991
+ (0, _buka_class_transformer_extra.ToNumber)(),
2992
+ (0, class_validator.IsNumber)({ allowNaN: false }),
2993
+ __decorateMetadata("design:type", Number)
2994
+ ], DatabaseConfig.prototype, "poolMin", void 0);
2995
+ __decorate([
2996
+ (0, _buka_class_transformer_extra.ToNumber)(),
2997
+ (0, class_validator.IsNumber)({ allowNaN: false }),
2998
+ __decorateMetadata("design:type", Number)
2999
+ ], DatabaseConfig.prototype, "poolIdleTimeoutMillis", void 0);
2977
3000
  //#endregion
2978
3001
  //#region src/modules/core/pipes/validation.pipe.ts
2979
3002
  var _ref$12, _ref2$2, _ref3$1, _BukaValidationPipe;
@@ -9412,7 +9435,7 @@ let KmsProvider = _KmsProvider = class KmsProvider {
9412
9435
  this.openbao = openbao;
9413
9436
  this.options = options;
9414
9437
  }
9415
- async onModuleInit() {
9438
+ async onApplicationBootstrap() {
9416
9439
  const keks = this.options.keks ?? [];
9417
9440
  await Promise.all(keks.map((kekId) => this.getOrLoadKekMetadata(kekId)));
9418
9441
  const ttl = this.options.dekCacheTtl ?? 0;