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
@@ -1,46 +1,100 @@
1
1
  // Canonical, machine-readable description of the `pm.*` scripting surface.
2
2
  // Same philosophy as templating/generator-metadata.ts: ONE runtime data
3
3
  // structure, colocated with the implementation, consumed by every surface
4
- // that needs to know "what exists" — today the AI knowledge-pack generator
5
- // (scripts/generate-ai-packs.mjs), tomorrow the desktop autocomplete.
4
+ // that needs to know "what exists" — the AI knowledge-pack generator
5
+ // (scripts/generate-ai-packs.mjs), the backend AI script prompt, the MCP docs
6
+ // and the desktop `/help` catalog.
6
7
  //
7
- // When a feature module gains/loses a method, update THIS file in the same
8
- // commit. The CI drift check regenerates ai-packs/ and fails on a diff, so
9
- // the metadata cannot silently fall behind the docs the AI sees.
8
+ // The TypeScript declarations editors use live in pm-api-declarations.ts; this
9
+ // file is the DOCUMENTATION half (descriptions, examples, stage notes).
10
+ // scripts/check-pm-api-drift.mjs fails CI when a documented `pm.x.y` is not a
11
+ // member of the declared (and therefore real) API, and `npm run ai:packs:check`
12
+ // fails when the generated packs fall behind this file.
13
+ //
14
+ // When a feature module gains/loses a method, update THIS file and
15
+ // pm-api-declarations.ts in the same commit.
16
+ const RESPONSE_STAGES = ["post-response", "tests"];
17
+ const REQUEST_STAGES = ["pre-request", "post-response", "tests"];
10
18
  export const PM_API_METADATA = [
19
+ {
20
+ name: "pm",
21
+ 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.",
22
+ members: [
23
+ {
24
+ signature: "cm.environment.set(key, value)",
25
+ description: "`cm.x` and `callman.x` are aliases of `pm.x` for every member below.",
26
+ example: 'cm.test("ok", () => cm.expect(1).to.equal(1))',
27
+ },
28
+ ],
29
+ },
11
30
  {
12
31
  name: "pm.test",
13
- description: "Register a named test. The callback's assertion failures mark the test failed without aborting the script.",
32
+ 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.",
14
33
  members: [
15
34
  {
16
35
  signature: "pm.test(name, fn)",
17
- description: "Runs fn (sync or async); pass/fail lands in the run's test results.",
36
+ 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.",
37
+ example: 'pm.test("sum is 4", () => pm.expect(2 + 2).to.equal(4))',
38
+ },
39
+ {
40
+ signature: "pm.test(name, done => { done(); })",
41
+ description: "Callback-style async test: the test completes when done() is called (done(error) fails it).",
42
+ example: 'pm.test("later", done => { setTimeout(done, 10); })',
43
+ },
44
+ {
45
+ signature: "pm.test.skip(name)",
46
+ description: "Record a skipped test (shown as SKIP); the callback, if any, is never run.",
47
+ example: 'pm.test.skip("not ready yet")',
48
+ },
49
+ {
50
+ signature: "pm.test.index()",
51
+ description: "Number of tests recorded so far in this script.",
52
+ example: "pm.test.index()",
18
53
  },
19
54
  ],
20
55
  },
21
56
  {
22
57
  name: "pm.expect",
23
- description: "Chai-style assertions plus Jest-style matchers.",
58
+ 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.",
24
59
  members: [
25
60
  {
26
- signature: "pm.expect(value)",
27
- 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?).",
61
+ signature: "pm.expect(value, message?)",
62
+ 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>.",
63
+ example: 'pm.expect(user.id).to.be.a("number")',
64
+ },
65
+ {
66
+ signature: "pm.expect.fail(message?)",
67
+ description: "Throws an AssertionError (fails the surrounding test) immediately.",
68
+ example: 'pm.expect.fail("unexpected branch")',
69
+ },
70
+ {
71
+ signature: "pm.expect(value).to.have.jsonSchema(schema, ajvOptions?)",
72
+ 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.",
73
+ example: 'pm.expect(user).to.have.jsonSchema({ type: "object", required: ["id"] })',
28
74
  },
29
- { signature: "pm.expect.fail(message?)", description: "Fails the surrounding test immediately." },
30
75
  ],
31
76
  },
32
77
  {
33
78
  name: "pm.environment",
34
- description: "Active environment variables (alias: pm.env). Writes are scoped to the run and surface as variable mutations.",
79
+ 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.",
35
80
  members: [
36
- { signature: "pm.environment.get(key)", description: "Read a variable (string or undefined)." },
37
- { signature: "pm.environment.set(key, value)", description: "Write a variable for subsequent steps." },
81
+ { signature: "pm.environment.get(key)", description: "Read a variable (undefined when missing).", example: 'pm.environment.get("baseUrl")' },
82
+ {
83
+ signature: "pm.environment.set(key, value, type?)",
84
+ description: "Write a variable for subsequent steps. type is one of string, number, boolean, json, any.",
85
+ example: 'pm.environment.set("token", token)',
86
+ },
38
87
  { signature: "pm.environment.unset(key)", description: "Remove a variable." },
39
88
  { signature: "pm.environment.has(key)", description: "true when the key exists." },
40
89
  { signature: "pm.environment.clear()", description: "Remove every variable in the scope." },
41
90
  { signature: "pm.environment.toObject()", description: "Plain { key: value } snapshot." },
42
- { signature: "pm.environment.replaceIn(template)", description: "Resolve {{tokens}} inside a string." },
91
+ {
92
+ signature: "pm.environment.replaceIn(template)",
93
+ description: "Resolve {{tokens}} against THIS scope only. Unresolved {{x}} stay as written (literal); objects and arrays are walked.",
94
+ example: 'pm.environment.replaceIn("{{baseUrl}}/users")',
95
+ },
43
96
  { signature: "pm.environment.name", description: "Active environment's name." },
97
+ { signature: "pm.environment.values", description: "The raw string values record (read-only view)." },
44
98
  ],
45
99
  },
46
100
  {
@@ -48,189 +102,328 @@ export const PM_API_METADATA = [
48
102
  description: "Workspace-level global variables. Same surface as pm.environment.",
49
103
  members: [
50
104
  { signature: "pm.globals.get(key)", description: "Read a global." },
51
- { signature: "pm.globals.set(key, value)", description: "Write a global for the run." },
105
+ { signature: "pm.globals.set(key, value, type?)", description: "Write a global for the run." },
52
106
  { signature: "pm.globals.unset(key)", description: "Remove a global." },
53
107
  { signature: "pm.globals.has(key)", description: "true when the key exists." },
54
108
  { signature: "pm.globals.clear()", description: "Remove every global in the scope." },
55
109
  { signature: "pm.globals.toObject()", description: "Plain snapshot." },
56
- { signature: "pm.globals.replaceIn(template)", description: "Resolve {{tokens}} inside a string." },
110
+ { signature: "pm.globals.replaceIn(template)", description: "Resolve {{tokens}} against the globals; unresolved tokens stay literal." },
111
+ { signature: "pm.globals.name", description: "Scope name." },
112
+ { signature: "pm.globals.values", description: "The raw string values record (read-only view)." },
57
113
  ],
58
114
  },
59
115
  {
60
116
  name: "pm.collectionVariables",
61
- description: "Collection-scoped variables that survive across requests within one collection run iteration.",
117
+ description: "Collection-scoped variables that survive across requests within one collection run. `{{name}}` resolves them after the environment and before globals.",
62
118
  members: [
63
119
  { signature: "pm.collectionVariables.get(key)", description: "Read a collection variable." },
64
- { signature: "pm.collectionVariables.set(key, value)", description: "Write; persists across the iteration." },
120
+ { signature: "pm.collectionVariables.set(key, value, type?)", description: "Write; persists across the iteration." },
65
121
  { signature: "pm.collectionVariables.unset(key)", description: "Remove a collection variable." },
66
122
  { signature: "pm.collectionVariables.has(key)", description: "true when the key exists." },
67
123
  { signature: "pm.collectionVariables.clear()", description: "Remove all collection variables." },
68
124
  { signature: "pm.collectionVariables.toObject()", description: "Plain snapshot." },
69
- { signature: "pm.collectionVariables.replaceIn(template)", description: "Resolve {{tokens}}." },
125
+ { signature: "pm.collectionVariables.replaceIn(template)", description: "Resolve {{tokens}}; unresolved tokens stay literal." },
126
+ { signature: "pm.collectionVariables.name", description: "Scope name." },
127
+ { signature: "pm.collectionVariables.values", description: "The raw string values record (read-only view)." },
70
128
  ],
71
129
  },
72
130
  {
73
131
  name: "pm.variables",
74
- description: "Layered read across all scopes (per-iteration > environment > globals) plus template resolution.",
132
+ 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.",
75
133
  members: [
76
- { signature: "pm.variables.get(key)", description: "Read through the precedence chain." },
77
- { signature: "pm.variables.set(key, value)", description: "Write to the run-local layer." },
134
+ { signature: "pm.variables.get(key)", description: "Read through the precedence chain.", example: 'pm.variables.get("userId")' },
135
+ { signature: "pm.variables.set(key, value, type?)", description: "Write to the run-local layer." },
78
136
  { signature: "pm.variables.unset(key)", description: "Remove from the run-local layer." },
79
137
  { signature: "pm.variables.has(key)", description: "true when any layer has the key." },
138
+ { signature: "pm.variables.clear()", description: "Clear the run-local layer." },
80
139
  { signature: "pm.variables.toObject()", description: "Merged snapshot." },
81
- { signature: "pm.variables.replaceIn(template)", description: "Resolve {{tokens}} in a string." },
140
+ {
141
+ signature: "pm.variables.replaceIn(template)",
142
+ description: "Postman semantics: resolve {{tokens}} (and dynamic variables like {{$guid}}); an unresolved {{x}} stays as written; objects and arrays are walked.",
143
+ example: 'pm.variables.replaceIn("{{baseUrl}}/users/{{userId}}")',
144
+ },
82
145
  {
83
146
  signature: "pm.variables.resolve(template)",
84
- description: "Like replaceIn, but also resolves scenario node-output references.",
147
+ 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.",
148
+ example: 'pm.variables.resolve("{{missing}}")',
85
149
  },
86
150
  ],
87
151
  },
152
+ {
153
+ name: "pm.iterationData",
154
+ description: "The data-file / dataset row of the current iteration of a data-driven run (empty outside one). Also a layer of pm.variables.",
155
+ members: [
156
+ { signature: "pm.iterationData.get(key)", description: "Read a column of the current row.", example: 'pm.iterationData.get("email")' },
157
+ { signature: "pm.iterationData.has(key)", description: "true when the row has the column." },
158
+ { signature: "pm.iterationData.toObject()", description: "The whole row as a plain object." },
159
+ { signature: "pm.iterationData.toJSON()", description: "Same as toObject(); used by JSON.stringify." },
160
+ { signature: "pm.iterationData.set(key, value)", description: "Change this run's copy of the row (not written back to the data file)." },
161
+ { signature: "pm.iterationData.unset(key)", description: "Remove a column from this run's copy of the row." },
162
+ { signature: "pm.iterationData.clear()", description: "Remove every column from this run's copy of the row." },
163
+ { signature: "pm.iterationData.replaceIn(template)", description: "Resolve {{tokens}} against the row only." },
164
+ ],
165
+ },
88
166
  {
89
167
  name: "pm.request",
90
- description: "The outgoing request. Mutations only have effect in pre-request scripts (the call has not fired yet).",
168
+ 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).",
91
169
  members: [
92
- { signature: "pm.request.url", description: "Resolved URL string." },
93
- { signature: "pm.request.method", description: "HTTP method." },
94
- { signature: "pm.request.body", description: "Body snapshot (mode + content)." },
95
- { signature: "pm.request.headers", description: "HeaderList: .all() .get(name) .has(name) .add({key,value}) .upsert({key,value}) .remove(name) .idx(i)." },
96
- { signature: "pm.request.query", description: "Query params as a HeaderList." },
97
- { signature: "pm.request.getHeader(name)", description: "Read one header value." },
98
- { signature: "pm.request.setHeader(name, value)", description: "Set/replace a header.", stages: ["pre-request", "scenario-script"] },
99
- { signature: "pm.request.unsetHeader(name)", description: "Remove a header.", stages: ["pre-request", "scenario-script"] },
170
+ { 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." },
171
+ { signature: "pm.request.url.query.get(key)", description: "Value of a query param.", example: 'pm.request.url.query.get("page")' },
172
+ { 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" })' },
173
+ { signature: "pm.request.method", description: "HTTP method string; assignable in pre-request." },
174
+ {
175
+ signature: "pm.request.body",
176
+ description: "RequestBody: .mode ('raw'|'urlencoded'|'formdata'|'file'|'graphql') .raw .urlencoded .formdata .graphql .isEmpty() .toString() .update({ mode, raw }).",
177
+ example: 'pm.request.body.update({ mode: "raw", raw: JSON.stringify({ a: 1 }) })',
178
+ },
179
+ {
180
+ signature: "pm.request.headers",
181
+ 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.",
182
+ example: 'pm.request.headers.upsert({ key: "X-Trace", value: pm.variables.replaceIn("{{$guid}}") })',
183
+ },
184
+ { signature: "pm.request.query", description: "Callman alias of pm.request.url.query (the query params list)." },
185
+ { signature: "pm.request.getHeader(name)", description: "Read one header value (case-insensitive)." },
186
+ { signature: "pm.request.setHeader(name, value)", description: "Set/replace a header.", stages: ["pre-request"] },
187
+ { signature: "pm.request.unsetHeader(name)", description: "Remove a header.", stages: ["pre-request"] },
100
188
  { signature: "pm.request.getQueryParam(name)", description: "Read one query param." },
101
- { signature: "pm.request.setQueryParam(name, value)", description: "Set/replace a query param.", stages: ["pre-request", "scenario-script"] },
102
- { signature: "pm.request.unsetQueryParam(name)", description: "Remove a query param.", stages: ["pre-request", "scenario-script"] },
103
- { signature: "pm.request.setUrl(url)", description: "Replace the URL.", stages: ["pre-request", "scenario-script"] },
104
- { signature: "pm.request.setMethod(method)", description: "Replace the method.", stages: ["pre-request", "scenario-script"] },
105
- { signature: "pm.request.setRawBody(value)", description: "Replace the raw body (string or object → JSON).", stages: ["pre-request", "scenario-script"] },
189
+ { signature: "pm.request.setQueryParam(name, value)", description: "Set/replace a query param.", stages: ["pre-request"] },
190
+ { signature: "pm.request.unsetQueryParam(name)", description: "Remove a query param.", stages: ["pre-request"] },
191
+ { signature: "pm.request.setUrl(url)", description: "Replace the URL.", stages: ["pre-request"] },
192
+ { signature: "pm.request.setMethod(method)", description: "Replace the method.", stages: ["pre-request"] },
193
+ { signature: "pm.request.setRawBody(value)", description: "Replace the body with raw text (objects are NOT auto-stringified; pass JSON.stringify(obj)).", stages: ["pre-request"] },
194
+ { signature: "pm.request.to.have.header(name)", description: "chai-postman assertions work on the request too (pm.request.to.have.header, .to.have.body, ...)." },
106
195
  ],
107
196
  },
108
197
  {
109
198
  name: "pm.response",
110
- description: "The received response. Not available in pre-request scripts.",
199
+ 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.",
111
200
  members: [
112
- { signature: "pm.response.code", description: "Status code (number).", stages: ["post-response", "tests", "scenario-script"] },
113
- { signature: "pm.response.status", description: "Status code (number, alias).", stages: ["post-response", "tests", "scenario-script"] },
114
- { signature: "pm.response.statusText", description: "Status text.", stages: ["post-response", "tests", "scenario-script"] },
115
- { 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"] },
116
- { signature: "pm.response.text()", description: "Raw body as string.", stages: ["post-response", "tests", "scenario-script"] },
117
- { signature: "pm.response.rawBody", description: "Raw body string.", stages: ["post-response", "tests", "scenario-script"] },
118
- { signature: "pm.response.headers", description: "Response HeaderList.", stages: ["post-response", "tests", "scenario-script"] },
119
- { signature: "pm.response.responseTime", description: "Duration in ms.", stages: ["post-response", "tests", "scenario-script"] },
120
- { signature: "pm.response.responseSize", description: "Body size in bytes.", stages: ["post-response", "tests", "scenario-script"] },
201
+ { signature: "pm.response.code", description: "Status code (number).", stages: RESPONSE_STAGES, example: "pm.expect(pm.response.code).to.equal(200)" },
202
+ { signature: "pm.response.status", description: "Status reason phrase (string), e.g. \"OK\". Use pm.response.code for the number.", stages: RESPONSE_STAGES },
203
+ { signature: "pm.response.reason()", description: "Reason phrase (method form of status).", stages: RESPONSE_STAGES },
204
+ { signature: "pm.response.statusText", description: "Callman alias of pm.response.reason().", stages: RESPONSE_STAGES },
205
+ {
206
+ signature: "pm.response.json()",
207
+ 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.",
208
+ stages: RESPONSE_STAGES,
209
+ example: "const body = pm.response.json()",
210
+ },
211
+ { signature: "pm.response.text()", description: "Raw body as a string.", stages: RESPONSE_STAGES },
212
+ { signature: "pm.response.jsonp(callbackName?)", description: "Parse a JSONP body; throws when it is not valid.", stages: RESPONSE_STAGES },
213
+ { signature: "pm.response.rawBody", description: "Raw body string (Callman alias of text()).", stages: RESPONSE_STAGES },
214
+ { signature: "pm.response.body", description: "Callman: the parsed body (JSON value, or the text). Prefer json() / text().", stages: RESPONSE_STAGES },
215
+ { 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")' },
216
+ { signature: "pm.response.cookies", description: "CookieList of the response's Set-Cookie headers: .get(name) .has(name) .toObject() .each(fn).", stages: RESPONSE_STAGES },
217
+ { signature: "pm.response.responseTime", description: "Duration in ms.", stages: RESPONSE_STAGES },
218
+ { signature: "pm.response.responseSize", description: "Body size in bytes.", stages: RESPONSE_STAGES },
219
+ { signature: "pm.response.size()", description: "{ body, header, total } sizes in bytes.", stages: RESPONSE_STAGES },
220
+ { signature: "pm.response.dataURI()", description: "The body as a data: URI.", stages: RESPONSE_STAGES },
221
+ { signature: "pm.response.details()", description: "{ code, name, detail } of the status code.", stages: RESPONSE_STAGES },
222
+ { signature: "pm.response.contentInfo()", description: "{ mimeType, mimeFormat, charset, fileExtension, contentType } of the body.", stages: RESPONSE_STAGES },
223
+ { signature: "pm.response.stream", description: "Body bytes as a Buffer.", stages: RESPONSE_STAGES },
121
224
  {
122
- signature: "pm.response.to.have.status(code)",
123
- description: "Assertion shortcuts; also .to.have.header/.jsonBody/.body and .to.be.ok/.json/.success/.clientError/... plus .to.not.<predicate>.",
124
- stages: ["post-response", "tests", "scenario-script"],
225
+ signature: "pm.response.to.have.status(codeOrReason)",
226
+ 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>.",
227
+ stages: RESPONSE_STAGES,
228
+ example: 'pm.response.to.have.status(200)',
125
229
  },
126
230
  ],
127
231
  },
128
232
  {
129
233
  name: "pm.sendRequest",
130
- description: "Fire an ad-hoc HTTP request from inside a script.",
234
+ 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.",
131
235
  members: [
132
236
  {
133
- signature: "pm.sendRequest(urlOrOptions, callback?)",
134
- 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.",
237
+ signature: "pm.sendRequest(url)",
238
+ description: "GET a URL string. Prefer `const res = await pm.sendRequest(...)`.",
239
+ example: 'const res = await pm.sendRequest("https://api.example.com/health")',
240
+ },
241
+ {
242
+ signature: "pm.sendRequest({ url, method, header, body })",
243
+ 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.",
244
+ example: 'await pm.sendRequest({ url: "https://x.test/login", method: "POST", header: { "Content-Type": "application/json" }, body: { mode: "raw", raw: JSON.stringify({ user: "a" }) } })',
245
+ },
246
+ {
247
+ signature: "pm.sendRequest(request, (err, res, history) => {})",
248
+ description: "Callback form; request may also be a postman-collection Request (new (require('postman-collection').Request)({...})).",
249
+ example: 'pm.sendRequest("https://x.test", (err, res) => { pm.environment.set("code", res.code) })',
135
250
  },
136
251
  ],
137
252
  },
253
+ {
254
+ name: "pm.cookies",
255
+ 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().",
256
+ members: [
257
+ { signature: "pm.cookies.get(name)", description: "Value of a cookie of the request's domain.", example: 'pm.cookies.get("session")' },
258
+ { signature: "pm.cookies.has(name)", description: "true when the cookie exists." },
259
+ { signature: "pm.cookies.toObject()", description: "{ name: value } of the request's domain." },
260
+ { 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()' },
261
+ { 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")' },
262
+ { signature: "pm.cookies.jar().get(url, name)", description: "Value of one cookie, or null.", example: 'await pm.cookies.jar().get("https://x.test", "theme")' },
263
+ { signature: "pm.cookies.jar().getAll(url)", description: "All cookies matching the url (Cookie objects).", example: 'await pm.cookies.jar().getAll("https://x.test")' },
264
+ { signature: "pm.cookies.jar().unset(url, name)", description: "Delete one cookie." },
265
+ { signature: "pm.cookies.jar().clear(url)", description: "Delete every cookie of the url's domain." },
266
+ ],
267
+ },
268
+ {
269
+ name: "pm.visualizer",
270
+ 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.",
271
+ members: [
272
+ {
273
+ signature: "pm.visualizer.set(template, data, options?)",
274
+ description: "template: Handlebars HTML string; data: object available as {{...}} in the template; options: Handlebars compile options.",
275
+ stages: RESPONSE_STAGES,
276
+ example: 'pm.visualizer.set("<ul>{{#each items}}<li>{{name}}</li>{{/each}}</ul>", { items: pm.response.json() })',
277
+ },
278
+ { signature: "pm.visualizer.clear()", description: "Remove the visualization set earlier in the run.", stages: RESPONSE_STAGES },
279
+ {
280
+ signature: "pm.getData(callback)",
281
+ description: "Inside a visualizer template script: receive the data passed to pm.visualizer.set as callback(error, data).",
282
+ stages: RESPONSE_STAGES,
283
+ example: "pm.getData((error, data) => { console.log(data) })",
284
+ },
285
+ ],
286
+ },
287
+ {
288
+ name: "require",
289
+ 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.",
290
+ members: [
291
+ { 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")' },
292
+ { signature: "pm.require(name)", description: "Same as require(name).", example: 'const _lodash = pm.require("lodash")' },
293
+ { signature: "require('uuid').v4()", description: "Random UUID v4 string.", example: 'const id = require("uuid").v4()' },
294
+ { 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 })' },
295
+ { signature: "require('xml2js').parseString(xml, callback)", description: "Parse XML into a JS object (also parseStringPromise).", example: 'require("xml2js").parseString(xmlText, (err, result) => {})' },
296
+ { signature: "require('cheerio').load(html)", description: "Parse HTML and query it with jQuery-style selectors (cheerio 0.22).", example: 'const $ = require("cheerio").load(htmlText)' },
297
+ ],
298
+ },
299
+ {
300
+ name: "console",
301
+ 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.",
302
+ members: [
303
+ { 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"))' },
304
+ { signature: "console.info(...args)", description: "Info level." },
305
+ { signature: "console.warn(...args)", description: "Warning level." },
306
+ { signature: "console.error(...args)", description: "Error level." },
307
+ { signature: "console.debug(...args)", description: "Debug level." },
308
+ { signature: "console.trace(...args)", description: "Log with a stack trace." },
309
+ { signature: "console.assert(condition, ...args)", description: "Log an error when the condition is falsy (never throws)." },
310
+ { signature: "console.count(label?)", description: "Count calls per label.", example: 'console.count("retry")' },
311
+ { signature: "console.countReset(label?)", description: "Reset a counter." },
312
+ { signature: "console.time(label?)", description: "Start a timer." },
313
+ { signature: "console.timeLog(label?, ...args)", description: "Log the elapsed time without stopping the timer." },
314
+ { signature: "console.timeEnd(label?)", description: "Log the elapsed time and stop the timer." },
315
+ { signature: "console.group(...label)", description: "Indent following output until console.groupEnd() (console.groupCollapsed is the same)." },
316
+ { signature: "console.groupCollapsed(...label)", description: "Like console.group()." },
317
+ { signature: "console.groupEnd()", description: "End the current group." },
318
+ { signature: "console.table(data, columns?)", description: "Print an array of objects/arrays as a table.", example: "console.table(rows)" },
319
+ { signature: "console.dir(value, options?)", description: "Print an object with Node's inspect (depth/colors options)." },
320
+ { signature: "console.dirxml(...args)", description: "Same as console.log()." },
321
+ { signature: "console.clear()", description: "Clear the console buffer of the host." },
322
+ ],
323
+ },
138
324
  {
139
325
  name: "pm.db",
140
326
  description: "Database access (Oracle / MongoDB / PostgreSQL / MySQL). Disabled by feature policy in some contexts — tests then report SKIP.",
141
327
  members: [
142
328
  {
143
329
  signature: "pm.db.query({ connectionId, query })",
144
- 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.",
330
+ 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.",
145
331
  requires: "database",
332
+ example: 'const res = await pm.db.query({ connectionId: "orders-db", query: "select status from orders where id = 1" })',
146
333
  },
147
334
  {
148
335
  signature: "pm.db.pre",
149
336
  description: "Result object of the declared pre-request DB query: { success, error, rowCount, rows, firstRow() }. Not a promise — read directly.",
150
337
  requires: "database",
338
+ stages: REQUEST_STAGES,
151
339
  },
152
340
  {
153
341
  signature: "pm.db.post",
154
- description: "Result object of the declared post-response DB query (same shape as pm.db.pre).",
342
+ 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.",
155
343
  requires: "database",
156
- stages: ["post-response", "tests"],
344
+ stages: ["tests"],
157
345
  },
158
346
  ],
159
347
  },
160
- {
161
- name: "pm.kafka",
162
- description: "Captured Kafka events from the request's Kafka tab listener.",
163
- members: [
164
- { signature: "pm.kafka.event()", description: "The matched event's parsed payload (or null).", requires: "kafka", stages: ["post-response", "tests"] },
165
- { signature: "pm.kafka.messages()", description: "Every captured message in the listen window.", requires: "kafka", stages: ["post-response", "tests"] },
166
- ],
167
- },
168
348
  {
169
349
  name: "pm.redis",
170
350
  description: "Run ad-hoc Redis commands and read results of declared pre/post commands.",
171
351
  members: [
172
352
  {
173
353
  signature: "pm.redis.command({ connectionId, command })",
174
- 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.",
354
+ 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.",
175
355
  requires: "redis",
356
+ example: 'const res = await pm.redis.command({ command: "GET session:1" })',
176
357
  },
177
358
  { signature: "pm.redis.get(key)", description: "Read a value already captured by a declared GET.", requires: "redis" },
178
359
  { signature: "pm.redis.results.pre", description: "Array of pre-stage command results (by line index).", requires: "redis" },
179
- { signature: "pm.redis.results.post", description: "Array of post-stage command results.", requires: "redis", stages: ["post-response", "tests"] },
360
+ { signature: "pm.redis.results.post", description: "Array of post-stage command results.", requires: "redis", stages: RESPONSE_STAGES },
180
361
  ],
181
362
  },
182
363
  {
183
364
  name: "pm.random",
184
- description: "Deterministic-format random data generators.",
365
+ 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.",
185
366
  members: [
186
- { signature: "pm.random.uuid()", description: "UUID v4." },
187
- { signature: "pm.random.email()", description: "Random email address." },
188
- { signature: "pm.random.string(length?)", description: "Alphanumeric string." },
189
- { signature: "pm.random.int(min, max)", description: "Integer in range." },
190
- { signature: "pm.random.bigdecimal(min, max, scale)", description: "Decimal with given scale." },
191
- { signature: "pm.random.boolean()", description: "true/false." },
367
+ { signature: "pm.random.uuid()", description: "UUID v4 string.", example: "pm.random.uuid()" },
368
+ { signature: "pm.random.email()", description: "Random email address string." },
369
+ { signature: "pm.random.string(length?)", description: "Alphanumeric string (default 12, max 128)." },
370
+ { signature: "pm.random.int(min?, max?)", description: "Integer in range, as a STRING (default 0..999999).", example: "Number(pm.random.int(1, 100))" },
371
+ { signature: "pm.random.bigdecimal(min?, max?, scale?)", description: "Decimal string with `scale` fraction digits (default 6)." },
372
+ { signature: "pm.random.boolean()", description: "The string \"true\" or \"false\"." },
192
373
  { signature: "pm.random.phone()", description: "Phone number string." },
193
- { signature: "pm.random.name()", description: "Person name." },
194
- { signature: "pm.random.date(format?)", description: "Date string." },
374
+ { signature: "pm.random.name()", description: "Person name string." },
375
+ { 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)." },
195
376
  ],
196
377
  },
197
378
  {
198
379
  name: "pm.counter",
199
- description: "Monotonic counter scoped to the run.",
380
+ description: "Counter that survives across the requests of a run.",
200
381
  members: [
201
- { signature: "pm.counter.next()", description: "Next value (starts at 1)." },
202
- { signature: "pm.counter.start(startAt?)", description: "Counter starting at a custom value." },
382
+ { signature: "pm.counter.next()", description: "Next value (number, starts at 1)." },
383
+ { signature: "pm.counter.start(startAt?)", description: "Counter starting at a custom value (number, default 1); each call increments." },
203
384
  ],
204
385
  },
205
386
  {
206
387
  name: "pm.info",
207
- description: "Execution metadata snapshot.",
388
+ description: "Execution metadata snapshot (read-only).",
208
389
  members: [
209
- { signature: "pm.info.eventName", description: "\"prerequest\" | \"test\"." },
210
- { signature: "pm.info.iteration", description: "Zero-based data-driven iteration index." },
211
- {
212
- signature: "pm.info.iterationCount",
213
- description: "Total iterations — only meaningful in collection/data-driven runs. Never use it to gate token/cache logic in single sends.",
214
- },
390
+ { signature: "pm.info.eventName", description: "\"prerequest\" in pre-request scripts, \"test\" in post-response / tests scripts, \"scenario-script\" in scenario script nodes." },
391
+ { signature: "pm.info.iteration", description: "0-BASED index of the current iteration of a data-driven run (0 outside one, like Postman)." },
392
+ { 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." },
215
393
  { signature: "pm.info.requestName", description: "Current request's name." },
216
394
  { signature: "pm.info.requestId", description: "Current request's id." },
217
395
  ],
218
396
  },
219
397
  {
220
398
  name: "pm.execution",
221
- description: "Collection-run flow control.",
399
+ description: "Collection-run flow control (Postman's pm.execution). Honoured by the collection runner; a single Send ignores it.",
222
400
  members: [
223
- { signature: "pm.execution.setNextRequest(name)", description: "Jump to a named request next (collection runs)." },
224
- { signature: "pm.execution.skipRequest()", description: "Skip the current request.", stages: ["pre-request"] },
225
- { signature: "pm.execution.location", description: "Folder path of the current request." },
401
+ {
402
+ signature: "pm.execution.setNextRequest(nameOrId)",
403
+ 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.",
404
+ example: 'pm.execution.setNextRequest("Get order")',
405
+ },
406
+ {
407
+ signature: "pm.execution.skipRequest()",
408
+ description: "Skip the current request: it is not sent and its post-response/tests scripts do not run (counted as skipped).",
409
+ stages: ["pre-request"],
410
+ },
411
+ { 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" },
412
+ { signature: "pm.execution.runRequest(requestIdOrName)", description: "Not supported in Callman yet — always throws a clear error." },
226
413
  ],
227
414
  },
228
415
  {
229
416
  name: "pm.node",
230
- description: "Scenario workflow context (only meaningful inside scenario script nodes).",
417
+ 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).",
231
418
  members: [
232
- { signature: "pm.node.nodeLabel", description: "Current node's label.", stages: ["scenario-script"] },
233
- { signature: "pm.node.setNextRequest(name)", description: "Route the workflow to a named node.", stages: ["scenario-script"] },
419
+ {
420
+ signature: "pm.node(label)",
421
+ 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 }.",
422
+ stages: ["scenario-script"],
423
+ example: 'const token = pm.node("Login").token',
424
+ },
425
+ { signature: "workflow.__meta", description: "Run-level metadata: status, totalNodes, successfulNodes, failedNodes, skippedNodes, totalRetries, durationMs, currentNode, lastNode, failedNode.", stages: ["scenario-script"] },
426
+ { signature: "env.NAME", description: "The active environment's variables as a plain object (also available in request scripts).", example: "env.BASE_URL" },
234
427
  ],
235
428
  },
236
429
  {
@@ -240,30 +433,67 @@ export const PM_API_METADATA = [
240
433
  },
241
434
  {
242
435
  name: "CryptoJS",
243
- description: "crypto-js global (NOT under pm.*).",
436
+ description: "crypto-js global (NOT under pm.*; also require('crypto-js')). Results are WordArrays: call .toString() for hex or .toString(CryptoJS.enc.Base64).",
244
437
  members: [
245
- { signature: "CryptoJS.SHA256(msg) / SHA1 / SHA512 / MD5", description: "Hashes; .toString() or .toString(CryptoJS.enc.Hex)." },
246
- { signature: "CryptoJS.HmacSHA256(msg, key)", description: "HMAC family (SHA1/224/384/512, MD5 variants)." },
247
- { signature: "CryptoJS.AES.encrypt(msg, key) / .decrypt(cipher, key)", description: "AES; decrypt result needs .toString(CryptoJS.enc.Utf8)." },
248
- { signature: "CryptoJS.PBKDF2(password, salt, options)", description: "Key derivation." },
249
- { signature: "CryptoJS.enc.Utf8 / Base64 / Hex / Latin1", description: "Encoders for .toString(...)." },
250
- { signature: "CryptoJS.lib.WordArray.create / random(n)", description: "Raw word arrays (e.g. random IVs)." },
438
+ { signature: "CryptoJS.SHA256(message)", description: "Hash (also SHA1, SHA224, SHA384, SHA512, SHA3, MD5, RIPEMD160); .toString() is hex.", example: "CryptoJS.SHA256(body).toString()" },
439
+ { signature: "CryptoJS.HmacSHA256(message, key)", description: "HMAC (also HmacSHA1/224/384/512, HmacMD5).", example: "CryptoJS.HmacSHA256(msg, secret).toString(CryptoJS.enc.Hex)" },
440
+ { 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()" },
441
+ { signature: "CryptoJS.PBKDF2(password, salt, options)", description: "Key derivation ({ keySize, iterations })." },
442
+ { 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))" },
443
+ { signature: "CryptoJS.lib.WordArray.random(nBytes)", description: "Raw random word array (e.g. IVs); WordArray.create(words, sigBytes) builds one." },
251
444
  ],
252
445
  },
253
446
  {
254
447
  name: "_",
255
- description: "lodash global (NOT under pm.*).",
448
+ description: "lodash global (NOT under pm.*; also require('lodash')).",
256
449
  members: [
257
- { signature: "_.get(obj, path, default?) / _.pick / _.groupBy / _.sortBy / _.uniq / ...", description: "Full lodash surface for data wrangling." },
450
+ { 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")' },
451
+ { signature: "_.groupBy(collection, iteratee)", description: "Group items by a key or function.", example: '_.groupBy(items, "status")' },
258
452
  ],
259
453
  },
260
454
  {
261
455
  name: "timers",
262
- description: "Safe per-execution timer wrappers (callbacks never outlive the run).",
456
+ description: "Safe per-run timer wrappers (callbacks never outlive the run; delays are capped at 60 s). They return numeric ids.",
263
457
  members: [
264
- { signature: "setTimeout(fn, ms) / clearTimeout(id)", description: "Use with await new Promise(r => setTimeout(r, ms)) for polling loops." },
265
- { signature: "setInterval(fn, ms) / clearInterval(id)", description: "Interval variant." },
458
+ { 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))" },
459
+ { signature: "clearTimeout(id)", description: "Cancel a setTimeout." },
460
+ { signature: "setInterval(handler, delayMs)", description: "Repeat; clearInterval(id) cancels." },
461
+ { signature: "clearInterval(id)", description: "Cancel a setInterval." },
462
+ { signature: "setImmediate(handler)", description: "Run on the next turn (clearImmediate(id) cancels)." },
266
463
  ],
267
464
  },
465
+ {
466
+ name: "globals",
467
+ 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.",
468
+ members: [
469
+ { signature: "Buffer.from(data, encoding?)", description: "Node Buffer (utf8, hex, base64, base64url, latin1, ...).", example: 'Buffer.from("hello").toString("base64")' },
470
+ { signature: "crypto.randomUUID()", description: "Web Crypto: also crypto.getRandomValues(typedArray) and crypto.subtle.digest/sign/verify/encrypt/decrypt.", example: "crypto.randomUUID()" },
471
+ { signature: "structuredClone(value)", description: "Deep clone (Date, Map, Set, RegExp, ...)." },
472
+ { signature: "atob(base64)", description: "Decode base64 to a binary string (btoa(text) encodes)." },
473
+ ],
474
+ },
475
+ {
476
+ name: "postman",
477
+ 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.",
478
+ members: [
479
+ { signature: "postman.setEnvironmentVariable(key, value)", description: "Same as pm.environment.set (also getEnvironmentVariable, clearEnvironmentVariable, clearEnvironmentVariables).", example: 'postman.setEnvironmentVariable("token", "abc")' },
480
+ { signature: "postman.setGlobalVariable(key, value)", description: "Same as pm.globals.set (also getGlobalVariable, clearGlobalVariable, clearGlobalVariables)." },
481
+ { signature: "postman.setNextRequest(name)", description: "Same as pm.execution.setNextRequest." },
482
+ { signature: "postman.getResponseHeader(name)", description: "Header value of the response.", stages: RESPONSE_STAGES },
483
+ { signature: "postman.getResponseCookie(name)", description: "Cookie of the response.", stages: RESPONSE_STAGES },
484
+ { 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' },
485
+ { signature: "responseBody", description: "Legacy: raw response body text.", stages: RESPONSE_STAGES },
486
+ { signature: "responseCode.code", description: "Legacy: { code, name, detail } of the status.", stages: RESPONSE_STAGES },
487
+ { signature: "responseTime", description: "Legacy: response time in ms.", stages: RESPONSE_STAGES },
488
+ { signature: "responseHeaders", description: "Legacy: response headers as a plain object.", stages: RESPONSE_STAGES },
489
+ { signature: "responseCookies", description: "Legacy: response cookies as { name: value }.", stages: RESPONSE_STAGES },
490
+ { 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." },
491
+ ],
492
+ },
493
+ {
494
+ name: "unsupported",
495
+ 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.",
496
+ members: [],
497
+ },
268
498
  ];
269
499
  //# sourceMappingURL=pm-api-metadata.js.map