@nest-omni/core 4.1.3-2 → 4.1.3-4
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/audit/audit.module.d.ts +10 -0
- package/audit/audit.module.js +15 -0
- package/audit/controllers/audit.controller.d.ts +24 -0
- package/audit/controllers/audit.controller.js +24 -0
- package/audit/decorators/audit-controller.decorator.d.ts +8 -0
- package/audit/decorators/audit-controller.decorator.js +9 -0
- package/audit/decorators/audit-operation.decorator.d.ts +45 -0
- package/audit/decorators/audit-operation.decorator.js +49 -0
- package/audit/decorators/entity-audit.decorator.d.ts +8 -0
- package/audit/decorators/entity-audit.decorator.js +9 -0
- package/audit/dto/audit-log-query.dto.d.ts +3 -0
- package/audit/dto/audit-log-query.dto.js +3 -0
- package/audit/dto/begin-transaction.dto.d.ts +3 -0
- package/audit/dto/begin-transaction.dto.js +3 -0
- package/audit/dto/compare-entities.dto.d.ts +3 -0
- package/audit/dto/compare-entities.dto.js +3 -0
- package/audit/dto/pre-check-restore.dto.d.ts +3 -0
- package/audit/dto/pre-check-restore.dto.js +3 -0
- package/audit/dto/restore-entity.dto.d.ts +3 -0
- package/audit/dto/restore-entity.dto.js +3 -0
- package/audit/entities/entity-audit-log.entity.d.ts +3 -0
- package/audit/entities/entity-audit-log.entity.js +3 -0
- package/audit/entities/entity-transaction.entity.d.ts +3 -0
- package/audit/entities/entity-transaction.entity.js +3 -0
- package/audit/entities/manual-operation-log.entity.d.ts +4 -0
- package/audit/entities/manual-operation-log.entity.js +4 -0
- package/audit/entities/operation-template.entity.d.ts +4 -0
- package/audit/entities/operation-template.entity.js +4 -0
- package/audit/enums/audit.enums.d.ts +17 -2
- package/audit/enums/audit.enums.js +15 -0
- package/audit/index.js +10 -0
- package/audit/interceptors/audit.interceptor.d.ts +15 -0
- package/audit/interceptors/audit.interceptor.js +23 -1
- package/audit/interfaces/audit.interfaces.d.ts +42 -0
- package/audit/services/audit-context.service.d.ts +15 -0
- package/audit/services/audit-context.service.js +15 -0
- package/audit/services/audit-strategy.service.d.ts +6 -0
- package/audit/services/audit-strategy.service.js +13 -0
- package/audit/services/entity-audit.service.d.ts +57 -0
- package/audit/services/entity-audit.service.js +91 -0
- package/audit/services/manual-audit-log.service.d.ts +124 -0
- package/audit/services/manual-audit-log.service.js +138 -0
- package/audit/services/multi-database.service.d.ts +12 -0
- package/audit/services/multi-database.service.js +12 -0
- package/audit/services/operation-description.service.d.ts +59 -0
- package/audit/services/operation-description.service.js +76 -2
- package/audit/services/transaction-audit.service.d.ts +30 -0
- package/audit/services/transaction-audit.service.js +47 -0
- package/audit/subscribers/entity-audit.subscriber.d.ts +15 -0
- package/audit/subscribers/entity-audit.subscriber.js +29 -1
- package/cache/cache-metrics.service.d.ts +67 -0
- package/cache/cache-metrics.service.js +68 -4
- package/cache/cache-serialization.service.d.ts +31 -0
- package/cache/cache-serialization.service.js +25 -0
- package/cache/cache.constants.d.ts +9 -0
- package/cache/cache.constants.js +9 -0
- package/cache/cache.health.d.ts +26 -0
- package/cache/cache.health.js +30 -0
- package/cache/cache.module.d.ts +86 -0
- package/cache/cache.module.js +71 -0
- package/cache/cache.service.d.ts +140 -0
- package/cache/cache.service.js +157 -0
- package/cache/cache.warmup.service.d.ts +39 -0
- package/cache/cache.warmup.service.js +32 -0
- package/cache/decorators/cache-evict.decorator.d.ts +47 -0
- package/cache/decorators/cache-evict.decorator.js +56 -0
- package/cache/decorators/cache-put.decorator.d.ts +34 -0
- package/cache/decorators/cache-put.decorator.js +39 -0
- package/cache/decorators/cacheable.decorator.d.ts +40 -0
- package/cache/decorators/cacheable.decorator.js +55 -0
- package/cache/dependencies/callback.dependency.d.ts +33 -0
- package/cache/dependencies/callback.dependency.js +39 -1
- package/cache/dependencies/chain.dependency.d.ts +28 -0
- package/cache/dependencies/chain.dependency.js +34 -0
- package/cache/dependencies/db.dependency.d.ts +45 -0
- package/cache/dependencies/db.dependency.js +48 -1
- package/cache/dependencies/file.dependency.d.ts +32 -0
- package/cache/dependencies/file.dependency.js +34 -0
- package/cache/dependencies/tag.dependency.d.ts +36 -0
- package/cache/dependencies/tag.dependency.js +36 -0
- package/cache/dependencies/time.dependency.d.ts +43 -0
- package/cache/dependencies/time.dependency.js +43 -0
- package/cache/examples/basic-usage.d.ts +15 -0
- package/cache/examples/basic-usage.js +62 -8
- package/cache/index.js +9 -0
- package/cache/interfaces/cache-dependency.interface.d.ts +53 -0
- package/cache/interfaces/cache-options.interface.d.ts +81 -0
- package/cache/interfaces/cache-options.interface.js +6 -0
- package/cache/interfaces/cache-provider.interface.d.ts +78 -0
- package/cache/providers/base-cache.provider.d.ts +14 -0
- package/cache/providers/base-cache.provider.js +16 -0
- package/cache/providers/cls-cache.provider.d.ts +20 -0
- package/cache/providers/cls-cache.provider.js +28 -0
- package/cache/providers/memory-cache.provider.d.ts +23 -0
- package/cache/providers/memory-cache.provider.js +26 -0
- package/cache/providers/redis-cache.provider.d.ts +26 -0
- package/cache/providers/redis-cache.provider.js +29 -0
- package/cache/utils/dependency-manager.util.d.ts +52 -0
- package/cache/utils/dependency-manager.util.js +59 -0
- package/cache/utils/key-generator.util.d.ts +42 -0
- package/cache/utils/key-generator.util.js +53 -1
- package/common/abstract.entity.d.ts +14 -0
- package/common/abstract.entity.js +14 -0
- package/common/boilerplate.polyfill.d.ts +142 -0
- package/common/boilerplate.polyfill.js +17 -0
- package/common/dto/dto-container.d.ts +16 -0
- package/common/dto/dto-container.js +20 -0
- package/common/dto/dto-decorators.d.ts +18 -0
- package/common/dto/dto-decorators.js +14 -0
- package/common/dto/dto-extensions.d.ts +11 -0
- package/common/dto/dto-extensions.js +9 -0
- package/common/dto/dto-service-accessor.d.ts +17 -0
- package/common/dto/dto-service-accessor.js +18 -0
- package/common/dto/dto-transformer.d.ts +12 -0
- package/common/dto/dto-transformer.js +9 -0
- package/common/dto/index.js +2 -0
- package/common/examples/paginate-and-map.example.d.ts +6 -0
- package/common/examples/paginate-and-map.example.js +26 -0
- package/common/utils.d.ts +15 -0
- package/common/utils.js +15 -0
- package/constants/language-code.js +1 -0
- package/decorators/field.decorators.js +8 -1
- package/decorators/property.decorators.js +1 -0
- package/decorators/public-route.decorator.js +1 -0
- package/decorators/transform.decorators.d.ts +27 -0
- package/decorators/transform.decorators.js +29 -0
- package/decorators/translate.decorator.js +1 -0
- package/decorators/user.decorator.js +1 -0
- package/decorators/validator.decorators.d.ts +8 -18
- package/decorators/validator.decorators.js +22 -190
- package/filters/constraint-errors.js +1 -0
- package/helpers/common.helper.d.ts +13 -0
- package/helpers/common.helper.js +13 -0
- package/http-client/config/http-client.config.d.ts +15 -0
- package/http-client/config/http-client.config.js +25 -9
- package/http-client/decorators/http-client.decorators.d.ts +63 -0
- package/http-client/decorators/http-client.decorators.js +71 -3
- package/http-client/entities/http-log.entity.d.ts +229 -0
- package/http-client/entities/http-log.entity.js +6 -1
- package/http-client/errors/http-client.errors.d.ts +57 -0
- package/http-client/errors/http-client.errors.js +58 -0
- package/http-client/examples/advanced-usage.example.d.ts +41 -0
- package/http-client/examples/advanced-usage.example.js +68 -24
- package/http-client/examples/auth-with-waiting-lock.example.d.ts +31 -0
- package/http-client/examples/auth-with-waiting-lock.example.js +52 -5
- package/http-client/examples/basic-usage.example.d.ts +60 -0
- package/http-client/examples/basic-usage.example.js +60 -0
- package/http-client/examples/multi-api-configuration.example.d.ts +60 -0
- package/http-client/examples/multi-api-configuration.example.js +76 -5
- package/http-client/http-client.module.d.ts +13 -0
- package/http-client/http-client.module.js +19 -0
- package/http-client/index.js +8 -0
- package/http-client/interfaces/api-client-config.interface.d.ts +125 -0
- package/http-client/interfaces/api-client-config.interface.js +3 -0
- package/http-client/interfaces/http-client-config.interface.d.ts +60 -0
- package/http-client/services/api-client-registry.service.d.ts +57 -0
- package/http-client/services/api-client-registry.service.js +84 -1
- package/http-client/services/cache.service.d.ts +52 -0
- package/http-client/services/cache.service.js +72 -3
- package/http-client/services/circuit-breaker.service.d.ts +46 -0
- package/http-client/services/circuit-breaker.service.js +52 -0
- package/http-client/services/http-client.service.d.ts +67 -0
- package/http-client/services/http-client.service.js +105 -4
- package/http-client/services/http-log-query.service.d.ts +83 -0
- package/http-client/services/http-log-query.service.js +122 -1
- package/http-client/services/http-replay.service.d.ts +101 -0
- package/http-client/services/http-replay.service.js +86 -0
- package/http-client/services/log-cleanup.service.d.ts +63 -0
- package/http-client/services/log-cleanup.service.js +54 -2
- package/http-client/services/logging.service.d.ts +40 -0
- package/http-client/services/logging.service.js +53 -0
- package/http-client/utils/call-stack-extractor.util.d.ts +37 -0
- package/http-client/utils/call-stack-extractor.util.js +48 -0
- package/http-client/utils/context-extractor.util.d.ts +49 -0
- package/http-client/utils/context-extractor.util.js +52 -0
- package/http-client/utils/curl-generator.util.d.ts +21 -0
- package/http-client/utils/curl-generator.util.js +44 -3
- package/http-client/utils/request-id.util.d.ts +18 -0
- package/http-client/utils/request-id.util.js +20 -0
- package/http-client/utils/retry-recorder.util.d.ts +42 -0
- package/http-client/utils/retry-recorder.util.js +44 -0
- package/index.js +8 -0
- package/interceptors/translation-interceptor.service.js +5 -0
- package/package.json +1 -1
- package/providers/context.provider.js +2 -0
- package/providers/generator.provider.d.ts +4 -0
- package/providers/generator.provider.js +4 -0
- package/redis-lock/examples/lock-strategy.examples.d.ts +89 -0
- package/redis-lock/examples/lock-strategy.examples.js +130 -15
- package/redis-lock/index.js +3 -0
- package/redis-lock/redis-lock.decorator.d.ts +101 -0
- package/redis-lock/redis-lock.decorator.js +120 -0
- package/redis-lock/redis-lock.module.d.ts +60 -0
- package/redis-lock/redis-lock.module.js +46 -0
- package/redis-lock/redis-lock.service.d.ts +251 -0
- package/redis-lock/redis-lock.service.js +219 -3
- package/setup/bootstrap.setup.js +20 -0
- package/setup/mode.setup.d.ts +44 -0
- package/setup/mode.setup.js +44 -0
- package/setup/schedule.decorator.d.ts +226 -0
- package/setup/schedule.decorator.js +214 -1
- package/setup/worker.decorator.d.ts +86 -0
- package/setup/worker.decorator.js +88 -0
- package/shared/serviceRegistryModule.js +5 -1
- package/shared/services/api-config.service.d.ts +3 -0
- package/shared/services/api-config.service.js +20 -9
- package/validator-json/decorators.d.ts +17 -0
- package/validator-json/decorators.js +17 -2
- package/validator-json/default.d.ts +6 -0
- package/validator-json/default.js +30 -2
- package/validator-json/defaultConverters.js +1 -0
- package/validator-json/options.d.ts +23 -0
- package/validators/common-validators.d.ts +143 -0
- package/validators/common-validators.js +249 -0
- package/validators/custom-validate.examples.d.ts +23 -0
- package/validators/custom-validate.examples.js +78 -6
- package/validators/custom-validate.validator.d.ts +107 -0
- package/validators/custom-validate.validator.js +84 -0
- package/validators/index.d.ts +1 -0
- package/validators/index.js +1 -0
- package/validators/is-exists.validator.d.ts +11 -0
- package/validators/is-exists.validator.js +22 -0
- package/validators/is-unique.validator.d.ts +11 -0
- package/validators/is-unique.validator.js +31 -3
- package/validators/skip-empty.validator.d.ts +5 -0
- package/validators/skip-empty.validator.js +5 -0
- package/vault/interfaces/vault-options.interface.d.ts +9 -0
- package/vault/vault-config.loader.d.ts +30 -0
- package/vault/vault-config.loader.js +48 -1
- package/vault/vault-config.service.d.ts +53 -0
- package/vault/vault-config.service.js +57 -0
- package/vault/vault.module.d.ts +4 -0
- package/vault/vault.module.js +4 -0
- package/decorators/examples/validation-decorators.example.d.ts +0 -69
- package/decorators/examples/validation-decorators.example.js +0 -331
|
@@ -21,11 +21,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
21
21
|
exports.ExampleController = exports.ApiManagementService = exports.CustomApiService = exports.WeChatApiService = exports.StripeApiService = exports.GitHubApiService = void 0;
|
|
22
22
|
const common_1 = require("@nestjs/common");
|
|
23
23
|
const api_client_registry_service_1 = require("../services/api-client-registry.service");
|
|
24
|
+
/**
|
|
25
|
+
* GitHub API 客户端示例
|
|
26
|
+
*/
|
|
24
27
|
let GitHubApiService = class GitHubApiService {
|
|
25
28
|
constructor(apiRegistry) {
|
|
26
29
|
this.apiRegistry = apiRegistry;
|
|
27
30
|
this.initializeClients();
|
|
28
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* 获取GitHub客户端
|
|
34
|
+
*/
|
|
29
35
|
get github() {
|
|
30
36
|
return this.apiRegistry.getClient('github');
|
|
31
37
|
}
|
|
@@ -40,10 +46,11 @@ let GitHubApiService = class GitHubApiService {
|
|
|
40
46
|
},
|
|
41
47
|
},
|
|
42
48
|
responseTransformer: {
|
|
43
|
-
dataPath: 'data',
|
|
49
|
+
dataPath: 'data', // GitHub API通常返回 { data: [...] }
|
|
44
50
|
success: (response) => response.data,
|
|
45
51
|
error: (error) => {
|
|
46
52
|
var _a, _b;
|
|
53
|
+
// GitHub API 错误处理
|
|
47
54
|
if ((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) {
|
|
48
55
|
throw new Error(`GitHub API Error: ${error.response.data.message}`);
|
|
49
56
|
}
|
|
@@ -55,10 +62,11 @@ let GitHubApiService = class GitHubApiService {
|
|
|
55
62
|
retries: 3,
|
|
56
63
|
retryCondition: (error) => {
|
|
57
64
|
var _a, _b;
|
|
65
|
+
// GitHub API 速率限制时重试
|
|
58
66
|
return (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 403 || ((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) === 429);
|
|
59
67
|
},
|
|
60
68
|
},
|
|
61
|
-
responseTimeWarningThreshold: 2000,
|
|
69
|
+
responseTimeWarningThreshold: 2000, // 2秒警告
|
|
62
70
|
tags: ['github', 'vcs'],
|
|
63
71
|
});
|
|
64
72
|
}
|
|
@@ -68,6 +76,9 @@ exports.GitHubApiService = GitHubApiService = __decorate([
|
|
|
68
76
|
(0, common_1.Injectable)(),
|
|
69
77
|
__metadata("design:paramtypes", [api_client_registry_service_1.ApiClientRegistryService])
|
|
70
78
|
], GitHubApiService);
|
|
79
|
+
/**
|
|
80
|
+
* Stripe API 客户端示例
|
|
81
|
+
*/
|
|
71
82
|
let StripeApiService = class StripeApiService {
|
|
72
83
|
constructor(apiRegistry) {
|
|
73
84
|
this.apiRegistry = apiRegistry;
|
|
@@ -94,13 +105,14 @@ let StripeApiService = class StripeApiService {
|
|
|
94
105
|
dataPath: 'data',
|
|
95
106
|
error: (error) => {
|
|
96
107
|
var _a, _b, _c;
|
|
108
|
+
// Stripe API 错误处理
|
|
97
109
|
if ((_c = (_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) {
|
|
98
110
|
throw new Error(`Stripe API Error: ${error.response.data.error.message}`);
|
|
99
111
|
}
|
|
100
112
|
throw error;
|
|
101
113
|
},
|
|
102
114
|
},
|
|
103
|
-
responseTimeWarningThreshold: 3000,
|
|
115
|
+
responseTimeWarningThreshold: 3000, // 3秒警告
|
|
104
116
|
tags: ['stripe', 'payment'],
|
|
105
117
|
});
|
|
106
118
|
}
|
|
@@ -110,6 +122,9 @@ exports.StripeApiService = StripeApiService = __decorate([
|
|
|
110
122
|
(0, common_1.Injectable)(),
|
|
111
123
|
__metadata("design:paramtypes", [api_client_registry_service_1.ApiClientRegistryService])
|
|
112
124
|
], StripeApiService);
|
|
125
|
+
/**
|
|
126
|
+
* 微信API客户端示例
|
|
127
|
+
*/
|
|
113
128
|
let WeChatApiService = class WeChatApiService {
|
|
114
129
|
constructor(apiRegistry) {
|
|
115
130
|
this.apiRegistry = apiRegistry;
|
|
@@ -123,10 +138,11 @@ let WeChatApiService = class WeChatApiService {
|
|
|
123
138
|
name: 'wechat',
|
|
124
139
|
baseURL: 'https://api.weixin.qq.com',
|
|
125
140
|
auth: {
|
|
126
|
-
type: api_client_registry_service_1.AuthType.NONE,
|
|
141
|
+
type: api_client_registry_service_1.AuthType.NONE, // 微信API通常使用签名验证
|
|
127
142
|
},
|
|
128
143
|
responseTransformer: {
|
|
129
144
|
success: (response) => {
|
|
145
|
+
// 微信API响应格式: { errcode: 0, errmsg: 'success', data: {...} }
|
|
130
146
|
if (response.data.errcode !== 0) {
|
|
131
147
|
throw new Error(`WeChat API Error (${response.data.errcode}): ${response.data.errmsg}`);
|
|
132
148
|
}
|
|
@@ -136,7 +152,7 @@ let WeChatApiService = class WeChatApiService {
|
|
|
136
152
|
tags: ['wechat', 'social'],
|
|
137
153
|
environments: {
|
|
138
154
|
development: {
|
|
139
|
-
baseURL: 'https://api.tunnel.com/wechat',
|
|
155
|
+
baseURL: 'https://api.tunnel.com/wechat', // 开发环境使用隧道
|
|
140
156
|
},
|
|
141
157
|
},
|
|
142
158
|
});
|
|
@@ -147,6 +163,9 @@ exports.WeChatApiService = WeChatApiService = __decorate([
|
|
|
147
163
|
(0, common_1.Injectable)(),
|
|
148
164
|
__metadata("design:paramtypes", [api_client_registry_service_1.ApiClientRegistryService])
|
|
149
165
|
], WeChatApiService);
|
|
166
|
+
/**
|
|
167
|
+
* 自定义API客户端示例(复杂响应格式)
|
|
168
|
+
*/
|
|
150
169
|
let CustomApiService = class CustomApiService {
|
|
151
170
|
constructor(apiRegistry) {
|
|
152
171
|
this.apiRegistry = apiRegistry;
|
|
@@ -164,6 +183,7 @@ let CustomApiService = class CustomApiService {
|
|
|
164
183
|
config: {
|
|
165
184
|
authenticator(config) {
|
|
166
185
|
return __awaiter(this, void 0, void 0, function* () {
|
|
186
|
+
// 自定义JWT token刷新逻辑
|
|
167
187
|
const token = yield this.getValidToken();
|
|
168
188
|
config.headers = Object.assign(Object.assign({}, config.headers), { Authorization: `Bearer ${token}`, 'X-Timestamp': Date.now().toString(), 'X-Signature': this.generateSignature(config) });
|
|
169
189
|
return config;
|
|
@@ -172,6 +192,7 @@ let CustomApiService = class CustomApiService {
|
|
|
172
192
|
refresher(config, error) {
|
|
173
193
|
return __awaiter(this, void 0, void 0, function* () {
|
|
174
194
|
var _a;
|
|
195
|
+
// Token过期时自动刷新
|
|
175
196
|
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
|
|
176
197
|
const newToken = yield this.refreshToken();
|
|
177
198
|
config.headers['Authorization'] = `Bearer ${newToken}`;
|
|
@@ -184,10 +205,13 @@ let CustomApiService = class CustomApiService {
|
|
|
184
205
|
},
|
|
185
206
|
responseTransformer: {
|
|
186
207
|
success: (response) => {
|
|
208
|
+
// 复杂响应格式处理
|
|
187
209
|
const result = response.data;
|
|
210
|
+
// 统一成功格式
|
|
188
211
|
if (result.success === false) {
|
|
189
212
|
throw new Error(result.message || 'API request failed');
|
|
190
213
|
}
|
|
214
|
+
// 数据包装处理
|
|
191
215
|
return {
|
|
192
216
|
data: result.data || result,
|
|
193
217
|
code: result.code || 0,
|
|
@@ -198,6 +222,7 @@ let CustomApiService = class CustomApiService {
|
|
|
198
222
|
},
|
|
199
223
|
error: (error) => {
|
|
200
224
|
var _a;
|
|
225
|
+
// 统一错误格式
|
|
201
226
|
if ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) {
|
|
202
227
|
const errorData = error.response.data;
|
|
203
228
|
const customError = new Error(errorData.message || 'API request failed');
|
|
@@ -216,6 +241,7 @@ let CustomApiService = class CustomApiService {
|
|
|
216
241
|
enabled: true,
|
|
217
242
|
retries: 2,
|
|
218
243
|
retryCondition: (error) => {
|
|
244
|
+
// 只对网络错误和5xx错误重试
|
|
219
245
|
if (!error.response)
|
|
220
246
|
return true;
|
|
221
247
|
return error.response.status >= 500;
|
|
@@ -226,15 +252,18 @@ let CustomApiService = class CustomApiService {
|
|
|
226
252
|
}
|
|
227
253
|
getValidToken() {
|
|
228
254
|
return __awaiter(this, void 0, void 0, function* () {
|
|
255
|
+
// 实现token获取逻辑
|
|
229
256
|
return 'mock-jwt-token';
|
|
230
257
|
});
|
|
231
258
|
}
|
|
232
259
|
refreshToken() {
|
|
233
260
|
return __awaiter(this, void 0, void 0, function* () {
|
|
261
|
+
// 实现token刷新逻辑
|
|
234
262
|
return 'refreshed-jwt-token';
|
|
235
263
|
});
|
|
236
264
|
}
|
|
237
265
|
generateSignature(config) {
|
|
266
|
+
// 实现签名生成逻辑
|
|
238
267
|
return 'mock-signature';
|
|
239
268
|
}
|
|
240
269
|
};
|
|
@@ -243,27 +272,48 @@ exports.CustomApiService = CustomApiService = __decorate([
|
|
|
243
272
|
(0, common_1.Injectable)(),
|
|
244
273
|
__metadata("design:paramtypes", [api_client_registry_service_1.ApiClientRegistryService])
|
|
245
274
|
], CustomApiService);
|
|
275
|
+
/**
|
|
276
|
+
* API管理服务示例
|
|
277
|
+
*/
|
|
246
278
|
let ApiManagementService = class ApiManagementService {
|
|
247
279
|
constructor(apiRegistry) {
|
|
248
280
|
this.apiRegistry = apiRegistry;
|
|
249
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* 动态创建API客户端
|
|
284
|
+
*/
|
|
250
285
|
createDynamicClient(name, config) {
|
|
251
286
|
return this.apiRegistry.createClient(Object.assign({ name, baseURL: config.baseURL || '' }, config));
|
|
252
287
|
}
|
|
288
|
+
/**
|
|
289
|
+
* 获取所有客户端统计信息
|
|
290
|
+
*/
|
|
253
291
|
getAllStats() {
|
|
254
292
|
return this.apiRegistry.getAllStats();
|
|
255
293
|
}
|
|
294
|
+
/**
|
|
295
|
+
* 重置所有统计信息
|
|
296
|
+
*/
|
|
256
297
|
resetAllStats() {
|
|
257
298
|
this.apiRegistry.resetAllStats();
|
|
258
299
|
}
|
|
300
|
+
/**
|
|
301
|
+
* 健康检查
|
|
302
|
+
*/
|
|
259
303
|
healthCheck() {
|
|
260
304
|
return __awaiter(this, void 0, void 0, function* () {
|
|
261
305
|
return this.apiRegistry.healthCheck();
|
|
262
306
|
});
|
|
263
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* 批量创建客户端
|
|
310
|
+
*/
|
|
264
311
|
createMultipleClients(configs) {
|
|
265
312
|
this.apiRegistry.createClients(configs);
|
|
266
313
|
}
|
|
314
|
+
/**
|
|
315
|
+
* 获取客户端列表
|
|
316
|
+
*/
|
|
267
317
|
listClients() {
|
|
268
318
|
return this.apiRegistry.listClients();
|
|
269
319
|
}
|
|
@@ -273,6 +323,9 @@ exports.ApiManagementService = ApiManagementService = __decorate([
|
|
|
273
323
|
(0, common_1.Injectable)(),
|
|
274
324
|
__metadata("design:paramtypes", [api_client_registry_service_1.ApiClientRegistryService])
|
|
275
325
|
], ApiManagementService);
|
|
326
|
+
/**
|
|
327
|
+
* 使用示例控制器
|
|
328
|
+
*/
|
|
276
329
|
let ExampleController = class ExampleController {
|
|
277
330
|
constructor(githubApi, stripeApi, wechatApi, customApi, apiManagement) {
|
|
278
331
|
this.githubApi = githubApi;
|
|
@@ -281,12 +334,18 @@ let ExampleController = class ExampleController {
|
|
|
281
334
|
this.customApi = customApi;
|
|
282
335
|
this.apiManagement = apiManagement;
|
|
283
336
|
}
|
|
337
|
+
/**
|
|
338
|
+
* GitHub API 示例
|
|
339
|
+
*/
|
|
284
340
|
getGitHubUser(username) {
|
|
285
341
|
return __awaiter(this, void 0, void 0, function* () {
|
|
286
342
|
const github = this.githubApi.github;
|
|
287
343
|
return github.get(`/users/${username}`);
|
|
288
344
|
});
|
|
289
345
|
}
|
|
346
|
+
/**
|
|
347
|
+
* Stripe API 示例
|
|
348
|
+
*/
|
|
290
349
|
createStripePayment(amount, currency) {
|
|
291
350
|
return __awaiter(this, void 0, void 0, function* () {
|
|
292
351
|
const stripe = this.stripeApi.stripe;
|
|
@@ -297,6 +356,9 @@ let ExampleController = class ExampleController {
|
|
|
297
356
|
});
|
|
298
357
|
});
|
|
299
358
|
}
|
|
359
|
+
/**
|
|
360
|
+
* 微信 API 示例
|
|
361
|
+
*/
|
|
300
362
|
sendWeChatMessage(openid, content) {
|
|
301
363
|
return __awaiter(this, void 0, void 0, function* () {
|
|
302
364
|
const wechat = this.wechatApi.wechat;
|
|
@@ -309,12 +371,18 @@ let ExampleController = class ExampleController {
|
|
|
309
371
|
});
|
|
310
372
|
});
|
|
311
373
|
}
|
|
374
|
+
/**
|
|
375
|
+
* 自定义API 示例
|
|
376
|
+
*/
|
|
312
377
|
getCustomData(id) {
|
|
313
378
|
return __awaiter(this, void 0, void 0, function* () {
|
|
314
379
|
const custom = this.customApi.customApi;
|
|
315
380
|
return custom.get(`/data/${id}`);
|
|
316
381
|
});
|
|
317
382
|
}
|
|
383
|
+
/**
|
|
384
|
+
* 动态API示例
|
|
385
|
+
*/
|
|
318
386
|
callDynamicApi(url) {
|
|
319
387
|
return __awaiter(this, void 0, void 0, function* () {
|
|
320
388
|
const client = this.apiManagement.createDynamicClient('dynamic', {
|
|
@@ -331,6 +399,9 @@ let ExampleController = class ExampleController {
|
|
|
331
399
|
return client.get('/');
|
|
332
400
|
});
|
|
333
401
|
}
|
|
402
|
+
/**
|
|
403
|
+
* API管理示例
|
|
404
|
+
*/
|
|
334
405
|
getApiHealth() {
|
|
335
406
|
return __awaiter(this, void 0, void 0, function* () {
|
|
336
407
|
return this.apiManagement.healthCheck();
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import { DynamicModule } from '@nestjs/common';
|
|
2
2
|
import { HttpClientConfig } from './interfaces/http-client-config.interface';
|
|
3
|
+
/**
|
|
4
|
+
* HTTP客户端模块
|
|
5
|
+
* 类似Spring Boot的自动配置机制,集成现有的cache服务
|
|
6
|
+
*/
|
|
3
7
|
export declare class HttpClientModule {
|
|
8
|
+
/**
|
|
9
|
+
* 动态注册HTTP客户端模块
|
|
10
|
+
*/
|
|
4
11
|
static forRoot(config?: HttpClientConfig): DynamicModule;
|
|
12
|
+
/**
|
|
13
|
+
* 异步注册HTTP客户端模块
|
|
14
|
+
*/
|
|
5
15
|
static forRootAsync(config: {
|
|
6
16
|
useFactory: (...args: any[]) => Promise<HttpClientConfig> | HttpClientConfig;
|
|
7
17
|
inject?: any[];
|
|
8
18
|
imports?: any[];
|
|
9
19
|
}): DynamicModule;
|
|
20
|
+
/**
|
|
21
|
+
* 从环境变量加载配置
|
|
22
|
+
*/
|
|
10
23
|
private static loadConfigFromEnvironment;
|
|
11
24
|
}
|
|
@@ -32,9 +32,17 @@ const api_client_registry_service_1 = require("./services/api-client-registry.se
|
|
|
32
32
|
const entities_1 = require("./entities");
|
|
33
33
|
const cache_options_interface_1 = require("../cache/interfaces/cache-options.interface");
|
|
34
34
|
const redis_lock_service_1 = require("../redis-lock/redis-lock.service");
|
|
35
|
+
/**
|
|
36
|
+
* HTTP客户端模块
|
|
37
|
+
* 类似Spring Boot的自动配置机制,集成现有的cache服务
|
|
38
|
+
*/
|
|
35
39
|
let HttpClientModule = HttpClientModule_1 = class HttpClientModule {
|
|
40
|
+
/**
|
|
41
|
+
* 动态注册HTTP客户端模块
|
|
42
|
+
*/
|
|
36
43
|
static forRoot(config = {}) {
|
|
37
44
|
var _a, _b, _c;
|
|
45
|
+
// 基础服务提供者
|
|
38
46
|
const baseProviders = [
|
|
39
47
|
{
|
|
40
48
|
provide: 'HTTP_CLIENT_CONFIG',
|
|
@@ -64,6 +72,7 @@ let HttpClientModule = HttpClientModule_1 = class HttpClientModule {
|
|
|
64
72
|
],
|
|
65
73
|
},
|
|
66
74
|
];
|
|
75
|
+
// 基础导出
|
|
67
76
|
const baseExports = [
|
|
68
77
|
http_client_service_1.HttpClientService,
|
|
69
78
|
circuit_breaker_service_1.HttpCircuitBreakerService,
|
|
@@ -73,6 +82,7 @@ let HttpClientModule = HttpClientModule_1 = class HttpClientModule {
|
|
|
73
82
|
log_cleanup_service_1.HttpLogCleanupService,
|
|
74
83
|
api_client_registry_service_1.ApiClientRegistryService,
|
|
75
84
|
];
|
|
85
|
+
// 动态导入
|
|
76
86
|
const dynamicImports = [config_1.ConfigModule];
|
|
77
87
|
if ((_b = (_a = config.logging) === null || _a === void 0 ? void 0 : _a.databaseLogging) === null || _b === void 0 ? void 0 : _b.enabled) {
|
|
78
88
|
dynamicImports.push(typeorm_1.TypeOrmModule.forFeature([entities_1.HttpLogEntity]));
|
|
@@ -87,7 +97,11 @@ let HttpClientModule = HttpClientModule_1 = class HttpClientModule {
|
|
|
87
97
|
exports: baseExports,
|
|
88
98
|
};
|
|
89
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* 异步注册HTTP客户端模块
|
|
102
|
+
*/
|
|
90
103
|
static forRootAsync(config) {
|
|
104
|
+
// 基础服务提供者
|
|
91
105
|
const baseProviders = [
|
|
92
106
|
{
|
|
93
107
|
provide: 'HTTP_CLIENT_CONFIG',
|
|
@@ -118,6 +132,7 @@ let HttpClientModule = HttpClientModule_1 = class HttpClientModule {
|
|
|
118
132
|
],
|
|
119
133
|
},
|
|
120
134
|
];
|
|
135
|
+
// 基础导出
|
|
121
136
|
const baseExports = [
|
|
122
137
|
http_client_service_1.HttpClientService,
|
|
123
138
|
circuit_breaker_service_1.HttpCircuitBreakerService,
|
|
@@ -127,6 +142,7 @@ let HttpClientModule = HttpClientModule_1 = class HttpClientModule {
|
|
|
127
142
|
log_cleanup_service_1.HttpLogCleanupService,
|
|
128
143
|
api_client_registry_service_1.ApiClientRegistryService,
|
|
129
144
|
];
|
|
145
|
+
// 动态导入
|
|
130
146
|
const dynamicImports = [config_1.ConfigModule, ...(config.imports || [])];
|
|
131
147
|
return {
|
|
132
148
|
module: HttpClientModule_1,
|
|
@@ -135,6 +151,9 @@ let HttpClientModule = HttpClientModule_1 = class HttpClientModule {
|
|
|
135
151
|
exports: baseExports,
|
|
136
152
|
};
|
|
137
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* 从环境变量加载配置
|
|
156
|
+
*/
|
|
138
157
|
static loadConfigFromEnvironment(configService) {
|
|
139
158
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
140
159
|
return {
|
package/http-client/index.js
CHANGED
|
@@ -16,12 +16,20 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.HttpLogEntity = void 0;
|
|
18
18
|
__exportStar(require("./interfaces/api-client-config.interface"), exports);
|
|
19
|
+
// 实体类
|
|
19
20
|
var entities_1 = require("./entities");
|
|
20
21
|
Object.defineProperty(exports, "HttpLogEntity", { enumerable: true, get: function () { return entities_1.HttpLogEntity; } });
|
|
22
|
+
// 装饰器
|
|
21
23
|
__exportStar(require("./decorators"), exports);
|
|
24
|
+
// 服务
|
|
22
25
|
__exportStar(require("./services"), exports);
|
|
26
|
+
// 工具类
|
|
23
27
|
__exportStar(require("./utils"), exports);
|
|
28
|
+
// 错误处理
|
|
24
29
|
__exportStar(require("./errors"), exports);
|
|
30
|
+
// 配置
|
|
25
31
|
__exportStar(require("./config"), exports);
|
|
32
|
+
// 模块
|
|
26
33
|
__exportStar(require("./http-client.module"), exports);
|
|
34
|
+
// 示例
|
|
27
35
|
__exportStar(require("./examples"), exports);
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
2
|
import { HttpClientConfig } from './http-client-config.interface';
|
|
3
|
+
/**
|
|
4
|
+
* 鉴权类型枚举
|
|
5
|
+
*/
|
|
3
6
|
export declare enum AuthType {
|
|
4
7
|
NONE = "none",
|
|
5
8
|
API_KEY = "apiKey",
|
|
@@ -8,20 +11,32 @@ export declare enum AuthType {
|
|
|
8
11
|
OAUTH2 = "oauth2",
|
|
9
12
|
CUSTOM = "custom"
|
|
10
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* API密钥配置
|
|
16
|
+
*/
|
|
11
17
|
export interface ApiKeyConfig {
|
|
12
18
|
key: string;
|
|
13
19
|
location: 'header' | 'query';
|
|
14
20
|
name?: string;
|
|
15
21
|
prefix?: string;
|
|
16
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Bearer Token配置
|
|
25
|
+
*/
|
|
17
26
|
export interface BearerTokenConfig {
|
|
18
27
|
token: string;
|
|
19
28
|
scheme?: string;
|
|
20
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* 基础认证配置
|
|
32
|
+
*/
|
|
21
33
|
export interface BasicAuthConfig {
|
|
22
34
|
username: string;
|
|
23
35
|
password: string;
|
|
24
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* OAuth2配置
|
|
39
|
+
*/
|
|
25
40
|
export interface OAuth2Config {
|
|
26
41
|
clientId: string;
|
|
27
42
|
clientSecret: string;
|
|
@@ -33,10 +48,22 @@ export interface OAuth2Config {
|
|
|
33
48
|
redirectUri?: string;
|
|
34
49
|
refreshToken?: string;
|
|
35
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* 自定义鉴权配置
|
|
53
|
+
*/
|
|
36
54
|
export interface CustomAuthConfig {
|
|
55
|
+
/**
|
|
56
|
+
* 自定义鉴权函数
|
|
57
|
+
*/
|
|
37
58
|
authenticator: (config: AxiosRequestConfig) => Promise<AxiosRequestConfig>;
|
|
59
|
+
/**
|
|
60
|
+
* 刷新token函数
|
|
61
|
+
*/
|
|
38
62
|
refresher?: (config: AxiosRequestConfig, error: any) => Promise<AxiosRequestConfig>;
|
|
39
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* 鉴权配置
|
|
66
|
+
*/
|
|
40
67
|
export type AuthConfig = {
|
|
41
68
|
type: AuthType.NONE;
|
|
42
69
|
} | {
|
|
@@ -55,98 +82,196 @@ export type AuthConfig = {
|
|
|
55
82
|
type: AuthType.CUSTOM;
|
|
56
83
|
config: CustomAuthConfig;
|
|
57
84
|
};
|
|
85
|
+
/**
|
|
86
|
+
* 响应转换器配置
|
|
87
|
+
*/
|
|
58
88
|
export interface ResponseTransformerConfig {
|
|
89
|
+
/**
|
|
90
|
+
* 成功响应转换器
|
|
91
|
+
*/
|
|
59
92
|
success?: (response: AxiosResponse) => any;
|
|
93
|
+
/**
|
|
94
|
+
* 错误响应转换器
|
|
95
|
+
*/
|
|
60
96
|
error?: (error: any) => any;
|
|
97
|
+
/**
|
|
98
|
+
* 响应数据提取路径
|
|
99
|
+
* 例如 'data.items' 表示从 response.data.items 获取数据
|
|
100
|
+
*/
|
|
61
101
|
dataPath?: string;
|
|
102
|
+
/**
|
|
103
|
+
* 错误信息提取路径
|
|
104
|
+
* 例如 'error.message' 表示从 error.response.data.error.message 获取错误信息
|
|
105
|
+
*/
|
|
62
106
|
errorPath?: string;
|
|
107
|
+
/**
|
|
108
|
+
* 是否自动验证响应格式
|
|
109
|
+
*/
|
|
63
110
|
validateResponse?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* 响应格式验证器
|
|
113
|
+
*/
|
|
64
114
|
validator?: (data: any) => boolean;
|
|
65
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* API客户端配置
|
|
118
|
+
*/
|
|
66
119
|
export interface ApiClientConfig {
|
|
120
|
+
/** API名称(用于标识和日志) */
|
|
67
121
|
name: string;
|
|
122
|
+
/** 基础URL */
|
|
68
123
|
baseURL: string;
|
|
124
|
+
/** HTTP客户端基础配置 */
|
|
69
125
|
httpConfig?: HttpClientConfig;
|
|
126
|
+
/** 鉴权配置 */
|
|
70
127
|
auth?: AuthConfig;
|
|
128
|
+
/** 响应转换配置 */
|
|
71
129
|
responseTransformer?: ResponseTransformerConfig;
|
|
130
|
+
/** 默认请求头 */
|
|
72
131
|
defaultHeaders?: Record<string, string>;
|
|
132
|
+
/** 默认查询参数 */
|
|
73
133
|
defaultParams?: Record<string, any>;
|
|
134
|
+
/** 拦截器配置 */
|
|
74
135
|
interceptors?: {
|
|
75
136
|
request?: Array<(config: AxiosRequestConfig) => AxiosRequestConfig | Promise<AxiosRequestConfig>>;
|
|
76
137
|
response?: Array<(response: AxiosResponse) => AxiosResponse | Promise<AxiosResponse>>;
|
|
77
138
|
error?: Array<(error: any) => any>;
|
|
78
139
|
};
|
|
140
|
+
/** 重试配置(覆盖全局配置) */
|
|
79
141
|
retry?: {
|
|
80
142
|
enabled?: boolean;
|
|
81
143
|
retries?: number;
|
|
82
144
|
retryCondition?: (error: any) => boolean;
|
|
83
145
|
};
|
|
146
|
+
/** 是否启用响应验证 */
|
|
84
147
|
enableValidation?: boolean;
|
|
148
|
+
/** 响应时间警告阈值(毫秒) */
|
|
85
149
|
responseTimeWarningThreshold?: number;
|
|
150
|
+
/** 自定义标签(用于分类和查询) */
|
|
86
151
|
tags?: string[];
|
|
152
|
+
/** 是否启用详细日志 */
|
|
87
153
|
enableDetailedLogging?: boolean;
|
|
88
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* API客户端实例配置
|
|
157
|
+
*/
|
|
89
158
|
export interface ApiClientInstanceConfig extends ApiClientConfig {
|
|
159
|
+
/** 是否覆盖现有配置 */
|
|
90
160
|
override?: boolean;
|
|
161
|
+
/** 环境特定配置 */
|
|
91
162
|
environments?: {
|
|
92
163
|
development?: Partial<ApiClientConfig>;
|
|
93
164
|
staging?: Partial<ApiClientConfig>;
|
|
94
165
|
production?: Partial<ApiClientConfig>;
|
|
95
166
|
};
|
|
96
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* API客户端注册配置
|
|
170
|
+
*/
|
|
97
171
|
export interface ApiClientRegistryConfig {
|
|
172
|
+
/** 全局默认配置 */
|
|
98
173
|
globalDefaults?: Partial<HttpClientConfig>;
|
|
174
|
+
/** 日志清理配置 */
|
|
99
175
|
logCleanup?: {
|
|
100
176
|
enabled?: boolean;
|
|
101
177
|
retentionDays?: number;
|
|
102
178
|
maxRecords?: number;
|
|
103
179
|
};
|
|
180
|
+
/** 默认响应转换器 */
|
|
104
181
|
defaultResponseTransformer?: ResponseTransformerConfig;
|
|
182
|
+
/** 是否启用自动重试 */
|
|
105
183
|
enableGlobalRetry?: boolean;
|
|
184
|
+
/** 是否启用熔断器 */
|
|
106
185
|
enableCircuitBreaker?: boolean;
|
|
107
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* API客户端工厂接口
|
|
189
|
+
*/
|
|
108
190
|
export interface ApiClientFactory {
|
|
191
|
+
/**
|
|
192
|
+
* 创建API客户端实例
|
|
193
|
+
*/
|
|
109
194
|
createClient<T = any>(config: ApiClientInstanceConfig): T;
|
|
195
|
+
/**
|
|
196
|
+
* 获取已注册的客户端
|
|
197
|
+
*/
|
|
110
198
|
getClient<T = any>(name: string): T;
|
|
199
|
+
/**
|
|
200
|
+
* 列出所有已注册的客户端
|
|
201
|
+
*/
|
|
111
202
|
listClients(): string[];
|
|
203
|
+
/**
|
|
204
|
+
* 更新客户端配置
|
|
205
|
+
*/
|
|
112
206
|
updateClient(name: string, config: Partial<ApiClientConfig>): void;
|
|
207
|
+
/**
|
|
208
|
+
* 移除客户端
|
|
209
|
+
*/
|
|
113
210
|
removeClient(name: string): void;
|
|
114
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* API客户端接口
|
|
214
|
+
*/
|
|
115
215
|
export interface ApiClient {
|
|
216
|
+
/** 客户端名称 */
|
|
116
217
|
name: string;
|
|
218
|
+
/** 客户端配置 */
|
|
117
219
|
config: ApiClientConfig;
|
|
220
|
+
/** 基础HTTP请求方法 */
|
|
118
221
|
get<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
119
222
|
post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
|
|
120
223
|
put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
|
|
121
224
|
patch<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
|
|
122
225
|
delete<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
226
|
+
/** 通用请求方法 */
|
|
123
227
|
request<T = any>(config: AxiosRequestConfig): Promise<T>;
|
|
228
|
+
/** 获取客户端统计信息 */
|
|
124
229
|
getStats(): any;
|
|
230
|
+
/** 重置统计信息 */
|
|
125
231
|
resetStats(): void;
|
|
126
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* 通用API响应格式
|
|
235
|
+
*/
|
|
127
236
|
export interface ApiResponse<T = any> {
|
|
237
|
+
/** 响应数据 */
|
|
128
238
|
data?: T;
|
|
239
|
+
/** 响应代码 */
|
|
129
240
|
code?: number;
|
|
241
|
+
/** 响应消息 */
|
|
130
242
|
message?: string;
|
|
243
|
+
/** 成功标识 */
|
|
131
244
|
success?: boolean;
|
|
245
|
+
/** 错误详情 */
|
|
132
246
|
error?: {
|
|
133
247
|
code?: string;
|
|
134
248
|
message?: string;
|
|
135
249
|
details?: any;
|
|
136
250
|
};
|
|
251
|
+
/** 分页信息 */
|
|
137
252
|
pagination?: {
|
|
138
253
|
page?: number;
|
|
139
254
|
pageSize?: number;
|
|
140
255
|
total?: number;
|
|
141
256
|
totalPages?: number;
|
|
142
257
|
};
|
|
258
|
+
/** 请求ID */
|
|
143
259
|
requestId?: string;
|
|
260
|
+
/** 时间戳 */
|
|
144
261
|
timestamp?: string;
|
|
145
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* 错误响应格式
|
|
265
|
+
*/
|
|
146
266
|
export interface ErrorResponse {
|
|
267
|
+
/** 错误代码 */
|
|
147
268
|
code: string | number;
|
|
269
|
+
/** 错误消息 */
|
|
148
270
|
message: string;
|
|
271
|
+
/** 错误详情 */
|
|
149
272
|
details?: any;
|
|
273
|
+
/** 堆栈信息 */
|
|
150
274
|
stack?: string;
|
|
275
|
+
/** 请求ID */
|
|
151
276
|
requestId?: string;
|
|
152
277
|
}
|