callman-core 1.7.1 → 1.8.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.
Files changed (109) hide show
  1. package/dist/scenario-runner/runScenario.d.ts.map +1 -1
  2. package/dist/scenario-runner/runScenario.js +8 -0
  3. package/dist/scenario-runner/runScenario.js.map +1 -1
  4. package/dist/scenario-runner/types.d.ts +1 -1
  5. package/dist/scenario-runner/types.d.ts.map +1 -1
  6. package/dist/script/executor.d.ts.map +1 -1
  7. package/dist/script/executor.js +75 -9
  8. package/dist/script/executor.js.map +1 -1
  9. package/dist/script/features/collectionVariables.d.ts +16 -0
  10. package/dist/script/features/collectionVariables.d.ts.map +1 -0
  11. package/dist/script/features/collectionVariables.js +83 -0
  12. package/dist/script/features/collectionVariables.js.map +1 -0
  13. package/dist/script/features/cryptojs.d.ts +8 -12
  14. package/dist/script/features/cryptojs.d.ts.map +1 -1
  15. package/dist/script/features/cryptojs.js +15 -99
  16. package/dist/script/features/cryptojs.js.map +1 -1
  17. package/dist/script/features/environment.d.ts +8 -1
  18. package/dist/script/features/environment.d.ts.map +1 -1
  19. package/dist/script/features/environment.js +25 -1
  20. package/dist/script/features/environment.js.map +1 -1
  21. package/dist/script/features/execution.d.ts +17 -0
  22. package/dist/script/features/execution.d.ts.map +1 -0
  23. package/dist/script/features/execution.js +60 -0
  24. package/dist/script/features/execution.js.map +1 -0
  25. package/dist/script/features/headerList.d.ts +44 -0
  26. package/dist/script/features/headerList.d.ts.map +1 -0
  27. package/dist/script/features/headerList.js +284 -0
  28. package/dist/script/features/headerList.js.map +1 -0
  29. package/dist/script/features/info.d.ts +10 -0
  30. package/dist/script/features/info.d.ts.map +1 -0
  31. package/dist/script/features/info.js +32 -0
  32. package/dist/script/features/info.js.map +1 -0
  33. package/dist/script/features/request.d.ts +3 -2
  34. package/dist/script/features/request.d.ts.map +1 -1
  35. package/dist/script/features/request.js +38 -29
  36. package/dist/script/features/request.js.map +1 -1
  37. package/dist/script/features/response.d.ts +7 -5
  38. package/dist/script/features/response.d.ts.map +1 -1
  39. package/dist/script/features/response.js +16 -8
  40. package/dist/script/features/response.js.map +1 -1
  41. package/dist/script/features/responseAssertions.d.ts +50 -0
  42. package/dist/script/features/responseAssertions.d.ts.map +1 -0
  43. package/dist/script/features/responseAssertions.js +293 -0
  44. package/dist/script/features/responseAssertions.js.map +1 -0
  45. package/dist/script/features/timers.d.ts +17 -0
  46. package/dist/script/features/timers.d.ts.map +1 -0
  47. package/dist/script/features/timers.js +152 -0
  48. package/dist/script/features/timers.js.map +1 -0
  49. package/dist/script/features/variables.d.ts +8 -1
  50. package/dist/script/features/variables.d.ts.map +1 -1
  51. package/dist/script/features/variables.js +57 -11
  52. package/dist/script/features/variables.js.map +1 -1
  53. package/dist/script/scope.d.ts +10 -0
  54. package/dist/script/scope.d.ts.map +1 -1
  55. package/dist/script/scope.js +13 -4
  56. package/dist/script/scope.js.map +1 -1
  57. package/dist/script/types.d.ts +51 -1
  58. package/dist/script/types.d.ts.map +1 -1
  59. package/dist/templating/generator-metadata.d.ts +1 -0
  60. package/dist/templating/generator-metadata.d.ts.map +1 -1
  61. package/dist/templating/generator-metadata.js +76 -0
  62. package/dist/templating/generator-metadata.js.map +1 -1
  63. package/dist/templating/postman-generators.d.ts +12 -0
  64. package/dist/templating/postman-generators.d.ts.map +1 -0
  65. package/dist/templating/postman-generators.js +577 -0
  66. package/dist/templating/postman-generators.js.map +1 -0
  67. package/dist/templating/template-engine.d.ts.map +1 -1
  68. package/dist/templating/template-engine.js +16 -0
  69. package/dist/templating/template-engine.js.map +1 -1
  70. package/dist/variables/resolver.d.ts.map +1 -1
  71. package/dist/variables/resolver.js +15 -0
  72. package/dist/variables/resolver.js.map +1 -1
  73. package/dist-cjs/scenario-runner/runScenario.js +8 -0
  74. package/dist-cjs/scenario-runner/runScenario.js.map +1 -1
  75. package/dist-cjs/script/executor.js +78 -9
  76. package/dist-cjs/script/executor.js.map +1 -1
  77. package/dist-cjs/script/features/collectionVariables.js +87 -0
  78. package/dist-cjs/script/features/collectionVariables.js.map +1 -0
  79. package/dist-cjs/script/features/cryptojs.js +18 -99
  80. package/dist-cjs/script/features/cryptojs.js.map +1 -1
  81. package/dist-cjs/script/features/environment.js +25 -1
  82. package/dist-cjs/script/features/environment.js.map +1 -1
  83. package/dist-cjs/script/features/execution.js +64 -0
  84. package/dist-cjs/script/features/execution.js.map +1 -0
  85. package/dist-cjs/script/features/headerList.js +289 -0
  86. package/dist-cjs/script/features/headerList.js.map +1 -0
  87. package/dist-cjs/script/features/info.js +36 -0
  88. package/dist-cjs/script/features/info.js.map +1 -0
  89. package/dist-cjs/script/features/request.js +38 -29
  90. package/dist-cjs/script/features/request.js.map +1 -1
  91. package/dist-cjs/script/features/response.js +16 -8
  92. package/dist-cjs/script/features/response.js.map +1 -1
  93. package/dist-cjs/script/features/responseAssertions.js +297 -0
  94. package/dist-cjs/script/features/responseAssertions.js.map +1 -0
  95. package/dist-cjs/script/features/timers.js +156 -0
  96. package/dist-cjs/script/features/timers.js.map +1 -0
  97. package/dist-cjs/script/features/variables.js +57 -11
  98. package/dist-cjs/script/features/variables.js.map +1 -1
  99. package/dist-cjs/script/scope.js +13 -4
  100. package/dist-cjs/script/scope.js.map +1 -1
  101. package/dist-cjs/templating/generator-metadata.js +77 -1
  102. package/dist-cjs/templating/generator-metadata.js.map +1 -1
  103. package/dist-cjs/templating/postman-generators.js +581 -0
  104. package/dist-cjs/templating/postman-generators.js.map +1 -0
  105. package/dist-cjs/templating/template-engine.js +16 -0
  106. package/dist-cjs/templating/template-engine.js.map +1 -1
  107. package/dist-cjs/variables/resolver.js +15 -0
  108. package/dist-cjs/variables/resolver.js.map +1 -1
  109. package/package.json +6 -2
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ // pm.collectionVariables — Postman scope that survives across requests
3
+ // within a single collection run.
4
+ //
5
+ // Shape mirrors `pm.environment` exactly so scripts that already use
6
+ // `pm.environment.set` can swap it out for `pm.collectionVariables.set`
7
+ // without changing the method calls. The only difference is the
8
+ // persistence boundary:
9
+ //
10
+ // - pm.variables.set — request-scoped, gone after the script
11
+ // - pm.collectionVariables.set — collection-run-scoped, survives between
12
+ // requests within the same run but does NOT persist across runs
13
+ // - pm.environment.set — run-scoped, AND propagates back to the host
14
+ // so a follow-up "save environment" sticks
15
+ // - pm.globals.set — same as environment but workspace-wide
16
+ //
17
+ // Mutations are emitted with `scope: "collection"` so the runner can
18
+ // merge them into the next request's `capabilities.collectionVariables`
19
+ // without polluting environment / globals.
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.buildCollectionVariablesApi = void 0;
22
+ const resolver_js_1 = require("../../variables/resolver.js");
23
+ const coerceToString = (value) => {
24
+ if (value === undefined || value === null) {
25
+ return "";
26
+ }
27
+ return String(value);
28
+ };
29
+ const buildCollectionVariablesApi = (initial, mutations, options = {}) => {
30
+ const values = { ...initial };
31
+ const name = options.nameOverride ?? "Collection";
32
+ const recordMutation = (mutation) => {
33
+ if (mutations) {
34
+ mutations.push(mutation);
35
+ }
36
+ };
37
+ return {
38
+ values,
39
+ name,
40
+ get: (key) => values[String(key ?? "").trim()],
41
+ set: (key, value) => {
42
+ const normalisedKey = String(key ?? "").trim();
43
+ if (!normalisedKey) {
44
+ return;
45
+ }
46
+ const normalisedValue = coerceToString(value);
47
+ values[normalisedKey] = normalisedValue;
48
+ recordMutation({
49
+ scope: "collection",
50
+ type: "set",
51
+ key: normalisedKey,
52
+ value: normalisedValue,
53
+ });
54
+ },
55
+ unset: (key) => {
56
+ const normalisedKey = String(key ?? "").trim();
57
+ if (!normalisedKey || !(normalisedKey in values)) {
58
+ return;
59
+ }
60
+ delete values[normalisedKey];
61
+ recordMutation({
62
+ scope: "collection",
63
+ type: "unset",
64
+ key: normalisedKey,
65
+ });
66
+ },
67
+ has: (key) => {
68
+ const normalisedKey = String(key ?? "").trim();
69
+ return Boolean(normalisedKey) && normalisedKey in values;
70
+ },
71
+ clear: () => {
72
+ const keys = Object.keys(values);
73
+ for (const key of keys) {
74
+ delete values[key];
75
+ recordMutation({
76
+ scope: "collection",
77
+ type: "unset",
78
+ key,
79
+ });
80
+ }
81
+ },
82
+ toObject: () => ({ ...values }),
83
+ replaceIn: (template) => (0, resolver_js_1.resolveTemplate)(coerceToString(template), { env: values }),
84
+ };
85
+ };
86
+ exports.buildCollectionVariablesApi = buildCollectionVariablesApi;
87
+ //# sourceMappingURL=collectionVariables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collectionVariables.js","sourceRoot":"","sources":["../../../src/script/features/collectionVariables.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,kCAAkC;AAClC,EAAE;AACF,qEAAqE;AACrE,wEAAwE;AACxE,gEAAgE;AAChE,wBAAwB;AACxB,EAAE;AACF,kEAAkE;AAClE,2EAA2E;AAC3E,oEAAoE;AACpE,wEAAwE;AACxE,+CAA+C;AAC/C,mEAAmE;AACnE,EAAE;AACF,qEAAqE;AACrE,wEAAwE;AACxE,2CAA2C;;;AAE3C,6DAA8D;AAe9D,MAAM,cAAc,GAAG,CAAC,KAAc,EAAU,EAAE;IAChD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC1C,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC,CAAC;AAEK,MAAM,2BAA2B,GAAG,CACzC,OAA+B,EAC/B,SAA0C,EAC1C,UAAqC,EAAE,EACf,EAAE;IAC1B,MAAM,MAAM,GAA2B,EAAE,GAAG,OAAO,EAAE,CAAC;IACtD,MAAM,IAAI,GAAG,OAAO,CAAC,YAAY,IAAI,YAAY,CAAC;IAElD,MAAM,cAAc,GAAG,CAAC,QAAgC,EAAQ,EAAE;QAChE,IAAI,SAAS,EAAE,CAAC;YACd,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC,CAAC;IAEF,OAA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I,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACjC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;gBACvB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;gBACnB,cAAc,CAAC;oBACb,KAAK,EAAE,YAAY;oBACnB,IAAI,EAAE,OAAO;oBACb,GAAG;iBACJ,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QACD,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC;QAC/B,SAAS,EAAE,CAAC,QAAiB,EAAE,EAAE,CAC/B,IAAA,6BAAe,EAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;KAC7D,CAAC;AACJ,CAAC,CAAC;AA/DW,QAAA,2BAA2B,+BA+DtC"}
@@ -1,106 +1,25 @@
1
1
  "use strict";
2
- // CryptoJS — minimal collection-runner crypto helpers.
2
+ // CryptoJS — the real `crypto-js` package, surfaced unmodified so
3
+ // Postman scripts that lean on it ("CryptoJS.HmacSHA256(message, key)",
4
+ // "CryptoJS.AES.encrypt", "CryptoJS.SHA256", "CryptoJS.MD5",
5
+ // "CryptoJS.PBKDF2", "CryptoJS.enc.Hex/Base64/Utf8", "CryptoJS.lib.WordArray")
6
+ // run unmodified.
3
7
  //
4
- // Migrated from pmanfrontend/electron/script/runtime.ts. The original
5
- // implementation used Node's `Buffer` for base64 encoding; the canonical
6
- // sandbox blocks `Buffer` (security policy), so this rewrite uses an
7
- // in-process btoa-equivalent that produces RFC 4648 standard output.
8
+ // Why we kept a hand-written stub for so long: the original Callman
9
+ // sandbox blocked `Buffer`, and the team wanted to control bundle
10
+ // size. The trade-off failed in practice — every other request-signing
11
+ // pattern in real Postman scripts uses HMAC-SHA256, which the stub
12
+ // could not provide, leading to "CryptoJS.HmacSHA256 is not a function"
13
+ // errors. Bundling the real ~150 KB library is the right call.
8
14
  //
9
- // Only the surface that user scripts actually consume is implemented:
10
- // CryptoJS.enc.Utf8.parse(string) → Uint8Array
11
- // CryptoJS.enc.Utf8.stringify(Uint8Array | ArrayBufferLike) → string
12
- // CryptoJS.enc.Base64.stringify(Uint8Array | ArrayBufferLike) → string
13
- // CryptoJS.enc.Base64.parse(base64String) → Uint8Array (decoder)
14
- //
15
- // HMAC / SHA / AES are intentionally out of scope.
15
+ // The pure-JS implementation does not touch Node's `Buffer`, so it
16
+ // runs inside the vm sandbox without any host shims.
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
16
20
  Object.defineProperty(exports, "__esModule", { value: true });
17
21
  exports.createCryptoJsApi = void 0;
18
- const BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
19
- const toUint8Array = (input) => {
20
- if (input instanceof Uint8Array) {
21
- return input;
22
- }
23
- if (input instanceof ArrayBuffer) {
24
- return new Uint8Array(input);
25
- }
26
- if (ArrayBuffer.isView(input)) {
27
- const view = input;
28
- return new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
29
- }
30
- if (typeof input === "string") {
31
- return new TextEncoder().encode(input);
32
- }
33
- return new Uint8Array(0);
34
- };
35
- // Portable base64 encoder: walks the Uint8Array in 3-byte chunks and emits
36
- // four characters per chunk per RFC 4648. No reliance on Buffer or btoa,
37
- // so it works in vm contexts where neither is exposed.
38
- const encodeBase64 = (bytes) => {
39
- let output = "";
40
- const length = bytes.length;
41
- for (let index = 0; index < length; index += 3) {
42
- const b0 = bytes[index];
43
- const b1 = index + 1 < length ? bytes[index + 1] : 0;
44
- const b2 = index + 2 < length ? bytes[index + 2] : 0;
45
- const triplet = (b0 << 16) | (b1 << 8) | b2;
46
- output += BASE64_CHARS[(triplet >> 18) & 0x3f];
47
- output += BASE64_CHARS[(triplet >> 12) & 0x3f];
48
- output += index + 1 < length ? BASE64_CHARS[(triplet >> 6) & 0x3f] : "=";
49
- output += index + 2 < length ? BASE64_CHARS[triplet & 0x3f] : "=";
50
- }
51
- return output;
52
- };
53
- // Inverse of encodeBase64. Accepts both standard base64 (`+`/`/`, padded)
54
- // and base64url (`-`/`_`, unpadded) input — useful because callers
55
- // frequently pass JWT payload segments which use the url-safe alphabet
56
- // without padding. Throws on characters outside both alphabets so the
57
- // caller fails fast on garbage input rather than silently producing junk
58
- // bytes.
59
- const decodeBase64 = (input) => {
60
- // Normalize url-safe → standard and re-pad to a multiple of 4.
61
- const normalized = input.replace(/-/g, "+").replace(/_/g, "/");
62
- const padding = (4 - (normalized.length % 4)) % 4;
63
- const padded = normalized + "=".repeat(padding);
64
- // Reject anything outside the standard alphabet (post-normalization).
65
- if (!/^[A-Za-z0-9+/]*={0,2}$/.test(padded)) {
66
- throw new Error("CryptoJS.enc.Base64.parse: invalid base64 input");
67
- }
68
- const cleanLength = padded.replace(/=+$/g, "").length;
69
- const byteLength = Math.floor((cleanLength * 3) / 4);
70
- const out = new Uint8Array(byteLength);
71
- let outIndex = 0;
72
- for (let i = 0; i < padded.length; i += 4) {
73
- const c1 = BASE64_CHARS.indexOf(padded[i]);
74
- const c2 = BASE64_CHARS.indexOf(padded[i + 1]);
75
- const c3 = padded[i + 2] === "=" ? -1 : BASE64_CHARS.indexOf(padded[i + 2]);
76
- const c4 = padded[i + 3] === "=" ? -1 : BASE64_CHARS.indexOf(padded[i + 3]);
77
- out[outIndex++] = (c1 << 2) | (c2 >> 4);
78
- if (c3 >= 0)
79
- out[outIndex++] = ((c2 & 0x0f) << 4) | (c3 >> 2);
80
- if (c4 >= 0)
81
- out[outIndex++] = ((c3 & 0x03) << 6) | c4;
82
- }
83
- return out;
84
- };
85
- const createCryptoJsApi = () => {
86
- const decoder = new TextDecoder();
87
- return {
88
- enc: {
89
- Utf8: {
90
- parse: (input) => toUint8Array(input),
91
- stringify: (input) => decoder.decode(toUint8Array(input)),
92
- },
93
- Base64: {
94
- stringify: (input) => encodeBase64(toUint8Array(input)),
95
- parse: (input) => {
96
- if (typeof input !== "string") {
97
- throw new Error("CryptoJS.enc.Base64.parse: expected a string");
98
- }
99
- return decodeBase64(input);
100
- },
101
- },
102
- },
103
- };
104
- };
22
+ const crypto_js_1 = __importDefault(require("crypto-js"));
23
+ const createCryptoJsApi = () => crypto_js_1.default;
105
24
  exports.createCryptoJsApi = createCryptoJsApi;
106
25
  //# sourceMappingURL=cryptojs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cryptojs.js","sourceRoot":"","sources":["../../../src/script/features/cryptojs.ts"],"names":[],"mappings":";AAAA,uDAAuD;AACvD,EAAE;AACF,sEAAsE;AACtE,yEAAyE;AACzE,qEAAqE;AACrE,qEAAqE;AACrE,EAAE;AACF,sEAAsE;AACtE,iDAAiD;AACjD,uEAAuE;AACvE,yEAAyE;AACzE,oEAAoE;AACpE,EAAE;AACF,mDAAmD;;;AAEnD,MAAM,YAAY,GAChB,kEAAkE,CAAC;AAErE,MAAM,YAAY,GAAG,CAAC,KAAc,EAAc,EAAE;IAClD,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;QACjC,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IACD,IAAI,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,GAAG,KAAwB,CAAC;QACtC,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACvE,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;AAC3B,CAAC,CAAC;AAEF,2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AC,CAAC;gBACxE,KAAK,EAAE,CAAC,KAAa,EAAc,EAAE;oBACnC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;wBAC9B,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;oBAClE,CAAC;oBACD,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;gBAC7B,CAAC;aACF;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AAnBW,QAAA,iBAAiB,qBAmB5B"}
1
+ {"version":3,"file":"cryptojs.js","sourceRoot":"","sources":["../../../src/script/features/cryptojs.ts"],"names":[],"mappings":";AAAA,kEAAkE;AAClE,wEAAwE;AACxE,6DAA6D;AAC7D,+EAA+E;AAC/E,kBAAkB;AAClB,EAAE;AACF,oEAAoE;AACpE,kEAAkE;AAClE,uEAAuE;AACvE,mEAAmE;AACnE,wEAAwE;AACxE,+DAA+D;AAC/D,EAAE;AACF,mEAAmE;AACnE,qDAAqD;;;;;;AAErD,0DAAiC;AAU1B,MAAM,iBAAiB,GAAG,GAAgB,EAAE,CAAC,mBAAQ,CAAC;AAAhD,QAAA,iBAAiB,qBAA+B"}
@@ -8,18 +8,27 @@
8
8
  // - emitMutations=false: the API mutates the in-memory `values` record
9
9
  // directly without producing a log. Used by callman-core's legacy
10
10
  // `runScript` shim where EnvStore is the source of truth.
11
+ //
12
+ // Postman compatibility additions (Phase 1.3):
13
+ // - `.replaceIn(template)` — resolve `{{var}}` against THIS scope only.
14
+ // - `.clear()` — wipe all keys (emits one unset mutation per key when
15
+ // mutations are tracked, so the host can mirror the deletion).
16
+ // - `.name` — read-only string label of the active scope ("environment"
17
+ // or "global" by default; backend can override via `nameOverride`).
11
18
  Object.defineProperty(exports, "__esModule", { value: true });
12
19
  exports.buildEnvironmentApi = void 0;
20
+ const resolver_js_1 = require("../../variables/resolver.js");
13
21
  const coerceToString = (value) => {
14
22
  if (value === undefined || value === null) {
15
23
  return "";
16
24
  }
17
25
  return String(value);
18
26
  };
19
- const buildEnvironmentApi = (initial, mutations, scope) => {
27
+ const buildEnvironmentApi = (initial, mutations, scope, options = {}) => {
20
28
  // Copy so the caller's record is never mutated in-place when the
21
29
  // sandbox is configured to emit mutations.
22
30
  const values = { ...initial };
31
+ const name = options.nameOverride ?? (scope === "global" ? "Globals" : "Environment");
23
32
  const recordMutation = (mutation) => {
24
33
  if (mutations) {
25
34
  mutations.push(mutation);
@@ -27,6 +36,7 @@ const buildEnvironmentApi = (initial, mutations, scope) => {
27
36
  };
28
37
  return {
29
38
  values,
39
+ name,
30
40
  get: (key) => values[String(key ?? "").trim()],
31
41
  set: (key, value) => {
32
42
  const normalizedKey = String(key ?? "").trim();
@@ -58,7 +68,21 @@ const buildEnvironmentApi = (initial, mutations, scope) => {
58
68
  const normalizedKey = String(key ?? "").trim();
59
69
  return Boolean(normalizedKey) && normalizedKey in values;
60
70
  },
71
+ clear: () => {
72
+ // Snapshot keys first so we emit one unset mutation per entry and
73
+ // don't fight the iteration order while deleting.
74
+ const keys = Object.keys(values);
75
+ for (const key of keys) {
76
+ delete values[key];
77
+ recordMutation({
78
+ scope,
79
+ type: "unset",
80
+ key,
81
+ });
82
+ }
83
+ },
61
84
  toObject: () => ({ ...values }),
85
+ replaceIn: (template) => (0, resolver_js_1.resolveTemplate)(coerceToString(template), { env: values }),
62
86
  };
63
87
  };
64
88
  exports.buildEnvironmentApi = buildEnvironmentApi;
@@ -1 +1 @@
1
- {"version":3,"file":"environment.js","sourceRoot":"","sources":["../../../src/script/features/environment.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,EAAE;AACF,uBAAuB;AACvB,sEAAsE;AACtE,2EAA2E;AAC3E,qDAAqD;AACrD,yEAAyE;AACzE,sEAAsE;AACtE,8DAA8D;;;AAa9D,MAAM,cAAc,GAAG,CAAC,KAAc,EAAU,EAAE;IAChD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC1C,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,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,cAAc,CAAC;gBACb,KAAK;gBACL,IAAI,EAAE,OAAO;gBACb,GAAG,EAAE,aAAa;aACnB,CAAC,CAAC;QACL,CAAC;QACD,GAAG,EAAE,CAAC,GAAW,EAAE,EAAE;YACnB,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;YAC/C,OAAO,OAAO,CAAC,aAAa,CAAC,IAAI,aAAa,IAAI,MAAM,CAAC;QAC3D,CAAC;QACD,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC;KAChC,CAAC;AACJ,CAAC,CAAC;AAlDW,QAAA,mBAAmB,uBAkD9B"}
1
+ {"version":3,"file":"environment.js","sourceRoot":"","sources":["../../../src/script/features/environment.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,EAAE;AACF,uBAAuB;AACvB,sEAAsE;AACtE,2EAA2E;AAC3E,qDAAqD;AACrD,yEAAyE;AACzE,sEAAsE;AACtE,8DAA8D;AAC9D,EAAE;AACF,+CAA+C;AAC/C,0EAA0E;AAC1E,wEAAwE;AACxE,mEAAmE;AACnE,0EAA0E;AAC1E,wEAAwE;;;AAExE,6DAA8D;AAiB9D,MAAM,cAAc,GAAG,CAAC,KAAc,EAAU,EAAE;IAChD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC1C,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC,CAAC;AAEK,MAAM,mBAAmB,GAAG,CACjC,OAA+B,EAC/B,SAA0C,EAC1C,KAAsC,EACtC,UAAqC,EAAE,EACvB,EAAE;IAClB,iEAAiE;IACjE,2CAA2C;IAC3C,MAAM,MAAM,GAA2B,EAAE,GAAG,OAAO,EAAE,CAAC;IACtD,MAAM,IAAI,GAAG,OAAO,CAAC,YAAY,IAAI,CAAC,KAAK,KAAK,QAAQ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nB,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;YAC/C,OAAO,OAAO,CAAC,aAAa,CAAC,IAAI,aAAa,IAAI,MAAM,CAAC;QAC3D,CAAC;QACD,KAAK,EAAE,GAAG,EAAE;YACV,kEAAkE;YAClE,kDAAkD;YAClD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACjC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;gBACvB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;gBACnB,cAAc,CAAC;oBACb,KAAK;oBACL,IAAI,EAAE,OAAO;oBACb,GAAG;iBACJ,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QACD,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC;QAC/B,SAAS,EAAE,CAAC,QAAiB,EAAE,EAAE,CAC/B,IAAA,6BAAe,EAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;KAC7D,CAAC;AACJ,CAAC,CAAC;AApEW,QAAA,mBAAmB,uBAoE9B"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ // pm.execution — Postman's collection-runner control surface.
3
+ //
4
+ // pm.execution.setNextRequest(name | null)
5
+ // Tell the runner to jump to a named request after this one (or
6
+ // `null` to stop the branch). Has no effect outside a runner — the
7
+ // host is free to ignore the flag for ad-hoc Send.
8
+ //
9
+ // pm.execution.skipRequest()
10
+ // Only meaningful in a pre-request script. Sets a flag that causes
11
+ // the runner to skip the HTTP call entirely. The Tests script then
12
+ // does NOT run either.
13
+ //
14
+ // pm.execution.location / .location.current
15
+ // A path-like array of segment strings (e.g. ["Smoke",
16
+ // "Authentication", "Login"]) and the last segment as `.current`,
17
+ // so users can pivot behaviour by location.
18
+ //
19
+ // Why this lives separately from `pm.node`:
20
+ // pm.node was a Callman-specific scenario-flow accessor. pm.execution
21
+ // is the Postman-named surface. We expose both — pm.node stays for
22
+ // back-compat, pm.execution is preferred going forward.
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.buildExecutionFeature = void 0;
25
+ const buildLocation = (segments) => {
26
+ const arr = Array.isArray(segments) ? [...segments] : [];
27
+ const current = arr.length > 0 ? arr[arr.length - 1] : "";
28
+ // Augment the array with a `.current` getter. Using
29
+ // Object.defineProperty keeps it non-enumerable so JSON.stringify
30
+ // still produces a plain array.
31
+ Object.defineProperty(arr, "current", {
32
+ configurable: true,
33
+ enumerable: false,
34
+ get: () => current,
35
+ });
36
+ return arr;
37
+ };
38
+ const buildExecutionFeature = (capability) => {
39
+ const state = {
40
+ nextRequest: undefined,
41
+ skipRequested: false,
42
+ };
43
+ const location = buildLocation(capability?.location);
44
+ const api = {
45
+ setNextRequest: (name) => {
46
+ if (name === null || name === undefined) {
47
+ state.nextRequest = null;
48
+ return;
49
+ }
50
+ const trimmed = String(name).trim();
51
+ state.nextRequest = trimmed.length > 0 ? trimmed : null;
52
+ },
53
+ skipRequest: () => {
54
+ state.skipRequested = true;
55
+ },
56
+ location,
57
+ };
58
+ return {
59
+ api,
60
+ getControl: () => ({ ...state }),
61
+ };
62
+ };
63
+ exports.buildExecutionFeature = buildExecutionFeature;
64
+ //# sourceMappingURL=execution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution.js","sourceRoot":"","sources":["../../../src/script/features/execution.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,EAAE;AACF,6CAA6C;AAC7C,oEAAoE;AACpE,uEAAuE;AACvE,uDAAuD;AACvD,EAAE;AACF,+BAA+B;AAC/B,uEAAuE;AACvE,uEAAuE;AACvE,2BAA2B;AAC3B,EAAE;AACF,8CAA8C;AAC9C,2DAA2D;AAC3D,sEAAsE;AACtE,gDAAgD;AAChD,EAAE;AACF,4CAA4C;AAC5C,wEAAwE;AACxE,qEAAqE;AACrE,0DAA0D;;;AA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AC,aAAa,GAAG,IAAI,CAAC;QAC7B,CAAC;QACD,QAAQ;KACT,CAAC;IAEF,OAAO;QACL,GAAG;QACH,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC;KACjC,CAAC;AACJ,CAAC,CAAC;AA7BW,QAAA,qBAAqB,yBA6BhC"}
@@ -0,0 +1,289 @@
1
+ "use strict";
2
+ // HeaderList — Postman-compatible header / query parameter wrapper.
3
+ //
4
+ // Background. Older callman-core releases exposed `pm.request.headers` and
5
+ // `pm.response.headers` as plain `Record<string, string>` objects. Many real
6
+ // Postman scripts assume a richer `HeaderList` shape:
7
+ //
8
+ // pm.request.headers.add({ key, value, description? })
9
+ // pm.request.headers.upsert({ key, value, description? })
10
+ // pm.request.headers.remove(name)
11
+ // pm.request.headers.has(name) // case-insensitive
12
+ // pm.request.headers.get(name) // case-insensitive
13
+ // pm.request.headers.idx(i) // entry at index
14
+ // pm.request.headers.all() // [{ key, value, description }]
15
+ // for (const h of pm.request.headers) ... // iterable
16
+ //
17
+ // The class below provides both shapes through a Proxy: existing scripts that
18
+ // rely on bracket access (`headers["X-Custom"]`, `Object.keys(headers)`,
19
+ // `Object.entries(headers)`) keep working bit-for-bit, while new scripts can
20
+ // call the Postman methods on the same object.
21
+ //
22
+ // Mutability:
23
+ // - Request headers are writable. `setHeader` / `add` / `upsert` mutate the
24
+ // internal list and the changes are observed by `toRequestState()` when
25
+ // the script completes.
26
+ // - Response headers are constructed read-only — `add` / `upsert` / `remove`
27
+ // throw to preserve the immutability of an already-received response.
28
+ //
29
+ // Case sensitivity rules:
30
+ // - Lookups via `.get()`, `.has()`, `.remove()`, `.upsert()` are
31
+ // case-INSENSITIVE. This matches Postman and is the HTTP semantic.
32
+ // - Bracket access (`headers["X-Custom"]`) is case-SENSITIVE for
33
+ // back-compat with older Callman scripts that depended on exact-case
34
+ // keys derived from the previous Record<string, string> shape.
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.headerListEntries = exports.createHeaderList = void 0;
37
+ const METHOD_KEYS = new Set([
38
+ "get",
39
+ "has",
40
+ "idx",
41
+ "add",
42
+ "upsert",
43
+ "remove",
44
+ "all",
45
+ "toJSON",
46
+ "isReadOnly",
47
+ ]);
48
+ const normaliseSpec = (spec) => {
49
+ if (spec === null || typeof spec !== "object") {
50
+ throw new TypeError("HeaderList: expected { key, value, description? } object");
51
+ }
52
+ const key = String(spec.key ?? "").trim();
53
+ if (!key) {
54
+ throw new TypeError("HeaderList: header key must be a non-empty string");
55
+ }
56
+ const value = spec.value;
57
+ const description = spec.description;
58
+ return {
59
+ key,
60
+ value: value === undefined || value === null ? "" : String(value),
61
+ description: typeof description === "string" ? description : undefined,
62
+ };
63
+ };
64
+ const stringifyValue = (value) => value === undefined || value === null ? "" : String(value);
65
+ class HeaderListImpl {
66
+ entries = [];
67
+ readOnly;
68
+ constructor(initial, readOnly = false) {
69
+ for (const entry of initial) {
70
+ this.entries.push({ ...entry });
71
+ }
72
+ this.readOnly = readOnly;
73
+ }
74
+ guardWritable() {
75
+ if (this.readOnly) {
76
+ throw new Error("Cannot mutate response headers — they are read-only after the response is captured.");
77
+ }
78
+ }
79
+ get(name) {
80
+ const target = String(name ?? "")
81
+ .trim()
82
+ .toLowerCase();
83
+ if (!target)
84
+ return undefined;
85
+ for (const entry of this.entries) {
86
+ if (entry.key.toLowerCase() === target) {
87
+ return entry.value;
88
+ }
89
+ }
90
+ return undefined;
91
+ }
92
+ has(name) {
93
+ return this.get(name) !== undefined;
94
+ }
95
+ idx(index) {
96
+ if (!Number.isInteger(index) || index < 0 || index >= this.entries.length) {
97
+ return undefined;
98
+ }
99
+ return { ...this.entries[index] };
100
+ }
101
+ add(spec) {
102
+ this.guardWritable();
103
+ this.entries.push(normaliseSpec(spec));
104
+ }
105
+ upsert(spec) {
106
+ this.guardWritable();
107
+ const next = normaliseSpec(spec);
108
+ const target = next.key.toLowerCase();
109
+ const replaceIndex = this.entries.findIndex((entry) => entry.key.toLowerCase() === target);
110
+ if (replaceIndex >= 0) {
111
+ this.entries[replaceIndex] = next;
112
+ // Drop any further duplicates so upsert leaves a single entry.
113
+ for (let i = this.entries.length - 1; i > replaceIndex; i -= 1) {
114
+ if (this.entries[i].key.toLowerCase() === target) {
115
+ this.entries.splice(i, 1);
116
+ }
117
+ }
118
+ return;
119
+ }
120
+ this.entries.push(next);
121
+ }
122
+ remove(name) {
123
+ this.guardWritable();
124
+ const target = String(name ?? "")
125
+ .trim()
126
+ .toLowerCase();
127
+ if (!target)
128
+ return;
129
+ for (let i = this.entries.length - 1; i >= 0; i -= 1) {
130
+ if (this.entries[i].key.toLowerCase() === target) {
131
+ this.entries.splice(i, 1);
132
+ }
133
+ }
134
+ }
135
+ all() {
136
+ return this.entries.map((entry) => ({ ...entry }));
137
+ }
138
+ toJSON() {
139
+ return this.all();
140
+ }
141
+ *[Symbol.iterator]() {
142
+ for (const entry of this.entries) {
143
+ yield { ...entry };
144
+ }
145
+ }
146
+ // ── Internal hooks used by the Proxy wrapper ──────────────────────────
147
+ __rawEntries() {
148
+ return this.entries;
149
+ }
150
+ __setRaw(key, value) {
151
+ this.guardWritable();
152
+ const normalisedKey = String(key ?? "").trim();
153
+ if (!normalisedKey)
154
+ return;
155
+ // Bracket-assignment is treated as upsert with EXACT case so that
156
+ // Object.keys(headers) and headers[k] readbacks see the user's chosen
157
+ // case — matches the legacy Record<string, string> behaviour.
158
+ const stringValue = stringifyValue(value);
159
+ const existing = this.entries.findIndex((entry) => entry.key === normalisedKey);
160
+ if (existing >= 0) {
161
+ this.entries[existing].value = stringValue;
162
+ return;
163
+ }
164
+ this.entries.push({ key: normalisedKey, value: stringValue });
165
+ }
166
+ __deleteRaw(key) {
167
+ this.guardWritable();
168
+ const normalisedKey = String(key ?? "").trim();
169
+ if (!normalisedKey)
170
+ return false;
171
+ const idx = this.entries.findIndex((entry) => entry.key === normalisedKey);
172
+ if (idx >= 0) {
173
+ this.entries.splice(idx, 1);
174
+ return true;
175
+ }
176
+ return false;
177
+ }
178
+ }
179
+ /**
180
+ * Build a Proxy-wrapped HeaderList. Bracket access reads / writes as if the
181
+ * value were a plain `Record<string, string>` (case-sensitive, exact key
182
+ * match). The HeaderList methods (`get`, `has`, `add`, ...) are exposed
183
+ * directly on the wrapper.
184
+ */
185
+ const createHeaderList = (initial = [], options = {}) => {
186
+ const entries = Array.isArray(initial)
187
+ ? initial.map((entry) => ({ ...entry }))
188
+ : Object.entries(initial).map(([key, value]) => ({
189
+ key,
190
+ value: stringifyValue(value),
191
+ }));
192
+ const impl = new HeaderListImpl(entries, options.readOnly ?? false);
193
+ return new Proxy(impl, {
194
+ get(target, prop, receiver) {
195
+ // Hand back methods / iterator unchanged.
196
+ if (typeof prop === "symbol") {
197
+ return Reflect.get(target, prop, receiver);
198
+ }
199
+ if (METHOD_KEYS.has(prop) || prop in target) {
200
+ const value = Reflect.get(target, prop, receiver);
201
+ if (typeof value === "function") {
202
+ return value.bind(target);
203
+ }
204
+ return value;
205
+ }
206
+ // String prop → look up as a header name (case-sensitive bracket
207
+ // access for back-compat with the previous Record shape).
208
+ const raw = target.__rawEntries();
209
+ for (const entry of raw) {
210
+ if (entry.key === prop) {
211
+ return entry.value;
212
+ }
213
+ }
214
+ return undefined;
215
+ },
216
+ set(target, prop, value, receiver) {
217
+ if (typeof prop === "symbol" || METHOD_KEYS.has(prop)) {
218
+ return Reflect.set(target, prop, value, receiver);
219
+ }
220
+ target.__setRaw(prop, value);
221
+ return true;
222
+ },
223
+ has(target, prop) {
224
+ if (typeof prop === "symbol" || METHOD_KEYS.has(prop) || prop in target) {
225
+ return Reflect.has(target, prop);
226
+ }
227
+ const raw = target.__rawEntries();
228
+ return raw.some((entry) => entry.key === prop);
229
+ },
230
+ deleteProperty(target, prop) {
231
+ if (typeof prop === "symbol" || METHOD_KEYS.has(prop)) {
232
+ return Reflect.deleteProperty(target, prop);
233
+ }
234
+ return target.__deleteRaw(String(prop));
235
+ },
236
+ ownKeys(target) {
237
+ // Object.keys / Object.entries / for-in see only the header names.
238
+ // The HeaderList methods stay non-enumerable so they don't pollute
239
+ // serialisation.
240
+ const raw = target.__rawEntries();
241
+ const seen = new Set();
242
+ const keys = [];
243
+ for (const entry of raw) {
244
+ if (!seen.has(entry.key)) {
245
+ seen.add(entry.key);
246
+ keys.push(entry.key);
247
+ }
248
+ }
249
+ return keys;
250
+ },
251
+ getOwnPropertyDescriptor(target, prop) {
252
+ if (typeof prop === "symbol") {
253
+ return Reflect.getOwnPropertyDescriptor(target, prop);
254
+ }
255
+ if (METHOD_KEYS.has(prop)) {
256
+ return undefined;
257
+ }
258
+ const raw = target.__rawEntries();
259
+ const found = raw.find((entry) => entry.key === prop);
260
+ if (found) {
261
+ return {
262
+ configurable: true,
263
+ enumerable: true,
264
+ writable: true,
265
+ value: found.value,
266
+ };
267
+ }
268
+ return undefined;
269
+ },
270
+ });
271
+ };
272
+ exports.createHeaderList = createHeaderList;
273
+ /**
274
+ * Best-effort extraction of the underlying entry list, used by the
275
+ * request-state serialiser. Falls back to `Object.entries` for back-compat
276
+ * with any external callers that still pass a plain record.
277
+ */
278
+ const headerListEntries = (value) => {
279
+ if (value &&
280
+ typeof value.all === "function") {
281
+ return value.all();
282
+ }
283
+ return Object.entries(value).map(([key, raw]) => ({
284
+ key,
285
+ value: stringifyValue(raw),
286
+ }));
287
+ };
288
+ exports.headerListEntries = headerListEntries;
289
+ //# sourceMappingURL=headerList.js.map