@buka/nestjs-kit 4.4.13 → 4.6.0
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 +19 -0
- package/README.md +38 -0
- package/dist/index.d.mts +27 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -1
- package/dist/index.mjs.map +1 -1
- package/docs/mikro-orm.md +20 -1
- package/docs/open-bao.md +1 -1
- package/package.json +1 -1
- package/skills/nestjs-kit-coding-standards/SKILL.md +149 -0
- package/skills/nestjs-kit-coding-standards/references/controller.md +108 -0
- package/skills/nestjs-kit-coding-standards/references/dto.md +195 -0
- package/skills/nestjs-kit-coding-standards/references/entity.md +173 -0
- package/skills/nestjs-kit-coding-standards/references/query.md +222 -0
- package/skills/nestjs-kit-coding-standards/references/service.md +136 -0
- package/skills/nestjs-kit-crypto/SKILL.md +126 -0
- package/skills/nestjs-kit-exception/SKILL.md +172 -0
- package/skills/nestjs-kit-http/SKILL.md +102 -0
- package/skills/nestjs-kit-logger/SKILL.md +113 -0
- package/skills/nestjs-kit-object-storage/SKILL.md +110 -0
- package/skills/nestjs-kit-open-bao/SKILL.md +121 -0
- package/skills/nestjs-kit-swagger/SKILL.md +73 -0
- package/skills/nestjs-kit-urn/SKILL.md +79 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [4.6.0](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.5.0...v4.6.0) (2026-10-26)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* 添加 Columns.Date ([d116cf2](https://github.com/buka-ltd/npm.nestjs-kit/commit/d116cf20985e0ece543031d8dd2f9b1e8e0c2559))
|
|
9
|
+
|
|
10
|
+
## [4.5.0](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.4.13...v4.5.0) (2026-10-07)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* add skills ([dc7213a](https://github.com/buka-ltd/npm.nestjs-kit/commit/dc7213af706ccb85ee3285ef4723ec5bc0347f7e))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* 分页参数为标量时避免 in 运算符抛 TypeError ([3d5b2ab](https://github.com/buka-ltd/npm.nestjs-kit/commit/3d5b2ab32731182942b2acb6d775c66f37600ed4))
|
|
21
|
+
|
|
3
22
|
## [4.4.13](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.4.12...v4.4.13) (2026-08-09)
|
|
4
23
|
|
|
5
24
|
|
package/README.md
CHANGED
|
@@ -9,3 +9,41 @@
|
|
|
9
9
|
```bash
|
|
10
10
|
pnpm install @buka/nestjs-kit
|
|
11
11
|
```
|
|
12
|
+
|
|
13
|
+
## Skills
|
|
14
|
+
|
|
15
|
+
本仓库的 [skills/](./skills) 目录沉淀了 kit 各功能域的使用约定与编写规范(共 9 个 skill,其中 dto/entity/service/controller/query 等文件编写规范聚合为 nestjs-kit-coding-standards,细节经其 references/ 目录按需加载),
|
|
16
|
+
供业务项目的 AI 编码助手(Claude Code 等)使用,按需自动触发(每个 skill 的 description 声明了其适用任务)。通过 [`skills`](https://www.npmjs.com/package/skills) CLI 安装:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# 查看本仓库可用的 skills
|
|
20
|
+
npx skills add buka-ltd/npm.nestjs-kit --list
|
|
21
|
+
|
|
22
|
+
# 在业务项目中安装到 Claude Code(交互式选择)
|
|
23
|
+
npx skills add buka-ltd/npm.nestjs-kit -a claude-code
|
|
24
|
+
|
|
25
|
+
# 按需安装指定 skills
|
|
26
|
+
npx skills add buka-ltd/npm.nestjs-kit -a claude-code \
|
|
27
|
+
--skill nestjs-kit-coding-standards
|
|
28
|
+
|
|
29
|
+
# 全量安装(CI/脚本等非交互场景)
|
|
30
|
+
npx skills add buka-ltd/npm.nestjs-kit --skill '*' -a claude-code -y
|
|
31
|
+
|
|
32
|
+
# 更新已安装的 skills
|
|
33
|
+
npx skills update
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
> 默认安装到项目的 `.claude/skills/`(用 `-g` 装到全局 `~/.claude/skills/`;用 `--copy` 以复制代替符号链接)。
|
|
37
|
+
> 本仓库的 skills 也可用本地路径安装(开发调试时):`npx skills add ./skills -a claude-code`。
|
|
38
|
+
|
|
39
|
+
| Skill | 覆盖内容 |
|
|
40
|
+
| ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
41
|
+
| `nestjs-kit-coding-standards` | 模块目录组织与 dto/entity/service/controller/query 的编写规范(@Model/Column/Cardinality/command/@FilterQuery/Slice/@IsBrowserRequest 等,references/ 按需加载) |
|
|
42
|
+
| `nestjs-kit-urn` | URN 格式规范、概念域与资源段、通配匹配 |
|
|
43
|
+
| `nestjs-kit-exception` | 异常工厂、@ModuleExceptions、错误码体系 |
|
|
44
|
+
| `nestjs-kit-logger` | LoggerModule、@InjectLogger、LoggerConfig |
|
|
45
|
+
| `nestjs-kit-http` | keq 服务间调用的错误处理 |
|
|
46
|
+
| `nestjs-kit-crypto` | 信封加密 / 盲索引 / 加盐哈希 |
|
|
47
|
+
| `nestjs-kit-object-storage` | S3 兼容对象存储 |
|
|
48
|
+
| `nestjs-kit-open-bao` | OpenBao/Vault 集成 |
|
|
49
|
+
| `nestjs-kit-swagger` | Swagger 文档修补 |
|
package/dist/index.d.mts
CHANGED
|
@@ -1734,6 +1734,32 @@ interface UuidOptions<T extends object> extends Omit<PropertyOptions<T>, 'type'
|
|
|
1734
1734
|
*/
|
|
1735
1735
|
declare function Uuid<T extends object>(options?: UuidOptions<T>): (target: T, propertyName: string) => void;
|
|
1736
1736
|
//#endregion
|
|
1737
|
+
//#region src/modules/mikro-orm/decorators/columns/date.column.d.ts
|
|
1738
|
+
interface DateOptions<T extends object> extends Omit<PropertyOptions<T>, 'type' | 'columnType'> {
|
|
1739
|
+
example?: SchemaObject['example'];
|
|
1740
|
+
examples?: SchemaObject['examples'];
|
|
1741
|
+
}
|
|
1742
|
+
/**
|
|
1743
|
+
* DATE 列装饰器,声明一个只含日期的列(无时间、无时区)。
|
|
1744
|
+
*
|
|
1745
|
+
* 自动应用 MikroORM `@Property({ type: 'date' })`、`@Matches()` + `@IsISO8601({ strict: true })`
|
|
1746
|
+
* 验证及 Swagger schema(format: date)。
|
|
1747
|
+
*
|
|
1748
|
+
* MikroORM `DateType` 在 JS 侧表示为 `YYYY-MM-DD` 字符串,不是 `Date` 对象,也不代表某个绝对时刻。
|
|
1749
|
+
*
|
|
1750
|
+
* @param options - 列配置
|
|
1751
|
+
*
|
|
1752
|
+
* @example
|
|
1753
|
+
* ```typescript
|
|
1754
|
+
* @Entity()
|
|
1755
|
+
* class CourseOccurrence {
|
|
1756
|
+
* @Date({ comment: '计划日期' })
|
|
1757
|
+
* date: string
|
|
1758
|
+
* }
|
|
1759
|
+
* ```
|
|
1760
|
+
*/
|
|
1761
|
+
declare function Date$1<T extends object>(options?: DateOptions<T>): (target: T, propertyName: string) => void;
|
|
1762
|
+
//#endregion
|
|
1737
1763
|
//#region src/modules/mikro-orm/decorators/columns/timestamptz.column.d.ts
|
|
1738
1764
|
interface TimestamptzOptions<T extends object> extends Omit<PropertyOptions<T>, 'type' | 'columnType'> {
|
|
1739
1765
|
example?: SchemaObject['example'];
|
|
@@ -1884,6 +1910,7 @@ declare const Column: {
|
|
|
1884
1910
|
readonly Numeric: typeof Numeric;
|
|
1885
1911
|
readonly Boolean: typeof Boolean$1;
|
|
1886
1912
|
readonly Uuid: typeof Uuid;
|
|
1913
|
+
readonly Date: typeof Date$1;
|
|
1887
1914
|
readonly Timestamptz: typeof Timestamptz;
|
|
1888
1915
|
readonly Enum: typeof Enum$1;
|
|
1889
1916
|
readonly Jsonb: typeof Jsonb;
|
package/dist/index.d.ts
CHANGED
|
@@ -1734,6 +1734,32 @@ interface UuidOptions<T extends object> extends Omit<PropertyOptions<T>, 'type'
|
|
|
1734
1734
|
*/
|
|
1735
1735
|
declare function Uuid<T extends object>(options?: UuidOptions<T>): (target: T, propertyName: string) => void;
|
|
1736
1736
|
//#endregion
|
|
1737
|
+
//#region src/modules/mikro-orm/decorators/columns/date.column.d.ts
|
|
1738
|
+
interface DateOptions<T extends object> extends Omit<PropertyOptions<T>, 'type' | 'columnType'> {
|
|
1739
|
+
example?: SchemaObject['example'];
|
|
1740
|
+
examples?: SchemaObject['examples'];
|
|
1741
|
+
}
|
|
1742
|
+
/**
|
|
1743
|
+
* DATE 列装饰器,声明一个只含日期的列(无时间、无时区)。
|
|
1744
|
+
*
|
|
1745
|
+
* 自动应用 MikroORM `@Property({ type: 'date' })`、`@Matches()` + `@IsISO8601({ strict: true })`
|
|
1746
|
+
* 验证及 Swagger schema(format: date)。
|
|
1747
|
+
*
|
|
1748
|
+
* MikroORM `DateType` 在 JS 侧表示为 `YYYY-MM-DD` 字符串,不是 `Date` 对象,也不代表某个绝对时刻。
|
|
1749
|
+
*
|
|
1750
|
+
* @param options - 列配置
|
|
1751
|
+
*
|
|
1752
|
+
* @example
|
|
1753
|
+
* ```typescript
|
|
1754
|
+
* @Entity()
|
|
1755
|
+
* class CourseOccurrence {
|
|
1756
|
+
* @Date({ comment: '计划日期' })
|
|
1757
|
+
* date: string
|
|
1758
|
+
* }
|
|
1759
|
+
* ```
|
|
1760
|
+
*/
|
|
1761
|
+
declare function Date$1<T extends object>(options?: DateOptions<T>): (target: T, propertyName: string) => void;
|
|
1762
|
+
//#endregion
|
|
1737
1763
|
//#region src/modules/mikro-orm/decorators/columns/timestamptz.column.d.ts
|
|
1738
1764
|
interface TimestamptzOptions<T extends object> extends Omit<PropertyOptions<T>, 'type' | 'columnType'> {
|
|
1739
1765
|
example?: SchemaObject['example'];
|
|
@@ -1884,6 +1910,7 @@ declare const Column: {
|
|
|
1884
1910
|
readonly Numeric: typeof Numeric;
|
|
1885
1911
|
readonly Boolean: typeof Boolean$1;
|
|
1886
1912
|
readonly Uuid: typeof Uuid;
|
|
1913
|
+
readonly Date: typeof Date$1;
|
|
1887
1914
|
readonly Timestamptz: typeof Timestamptz;
|
|
1888
1915
|
readonly Enum: typeof Enum$1;
|
|
1889
1916
|
readonly Jsonb: typeof Jsonb;
|
package/dist/index.js
CHANGED
|
@@ -1353,6 +1353,13 @@ let BukaPageQueryValidationPipe = class BukaPageQueryValidationPipe {
|
|
|
1353
1353
|
if (metadata.type !== "query") throw new _nestjs_common.InternalServerErrorException("BukaPageQueryValidationPipe can only be used to validate query parameters.");
|
|
1354
1354
|
if (!value.page) if (this.options.optional) return value;
|
|
1355
1355
|
else throw new _nestjs_common.BadRequestException("Missing required query parameter: page");
|
|
1356
|
+
/**
|
|
1357
|
+
* 走到这里时 `value.page` 已非空,但 query string 可能把 `page` 解析为标量
|
|
1358
|
+
* (如 `?page=1` 解析为字符串 `"1"`),对原始值使用 `in` 运算符会抛 TypeError,
|
|
1359
|
+
* 冒泡到全局异常过滤器后被映射为 500。先保证 `page` 是纯对象,数组一并拦截,
|
|
1360
|
+
* 使非法形态收敛为 400。
|
|
1361
|
+
*/
|
|
1362
|
+
if (typeof value.page !== "object" || Array.isArray(value.page)) throw new _nestjs_common.BadRequestException("Invalid page query: page must be an object.");
|
|
1356
1363
|
const mode = this.options.mode;
|
|
1357
1364
|
if ((!mode || mode === "offset") && ("limit" in value.page || "offset" in value.page)) {
|
|
1358
1365
|
if ("after" in value.page || "first" in value.page || "before" in value.page || "last" in value.page) throw new _nestjs_common.BadRequestException(mixedOffsetAndCursorError);
|
|
@@ -2514,6 +2521,47 @@ function Uuid(options) {
|
|
|
2514
2521
|
};
|
|
2515
2522
|
}
|
|
2516
2523
|
//#endregion
|
|
2524
|
+
//#region src/modules/mikro-orm/decorators/columns/date.column.ts
|
|
2525
|
+
/**
|
|
2526
|
+
* DATE 列装饰器,声明一个只含日期的列(无时间、无时区)。
|
|
2527
|
+
*
|
|
2528
|
+
* 自动应用 MikroORM `@Property({ type: 'date' })`、`@Matches()` + `@IsISO8601({ strict: true })`
|
|
2529
|
+
* 验证及 Swagger schema(format: date)。
|
|
2530
|
+
*
|
|
2531
|
+
* MikroORM `DateType` 在 JS 侧表示为 `YYYY-MM-DD` 字符串,不是 `Date` 对象,也不代表某个绝对时刻。
|
|
2532
|
+
*
|
|
2533
|
+
* @param options - 列配置
|
|
2534
|
+
*
|
|
2535
|
+
* @example
|
|
2536
|
+
* ```typescript
|
|
2537
|
+
* @Entity()
|
|
2538
|
+
* class CourseOccurrence {
|
|
2539
|
+
* @Date({ comment: '计划日期' })
|
|
2540
|
+
* date: string
|
|
2541
|
+
* }
|
|
2542
|
+
* ```
|
|
2543
|
+
*/
|
|
2544
|
+
function Date$1(options) {
|
|
2545
|
+
return (target, propertyKey) => {
|
|
2546
|
+
(0, _mikro_orm_decorators_legacy.Property)({
|
|
2547
|
+
...options,
|
|
2548
|
+
type: "date"
|
|
2549
|
+
})(target, propertyKey);
|
|
2550
|
+
(0, _nestjs_common.applyDecorators)((0, class_validator.Matches)(/^\d{4}-\d{2}-\d{2}$/, { message: "$property must be a date in YYYY-MM-DD format" }), (0, class_validator.IsISO8601)({ strict: true }), Property({
|
|
2551
|
+
optional: options?.nullable,
|
|
2552
|
+
lazy: options?.lazy,
|
|
2553
|
+
schema: {
|
|
2554
|
+
type: "string",
|
|
2555
|
+
format: "date",
|
|
2556
|
+
description: options?.comment,
|
|
2557
|
+
example: options?.example,
|
|
2558
|
+
examples: options?.examples,
|
|
2559
|
+
required: !options?.nullable
|
|
2560
|
+
}
|
|
2561
|
+
}))(target, propertyKey);
|
|
2562
|
+
};
|
|
2563
|
+
}
|
|
2564
|
+
//#endregion
|
|
2517
2565
|
//#region src/modules/mikro-orm/decorators/columns/timestamptz.column.ts
|
|
2518
2566
|
/**
|
|
2519
2567
|
* TIMESTAMPTZ 列装饰器,声明一个带时区的时间戳列。
|
|
@@ -2762,6 +2810,7 @@ const Column = {
|
|
|
2762
2810
|
Numeric,
|
|
2763
2811
|
Boolean: Boolean$1,
|
|
2764
2812
|
Uuid,
|
|
2813
|
+
Date: Date$1,
|
|
2765
2814
|
Timestamptz,
|
|
2766
2815
|
Enum: Enum$1,
|
|
2767
2816
|
Jsonb,
|