@http-forge/core 0.4.4 → 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 +15 -0
- package/dist/container.d.ts +6 -1
- package/dist/index.js +156 -150
- package/dist/index.mjs +141 -135
- package/dist/infrastructure/collection/folder-collection-store.d.ts +7 -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
|
@@ -183,6 +183,13 @@ export declare class FolderCollectionStore implements ICollectionStore {
|
|
|
183
183
|
*/
|
|
184
184
|
private sortItemsByOrder;
|
|
185
185
|
private findItemPath;
|
|
186
|
+
/**
|
|
187
|
+
* Build the on-disk slug path (root → item) for the given item id by walking the
|
|
188
|
+
* in-memory collection tree. Each segment is resolved via idToSlugMap so it matches
|
|
189
|
+
* the folder names produced during save. Returns undefined if the item is not found
|
|
190
|
+
* or any ancestor lacks a known slug.
|
|
191
|
+
*/
|
|
192
|
+
private buildSlugPath;
|
|
186
193
|
private findItemById;
|
|
187
194
|
private deleteItemFromTree;
|
|
188
195
|
}
|
|
@@ -105,6 +105,15 @@ export declare function sortItemsByOrder<T extends {
|
|
|
105
105
|
* Recursively search for a directory named targetSlug under basePath.
|
|
106
106
|
*/
|
|
107
107
|
export declare function searchForItemPath(basePath: string, targetSlug: string): string | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* Recursively search for the directory whose metadata id equals targetId.
|
|
110
|
+
*
|
|
111
|
+
* Ids are globally unique, whereas slugs are de-duplicated only among siblings — so two
|
|
112
|
+
* items with the same name in different folders share a leaf slug. Resolving by id (reading
|
|
113
|
+
* each candidate's metadata) guarantees that only the directory belonging to that exact id
|
|
114
|
+
* is matched, regardless of slug collisions.
|
|
115
|
+
*/
|
|
116
|
+
export declare function searchForItemPathById(basePath: string, targetId: string): string | undefined;
|
|
108
117
|
/**
|
|
109
118
|
* Generate a slug from a name.
|
|
110
119
|
* Handles HTTP method prefixes, version indicators (T7, 1.5), path parameters,
|
|
@@ -65,6 +65,7 @@ export declare class ConfigService implements IConfigService {
|
|
|
65
65
|
getResultsPath(): string;
|
|
66
66
|
getSuitesPath(): string;
|
|
67
67
|
getModulePaths(): string[];
|
|
68
|
+
getScriptScope(): 'shared' | 'isolated';
|
|
68
69
|
getWorkspacePath(): string;
|
|
69
70
|
reload(): void;
|
|
70
71
|
configExists(): boolean;
|
|
@@ -35,6 +35,15 @@ export interface RequestConfig {
|
|
|
35
35
|
export interface ScriptsConfig {
|
|
36
36
|
/** Paths to search for importable modules (relative to workspace) */
|
|
37
37
|
modulePaths: string[];
|
|
38
|
+
/**
|
|
39
|
+
* Script scope mode.
|
|
40
|
+
* - 'shared' (default): all script levels run in one shared scope; var/function
|
|
41
|
+
* declarations leak across levels and across pre-request/post-response phases.
|
|
42
|
+
* Lowest overhead; preserves existing behavior.
|
|
43
|
+
* - 'isolated': each script level runs in its own scope (Postman-compatible). State
|
|
44
|
+
* must pass through pm.variables / pm.environment / pm.globals.
|
|
45
|
+
*/
|
|
46
|
+
scope?: 'shared' | 'isolated';
|
|
38
47
|
}
|
|
39
48
|
/**
|
|
40
49
|
* Runner configuration
|
|
@@ -201,6 +210,8 @@ export interface IConfigService {
|
|
|
201
210
|
getSuitesPath(): string;
|
|
202
211
|
/** Get resolved module paths for script imports */
|
|
203
212
|
getModulePaths(): string[];
|
|
213
|
+
/** Get the script scope mode ('shared' default, or 'isolated' for Postman parity) */
|
|
214
|
+
getScriptScope(): 'shared' | 'isolated';
|
|
204
215
|
/** Get the workspace root path */
|
|
205
216
|
getWorkspacePath(): string;
|
|
206
217
|
/** Reload configuration from disk */
|
|
@@ -16,6 +16,8 @@ import { CommonScriptContext, IRequestScriptSession, PostResponseScriptResult, P
|
|
|
16
16
|
export interface SessionDependencies {
|
|
17
17
|
createVM: (ctx: any, scriptConsole: any) => vm.Context;
|
|
18
18
|
createCommonContext: (context: CommonScriptContext, eventName: 'prerequest' | 'test') => any;
|
|
19
|
+
/** When true, each script level runs in its own scope (Postman-compatible). */
|
|
20
|
+
isolateScripts?: boolean;
|
|
19
21
|
}
|
|
20
22
|
/**
|
|
21
23
|
* Request Script Session Implementation
|
|
@@ -22,8 +22,9 @@ import { IRequestScriptSession, IScriptExecutor, PreRequestScriptContext } from
|
|
|
22
22
|
export declare class ScriptExecutor implements IScriptExecutor {
|
|
23
23
|
private readonly httpService?;
|
|
24
24
|
private readonly secretRegistry?;
|
|
25
|
+
private readonly scopeMode;
|
|
25
26
|
private readonly moduleLoader;
|
|
26
|
-
constructor(httpService?: IHttpRequestService | undefined, modulePaths?: string[], secretRegistry?: SecretResolverRegistry | undefined);
|
|
27
|
+
constructor(httpService?: IHttpRequestService | undefined, modulePaths?: string[], secretRegistry?: SecretResolverRegistry | undefined, scopeMode?: 'shared' | 'isolated');
|
|
27
28
|
/**
|
|
28
29
|
* Create a request execution session
|
|
29
30
|
* Factory method implementing IScriptExecutor
|
|
@@ -13,10 +13,17 @@ export interface ConsoleMessage {
|
|
|
13
13
|
args: any[];
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* Concatenate multiple scripts into one
|
|
17
|
-
*
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
* Concatenate multiple scripts into one program.
|
|
17
|
+
*
|
|
18
|
+
* - shared (default): scripts are joined into one scope, so variables/functions declared
|
|
19
|
+
* in an earlier script are visible to later scripts (and, via var/function hoisting onto
|
|
20
|
+
* the shared VM global, to the post-response phase).
|
|
21
|
+
* - isolated: each script unit is wrapped in its own async IIFE, so its var/const/let/function
|
|
22
|
+
* declarations cannot collide within a phase or leak across phases (Postman parity). The
|
|
23
|
+
* whole batch is wrapped in one outer async IIFE so top-level `await` inside any unit works
|
|
24
|
+
* and the program resolves to an awaitable promise.
|
|
25
|
+
*/
|
|
26
|
+
export declare function concatenateScripts(scripts: string | string[], isolate?: boolean): string;
|
|
20
27
|
/**
|
|
21
28
|
* Check if an object has changed from its original value
|
|
22
29
|
* Uses JSON serialization for deep comparison
|
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
export declare function sanitizeName(name: string): string;
|
|
11
11
|
/**
|
|
12
12
|
* Generate a unique identifier.
|
|
13
|
-
*
|
|
13
|
+
* Combines a base-36 timestamp, a per-process monotonic counter, and a random
|
|
14
|
+
* suffix so ids created in the same millisecond are still distinct.
|
|
14
15
|
* Optional prefix is sanitized and prepended.
|
|
15
16
|
*/
|
|
16
17
|
export declare function generateId(prefix?: string): string;
|
package/package.json
CHANGED