@http-forge/core 0.4.7 → 0.5.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 +42 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +206 -206
- package/dist/index.mjs +206 -206
- package/dist/infrastructure/auth/oauth2-token-manager.d.ts +1 -1
- package/dist/infrastructure/config/config.interface.d.ts +22 -0
- package/dist/infrastructure/config/index.d.ts +1 -1
- package/dist/infrastructure/script/interfaces.d.ts +7 -1
- package/dist/infrastructure/script/request-script-session.d.ts +13 -0
- package/dist/infrastructure/script/script-factories.d.ts +57 -6
- package/dist/infrastructure/script/script-utils.d.ts +14 -0
- package/dist/runtime/mcp-tool-name.d.ts +64 -0
- package/dist/runtime/mcp-tool-schemas.d.ts +192 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -252,6 +252,35 @@ if (pm.response.headers.has('Set-Cookie')) {
|
|
|
252
252
|
}
|
|
253
253
|
```
|
|
254
254
|
|
|
255
|
+
#### Response Body Type
|
|
256
|
+
|
|
257
|
+
Like Postman, `pm.response.body` is the **raw response string** — it is not eagerly parsed. Parse JSON on demand:
|
|
258
|
+
|
|
259
|
+
```javascript
|
|
260
|
+
const data = pm.response.json(); // parsed object (null if not JSON)
|
|
261
|
+
const text = pm.response.text(); // raw string
|
|
262
|
+
const obj = JSON.parse(pm.response.body); // body is a string
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
`json()` tolerates an already-parsed object body for backward compatibility, but new code should treat `pm.response.body` as a string.
|
|
266
|
+
|
|
267
|
+
#### Legacy Postman Globals
|
|
268
|
+
|
|
269
|
+
Older Postman scripts and many Newman-exported collections rely on bare globals from the pre-`pm.*` sandbox. The core injects these so legacy scripts run unchanged.
|
|
270
|
+
|
|
271
|
+
Available in **both** pre-request and test scripts: `request` (`{ id, name, description, url, method, headers, data }`), `environment` (read snapshot), `globals` (read snapshot), `data` (iteration row), `iteration` (index), and `tv4` (`tv4.validate(data, schema)` — when the optional `tv4` module is installed).
|
|
272
|
+
|
|
273
|
+
Available in **test** scripts only: `responseBody` (raw string), `responseCode` (`{ code, name, detail }`), `responseHeaders`, `responseTime`, `responseCookies` (cookie objects with `name`, `value`, `domain`, `path`, `expires`, `maxAge`, `httpOnly`, `secure`, `sameSite`), `tests` (`tests['name'] = boolean`), plus `postman.getResponseHeader(name)` and `postman.getResponseCookie(name)` (case-insensitive; `getResponseCookie` returns the full cookie object, both return `null` if absent).
|
|
274
|
+
|
|
275
|
+
```javascript
|
|
276
|
+
// Legacy-style test script — runs unmodified
|
|
277
|
+
tests['status 200'] = responseCode.code === 200;
|
|
278
|
+
tests['has token'] = JSON.parse(responseBody).token !== undefined;
|
|
279
|
+
tests['is json'] = /application\/json/.test(postman.getResponseHeader('Content-Type'));
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
> `environment` and `globals` are read snapshots — direct assignment was never persisted in legacy Postman either. Use `postman.setEnvironmentVariable()` / `postman.setGlobalVariable()` (or the modern `pm.environment.set()` / `pm.globals.set()`) to persist changes.
|
|
283
|
+
|
|
255
284
|
#### Script Scope
|
|
256
285
|
|
|
257
286
|
Control how script levels (collection → folder → request) and the pre-request/post-response phases share a JavaScript scope via `scripts.scope` in `http-forge.config.json` (or the `scriptScope` SDK option):
|
|
@@ -400,6 +429,11 @@ pm.response.cookies.forEach(cookie => {
|
|
|
400
429
|
pm.cookies.set(cookie.name, cookie.value);
|
|
401
430
|
});
|
|
402
431
|
|
|
432
|
+
// Read a response cookie (Postman-compatible CookieList)
|
|
433
|
+
const sid = pm.response.cookies.get('sessionId'); // value string
|
|
434
|
+
const sidCookie = pm.response.cookies.one('sessionId'); // full object
|
|
435
|
+
if (sidCookie?.secure && sidCookie.maxAge > 0) { /* ... */ }
|
|
436
|
+
|
|
403
437
|
// List all active cookies
|
|
404
438
|
const allCookies = pm.cookies.list(); // [{name, value}, ...]
|
|
405
439
|
|
|
@@ -655,12 +689,20 @@ interface McpConfig {
|
|
|
655
689
|
excludedSuites: string[]; // IDs or names to hide (default: [] = expose all)
|
|
656
690
|
toolPrefix: string; // Prefix for every tool name (default: "")
|
|
657
691
|
maxRequestsPerCall: number; // Safety cap per collection/suite call (default: 50)
|
|
692
|
+
toolMode: 'flat' | 'drilldown' | 'auto'; // How tools are exposed (default: 'flat')
|
|
693
|
+
drilldownThreshold: number; // 'auto' switches to drill-down above this request-tool count (default: 200)
|
|
658
694
|
cors: {
|
|
659
695
|
allowedOrigins: string[]; // CORS origins (default: ["http://localhost","http://127.0.0.1"])
|
|
660
696
|
};
|
|
661
697
|
}
|
|
662
698
|
```
|
|
663
699
|
|
|
700
|
+
**`toolMode`** controls how collections/requests are surfaced as MCP tools:
|
|
701
|
+
|
|
702
|
+
- `flat` (default) — one tool per request, folder, collection, and suite. Richest discoverability; best for normal workspaces.
|
|
703
|
+
- `drilldown` — a small fixed set of generic tools (`list_collections`, `list_requests`, `run_request`, `run_folder`, `run_collection`, `run_suite`) whose arguments select the target. Collection/suite names are advertised as JSON-schema `enum`s so agents pick real values. Keeps the tool list tiny for very large workspaces.
|
|
704
|
+
- `auto` — stays `flat` until the per-request tool count would exceed `drilldownThreshold`, then switches to `drilldown`.
|
|
705
|
+
|
|
664
706
|
Use `IConfigService.getMcpConfig()` to read the resolved config with all defaults applied.
|
|
665
707
|
|
|
666
708
|
---
|
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,10 @@ export { ForgeContainer } from './container';
|
|
|
20
20
|
export type { ForgeContainerOptions, StorageFormat } from './container';
|
|
21
21
|
export { getServiceContainer, registerCoreServices, ServiceContainer, ServiceIdentifiers } from './di';
|
|
22
22
|
export type { PlatformAdapters, ServiceIdentifier } from './di';
|
|
23
|
+
export { buildCollectionToolDescription, buildCollectionToolName, buildFolderToolDescription, buildFolderToolName, buildRequestToolDescription, buildRequestToolName, buildSuiteToolDescription, buildSuiteToolName, mcpToolSegment, mcpToolToken, parseMcpToolName, resolveFolderToken, resolveToken } from './runtime/mcp-tool-name';
|
|
24
|
+
export type { McpToolKind, ParsedMcpToolName } from './runtime/mcp-tool-name';
|
|
25
|
+
export { buildGenericTools, COLLECTION_INPUT_SCHEMA, FOLDER_INPUT_SCHEMA, GENERIC_TOOL_NAMES, REQUEST_INPUT_SCHEMA, SUITE_INPUT_SCHEMA } from './runtime/mcp-tool-schemas';
|
|
26
|
+
export type { GenericToolName } from './runtime/mcp-tool-schemas';
|
|
23
27
|
export { createMcpRuntime, runCollection, runFolder, runRequest, runSuite } from './runtime/runtime-contracts';
|
|
24
28
|
export type { McpRuntimeHandle, McpRuntimeOptions, RunCollectionOptions, RunRequestOptions, RunSuiteOptions } from './runtime/runtime-contracts';
|
|
25
29
|
export { bootstrapNodeRuntime, createNodeContainer } from './runtime/node-bootstrap';
|
|
@@ -99,7 +103,7 @@ export { ExampleGenerator, HistoryAnalyzer, OpenApiExporter, OpenApiImporter, Re
|
|
|
99
103
|
export type { OpenApiExportOptions, OpenApiImportOptions, ScriptAnalysisResult } from './infrastructure/openapi';
|
|
100
104
|
export * from './infrastructure/openapi/interfaces';
|
|
101
105
|
export { CONFIG_FILES, ConfigService, DEFAULT_CONFIG, ROOT_DIRECTORIES } from './infrastructure/config';
|
|
102
|
-
export type { EnvironmentsConfig, HttpForgeConfig, IConfigService, McpConfig, McpCorsConfig, ProxyConfig, RequestConfig, RestClientExportConfig, RunnerConfig, ScriptsConfig, StorageConfig } from './infrastructure/config';
|
|
106
|
+
export type { EnvironmentsConfig, HttpForgeConfig, IConfigService, McpConfig, McpCorsConfig, McpToolMode, ProxyConfig, RequestConfig, RestClientExportConfig, RunnerConfig, ScriptsConfig, StorageConfig } from './infrastructure/config';
|
|
103
107
|
export { HtmlReportGenerator } from './infrastructure/test-suite/html-report-generator';
|
|
104
108
|
export { DEFAULT_SUITE_CONFIG } from './infrastructure/test-suite/interfaces';
|
|
105
109
|
export type { ErrorSummary, IStatisticsService, ITestSuiteService, RequestStatistics, RunStatistics, RunSummary, SuiteConfig, SuiteRequest, TestSuite } from './infrastructure/test-suite/interfaces';
|