@http-forge/core 0.4.4 → 0.4.6

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 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
@@ -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 */