@bearei/contracts 2.2.0 → 2.2.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 +9 -0
- package/README.md +27 -1
- package/README.zh-CN.md +26 -2
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +7 -7
- package/dist/index.mjs +7 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,15 @@ All notable changes to this project are documented in this file. The format is b
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to
|
|
5
5
|
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## 2.2.1 — 2026-10-28
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- README now documents the release flow and states that the package declares no runtime or peer
|
|
12
|
+
dependencies; the Chinese README matches the English one again.
|
|
13
|
+
- `ApiErrorBody` is documented as the business error body. Validation errors keep the NestJS
|
|
14
|
+
default body and are not assignable to it. No exported value or type changed.
|
|
15
|
+
|
|
7
16
|
## 2.2.0 — 2026-10-27
|
|
8
17
|
|
|
9
18
|
### Added
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ English | [中文](./README.zh-CN.md)
|
|
|
8
8
|
| Export | Kind | Purpose |
|
|
9
9
|
| ------------------------------------------------------ | ----- | --------------------------------------------------- |
|
|
10
10
|
| `HTTP_EXCEPTION_CODE`, `HttpExceptionCode` | value | Numeric error codes shared by services and clients |
|
|
11
|
-
| `ApiErrorBody` | type |
|
|
11
|
+
| `ApiErrorBody` | type | Business error body `{code, message, statusCode}` |
|
|
12
12
|
| `DEFAULT_PAGE_SIZE`, `MAX_PAGE_SIZE` | value | Paging limits used by every list endpoint |
|
|
13
13
|
| `PaginationQuery`, `PaginatedResult<T>` | type | Paging request fields and page envelope |
|
|
14
14
|
| `RESERVED_REQUEST_HEADER`, `ReservedRequestHeaderName` | value | Headers set by the gateway or authentication layer |
|
|
@@ -23,6 +23,9 @@ English | [中文](./README.zh-CN.md)
|
|
|
23
23
|
yarn add @bearei/contracts
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
The package declares no runtime or peer dependencies, so installing it adds nothing else to your
|
|
27
|
+
dependency tree.
|
|
28
|
+
|
|
26
29
|
## Usage
|
|
27
30
|
|
|
28
31
|
```ts
|
|
@@ -48,6 +51,10 @@ const page: PaginatedResult<{id: string}> = {
|
|
|
48
51
|
}
|
|
49
52
|
```
|
|
50
53
|
|
|
54
|
+
`ApiErrorBody` describes business errors raised by guards, services and shared exceptions. Request
|
|
55
|
+
validation errors keep the NestJS default body (`statusCode`, `message`, `error`) and are not
|
|
56
|
+
assignable to this type.
|
|
57
|
+
|
|
51
58
|
### Module formats
|
|
52
59
|
|
|
53
60
|
The `exports` map resolves `import` consumers to the ESM build and `require` consumers to the
|
|
@@ -75,3 +82,22 @@ yarn install
|
|
|
75
82
|
yarn verify # format + lint + typecheck + coverage + build
|
|
76
83
|
yarn run pack # pack once and inspect the tarball
|
|
77
84
|
```
|
|
85
|
+
|
|
86
|
+
## Release
|
|
87
|
+
|
|
88
|
+
Releases are tag-driven. Bump `version` in `package.json`, update `CHANGELOG.md`, then push a
|
|
89
|
+
matching tag (`2.2.1` and `v2.2.1` are both accepted). The tag must equal the package version;
|
|
90
|
+
stable tags must be on `main`, and prerelease tags must be on `main` or `develop`.
|
|
91
|
+
|
|
92
|
+
`.github/workflows/release.yml` then:
|
|
93
|
+
|
|
94
|
+
1. runs `yarn verify`;
|
|
95
|
+
2. packs the tarball once and verifies its file list and export map;
|
|
96
|
+
3. publishes that tarball through npm Trusted Publishing (OIDC), using `latest` for stable versions
|
|
97
|
+
and `next` for prereleases such as `2.3.0-rc.1`;
|
|
98
|
+
4. downloads the published tarball from the registry and verifies it again;
|
|
99
|
+
5. creates a GitHub Release with the tarball attached as `bearei-contracts-<version>.tgz` (marked
|
|
100
|
+
pre-release when the dist-tag is `next`).
|
|
101
|
+
|
|
102
|
+
Register this GitHub repository, the `release.yml` workflow and the `npm` environment as a trusted
|
|
103
|
+
publisher for `@bearei/contracts` on npmjs.com. `workflow_dispatch` reruns an existing tag.
|
package/README.zh-CN.md
CHANGED
|
@@ -8,7 +8,7 @@ ESM 与 CommonJS 两种产物。
|
|
|
8
8
|
| 导出 | 类型 | 用途 |
|
|
9
9
|
| ------------------------------------------------------ | ---- | ---------------------------------------- |
|
|
10
10
|
| `HTTP_EXCEPTION_CODE`、`HttpExceptionCode` | 值 | 服务与客户端共享的数字错误码 |
|
|
11
|
-
| `ApiErrorBody` | 类型 |
|
|
11
|
+
| `ApiErrorBody` | 类型 | 业务错误体 `{code, message, statusCode}` |
|
|
12
12
|
| `DEFAULT_PAGE_SIZE`、`MAX_PAGE_SIZE` | 值 | 所有列表接口使用的分页上限 |
|
|
13
13
|
| `PaginationQuery`、`PaginatedResult<T>` | 类型 | 分页请求字段与分页响应信封 |
|
|
14
14
|
| `RESERVED_REQUEST_HEADER`、`ReservedRequestHeaderName` | 值 | 由网关或认证层写入的保留请求头 |
|
|
@@ -23,6 +23,8 @@ ESM 与 CommonJS 两种产物。
|
|
|
23
23
|
yarn add @bearei/contracts
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
本包不声明任何运行时依赖或 peer 依赖,安装它不会向依赖树加入其他包。
|
|
27
|
+
|
|
26
28
|
## 使用
|
|
27
29
|
|
|
28
30
|
```ts
|
|
@@ -48,6 +50,9 @@ const page: PaginatedResult<{id: string}> = {
|
|
|
48
50
|
}
|
|
49
51
|
```
|
|
50
52
|
|
|
53
|
+
`ApiErrorBody` 对应守卫、服务与共享异常抛出的业务错误。请求参数校验错误仍使用 NestJS 标准体
|
|
54
|
+
(`statusCode`、`message`、`error`),不能赋值给该类型。
|
|
55
|
+
|
|
51
56
|
### 模块格式
|
|
52
57
|
|
|
53
58
|
`exports` 映射会让 `import` 使用 ESM 产物、`require` 使用 CommonJS 产物;TypeScript 会自动选择
|
|
@@ -72,6 +77,25 @@ const page: PaginatedResult<{id: string}> = {
|
|
|
72
77
|
|
|
73
78
|
```bash
|
|
74
79
|
yarn install
|
|
75
|
-
yarn verify # lint + typecheck + 覆盖率 + 构建
|
|
80
|
+
yarn verify # 格式 + lint + typecheck + 覆盖率 + 构建
|
|
76
81
|
yarn run pack # 打包一次并检查 tarball
|
|
77
82
|
```
|
|
83
|
+
|
|
84
|
+
## 发布
|
|
85
|
+
|
|
86
|
+
发布由版本 tag 驱动。先修改 `package.json` 的 `version` 并更新 `CHANGELOG.md`,再推送同版本 tag
|
|
87
|
+
(`2.2.1` 与 `v2.2.1` 均可)。tag 必须等于包版本;稳定版 tag 必须位于 `main`,预发布 tag 必须位于
|
|
88
|
+
`main` 或 `develop`。
|
|
89
|
+
|
|
90
|
+
`.github/workflows/release.yml` 随后会:
|
|
91
|
+
|
|
92
|
+
1. 执行 `yarn verify`;
|
|
93
|
+
2. 打包一次并校验 tarball 的文件清单与导出映射;
|
|
94
|
+
3. 通过 npm Trusted Publishing(OIDC)发布该 tarball,稳定版使用 `latest`,预发布(如
|
|
95
|
+
`2.3.0-rc.1`)使用 `next`;
|
|
96
|
+
4. 从 registry 下载已发布的 tarball 并再次校验;
|
|
97
|
+
5. 创建 GitHub Release,附件为 `bearei-contracts-<version>.tgz`(dist-tag 为 `next` 时标记为
|
|
98
|
+
pre-release)。
|
|
99
|
+
|
|
100
|
+
发布前需在 npmjs.com 上为 `@bearei/contracts` 登记本 GitHub 仓库、`release.yml` 工作流与 `npm`
|
|
101
|
+
环境作为 trusted publisher。`workflow_dispatch` 可用已有 tag 手动重跑。
|
package/dist/index.d.mts
CHANGED
|
@@ -40,7 +40,8 @@ declare const HTTP_EXCEPTION_CODE: {
|
|
|
40
40
|
type HttpExceptionCode = (typeof HTTP_EXCEPTION_CODE)[keyof typeof HTTP_EXCEPTION_CODE];
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
43
|
+
* Business error body returned by Bearei HTTP APIs. Validation errors keep the NestJS default
|
|
44
|
+
* body (`statusCode`, `message`, `error`) and are not represented by this type.
|
|
44
45
|
* Services may return codes outside `HTTP_EXCEPTION_CODE`, so `code` stays numeric.
|
|
45
46
|
*/
|
|
46
47
|
interface ApiErrorBody {
|
|
@@ -73,6 +74,7 @@ type Order = (typeof ORDER)[keyof typeof ORDER];
|
|
|
73
74
|
|
|
74
75
|
declare const DEFAULT_PAGE_SIZE = 10;
|
|
75
76
|
declare const MAX_PAGE_SIZE = 1024;
|
|
77
|
+
|
|
76
78
|
interface PaginationQuery {
|
|
77
79
|
page?: number;
|
|
78
80
|
pageSize?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -40,7 +40,8 @@ declare const HTTP_EXCEPTION_CODE: {
|
|
|
40
40
|
type HttpExceptionCode = (typeof HTTP_EXCEPTION_CODE)[keyof typeof HTTP_EXCEPTION_CODE];
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
43
|
+
* Business error body returned by Bearei HTTP APIs. Validation errors keep the NestJS default
|
|
44
|
+
* body (`statusCode`, `message`, `error`) and are not represented by this type.
|
|
44
45
|
* Services may return codes outside `HTTP_EXCEPTION_CODE`, so `code` stays numeric.
|
|
45
46
|
*/
|
|
46
47
|
interface ApiErrorBody {
|
|
@@ -73,6 +74,7 @@ type Order = (typeof ORDER)[keyof typeof ORDER];
|
|
|
73
74
|
|
|
74
75
|
declare const DEFAULT_PAGE_SIZE = 10;
|
|
75
76
|
declare const MAX_PAGE_SIZE = 1024;
|
|
77
|
+
|
|
76
78
|
interface PaginationQuery {
|
|
77
79
|
page?: number;
|
|
78
80
|
pageSize?: number;
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ __export(index_exports, {
|
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(index_exports);
|
|
33
33
|
|
|
34
|
-
// src/error-code.ts
|
|
34
|
+
// src/error-code.enum.ts
|
|
35
35
|
var HTTP_EXCEPTION_CODE = {
|
|
36
36
|
ACCESS_DENIED_FOR_GUEST: 401003,
|
|
37
37
|
APPLE_IAP_TRANSACTION_NOT_COMPLETED: 403004,
|
|
@@ -68,7 +68,7 @@ var HTTP_EXCEPTION_CODE = {
|
|
|
68
68
|
USER_DEACTIVATED: 401005
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
-
// src/header.ts
|
|
71
|
+
// src/header.enum.ts
|
|
72
72
|
var RESERVED_REQUEST_HEADER = {
|
|
73
73
|
CLIENT: "x-bearei-client",
|
|
74
74
|
DOMAIN_ID: "x-bearei-domain-id",
|
|
@@ -78,23 +78,23 @@ var RESERVED_REQUEST_HEADER = {
|
|
|
78
78
|
SUBSCRIPTION: "x-bearei-subscription"
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
-
// src/language.ts
|
|
81
|
+
// src/language.enum.ts
|
|
82
82
|
var LANGUAGE = {
|
|
83
83
|
EN_US: "EN_US",
|
|
84
84
|
ZH_CN: "ZH_CN"
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
-
// src/order.ts
|
|
87
|
+
// src/order.enum.ts
|
|
88
88
|
var ORDER = {
|
|
89
89
|
ASC: "ASC",
|
|
90
90
|
DESC: "DESC"
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
-
// src/pagination.ts
|
|
93
|
+
// src/pagination.const.ts
|
|
94
94
|
var DEFAULT_PAGE_SIZE = 10;
|
|
95
95
|
var MAX_PAGE_SIZE = 1024;
|
|
96
96
|
|
|
97
|
-
// src/permission.ts
|
|
97
|
+
// src/permission.enum.ts
|
|
98
98
|
var PERMISSION = {
|
|
99
99
|
ACTION_LOG_CREATE: "action-log:create",
|
|
100
100
|
ACTION_LOG_DELETE: "action-log:delete",
|
|
@@ -166,7 +166,7 @@ var PERMISSION = {
|
|
|
166
166
|
VERSION_LOG_UPDATE: "version-log:update"
|
|
167
167
|
};
|
|
168
168
|
|
|
169
|
-
// src/subscription-feature.ts
|
|
169
|
+
// src/subscription-feature.enum.ts
|
|
170
170
|
var SUBSCRIPTION_FEATURE = {
|
|
171
171
|
BOOKMARK_CLOUD_SYNC: "bookmark:cloud_sync",
|
|
172
172
|
CARTON_CLOUD_SYNC: "bookmark:carton_cloud_sync",
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/error-code.ts
|
|
1
|
+
// src/error-code.enum.ts
|
|
2
2
|
var HTTP_EXCEPTION_CODE = {
|
|
3
3
|
ACCESS_DENIED_FOR_GUEST: 401003,
|
|
4
4
|
APPLE_IAP_TRANSACTION_NOT_COMPLETED: 403004,
|
|
@@ -35,7 +35,7 @@ var HTTP_EXCEPTION_CODE = {
|
|
|
35
35
|
USER_DEACTIVATED: 401005
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
// src/header.ts
|
|
38
|
+
// src/header.enum.ts
|
|
39
39
|
var RESERVED_REQUEST_HEADER = {
|
|
40
40
|
CLIENT: "x-bearei-client",
|
|
41
41
|
DOMAIN_ID: "x-bearei-domain-id",
|
|
@@ -45,23 +45,23 @@ var RESERVED_REQUEST_HEADER = {
|
|
|
45
45
|
SUBSCRIPTION: "x-bearei-subscription"
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
// src/language.ts
|
|
48
|
+
// src/language.enum.ts
|
|
49
49
|
var LANGUAGE = {
|
|
50
50
|
EN_US: "EN_US",
|
|
51
51
|
ZH_CN: "ZH_CN"
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
// src/order.ts
|
|
54
|
+
// src/order.enum.ts
|
|
55
55
|
var ORDER = {
|
|
56
56
|
ASC: "ASC",
|
|
57
57
|
DESC: "DESC"
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
// src/pagination.ts
|
|
60
|
+
// src/pagination.const.ts
|
|
61
61
|
var DEFAULT_PAGE_SIZE = 10;
|
|
62
62
|
var MAX_PAGE_SIZE = 1024;
|
|
63
63
|
|
|
64
|
-
// src/permission.ts
|
|
64
|
+
// src/permission.enum.ts
|
|
65
65
|
var PERMISSION = {
|
|
66
66
|
ACTION_LOG_CREATE: "action-log:create",
|
|
67
67
|
ACTION_LOG_DELETE: "action-log:delete",
|
|
@@ -133,7 +133,7 @@ var PERMISSION = {
|
|
|
133
133
|
VERSION_LOG_UPDATE: "version-log:update"
|
|
134
134
|
};
|
|
135
135
|
|
|
136
|
-
// src/subscription-feature.ts
|
|
136
|
+
// src/subscription-feature.enum.ts
|
|
137
137
|
var SUBSCRIPTION_FEATURE = {
|
|
138
138
|
BOOKMARK_CLOUD_SYNC: "bookmark:cloud_sync",
|
|
139
139
|
CARTON_CLOUD_SYNC: "bookmark:carton_cloud_sync",
|