@apitap/core 1.5.3 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -8
- package/dist/auth/handoff.js +1 -1
- package/dist/auth/handoff.js.map +1 -1
- package/dist/capture/cdp-attach.d.ts +60 -0
- package/dist/capture/cdp-attach.js +422 -0
- package/dist/capture/cdp-attach.js.map +1 -0
- package/dist/capture/filter.js +6 -0
- package/dist/capture/filter.js.map +1 -1
- package/dist/capture/parameterize.d.ts +7 -6
- package/dist/capture/parameterize.js +204 -12
- package/dist/capture/parameterize.js.map +1 -1
- package/dist/capture/session.js +20 -10
- package/dist/capture/session.js.map +1 -1
- package/dist/cli.js +387 -20
- package/dist/cli.js.map +1 -1
- package/dist/discovery/openapi.js +23 -50
- package/dist/discovery/openapi.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +12 -0
- package/dist/mcp.js.map +1 -1
- package/dist/native-host.js +5 -0
- package/dist/native-host.js.map +1 -1
- package/dist/plugin.js +10 -3
- package/dist/plugin.js.map +1 -1
- package/dist/replay/engine.d.ts +13 -0
- package/dist/replay/engine.js +20 -0
- package/dist/replay/engine.js.map +1 -1
- package/dist/skill/apis-guru.d.ts +35 -0
- package/dist/skill/apis-guru.js +128 -0
- package/dist/skill/apis-guru.js.map +1 -0
- package/dist/skill/generator.d.ts +7 -1
- package/dist/skill/generator.js +35 -3
- package/dist/skill/generator.js.map +1 -1
- package/dist/skill/merge.d.ts +29 -0
- package/dist/skill/merge.js +252 -0
- package/dist/skill/merge.js.map +1 -0
- package/dist/skill/openapi-converter.d.ts +31 -0
- package/dist/skill/openapi-converter.js +383 -0
- package/dist/skill/openapi-converter.js.map +1 -0
- package/dist/types.d.ts +41 -0
- package/package.json +1 -1
- package/src/auth/handoff.ts +1 -1
- package/src/capture/cdp-attach.ts +501 -0
- package/src/capture/filter.ts +5 -0
- package/src/capture/parameterize.ts +207 -11
- package/src/capture/session.ts +20 -10
- package/src/cli.ts +420 -18
- package/src/discovery/openapi.ts +25 -56
- package/src/index.ts +1 -0
- package/src/mcp.ts +12 -0
- package/src/native-host.ts +7 -0
- package/src/plugin.ts +10 -3
- package/src/replay/engine.ts +19 -0
- package/src/skill/apis-guru.ts +163 -0
- package/src/skill/generator.ts +38 -3
- package/src/skill/merge.ts +281 -0
- package/src/skill/openapi-converter.ts +426 -0
- package/src/types.ts +42 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { SkillFile, SkillEndpoint, ImportMeta, MergeResult } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Normalize a parameterized path by replacing all named param placeholders
|
|
4
|
+
* with the generic `:_` placeholder, enabling matching across different param
|
|
5
|
+
* naming conventions (e.g. `:id` vs `:userId` vs `:user_id`).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* normalizePath('/repos/:owner/:repo') // → '/repos/:_/:_'
|
|
9
|
+
* normalizePath('/users/list') // → '/users/list'
|
|
10
|
+
*/
|
|
11
|
+
export declare function normalizePath(path: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Pure function — no I/O.
|
|
14
|
+
*
|
|
15
|
+
* Merges imported OpenAPI endpoints into an existing skill file.
|
|
16
|
+
*
|
|
17
|
+
* Captured data is sacred: it always wins on confidence, examples, and
|
|
18
|
+
* endpoint provenance. Spec data can only enrich (add description, specSource,
|
|
19
|
+
* query param enum/required/type) or fill gaps (add missing endpoints).
|
|
20
|
+
*
|
|
21
|
+
* Match logic: METHOD + normalizePath(path). This allows `:owner` and `:user`
|
|
22
|
+
* to be considered the same parameter slot.
|
|
23
|
+
*
|
|
24
|
+
* @param existing The existing skill file on disk, or null if none exists.
|
|
25
|
+
* @param imported Endpoints parsed from the OpenAPI spec.
|
|
26
|
+
* @param importMeta Metadata about the import (spec URL, version, etc.).
|
|
27
|
+
* @returns MergeResult with the updated SkillFile and a diff summary.
|
|
28
|
+
*/
|
|
29
|
+
export declare function mergeSkillFile(existing: SkillFile | null, imported: SkillEndpoint[], importMeta: ImportMeta): MergeResult;
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize a parameterized path by replacing all named param placeholders
|
|
3
|
+
* with the generic `:_` placeholder, enabling matching across different param
|
|
4
|
+
* naming conventions (e.g. `:id` vs `:userId` vs `:user_id`).
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* normalizePath('/repos/:owner/:repo') // → '/repos/:_/:_'
|
|
8
|
+
* normalizePath('/users/list') // → '/users/list'
|
|
9
|
+
*/
|
|
10
|
+
export function normalizePath(path) {
|
|
11
|
+
return path.replace(/:[a-zA-Z_]\w*/g, ':_');
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Build a match key for endpoint deduplication: METHOD + normalized path.
|
|
15
|
+
*/
|
|
16
|
+
function matchKey(method, path) {
|
|
17
|
+
return `${method.toUpperCase()} ${normalizePath(path)}`;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Merge query params from a captured endpoint with params from an imported
|
|
21
|
+
* spec endpoint.
|
|
22
|
+
*
|
|
23
|
+
* Rules:
|
|
24
|
+
* - Captured `example` values are preserved (captured data is sacred).
|
|
25
|
+
* - Spec `type`, `required`, `enum` augment the captured params.
|
|
26
|
+
* - New params that only exist in the spec are added wholesale.
|
|
27
|
+
*/
|
|
28
|
+
function mergeQueryParams(captured, specParams) {
|
|
29
|
+
const merged = { ...captured };
|
|
30
|
+
for (const [name, specParam] of Object.entries(specParams)) {
|
|
31
|
+
if (name in merged) {
|
|
32
|
+
// Param exists in captured — keep captured example, augment with spec metadata
|
|
33
|
+
const existing = merged[name];
|
|
34
|
+
merged[name] = {
|
|
35
|
+
...existing,
|
|
36
|
+
// Take spec type only if captured has generic 'string' and spec is more specific
|
|
37
|
+
type: existing.type === 'string' && specParam.type !== 'string' ? specParam.type : existing.type,
|
|
38
|
+
// Always preserve captured example value
|
|
39
|
+
example: existing.example,
|
|
40
|
+
// Add spec enum if present
|
|
41
|
+
...(specParam.enum !== undefined ? { enum: specParam.enum } : {}),
|
|
42
|
+
// Add spec required flag if present
|
|
43
|
+
...(specParam.required !== undefined ? { required: specParam.required } : {}),
|
|
44
|
+
// Mark as also coming from spec
|
|
45
|
+
...(specParam.fromSpec ? { fromSpec: true } : {}),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// New param only in spec — add it
|
|
50
|
+
merged[name] = specParam;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return merged;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Determine whether an imported endpoint would enrich an existing captured
|
|
57
|
+
* endpoint (i.e. adds new metadata not already present).
|
|
58
|
+
*/
|
|
59
|
+
function wouldEnrich(existing, imported) {
|
|
60
|
+
if (!existing.description && imported.description)
|
|
61
|
+
return true;
|
|
62
|
+
if (!existing.specSource && imported.specSource)
|
|
63
|
+
return true;
|
|
64
|
+
// Check if any new query params would be added or enriched
|
|
65
|
+
for (const [name, specParam] of Object.entries(imported.queryParams)) {
|
|
66
|
+
if (!(name in existing.queryParams))
|
|
67
|
+
return true;
|
|
68
|
+
const ep = existing.queryParams[name];
|
|
69
|
+
if (!ep.enum && specParam.enum)
|
|
70
|
+
return true;
|
|
71
|
+
if (ep.required === undefined && specParam.required !== undefined)
|
|
72
|
+
return true;
|
|
73
|
+
if (ep.type === 'string' && specParam.type !== 'string')
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Pure function — no I/O.
|
|
80
|
+
*
|
|
81
|
+
* Merges imported OpenAPI endpoints into an existing skill file.
|
|
82
|
+
*
|
|
83
|
+
* Captured data is sacred: it always wins on confidence, examples, and
|
|
84
|
+
* endpoint provenance. Spec data can only enrich (add description, specSource,
|
|
85
|
+
* query param enum/required/type) or fill gaps (add missing endpoints).
|
|
86
|
+
*
|
|
87
|
+
* Match logic: METHOD + normalizePath(path). This allows `:owner` and `:user`
|
|
88
|
+
* to be considered the same parameter slot.
|
|
89
|
+
*
|
|
90
|
+
* @param existing The existing skill file on disk, or null if none exists.
|
|
91
|
+
* @param imported Endpoints parsed from the OpenAPI spec.
|
|
92
|
+
* @param importMeta Metadata about the import (spec URL, version, etc.).
|
|
93
|
+
* @returns MergeResult with the updated SkillFile and a diff summary.
|
|
94
|
+
*/
|
|
95
|
+
export function mergeSkillFile(existing, imported, importMeta) {
|
|
96
|
+
const now = new Date().toISOString();
|
|
97
|
+
let preserved = 0;
|
|
98
|
+
let added = 0;
|
|
99
|
+
let enriched = 0;
|
|
100
|
+
let skipped = 0;
|
|
101
|
+
// --- Case: no existing file — create a new SkillFile from imported endpoints ---
|
|
102
|
+
if (existing === null) {
|
|
103
|
+
const endpoints = imported.map(ep => ({
|
|
104
|
+
...ep,
|
|
105
|
+
normalizedPath: normalizePath(ep.path),
|
|
106
|
+
}));
|
|
107
|
+
const skillFile = {
|
|
108
|
+
version: '1.2',
|
|
109
|
+
domain: extractDomainFromMeta(importMeta),
|
|
110
|
+
capturedAt: now,
|
|
111
|
+
baseUrl: extractBaseUrlFromMeta(importMeta),
|
|
112
|
+
endpoints,
|
|
113
|
+
metadata: {
|
|
114
|
+
captureCount: 0,
|
|
115
|
+
filteredCount: 0,
|
|
116
|
+
toolVersion: '1.0.0',
|
|
117
|
+
importHistory: [{
|
|
118
|
+
specUrl: importMeta.specUrl,
|
|
119
|
+
specVersion: importMeta.specVersion,
|
|
120
|
+
importedAt: now,
|
|
121
|
+
endpointsAdded: endpoints.length,
|
|
122
|
+
endpointsEnriched: 0,
|
|
123
|
+
}],
|
|
124
|
+
},
|
|
125
|
+
provenance: 'imported',
|
|
126
|
+
};
|
|
127
|
+
added = endpoints.length;
|
|
128
|
+
return {
|
|
129
|
+
skillFile,
|
|
130
|
+
diff: { preserved, added, enriched, skipped },
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
// --- Case: existing file present — merge into it ---
|
|
134
|
+
// Build a map from match-key → existing endpoint (mutable copy)
|
|
135
|
+
const existingMap = new Map();
|
|
136
|
+
for (const ep of existing.endpoints) {
|
|
137
|
+
existingMap.set(matchKey(ep.method, ep.path), ep);
|
|
138
|
+
}
|
|
139
|
+
// Build a map from match-key → imported endpoint
|
|
140
|
+
const importedMap = new Map();
|
|
141
|
+
for (const ep of imported) {
|
|
142
|
+
const key = matchKey(ep.method, ep.path);
|
|
143
|
+
// If multiple imported endpoints map to the same key, last wins
|
|
144
|
+
if (importedMap.has(key)) {
|
|
145
|
+
process.stderr.write(`[openapi-import] Warning: ${ep.method} ${ep.path} collides with existing import after normalization\n`);
|
|
146
|
+
}
|
|
147
|
+
importedMap.set(key, ep);
|
|
148
|
+
}
|
|
149
|
+
// Process: update or preserve existing endpoints
|
|
150
|
+
const resultEndpoints = [];
|
|
151
|
+
for (const [key, existingEp] of existingMap) {
|
|
152
|
+
const importedEp = importedMap.get(key);
|
|
153
|
+
if (!importedEp) {
|
|
154
|
+
// Not in import — preserve as-is (captured endpoint with no match in spec)
|
|
155
|
+
resultEndpoints.push({
|
|
156
|
+
...existingEp,
|
|
157
|
+
normalizedPath: normalizePath(existingEp.path),
|
|
158
|
+
});
|
|
159
|
+
preserved++;
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
// Imported endpoint matches an existing one — check if it would add anything new
|
|
163
|
+
if (!wouldEnrich(existingEp, importedEp)) {
|
|
164
|
+
resultEndpoints.push({
|
|
165
|
+
...existingEp,
|
|
166
|
+
normalizedPath: normalizePath(existingEp.path),
|
|
167
|
+
});
|
|
168
|
+
// "skipped" means the import is redundant — existing already has spec metadata.
|
|
169
|
+
// "preserved" means the captured endpoint is untouched (import had nothing for it,
|
|
170
|
+
// or both sides are bare with no spec data to exchange).
|
|
171
|
+
const existingHasSpecData = !!(existingEp.specSource || existingEp.description);
|
|
172
|
+
const importHasSpecData = !!(importedEp.specSource || importedEp.description);
|
|
173
|
+
if (existingHasSpecData || importHasSpecData) {
|
|
174
|
+
// Spec data was already integrated (or import tried to add it but it's already present)
|
|
175
|
+
skipped++;
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
// Neither side has spec enrichment data — captured endpoint simply preserved
|
|
179
|
+
preserved++;
|
|
180
|
+
}
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
// Enrich the captured endpoint with spec metadata
|
|
184
|
+
const mergedQueryParams = mergeQueryParams(existingEp.queryParams, importedEp.queryParams);
|
|
185
|
+
const enrichedEp = {
|
|
186
|
+
...existingEp,
|
|
187
|
+
normalizedPath: normalizePath(existingEp.path),
|
|
188
|
+
// Augment with spec fields (only if not already present)
|
|
189
|
+
...(importedEp.description && !existingEp.description ? { description: importedEp.description } : {}),
|
|
190
|
+
...(importedEp.specSource && !existingEp.specSource ? { specSource: importedEp.specSource } : {}),
|
|
191
|
+
// Confidence never downgrades
|
|
192
|
+
confidence: Math.max(existingEp.confidence ?? 0, importedEp.confidence ?? 0) || existingEp.confidence,
|
|
193
|
+
// Keep captured provenance
|
|
194
|
+
endpointProvenance: existingEp.endpointProvenance,
|
|
195
|
+
queryParams: mergedQueryParams,
|
|
196
|
+
};
|
|
197
|
+
resultEndpoints.push(enrichedEp);
|
|
198
|
+
enriched++;
|
|
199
|
+
}
|
|
200
|
+
// Add endpoints from import that don't exist in the existing file
|
|
201
|
+
for (const [key, importedEp] of importedMap) {
|
|
202
|
+
if (!existingMap.has(key)) {
|
|
203
|
+
resultEndpoints.push({
|
|
204
|
+
...importedEp,
|
|
205
|
+
normalizedPath: normalizePath(importedEp.path),
|
|
206
|
+
});
|
|
207
|
+
added++;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
// Build updated import history
|
|
211
|
+
const prevHistory = existing.metadata.importHistory ?? [];
|
|
212
|
+
const newHistoryEntry = {
|
|
213
|
+
specUrl: importMeta.specUrl,
|
|
214
|
+
specVersion: importMeta.specVersion,
|
|
215
|
+
importedAt: now,
|
|
216
|
+
endpointsAdded: added,
|
|
217
|
+
endpointsEnriched: enriched,
|
|
218
|
+
};
|
|
219
|
+
const skillFile = {
|
|
220
|
+
...existing,
|
|
221
|
+
endpoints: resultEndpoints,
|
|
222
|
+
metadata: {
|
|
223
|
+
...existing.metadata,
|
|
224
|
+
importHistory: [...prevHistory, newHistoryEntry],
|
|
225
|
+
},
|
|
226
|
+
};
|
|
227
|
+
return {
|
|
228
|
+
skillFile,
|
|
229
|
+
diff: { preserved, added, enriched, skipped },
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
// ---------------------------------------------------------------------------
|
|
233
|
+
// Internal helpers
|
|
234
|
+
// ---------------------------------------------------------------------------
|
|
235
|
+
function extractDomainFromMeta(meta) {
|
|
236
|
+
try {
|
|
237
|
+
return new URL(meta.specUrl).hostname;
|
|
238
|
+
}
|
|
239
|
+
catch {
|
|
240
|
+
throw new Error(`Cannot determine domain from specUrl: ${meta.specUrl}`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
function extractBaseUrlFromMeta(meta) {
|
|
244
|
+
try {
|
|
245
|
+
const u = new URL(meta.specUrl);
|
|
246
|
+
return `${u.protocol}//${u.hostname}`;
|
|
247
|
+
}
|
|
248
|
+
catch {
|
|
249
|
+
throw new Error(`Cannot determine base URL from specUrl: ${meta.specUrl}`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
//# sourceMappingURL=merge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/skill/merge.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;AAC9C,CAAC;AAED;;GAEG;AACH,SAAS,QAAQ,CAAC,MAAc,EAAE,IAAY;IAC5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G,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC;IACxC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,2CAA2C,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ImportResult } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve a JSON $ref pointer in an OpenAPI spec.
|
|
4
|
+
* Uses a visited set to detect cycles and a depth limit as safety net.
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveRef(obj: any, spec: Record<string, any>, visited?: Set<string>, depth?: number): any;
|
|
7
|
+
export declare function extractDomainAndBasePath(spec: Record<string, any>, specUrl: string): {
|
|
8
|
+
domain: string;
|
|
9
|
+
basePath: string;
|
|
10
|
+
};
|
|
11
|
+
export interface ConfidenceInput {
|
|
12
|
+
method: string;
|
|
13
|
+
hasExamples: boolean;
|
|
14
|
+
requiresAuth: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function computeConfidence(input: ConfidenceInput): number;
|
|
17
|
+
export type AuthType = 'apiKey' | 'oauth2' | 'bearer' | 'basic' | 'openIdConnect';
|
|
18
|
+
export declare function detectAuth(spec: Record<string, any>): {
|
|
19
|
+
requiresAuth: boolean;
|
|
20
|
+
authType?: AuthType;
|
|
21
|
+
};
|
|
22
|
+
export declare function generateEndpointId(method: string, path: string, operationId: string | undefined, seen: Set<string>): string;
|
|
23
|
+
/**
|
|
24
|
+
* Detect whether a parsed JSON object is an OpenAPI/Swagger spec.
|
|
25
|
+
* Returns false for SkillFile objects (which have version+domain+baseUrl+endpoints).
|
|
26
|
+
*/
|
|
27
|
+
export declare function isOpenAPISpec(obj: unknown): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Convert an OpenAPI 3.x or Swagger 2.0 spec into an ImportResult.
|
|
30
|
+
*/
|
|
31
|
+
export declare function convertOpenAPISpec(spec: Record<string, any>, specUrl: string): ImportResult;
|