callman-core 1.35.0 → 1.36.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/ai-packs/feature-policy.md +1 -6
- package/ai-packs/pm-api.md +238 -98
- package/ai-packs/sandbox-globals.md +6 -5
- package/dist/ai/prompts/fragments.d.ts.map +1 -1
- package/dist/ai/prompts/fragments.js +0 -1
- package/dist/ai/prompts/fragments.js.map +1 -1
- package/dist/ai/prompts/unified.js +1 -1
- package/dist/ai/prompts/unified.js.map +1 -1
- package/dist/ai/types.d.ts +1 -1
- package/dist/ai/types.d.ts.map +1 -1
- package/dist/ai/types.js +1 -1
- package/dist/ai/types.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/runner/requestRunner.d.ts.map +1 -1
- package/dist/runner/requestRunner.js +33 -0
- package/dist/runner/requestRunner.js.map +1 -1
- package/dist/runner/runCollection.d.ts.map +1 -1
- package/dist/runner/runCollection.js +46 -9
- package/dist/runner/runCollection.js.map +1 -1
- package/dist/runner/runRequestWithDataset.d.ts.map +1 -1
- package/dist/runner/runRequestWithDataset.js +3 -2
- package/dist/runner/runRequestWithDataset.js.map +1 -1
- package/dist/scenario-runner/adapters/request-executor.d.ts.map +1 -1
- package/dist/scenario-runner/adapters/request-executor.js +7 -0
- package/dist/scenario-runner/adapters/request-executor.js.map +1 -1
- package/dist/scenario-runner/runScenario.d.ts.map +1 -1
- package/dist/scenario-runner/runScenario.js +4 -0
- package/dist/scenario-runner/runScenario.js.map +1 -1
- package/dist/scenario-runner/types.d.ts +11 -0
- package/dist/scenario-runner/types.d.ts.map +1 -1
- package/dist/script/chain.d.ts +2 -0
- package/dist/script/chain.d.ts.map +1 -1
- package/dist/script/chain.js +2 -0
- package/dist/script/chain.js.map +1 -1
- package/dist/script/errors.js +6 -6
- package/dist/script/errors.js.map +1 -1
- package/dist/script/executor.d.ts.map +1 -1
- package/dist/script/executor.js +284 -64
- package/dist/script/executor.js.map +1 -1
- package/dist/script/features/collectionVariables.d.ts +4 -4
- package/dist/script/features/collectionVariables.d.ts.map +1 -1
- package/dist/script/features/collectionVariables.js +20 -11
- package/dist/script/features/collectionVariables.js.map +1 -1
- package/dist/script/features/environment.d.ts +4 -4
- package/dist/script/features/environment.d.ts.map +1 -1
- package/dist/script/features/environment.js +20 -11
- package/dist/script/features/environment.js.map +1 -1
- package/dist/script/features/feature-policy.d.ts +1 -1
- package/dist/script/features/feature-policy.d.ts.map +1 -1
- package/dist/script/features/feature-policy.js +2 -2
- package/dist/script/features/feature-policy.js.map +1 -1
- package/dist/script/features/info.d.ts.map +1 -1
- package/dist/script/features/info.js +6 -3
- package/dist/script/features/info.js.map +1 -1
- package/dist/script/features/iterationData.d.ts +12 -0
- package/dist/script/features/iterationData.d.ts.map +1 -0
- package/dist/script/features/iterationData.js +28 -0
- package/dist/script/features/iterationData.js.map +1 -0
- package/dist/script/features/legacyPostman.d.ts +14 -0
- package/dist/script/features/legacyPostman.d.ts.map +1 -0
- package/dist/script/features/legacyPostman.js +106 -0
- package/dist/script/features/legacyPostman.js.map +1 -0
- package/dist/script/features/log.d.ts +35 -8
- package/dist/script/features/log.d.ts.map +1 -1
- package/dist/script/features/log.js +343 -27
- package/dist/script/features/log.js.map +1 -1
- package/dist/script/features/tests.d.ts +7 -8
- package/dist/script/features/tests.d.ts.map +1 -1
- package/dist/script/features/tests.js +90 -64
- package/dist/script/features/tests.js.map +1 -1
- package/dist/script/features/timers.d.ts +7 -1
- package/dist/script/features/timers.d.ts.map +1 -1
- package/dist/script/features/timers.js +17 -5
- package/dist/script/features/timers.js.map +1 -1
- package/dist/script/features/variables.d.ts +19 -4
- package/dist/script/features/variables.d.ts.map +1 -1
- package/dist/script/features/variables.js +22 -6
- package/dist/script/features/variables.js.map +1 -1
- package/dist/script/features/visualizer.d.ts +15 -0
- package/dist/script/features/visualizer.d.ts.map +1 -0
- package/dist/script/features/visualizer.js +52 -0
- package/dist/script/features/visualizer.js.map +1 -0
- package/dist/script/isolated-runner.d.ts +4 -1
- package/dist/script/isolated-runner.d.ts.map +1 -1
- package/dist/script/isolated-runner.js +26 -2
- package/dist/script/isolated-runner.js.map +1 -1
- package/dist/script/legacy.d.ts +1 -0
- package/dist/script/legacy.d.ts.map +1 -1
- package/dist/script/legacy.js +12 -2
- package/dist/script/legacy.js.map +1 -1
- package/dist/script/pm-api-declarations.d.ts +45 -0
- package/dist/script/pm-api-declarations.d.ts.map +1 -0
- package/dist/script/pm-api-declarations.js +1963 -0
- package/dist/script/pm-api-declarations.js.map +1 -0
- package/dist/script/pm-api-metadata.d.ts +3 -1
- package/dist/script/pm-api-metadata.d.ts.map +1 -1
- package/dist/script/pm-api-metadata.js +336 -106
- package/dist/script/pm-api-metadata.js.map +1 -1
- package/dist/script/pm-api-reference.d.ts.map +1 -1
- package/dist/script/pm-api-reference.js +24 -8
- package/dist/script/pm-api-reference.js.map +1 -1
- package/dist/script/postman/chaiCompat.d.ts +4 -0
- package/dist/script/postman/chaiCompat.d.ts.map +1 -0
- package/dist/script/postman/chaiCompat.js +176 -0
- package/dist/script/postman/chaiCompat.js.map +1 -0
- package/dist/script/postman/cookies.d.ts +36 -0
- package/dist/script/postman/cookies.d.ts.map +1 -0
- package/dist/script/postman/cookies.js +163 -0
- package/dist/script/postman/cookies.js.map +1 -0
- package/dist/script/postman/modules.d.ts +16 -0
- package/dist/script/postman/modules.d.ts.map +1 -0
- package/dist/script/postman/modules.js +114 -0
- package/dist/script/postman/modules.js.map +1 -0
- package/dist/script/postman/proxies.d.ts +13 -0
- package/dist/script/postman/proxies.d.ts.map +1 -0
- package/dist/script/postman/proxies.js +88 -0
- package/dist/script/postman/proxies.js.map +1 -0
- package/dist/script/postman/requestAdapter.d.ts +7 -0
- package/dist/script/postman/requestAdapter.d.ts.map +1 -0
- package/dist/script/postman/requestAdapter.js +223 -0
- package/dist/script/postman/requestAdapter.js.map +1 -0
- package/dist/script/postman/responseAdapter.d.ts +5 -0
- package/dist/script/postman/responseAdapter.d.ts.map +1 -0
- package/dist/script/postman/responseAdapter.js +78 -0
- package/dist/script/postman/responseAdapter.js.map +1 -0
- package/dist/script/postman/runtime.d.ts +22 -0
- package/dist/script/postman/runtime.d.ts.map +1 -0
- package/dist/script/postman/runtime.js +122 -0
- package/dist/script/postman/runtime.js.map +1 -0
- package/dist/script/scope.d.ts +5 -1
- package/dist/script/scope.d.ts.map +1 -1
- package/dist/script/scope.js +47 -5
- package/dist/script/scope.js.map +1 -1
- package/dist/script/types.d.ts +33 -14
- package/dist/script/types.d.ts.map +1 -1
- package/dist/script/worker-entry.js +9 -0
- package/dist/script/worker-entry.js.map +1 -1
- package/dist/script/worker-pool.d.ts +3 -1
- package/dist/script/worker-pool.d.ts.map +1 -1
- package/dist/script/worker-pool.js +23 -2
- package/dist/script/worker-pool.js.map +1 -1
- package/dist/templating/generator-metadata.d.ts +1 -0
- package/dist/templating/generator-metadata.d.ts.map +1 -1
- package/dist/templating/generator-metadata.js +14 -0
- package/dist/templating/generator-metadata.js.map +1 -1
- package/dist/templating/postman-dynamic-catalog.d.ts +7 -0
- package/dist/templating/postman-dynamic-catalog.d.ts.map +1 -0
- package/dist/templating/postman-dynamic-catalog.js +126 -0
- package/dist/templating/postman-dynamic-catalog.js.map +1 -0
- package/dist/templating/postman-generators.d.ts +9 -0
- package/dist/templating/postman-generators.d.ts.map +1 -1
- package/dist/templating/postman-generators.js +10 -1
- package/dist/templating/postman-generators.js.map +1 -1
- package/dist/types/index.d.ts +22 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/variables/replaceIn.d.ts +10 -0
- package/dist/variables/replaceIn.d.ts.map +1 -0
- package/dist/variables/replaceIn.js +106 -0
- package/dist/variables/replaceIn.js.map +1 -0
- package/dist-cjs/ai/prompts/fragments.js +0 -1
- package/dist-cjs/ai/prompts/fragments.js.map +1 -1
- package/dist-cjs/ai/prompts/unified.js +1 -1
- package/dist-cjs/ai/prompts/unified.js.map +1 -1
- package/dist-cjs/ai/types.js +1 -1
- package/dist-cjs/ai/types.js.map +1 -1
- package/dist-cjs/index.js +17 -5
- package/dist-cjs/index.js.map +1 -1
- package/dist-cjs/runner/requestRunner.js +33 -0
- package/dist-cjs/runner/requestRunner.js.map +1 -1
- package/dist-cjs/runner/runCollection.js +46 -9
- package/dist-cjs/runner/runCollection.js.map +1 -1
- package/dist-cjs/runner/runRequestWithDataset.js +3 -2
- package/dist-cjs/runner/runRequestWithDataset.js.map +1 -1
- package/dist-cjs/scenario-runner/adapters/request-executor.js +7 -0
- package/dist-cjs/scenario-runner/adapters/request-executor.js.map +1 -1
- package/dist-cjs/scenario-runner/runScenario.js +4 -0
- package/dist-cjs/scenario-runner/runScenario.js.map +1 -1
- package/dist-cjs/script/chain.js +2 -0
- package/dist-cjs/script/chain.js.map +1 -1
- package/dist-cjs/script/errors.js +6 -6
- package/dist-cjs/script/errors.js.map +1 -1
- package/dist-cjs/script/executor.js +284 -64
- package/dist-cjs/script/executor.js.map +1 -1
- package/dist-cjs/script/features/collectionVariables.js +20 -11
- package/dist-cjs/script/features/collectionVariables.js.map +1 -1
- package/dist-cjs/script/features/environment.js +20 -11
- package/dist-cjs/script/features/environment.js.map +1 -1
- package/dist-cjs/script/features/feature-policy.js +2 -2
- package/dist-cjs/script/features/feature-policy.js.map +1 -1
- package/dist-cjs/script/features/info.js +6 -3
- package/dist-cjs/script/features/info.js.map +1 -1
- package/dist-cjs/script/features/iterationData.js +32 -0
- package/dist-cjs/script/features/iterationData.js.map +1 -0
- package/dist-cjs/script/features/legacyPostman.js +112 -0
- package/dist-cjs/script/features/legacyPostman.js.map +1 -0
- package/dist-cjs/script/features/log.js +347 -28
- package/dist-cjs/script/features/log.js.map +1 -1
- package/dist-cjs/script/features/tests.js +90 -64
- package/dist-cjs/script/features/tests.js.map +1 -1
- package/dist-cjs/script/features/timers.js +17 -5
- package/dist-cjs/script/features/timers.js.map +1 -1
- package/dist-cjs/script/features/variables.js +22 -6
- package/dist-cjs/script/features/variables.js.map +1 -1
- package/dist-cjs/script/features/visualizer.js +56 -0
- package/dist-cjs/script/features/visualizer.js.map +1 -0
- package/dist-cjs/script/isolated-runner.js +26 -2
- package/dist-cjs/script/isolated-runner.js.map +1 -1
- package/dist-cjs/script/legacy.js +14 -3
- package/dist-cjs/script/legacy.js.map +1 -1
- package/dist-cjs/script/pm-api-declarations.js +1969 -0
- package/dist-cjs/script/pm-api-declarations.js.map +1 -0
- package/dist-cjs/script/pm-api-metadata.js +336 -106
- package/dist-cjs/script/pm-api-metadata.js.map +1 -1
- package/dist-cjs/script/pm-api-reference.js +24 -8
- package/dist-cjs/script/pm-api-reference.js.map +1 -1
- package/dist-cjs/script/postman/chaiCompat.js +181 -0
- package/dist-cjs/script/postman/chaiCompat.js.map +1 -0
- package/dist-cjs/script/postman/cookies.js +170 -0
- package/dist-cjs/script/postman/cookies.js.map +1 -0
- package/dist-cjs/script/postman/modules.js +123 -0
- package/dist-cjs/script/postman/modules.js.map +1 -0
- package/dist-cjs/script/postman/proxies.js +93 -0
- package/dist-cjs/script/postman/proxies.js.map +1 -0
- package/dist-cjs/script/postman/requestAdapter.js +227 -0
- package/dist-cjs/script/postman/requestAdapter.js.map +1 -0
- package/dist-cjs/script/postman/responseAdapter.js +83 -0
- package/dist-cjs/script/postman/responseAdapter.js.map +1 -0
- package/dist-cjs/script/postman/runtime.js +132 -0
- package/dist-cjs/script/postman/runtime.js.map +1 -0
- package/dist-cjs/script/scope.js +47 -5
- package/dist-cjs/script/scope.js.map +1 -1
- package/dist-cjs/script/worker-entry.js +9 -0
- package/dist-cjs/script/worker-entry.js.map +1 -1
- package/dist-cjs/script/worker-pool.js +23 -2
- package/dist-cjs/script/worker-pool.js.map +1 -1
- package/dist-cjs/templating/generator-metadata.js +15 -1
- package/dist-cjs/templating/generator-metadata.js.map +1 -1
- package/dist-cjs/templating/postman-dynamic-catalog.js +129 -0
- package/dist-cjs/templating/postman-dynamic-catalog.js.map +1 -0
- package/dist-cjs/templating/postman-generators.js +13 -3
- package/dist-cjs/templating/postman-generators.js.map +1 -1
- package/dist-cjs/variables/replaceIn.js +111 -0
- package/dist-cjs/variables/replaceIn.js.map +1 -0
- package/package.json +12 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.js","sourceRoot":"","sources":["../../src/script/chain.ts"],"names":[],"mappings":";AAAA,oEAAoE;AACpE,8EAA8E;AAC9E,0EAA0E;AAC1E,yEAAyE;AACzE,+CAA+C;AAC/C,EAAE;AACF,wEAAwE;AACxE,yEAAyE;AACzE,yEAAyE;;;AAEzE,+CAA8C;
|
|
1
|
+
{"version":3,"file":"chain.js","sourceRoot":"","sources":["../../src/script/chain.ts"],"names":[],"mappings":";AAAA,oEAAoE;AACpE,8EAA8E;AAC9E,0EAA0E;AAC1E,yEAAyE;AACzE,+CAA+C;AAC/C,EAAE;AACF,wEAAwE;AACxE,yEAAyE;AACzE,yEAAyE;;;AAEzE,+CAA8C;AAoE9C,MAAM,iBAAiB,GAAsC;IAC3D,UAAU,EAAE,8BAA8B;IAC1C,MAAM,EAAE,0BAA0B;IAClC,OAAO,EAAE,2BAA2B;CACrC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,MAA8B,EAAE,QAAgC,EAAQ,EAAE;IAC/F,IAAI,QAAQ,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC;IAC9C,CAAC;AACH,CAAC,CAAC;AAEF,mEAAmE;AAC5D,MAAM,oBAAoB,GAAG,CAAC,MAAoB,EAAU,EAAE,CACnE,MAAM,CAAC,KAAK,KAAK,SAAS;IACxB,CAAC,CAAC,MAAM,CAAC,IAAI;IACb,CAAC,CAAC,GAAG,MA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", { value: true });
|
|
11
11
|
exports.toSerializableError = void 0;
|
|
12
|
+
// Any virtual script filename a host passes to `new vm.Script` — the canonical
|
|
13
|
+
// `callman-script.js`, `callman-<kind>.script.js` and the desktop's
|
|
14
|
+
// `pman-<stage>.script.js` — followed by `:line[:column]`. SyntaxErrors only
|
|
15
|
+
// carry `file:line` (no column), so the column group is optional.
|
|
12
16
|
const FRAME_PATTERNS = [
|
|
13
|
-
/callman-script\.js:(\d+)
|
|
14
|
-
/callman-scenario\.script\.js:(\d+):(\d+)/,
|
|
15
|
-
/callman-request\.script\.js:(\d+):(\d+)/,
|
|
16
|
-
/callman-collection\.script\.js:(\d+):(\d+)/,
|
|
17
|
-
/callman-folder\.script\.js:(\d+):(\d+)/,
|
|
17
|
+
/(?:callman-script|[\w.-]+\.script)\.js:(\d+)(?::(\d+))?/,
|
|
18
18
|
/<anonymous>:(\d+):(\d+)/,
|
|
19
19
|
];
|
|
20
20
|
const matchFrame = (stack) => {
|
|
@@ -26,7 +26,7 @@ const matchFrame = (stack) => {
|
|
|
26
26
|
if (match) {
|
|
27
27
|
return {
|
|
28
28
|
lineNumber: Math.max(1, Number(match[1])),
|
|
29
|
-
column: Number(match[2]),
|
|
29
|
+
column: match[2] === undefined ? null : Number(match[2]),
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/script/errors.ts"],"names":[],"mappings":";AAAA,wDAAwD;AACxD,EAAE;AACF,yEAAyE;AACzE,uEAAuE;AACvE,0EAA0E;AAC1E,4EAA4E;AAC5E,sEAAsE;AACtE,wEAAwE;;;AAIxE,MAAM,cAAc,GAAa;IAC/B,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/script/errors.ts"],"names":[],"mappings":";AAAA,wDAAwD;AACxD,EAAE;AACF,yEAAyE;AACzE,uEAAuE;AACvE,0EAA0E;AAC1E,4EAA4E;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AC,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,KAAc,EAAiB,EAAE;IAClD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC;IAC7B,CAAC;IACD,IACE,KAAK;QACL,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,IAAI,KAAK;QAChB,OAAQ,KAA4B,CAAC,KAAK,KAAK,QAAQ,EACvD,CAAC;QACD,OAAQ,KAA2B,CAAC,KAAK,CAAC;IAC5C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEK,MAAM,mBAAmB,GAAG,CACjC,KAAkB,EAClB,KAAc,EACD,EAAE;IACf,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IACnC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAEjD,OAAO;QACL,KAAK;QACL,OAAO;QACP,UAAU;QACV,MAAM;QACN,KAAK;KACN,CAAC;AACJ,CAAC,CAAC;AAfW,QAAA,mBAAmB,uBAe9B"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// Composes:
|
|
6
6
|
// - sandbox (vm.createContext + scope Proxy + reserved globals)
|
|
7
7
|
// - pm API (assertions + tests + env/globals + request/response + node + log)
|
|
8
|
-
// - sandbox-D extensions (db,
|
|
8
|
+
// - sandbox-D extensions (db, redis, random, counter, cryptojs, variables)
|
|
9
9
|
// - timeout (vm-level + outer Promise race)
|
|
10
10
|
// - error serialization (line/column attribution)
|
|
11
11
|
//
|
|
@@ -19,13 +19,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
19
|
exports.validateScript = exports.executeScript = void 0;
|
|
20
20
|
const executeRequest_js_1 = require("../request/executeRequest.js");
|
|
21
21
|
const environment_js_1 = require("./features/environment.js");
|
|
22
|
-
const
|
|
22
|
+
const legacy_js_1 = require("./legacy.js");
|
|
23
|
+
const legacyPostman_js_1 = require("./features/legacyPostman.js");
|
|
24
|
+
const modules_js_1 = require("./postman/modules.js");
|
|
25
|
+
const cookies_js_1 = require("./postman/cookies.js");
|
|
26
|
+
const visualizer_js_1 = require("./features/visualizer.js");
|
|
27
|
+
const requestAdapter_js_1 = require("./postman/requestAdapter.js");
|
|
28
|
+
const responseAdapter_js_1 = require("./postman/responseAdapter.js");
|
|
29
|
+
const runtime_js_1 = require("./postman/runtime.js");
|
|
23
30
|
const node_js_1 = require("./features/node.js");
|
|
24
31
|
const request_js_1 = require("./features/request.js");
|
|
25
32
|
const response_js_1 = require("./features/response.js");
|
|
26
33
|
const tests_js_1 = require("./features/tests.js");
|
|
27
34
|
const log_js_1 = require("./features/log.js");
|
|
28
|
-
const kafka_js_1 = require("./features/kafka.js");
|
|
29
35
|
const redis_js_1 = require("./features/redis.js");
|
|
30
36
|
const random_js_1 = require("./features/random.js");
|
|
31
37
|
const counter_js_1 = require("./features/counter.js");
|
|
@@ -34,6 +40,7 @@ const variables_js_1 = require("./features/variables.js");
|
|
|
34
40
|
const db_js_1 = require("./features/db.js");
|
|
35
41
|
const timers_js_1 = require("./features/timers.js");
|
|
36
42
|
const collectionVariables_js_1 = require("./features/collectionVariables.js");
|
|
43
|
+
const iterationData_js_1 = require("./features/iterationData.js");
|
|
37
44
|
const info_js_1 = require("./features/info.js");
|
|
38
45
|
const execution_js_1 = require("./features/execution.js");
|
|
39
46
|
// Lodash is exposed unconditionally as the `_` global — Postman
|
|
@@ -46,27 +53,13 @@ const timeout_js_1 = require("./timeout.js");
|
|
|
46
53
|
const DEFAULT_TIMEOUT_MS = 15_000;
|
|
47
54
|
const DEFAULT_FILENAME = "callman-script.js";
|
|
48
55
|
const DEFAULT_STAGE = "script";
|
|
49
|
-
const buildSandboxDFeatures = (capabilities, isInsideTestCallback, envValues, globalValues, responseTemplateRoot, collectionValues) => {
|
|
56
|
+
const buildSandboxDFeatures = (capabilities, isInsideTestCallback, envValues, globalValues, responseTemplateRoot, collectionValues, live) => {
|
|
50
57
|
const extensions = capabilities.extensions ?? {};
|
|
51
58
|
const featurePolicy = capabilities.featurePolicy;
|
|
52
59
|
const pm = {};
|
|
53
60
|
const scopeShortcuts = {};
|
|
54
61
|
let counterSnapshotFn = null;
|
|
55
62
|
let variablesApi = null;
|
|
56
|
-
if (extensions.kafka) {
|
|
57
|
-
const kafkaEnabled = featurePolicy ? featurePolicy.kafka : true;
|
|
58
|
-
if (kafkaEnabled) {
|
|
59
|
-
const api = (0, kafka_js_1.buildKafkaApi)(extensions.kafka, capabilities.allowDeferredKafkaTests ?? false);
|
|
60
|
-
pm.kafka = api;
|
|
61
|
-
scopeShortcuts.kafka = api;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
// Disabled kafka — replace with feature-policy guarded value
|
|
65
|
-
// (handled at the test-collector level via DisabledFeatureDependencyError).
|
|
66
|
-
// We still expose the binding so user scripts don't crash at scope lookup.
|
|
67
|
-
void isInsideTestCallback;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
63
|
if (extensions.redis) {
|
|
71
64
|
const api = (0, redis_js_1.buildRedisApi)({
|
|
72
65
|
capability: extensions.redis,
|
|
@@ -108,9 +101,13 @@ const buildSandboxDFeatures = (capabilities, isInsideTestCallback, envValues, gl
|
|
|
108
101
|
{
|
|
109
102
|
const api = (0, variables_js_1.buildVariablesApi)(envValues, globalValues, {
|
|
110
103
|
collectionVariables: collectionValues,
|
|
104
|
+
...(live ? { live } : {}),
|
|
105
|
+
...(capabilities.iterationData ? { iterationData: capabilities.iterationData.values } : {}),
|
|
111
106
|
...(capabilities.localVariables ? { local: capabilities.localVariables.values } : {}),
|
|
112
107
|
});
|
|
113
108
|
pm.variables = api;
|
|
109
|
+
// Postman exposes pm.iterationData in every script (empty outside a data run).
|
|
110
|
+
pm.iterationData = (0, iterationData_js_1.buildIterationDataApi)(capabilities.iterationData?.values);
|
|
114
111
|
variablesApi = api;
|
|
115
112
|
if (extensions.variables) {
|
|
116
113
|
scopeShortcuts.variables = api;
|
|
@@ -203,7 +200,16 @@ const normalizeSendBody = (body) => {
|
|
|
203
200
|
if (isPlainRecord(body)) {
|
|
204
201
|
const mode = body.mode;
|
|
205
202
|
if (mode === "raw") {
|
|
206
|
-
|
|
203
|
+
// Postman picks the Content-Type from the raw language (Text → text/plain);
|
|
204
|
+
// without one axios would label a string body as form-urlencoded.
|
|
205
|
+
const language = String(body.options?.raw?.language ?? "text").toLowerCase();
|
|
206
|
+
const byLanguage = {
|
|
207
|
+
json: "application/json",
|
|
208
|
+
xml: "application/xml",
|
|
209
|
+
html: "text/html",
|
|
210
|
+
javascript: "application/javascript",
|
|
211
|
+
};
|
|
212
|
+
return { data: body.raw ?? "", impliedContentType: byLanguage[language] ?? "text/plain" };
|
|
207
213
|
}
|
|
208
214
|
if (mode === "urlencoded" && Array.isArray(body.urlencoded)) {
|
|
209
215
|
const params = new URLSearchParams();
|
|
@@ -260,7 +266,33 @@ const resolveSendTemplates = (value, resolve) => {
|
|
|
260
266
|
}
|
|
261
267
|
return value;
|
|
262
268
|
};
|
|
263
|
-
const
|
|
269
|
+
const MULTIPART_BOUNDARY_PREFIX = "----CallmanFormBoundary";
|
|
270
|
+
// Multipart is built as a STRING body so every host executor (axios, the
|
|
271
|
+
// desktop's engine over worker RPC) sends it the same way. Text parts only —
|
|
272
|
+
// a file part has no bytes to read inside the sandbox.
|
|
273
|
+
const buildMultipartBody = (entries) => {
|
|
274
|
+
const boundary = `${MULTIPART_BOUNDARY_PREFIX}${Math.random().toString(16).slice(2)}${Date.now().toString(16)}`;
|
|
275
|
+
const parts = [];
|
|
276
|
+
for (const entry of entries) {
|
|
277
|
+
if (entry.disabled === true)
|
|
278
|
+
continue;
|
|
279
|
+
const key = String(entry.key ?? "").trim();
|
|
280
|
+
if (!key)
|
|
281
|
+
continue;
|
|
282
|
+
if (entry.type === "file") {
|
|
283
|
+
throw new Error(`pm.sendRequest: file part "${key}" is not supported (the sandbox cannot read files).`);
|
|
284
|
+
}
|
|
285
|
+
parts.push(`--${boundary}\r\nContent-Disposition: form-data; name="${key.replace(/"/g, "%22")}"\r\n\r\n${String(entry.value ?? "")}\r\n`);
|
|
286
|
+
}
|
|
287
|
+
return { data: `${parts.join("")}--${boundary}--\r\n`, contentType: `multipart/form-data; boundary=${boundary}` };
|
|
288
|
+
};
|
|
289
|
+
const setCookieLines = (headers) => {
|
|
290
|
+
const raw = Object.entries(headers).find(([key]) => key.toLowerCase() === "set-cookie")?.[1];
|
|
291
|
+
if (raw === undefined || raw === null)
|
|
292
|
+
return [];
|
|
293
|
+
return Array.isArray(raw) ? raw.map(String) : String(raw).split(/\r?\n/);
|
|
294
|
+
};
|
|
295
|
+
const createPmSendRequest = (tracker, executor, resolveTemplate, context = { sdk: null, chai: null }) => {
|
|
264
296
|
// Host-injected executor (desktop's real engine) takes precedence; backend
|
|
265
297
|
// and CLI omit it and fall back to the built-in bare-axios client.
|
|
266
298
|
const run = executor ?? executeRequest_js_1.executeRequest;
|
|
@@ -269,20 +301,60 @@ const createPmSendRequest = (tracker, executor, resolveTemplate) => {
|
|
|
269
301
|
// pm.environment.set writes made earlier in this script). No resolver
|
|
270
302
|
// wired → identity passthrough so behaviour is unchanged.
|
|
271
303
|
const resolve = resolveTemplate ?? ((template) => template);
|
|
304
|
+
const { sdk, chai, jar } = context;
|
|
305
|
+
// Request objects (sdk.Request) and the Url/HeaderList inside them become the
|
|
306
|
+
// plain definition the rest of this function understands.
|
|
307
|
+
const toDefinition = (options) => {
|
|
308
|
+
if (typeof options === "string")
|
|
309
|
+
return { url: options, method: "GET" };
|
|
310
|
+
if (sdk && options && typeof options === "object" && sdk.Request.isRequest(options)) {
|
|
311
|
+
return options.toJSON();
|
|
312
|
+
}
|
|
313
|
+
return isPlainRecord(options) ? options : {};
|
|
314
|
+
};
|
|
315
|
+
const urlFrom = (input) => {
|
|
316
|
+
if (sdk && input && typeof input === "object" && !Array.isArray(input) && !("raw" in input) && "host" in input) {
|
|
317
|
+
return new sdk.Url(input).toString();
|
|
318
|
+
}
|
|
319
|
+
return normalizeSendUrl(input);
|
|
320
|
+
};
|
|
272
321
|
return (options, callback) => {
|
|
273
322
|
const promise = (async () => {
|
|
274
|
-
const rawOptions =
|
|
275
|
-
? { url: options, method: "GET" }
|
|
276
|
-
: isPlainRecord(options)
|
|
277
|
-
? options
|
|
278
|
-
: {};
|
|
323
|
+
const rawOptions = toDefinition(options);
|
|
279
324
|
// Resolve templates up-front against the live scope, then normalize.
|
|
280
325
|
const normalized = resolveSendTemplates(rawOptions, resolve);
|
|
281
|
-
const url =
|
|
326
|
+
const url = urlFrom(normalized.url);
|
|
282
327
|
const method = String(normalized.method ?? "GET").toUpperCase();
|
|
283
328
|
const headerInput = normalized.header ?? normalized.headers;
|
|
284
329
|
const headers = normalizeSendHeaderInput(headerInput);
|
|
285
|
-
const
|
|
330
|
+
const body = normalized.body;
|
|
331
|
+
let data;
|
|
332
|
+
let impliedContentType = null;
|
|
333
|
+
if (isPlainRecord(body) && body.mode === "formdata" && Array.isArray(body.formdata)) {
|
|
334
|
+
const multipart = buildMultipartBody(body.formdata);
|
|
335
|
+
data = multipart.data;
|
|
336
|
+
impliedContentType = multipart.contentType;
|
|
337
|
+
}
|
|
338
|
+
else if (isPlainRecord(body) && body.mode === "graphql" && isPlainRecord(body.graphql)) {
|
|
339
|
+
const graphql = body.graphql;
|
|
340
|
+
let variables = graphql.variables;
|
|
341
|
+
if (typeof variables === "string" && variables.trim()) {
|
|
342
|
+
try {
|
|
343
|
+
variables = JSON.parse(variables);
|
|
344
|
+
}
|
|
345
|
+
catch {
|
|
346
|
+
// leave the text as the user wrote it
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
data = JSON.stringify({ query: graphql.query, ...(variables ? { variables } : {}) });
|
|
350
|
+
impliedContentType = "application/json";
|
|
351
|
+
}
|
|
352
|
+
else if (isPlainRecord(body) && body.mode === "file") {
|
|
353
|
+
throw new Error("pm.sendRequest: body mode \"file\" is not supported (the sandbox cannot read files).");
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
({ data, impliedContentType } = normalizeSendBody(body));
|
|
357
|
+
}
|
|
286
358
|
if (impliedContentType &&
|
|
287
359
|
!Object.keys(headers).some((k) => k.toLowerCase() === "content-type")) {
|
|
288
360
|
headers["Content-Type"] = impliedContentType;
|
|
@@ -290,6 +362,14 @@ const createPmSendRequest = (tracker, executor, resolveTemplate) => {
|
|
|
290
362
|
const timeoutMs = typeof normalized.timeout === "number" && normalized.timeout > 0
|
|
291
363
|
? Number(normalized.timeout)
|
|
292
364
|
: undefined;
|
|
365
|
+
// Hosts that provide a persistent cookie jar get Postman's behaviour:
|
|
366
|
+
// matching cookies are sent, Set-Cookie responses are stored.
|
|
367
|
+
if (jar && !Object.keys(headers).some((key) => key.toLowerCase() === "cookie")) {
|
|
368
|
+
const stored = await jar.getAll(url);
|
|
369
|
+
if (stored.length > 0) {
|
|
370
|
+
headers.Cookie = stored.map((cookie) => `${cookie.name}=${cookie.value}`).join("; ");
|
|
371
|
+
}
|
|
372
|
+
}
|
|
293
373
|
const result = await run({
|
|
294
374
|
method,
|
|
295
375
|
url,
|
|
@@ -298,21 +378,47 @@ const createPmSendRequest = (tracker, executor, resolveTemplate) => {
|
|
|
298
378
|
body: data,
|
|
299
379
|
timeoutMs,
|
|
300
380
|
});
|
|
301
|
-
const bodyText = typeof result.
|
|
302
|
-
? result.
|
|
303
|
-
:
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
381
|
+
const bodyText = typeof result.rawText === "string"
|
|
382
|
+
? result.rawText
|
|
383
|
+
: typeof result.data === "string"
|
|
384
|
+
? result.data
|
|
385
|
+
: (() => {
|
|
386
|
+
try {
|
|
387
|
+
return JSON.stringify(result.data ?? null);
|
|
388
|
+
}
|
|
389
|
+
catch {
|
|
390
|
+
return String(result.data ?? "");
|
|
391
|
+
}
|
|
392
|
+
})();
|
|
393
|
+
const responseHeaders = (result.headers ?? {});
|
|
394
|
+
const cookieLines = setCookieLines(responseHeaders);
|
|
395
|
+
if (jar) {
|
|
396
|
+
for (const line of cookieLines) {
|
|
397
|
+
const cookie = (0, cookies_js_1.parseSetCookieLine)(line);
|
|
398
|
+
if (cookie)
|
|
399
|
+
await jar.set(url, cookie);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
if (sdk && chai) {
|
|
403
|
+
return (0, responseAdapter_js_1.buildSdkResponseApi)(sdk, chai, {
|
|
404
|
+
ok: result.status >= 200 && result.status < 400,
|
|
405
|
+
status: result.status,
|
|
406
|
+
statusText: "",
|
|
407
|
+
headers: responseHeaders,
|
|
408
|
+
body: result.data,
|
|
409
|
+
jsonBody: result.data !== null && typeof result.data === "object" ? result.data : null,
|
|
410
|
+
rawBody: bodyText,
|
|
411
|
+
contentType: Object.entries(responseHeaders).find(([key]) => key.toLowerCase() === "content-type")?.[1] ?? "",
|
|
412
|
+
durationMs: result.duration ?? 0,
|
|
413
|
+
sizeBytes: bodyText.length,
|
|
414
|
+
cookies: cookieLines,
|
|
415
|
+
});
|
|
416
|
+
}
|
|
311
417
|
return {
|
|
312
418
|
code: result.status,
|
|
313
419
|
status: result.status,
|
|
314
420
|
statusText: "",
|
|
315
|
-
headers:
|
|
421
|
+
headers: responseHeaders,
|
|
316
422
|
body: result.data,
|
|
317
423
|
responseTime: result.duration,
|
|
318
424
|
duration: result.duration,
|
|
@@ -329,7 +435,7 @@ const createPmSendRequest = (tracker, executor, resolveTemplate) => {
|
|
|
329
435
|
if (typeof callback === "function") {
|
|
330
436
|
promise.then((response) => {
|
|
331
437
|
try {
|
|
332
|
-
callback(null, response);
|
|
438
|
+
callback(null, response, undefined);
|
|
333
439
|
}
|
|
334
440
|
catch (callbackError) {
|
|
335
441
|
// Surface callback throws to the host log; suppressing
|
|
@@ -339,7 +445,7 @@ const createPmSendRequest = (tracker, executor, resolveTemplate) => {
|
|
|
339
445
|
}
|
|
340
446
|
}, (error) => {
|
|
341
447
|
try {
|
|
342
|
-
callback(error instanceof Error ? error : new Error(String(error)), null);
|
|
448
|
+
callback(error instanceof Error ? error : new Error(String(error)), null, undefined);
|
|
343
449
|
}
|
|
344
450
|
catch (callbackError) {
|
|
345
451
|
// eslint-disable-next-line no-console
|
|
@@ -384,8 +490,12 @@ const buildPm = (capabilities, logs, collectors, sandboxDPm) => {
|
|
|
384
490
|
// interpolates {{var}} exactly like pm.variables.replaceIn(...).
|
|
385
491
|
const variablesApi = sandboxDPm.variables;
|
|
386
492
|
pm.sendRequest = createPmSendRequest(collectors.sendRequestTracker, capabilities.extensions?.sendRequest?.execute, variablesApi
|
|
387
|
-
? (template) => variablesApi.replaceIn(template)
|
|
388
|
-
: undefined
|
|
493
|
+
? (template) => String(variablesApi.replaceIn(template))
|
|
494
|
+
: undefined, {
|
|
495
|
+
sdk: collectors.runtime?.sdk ?? null,
|
|
496
|
+
chai: collectors.runtime?.chai ?? null,
|
|
497
|
+
jar: capabilities.cookies?.jar,
|
|
498
|
+
});
|
|
389
499
|
}
|
|
390
500
|
const extensions = capabilities.extensions ?? {};
|
|
391
501
|
if (extensions.log) {
|
|
@@ -399,7 +509,7 @@ const buildPm = (capabilities, logs, collectors, sandboxDPm) => {
|
|
|
399
509
|
}
|
|
400
510
|
return pm;
|
|
401
511
|
};
|
|
402
|
-
const buildScopeBindings = ({ pm, capabilities, consoleApi, envValues, environmentApi, request, response, expect, test, sandboxDShortcuts, timers, }) => {
|
|
512
|
+
const buildScopeBindings = ({ pm, capabilities, consoleApi, envValues, environmentApi, request, response, expect, test, sandboxDShortcuts, timers, extraGlobals, }) => {
|
|
403
513
|
const exposeLabels = capabilities.workflowContext &&
|
|
404
514
|
capabilities.exposeLabelsAsGlobals !== false;
|
|
405
515
|
const labelGlobals = exposeLabels
|
|
@@ -418,7 +528,6 @@ const buildScopeBindings = ({ pm, capabilities, consoleApi, envValues, environme
|
|
|
418
528
|
expect,
|
|
419
529
|
console: consoleApi,
|
|
420
530
|
db: sandboxDShortcuts.db,
|
|
421
|
-
kafka: sandboxDShortcuts.kafka,
|
|
422
531
|
redis: sandboxDShortcuts.redis,
|
|
423
532
|
random: sandboxDShortcuts.random,
|
|
424
533
|
counter: sandboxDShortcuts.counter,
|
|
@@ -426,14 +535,26 @@ const buildScopeBindings = ({ pm, capabilities, consoleApi, envValues, environme
|
|
|
426
535
|
CryptoJS: sandboxDShortcuts.CryptoJS,
|
|
427
536
|
lodash: lodash_1.default,
|
|
428
537
|
timers,
|
|
538
|
+
extraGlobals,
|
|
429
539
|
labelGlobals,
|
|
430
540
|
};
|
|
431
541
|
};
|
|
542
|
+
const NUMERIC_STATUS_COMPARISON = /(?:\b(?:pm|cm|callman)\.response\.status\s*(?:===?|!==?|<=?|>=?)\s*\d{3}\b)|(?:\b\d{3}\s*(?:===?|!==?|<=?|>=?)\s*(?:pm|cm|callman)\.response\.status\b)|(?:expect\(\s*(?:pm|cm|callman)\.response\.status\s*\)[^;\n]*\b\d{3}\b)/;
|
|
432
543
|
const executeScript = async (input) => {
|
|
433
544
|
const timeoutMs = input.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
434
545
|
const filename = input.filename ?? DEFAULT_FILENAME;
|
|
435
546
|
const stage = input.stage ?? DEFAULT_STAGE;
|
|
436
|
-
|
|
547
|
+
// A host may hand over several Set-Cookie headers joined into one string
|
|
548
|
+
// ("a=1; Path=/, b=2; …"); split them so each cookie is its own entry.
|
|
549
|
+
const capabilities = input.capabilities.response?.cookies?.some((line) => /,\s*[^;,=\s]+=/.test(line))
|
|
550
|
+
? {
|
|
551
|
+
...input.capabilities,
|
|
552
|
+
response: {
|
|
553
|
+
...input.capabilities.response,
|
|
554
|
+
cookies: input.capabilities.response.cookies.flatMap(legacy_js_1.splitSetCookieHeader),
|
|
555
|
+
},
|
|
556
|
+
}
|
|
557
|
+
: input.capabilities;
|
|
437
558
|
const extensions = capabilities.extensions ?? {};
|
|
438
559
|
// Empty / whitespace-only scripts short-circuit with an empty success.
|
|
439
560
|
if (!input.script.trim()) {
|
|
@@ -448,9 +569,6 @@ const executeScript = async (input) => {
|
|
|
448
569
|
if (extensions.counter) {
|
|
449
570
|
passthrough.counterSnapshot = extensions.counter.snapshot;
|
|
450
571
|
}
|
|
451
|
-
if (capabilities.allowDeferredKafkaTests) {
|
|
452
|
-
passthrough.deferredTestNames = [];
|
|
453
|
-
}
|
|
454
572
|
if (capabilities.localVariables) {
|
|
455
573
|
passthrough.localVariables = { ...capabilities.localVariables.values };
|
|
456
574
|
}
|
|
@@ -476,23 +594,46 @@ const executeScript = async (input) => {
|
|
|
476
594
|
: (0, collectionVariables_js_1.buildCollectionVariablesApi)({}, null);
|
|
477
595
|
const infoApi = (0, info_js_1.buildInfoApi)(capabilities.info, stage);
|
|
478
596
|
const executionFeature = (0, execution_js_1.buildExecutionFeature)(capabilities.execution);
|
|
597
|
+
// pm.request / pm.response are real `postman-collection` objects and pm.expect
|
|
598
|
+
// is chai: load them before the (synchronous) sandbox is assembled.
|
|
599
|
+
const runtime = await (0, runtime_js_1.loadPostmanRuntime)({
|
|
600
|
+
sdk: (0, runtime_js_1.scriptNeedsSdk)(input.script, Boolean(capabilities.request || capabilities.response)),
|
|
601
|
+
});
|
|
479
602
|
const requestBundle = capabilities.request
|
|
480
|
-
?
|
|
603
|
+
? runtime.sdk
|
|
604
|
+
? (0, requestAdapter_js_1.buildSdkRequestApi)(runtime.sdk, capabilities.request)
|
|
605
|
+
: (0, request_js_1.buildRequestApi)(capabilities.request)
|
|
481
606
|
: undefined;
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
607
|
+
if (requestBundle && runtime.sdk) {
|
|
608
|
+
(0, responseAdapter_js_1.attachRequestAssertions)(runtime.chai, requestBundle.api);
|
|
609
|
+
}
|
|
610
|
+
const responseApi = capabilities.response
|
|
611
|
+
? runtime.sdk
|
|
612
|
+
? (0, responseAdapter_js_1.buildSdkResponseApi)(runtime.sdk, runtime.chai, capabilities.response)
|
|
613
|
+
: ((0, response_js_1.buildResponseApi)(capabilities.response) ?? undefined)
|
|
614
|
+
: undefined;
|
|
615
|
+
const expect = runtime.chai.expect;
|
|
616
|
+
const tests = (0, tests_js_1.buildTestCollector)(stage);
|
|
488
617
|
const logCollector = extensions.log
|
|
489
|
-
? (0, log_js_1.createLogCollector)()
|
|
618
|
+
? (0, log_js_1.createLogCollector)(typeof extensions.log === "object" ? { onEntry: extensions.log.onEntry } : {})
|
|
490
619
|
: (0, log_js_1.createSilentLogCollector)();
|
|
620
|
+
// `pm.response.status` is Postman's reason phrase ("OK"); scripts written
|
|
621
|
+
// against Callman's old numeric status silently stop matching. Say so once.
|
|
622
|
+
if (extensions.log && NUMERIC_STATUS_COMPARISON.test(input.script)) {
|
|
623
|
+
logCollector.consoleApi.warn('pm.response.status is the reason phrase (e.g. "OK") like in Postman — compare pm.response.code for the numeric status.');
|
|
624
|
+
}
|
|
491
625
|
// Sandbox D feature bundle — depends on env/globals being constructed first
|
|
492
626
|
// (cryptojs/random/counter don't, but variables/db do).
|
|
493
|
-
const sandboxD = buildSandboxDFeatures(capabilities, () => tests.isInsideCallback(), environmentApi?.values ?? capabilities.environment?.values ?? {}, globalsApi?.values ?? capabilities.globals?.values ?? {}, capabilities.response ?? null, collectionVariablesApi.values
|
|
627
|
+
const sandboxD = buildSandboxDFeatures(capabilities, () => tests.isInsideCallback(), environmentApi?.values ?? capabilities.environment?.values ?? {}, globalsApi?.values ?? capabilities.globals?.values ?? {}, capabilities.response ?? null, collectionVariablesApi.values, {
|
|
628
|
+
...(environmentApi ? { environment: () => environmentApi.toObject() } : {}),
|
|
629
|
+
...(globalsApi ? { globals: () => globalsApi.toObject() } : {}),
|
|
630
|
+
collection: () => collectionVariablesApi.toObject(),
|
|
631
|
+
});
|
|
494
632
|
const sendRequestTracker = buildSendRequestPendingTracker();
|
|
495
|
-
const timerFeature = (0, timers_js_1.buildTimerFeature)()
|
|
633
|
+
const timerFeature = (0, timers_js_1.buildTimerFeature)((kind, error) => {
|
|
634
|
+
const detail = error instanceof Error ? (error.stack ?? error.message) : String(error);
|
|
635
|
+
logCollector.consoleApi.error(`Uncaught error in ${kind === "timeout" ? "setTimeout" : "setInterval"} callback: ${detail}`);
|
|
636
|
+
});
|
|
496
637
|
const pm = buildPm(capabilities, { pmLog: logCollector.pmLog }, {
|
|
497
638
|
test: tests,
|
|
498
639
|
expect,
|
|
@@ -504,9 +645,88 @@ const executeScript = async (input) => {
|
|
|
504
645
|
request: requestBundle,
|
|
505
646
|
response: responseApi ?? undefined,
|
|
506
647
|
sendRequestTracker,
|
|
648
|
+
runtime,
|
|
507
649
|
}, sandboxD.pm);
|
|
650
|
+
// Postman APIs Callman does not implement: fail with an explanation instead
|
|
651
|
+
// of "Cannot read properties of undefined".
|
|
652
|
+
const unsupportedApi = (name) => new Proxy(function unsupported() {
|
|
653
|
+
return undefined;
|
|
654
|
+
}, {
|
|
655
|
+
get: (_target, property) => {
|
|
656
|
+
if (property === Symbol.toPrimitive || property === "then" || property === "toJSON")
|
|
657
|
+
return undefined;
|
|
658
|
+
throw new Error(`${name} is not supported in Callman yet.`);
|
|
659
|
+
},
|
|
660
|
+
apply: () => {
|
|
661
|
+
throw new Error(`${name} is not supported in Callman yet.`);
|
|
662
|
+
},
|
|
663
|
+
});
|
|
664
|
+
for (const name of ["vault", "datasets", "mock", "state", "message"]) {
|
|
665
|
+
if (!(name in pm))
|
|
666
|
+
pm[name] = unsupportedApi(`pm.${name}`);
|
|
667
|
+
}
|
|
668
|
+
if (pm.execution && typeof pm.execution === "object" && !("runRequest" in pm.execution)) {
|
|
669
|
+
pm.execution.runRequest = async () => {
|
|
670
|
+
throw new Error("pm.execution.runRequest is not supported in Callman yet.");
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
const visualizerFeature = (0, visualizer_js_1.buildVisualizerFeature)();
|
|
674
|
+
pm.visualizer = visualizerFeature.api;
|
|
675
|
+
pm.getData = visualizerFeature.getData;
|
|
676
|
+
// pm.cookies (CookieList of the request's domain) + pm.cookies.jar().
|
|
677
|
+
pm.cookies = (0, cookies_js_1.buildPmCookies)({
|
|
678
|
+
sdk: runtime.sdk,
|
|
679
|
+
lines: capabilities.cookies?.snapshot ?? capabilities.response?.cookies ?? [],
|
|
680
|
+
jar: capabilities.cookies?.jar ?? (0, cookies_js_1.createMemoryCookieJar)(),
|
|
681
|
+
});
|
|
682
|
+
// require() / pm.require() and Postman's legacy globals (postman.*, tests[],
|
|
683
|
+
// responseBody…). Modules are loaded up front: the sandbox itself is sync.
|
|
684
|
+
const optsOutOfLegacy = (0, legacyPostman_js_1.scriptOptsOutOfLegacy)(input.script);
|
|
685
|
+
const legacyEnabled = !optsOutOfLegacy && stage !== "script";
|
|
686
|
+
const legacyLibraries = legacyEnabled
|
|
687
|
+
? ["tv4", "cheerio"].filter((name) => new RegExp(`\\b${name}\\b`).test(input.script))
|
|
688
|
+
: [];
|
|
689
|
+
const wantsXml2Json = legacyEnabled && /\bxml2Json\b/.test(input.script);
|
|
690
|
+
const loadedModules = await (0, modules_js_1.preloadScriptModules)([
|
|
691
|
+
input.script,
|
|
692
|
+
...legacyLibraries.map((name) => `require("${name}")`),
|
|
693
|
+
...(wantsXml2Json ? [`require("xml2js")`] : []),
|
|
694
|
+
].join("\n"), {
|
|
695
|
+
sdk: runtime.sdk,
|
|
696
|
+
chai: runtime.chai,
|
|
697
|
+
cryptoJs: sandboxD.scopeShortcuts.CryptoJS,
|
|
698
|
+
timers: timerFeature.api,
|
|
699
|
+
});
|
|
700
|
+
pm.require = (0, modules_js_1.createSandboxRequire)(loadedModules, "pm.require");
|
|
701
|
+
const extraGlobals = {
|
|
702
|
+
require: (0, modules_js_1.createSandboxRequire)(loadedModules),
|
|
703
|
+
};
|
|
704
|
+
if (legacyEnabled) {
|
|
705
|
+
Object.assign(extraGlobals, (0, legacyPostman_js_1.buildLegacyGlobals)({
|
|
706
|
+
pm,
|
|
707
|
+
environmentApi,
|
|
708
|
+
globalsApi,
|
|
709
|
+
response: capabilities.response ?? null,
|
|
710
|
+
testFn: tests.test,
|
|
711
|
+
iterationDataValues: capabilities.iterationData?.values ?? {},
|
|
712
|
+
}));
|
|
713
|
+
for (const name of legacyLibraries) {
|
|
714
|
+
extraGlobals[name] = loadedModules.get(name);
|
|
715
|
+
}
|
|
716
|
+
if (wantsXml2Json) {
|
|
717
|
+
const xml2js = loadedModules.get("xml2js");
|
|
718
|
+
extraGlobals.xml2Json = (xml) => {
|
|
719
|
+
let out;
|
|
720
|
+
xml2js?.parseString(String(xml ?? ""), { explicitArray: false, async: false }, (_error, result) => {
|
|
721
|
+
out = result;
|
|
722
|
+
});
|
|
723
|
+
return out;
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
}
|
|
508
727
|
const bindings = buildScopeBindings({
|
|
509
728
|
pm,
|
|
729
|
+
extraGlobals,
|
|
510
730
|
capabilities,
|
|
511
731
|
consoleApi: logCollector.consoleApi,
|
|
512
732
|
envValues: environmentApi?.values,
|
|
@@ -521,6 +741,8 @@ const executeScript = async (input) => {
|
|
|
521
741
|
clearTimeout: timerFeature.api.clearTimeout,
|
|
522
742
|
setInterval: timerFeature.api.setInterval,
|
|
523
743
|
clearInterval: timerFeature.api.clearInterval,
|
|
744
|
+
setImmediate: timerFeature.api.setImmediate,
|
|
745
|
+
clearImmediate: timerFeature.api.clearImmediate,
|
|
524
746
|
},
|
|
525
747
|
});
|
|
526
748
|
let compiled;
|
|
@@ -543,9 +765,6 @@ const executeScript = async (input) => {
|
|
|
543
765
|
if (sandboxD.counterSnapshotFn) {
|
|
544
766
|
result.counterSnapshot = sandboxD.counterSnapshotFn();
|
|
545
767
|
}
|
|
546
|
-
if (capabilities.allowDeferredKafkaTests) {
|
|
547
|
-
result.deferredTestNames = [];
|
|
548
|
-
}
|
|
549
768
|
if (capabilities.localVariables) {
|
|
550
769
|
result.localVariables = { ...capabilities.localVariables.values };
|
|
551
770
|
}
|
|
@@ -591,9 +810,6 @@ const executeScript = async (input) => {
|
|
|
591
810
|
if (sandboxD.counterSnapshotFn) {
|
|
592
811
|
result.counterSnapshot = sandboxD.counterSnapshotFn();
|
|
593
812
|
}
|
|
594
|
-
if (capabilities.allowDeferredKafkaTests) {
|
|
595
|
-
result.deferredTestNames = [...tests.deferredTestNames];
|
|
596
|
-
}
|
|
597
813
|
// Only surface executionControl when the host actually wired the
|
|
598
814
|
// capability — keeps the result shape unchanged for callers that
|
|
599
815
|
// don't know about pm.execution yet.
|
|
@@ -603,6 +819,10 @@ const executeScript = async (input) => {
|
|
|
603
819
|
if (capabilities.localVariables) {
|
|
604
820
|
result.localVariables = sandboxD.variablesApi.localSnapshot?.() ?? {};
|
|
605
821
|
}
|
|
822
|
+
const visualization = visualizerFeature.payload();
|
|
823
|
+
if (visualization) {
|
|
824
|
+
result.visualizer = visualization;
|
|
825
|
+
}
|
|
606
826
|
return result;
|
|
607
827
|
};
|
|
608
828
|
exports.executeScript = executeScript;
|