cgraphx 1.2.0 → 1.3.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/dist/.claude-template/hooks/precommit-check/precommit-check.cjs +90 -0
- package/dist/.claude-template/skills/cgraphx-guide/how-to-use.html +99 -78
- package/dist/.claude-template/skills/precommit-review/SKILL.md +50 -0
- package/dist/.claude-template/skills/run-api-test/SKILL.md +187 -0
- package/dist/.claude-template/skills/run-api-test/assets/template-test-report.md +103 -0
- package/dist/.claude-template/skills/run-api-test/assets/template-test-verify.jsonl +5 -0
- package/dist/.claude-template/skills/run-api-test/references/bru-run.md +60 -0
- package/dist/.claude-template/skills/run-api-test/references/db-verification.md +81 -0
- package/dist/.claude-template/skills/run-api-test/references/report-format.md +104 -0
- package/dist/.claude-template/skills/run-api-test/references/service-readiness.md +61 -0
- package/dist/.claude-template/skills/run-api-test/references/test-scope.md +64 -0
- package/dist/.claude-template/skills/write-api/SKILL.md +150 -0
- package/dist/.claude-template/skills/write-api/assets/template-api-spec.md +112 -0
- package/dist/.claude-template/skills/write-api/assets/template-request.bru +75 -0
- package/dist/.claude-template/skills/write-api/references/ai-prompts.md +133 -0
- package/dist/.claude-template/skills/write-api/references/api-spec-format.md +108 -0
- package/dist/.claude-template/skills/write-api/references/bru-format.md +144 -0
- package/dist/.claude-template/skills/write-api/references/collection-layout.md +81 -0
- package/dist/.claude-template/skills/write-api/references/environment-setup.md +105 -0
- package/dist/.claude-template/skills/write-api/references/interface-scope.md +74 -0
- package/dist/api-test/ai-fields.d.ts +37 -0
- package/dist/api-test/ai-fields.d.ts.map +1 -0
- package/dist/api-test/ai-fields.js +114 -0
- package/dist/api-test/ai-fields.js.map +1 -0
- package/dist/api-test/assemble.d.ts +76 -0
- package/dist/api-test/assemble.d.ts.map +1 -0
- package/dist/api-test/assemble.js +185 -0
- package/dist/api-test/assemble.js.map +1 -0
- package/dist/api-test/bru-cli-invoker.d.ts +72 -0
- package/dist/api-test/bru-cli-invoker.d.ts.map +1 -0
- package/dist/api-test/bru-cli-invoker.js +169 -0
- package/dist/api-test/bru-cli-invoker.js.map +1 -0
- package/dist/api-test/bru-report-parser.d.ts +24 -0
- package/dist/api-test/bru-report-parser.d.ts.map +1 -0
- package/dist/api-test/bru-report-parser.js +110 -0
- package/dist/api-test/bru-report-parser.js.map +1 -0
- package/dist/api-test/bru-runner.d.ts +101 -0
- package/dist/api-test/bru-runner.d.ts.map +1 -0
- package/dist/api-test/bru-runner.js +316 -0
- package/dist/api-test/bru-runner.js.map +1 -0
- package/dist/api-test/bru-writer.d.ts +52 -0
- package/dist/api-test/bru-writer.d.ts.map +1 -0
- package/dist/api-test/bru-writer.js +159 -0
- package/dist/api-test/bru-writer.js.map +1 -0
- package/dist/api-test/call-chain-extractor.d.ts +80 -0
- package/dist/api-test/call-chain-extractor.d.ts.map +1 -0
- package/dist/api-test/call-chain-extractor.js +179 -0
- package/dist/api-test/call-chain-extractor.js.map +1 -0
- package/dist/api-test/cli.d.ts +133 -0
- package/dist/api-test/cli.d.ts.map +1 -0
- package/dist/api-test/cli.js +1009 -0
- package/dist/api-test/cli.js.map +1 -0
- package/dist/api-test/config.d.ts +75 -0
- package/dist/api-test/config.d.ts.map +1 -0
- package/dist/api-test/config.js +406 -0
- package/dist/api-test/config.js.map +1 -0
- package/dist/api-test/db-query-cli.d.ts +51 -0
- package/dist/api-test/db-query-cli.d.ts.map +1 -0
- package/dist/api-test/db-query-cli.js +119 -0
- package/dist/api-test/db-query-cli.js.map +1 -0
- package/dist/api-test/enhance-prepare.d.ts +111 -0
- package/dist/api-test/enhance-prepare.d.ts.map +1 -0
- package/dist/api-test/enhance-prepare.js +425 -0
- package/dist/api-test/enhance-prepare.js.map +1 -0
- package/dist/api-test/enhance-write.d.ts +28 -0
- package/dist/api-test/enhance-write.d.ts.map +1 -0
- package/dist/api-test/enhance-write.js +145 -0
- package/dist/api-test/enhance-write.js.map +1 -0
- package/dist/api-test/errors.d.ts +48 -0
- package/dist/api-test/errors.d.ts.map +1 -0
- package/dist/api-test/errors.js +76 -0
- package/dist/api-test/errors.js.map +1 -0
- package/dist/api-test/field-extractor.d.ts +98 -0
- package/dist/api-test/field-extractor.d.ts.map +1 -0
- package/dist/api-test/field-extractor.js +327 -0
- package/dist/api-test/field-extractor.js.map +1 -0
- package/dist/api-test/impl-finder.d.ts +37 -0
- package/dist/api-test/impl-finder.d.ts.map +1 -0
- package/dist/api-test/impl-finder.js +54 -0
- package/dist/api-test/impl-finder.js.map +1 -0
- package/dist/api-test/index.d.ts +41 -0
- package/dist/api-test/index.d.ts.map +1 -0
- package/dist/api-test/index.js +124 -0
- package/dist/api-test/index.js.map +1 -0
- package/dist/api-test/java-parser.d.ts +89 -0
- package/dist/api-test/java-parser.d.ts.map +1 -0
- package/dist/api-test/java-parser.js +508 -0
- package/dist/api-test/java-parser.js.map +1 -0
- package/dist/api-test/md-writer.d.ts +49 -0
- package/dist/api-test/md-writer.d.ts.map +1 -0
- package/dist/api-test/md-writer.js +202 -0
- package/dist/api-test/md-writer.js.map +1 -0
- package/dist/api-test/parser-httpservice.d.ts +91 -0
- package/dist/api-test/parser-httpservice.d.ts.map +1 -0
- package/dist/api-test/parser-httpservice.js +271 -0
- package/dist/api-test/parser-httpservice.js.map +1 -0
- package/dist/api-test/report.d.ts +188 -0
- package/dist/api-test/report.d.ts.map +1 -0
- package/dist/api-test/report.js +522 -0
- package/dist/api-test/report.js.map +1 -0
- package/dist/api-test/snapshot.d.ts +26 -0
- package/dist/api-test/snapshot.d.ts.map +1 -0
- package/dist/api-test/snapshot.js +150 -0
- package/dist/api-test/snapshot.js.map +1 -0
- package/dist/api-test/test-history.d.ts +48 -0
- package/dist/api-test/test-history.d.ts.map +1 -0
- package/dist/api-test/test-history.js +122 -0
- package/dist/api-test/test-history.js.map +1 -0
- package/dist/api-test/types.d.ts +174 -0
- package/dist/api-test/types.d.ts.map +1 -0
- package/dist/api-test/types.js +13 -0
- package/dist/api-test/types.js.map +1 -0
- package/dist/api-test/verify-prepare.d.ts +30 -0
- package/dist/api-test/verify-prepare.d.ts.map +1 -0
- package/dist/api-test/verify-prepare.js +150 -0
- package/dist/api-test/verify-prepare.js.map +1 -0
- package/dist/api-test/verify-write.d.ts +31 -0
- package/dist/api-test/verify-write.d.ts.map +1 -0
- package/dist/api-test/verify-write.js +159 -0
- package/dist/api-test/verify-write.js.map +1 -0
- package/dist/dbquery/dump-schema.d.ts +46 -0
- package/dist/dbquery/dump-schema.d.ts.map +1 -0
- package/dist/dbquery/dump-schema.js +379 -0
- package/dist/dbquery/dump-schema.js.map +1 -0
- package/dist/installer/targets/claude.d.ts +15 -0
- package/dist/installer/targets/claude.d.ts.map +1 -1
- package/dist/installer/targets/claude.js +53 -0
- package/dist/installer/targets/claude.js.map +1 -1
- package/package.json +1 -1
- package/scripts/agent-eval/block-cgraphx-and-gitnexus-cli-hook.sh +0 -43
- package/scripts/agent-eval/block-cgraphx-cli-hook.sh +0 -32
- package/scripts/agent-eval/block-cgraphx-cli-settings.json +0 -16
- package/scripts/agent-eval/cli-vs-mcp-3arm.sh +0 -121
- package/scripts/agent-eval/multi-tool-eval.sh +0 -171
- package/scripts/agent-eval/parse-cli-vs-mcp.mjs +0 -232
- package/scripts/agent-eval/parse-multi-tool.mjs +0 -242
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Analyze phase — extract the call chain, dependency tables, and auth flag
|
|
4
|
+
* from an impl method body.
|
|
5
|
+
*
|
|
6
|
+
* Spec contract (T-30):
|
|
7
|
+
* - Call chain: every `someService.method()` invocation in the body
|
|
8
|
+
* (first-level callees only — no recursion into callees of callees).
|
|
9
|
+
* At least 1 level is expected (impl → first callee).
|
|
10
|
+
* - Dep tables: inferred from Mapper calls (`xxxMapper.selectXxx` etc.)
|
|
11
|
+
* by stripping the `Mapper` suffix from the receiver's declared field
|
|
12
|
+
* type (or receiver name) and lowercasing.
|
|
13
|
+
* - Auth required: true when the impl calls `IAuthInfoService` (field type
|
|
14
|
+
* or receiver name starting with `iAuth` / `IAuthInfoService`) or reads
|
|
15
|
+
* the staffcode header (`ServerHeadersHolder.getStaffcode()` etc.).
|
|
16
|
+
*
|
|
17
|
+
* Implementation note: extraction uses `method.bodyText` (regex) rather than
|
|
18
|
+
* the AST `body` node. The T-11 parser deletes the tree after extraction to
|
|
19
|
+
* release WASM heap, which would invalidate any retained AST node reference;
|
|
20
|
+
* `bodyText` is captured before the delete and stays valid. The task's
|
|
21
|
+
* "允许局部适配" clause permits this regex-based approach.
|
|
22
|
+
*
|
|
23
|
+
* Self-contained: depends only on `./java-parser` (ClassInfo, MethodSignature).
|
|
24
|
+
* No imports from `src/extraction/` / `src/resolution/` / `src/db/`.
|
|
25
|
+
*
|
|
26
|
+
* Public surface:
|
|
27
|
+
* - `extractCallChain(implInfo, method)` —
|
|
28
|
+
* Promise<{ callChain: string[]; depTables: string[]; authRequired: boolean }>
|
|
29
|
+
*/
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.__INTERNAL_CALL_CHAIN = void 0;
|
|
32
|
+
exports.extractCallChain = extractCallChain;
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
// Call chain extraction
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
/**
|
|
37
|
+
* Match `receiver.methodName(` calls in the body text. Captures the receiver
|
|
38
|
+
* identifier and method name. Skips:
|
|
39
|
+
* - Calls without a receiver (`foo()` — can't qualify).
|
|
40
|
+
* - `super(...)` / `this(...)` constructor calls.
|
|
41
|
+
* - Chained-call inner segments are captured as separate `a.b` and `b.c`
|
|
42
|
+
* pairs; dedup handles the rest.
|
|
43
|
+
*
|
|
44
|
+
* The receiver pattern `[A-Za-z_]\w*` matches simple identifiers (not
|
|
45
|
+
* qualified `this.foo` or `Class.staticMethod` — those are captured as
|
|
46
|
+
* `this.foo` / `Class.staticMethod` with the dotted receiver included).
|
|
47
|
+
*/
|
|
48
|
+
const METHOD_CALL_RE = /\b([A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)\.([A-Za-z_]\w*)\s*\(/g;
|
|
49
|
+
/**
|
|
50
|
+
* Extract `receiver.methodName` strings from the body text. Dedupes by
|
|
51
|
+
* the full `receiver.method` pair, preserving document order.
|
|
52
|
+
*/
|
|
53
|
+
function extractCallChainFromBody(bodyText) {
|
|
54
|
+
const out = [];
|
|
55
|
+
const seen = new Set();
|
|
56
|
+
METHOD_CALL_RE.lastIndex = 0;
|
|
57
|
+
let m;
|
|
58
|
+
while ((m = METHOD_CALL_RE.exec(bodyText)) !== null) {
|
|
59
|
+
const receiver = m[1] ?? '';
|
|
60
|
+
const methodName = m[2] ?? '';
|
|
61
|
+
if (!receiver || !methodName)
|
|
62
|
+
continue;
|
|
63
|
+
// Skip `super.x` and `this.x` — not service calls.
|
|
64
|
+
if (receiver === 'super' || receiver === 'this')
|
|
65
|
+
continue;
|
|
66
|
+
const key = `${receiver}.${methodName}`;
|
|
67
|
+
if (seen.has(key))
|
|
68
|
+
continue;
|
|
69
|
+
seen.add(key);
|
|
70
|
+
out.push(key);
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
// Dependency table inference
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
77
|
+
/**
|
|
78
|
+
* Infer dependency table names from Mapper-typed calls in the body.
|
|
79
|
+
*
|
|
80
|
+
* Heuristic:
|
|
81
|
+
* 1. For each `xxxMapper.method()` call in the body, look up the field
|
|
82
|
+
* `xxxMapper` on the impl class. If its type ends with `Mapper`,
|
|
83
|
+
* strip the suffix and lowercase → table name.
|
|
84
|
+
* 2. Fallback: if the receiver name itself ends with `Mapper` (e.g.
|
|
85
|
+
* `orderMapper`), strip + lowercase.
|
|
86
|
+
*
|
|
87
|
+
* Returns deduped table names in document order.
|
|
88
|
+
*/
|
|
89
|
+
function inferDepTables(bodyText, implInfo) {
|
|
90
|
+
// Build a map of field name → field type for the impl class.
|
|
91
|
+
const fieldTypeByName = new Map();
|
|
92
|
+
for (const f of implInfo.fields) {
|
|
93
|
+
fieldTypeByName.set(f.name, f.type);
|
|
94
|
+
}
|
|
95
|
+
const out = [];
|
|
96
|
+
const seen = new Set();
|
|
97
|
+
METHOD_CALL_RE.lastIndex = 0;
|
|
98
|
+
let m;
|
|
99
|
+
while ((m = METHOD_CALL_RE.exec(bodyText)) !== null) {
|
|
100
|
+
const receiver = m[1] ?? '';
|
|
101
|
+
if (!receiver)
|
|
102
|
+
continue;
|
|
103
|
+
// Resolve receiver → field type (if it's a simple identifier matching a field).
|
|
104
|
+
const fieldType = fieldTypeByName.get(receiver);
|
|
105
|
+
const typeForInference = fieldType ?? receiver;
|
|
106
|
+
// Match `XxxMapper` (or `xxxMapper`).
|
|
107
|
+
const mm = /^([A-Za-z_]\w*)Mapper$/.exec(typeForInference);
|
|
108
|
+
if (!mm)
|
|
109
|
+
continue;
|
|
110
|
+
const table = (mm[1] ?? '').toLowerCase();
|
|
111
|
+
if (!table || seen.has(table))
|
|
112
|
+
continue;
|
|
113
|
+
seen.add(table);
|
|
114
|
+
out.push(table);
|
|
115
|
+
}
|
|
116
|
+
return out;
|
|
117
|
+
}
|
|
118
|
+
// ---------------------------------------------------------------------------
|
|
119
|
+
// Auth-required detection
|
|
120
|
+
// ---------------------------------------------------------------------------
|
|
121
|
+
/**
|
|
122
|
+
* Detect whether the impl method touches the auth surface.
|
|
123
|
+
*
|
|
124
|
+
* Signals (any one → true):
|
|
125
|
+
* - The impl class has a field whose type simple-name is `IAuthInfoService`
|
|
126
|
+
* (or whose name starts with `iAuth`).
|
|
127
|
+
* - The body text references `IAuthInfoService`, `getStaffcode`, or
|
|
128
|
+
* `ServerHeadersHolder`.
|
|
129
|
+
*
|
|
130
|
+
* The field-type check catches `@Resource IAuthInfoService iAuthService;`
|
|
131
|
+
* even when the body only calls `iAuthService.check()` (receiver name
|
|
132
|
+
* doesn't carry the type). The body-text check catches direct
|
|
133
|
+
* `ServerHeadersHolder.getStaffcode()` calls without a field.
|
|
134
|
+
*/
|
|
135
|
+
function detectAuthRequired(bodyText, implInfo) {
|
|
136
|
+
// Field-type check.
|
|
137
|
+
for (const f of implInfo.fields) {
|
|
138
|
+
const simple = f.type.split('.').pop() ?? f.type;
|
|
139
|
+
if (simple === 'IAuthInfoService' || simple === 'AuthInfoService') {
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
if (/^iAuth\w*/.test(f.name) || /^authService$/i.test(f.name)) {
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// Body-text check.
|
|
147
|
+
if (/IAuthInfoService/.test(bodyText))
|
|
148
|
+
return true;
|
|
149
|
+
if (/getStaffcode/.test(bodyText))
|
|
150
|
+
return true;
|
|
151
|
+
if (/ServerHeadersHolder/.test(bodyText))
|
|
152
|
+
return true;
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
// ---------------------------------------------------------------------------
|
|
156
|
+
// Public API
|
|
157
|
+
// ---------------------------------------------------------------------------
|
|
158
|
+
/**
|
|
159
|
+
* Extract the call chain, dependency tables, and auth-required flag for
|
|
160
|
+
* one impl method. Returns empty arrays + `authRequired: false` when the
|
|
161
|
+
* method has no body (interface/abstract method — shouldn't happen for an
|
|
162
|
+
* impl, but defensive per T-11's empty-bodyText caveat).
|
|
163
|
+
*/
|
|
164
|
+
async function extractCallChain(implInfo, method) {
|
|
165
|
+
if (!method.bodyText) {
|
|
166
|
+
return { callChain: [], depTables: [], authRequired: false };
|
|
167
|
+
}
|
|
168
|
+
const callChain = extractCallChainFromBody(method.bodyText);
|
|
169
|
+
const depTables = inferDepTables(method.bodyText, implInfo);
|
|
170
|
+
const authRequired = detectAuthRequired(method.bodyText, implInfo);
|
|
171
|
+
return { callChain, depTables, authRequired };
|
|
172
|
+
}
|
|
173
|
+
// Internal helpers re-exported for tests.
|
|
174
|
+
exports.__INTERNAL_CALL_CHAIN = {
|
|
175
|
+
extractCallChainFromBody,
|
|
176
|
+
inferDepTables,
|
|
177
|
+
detectAuthRequired,
|
|
178
|
+
};
|
|
179
|
+
//# sourceMappingURL=call-chain-extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-chain-extractor.js","sourceRoot":"","sources":["../../src/api-test/call-chain-extractor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;AAoJH,4CAaC;AA7JD,8EAA8E;AAC9E,wBAAwB;AACxB,8EAA8E;AAE9E;;;;;;;;;;;GAWG;AACH,MAAM,cAAc,GAAG,2DAA2D,CAAC;AAEnF;;;GAGG;AACH,SAAS,wBAAwB,CAAC,QAAgB;IAChD,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/B,cAAc,CAAC,SAAS,GAAG,CAAC,CAAC;IAC7B,IAAI,CAAyB,CAAC;IAC9B,OAAO,CAAC,CAAC,GAAG,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACpD,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC5B,MAAM,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,QAAQ,IAAI,CAAC,UAAU;YAAE,SAAS;QACvC,mDAAmD;QACnD,IAAI,QAAQ,KAAK,OAAO,IAAI,QAAQ,KAAK,MAAM;YAAE,SAAS;QAC1D,MAAM,GAAG,GAAG,GAAG,QAAQ,IAAI,UAAU,EAAE,CAAC;QACxC,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,SAAS;QAC5B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACd,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChB,CAA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AAG,wBAAwB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC5D,MAAM,SAAS,GAAG,cAAc,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC5D,MAAM,YAAY,GAAG,kBAAkB,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAEnE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;AAChD,CAAC;AAED,0CAA0C;AAC7B,QAAA,qBAAqB,GAAG;IACnC,wBAAwB;IACxB,cAAc;IACd,kBAAkB;CACnB,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI wiring for the api-test subsystem.
|
|
3
|
+
*
|
|
4
|
+
* Exposes `registerApiTestCommands(program)` — called once from
|
|
5
|
+
* `src/bin/codegraph.ts`. All api-test subcommands live under
|
|
6
|
+
* `codegraph api-test <sub>`. The scan subcommand (T-20) is wired here;
|
|
7
|
+
* the analyze/assemble/run/report/list subcommands will be added in
|
|
8
|
+
* T-30 / T-40 / T-50 / T-60.
|
|
9
|
+
*
|
|
10
|
+
* Spec contract — scan:
|
|
11
|
+
* - Full re-scan (delete `docs/api-test/<service>/` subtree, rebuild).
|
|
12
|
+
* - Writes one `.bru` + one `.md` per endpoint under
|
|
13
|
+
* `docs/api-test/<service>/<svc_id>_<methodName>.{bru,md}`.
|
|
14
|
+
* - Writes `docs/api-test/bruno.json` at the api-test root with the
|
|
15
|
+
* minimal Bruno collection schema.
|
|
16
|
+
* - Failed endpoints don't abort the rest — warnings go to stderr.
|
|
17
|
+
*
|
|
18
|
+
* Exit codes:
|
|
19
|
+
* 0 success (or partial success with warnings)
|
|
20
|
+
* 2 config error (ConfigError — missing/invalid profile or config)
|
|
21
|
+
* 5 argument error
|
|
22
|
+
*/
|
|
23
|
+
import type { Command } from 'commander';
|
|
24
|
+
import { type ClassInfo, type MethodSignature } from './java-parser';
|
|
25
|
+
import { type BrunoRunResult } from './bru-runner';
|
|
26
|
+
import type { Endpoint, ApiTestProfile } from './types';
|
|
27
|
+
/**
|
|
28
|
+
* Attach the `api-test` command group to a commander program.
|
|
29
|
+
*/
|
|
30
|
+
export declare function registerApiTestCommands(program: Command): void;
|
|
31
|
+
/**
|
|
32
|
+
* Walk `projectRoot` and yield every `.java` file path. Same ignore list as
|
|
33
|
+
* the scan phase (parser-httpservice.iterJavaFiles) — duplicated here to
|
|
34
|
+
* avoid leaking the scan module's internal helper through the CLI surface.
|
|
35
|
+
* Symlinks are not followed.
|
|
36
|
+
*/
|
|
37
|
+
declare function iterJavaFilesCached(root: string): IterableIterator<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Run the analyze pipeline for one endpoint:
|
|
40
|
+
* 1. findImplFor(interfaceFqn, allClasses) — locate the impl class.
|
|
41
|
+
* 2. Match the interface method to the impl method (name + param count).
|
|
42
|
+
* 3. extractFields + extractCallChain.
|
|
43
|
+
*
|
|
44
|
+
* Returns the enriched fields/callChain/depTables/authRequired, plus a
|
|
45
|
+
* `skipReason` string when the endpoint should be marked `status: skip`.
|
|
46
|
+
*/
|
|
47
|
+
declare function analyzeEndpoint(endpoint: Endpoint, allClasses: ClassInfo[]): Promise<{
|
|
48
|
+
fields: Endpoint['fields'];
|
|
49
|
+
callChain: string[];
|
|
50
|
+
depTables: string[];
|
|
51
|
+
authRequired: boolean;
|
|
52
|
+
skipReason: string | null;
|
|
53
|
+
}>;
|
|
54
|
+
/** Count parameters in a signature string like `Object qryOrderList(Object reqVo)`. */
|
|
55
|
+
declare function countParamsInSignature(signature: string): number;
|
|
56
|
+
/**
|
|
57
|
+
* Find the impl method matching `name` + `paramCount`. Falls back to
|
|
58
|
+
* name-only match if paramCount is 0 (defensive — shouldn't happen for
|
|
59
|
+
* real @Center methods, which always have ≥1 param).
|
|
60
|
+
*/
|
|
61
|
+
declare function findImplMethod(implInfo: ClassInfo, name: string, paramCount: number): MethodSignature | null;
|
|
62
|
+
/**
|
|
63
|
+
* Remove the existing output subtree so a re-scan doesn't leave stale
|
|
64
|
+
* `.bru` / `.md` files behind for endpoints that no longer exist. Safe to
|
|
65
|
+
* call on a non-existent dir.
|
|
66
|
+
*
|
|
67
|
+
* Preserves any files / subdirs the user might have added that are NOT
|
|
68
|
+
* `.bru` / `.md` pairs? Spec says "full re-scan" = delete the whole
|
|
69
|
+
* `docs/api-test/<service>/` subtree and rewrite bruno.json. We follow
|
|
70
|
+
* that literally: delete the entire output dir's *.bru / *.md / bruno.json,
|
|
71
|
+
* and remove now-empty service subdirs.
|
|
72
|
+
*/
|
|
73
|
+
declare function clearOutputDir(outputDir: string): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Read an endpoint's status from its `.md` frontmatter. Returns 'active'
|
|
76
|
+
* when the .md doesn't exist or the status line can't be found (defensive
|
|
77
|
+
* — a fresh collection with no analyze phase still runs).
|
|
78
|
+
*/
|
|
79
|
+
declare function readEndpointStatus(endpoint: Endpoint, outputDir: string): 'active' | 'skip';
|
|
80
|
+
/**
|
|
81
|
+
* When `--filter` narrows to exactly one service, return that service name
|
|
82
|
+
* so `runBrunoCollection` can narrow Bruno CLI's run to that subdir (faster).
|
|
83
|
+
* When multiple services match (or none), return null — run the whole
|
|
84
|
+
* collection and filter results after.
|
|
85
|
+
*/
|
|
86
|
+
declare function pickFilterService(filterRe: RegExp | null, endpoints: Endpoint[]): string | null;
|
|
87
|
+
/** Judgment outcome for one BrunoRunResult. */
|
|
88
|
+
interface Judgment {
|
|
89
|
+
passed: boolean;
|
|
90
|
+
bizCode: string | null;
|
|
91
|
+
error: string | null;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Judge pass/fail for one Bruno run result against the profile's biz-code rule.
|
|
95
|
+
*
|
|
96
|
+
* - Bruno-reported error (timeout / request_failed) → passed=false, error
|
|
97
|
+
* forwarded.
|
|
98
|
+
* - HTTP 5xx → passed=false, error=http_5xx.
|
|
99
|
+
* - HTTP 4xx → passed=false, error=http_4xx.
|
|
100
|
+
* - Other non-200 → passed=false, error=http_non_200.
|
|
101
|
+
* - HTTP 200 + bizCodeField null → passed=true (HTTP-only check).
|
|
102
|
+
* - HTTP 200 + bizCodeField set + value in bizCodeSuccessValues → passed=true.
|
|
103
|
+
* - HTTP 200 + bizCodeField set + value NOT in success values → passed=false,
|
|
104
|
+
* error=biz_code_value_mismatch.
|
|
105
|
+
* - HTTP 200 + bizCodeField set + field missing from response body →
|
|
106
|
+
* passed=false, error=biz_code_field_missing.
|
|
107
|
+
*/
|
|
108
|
+
declare function judgePass(result: BrunoRunResult, profile: ApiTestProfile): Judgment;
|
|
109
|
+
/**
|
|
110
|
+
* Extract the biz code value from a response body. The body may be a JSON
|
|
111
|
+
* object or a JSON string. Returns the stringified value, or null when the
|
|
112
|
+
* field is absent / the body can't be parsed.
|
|
113
|
+
*/
|
|
114
|
+
declare function extractBizCode(responseBody: string, bizCodeField: string): string | null;
|
|
115
|
+
export declare const __INTERNAL_CLI: {
|
|
116
|
+
DEFAULT_OUTPUT_DIR: string;
|
|
117
|
+
BRUNO_COLLECTION_CONFIG: {
|
|
118
|
+
version: number;
|
|
119
|
+
name: string;
|
|
120
|
+
type: string;
|
|
121
|
+
};
|
|
122
|
+
clearOutputDir: typeof clearOutputDir;
|
|
123
|
+
iterJavaFilesCached: typeof iterJavaFilesCached;
|
|
124
|
+
analyzeEndpoint: typeof analyzeEndpoint;
|
|
125
|
+
countParamsInSignature: typeof countParamsInSignature;
|
|
126
|
+
findImplMethod: typeof findImplMethod;
|
|
127
|
+
readEndpointStatus: typeof readEndpointStatus;
|
|
128
|
+
pickFilterService: typeof pickFilterService;
|
|
129
|
+
judgePass: typeof judgePass;
|
|
130
|
+
extractBizCode: typeof extractBizCode;
|
|
131
|
+
};
|
|
132
|
+
export {};
|
|
133
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/api-test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