callman-core 1.34.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.
Files changed (266) hide show
  1. package/ai-packs/feature-policy.md +1 -6
  2. package/ai-packs/pm-api.md +246 -97
  3. package/ai-packs/sandbox-globals.md +6 -5
  4. package/dist/ai/prompts/fragments.d.ts.map +1 -1
  5. package/dist/ai/prompts/fragments.js +0 -1
  6. package/dist/ai/prompts/fragments.js.map +1 -1
  7. package/dist/ai/prompts/unified.js +1 -1
  8. package/dist/ai/prompts/unified.js.map +1 -1
  9. package/dist/ai/types.d.ts +1 -1
  10. package/dist/ai/types.d.ts.map +1 -1
  11. package/dist/ai/types.js +1 -1
  12. package/dist/ai/types.js.map +1 -1
  13. package/dist/index.d.ts +7 -2
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +5 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/runner/requestRunner.d.ts.map +1 -1
  18. package/dist/runner/requestRunner.js +339 -1
  19. package/dist/runner/requestRunner.js.map +1 -1
  20. package/dist/runner/runCollection.d.ts +1 -1
  21. package/dist/runner/runCollection.d.ts.map +1 -1
  22. package/dist/runner/runCollection.js +60 -7
  23. package/dist/runner/runCollection.js.map +1 -1
  24. package/dist/runner/runRequestWithDataset.d.ts.map +1 -1
  25. package/dist/runner/runRequestWithDataset.js +5 -0
  26. package/dist/runner/runRequestWithDataset.js.map +1 -1
  27. package/dist/scenario-runner/adapters/request-executor.d.ts.map +1 -1
  28. package/dist/scenario-runner/adapters/request-executor.js +7 -0
  29. package/dist/scenario-runner/adapters/request-executor.js.map +1 -1
  30. package/dist/scenario-runner/runScenario.d.ts.map +1 -1
  31. package/dist/scenario-runner/runScenario.js +4 -0
  32. package/dist/scenario-runner/runScenario.js.map +1 -1
  33. package/dist/scenario-runner/types.d.ts +11 -0
  34. package/dist/scenario-runner/types.d.ts.map +1 -1
  35. package/dist/script/chain.d.ts +56 -0
  36. package/dist/script/chain.d.ts.map +1 -0
  37. package/dist/script/chain.js +121 -0
  38. package/dist/script/chain.js.map +1 -0
  39. package/dist/script/errors.d.ts.map +1 -1
  40. package/dist/script/errors.js +6 -4
  41. package/dist/script/errors.js.map +1 -1
  42. package/dist/script/executor.d.ts.map +1 -1
  43. package/dist/script/executor.js +298 -64
  44. package/dist/script/executor.js.map +1 -1
  45. package/dist/script/features/collectionVariables.d.ts +4 -4
  46. package/dist/script/features/collectionVariables.d.ts.map +1 -1
  47. package/dist/script/features/collectionVariables.js +20 -11
  48. package/dist/script/features/collectionVariables.js.map +1 -1
  49. package/dist/script/features/environment.d.ts +4 -4
  50. package/dist/script/features/environment.d.ts.map +1 -1
  51. package/dist/script/features/environment.js +20 -11
  52. package/dist/script/features/environment.js.map +1 -1
  53. package/dist/script/features/feature-policy.d.ts +1 -1
  54. package/dist/script/features/feature-policy.d.ts.map +1 -1
  55. package/dist/script/features/feature-policy.js +2 -2
  56. package/dist/script/features/feature-policy.js.map +1 -1
  57. package/dist/script/features/info.d.ts.map +1 -1
  58. package/dist/script/features/info.js +6 -3
  59. package/dist/script/features/info.js.map +1 -1
  60. package/dist/script/features/iterationData.d.ts +12 -0
  61. package/dist/script/features/iterationData.d.ts.map +1 -0
  62. package/dist/script/features/iterationData.js +28 -0
  63. package/dist/script/features/iterationData.js.map +1 -0
  64. package/dist/script/features/legacyPostman.d.ts +14 -0
  65. package/dist/script/features/legacyPostman.d.ts.map +1 -0
  66. package/dist/script/features/legacyPostman.js +106 -0
  67. package/dist/script/features/legacyPostman.js.map +1 -0
  68. package/dist/script/features/log.d.ts +35 -8
  69. package/dist/script/features/log.d.ts.map +1 -1
  70. package/dist/script/features/log.js +343 -27
  71. package/dist/script/features/log.js.map +1 -1
  72. package/dist/script/features/tests.d.ts +7 -8
  73. package/dist/script/features/tests.d.ts.map +1 -1
  74. package/dist/script/features/tests.js +90 -64
  75. package/dist/script/features/tests.js.map +1 -1
  76. package/dist/script/features/timers.d.ts +7 -1
  77. package/dist/script/features/timers.d.ts.map +1 -1
  78. package/dist/script/features/timers.js +17 -5
  79. package/dist/script/features/timers.js.map +1 -1
  80. package/dist/script/features/variables.d.ts +25 -4
  81. package/dist/script/features/variables.d.ts.map +1 -1
  82. package/dist/script/features/variables.js +26 -9
  83. package/dist/script/features/variables.js.map +1 -1
  84. package/dist/script/features/visualizer.d.ts +15 -0
  85. package/dist/script/features/visualizer.d.ts.map +1 -0
  86. package/dist/script/features/visualizer.js +52 -0
  87. package/dist/script/features/visualizer.js.map +1 -0
  88. package/dist/script/isolated-runner.d.ts +4 -1
  89. package/dist/script/isolated-runner.d.ts.map +1 -1
  90. package/dist/script/isolated-runner.js +26 -2
  91. package/dist/script/isolated-runner.js.map +1 -1
  92. package/dist/script/layers.d.ts +46 -0
  93. package/dist/script/layers.d.ts.map +1 -0
  94. package/dist/script/layers.js +52 -0
  95. package/dist/script/layers.js.map +1 -0
  96. package/dist/script/legacy.d.ts +6 -1
  97. package/dist/script/legacy.d.ts.map +1 -1
  98. package/dist/script/legacy.js +15 -5
  99. package/dist/script/legacy.js.map +1 -1
  100. package/dist/script/pm-api-declarations.d.ts +45 -0
  101. package/dist/script/pm-api-declarations.d.ts.map +1 -0
  102. package/dist/script/pm-api-declarations.js +1963 -0
  103. package/dist/script/pm-api-declarations.js.map +1 -0
  104. package/dist/script/pm-api-metadata.d.ts +3 -1
  105. package/dist/script/pm-api-metadata.d.ts.map +1 -1
  106. package/dist/script/pm-api-metadata.js +336 -106
  107. package/dist/script/pm-api-metadata.js.map +1 -1
  108. package/dist/script/pm-api-reference.d.ts.map +1 -1
  109. package/dist/script/pm-api-reference.js +32 -7
  110. package/dist/script/pm-api-reference.js.map +1 -1
  111. package/dist/script/postman/chaiCompat.d.ts +4 -0
  112. package/dist/script/postman/chaiCompat.d.ts.map +1 -0
  113. package/dist/script/postman/chaiCompat.js +176 -0
  114. package/dist/script/postman/chaiCompat.js.map +1 -0
  115. package/dist/script/postman/cookies.d.ts +36 -0
  116. package/dist/script/postman/cookies.d.ts.map +1 -0
  117. package/dist/script/postman/cookies.js +163 -0
  118. package/dist/script/postman/cookies.js.map +1 -0
  119. package/dist/script/postman/modules.d.ts +16 -0
  120. package/dist/script/postman/modules.d.ts.map +1 -0
  121. package/dist/script/postman/modules.js +114 -0
  122. package/dist/script/postman/modules.js.map +1 -0
  123. package/dist/script/postman/proxies.d.ts +13 -0
  124. package/dist/script/postman/proxies.d.ts.map +1 -0
  125. package/dist/script/postman/proxies.js +88 -0
  126. package/dist/script/postman/proxies.js.map +1 -0
  127. package/dist/script/postman/requestAdapter.d.ts +7 -0
  128. package/dist/script/postman/requestAdapter.d.ts.map +1 -0
  129. package/dist/script/postman/requestAdapter.js +223 -0
  130. package/dist/script/postman/requestAdapter.js.map +1 -0
  131. package/dist/script/postman/responseAdapter.d.ts +5 -0
  132. package/dist/script/postman/responseAdapter.d.ts.map +1 -0
  133. package/dist/script/postman/responseAdapter.js +78 -0
  134. package/dist/script/postman/responseAdapter.js.map +1 -0
  135. package/dist/script/postman/runtime.d.ts +22 -0
  136. package/dist/script/postman/runtime.d.ts.map +1 -0
  137. package/dist/script/postman/runtime.js +122 -0
  138. package/dist/script/postman/runtime.js.map +1 -0
  139. package/dist/script/scope.d.ts +5 -1
  140. package/dist/script/scope.d.ts.map +1 -1
  141. package/dist/script/scope.js +47 -5
  142. package/dist/script/scope.js.map +1 -1
  143. package/dist/script/types.d.ts +42 -14
  144. package/dist/script/types.d.ts.map +1 -1
  145. package/dist/script/worker-entry.js +9 -0
  146. package/dist/script/worker-entry.js.map +1 -1
  147. package/dist/script/worker-pool.d.ts +3 -1
  148. package/dist/script/worker-pool.d.ts.map +1 -1
  149. package/dist/script/worker-pool.js +23 -2
  150. package/dist/script/worker-pool.js.map +1 -1
  151. package/dist/templating/generator-metadata.d.ts +1 -0
  152. package/dist/templating/generator-metadata.d.ts.map +1 -1
  153. package/dist/templating/generator-metadata.js +14 -0
  154. package/dist/templating/generator-metadata.js.map +1 -1
  155. package/dist/templating/postman-dynamic-catalog.d.ts +7 -0
  156. package/dist/templating/postman-dynamic-catalog.d.ts.map +1 -0
  157. package/dist/templating/postman-dynamic-catalog.js +126 -0
  158. package/dist/templating/postman-dynamic-catalog.js.map +1 -0
  159. package/dist/templating/postman-generators.d.ts +9 -0
  160. package/dist/templating/postman-generators.d.ts.map +1 -1
  161. package/dist/templating/postman-generators.js +10 -1
  162. package/dist/templating/postman-generators.js.map +1 -1
  163. package/dist/types/index.d.ts +44 -2
  164. package/dist/types/index.d.ts.map +1 -1
  165. package/dist/variables/envStore.d.ts +3 -0
  166. package/dist/variables/envStore.d.ts.map +1 -1
  167. package/dist/variables/envStore.js +5 -0
  168. package/dist/variables/envStore.js.map +1 -1
  169. package/dist/variables/replaceIn.d.ts +10 -0
  170. package/dist/variables/replaceIn.d.ts.map +1 -0
  171. package/dist/variables/replaceIn.js +106 -0
  172. package/dist/variables/replaceIn.js.map +1 -0
  173. package/dist/variables/resolver.d.ts.map +1 -1
  174. package/dist/variables/resolver.js +16 -2
  175. package/dist/variables/resolver.js.map +1 -1
  176. package/dist-cjs/ai/prompts/fragments.js +0 -1
  177. package/dist-cjs/ai/prompts/fragments.js.map +1 -1
  178. package/dist-cjs/ai/prompts/unified.js +1 -1
  179. package/dist-cjs/ai/prompts/unified.js.map +1 -1
  180. package/dist-cjs/ai/types.js +1 -1
  181. package/dist-cjs/ai/types.js.map +1 -1
  182. package/dist-cjs/index.js +23 -5
  183. package/dist-cjs/index.js.map +1 -1
  184. package/dist-cjs/runner/requestRunner.js +339 -1
  185. package/dist-cjs/runner/requestRunner.js.map +1 -1
  186. package/dist-cjs/runner/runCollection.js +60 -7
  187. package/dist-cjs/runner/runCollection.js.map +1 -1
  188. package/dist-cjs/runner/runRequestWithDataset.js +5 -0
  189. package/dist-cjs/runner/runRequestWithDataset.js.map +1 -1
  190. package/dist-cjs/scenario-runner/adapters/request-executor.js +7 -0
  191. package/dist-cjs/scenario-runner/adapters/request-executor.js.map +1 -1
  192. package/dist-cjs/scenario-runner/runScenario.js +4 -0
  193. package/dist-cjs/scenario-runner/runScenario.js.map +1 -1
  194. package/dist-cjs/script/chain.js +126 -0
  195. package/dist-cjs/script/chain.js.map +1 -0
  196. package/dist-cjs/script/errors.js +6 -4
  197. package/dist-cjs/script/errors.js.map +1 -1
  198. package/dist-cjs/script/executor.js +298 -64
  199. package/dist-cjs/script/executor.js.map +1 -1
  200. package/dist-cjs/script/features/collectionVariables.js +20 -11
  201. package/dist-cjs/script/features/collectionVariables.js.map +1 -1
  202. package/dist-cjs/script/features/environment.js +20 -11
  203. package/dist-cjs/script/features/environment.js.map +1 -1
  204. package/dist-cjs/script/features/feature-policy.js +2 -2
  205. package/dist-cjs/script/features/feature-policy.js.map +1 -1
  206. package/dist-cjs/script/features/info.js +6 -3
  207. package/dist-cjs/script/features/info.js.map +1 -1
  208. package/dist-cjs/script/features/iterationData.js +32 -0
  209. package/dist-cjs/script/features/iterationData.js.map +1 -0
  210. package/dist-cjs/script/features/legacyPostman.js +112 -0
  211. package/dist-cjs/script/features/legacyPostman.js.map +1 -0
  212. package/dist-cjs/script/features/log.js +347 -28
  213. package/dist-cjs/script/features/log.js.map +1 -1
  214. package/dist-cjs/script/features/tests.js +90 -64
  215. package/dist-cjs/script/features/tests.js.map +1 -1
  216. package/dist-cjs/script/features/timers.js +17 -5
  217. package/dist-cjs/script/features/timers.js.map +1 -1
  218. package/dist-cjs/script/features/variables.js +26 -9
  219. package/dist-cjs/script/features/variables.js.map +1 -1
  220. package/dist-cjs/script/features/visualizer.js +56 -0
  221. package/dist-cjs/script/features/visualizer.js.map +1 -0
  222. package/dist-cjs/script/isolated-runner.js +26 -2
  223. package/dist-cjs/script/isolated-runner.js.map +1 -1
  224. package/dist-cjs/script/layers.js +57 -0
  225. package/dist-cjs/script/layers.js.map +1 -0
  226. package/dist-cjs/script/legacy.js +20 -6
  227. package/dist-cjs/script/legacy.js.map +1 -1
  228. package/dist-cjs/script/pm-api-declarations.js +1969 -0
  229. package/dist-cjs/script/pm-api-declarations.js.map +1 -0
  230. package/dist-cjs/script/pm-api-metadata.js +336 -106
  231. package/dist-cjs/script/pm-api-metadata.js.map +1 -1
  232. package/dist-cjs/script/pm-api-reference.js +32 -7
  233. package/dist-cjs/script/pm-api-reference.js.map +1 -1
  234. package/dist-cjs/script/postman/chaiCompat.js +181 -0
  235. package/dist-cjs/script/postman/chaiCompat.js.map +1 -0
  236. package/dist-cjs/script/postman/cookies.js +170 -0
  237. package/dist-cjs/script/postman/cookies.js.map +1 -0
  238. package/dist-cjs/script/postman/modules.js +123 -0
  239. package/dist-cjs/script/postman/modules.js.map +1 -0
  240. package/dist-cjs/script/postman/proxies.js +93 -0
  241. package/dist-cjs/script/postman/proxies.js.map +1 -0
  242. package/dist-cjs/script/postman/requestAdapter.js +227 -0
  243. package/dist-cjs/script/postman/requestAdapter.js.map +1 -0
  244. package/dist-cjs/script/postman/responseAdapter.js +83 -0
  245. package/dist-cjs/script/postman/responseAdapter.js.map +1 -0
  246. package/dist-cjs/script/postman/runtime.js +132 -0
  247. package/dist-cjs/script/postman/runtime.js.map +1 -0
  248. package/dist-cjs/script/scope.js +47 -5
  249. package/dist-cjs/script/scope.js.map +1 -1
  250. package/dist-cjs/script/worker-entry.js +9 -0
  251. package/dist-cjs/script/worker-entry.js.map +1 -1
  252. package/dist-cjs/script/worker-pool.js +23 -2
  253. package/dist-cjs/script/worker-pool.js.map +1 -1
  254. package/dist-cjs/templating/generator-metadata.js +15 -1
  255. package/dist-cjs/templating/generator-metadata.js.map +1 -1
  256. package/dist-cjs/templating/postman-dynamic-catalog.js +129 -0
  257. package/dist-cjs/templating/postman-dynamic-catalog.js.map +1 -0
  258. package/dist-cjs/templating/postman-generators.js +13 -3
  259. package/dist-cjs/templating/postman-generators.js.map +1 -1
  260. package/dist-cjs/variables/envStore.js +5 -0
  261. package/dist-cjs/variables/envStore.js.map +1 -1
  262. package/dist-cjs/variables/replaceIn.js +111 -0
  263. package/dist-cjs/variables/replaceIn.js.map +1 -0
  264. package/dist-cjs/variables/resolver.js +16 -2
  265. package/dist-cjs/variables/resolver.js.map +1 -1
  266. package/package.json +12 -2
@@ -2,48 +2,102 @@
2
2
  // Canonical, machine-readable description of the `pm.*` scripting surface.
3
3
  // Same philosophy as templating/generator-metadata.ts: ONE runtime data
4
4
  // structure, colocated with the implementation, consumed by every surface
5
- // that needs to know "what exists" — today the AI knowledge-pack generator
6
- // (scripts/generate-ai-packs.mjs), tomorrow the desktop autocomplete.
5
+ // that needs to know "what exists" — the AI knowledge-pack generator
6
+ // (scripts/generate-ai-packs.mjs), the backend AI script prompt, the MCP docs
7
+ // and the desktop `/help` catalog.
7
8
  //
8
- // When a feature module gains/loses a method, update THIS file in the same
9
- // commit. The CI drift check regenerates ai-packs/ and fails on a diff, so
10
- // the metadata cannot silently fall behind the docs the AI sees.
9
+ // The TypeScript declarations editors use live in pm-api-declarations.ts; this
10
+ // file is the DOCUMENTATION half (descriptions, examples, stage notes).
11
+ // scripts/check-pm-api-drift.mjs fails CI when a documented `pm.x.y` is not a
12
+ // member of the declared (and therefore real) API, and `npm run ai:packs:check`
13
+ // fails when the generated packs fall behind this file.
14
+ //
15
+ // When a feature module gains/loses a method, update THIS file and
16
+ // pm-api-declarations.ts in the same commit.
11
17
  Object.defineProperty(exports, "__esModule", { value: true });
12
18
  exports.PM_API_METADATA = void 0;
19
+ const RESPONSE_STAGES = ["post-response", "tests"];
20
+ const REQUEST_STAGES = ["pre-request", "post-response", "tests"];
13
21
  exports.PM_API_METADATA = [
22
+ {
23
+ name: "pm",
24
+ description: "The script API. `cm` and `callman` are the SAME object as `pm` — a script can use `cm.` exactly like `pm.` (cm === pm), so Postman scripts run unchanged and Callman-branded scripts behave identically.",
25
+ members: [
26
+ {
27
+ signature: "cm.environment.set(key, value)",
28
+ description: "`cm.x` and `callman.x` are aliases of `pm.x` for every member below.",
29
+ example: 'cm.test("ok", () => cm.expect(1).to.equal(1))',
30
+ },
31
+ ],
32
+ },
14
33
  {
15
34
  name: "pm.test",
16
- description: "Register a named test. The callback's assertion failures mark the test failed without aborting the script.",
35
+ description: "Register a named test. The callback runs synchronously; a failing assertion (or a throw) marks the test failed without aborting the script. Works in pre-request, post-response and tests scripts.",
17
36
  members: [
18
37
  {
19
38
  signature: "pm.test(name, fn)",
20
- description: "Runs fn (sync or async); pass/fail lands in the run's test results.",
39
+ description: "Runs fn immediately; pass/fail lands in the run's test results. An async fn / returned Promise is awaited before the script is reported.",
40
+ example: 'pm.test("sum is 4", () => pm.expect(2 + 2).to.equal(4))',
41
+ },
42
+ {
43
+ signature: "pm.test(name, done => { done(); })",
44
+ description: "Callback-style async test: the test completes when done() is called (done(error) fails it).",
45
+ example: 'pm.test("later", done => { setTimeout(done, 10); })',
46
+ },
47
+ {
48
+ signature: "pm.test.skip(name)",
49
+ description: "Record a skipped test (shown as SKIP); the callback, if any, is never run.",
50
+ example: 'pm.test.skip("not ready yet")',
51
+ },
52
+ {
53
+ signature: "pm.test.index()",
54
+ description: "Number of tests recorded so far in this script.",
55
+ example: "pm.test.index()",
21
56
  },
22
57
  ],
23
58
  },
24
59
  {
25
60
  name: "pm.expect",
26
- description: "Chai-style assertions plus Jest-style matchers.",
61
+ description: "pm.expect is chai 4.4.1 with the full BDD API (expect-style), the chai-postman helpers and a few jest-style aliases. Chain words (to, be, been, is, that, which, and, has, have, with, at, of, same, but, does, still, also) read like English; flags (not, deep, nested, own, ordered, any, all, itself) change the assertion that follows. Equality is strict: .equal / .eq use ===, so NaN does not equal NaN and 1 does not equal \"1\"; use .eql / .deep.equal for structural comparison. Failure messages are chai's own.",
27
62
  members: [
28
63
  {
29
- signature: "pm.expect(value)",
30
- description: "Assertion chain. Equality: .to.equal(x) (identity), .to.eql(x) / .to.deep.equal(x) / .toEqual(x) (deep). Existence: .to.exist, .toBeDefined(), .toBeNull(). Strings/arrays: .to.include(x) / .toContain(x), .oneOf([..]). Numbers: .toBeGreaterThan / .toBeLessThan / .to.be.above(n) / .to.be.below(n). Types: .to.be.a('string'|'number'|...). Negation: .to.not.<...> / .not.<matcher>. Properties: .to.have.property('name', value?).",
64
+ signature: "pm.expect(value, message?)",
65
+ description: "Start an assertion. Equality: .to.equal(x) (===), .to.eql(x) / .to.deep.equal(x) (deep), .toBe(x) / .toEqual(x) (jest-style). Existence/type: .to.exist, .to.be.null, .to.be.undefined, .to.be.true, .to.be.a('string'|'number'|'array'|'object'|...). Strings/arrays: .to.include(x) / .to.contain(x) / .toContain(x), .to.have.lengthOf(n), .to.be.empty, .to.match(/re/), .to.have.members([...]), .to.be.oneOf([...]). Numbers: .to.be.above(n) / .below(n) / .within(a, b) / .closeTo(n, delta) / .toBeGreaterThan(n) / .toBeLessThan(n). Objects: .to.have.property('a.b', value?) (dot paths work by default), .to.have.all.keys('a', 'b'), .to.have.jsonSchema(schema). Negation: .to.not.<assertion>.",
66
+ example: 'pm.expect(user.id).to.be.a("number")',
67
+ },
68
+ {
69
+ signature: "pm.expect.fail(message?)",
70
+ description: "Throws an AssertionError (fails the surrounding test) immediately.",
71
+ example: 'pm.expect.fail("unexpected branch")',
72
+ },
73
+ {
74
+ signature: "pm.expect(value).to.have.jsonSchema(schema, ajvOptions?)",
75
+ description: "Validate any value against a JSON Schema (ajv). Also available on the response as pm.response.to.have.jsonSchema(schema) in post-response scripts.",
76
+ example: 'pm.expect(user).to.have.jsonSchema({ type: "object", required: ["id"] })',
31
77
  },
32
- { signature: "pm.expect.fail(message?)", description: "Fails the surrounding test immediately." },
33
78
  ],
34
79
  },
35
80
  {
36
81
  name: "pm.environment",
37
- description: "Active environment variables (alias: pm.env). Writes are scoped to the run and surface as variable mutations.",
82
+ description: "Active environment variables (alias: pm.env). get() returns the value as it was set within the run (numbers and objects stay native); stored values are strings, objects/arrays are saved as JSON. Writes surface as variable mutations.",
38
83
  members: [
39
- { signature: "pm.environment.get(key)", description: "Read a variable (string or undefined)." },
40
- { signature: "pm.environment.set(key, value)", description: "Write a variable for subsequent steps." },
84
+ { signature: "pm.environment.get(key)", description: "Read a variable (undefined when missing).", example: 'pm.environment.get("baseUrl")' },
85
+ {
86
+ signature: "pm.environment.set(key, value, type?)",
87
+ description: "Write a variable for subsequent steps. type is one of string, number, boolean, json, any.",
88
+ example: 'pm.environment.set("token", token)',
89
+ },
41
90
  { signature: "pm.environment.unset(key)", description: "Remove a variable." },
42
91
  { signature: "pm.environment.has(key)", description: "true when the key exists." },
43
92
  { signature: "pm.environment.clear()", description: "Remove every variable in the scope." },
44
93
  { signature: "pm.environment.toObject()", description: "Plain { key: value } snapshot." },
45
- { signature: "pm.environment.replaceIn(template)", description: "Resolve {{tokens}} inside a string." },
94
+ {
95
+ signature: "pm.environment.replaceIn(template)",
96
+ description: "Resolve {{tokens}} against THIS scope only. Unresolved {{x}} stay as written (literal); objects and arrays are walked.",
97
+ example: 'pm.environment.replaceIn("{{baseUrl}}/users")',
98
+ },
46
99
  { signature: "pm.environment.name", description: "Active environment's name." },
100
+ { signature: "pm.environment.values", description: "The raw string values record (read-only view)." },
47
101
  ],
48
102
  },
49
103
  {
@@ -51,189 +105,328 @@ exports.PM_API_METADATA = [
51
105
  description: "Workspace-level global variables. Same surface as pm.environment.",
52
106
  members: [
53
107
  { signature: "pm.globals.get(key)", description: "Read a global." },
54
- { signature: "pm.globals.set(key, value)", description: "Write a global for the run." },
108
+ { signature: "pm.globals.set(key, value, type?)", description: "Write a global for the run." },
55
109
  { signature: "pm.globals.unset(key)", description: "Remove a global." },
56
110
  { signature: "pm.globals.has(key)", description: "true when the key exists." },
57
111
  { signature: "pm.globals.clear()", description: "Remove every global in the scope." },
58
112
  { signature: "pm.globals.toObject()", description: "Plain snapshot." },
59
- { signature: "pm.globals.replaceIn(template)", description: "Resolve {{tokens}} inside a string." },
113
+ { signature: "pm.globals.replaceIn(template)", description: "Resolve {{tokens}} against the globals; unresolved tokens stay literal." },
114
+ { signature: "pm.globals.name", description: "Scope name." },
115
+ { signature: "pm.globals.values", description: "The raw string values record (read-only view)." },
60
116
  ],
61
117
  },
62
118
  {
63
119
  name: "pm.collectionVariables",
64
- description: "Collection-scoped variables that survive across requests within one collection run iteration.",
120
+ description: "Collection-scoped variables that survive across requests within one collection run. `{{name}}` resolves them after the environment and before globals.",
65
121
  members: [
66
122
  { signature: "pm.collectionVariables.get(key)", description: "Read a collection variable." },
67
- { signature: "pm.collectionVariables.set(key, value)", description: "Write; persists across the iteration." },
123
+ { signature: "pm.collectionVariables.set(key, value, type?)", description: "Write; persists across the iteration." },
68
124
  { signature: "pm.collectionVariables.unset(key)", description: "Remove a collection variable." },
69
125
  { signature: "pm.collectionVariables.has(key)", description: "true when the key exists." },
70
126
  { signature: "pm.collectionVariables.clear()", description: "Remove all collection variables." },
71
127
  { signature: "pm.collectionVariables.toObject()", description: "Plain snapshot." },
72
- { signature: "pm.collectionVariables.replaceIn(template)", description: "Resolve {{tokens}}." },
128
+ { signature: "pm.collectionVariables.replaceIn(template)", description: "Resolve {{tokens}}; unresolved tokens stay literal." },
129
+ { signature: "pm.collectionVariables.name", description: "Scope name." },
130
+ { signature: "pm.collectionVariables.values", description: "The raw string values record (read-only view)." },
73
131
  ],
74
132
  },
75
133
  {
76
134
  name: "pm.variables",
77
- description: "Layered read across all scopes (per-iteration > environment > globals) plus template resolution.",
135
+ description: "Layered read across all scopes — local > iteration data > environment > collection > globals. `set` writes the local scope, shared by every script of the same request (collection → folder → request) and gone afterwards.",
78
136
  members: [
79
- { signature: "pm.variables.get(key)", description: "Read through the precedence chain." },
80
- { signature: "pm.variables.set(key, value)", description: "Write to the run-local layer." },
137
+ { signature: "pm.variables.get(key)", description: "Read through the precedence chain.", example: 'pm.variables.get("userId")' },
138
+ { signature: "pm.variables.set(key, value, type?)", description: "Write to the run-local layer." },
81
139
  { signature: "pm.variables.unset(key)", description: "Remove from the run-local layer." },
82
140
  { signature: "pm.variables.has(key)", description: "true when any layer has the key." },
141
+ { signature: "pm.variables.clear()", description: "Clear the run-local layer." },
83
142
  { signature: "pm.variables.toObject()", description: "Merged snapshot." },
84
- { signature: "pm.variables.replaceIn(template)", description: "Resolve {{tokens}} in a string." },
143
+ {
144
+ signature: "pm.variables.replaceIn(template)",
145
+ description: "Postman semantics: resolve {{tokens}} (and dynamic variables like {{$guid}}); an unresolved {{x}} stays as written; objects and arrays are walked.",
146
+ example: 'pm.variables.replaceIn("{{baseUrl}}/users/{{userId}}")',
147
+ },
85
148
  {
86
149
  signature: "pm.variables.resolve(template)",
87
- description: "Like replaceIn, but also resolves scenario node-output references.",
150
+ description: "Callman's older resolver: like replaceIn on a string, but an unresolved {{x}} becomes an empty string. Does NOT read scenario node outputs — use pm.node(label) for those.",
151
+ example: 'pm.variables.resolve("{{missing}}")',
88
152
  },
89
153
  ],
90
154
  },
155
+ {
156
+ name: "pm.iterationData",
157
+ description: "The data-file / dataset row of the current iteration of a data-driven run (empty outside one). Also a layer of pm.variables.",
158
+ members: [
159
+ { signature: "pm.iterationData.get(key)", description: "Read a column of the current row.", example: 'pm.iterationData.get("email")' },
160
+ { signature: "pm.iterationData.has(key)", description: "true when the row has the column." },
161
+ { signature: "pm.iterationData.toObject()", description: "The whole row as a plain object." },
162
+ { signature: "pm.iterationData.toJSON()", description: "Same as toObject(); used by JSON.stringify." },
163
+ { signature: "pm.iterationData.set(key, value)", description: "Change this run's copy of the row (not written back to the data file)." },
164
+ { signature: "pm.iterationData.unset(key)", description: "Remove a column from this run's copy of the row." },
165
+ { signature: "pm.iterationData.clear()", description: "Remove every column from this run's copy of the row." },
166
+ { signature: "pm.iterationData.replaceIn(template)", description: "Resolve {{tokens}} against the row only." },
167
+ ],
168
+ },
91
169
  {
92
170
  name: "pm.request",
93
- description: "The outgoing request. Mutations only have effect in pre-request scripts (the call has not fired yet).",
171
+ description: "The request. Its url is a postman-collection Url object that ALSO behaves like a string (url.includes('/v1'), url + '?x=1'); headers is a HeaderList (case-insensitive get/has/add/upsert/remove, bracket access headers['X-Id']). Mutations only have effect in pre-request scripts (the call has not fired yet).",
94
172
  members: [
95
- { signature: "pm.request.url", description: "Resolved URL string." },
96
- { signature: "pm.request.method", description: "HTTP method." },
97
- { signature: "pm.request.body", description: "Body snapshot (mode + content)." },
98
- { signature: "pm.request.headers", description: "HeaderList: .all() .get(name) .has(name) .add({key,value}) .upsert({key,value}) .remove(name) .idx(i)." },
99
- { signature: "pm.request.query", description: "Query params as a HeaderList." },
100
- { signature: "pm.request.getHeader(name)", description: "Read one header value." },
101
- { signature: "pm.request.setHeader(name, value)", description: "Set/replace a header.", stages: ["pre-request", "scenario-script"] },
102
- { signature: "pm.request.unsetHeader(name)", description: "Remove a header.", stages: ["pre-request", "scenario-script"] },
173
+ { signature: "pm.request.url", description: "Url object: .getHost() .getPath() .getPathWithQuery() .getQueryString() .getRaw() .protocol .host[] .port .path[] .hash .query (list of params) .variables .addQueryParams() .removeQueryParams() .update(); also usable as a string. Assign a string to replace it." },
174
+ { signature: "pm.request.url.query.get(key)", description: "Value of a query param.", example: 'pm.request.url.query.get("page")' },
175
+ { signature: "pm.request.url.query.add(param)", description: "Add a query param ({ key, value }).", stages: ["pre-request"], example: 'pm.request.url.query.add({ key: "debug", value: "1" })' },
176
+ { signature: "pm.request.method", description: "HTTP method string; assignable in pre-request." },
177
+ {
178
+ signature: "pm.request.body",
179
+ description: "RequestBody: .mode ('raw'|'urlencoded'|'formdata'|'file'|'graphql') .raw .urlencoded .formdata .graphql .isEmpty() .toString() .update({ mode, raw }).",
180
+ example: 'pm.request.body.update({ mode: "raw", raw: JSON.stringify({ a: 1 }) })',
181
+ },
182
+ {
183
+ signature: "pm.request.headers",
184
+ description: "HeaderList: .get(name) .has(name) .add({key,value}) .upsert({key,value}) .remove(name) .each(fn) .map(fn) .filter(fn) .find(fn) .count() .toObject(); bracket access reads/writes by name.",
185
+ example: 'pm.request.headers.upsert({ key: "X-Trace", value: pm.variables.replaceIn("{{$guid}}") })',
186
+ },
187
+ { signature: "pm.request.query", description: "Callman alias of pm.request.url.query (the query params list)." },
188
+ { signature: "pm.request.getHeader(name)", description: "Read one header value (case-insensitive)." },
189
+ { signature: "pm.request.setHeader(name, value)", description: "Set/replace a header.", stages: ["pre-request"] },
190
+ { signature: "pm.request.unsetHeader(name)", description: "Remove a header.", stages: ["pre-request"] },
103
191
  { signature: "pm.request.getQueryParam(name)", description: "Read one query param." },
104
- { signature: "pm.request.setQueryParam(name, value)", description: "Set/replace a query param.", stages: ["pre-request", "scenario-script"] },
105
- { signature: "pm.request.unsetQueryParam(name)", description: "Remove a query param.", stages: ["pre-request", "scenario-script"] },
106
- { signature: "pm.request.setUrl(url)", description: "Replace the URL.", stages: ["pre-request", "scenario-script"] },
107
- { signature: "pm.request.setMethod(method)", description: "Replace the method.", stages: ["pre-request", "scenario-script"] },
108
- { signature: "pm.request.setRawBody(value)", description: "Replace the raw body (string or object → JSON).", stages: ["pre-request", "scenario-script"] },
192
+ { signature: "pm.request.setQueryParam(name, value)", description: "Set/replace a query param.", stages: ["pre-request"] },
193
+ { signature: "pm.request.unsetQueryParam(name)", description: "Remove a query param.", stages: ["pre-request"] },
194
+ { signature: "pm.request.setUrl(url)", description: "Replace the URL.", stages: ["pre-request"] },
195
+ { signature: "pm.request.setMethod(method)", description: "Replace the method.", stages: ["pre-request"] },
196
+ { signature: "pm.request.setRawBody(value)", description: "Replace the body with raw text (objects are NOT auto-stringified; pass JSON.stringify(obj)).", stages: ["pre-request"] },
197
+ { signature: "pm.request.to.have.header(name)", description: "chai-postman assertions work on the request too (pm.request.to.have.header, .to.have.body, ...)." },
109
198
  ],
110
199
  },
111
200
  {
112
201
  name: "pm.response",
113
- description: "The received response. Not available in pre-request scripts.",
202
+ description: "The received response — a postman-collection Response. Not available in pre-request scripts. pm.response.code is the NUMBER (200); pm.response.status is the reason PHRASE ('OK', 'Not Found') exactly like Postman, so `pm.response.status === 200` is false.",
114
203
  members: [
115
- { signature: "pm.response.code", description: "Status code (number).", stages: ["post-response", "tests", "scenario-script"] },
116
- { signature: "pm.response.status", description: "Status code (number, alias).", stages: ["post-response", "tests", "scenario-script"] },
117
- { signature: "pm.response.statusText", description: "Status text.", stages: ["post-response", "tests", "scenario-script"] },
118
- { signature: "pm.response.json()", description: "Parsed JSON body — call once into a const (`const body = pm.response.json()`); throws on non-JSON, so guard with try/catch or pm.response.to.be.json when the content type is uncertain.", stages: ["post-response", "tests", "scenario-script"] },
119
- { signature: "pm.response.text()", description: "Raw body as string.", stages: ["post-response", "tests", "scenario-script"] },
120
- { signature: "pm.response.rawBody", description: "Raw body string.", stages: ["post-response", "tests", "scenario-script"] },
121
- { signature: "pm.response.headers", description: "Response HeaderList.", stages: ["post-response", "tests", "scenario-script"] },
122
- { signature: "pm.response.responseTime", description: "Duration in ms.", stages: ["post-response", "tests", "scenario-script"] },
123
- { signature: "pm.response.responseSize", description: "Body size in bytes.", stages: ["post-response", "tests", "scenario-script"] },
204
+ { signature: "pm.response.code", description: "Status code (number).", stages: RESPONSE_STAGES, example: "pm.expect(pm.response.code).to.equal(200)" },
205
+ { signature: "pm.response.status", description: "Status reason phrase (string), e.g. \"OK\". Use pm.response.code for the number.", stages: RESPONSE_STAGES },
206
+ { signature: "pm.response.reason()", description: "Reason phrase (method form of status).", stages: RESPONSE_STAGES },
207
+ { signature: "pm.response.statusText", description: "Callman alias of pm.response.reason().", stages: RESPONSE_STAGES },
208
+ {
209
+ signature: "pm.response.json()",
210
+ description: "Parse the body as JSON — call it once into a const. THROWS when the body is empty or not valid JSON (guard with try/catch, or assert pm.response.to.be.json first). Optional reviver as in JSON.parse.",
211
+ stages: RESPONSE_STAGES,
212
+ example: "const body = pm.response.json()",
213
+ },
214
+ { signature: "pm.response.text()", description: "Raw body as a string.", stages: RESPONSE_STAGES },
215
+ { signature: "pm.response.jsonp(callbackName?)", description: "Parse a JSONP body; throws when it is not valid.", stages: RESPONSE_STAGES },
216
+ { signature: "pm.response.rawBody", description: "Raw body string (Callman alias of text()).", stages: RESPONSE_STAGES },
217
+ { signature: "pm.response.body", description: "Callman: the parsed body (JSON value, or the text). Prefer json() / text().", stages: RESPONSE_STAGES },
218
+ { signature: "pm.response.headers", description: "Response HeaderList (read-only): .get(name) .has(name) .each(fn) .toObject(); bracket access headers['content-type'].", stages: RESPONSE_STAGES, example: 'pm.response.headers.get("Content-Type")' },
219
+ { signature: "pm.response.cookies", description: "CookieList of the response's Set-Cookie headers: .get(name) .has(name) .toObject() .each(fn).", stages: RESPONSE_STAGES },
220
+ { signature: "pm.response.responseTime", description: "Duration in ms.", stages: RESPONSE_STAGES },
221
+ { signature: "pm.response.responseSize", description: "Body size in bytes.", stages: RESPONSE_STAGES },
222
+ { signature: "pm.response.size()", description: "{ body, header, total } sizes in bytes.", stages: RESPONSE_STAGES },
223
+ { signature: "pm.response.dataURI()", description: "The body as a data: URI.", stages: RESPONSE_STAGES },
224
+ { signature: "pm.response.details()", description: "{ code, name, detail } of the status code.", stages: RESPONSE_STAGES },
225
+ { signature: "pm.response.contentInfo()", description: "{ mimeType, mimeFormat, charset, fileExtension, contentType } of the body.", stages: RESPONSE_STAGES },
226
+ { signature: "pm.response.stream", description: "Body bytes as a Buffer.", stages: RESPONSE_STAGES },
124
227
  {
125
- signature: "pm.response.to.have.status(code)",
126
- description: "Assertion shortcuts; also .to.have.header/.jsonBody/.body and .to.be.ok/.json/.success/.clientError/... plus .to.not.<predicate>.",
127
- stages: ["post-response", "tests", "scenario-script"],
228
+ signature: "pm.response.to.have.status(codeOrReason)",
229
+ description: "chai-postman assertions on the response: .to.have.status(200 | \"OK\"), .to.have.header(name, value?), .to.have.body(text?), .to.have.jsonBody(path?, value?), .to.have.jsonSchema(schema), .to.have.responseTime.below(ms), .to.be.ok / .success / .info / .redirection / .clientError / .serverError / .error / .json / .html / .xml / .withBody / .accepted / .badRequest / .unauthorized / .forbidden / .notFound / .rateLimited, plus .to.not.<predicate>.",
230
+ stages: RESPONSE_STAGES,
231
+ example: 'pm.response.to.have.status(200)',
128
232
  },
129
233
  ],
130
234
  },
131
235
  {
132
236
  name: "pm.sendRequest",
133
- description: "Fire an ad-hoc HTTP request from inside a script.",
237
+ description: "Fire an ad-hoc HTTP request from inside a script. It returns a Promise that resolves to a Response with the same API as pm.response (code, status, json(), text(), headers, cookies, responseTime, ...). The callback form (err, res) also works; hosts that keep a cookie jar send and store cookies.",
134
238
  members: [
135
239
  {
136
- signature: "pm.sendRequest(urlOrOptions, callback?)",
137
- description: "Options: { url, method, header: {name: value}, body }. Body accepts a plain object (auto-JSON) OR Postman style { mode: 'raw', raw: JSON.stringify({...}) } / { mode: 'urlencoded', urlencoded: [{key, value}] }. Prefer `const res = await pm.sendRequest({...})`; callback form gets (err, res). The response object is { code, status, statusText, headers, body, responseTime, json(), text() } — note it is NOT pm.response.",
240
+ signature: "pm.sendRequest(url)",
241
+ description: "GET a URL string. Prefer `const res = await pm.sendRequest(...)`.",
242
+ example: 'const res = await pm.sendRequest("https://api.example.com/health")',
243
+ },
244
+ {
245
+ signature: "pm.sendRequest({ url, method, header, body })",
246
+ description: "Request options. header: object, array of { key, value } or a header string. body: a string, or { mode: 'raw', raw }, { mode: 'urlencoded', urlencoded: [{key,value}] }, { mode: 'formdata', formdata: [{key,value}] } (text parts only), { mode: 'graphql', graphql: { query, variables } }. {{variables}} in all fields are resolved.",
247
+ example: 'await pm.sendRequest({ url: "https://x.test/login", method: "POST", header: { "Content-Type": "application/json" }, body: { mode: "raw", raw: JSON.stringify({ user: "a" }) } })',
248
+ },
249
+ {
250
+ signature: "pm.sendRequest(request, (err, res, history) => {})",
251
+ description: "Callback form; request may also be a postman-collection Request (new (require('postman-collection').Request)({...})).",
252
+ example: 'pm.sendRequest("https://x.test", (err, res) => { pm.environment.set("code", res.code) })',
138
253
  },
139
254
  ],
140
255
  },
256
+ {
257
+ name: "pm.cookies",
258
+ description: "Cookies of the current request's domain (a CookieList: .get(name) .has(name) .toObject() .each(fn)), plus the cookie jar of ANY domain via pm.cookies.jar().",
259
+ members: [
260
+ { signature: "pm.cookies.get(name)", description: "Value of a cookie of the request's domain.", example: 'pm.cookies.get("session")' },
261
+ { signature: "pm.cookies.has(name)", description: "true when the cookie exists." },
262
+ { signature: "pm.cookies.toObject()", description: "{ name: value } of the request's domain." },
263
+ { signature: "pm.cookies.jar()", description: "The cookie jar. Every jar method takes a callback (error, result) OR returns a Promise.", example: 'const jar = pm.cookies.jar()' },
264
+ { signature: "pm.cookies.jar().set(url, name, value)", description: "Set a cookie (or pass a { name, value, domain, path, expires, httpOnly, secure } object instead of name, value).", example: 'await pm.cookies.jar().set("https://x.test", "theme", "dark")' },
265
+ { signature: "pm.cookies.jar().get(url, name)", description: "Value of one cookie, or null.", example: 'await pm.cookies.jar().get("https://x.test", "theme")' },
266
+ { signature: "pm.cookies.jar().getAll(url)", description: "All cookies matching the url (Cookie objects).", example: 'await pm.cookies.jar().getAll("https://x.test")' },
267
+ { signature: "pm.cookies.jar().unset(url, name)", description: "Delete one cookie." },
268
+ { signature: "pm.cookies.jar().clear(url)", description: "Delete every cookie of the url's domain." },
269
+ ],
270
+ },
271
+ {
272
+ name: "pm.visualizer",
273
+ description: "Render a custom view of the response: pass a Handlebars HTML template and its data; the host shows it in the Visualize tab (the last call wins). Data must be JSON-serializable.",
274
+ members: [
275
+ {
276
+ signature: "pm.visualizer.set(template, data, options?)",
277
+ description: "template: Handlebars HTML string; data: object available as {{...}} in the template; options: Handlebars compile options.",
278
+ stages: RESPONSE_STAGES,
279
+ example: 'pm.visualizer.set("<ul>{{#each items}}<li>{{name}}</li>{{/each}}</ul>", { items: pm.response.json() })',
280
+ },
281
+ { signature: "pm.visualizer.clear()", description: "Remove the visualization set earlier in the run.", stages: RESPONSE_STAGES },
282
+ {
283
+ signature: "pm.getData(callback)",
284
+ description: "Inside a visualizer template script: receive the data passed to pm.visualizer.set as callback(error, data).",
285
+ stages: RESPONSE_STAGES,
286
+ example: "pm.getData((error, data) => { console.log(data) })",
287
+ },
288
+ ],
289
+ },
290
+ {
291
+ name: "require",
292
+ description: "require(name) and pm.require(name) load one of the built-in libraries (Postman's list). There is no filesystem or package access: `npm:`, `jsr:` and `@team/` specifiers and any other name throw \"Cannot find module\". The `node:` prefix is accepted.",
293
+ members: [
294
+ { signature: "require(name)", description: "Built-in modules: lodash, moment, chai, ajv (v6), cheerio (0.22), xml2js, uuid, csv-parse/lib/sync, postman-collection, crypto-js, tv4, atob, btoa, path, assert, buffer, util, url, querystring, string_decoder, stream, events, punycode, timers.", example: 'const moment = require("moment")' },
295
+ { signature: "pm.require(name)", description: "Same as require(name).", example: 'const _lodash = pm.require("lodash")' },
296
+ { signature: "require('uuid').v4()", description: "Random UUID v4 string.", example: 'const id = require("uuid").v4()' },
297
+ { signature: "require('csv-parse/lib/sync')(input, options?)", description: "Parse CSV text into an array of rows.", example: 'require("csv-parse/lib/sync")(csv, { columns: true })' },
298
+ { signature: "require('xml2js').parseString(xml, callback)", description: "Parse XML into a JS object (also parseStringPromise).", example: 'require("xml2js").parseString(xmlText, (err, result) => {})' },
299
+ { signature: "require('cheerio').load(html)", description: "Parse HTML and query it with jQuery-style selectors (cheerio 0.22).", example: 'const $ = require("cheerio").load(htmlText)' },
300
+ ],
301
+ },
302
+ {
303
+ name: "console",
304
+ description: "The full console API. Output appears in the run's Console and is streamed while the script runs (kept even when the script times out). Format strings %s %d %i %f %j %o %O %c are supported; objects, Errors, Maps and Sets print readably.",
305
+ members: [
306
+ { signature: "console.log(...args)", description: "Print to the console (also console.info / warn / error / debug, which set the level).", example: 'console.log("token:", pm.environment.get("token"))' },
307
+ { signature: "console.info(...args)", description: "Info level." },
308
+ { signature: "console.warn(...args)", description: "Warning level." },
309
+ { signature: "console.error(...args)", description: "Error level." },
310
+ { signature: "console.debug(...args)", description: "Debug level." },
311
+ { signature: "console.trace(...args)", description: "Log with a stack trace." },
312
+ { signature: "console.assert(condition, ...args)", description: "Log an error when the condition is falsy (never throws)." },
313
+ { signature: "console.count(label?)", description: "Count calls per label.", example: 'console.count("retry")' },
314
+ { signature: "console.countReset(label?)", description: "Reset a counter." },
315
+ { signature: "console.time(label?)", description: "Start a timer." },
316
+ { signature: "console.timeLog(label?, ...args)", description: "Log the elapsed time without stopping the timer." },
317
+ { signature: "console.timeEnd(label?)", description: "Log the elapsed time and stop the timer." },
318
+ { signature: "console.group(...label)", description: "Indent following output until console.groupEnd() (console.groupCollapsed is the same)." },
319
+ { signature: "console.groupCollapsed(...label)", description: "Like console.group()." },
320
+ { signature: "console.groupEnd()", description: "End the current group." },
321
+ { signature: "console.table(data, columns?)", description: "Print an array of objects/arrays as a table.", example: "console.table(rows)" },
322
+ { signature: "console.dir(value, options?)", description: "Print an object with Node's inspect (depth/colors options)." },
323
+ { signature: "console.dirxml(...args)", description: "Same as console.log()." },
324
+ { signature: "console.clear()", description: "Clear the console buffer of the host." },
325
+ ],
326
+ },
141
327
  {
142
328
  name: "pm.db",
143
329
  description: "Database access (Oracle / MongoDB / PostgreSQL / MySQL). Disabled by feature policy in some contexts — tests then report SKIP.",
144
330
  members: [
145
331
  {
146
332
  signature: "pm.db.query({ connectionId, query })",
147
- description: "Run an ad-hoc query — ALWAYS await it. SQL connections (Oracle/Postgres/MySQL): `query` is the SQL text. MongoDB: `query` is a JSON STRING of a command object, e.g. `JSON.stringify({ collection: 'users', operation: 'findOne', filter: { email } })` — operation is find|findOne|aggregate|countDocuments|insertOne|updateOne|deleteOne|…, the match key is `filter` (NOT a `db.coll.find(...)` shell string and NOT `query`), and aggregate uses `pipeline`. Resolves to { success, error, rowCount, rows, firstRow(), connectionId, connectionName, connectionType, durationMs, executedAt }. firstRow is a FUNCTION: res.firstRow()?.STATUS (Oracle columns are UPPERCASE); for a Mongo existence check assert rowCount > 0.",
333
+ description: "Run an ad-hoc query — ALWAYS await it. Rejects when the query fails. SQL connections (Oracle/Postgres/MySQL): `query` is the SQL text. MongoDB: `query` is a JSON STRING of a command object, e.g. `JSON.stringify({ collection: 'users', operation: 'findOne', filter: { email } })` — operation is find|findOne|aggregate|countDocuments|insertOne|updateOne|deleteOne|…, the match key is `filter` (NOT a `db.coll.find(...)` shell string and NOT `query`), and aggregate uses `pipeline`. Resolves to { success, error, rowCount, rows, firstRow(), connectionId, connectionName, connectionType, durationMs, executedAt }. firstRow is a FUNCTION: res.firstRow()?.STATUS (Oracle columns are UPPERCASE); for a Mongo existence check assert rowCount > 0.",
148
334
  requires: "database",
335
+ example: 'const res = await pm.db.query({ connectionId: "orders-db", query: "select status from orders where id = 1" })',
149
336
  },
150
337
  {
151
338
  signature: "pm.db.pre",
152
339
  description: "Result object of the declared pre-request DB query: { success, error, rowCount, rows, firstRow() }. Not a promise — read directly.",
153
340
  requires: "database",
341
+ stages: REQUEST_STAGES,
154
342
  },
155
343
  {
156
344
  signature: "pm.db.post",
157
- description: "Result object of the declared post-response DB query (same shape as pm.db.pre).",
345
+ description: "Result object of the declared post-response DB query (same shape as pm.db.pre). Populated ONLY in the `tests` script; in a post-response script it is an empty result.",
158
346
  requires: "database",
159
- stages: ["post-response", "tests"],
347
+ stages: ["tests"],
160
348
  },
161
349
  ],
162
350
  },
163
- {
164
- name: "pm.kafka",
165
- description: "Captured Kafka events from the request's Kafka tab listener.",
166
- members: [
167
- { signature: "pm.kafka.event()", description: "The matched event's parsed payload (or null).", requires: "kafka", stages: ["post-response", "tests"] },
168
- { signature: "pm.kafka.messages()", description: "Every captured message in the listen window.", requires: "kafka", stages: ["post-response", "tests"] },
169
- ],
170
- },
171
351
  {
172
352
  name: "pm.redis",
173
353
  description: "Run ad-hoc Redis commands and read results of declared pre/post commands.",
174
354
  members: [
175
355
  {
176
356
  signature: "pm.redis.command({ connectionId, command })",
177
- description: "Run an ad-hoc Redis command (GET/SET/DEL/EXISTS/TTL) — ALWAYS await it. Resolves to { success, error, result, resultText, commandName, key, connectionId, connectionName, command, resolvedCommand, durationMs, executedAt }. Omit connectionId to use the request's configured Redis connection.",
357
+ description: "Run an ad-hoc Redis command (strings, hashes, lists, sets, sorted sets, counters, key expiry, SCAN) — ALWAYS await it. Resolves to { success, error, result, resultText, commandName, key, connectionId, connectionName, command, resolvedCommand, durationMs, executedAt }. Omit connectionId to use the request's configured Redis connection.",
178
358
  requires: "redis",
359
+ example: 'const res = await pm.redis.command({ command: "GET session:1" })',
179
360
  },
180
361
  { signature: "pm.redis.get(key)", description: "Read a value already captured by a declared GET.", requires: "redis" },
181
362
  { signature: "pm.redis.results.pre", description: "Array of pre-stage command results (by line index).", requires: "redis" },
182
- { signature: "pm.redis.results.post", description: "Array of post-stage command results.", requires: "redis", stages: ["post-response", "tests"] },
363
+ { signature: "pm.redis.results.post", description: "Array of post-stage command results.", requires: "redis", stages: RESPONSE_STAGES },
183
364
  ],
184
365
  },
185
366
  {
186
367
  name: "pm.random",
187
- description: "Deterministic-format random data generators.",
368
+ description: "Random data generators. EVERY generator returns a string (pm.random.int() returns \"42\", pm.random.boolean() returns \"true\"/\"false\") — wrap with Number() when you need a number.",
188
369
  members: [
189
- { signature: "pm.random.uuid()", description: "UUID v4." },
190
- { signature: "pm.random.email()", description: "Random email address." },
191
- { signature: "pm.random.string(length?)", description: "Alphanumeric string." },
192
- { signature: "pm.random.int(min, max)", description: "Integer in range." },
193
- { signature: "pm.random.bigdecimal(min, max, scale)", description: "Decimal with given scale." },
194
- { signature: "pm.random.boolean()", description: "true/false." },
370
+ { signature: "pm.random.uuid()", description: "UUID v4 string.", example: "pm.random.uuid()" },
371
+ { signature: "pm.random.email()", description: "Random email address string." },
372
+ { signature: "pm.random.string(length?)", description: "Alphanumeric string (default 12, max 128)." },
373
+ { signature: "pm.random.int(min?, max?)", description: "Integer in range, as a STRING (default 0..999999).", example: "Number(pm.random.int(1, 100))" },
374
+ { signature: "pm.random.bigdecimal(min?, max?, scale?)", description: "Decimal string with `scale` fraction digits (default 6)." },
375
+ { signature: "pm.random.boolean()", description: "The string \"true\" or \"false\"." },
195
376
  { signature: "pm.random.phone()", description: "Phone number string." },
196
- { signature: "pm.random.name()", description: "Person name." },
197
- { signature: "pm.random.date(format?)", description: "Date string." },
377
+ { signature: "pm.random.name()", description: "Person name string." },
378
+ { signature: "pm.random.date(format?)", description: "Date string within ±1 year (default format YYYY-MM-DD; tokens YYYY MM DD HH mm ss SSS Z)." },
198
379
  ],
199
380
  },
200
381
  {
201
382
  name: "pm.counter",
202
- description: "Monotonic counter scoped to the run.",
383
+ description: "Counter that survives across the requests of a run.",
203
384
  members: [
204
- { signature: "pm.counter.next()", description: "Next value (starts at 1)." },
205
- { signature: "pm.counter.start(startAt?)", description: "Counter starting at a custom value." },
385
+ { signature: "pm.counter.next()", description: "Next value (number, starts at 1)." },
386
+ { signature: "pm.counter.start(startAt?)", description: "Counter starting at a custom value (number, default 1); each call increments." },
206
387
  ],
207
388
  },
208
389
  {
209
390
  name: "pm.info",
210
- description: "Execution metadata snapshot.",
391
+ description: "Execution metadata snapshot (read-only).",
211
392
  members: [
212
- { signature: "pm.info.eventName", description: "\"prerequest\" | \"test\"." },
213
- { signature: "pm.info.iteration", description: "Zero-based data-driven iteration index." },
214
- {
215
- signature: "pm.info.iterationCount",
216
- description: "Total iterations — only meaningful in collection/data-driven runs. Never use it to gate token/cache logic in single sends.",
217
- },
393
+ { signature: "pm.info.eventName", description: "\"prerequest\" in pre-request scripts, \"test\" in post-response / tests scripts, \"scenario-script\" in scenario script nodes." },
394
+ { signature: "pm.info.iteration", description: "0-BASED index of the current iteration of a data-driven run (0 outside one, like Postman)." },
395
+ { signature: "pm.info.iterationCount", description: "Total iterations of the run (1 outside a data-driven run). Never use it to gate token/cache logic in single sends." },
218
396
  { signature: "pm.info.requestName", description: "Current request's name." },
219
397
  { signature: "pm.info.requestId", description: "Current request's id." },
220
398
  ],
221
399
  },
222
400
  {
223
401
  name: "pm.execution",
224
- description: "Collection-run flow control.",
402
+ description: "Collection-run flow control (Postman's pm.execution). Honoured by the collection runner; a single Send ignores it.",
225
403
  members: [
226
- { signature: "pm.execution.setNextRequest(name)", description: "Jump to a named request next (collection runs)." },
227
- { signature: "pm.execution.skipRequest()", description: "Skip the current request.", stages: ["pre-request"] },
228
- { signature: "pm.execution.location", description: "Folder path of the current request." },
404
+ {
405
+ signature: "pm.execution.setNextRequest(nameOrId)",
406
+ description: "Run the request with this name or id next; pass null to stop the run after the current request. Postman's postman.setNextRequest is the same.",
407
+ example: 'pm.execution.setNextRequest("Get order")',
408
+ },
409
+ {
410
+ signature: "pm.execution.skipRequest()",
411
+ description: "Skip the current request: it is not sent and its post-response/tests scripts do not run (counted as skipped).",
412
+ stages: ["pre-request"],
413
+ },
414
+ { signature: "pm.execution.location", description: "Folder path of the current request as an array of names; pm.execution.location.current is the request's own name.", example: "pm.execution.location.current" },
415
+ { signature: "pm.execution.runRequest(requestIdOrName)", description: "Not supported in Callman yet — always throws a clear error." },
229
416
  ],
230
417
  },
231
418
  {
232
419
  name: "pm.node",
233
- description: "Scenario workflow context (only meaningful inside scenario script nodes).",
420
+ description: "Scenario workflow context (scenario script and request nodes only). pm.node is a FUNCTION — pm.node(label) — not an object. The same data is also available as a global named after the node label when the label is a valid identifier (Login.token).",
234
421
  members: [
235
- { signature: "pm.node.nodeLabel", description: "Current node's label.", stages: ["scenario-script"] },
236
- { signature: "pm.node.setNextRequest(name)", description: "Route the workflow to a named node.", stages: ["scenario-script"] },
422
+ {
423
+ signature: "pm.node(label)",
424
+ description: "Output of a previous node by label (null when it has not run). The value carries __meta { status, success, failed, skipped, attempts, startedAt, endedAt, durationMs, error }.",
425
+ stages: ["scenario-script"],
426
+ example: 'const token = pm.node("Login").token',
427
+ },
428
+ { signature: "workflow.__meta", description: "Run-level metadata: status, totalNodes, successfulNodes, failedNodes, skippedNodes, totalRetries, durationMs, currentNode, lastNode, failedNode.", stages: ["scenario-script"] },
429
+ { signature: "env.NAME", description: "The active environment's variables as a plain object (also available in request scripts).", example: "env.BASE_URL" },
237
430
  ],
238
431
  },
239
432
  {
@@ -243,30 +436,67 @@ exports.PM_API_METADATA = [
243
436
  },
244
437
  {
245
438
  name: "CryptoJS",
246
- description: "crypto-js global (NOT under pm.*).",
439
+ description: "crypto-js global (NOT under pm.*; also require('crypto-js')). Results are WordArrays: call .toString() for hex or .toString(CryptoJS.enc.Base64).",
247
440
  members: [
248
- { signature: "CryptoJS.SHA256(msg) / SHA1 / SHA512 / MD5", description: "Hashes; .toString() or .toString(CryptoJS.enc.Hex)." },
249
- { signature: "CryptoJS.HmacSHA256(msg, key)", description: "HMAC family (SHA1/224/384/512, MD5 variants)." },
250
- { signature: "CryptoJS.AES.encrypt(msg, key) / .decrypt(cipher, key)", description: "AES; decrypt result needs .toString(CryptoJS.enc.Utf8)." },
251
- { signature: "CryptoJS.PBKDF2(password, salt, options)", description: "Key derivation." },
252
- { signature: "CryptoJS.enc.Utf8 / Base64 / Hex / Latin1", description: "Encoders for .toString(...)." },
253
- { signature: "CryptoJS.lib.WordArray.create / random(n)", description: "Raw word arrays (e.g. random IVs)." },
441
+ { signature: "CryptoJS.SHA256(message)", description: "Hash (also SHA1, SHA224, SHA384, SHA512, SHA3, MD5, RIPEMD160); .toString() is hex.", example: "CryptoJS.SHA256(body).toString()" },
442
+ { signature: "CryptoJS.HmacSHA256(message, key)", description: "HMAC (also HmacSHA1/224/384/512, HmacMD5).", example: "CryptoJS.HmacSHA256(msg, secret).toString(CryptoJS.enc.Hex)" },
443
+ { signature: "CryptoJS.AES.encrypt(message, key)", description: "AES encryption; CryptoJS.AES.decrypt(cipher, key) returns a WordArray — call .toString(CryptoJS.enc.Utf8).", example: "CryptoJS.AES.encrypt(text, key).toString()" },
444
+ { signature: "CryptoJS.PBKDF2(password, salt, options)", description: "Key derivation ({ keySize, iterations })." },
445
+ { signature: "CryptoJS.enc.Base64", description: "Encoders for .toString(...) / .parse(...): Utf8, Base64, Base64url, Hex, Latin1, Utf16.", example: "CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(text))" },
446
+ { signature: "CryptoJS.lib.WordArray.random(nBytes)", description: "Raw random word array (e.g. IVs); WordArray.create(words, sigBytes) builds one." },
254
447
  ],
255
448
  },
256
449
  {
257
450
  name: "_",
258
- description: "lodash global (NOT under pm.*).",
451
+ description: "lodash global (NOT under pm.*; also require('lodash')).",
259
452
  members: [
260
- { signature: "_.get(obj, path, default?) / _.pick / _.groupBy / _.sortBy / _.uniq / ...", description: "Full lodash surface for data wrangling." },
453
+ { signature: "_.get(object, path, defaultValue?)", description: "Safe nested read; the full lodash surface (pick, omit, groupBy, sortBy, uniq, merge, cloneDeep, isEqual, chunk, ...) is available.", example: '_.get(payload, "data.items[0].id")' },
454
+ { signature: "_.groupBy(collection, iteratee)", description: "Group items by a key or function.", example: '_.groupBy(items, "status")' },
261
455
  ],
262
456
  },
263
457
  {
264
458
  name: "timers",
265
- description: "Safe per-execution timer wrappers (callbacks never outlive the run).",
459
+ description: "Safe per-run timer wrappers (callbacks never outlive the run; delays are capped at 60 s). They return numeric ids.",
266
460
  members: [
267
- { signature: "setTimeout(fn, ms) / clearTimeout(id)", description: "Use with await new Promise(r => setTimeout(r, ms)) for polling loops." },
268
- { signature: "setInterval(fn, ms) / clearInterval(id)", description: "Interval variant." },
461
+ { signature: "setTimeout(handler, delayMs)", description: "Run later; use with await new Promise(r => setTimeout(r, ms)) for polling loops. clearTimeout(id) cancels.", example: "await new Promise(r => setTimeout(r, 500))" },
462
+ { signature: "clearTimeout(id)", description: "Cancel a setTimeout." },
463
+ { signature: "setInterval(handler, delayMs)", description: "Repeat; clearInterval(id) cancels." },
464
+ { signature: "clearInterval(id)", description: "Cancel a setInterval." },
465
+ { signature: "setImmediate(handler)", description: "Run on the next turn (clearImmediate(id) cancels)." },
269
466
  ],
270
467
  },
468
+ {
469
+ name: "globals",
470
+ description: "Other globals available in every script (no import): Buffer, Intl, Reflect, Proxy, WeakRef, URL, URLSearchParams, TextEncoder/TextDecoder, atob/btoa, structuredClone, queueMicrotask, AbortController, Blob, crypto (Web Crypto), encodeURI/decodeURI, escape/unescape and the usual JSON/Math/Date/Promise/Map/Set/typed arrays. fetch, XMLHttpRequest, WebSocket, process, window, eval and Function are blocked — use pm.sendRequest for HTTP.",
471
+ members: [
472
+ { signature: "Buffer.from(data, encoding?)", description: "Node Buffer (utf8, hex, base64, base64url, latin1, ...).", example: 'Buffer.from("hello").toString("base64")' },
473
+ { signature: "crypto.randomUUID()", description: "Web Crypto: also crypto.getRandomValues(typedArray) and crypto.subtle.digest/sign/verify/encrypt/decrypt.", example: "crypto.randomUUID()" },
474
+ { signature: "structuredClone(value)", description: "Deep clone (Date, Map, Set, RegExp, ...)." },
475
+ { signature: "atob(base64)", description: "Decode base64 to a binary string (btoa(text) encodes)." },
476
+ ],
477
+ },
478
+ {
479
+ name: "postman",
480
+ description: "Postman's LEGACY scripting API, kept so old exported collections run unchanged. Enabled in request scripts unless the script starts with \"use sandbox2\"; prefer pm.* in new scripts.",
481
+ members: [
482
+ { signature: "postman.setEnvironmentVariable(key, value)", description: "Same as pm.environment.set (also getEnvironmentVariable, clearEnvironmentVariable, clearEnvironmentVariables).", example: 'postman.setEnvironmentVariable("token", "abc")' },
483
+ { signature: "postman.setGlobalVariable(key, value)", description: "Same as pm.globals.set (also getGlobalVariable, clearGlobalVariable, clearGlobalVariables)." },
484
+ { signature: "postman.setNextRequest(name)", description: "Same as pm.execution.setNextRequest." },
485
+ { signature: "postman.getResponseHeader(name)", description: "Header value of the response.", stages: RESPONSE_STAGES },
486
+ { signature: "postman.getResponseCookie(name)", description: "Cookie of the response.", stages: RESPONSE_STAGES },
487
+ { signature: "tests['name'] = boolean", description: "Legacy test: records a test named `name` that passes when the value is truthy.", example: 'tests["status is 200"] = responseCode.code === 200' },
488
+ { signature: "responseBody", description: "Legacy: raw response body text.", stages: RESPONSE_STAGES },
489
+ { signature: "responseCode.code", description: "Legacy: { code, name, detail } of the status.", stages: RESPONSE_STAGES },
490
+ { signature: "responseTime", description: "Legacy: response time in ms.", stages: RESPONSE_STAGES },
491
+ { signature: "responseHeaders", description: "Legacy: response headers as a plain object.", stages: RESPONSE_STAGES },
492
+ { signature: "responseCookies", description: "Legacy: response cookies as { name: value }.", stages: RESPONSE_STAGES },
493
+ { signature: "environment['name']", description: "Legacy: `environment` and `globals` also read variables by bracket (environment['token']); environment.get('token') keeps working. `data` is the iteration row, `iteration` the 0-based index; tv4, cheerio and xml2Json(xml) are globals." },
494
+ ],
495
+ },
496
+ {
497
+ name: "unsupported",
498
+ description: "Postman APIs Callman does not implement. Accessing them throws a clear \"is not supported in Callman yet\" error (never `undefined`), so a copied script fails loudly instead of misbehaving: pm.vault, pm.datasets, pm.mock, pm.state, pm.message, pm.execution.runRequest, and pm.require('npm:...' / 'jsr:...' / '@team/...') package specifiers. Postman Flows, Postbot, gRPC/WebSocket/MQTT hooks are out of scope.",
499
+ members: [],
500
+ },
271
501
  ];
272
502
  //# sourceMappingURL=pm-api-metadata.js.map