@http-forge/core 0.4.3 → 0.4.5
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 +23 -0
- package/dist/container.d.ts +6 -1
- package/dist/index.js +175 -169
- package/dist/index.mjs +161 -155
- package/dist/infrastructure/collection/collection-service.d.ts +2 -0
- package/dist/infrastructure/collection/folder-collection-store.d.ts +16 -0
- package/dist/infrastructure/collection/folder-io.d.ts +9 -0
- package/dist/infrastructure/config/config-service.d.ts +1 -0
- package/dist/infrastructure/config/config.interface.d.ts +11 -0
- package/dist/infrastructure/execution/request-executor.d.ts +1 -0
- package/dist/infrastructure/script/request-script-session.d.ts +2 -0
- package/dist/infrastructure/script/script-executor.d.ts +2 -1
- package/dist/infrastructure/script/script-utils.d.ts +11 -4
- package/dist/utils/helpers.d.ts +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -252,6 +252,21 @@ if (pm.response.headers.has('Set-Cookie')) {
|
|
|
252
252
|
}
|
|
253
253
|
```
|
|
254
254
|
|
|
255
|
+
#### Script Scope
|
|
256
|
+
|
|
257
|
+
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):
|
|
258
|
+
|
|
259
|
+
| Mode | Behavior |
|
|
260
|
+
|------|----------|
|
|
261
|
+
| `'shared'` *(default)* | All levels and both phases run in one scope. `var`/`function` and global assignments leak across them; lowest overhead. Top-level `let`/`const` are scoped to a single phase. |
|
|
262
|
+
| `'isolated'` | Each level runs in its own scope, matching Postman. Declarations cannot collide or leak; pass state through `pm.variables` / `pm.environment` / `pm.globals`. |
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
const forge = ForgeContainer.create({ scriptScope: 'isolated' });
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Use `'isolated'` when importing Postman collections whose scripts re-declare the same identifiers at multiple levels, which would otherwise throw `Identifier already declared` in shared mode.
|
|
269
|
+
|
|
255
270
|
### Environment Management
|
|
256
271
|
|
|
257
272
|
```typescript
|
|
@@ -549,6 +564,14 @@ Detects Postman format by `info._postman_id` and converts all five body modes:
|
|
|
549
564
|
|
|
550
565
|
Auth types `bearer`, `basic`, and `apikey` are converted. Pre-request and test scripts (`prerequest`/`test` events) are imported as `scripts.preRequest`/`scripts.postResponse`. Folder hierarchy and item order are preserved.
|
|
551
566
|
|
|
567
|
+
The whole collection is built in memory and persisted with a single `saveCollection()`
|
|
568
|
+
call. `FolderCollectionStore.save()` writes sibling items and each request's
|
|
569
|
+
independent files (body, docs, scripts, schemas) in parallel and writes each
|
|
570
|
+
metadata file once; fresh imports skip stale-body cleanup and schema-existence
|
|
571
|
+
probes. Loaders read JSON via a `readJsonFileSafe` helper that silently skips
|
|
572
|
+
empty or half-written files, so a watcher reloading mid-import never throws
|
|
573
|
+
`Unexpected end of JSON input`.
|
|
574
|
+
|
|
552
575
|
**Export** (`exportCollection(collectionId, filePath)`):
|
|
553
576
|
|
|
554
577
|
Converts back to Postman v2.1 JSON. All body types round-trip correctly: `x-www-form-urlencoded` exports as `mode: "urlencoded"`, `form-data` as `mode: "formdata"`, `graphql` as `mode: "graphql"`, and `binary` as `mode: "binary"`.
|
package/dist/container.d.ts
CHANGED
|
@@ -26,13 +26,13 @@ import { ParserRegistry } from './infrastructure/collection/parser-registry';
|
|
|
26
26
|
import { ICookieService } from './infrastructure/cookie/interfaces';
|
|
27
27
|
import { EnvironmentResolver, EnvironmentStoreConfig } from './infrastructure/environment/environment-resolver';
|
|
28
28
|
import { ForgeEnv } from './infrastructure/environment/forge-env';
|
|
29
|
-
import { IVariableInterpolator } from './types/environment-config';
|
|
30
29
|
import { RequestExecutor } from './infrastructure/execution/request-executor';
|
|
31
30
|
import { IRequestHistory } from './infrastructure/history/history-interfaces';
|
|
32
31
|
import { IErrorInterceptor, IInterceptorChain, IRequestInterceptor, IResponseInterceptor } from './infrastructure/http/interceptor-chain';
|
|
33
32
|
import { IRequestPreprocessor } from './infrastructure/http/request-preprocessor';
|
|
34
33
|
import { IDataFileParser } from './infrastructure/platform/data-file-parser';
|
|
35
34
|
import { IScriptExecutor } from './infrastructure/script/interfaces';
|
|
35
|
+
import { IVariableInterpolator } from './types/environment-config';
|
|
36
36
|
import { IFileSystem, IHttpClient } from './types/platform';
|
|
37
37
|
import { HttpRequest, HttpResponse, RequestSettings, UnifiedCollection, UnifiedRequest } from './types/types';
|
|
38
38
|
/**
|
|
@@ -71,6 +71,11 @@ export interface ForgeContainerOptions {
|
|
|
71
71
|
scriptExecutor?: IScriptExecutor;
|
|
72
72
|
/** Script execution timeout (ms) */
|
|
73
73
|
scriptTimeout?: number;
|
|
74
|
+
/**
|
|
75
|
+
* Script scope mode. 'shared' (default) runs all script levels in one scope;
|
|
76
|
+
* 'isolated' runs each level in its own scope for Postman compatibility.
|
|
77
|
+
*/
|
|
78
|
+
scriptScope?: 'shared' | 'isolated';
|
|
74
79
|
/** Custom file system implementation */
|
|
75
80
|
fileSystem?: IFileSystem;
|
|
76
81
|
/** Custom variable interpolator implementation */
|