@dommaker/harness 0.7.2 → 0.7.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/README.md +390 -5
- package/dist/architecture/constraint-engine.d.ts +49 -0
- package/dist/architecture/constraint-engine.d.ts.map +1 -0
- package/dist/architecture/constraint-engine.js +207 -0
- package/dist/architecture/constraint-engine.js.map +1 -0
- package/dist/architecture/cross-project-checker.d.ts +34 -0
- package/dist/architecture/cross-project-checker.d.ts.map +1 -0
- package/dist/architecture/cross-project-checker.js +260 -0
- package/dist/architecture/cross-project-checker.js.map +1 -0
- package/dist/context/progressive-loader.d.ts +110 -0
- package/dist/context/progressive-loader.d.ts.map +1 -0
- package/dist/context/progressive-loader.js +183 -0
- package/dist/context/progressive-loader.js.map +1 -0
- package/dist/context/token-budget.d.ts +144 -0
- package/dist/context/token-budget.d.ts.map +1 -0
- package/dist/context/token-budget.js +264 -0
- package/dist/context/token-budget.js.map +1 -0
- package/dist/core/constraints/definitions.d.ts.map +1 -1
- package/dist/core/constraints/definitions.js +33 -0
- package/dist/core/constraints/definitions.js.map +1 -1
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +4 -0
- package/dist/core/index.js.map +1 -1
- package/dist/failure/classifier.d.ts +63 -0
- package/dist/failure/classifier.d.ts.map +1 -0
- package/dist/failure/classifier.js +123 -0
- package/dist/failure/classifier.js.map +1 -0
- package/dist/failure/index.d.ts +10 -0
- package/dist/failure/index.d.ts.map +1 -0
- package/dist/failure/index.js +36 -0
- package/dist/failure/index.js.map +1 -0
- package/dist/failure/recorder.d.ts +78 -0
- package/dist/failure/recorder.d.ts.map +1 -0
- package/dist/failure/recorder.js +193 -0
- package/dist/failure/recorder.js.map +1 -0
- package/dist/failure/types.d.ts +89 -0
- package/dist/failure/types.d.ts.map +1 -0
- package/dist/failure/types.js +121 -0
- package/dist/failure/types.js.map +1 -0
- package/dist/gates/acceptance.d.ts +159 -0
- package/dist/gates/acceptance.d.ts.map +1 -0
- package/dist/gates/acceptance.js +368 -0
- package/dist/gates/acceptance.js.map +1 -0
- package/dist/gates/contract.d.ts +41 -0
- package/dist/gates/contract.d.ts.map +1 -0
- package/dist/gates/contract.js +264 -0
- package/dist/gates/contract.js.map +1 -0
- package/dist/gates/index.d.ts +23 -0
- package/dist/gates/index.d.ts.map +1 -0
- package/dist/gates/index.js +46 -0
- package/dist/gates/index.js.map +1 -0
- package/dist/gates/performance.d.ts +81 -0
- package/dist/gates/performance.d.ts.map +1 -0
- package/dist/gates/performance.js +336 -0
- package/dist/gates/performance.js.map +1 -0
- package/dist/gates/review.d.ts +37 -0
- package/dist/gates/review.d.ts.map +1 -0
- package/dist/gates/review.js +149 -0
- package/dist/gates/review.js.map +1 -0
- package/dist/gates/security.d.ts +45 -0
- package/dist/gates/security.d.ts.map +1 -0
- package/dist/gates/security.js +221 -0
- package/dist/gates/security.js.map +1 -0
- package/dist/gates/types.d.ts +115 -0
- package/dist/gates/types.d.ts.map +1 -0
- package/dist/gates/types.js +6 -0
- package/dist/gates/types.js.map +1 -0
- package/dist/index.d.ts +15 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -5
- package/dist/index.js.map +1 -1
- package/dist/monitoring/index.d.ts +6 -0
- package/dist/monitoring/index.d.ts.map +1 -1
- package/dist/monitoring/index.js +6 -0
- package/dist/monitoring/index.js.map +1 -1
- package/dist/monitoring/performance-analyzer.d.ts +104 -0
- package/dist/monitoring/performance-analyzer.d.ts.map +1 -0
- package/dist/monitoring/performance-analyzer.js +417 -0
- package/dist/monitoring/performance-analyzer.js.map +1 -0
- package/dist/monitoring/performance-collector.d.ts +111 -0
- package/dist/monitoring/performance-collector.d.ts.map +1 -0
- package/dist/monitoring/performance-collector.js +319 -0
- package/dist/monitoring/performance-collector.js.map +1 -0
- package/dist/monitoring/trace-analyzer.js +1 -1
- package/dist/monitoring/trace-analyzer.js.map +1 -1
- package/dist/monitoring/traces.js +1 -1
- package/dist/monitoring/traces.js.map +1 -1
- package/dist/presets/index.d.ts +0 -1
- package/dist/presets/index.d.ts.map +1 -1
- package/dist/presets/index.js +1 -6
- package/dist/presets/index.js.map +1 -1
- package/dist/spec/annotation-checker.d.ts +47 -0
- package/dist/spec/annotation-checker.d.ts.map +1 -0
- package/dist/spec/annotation-checker.js +299 -0
- package/dist/spec/annotation-checker.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +9 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/performance.d.ts +204 -0
- package/dist/types/performance.d.ts.map +1 -0
- package/dist/types/performance.js +12 -0
- package/dist/types/performance.js.map +1 -0
- package/package.json +3 -1
- package/dist/extensions/long-running/constraints.d.ts +0 -38
- package/dist/extensions/long-running/constraints.d.ts.map +0 -1
- package/dist/extensions/long-running/constraints.js +0 -153
- package/dist/extensions/long-running/constraints.js.map +0 -1
- package/dist/extensions/long-running/index.d.ts +0 -30
- package/dist/extensions/long-running/index.d.ts.map +0 -1
- package/dist/extensions/long-running/index.js +0 -50
- package/dist/extensions/long-running/index.js.map +0 -1
- package/dist/extensions/long-running/types.d.ts +0 -154
- package/dist/extensions/long-running/types.d.ts.map +0 -1
- package/dist/extensions/long-running/types.js +0 -9
- package/dist/extensions/long-running/types.js.map +0 -1
- package/dist/presets/long-running.d.ts +0 -33
- package/dist/presets/long-running.d.ts.map +0 -1
- package/dist/presets/long-running.js +0 -52
- package/dist/presets/long-running.js.map +0 -1
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* 契约门禁
|
|
4
|
+
*
|
|
5
|
+
* 检查 API 契约:
|
|
6
|
+
* - OpenAPI Schema 验证
|
|
7
|
+
* - 破坏性变更检测
|
|
8
|
+
* - 版本兼容性
|
|
9
|
+
*/
|
|
10
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
17
|
+
}) : (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
o[k2] = m[k];
|
|
20
|
+
}));
|
|
21
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
22
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
23
|
+
}) : function(o, v) {
|
|
24
|
+
o["default"] = v;
|
|
25
|
+
});
|
|
26
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
27
|
+
var ownKeys = function(o) {
|
|
28
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
29
|
+
var ar = [];
|
|
30
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
31
|
+
return ar;
|
|
32
|
+
};
|
|
33
|
+
return ownKeys(o);
|
|
34
|
+
};
|
|
35
|
+
return function (mod) {
|
|
36
|
+
if (mod && mod.__esModule) return mod;
|
|
37
|
+
var result = {};
|
|
38
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
39
|
+
__setModuleDefault(result, mod);
|
|
40
|
+
return result;
|
|
41
|
+
};
|
|
42
|
+
})();
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.ContractGate = void 0;
|
|
45
|
+
const child_process_1 = require("child_process");
|
|
46
|
+
const util_1 = require("util");
|
|
47
|
+
const fs = __importStar(require("fs/promises"));
|
|
48
|
+
const path = __importStar(require("path"));
|
|
49
|
+
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
50
|
+
/**
|
|
51
|
+
* 契约门禁
|
|
52
|
+
*/
|
|
53
|
+
class ContractGate {
|
|
54
|
+
config;
|
|
55
|
+
constructor(config = {}) {
|
|
56
|
+
this.config = {
|
|
57
|
+
enabled: config.enabled ?? true,
|
|
58
|
+
strict: config.strict ?? true,
|
|
59
|
+
allowBreakingChanges: config.allowBreakingChanges ?? false,
|
|
60
|
+
contractPath: config.contractPath ?? 'openapi.yaml',
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* 检查契约
|
|
65
|
+
*/
|
|
66
|
+
async check(context) {
|
|
67
|
+
const startTime = Date.now();
|
|
68
|
+
if (!this.config.enabled) {
|
|
69
|
+
return {
|
|
70
|
+
gate: 'contract',
|
|
71
|
+
passed: true,
|
|
72
|
+
message: '契约门禁已禁用',
|
|
73
|
+
timestamp: new Date().toISOString(),
|
|
74
|
+
duration: Date.now() - startTime,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
const contractPath = context.newContractPath ??
|
|
79
|
+
path.join(context.projectPath, this.config.contractPath);
|
|
80
|
+
// 检查契约文件是否存在
|
|
81
|
+
try {
|
|
82
|
+
await fs.access(contractPath);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return {
|
|
86
|
+
gate: 'contract',
|
|
87
|
+
passed: true,
|
|
88
|
+
message: '未找到契约文件,跳过检查',
|
|
89
|
+
details: {
|
|
90
|
+
contractPath,
|
|
91
|
+
suggestion: '创建 OpenAPI 规范文件',
|
|
92
|
+
},
|
|
93
|
+
timestamp: new Date().toISOString(),
|
|
94
|
+
duration: Date.now() - startTime,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
// 验证契约格式
|
|
98
|
+
const validation = await this.validateContract(contractPath);
|
|
99
|
+
if (!validation.valid) {
|
|
100
|
+
return {
|
|
101
|
+
gate: 'contract',
|
|
102
|
+
passed: false,
|
|
103
|
+
message: `契约格式无效: ${validation.errors.join(', ')}`,
|
|
104
|
+
details: {
|
|
105
|
+
contractPath,
|
|
106
|
+
errors: validation.errors,
|
|
107
|
+
},
|
|
108
|
+
timestamp: new Date().toISOString(),
|
|
109
|
+
duration: Date.now() - startTime,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
// 检查破坏性变更(如果提供了旧契约)
|
|
113
|
+
if (context.oldContractPath) {
|
|
114
|
+
const breakingChanges = await this.detectBreakingChanges(context.oldContractPath, contractPath);
|
|
115
|
+
if (breakingChanges.length > 0 && !this.config.allowBreakingChanges) {
|
|
116
|
+
return {
|
|
117
|
+
gate: 'contract',
|
|
118
|
+
passed: false,
|
|
119
|
+
message: `发现破坏性变更: ${breakingChanges.length} 个`,
|
|
120
|
+
details: {
|
|
121
|
+
contractPath,
|
|
122
|
+
oldContractPath: context.oldContractPath,
|
|
123
|
+
breakingChanges,
|
|
124
|
+
suggestion: '更新 API 版本或保持向后兼容',
|
|
125
|
+
},
|
|
126
|
+
timestamp: new Date().toISOString(),
|
|
127
|
+
duration: Date.now() - startTime,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
gate: 'contract',
|
|
133
|
+
passed: true,
|
|
134
|
+
message: '契约检查通过',
|
|
135
|
+
details: {
|
|
136
|
+
contractPath,
|
|
137
|
+
endpoints: validation.endpoints,
|
|
138
|
+
version: validation.version,
|
|
139
|
+
},
|
|
140
|
+
timestamp: new Date().toISOString(),
|
|
141
|
+
duration: Date.now() - startTime,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
return {
|
|
146
|
+
gate: 'contract',
|
|
147
|
+
passed: false,
|
|
148
|
+
message: `契约检查失败: ${error.message}`,
|
|
149
|
+
timestamp: new Date().toISOString(),
|
|
150
|
+
duration: Date.now() - startTime,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* 验证契约格式
|
|
156
|
+
*/
|
|
157
|
+
async validateContract(contractPath) {
|
|
158
|
+
const errors = [];
|
|
159
|
+
let endpoints = 0;
|
|
160
|
+
let version;
|
|
161
|
+
try {
|
|
162
|
+
const content = await fs.readFile(contractPath, 'utf-8');
|
|
163
|
+
let spec;
|
|
164
|
+
// 解析 YAML 或 JSON
|
|
165
|
+
if (contractPath.endsWith('.yaml') || contractPath.endsWith('.yml')) {
|
|
166
|
+
// 简化的 YAML 解析(只提取基本信息)
|
|
167
|
+
const lines = content.split('\n');
|
|
168
|
+
for (const line of lines) {
|
|
169
|
+
if (line.startsWith('openapi:') || line.startsWith('swagger:')) {
|
|
170
|
+
version = line.split(':')[1]?.trim();
|
|
171
|
+
}
|
|
172
|
+
if (line.match(/^\s*\/\w+/)) {
|
|
173
|
+
endpoints++;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
spec = JSON.parse(content);
|
|
179
|
+
version = spec.openapi || spec.swagger;
|
|
180
|
+
if (spec.paths) {
|
|
181
|
+
endpoints = Object.keys(spec.paths).length;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// 基本验证
|
|
185
|
+
if (!version) {
|
|
186
|
+
errors.push('缺少 openapi/swagger 版本');
|
|
187
|
+
}
|
|
188
|
+
if (endpoints === 0) {
|
|
189
|
+
errors.push('没有定义任何端点');
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
valid: errors.length === 0,
|
|
193
|
+
errors,
|
|
194
|
+
endpoints,
|
|
195
|
+
version,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
return {
|
|
200
|
+
valid: false,
|
|
201
|
+
errors: [`解析失败: ${error.message}`],
|
|
202
|
+
endpoints: 0,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* 检测破坏性变更
|
|
208
|
+
*/
|
|
209
|
+
async detectBreakingChanges(oldPath, newPath) {
|
|
210
|
+
const changes = [];
|
|
211
|
+
try {
|
|
212
|
+
const oldContent = await fs.readFile(oldPath, 'utf-8');
|
|
213
|
+
const newContent = await fs.readFile(newPath, 'utf-8');
|
|
214
|
+
// 提取端点列表
|
|
215
|
+
const oldEndpoints = this.extractEndpoints(oldContent);
|
|
216
|
+
const newEndpoints = this.extractEndpoints(newContent);
|
|
217
|
+
// 检查删除的端点
|
|
218
|
+
for (const endpoint of oldEndpoints) {
|
|
219
|
+
if (!newEndpoints.includes(endpoint)) {
|
|
220
|
+
changes.push({
|
|
221
|
+
type: 'endpoint_removed',
|
|
222
|
+
description: `端点 ${endpoint} 已删除`,
|
|
223
|
+
path: endpoint,
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
// 检查新增的端点(不是破坏性变更)
|
|
228
|
+
// 检查方法变更
|
|
229
|
+
// 简化实现,实际应该完整比较
|
|
230
|
+
return changes;
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
return [];
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* 提取端点列表
|
|
238
|
+
*/
|
|
239
|
+
extractEndpoints(content) {
|
|
240
|
+
const endpoints = [];
|
|
241
|
+
const lines = content.split('\n');
|
|
242
|
+
for (const line of lines) {
|
|
243
|
+
const match = line.match(/^\s*\/[\w/-]+:/);
|
|
244
|
+
if (match) {
|
|
245
|
+
endpoints.push(match[0].replace(':', '').trim());
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return endpoints;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* 设置契约路径
|
|
252
|
+
*/
|
|
253
|
+
setContractPath(path) {
|
|
254
|
+
this.config.contractPath = path;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* 获取配置
|
|
258
|
+
*/
|
|
259
|
+
getConfig() {
|
|
260
|
+
return { ...this.config };
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
exports.ContractGate = ContractGate;
|
|
264
|
+
//# sourceMappingURL=contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/gates/contract.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iDAAqC;AACrC,+BAAiC;AACjC,gDAAkC;AAClC,2CAA6B;AAG7B,MAAM,SAAS,GAAG,IAAA,gBAAS,EAAC,oBAAI,CAAC,CAAC;AAElC;;GAEG;AACH,MAAa,YAAY;IACf,MAAM,CAA+B;IAE7C,YAAY,SAAsC,EAAE;QAClD,IAAI,CAAC,MAAM,GAAG;YACZ,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,IAAI;YAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,IAAI;YAC7B,oBAAoB,EAAE,MAAM,CAAC,oBAAoB,IAAI,KAAK;YAC1D,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,cAAc;SACpD,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK,CAAC,OAAoB;QAC9B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAE7B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACzB,OAAO;gBACL,IAAI,EAAE,UAAU;gBAChB,MAAM,EAAE,IAAI;gBACZ,OAAO,EAAE,SAAS;gBAClB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACnC,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;aACjC,CAAC;QACJ,CAAC;QAED,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,OAAO,CAAC,eAAe;gBAC1C,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;YAE3D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BAAgB,CAAC,CAAC;YAC3C,IAAI,KAAK,EAAE,CAAC;gBACV,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,eAAe,CAAC,IAAY;QAC1B,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC5B,CAAC;CACF;AAlPD,oCAkPC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 门禁系统导出
|
|
3
|
+
*
|
|
4
|
+
* 统一导出所有门禁类型
|
|
5
|
+
*/
|
|
6
|
+
export type { GateResult, GateContext, PerformanceThresholds, ReviewGateConfig, SecurityGateConfig, PerformanceGateConfig, ContractGateConfig, SpecAcceptanceGateConfig, AcceptanceGateContext, AcceptanceCriteria, } from './types';
|
|
7
|
+
export { ReviewGate } from './review';
|
|
8
|
+
export { SecurityGate } from './security';
|
|
9
|
+
export { PerformanceGate } from './performance';
|
|
10
|
+
export { ContractGate } from './contract';
|
|
11
|
+
export { SpecAcceptanceGate } from './acceptance';
|
|
12
|
+
import { ReviewGate } from './review';
|
|
13
|
+
import { SecurityGate } from './security';
|
|
14
|
+
import { PerformanceGate } from './performance';
|
|
15
|
+
import { ContractGate } from './contract';
|
|
16
|
+
import { SpecAcceptanceGate } from './acceptance';
|
|
17
|
+
import type { ReviewGateConfig, SecurityGateConfig, PerformanceGateConfig, ContractGateConfig, SpecAcceptanceGateConfig } from './types';
|
|
18
|
+
export declare function createReviewGate(config?: Partial<ReviewGateConfig>): ReviewGate;
|
|
19
|
+
export declare function createSecurityGate(config?: Partial<SecurityGateConfig>): SecurityGate;
|
|
20
|
+
export declare function createPerformanceGate(config?: Partial<PerformanceGateConfig>): PerformanceGate;
|
|
21
|
+
export declare function createContractGate(config?: Partial<ContractGateConfig>): ContractGate;
|
|
22
|
+
export declare function createSpecAcceptanceGate(config?: Partial<SpecAcceptanceGateConfig>): SpecAcceptanceGate;
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gates/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EACV,UAAU,EACV,WAAW,EACX,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAEjB,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,UAAU,CAE/E;AAED,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG,YAAY,CAErF;AAED,wBAAgB,qBAAqB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,GAAG,eAAe,CAE9F;AAED,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG,YAAY,CAErF;AAED,wBAAgB,wBAAwB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,GAAG,kBAAkB,CAEvG"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* 门禁系统导出
|
|
4
|
+
*
|
|
5
|
+
* 统一导出所有门禁类型
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.SpecAcceptanceGate = exports.ContractGate = exports.PerformanceGate = exports.SecurityGate = exports.ReviewGate = void 0;
|
|
9
|
+
exports.createReviewGate = createReviewGate;
|
|
10
|
+
exports.createSecurityGate = createSecurityGate;
|
|
11
|
+
exports.createPerformanceGate = createPerformanceGate;
|
|
12
|
+
exports.createContractGate = createContractGate;
|
|
13
|
+
exports.createSpecAcceptanceGate = createSpecAcceptanceGate;
|
|
14
|
+
// 门禁类导出
|
|
15
|
+
var review_1 = require("./review");
|
|
16
|
+
Object.defineProperty(exports, "ReviewGate", { enumerable: true, get: function () { return review_1.ReviewGate; } });
|
|
17
|
+
var security_1 = require("./security");
|
|
18
|
+
Object.defineProperty(exports, "SecurityGate", { enumerable: true, get: function () { return security_1.SecurityGate; } });
|
|
19
|
+
var performance_1 = require("./performance");
|
|
20
|
+
Object.defineProperty(exports, "PerformanceGate", { enumerable: true, get: function () { return performance_1.PerformanceGate; } });
|
|
21
|
+
var contract_1 = require("./contract");
|
|
22
|
+
Object.defineProperty(exports, "ContractGate", { enumerable: true, get: function () { return contract_1.ContractGate; } });
|
|
23
|
+
var acceptance_1 = require("./acceptance");
|
|
24
|
+
Object.defineProperty(exports, "SpecAcceptanceGate", { enumerable: true, get: function () { return acceptance_1.SpecAcceptanceGate; } });
|
|
25
|
+
// 便捷工厂函数
|
|
26
|
+
const review_2 = require("./review");
|
|
27
|
+
const security_2 = require("./security");
|
|
28
|
+
const performance_2 = require("./performance");
|
|
29
|
+
const contract_2 = require("./contract");
|
|
30
|
+
const acceptance_2 = require("./acceptance");
|
|
31
|
+
function createReviewGate(config) {
|
|
32
|
+
return new review_2.ReviewGate(config);
|
|
33
|
+
}
|
|
34
|
+
function createSecurityGate(config) {
|
|
35
|
+
return new security_2.SecurityGate(config);
|
|
36
|
+
}
|
|
37
|
+
function createPerformanceGate(config) {
|
|
38
|
+
return new performance_2.PerformanceGate(config);
|
|
39
|
+
}
|
|
40
|
+
function createContractGate(config) {
|
|
41
|
+
return new contract_2.ContractGate(config);
|
|
42
|
+
}
|
|
43
|
+
function createSpecAcceptanceGate(config) {
|
|
44
|
+
return new acceptance_2.SpecAcceptanceGate(config);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gates/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAqCH,4CAEC;AAED,gDAEC;AAED,sDAEC;AAED,gDAEC;AAED,4DAEC;AAvCD,QAAQ;AACR,mCAAsC;AAA7B,oGAAA,UAAU,OAAA;AACnB,uCAA0C;AAAjC,wGAAA,YAAY,OAAA;AACrB,6CAAgD;AAAvC,8GAAA,eAAe,OAAA;AACxB,uCAA0C;AAAjC,wGAAA,YAAY,OAAA;AACrB,2CAAkD;AAAzC,gHAAA,kBAAkB,OAAA;AAE3B,SAAS;AACT,qCAAsC;AACtC,yCAA0C;AAC1C,+CAAgD;AAChD,yCAA0C;AAC1C,6CAAkD;AASlD,SAAgB,gBAAgB,CAAC,MAAkC;IACjE,OAAO,IAAI,mBAAU,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC;AAED,SAAgB,kBAAkB,CAAC,MAAoC;IACrE,OAAO,IAAI,uBAAY,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC;AAED,SAAgB,qBAAqB,CAAC,MAAuC;IAC3E,OAAO,IAAI,6BAAe,CAAC,MAAM,CAAC,CAAC;AACrC,CAAC;AAED,SAAgB,kBAAkB,CAAC,MAAoC;IACrE,OAAO,IAAI,uBAAY,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC;AAED,SAAgB,wBAAwB,CAAC,MAA0C;IACjF,OAAO,IAAI,+BAAkB,CAAC,MAAM,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 性能门禁
|
|
3
|
+
*
|
|
4
|
+
* 检查性能指标:
|
|
5
|
+
* - 响应时间
|
|
6
|
+
* - 内存使用
|
|
7
|
+
* - 测试覆盖率
|
|
8
|
+
* - 打包大小
|
|
9
|
+
*
|
|
10
|
+
* 改进:
|
|
11
|
+
* - 添加超时机制
|
|
12
|
+
* - 改进错误处理
|
|
13
|
+
* - 返回详细的错误信息
|
|
14
|
+
*/
|
|
15
|
+
import type { GateResult, GateContext, PerformanceGateConfig, PerformanceThresholds } from './types';
|
|
16
|
+
/**
|
|
17
|
+
* 性能门禁配置
|
|
18
|
+
*/
|
|
19
|
+
export interface ExtendedPerformanceGateConfig extends PerformanceGateConfig {
|
|
20
|
+
/** 覆盖率测试超时(毫秒) */
|
|
21
|
+
coverageTimeout?: number;
|
|
22
|
+
/** 基准测试超时(毫秒) */
|
|
23
|
+
benchmarkTimeout?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 性能门禁
|
|
27
|
+
*/
|
|
28
|
+
export declare class PerformanceGate {
|
|
29
|
+
private config;
|
|
30
|
+
constructor(config?: Partial<ExtendedPerformanceGateConfig>);
|
|
31
|
+
/**
|
|
32
|
+
* 检查性能
|
|
33
|
+
*/
|
|
34
|
+
check(context: GateContext): Promise<GateResult>;
|
|
35
|
+
/**
|
|
36
|
+
* 收集性能指标
|
|
37
|
+
*/
|
|
38
|
+
private collectMetrics;
|
|
39
|
+
/**
|
|
40
|
+
* 收集测试覆盖率(带超时)
|
|
41
|
+
*/
|
|
42
|
+
private collectCoverage;
|
|
43
|
+
/**
|
|
44
|
+
* 收集打包大小
|
|
45
|
+
*/
|
|
46
|
+
private collectBundleSize;
|
|
47
|
+
/**
|
|
48
|
+
* 格式化指标输出
|
|
49
|
+
*/
|
|
50
|
+
private formatMetrics;
|
|
51
|
+
/**
|
|
52
|
+
* 运行基准测试(带超时)
|
|
53
|
+
*/
|
|
54
|
+
runBenchmark(context: GateContext): Promise<{
|
|
55
|
+
avgResponseTime: number;
|
|
56
|
+
avgMemoryUsage: number;
|
|
57
|
+
minResponseTime: number;
|
|
58
|
+
maxResponseTime: number;
|
|
59
|
+
error?: string;
|
|
60
|
+
}>;
|
|
61
|
+
/**
|
|
62
|
+
* 单次基准测试(带超时)
|
|
63
|
+
*/
|
|
64
|
+
private singleBenchmark;
|
|
65
|
+
/**
|
|
66
|
+
* 设置阈值
|
|
67
|
+
*/
|
|
68
|
+
setThresholds(thresholds: Partial<PerformanceThresholds>): void;
|
|
69
|
+
/**
|
|
70
|
+
* 设置超时时间
|
|
71
|
+
*/
|
|
72
|
+
setTimeouts(options: {
|
|
73
|
+
coverage?: number;
|
|
74
|
+
benchmark?: number;
|
|
75
|
+
}): void;
|
|
76
|
+
/**
|
|
77
|
+
* 获取配置
|
|
78
|
+
*/
|
|
79
|
+
getConfig(): Required<ExtendedPerformanceGateConfig>;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=performance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performance.d.ts","sourceRoot":"","sources":["../../src/gates/performance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,OAAO,KAAK,EAAE,UA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