@http-forge/core 0.6.38 → 0.6.40
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 +47 -0
- package/dist/index.js +213 -213
- package/dist/index.mjs +204 -204
- package/dist/infrastructure/analysis/ai-env-suggester.d.ts +1 -1
- package/dist/infrastructure/collection/collection-service.d.ts +5 -0
- package/dist/infrastructure/collection/collection-store.d.ts +22 -0
- package/dist/infrastructure/collection/folder-collection-store.d.ts +36 -22
- package/dist/infrastructure/collection/json-collection-loader.d.ts +1 -1
- package/dist/infrastructure/config/config-service.d.ts +12 -4
- package/dist/infrastructure/test-suite/test-suite-service.d.ts +1 -1
- package/dist/runtime/mcp-handlers/helpers.d.ts +7 -0
- package/dist/types/collection.d.ts +5 -0
- package/package.json +8 -3
|
@@ -19,4 +19,4 @@ import type { EnvSuggestion } from './env-suggester';
|
|
|
19
19
|
* @param aiProvider Any IAiProvider (Copilot, OpenAI, Anthropic, …).
|
|
20
20
|
* @returns Suggestions sorted by occurrence count descending.
|
|
21
21
|
*/
|
|
22
|
-
export declare function scanCollectionForEnvVarsWithAi(collection: Collection, aiProvider: IAiProvider): Promise<EnvSuggestion[]>;
|
|
22
|
+
export declare function scanCollectionForEnvVarsWithAi(collection: Collection, aiProvider: IAiProvider, collectionService?: Pick<import('../../types/collection').ICollectionService, 'getRequestDetail'>): Promise<EnvSuggestion[]>;
|
|
@@ -43,6 +43,11 @@ export declare class CollectionService implements ICollectionService {
|
|
|
43
43
|
constructor(configService: IConfigService, fileWatcherFactory?: IFileWatcherFactory | undefined);
|
|
44
44
|
private ensureCollectionsDir;
|
|
45
45
|
private loadCollections;
|
|
46
|
+
/**
|
|
47
|
+
* Load heavy request detail on demand (body, scripts, schemas, doc).
|
|
48
|
+
* No-op for stores without lazy support (e.g. JSON format) — falls back to `findRequest`.
|
|
49
|
+
*/
|
|
50
|
+
getRequestDetail(collectionId: string, requestId: string): CollectionRequestItem | undefined;
|
|
46
51
|
private setupFileWatcher;
|
|
47
52
|
getAllCollections(): Collection[];
|
|
48
53
|
getCollection(id: string): Collection | undefined;
|
|
@@ -82,7 +82,29 @@ export interface ICollectionStore {
|
|
|
82
82
|
* Get the disk path of an item (folder or request) within a collection
|
|
83
83
|
*/
|
|
84
84
|
getItemPath(collectionId: string, itemId: string): string | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Load heavy request detail (body, scripts, schemas, doc) on demand.
|
|
87
|
+
* Used to keep `loadAll()` light for tree view and defer I/O until a request is opened/executed.
|
|
88
|
+
*/
|
|
89
|
+
loadRequestDetail?(collectionId: string, requestId: string): CollectionItem | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Load all collections in light mode (cheap metadata only, no body/scripts/schemas/doc).
|
|
92
|
+
* Optimized for tree view and startup.
|
|
93
|
+
*/
|
|
94
|
+
loadAllLight?(): Collection[];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* In-memory marker for requests loaded via `loadAllLight()`.
|
|
98
|
+
* Never persisted to disk — set only on the in-memory item and cleared by
|
|
99
|
+
* `loadRequestDetail()` once heavy fields are enriched (or enrichment is attempted).
|
|
100
|
+
*/
|
|
101
|
+
export interface LightLoadedRequest {
|
|
102
|
+
_light?: boolean;
|
|
85
103
|
}
|
|
104
|
+
/** True when the item still needs on-demand heavy-field enrichment. */
|
|
105
|
+
export declare function isLightLoaded(item: CollectionItem): boolean;
|
|
106
|
+
/** Mark an item as fully loaded (enriched, or enrichment attempted). */
|
|
107
|
+
export declare function markDetailLoaded(item: CollectionItem): void;
|
|
86
108
|
/**
|
|
87
109
|
* Metadata stored in collection.json for folder format
|
|
88
110
|
*/
|
|
@@ -36,6 +36,11 @@ export declare class FolderCollectionStore implements ICollectionStore {
|
|
|
36
36
|
private cache;
|
|
37
37
|
private slugToIdMap;
|
|
38
38
|
private idToSlugMap;
|
|
39
|
+
/**
|
|
40
|
+
* When true, `loadRequestFromDir` delegates to the light loader
|
|
41
|
+
* (metadata only). Set only inside `loadAllLight()`; never left on.
|
|
42
|
+
*/
|
|
43
|
+
private lightLoad;
|
|
39
44
|
constructor(collectionsDir: string);
|
|
40
45
|
/**
|
|
41
46
|
* Get collection/item slug from ID
|
|
@@ -49,6 +54,7 @@ export declare class FolderCollectionStore implements ICollectionStore {
|
|
|
49
54
|
* Ensure collections directory exists, and write AGENTS.md to the forge root
|
|
50
55
|
* (.http-forge/) on first initialisation so AI agents can discover the workspace
|
|
51
56
|
* schema without needing MCP tools.
|
|
57
|
+
* Only called when actually saving data, not on construction.
|
|
52
58
|
*/
|
|
53
59
|
private ensureDirectory;
|
|
54
60
|
/**
|
|
@@ -89,31 +95,26 @@ export declare class FolderCollectionStore implements ICollectionStore {
|
|
|
89
95
|
* Load a folder from directory
|
|
90
96
|
*/
|
|
91
97
|
private loadFolderFromDir;
|
|
98
|
+
/**
|
|
99
|
+
* Load a request from directory — light mode (cheap metadata only, no heavy I/O).
|
|
100
|
+
* Used by `loadAllLight()` for tree view / startup optimization.
|
|
101
|
+
*/
|
|
102
|
+
private loadRequestFromDirLight;
|
|
103
|
+
/**
|
|
104
|
+
* Load heavy request detail on demand (body, scripts, schemas, doc).
|
|
105
|
+
* Populates the cached collection item in-place when found.
|
|
106
|
+
* Idempotent: items that are already fully loaded are returned without disk I/O.
|
|
107
|
+
*/
|
|
108
|
+
loadRequestDetail(collectionId: string, requestId: string): CollectionItem | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* Load all collections in light mode (no heavy I/O) — optimized for startup/tree view.
|
|
111
|
+
*/
|
|
112
|
+
loadAllLight(): Collection[];
|
|
92
113
|
/**
|
|
93
114
|
* Load a request from directory
|
|
94
115
|
*
|
|
95
|
-
*
|
|
96
|
-
* startup
|
|
97
|
-
* and docs can consume hundreds of MB of heap.
|
|
98
|
-
*
|
|
99
|
-
* The fix is to load only cheap metadata here (url, method, headers, auth, settings,
|
|
100
|
-
* name, description, deprecated) and introduce an on-demand
|
|
101
|
-
* `loadRequestDetail(requestPath)` that reads the heavy fields only when a request is
|
|
102
|
-
* actually opened or executed.
|
|
103
|
-
*
|
|
104
|
-
* Heavy fields to defer:
|
|
105
|
-
* - body (readBodyFromDir) — up to 100 KB+
|
|
106
|
-
* - scripts (loadScriptsFromDir) — pre/post JS source, up to 20 KB
|
|
107
|
-
* - responseSchema (readSchemaFile) — OpenAPI JSON, up to 1 MB+
|
|
108
|
-
* - bodySchema (readSchemaFile) — OpenAPI JSON, up to 1 MB+
|
|
109
|
-
* - doc (fs.readFileSync doc.md) — markdown, up to 50 KB
|
|
110
|
-
*
|
|
111
|
-
* Callers that need the heavy fields:
|
|
112
|
-
* - CollectionRequestExecutor (body, scripts)
|
|
113
|
-
* - RequestExecutionHandler (body, scripts)
|
|
114
|
-
* - SchemaHandler (responseSchema, bodySchema)
|
|
115
|
-
* - PanelDataProvider.getInitialData() (sends full request to webview)
|
|
116
|
-
* - MCP direct-execution: runRequest / runCollection (body, scripts)
|
|
116
|
+
* Heavy fields are loaded eagerly here for backward compatibility (direct execution, tests).
|
|
117
|
+
* For startup optimization, use `loadAllLight()` + `loadRequestDetail()` on demand.
|
|
117
118
|
*/
|
|
118
119
|
private loadRequestFromDir;
|
|
119
120
|
/**
|
|
@@ -192,6 +193,19 @@ export declare class FolderCollectionStore implements ICollectionStore {
|
|
|
192
193
|
* Load scripts for a specific item
|
|
193
194
|
*/
|
|
194
195
|
loadScripts(collectionId: string, itemId: string): RequestScripts | undefined;
|
|
196
|
+
/**
|
|
197
|
+
* Hydrate light-loaded requests in place before a disk write.
|
|
198
|
+
* Saving a light item would otherwise persist metadata without its heavy
|
|
199
|
+
* files (e.g. overwrite body.json with empty content). The cache holds the
|
|
200
|
+
* same object references the service works with, so in-place enrichment
|
|
201
|
+
* fixes both the write and any live readers.
|
|
202
|
+
*/
|
|
203
|
+
private hydrateLightItems;
|
|
204
|
+
/**
|
|
205
|
+
* Resolve the request to persist: a detached light copy carries no heavy
|
|
206
|
+
* fields, so prefer the enriched cached item when available.
|
|
207
|
+
*/
|
|
208
|
+
private resolveWritableRequest;
|
|
195
209
|
/**
|
|
196
210
|
* Update collection metadata only
|
|
197
211
|
*/
|
|
@@ -18,7 +18,7 @@ export declare class JsonCollectionLoader implements ICollectionStore {
|
|
|
18
18
|
private cache;
|
|
19
19
|
constructor(collectionsDir: string);
|
|
20
20
|
/**
|
|
21
|
-
* Ensure collections directory exists
|
|
21
|
+
* Ensure collections directory exists (lazy)
|
|
22
22
|
*/
|
|
23
23
|
private ensureDirectory;
|
|
24
24
|
/**
|
|
@@ -21,8 +21,12 @@ export declare class ConfigService implements IConfigService {
|
|
|
21
21
|
private notifications?;
|
|
22
22
|
private config;
|
|
23
23
|
private configPath;
|
|
24
|
+
private configDir;
|
|
24
25
|
private fileWatchers;
|
|
26
|
+
private _standaloneProbeCache?;
|
|
27
|
+
private _cachedWorkspaceNormalization?;
|
|
25
28
|
constructor(workspacePath: string, fileWatcherFactory?: IFileWatcherFactory | undefined, notifications?: INotificationService | undefined);
|
|
29
|
+
private isStandaloneLayoutCached;
|
|
26
30
|
private normalizeWorkspacePath;
|
|
27
31
|
private resolveConfigPath;
|
|
28
32
|
/**
|
|
@@ -57,7 +61,11 @@ export declare class ConfigService implements IConfigService {
|
|
|
57
61
|
getDiscoveryConfig(): DiscoveryConfig;
|
|
58
62
|
getMcpConfig(): McpConfig;
|
|
59
63
|
/**
|
|
60
|
-
* Resolve a path relative to
|
|
64
|
+
* Resolve a path relative to the config file location.
|
|
65
|
+
* When a config file exists, paths are resolved against its directory.
|
|
66
|
+
* When no config exists, fallback to workspace root.
|
|
67
|
+
* Handles backward compatibility for configs inside .http-forge that used
|
|
68
|
+
* workspace-relative defaults like "./.http-forge/assets".
|
|
61
69
|
*/
|
|
62
70
|
private resolvePath;
|
|
63
71
|
/**
|
|
@@ -73,9 +81,8 @@ export declare class ConfigService implements IConfigService {
|
|
|
73
81
|
/**
|
|
74
82
|
* Resolve storage root with backward compatibility for config-less workspaces.
|
|
75
83
|
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* default location, prefer that legacy location so collections remain visible.
|
|
84
|
+
* Supports both integrated mode (workspace/.http-forge/assets) and standalone mode
|
|
85
|
+
* (workspace/assets) where .http-forge is opened as the workspace root.
|
|
79
86
|
*/
|
|
80
87
|
private resolveStorageRootPath;
|
|
81
88
|
getRootPath(): string;
|
|
@@ -92,6 +99,7 @@ export declare class ConfigService implements IConfigService {
|
|
|
92
99
|
onConfigReloaded?: () => void;
|
|
93
100
|
reload(): void;
|
|
94
101
|
configExists(): boolean;
|
|
102
|
+
private getDefaultConfigForCurrentLocation;
|
|
95
103
|
createDefaultConfig(): Promise<void>;
|
|
96
104
|
/**
|
|
97
105
|
* Create sample environment files
|
|
@@ -30,7 +30,7 @@ export declare class TestSuiteService implements ITestSuiteService {
|
|
|
30
30
|
onSuitesChanged?: SuitesChangedCallback;
|
|
31
31
|
});
|
|
32
32
|
/**
|
|
33
|
-
* Ensure suites directory exists
|
|
33
|
+
* Ensure suites directory exists (lazy — only when saving).
|
|
34
34
|
*/
|
|
35
35
|
private ensureSuitesDir;
|
|
36
36
|
/**
|
|
@@ -16,6 +16,13 @@ export declare function resolveCollectionByLabel(label: unknown, collections: Co
|
|
|
16
16
|
* name/substring.
|
|
17
17
|
*/
|
|
18
18
|
export declare function resolveRequestByLabel(label: unknown, col: Collection): CollectionRequestItem;
|
|
19
|
+
/**
|
|
20
|
+
* Hydrate a tree-resolved request with heavy fields (body/scripts/schemas/doc).
|
|
21
|
+
* Collections load light (metadata only); single-request readers must call this
|
|
22
|
+
* before touching heavy fields. Falls back to the passed item on stores
|
|
23
|
+
* without lazy support. List/match paths keep using light refs untouched.
|
|
24
|
+
*/
|
|
25
|
+
export declare function hydrateRequest(services: McpDispatchServices, collectionId: string, req: CollectionRequestItem): CollectionRequestItem;
|
|
19
26
|
/**
|
|
20
27
|
* Find a folder item in a collection tree by its ID.
|
|
21
28
|
*
|
|
@@ -66,6 +66,11 @@ export interface ICollectionReader {
|
|
|
66
66
|
getCollectionById(id: string): Collection | undefined;
|
|
67
67
|
getCollectionByName(name: string): Collection | undefined;
|
|
68
68
|
findRequest(collectionId: string, requestId: string): CollectionRequestItem | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Load heavy request detail (body, scripts, schemas, doc) on demand.
|
|
71
|
+
* Falls back to `findRequest` on stores without lazy support.
|
|
72
|
+
*/
|
|
73
|
+
getRequestDetail(collectionId: string, requestId: string): CollectionRequestItem | undefined;
|
|
69
74
|
getCollectionVariables(collectionId: string): Record<string, string>;
|
|
70
75
|
}
|
|
71
76
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@http-forge/core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.40",
|
|
4
4
|
"description": "Headless Postman-compatible API testing engine for Node.js, CI/CD, OpenAPI workflows, and HTTP Forge automation",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@apidevtools/json-schema-ref-parser": "^11.7.3",
|
|
69
69
|
"ajv": "^8.12.0",
|
|
70
70
|
"java-parser": "^3.0.1",
|
|
71
|
-
"lodash": "
|
|
71
|
+
"lodash": "4.18.1",
|
|
72
72
|
"moment": "^2.30.1",
|
|
73
73
|
"tv4": "^1.3.0",
|
|
74
74
|
"typescript": "^5.3.0",
|
|
@@ -100,10 +100,15 @@
|
|
|
100
100
|
"@types/node": "^20.10.0",
|
|
101
101
|
"@types/tv4": "^1.2.33",
|
|
102
102
|
"@types/uuid": "^9.0.7",
|
|
103
|
-
"esbuild": "
|
|
103
|
+
"esbuild": "0.28.2",
|
|
104
104
|
"rimraf": "^5.0.5",
|
|
105
105
|
"tsup": "^8.0.1",
|
|
106
106
|
"typescript": "^5.3.0",
|
|
107
107
|
"vitest": "^4.1.9"
|
|
108
|
+
},
|
|
109
|
+
"overrides": {
|
|
110
|
+
"esbuild": "0.28.2",
|
|
111
|
+
"lodash": "4.18.1",
|
|
112
|
+
"lodash-es": "4.18.1"
|
|
108
113
|
}
|
|
109
114
|
}
|