callman-core 1.9.1 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai-packs/feature-policy.md +26 -0
- package/ai-packs/pm-api.md +213 -0
- package/ai-packs/sandbox-globals.md +20 -0
- package/ai-packs/templating.md +104 -0
- package/dist/host/connections.d.ts +67 -0
- package/dist/host/connections.d.ts.map +1 -0
- package/dist/host/connections.js +156 -0
- package/dist/host/connections.js.map +1 -0
- package/dist/host/db/mongoAdapter.d.ts +7 -0
- package/dist/host/db/mongoAdapter.d.ts.map +1 -0
- package/dist/host/db/mongoAdapter.js +426 -0
- package/dist/host/db/mongoAdapter.js.map +1 -0
- package/dist/host/db/mysqlAdapter.d.ts +7 -0
- package/dist/host/db/mysqlAdapter.d.ts.map +1 -0
- package/dist/host/db/mysqlAdapter.js +68 -0
- package/dist/host/db/mysqlAdapter.js.map +1 -0
- package/dist/host/db/oracleAdapter.d.ts +7 -0
- package/dist/host/db/oracleAdapter.d.ts.map +1 -0
- package/dist/host/db/oracleAdapter.js +142 -0
- package/dist/host/db/oracleAdapter.js.map +1 -0
- package/dist/host/db/oracleConnectString.d.ts +10 -0
- package/dist/host/db/oracleConnectString.d.ts.map +1 -0
- package/dist/host/db/oracleConnectString.js +58 -0
- package/dist/host/db/oracleConnectString.js.map +1 -0
- package/dist/host/db/postgresAdapter.d.ts +7 -0
- package/dist/host/db/postgresAdapter.d.ts.map +1 -0
- package/dist/host/db/postgresAdapter.js +67 -0
- package/dist/host/db/postgresAdapter.js.map +1 -0
- package/dist/host/db/queryExecutor.d.ts +3 -0
- package/dist/host/db/queryExecutor.d.ts.map +1 -0
- package/dist/host/db/queryExecutor.js +97 -0
- package/dist/host/db/queryExecutor.js.map +1 -0
- package/dist/host/db/sqlNormalize.d.ts +3 -0
- package/dist/host/db/sqlNormalize.d.ts.map +1 -0
- package/dist/host/db/sqlNormalize.js +29 -0
- package/dist/host/db/sqlNormalize.js.map +1 -0
- package/dist/host/db/templateResolver.d.ts +3 -0
- package/dist/host/db/templateResolver.d.ts.map +1 -0
- package/dist/host/db/templateResolver.js +77 -0
- package/dist/host/db/templateResolver.js.map +1 -0
- package/dist/host/db/types.d.ts +59 -0
- package/dist/host/db/types.d.ts.map +1 -0
- package/dist/host/db/types.js +6 -0
- package/dist/host/db/types.js.map +1 -0
- package/dist/host/index.d.ts +6 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +7 -0
- package/dist/host/index.js.map +1 -0
- package/dist/host/lazy.d.ts +3 -0
- package/dist/host/lazy.d.ts.map +1 -0
- package/dist/host/lazy.js +31 -0
- package/dist/host/lazy.js.map +1 -0
- package/dist/host/redis/redisService.d.ts +9 -0
- package/dist/host/redis/redisService.d.ts.map +1 -0
- package/dist/host/redis/redisService.js +264 -0
- package/dist/host/redis/redisService.js.map +1 -0
- package/dist/host/redis/types.d.ts +44 -0
- package/dist/host/redis/types.d.ts.map +1 -0
- package/dist/host/redis/types.js +4 -0
- package/dist/host/redis/types.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/runner/requestRunner.d.ts.map +1 -1
- package/dist/runner/requestRunner.js +120 -0
- package/dist/runner/requestRunner.js.map +1 -1
- package/dist/runner/runCollection.d.ts +1 -1
- package/dist/runner/runCollection.d.ts.map +1 -1
- package/dist/runner/runCollection.js +3 -1
- package/dist/runner/runCollection.js.map +1 -1
- package/dist/scenario-runner/adapters/script-executor.js +3 -3
- package/dist/scenario-runner/adapters/script-executor.js.map +1 -1
- package/dist/script/features/log.d.ts.map +1 -1
- package/dist/script/features/log.js +23 -4
- package/dist/script/features/log.js.map +1 -1
- package/dist/script/isolated-runner.d.ts +11 -0
- package/dist/script/isolated-runner.d.ts.map +1 -0
- package/dist/script/isolated-runner.js +172 -0
- package/dist/script/isolated-runner.js.map +1 -0
- package/dist/script/legacy.d.ts.map +1 -1
- package/dist/script/legacy.js +8 -0
- package/dist/script/legacy.js.map +1 -1
- package/dist/script/pm-api-metadata.d.ts +19 -0
- package/dist/script/pm-api-metadata.d.ts.map +1 -0
- package/dist/script/pm-api-metadata.js +264 -0
- package/dist/script/pm-api-metadata.js.map +1 -0
- package/dist/script/scope.d.ts +2 -0
- package/dist/script/scope.d.ts.map +1 -1
- package/dist/script/scope.js +4 -0
- package/dist/script/scope.js.map +1 -1
- package/dist/script/worker-entry.d.ts +2 -0
- package/dist/script/worker-entry.d.ts.map +1 -0
- package/dist/script/worker-entry.js +79 -0
- package/dist/script/worker-entry.js.map +1 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist-cjs/host/connections.js +164 -0
- package/dist-cjs/host/connections.js.map +1 -0
- package/dist-cjs/host/db/mongoAdapter.js +431 -0
- package/dist-cjs/host/db/mongoAdapter.js.map +1 -0
- package/dist-cjs/host/db/mysqlAdapter.js +73 -0
- package/dist-cjs/host/db/mysqlAdapter.js.map +1 -0
- package/dist-cjs/host/db/oracleAdapter.js +147 -0
- package/dist-cjs/host/db/oracleAdapter.js.map +1 -0
- package/dist-cjs/host/db/oracleConnectString.js +63 -0
- package/dist-cjs/host/db/oracleConnectString.js.map +1 -0
- package/dist-cjs/host/db/postgresAdapter.js +72 -0
- package/dist-cjs/host/db/postgresAdapter.js.map +1 -0
- package/dist-cjs/host/db/queryExecutor.js +101 -0
- package/dist-cjs/host/db/queryExecutor.js.map +1 -0
- package/dist-cjs/host/db/sqlNormalize.js +33 -0
- package/dist-cjs/host/db/sqlNormalize.js.map +1 -0
- package/dist-cjs/host/db/templateResolver.js +81 -0
- package/dist-cjs/host/db/templateResolver.js.map +1 -0
- package/dist-cjs/host/db/types.js +7 -0
- package/dist-cjs/host/db/types.js.map +1 -0
- package/dist-cjs/host/index.js +17 -0
- package/dist-cjs/host/index.js.map +1 -0
- package/dist-cjs/host/lazy.js +69 -0
- package/dist-cjs/host/lazy.js.map +1 -0
- package/dist-cjs/host/redis/redisService.js +268 -0
- package/dist-cjs/host/redis/redisService.js.map +1 -0
- package/dist-cjs/host/redis/types.js +5 -0
- package/dist-cjs/host/redis/types.js.map +1 -0
- package/dist-cjs/index.js +10 -1
- package/dist-cjs/index.js.map +1 -1
- package/dist-cjs/runner/requestRunner.js +120 -0
- package/dist-cjs/runner/requestRunner.js.map +1 -1
- package/dist-cjs/runner/runCollection.js +3 -1
- package/dist-cjs/runner/runCollection.js.map +1 -1
- package/dist-cjs/scenario-runner/adapters/script-executor.js +3 -3
- package/dist-cjs/scenario-runner/adapters/script-executor.js.map +1 -1
- package/dist-cjs/script/features/log.js +23 -4
- package/dist-cjs/script/features/log.js.map +1 -1
- package/dist-cjs/script/isolated-runner.js +209 -0
- package/dist-cjs/script/isolated-runner.js.map +1 -0
- package/dist-cjs/script/legacy.js +8 -0
- package/dist-cjs/script/legacy.js.map +1 -1
- package/dist-cjs/script/pm-api-metadata.js +267 -0
- package/dist-cjs/script/pm-api-metadata.js.map +1 -0
- package/dist-cjs/script/scope.js +5 -1
- package/dist-cjs/script/scope.js.map +1 -1
- package/dist-cjs/script/worker-entry.js +81 -0
- package/dist-cjs/script/worker-entry.js.map +1 -0
- package/package.json +15 -3
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!-- GENERATED FILE — do not edit by hand. Source: callman_core (npm run ai:packs). -->
|
|
2
|
+
|
|
3
|
+
# Script feature policy
|
|
4
|
+
|
|
5
|
+
Some `pm.*` features can be disabled per execution context (ScriptFeaturePolicy). A disabled feature evaluates to `undefined` at top level; inside `pm.test` callbacks it throws so the test reports SKIPPED instead of failing.
|
|
6
|
+
|
|
7
|
+
Capability-gated members:
|
|
8
|
+
|
|
9
|
+
## database
|
|
10
|
+
|
|
11
|
+
- `pm.db.query({ connectionId, query })`
|
|
12
|
+
- `pm.db.pre`
|
|
13
|
+
- `pm.db.post`
|
|
14
|
+
|
|
15
|
+
## kafka
|
|
16
|
+
|
|
17
|
+
- `pm.kafka.event()`
|
|
18
|
+
- `pm.kafka.messages()`
|
|
19
|
+
|
|
20
|
+
## redis
|
|
21
|
+
|
|
22
|
+
- `pm.redis.get(key)`
|
|
23
|
+
- `pm.redis.results.pre`
|
|
24
|
+
- `pm.redis.results.post`
|
|
25
|
+
|
|
26
|
+
Generation guidance: prefer declared pre/post queries and `pm.db.query` only when the user explicitly asks for database work; never assume kafka/redis capabilities exist unless the task mentions them.
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
<!-- GENERATED FILE — do not edit by hand. Source: callman_core (npm run ai:packs). -->
|
|
2
|
+
|
|
3
|
+
# Callman `pm.*` scripting API
|
|
4
|
+
|
|
5
|
+
Scripts are plain JavaScript (top-level `await` allowed). Use ONLY the API below — anything else (fetch, require, process, Buffer, ...) is blocked by the sandbox.
|
|
6
|
+
|
|
7
|
+
## pm.test
|
|
8
|
+
|
|
9
|
+
Register a named test. The callback's assertion failures mark the test failed without aborting the script.
|
|
10
|
+
|
|
11
|
+
- `pm.test(name, fn)` — Runs fn (sync or async); pass/fail lands in the run's test results.
|
|
12
|
+
|
|
13
|
+
## pm.expect
|
|
14
|
+
|
|
15
|
+
Chai-style assertions plus Jest-style matchers.
|
|
16
|
+
|
|
17
|
+
- `pm.expect(value)` — 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?).
|
|
18
|
+
- `pm.expect.fail(message?)` — Fails the surrounding test immediately.
|
|
19
|
+
|
|
20
|
+
## pm.environment
|
|
21
|
+
|
|
22
|
+
Active environment variables (alias: pm.env). Writes are scoped to the run and surface as variable mutations.
|
|
23
|
+
|
|
24
|
+
- `pm.environment.get(key)` — Read a variable (string or undefined).
|
|
25
|
+
- `pm.environment.set(key, value)` — Write a variable for subsequent steps.
|
|
26
|
+
- `pm.environment.unset(key)` — Remove a variable.
|
|
27
|
+
- `pm.environment.has(key)` — true when the key exists.
|
|
28
|
+
- `pm.environment.clear()` — Remove every variable in the scope.
|
|
29
|
+
- `pm.environment.toObject()` — Plain { key: value } snapshot.
|
|
30
|
+
- `pm.environment.replaceIn(template)` — Resolve {{tokens}} inside a string.
|
|
31
|
+
- `pm.environment.name` — Active environment's name.
|
|
32
|
+
|
|
33
|
+
## pm.globals
|
|
34
|
+
|
|
35
|
+
Workspace-level global variables. Same surface as pm.environment.
|
|
36
|
+
|
|
37
|
+
- `pm.globals.get(key)` — Read a global.
|
|
38
|
+
- `pm.globals.set(key, value)` — Write a global for the run.
|
|
39
|
+
- `pm.globals.unset(key)` — Remove a global.
|
|
40
|
+
- `pm.globals.has(key)` — true when the key exists.
|
|
41
|
+
- `pm.globals.clear()` — Remove every global in the scope.
|
|
42
|
+
- `pm.globals.toObject()` — Plain snapshot.
|
|
43
|
+
- `pm.globals.replaceIn(template)` — Resolve {{tokens}} inside a string.
|
|
44
|
+
|
|
45
|
+
## pm.collectionVariables
|
|
46
|
+
|
|
47
|
+
Collection-scoped variables that survive across requests within one collection run iteration.
|
|
48
|
+
|
|
49
|
+
- `pm.collectionVariables.get(key)` — Read a collection variable.
|
|
50
|
+
- `pm.collectionVariables.set(key, value)` — Write; persists across the iteration.
|
|
51
|
+
- `pm.collectionVariables.unset(key)` — Remove a collection variable.
|
|
52
|
+
- `pm.collectionVariables.has(key)` — true when the key exists.
|
|
53
|
+
- `pm.collectionVariables.clear()` — Remove all collection variables.
|
|
54
|
+
- `pm.collectionVariables.toObject()` — Plain snapshot.
|
|
55
|
+
- `pm.collectionVariables.replaceIn(template)` — Resolve {{tokens}}.
|
|
56
|
+
|
|
57
|
+
## pm.variables
|
|
58
|
+
|
|
59
|
+
Layered read across all scopes (per-iteration > environment > globals) plus template resolution.
|
|
60
|
+
|
|
61
|
+
- `pm.variables.get(key)` — Read through the precedence chain.
|
|
62
|
+
- `pm.variables.set(key, value)` — Write to the run-local layer.
|
|
63
|
+
- `pm.variables.unset(key)` — Remove from the run-local layer.
|
|
64
|
+
- `pm.variables.has(key)` — true when any layer has the key.
|
|
65
|
+
- `pm.variables.toObject()` — Merged snapshot.
|
|
66
|
+
- `pm.variables.replaceIn(template)` — Resolve {{tokens}} in a string.
|
|
67
|
+
- `pm.variables.resolve(template)` — Like replaceIn, but also resolves scenario node-output references.
|
|
68
|
+
|
|
69
|
+
## pm.request
|
|
70
|
+
|
|
71
|
+
The outgoing request. Mutations only have effect in pre-request scripts (the call has not fired yet).
|
|
72
|
+
|
|
73
|
+
- `pm.request.url` — Resolved URL string.
|
|
74
|
+
- `pm.request.method` — HTTP method.
|
|
75
|
+
- `pm.request.body` — Body snapshot (mode + content).
|
|
76
|
+
- `pm.request.headers` — HeaderList: .all() .get(name) .has(name) .add({key,value}) .upsert({key,value}) .remove(name) .idx(i).
|
|
77
|
+
- `pm.request.query` — Query params as a HeaderList.
|
|
78
|
+
- `pm.request.getHeader(name)` — Read one header value.
|
|
79
|
+
- `pm.request.setHeader(name, value)` — Set/replace a header. _(stages: pre-request, scenario-script)_
|
|
80
|
+
- `pm.request.unsetHeader(name)` — Remove a header. _(stages: pre-request, scenario-script)_
|
|
81
|
+
- `pm.request.getQueryParam(name)` — Read one query param.
|
|
82
|
+
- `pm.request.setQueryParam(name, value)` — Set/replace a query param. _(stages: pre-request, scenario-script)_
|
|
83
|
+
- `pm.request.unsetQueryParam(name)` — Remove a query param. _(stages: pre-request, scenario-script)_
|
|
84
|
+
- `pm.request.setUrl(url)` — Replace the URL. _(stages: pre-request, scenario-script)_
|
|
85
|
+
- `pm.request.setMethod(method)` — Replace the method. _(stages: pre-request, scenario-script)_
|
|
86
|
+
- `pm.request.setRawBody(value)` — Replace the raw body (string or object → JSON). _(stages: pre-request, scenario-script)_
|
|
87
|
+
|
|
88
|
+
## pm.response
|
|
89
|
+
|
|
90
|
+
The received response. Not available in pre-request scripts.
|
|
91
|
+
|
|
92
|
+
- `pm.response.code` — Status code (number). _(stages: post-response, tests, scenario-script)_
|
|
93
|
+
- `pm.response.status` — Status code (number, alias). _(stages: post-response, tests, scenario-script)_
|
|
94
|
+
- `pm.response.statusText` — Status text. _(stages: post-response, tests, scenario-script)_
|
|
95
|
+
- `pm.response.json()` — 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)_
|
|
96
|
+
- `pm.response.text()` — Raw body as string. _(stages: post-response, tests, scenario-script)_
|
|
97
|
+
- `pm.response.rawBody` — Raw body string. _(stages: post-response, tests, scenario-script)_
|
|
98
|
+
- `pm.response.headers` — Response HeaderList. _(stages: post-response, tests, scenario-script)_
|
|
99
|
+
- `pm.response.responseTime` — Duration in ms. _(stages: post-response, tests, scenario-script)_
|
|
100
|
+
- `pm.response.responseSize` — Body size in bytes. _(stages: post-response, tests, scenario-script)_
|
|
101
|
+
- `pm.response.to.have.status(code)` — Assertion shortcuts; also .to.have.header/.jsonBody/.body and .to.be.ok/.json/.success/.clientError/... plus .to.not.<predicate>. _(stages: post-response, tests, scenario-script)_
|
|
102
|
+
|
|
103
|
+
## pm.sendRequest
|
|
104
|
+
|
|
105
|
+
Fire an ad-hoc HTTP request from inside a script.
|
|
106
|
+
|
|
107
|
+
- `pm.sendRequest(urlOrOptions, callback?)` — 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.
|
|
108
|
+
|
|
109
|
+
## pm.db
|
|
110
|
+
|
|
111
|
+
Database access (Oracle / MongoDB / PostgreSQL / MySQL). Disabled by feature policy in some contexts — tests then report SKIP.
|
|
112
|
+
|
|
113
|
+
- `pm.db.query({ connectionId, query })` — Run an ad-hoc query — ALWAYS await it. Resolves to { success, error, rowCount, rows, firstRow(), connectionId, connectionName, connectionType, durationMs, executedAt }. firstRow is a FUNCTION: res.firstRow()?.STATUS (Oracle columns are UPPERCASE). _(requires the database capability — may be disabled by feature policy)_
|
|
114
|
+
- `pm.db.pre` — Result object of the declared pre-request DB query: { success, error, rowCount, rows, firstRow() }. Not a promise — read directly. _(requires the database capability — may be disabled by feature policy)_
|
|
115
|
+
- `pm.db.post` — Result object of the declared post-response DB query (same shape as pm.db.pre). _(stages: post-response, tests)_ _(requires the database capability — may be disabled by feature policy)_
|
|
116
|
+
|
|
117
|
+
## pm.kafka
|
|
118
|
+
|
|
119
|
+
Captured Kafka events from the request's Kafka tab listener.
|
|
120
|
+
|
|
121
|
+
- `pm.kafka.event()` — The matched event's parsed payload (or null). _(stages: post-response, tests)_ _(requires the kafka capability — may be disabled by feature policy)_
|
|
122
|
+
- `pm.kafka.messages()` — Every captured message in the listen window. _(stages: post-response, tests)_ _(requires the kafka capability — may be disabled by feature policy)_
|
|
123
|
+
|
|
124
|
+
## pm.redis
|
|
125
|
+
|
|
126
|
+
Results of the declared pre/post Redis commands.
|
|
127
|
+
|
|
128
|
+
- `pm.redis.get(key)` — Read a value already captured by a declared GET. _(requires the redis capability — may be disabled by feature policy)_
|
|
129
|
+
- `pm.redis.results.pre` — Array of pre-stage command results (by line index). _(requires the redis capability — may be disabled by feature policy)_
|
|
130
|
+
- `pm.redis.results.post` — Array of post-stage command results. _(stages: post-response, tests)_ _(requires the redis capability — may be disabled by feature policy)_
|
|
131
|
+
|
|
132
|
+
## pm.random
|
|
133
|
+
|
|
134
|
+
Deterministic-format random data generators.
|
|
135
|
+
|
|
136
|
+
- `pm.random.uuid()` — UUID v4.
|
|
137
|
+
- `pm.random.email()` — Random email address.
|
|
138
|
+
- `pm.random.string(length?)` — Alphanumeric string.
|
|
139
|
+
- `pm.random.int(min, max)` — Integer in range.
|
|
140
|
+
- `pm.random.bigdecimal(min, max, scale)` — Decimal with given scale.
|
|
141
|
+
- `pm.random.boolean()` — true/false.
|
|
142
|
+
- `pm.random.phone()` — Phone number string.
|
|
143
|
+
- `pm.random.name()` — Person name.
|
|
144
|
+
- `pm.random.date(format?)` — Date string.
|
|
145
|
+
|
|
146
|
+
## pm.counter
|
|
147
|
+
|
|
148
|
+
Monotonic counter scoped to the run.
|
|
149
|
+
|
|
150
|
+
- `pm.counter.next()` — Next value (starts at 1).
|
|
151
|
+
- `pm.counter.start(startAt?)` — Counter starting at a custom value.
|
|
152
|
+
|
|
153
|
+
## pm.info
|
|
154
|
+
|
|
155
|
+
Execution metadata snapshot.
|
|
156
|
+
|
|
157
|
+
- `pm.info.eventName` — "prerequest" | "test".
|
|
158
|
+
- `pm.info.iteration` — Zero-based data-driven iteration index.
|
|
159
|
+
- `pm.info.iterationCount` — Total iterations — only meaningful in collection/data-driven runs. Never use it to gate token/cache logic in single sends.
|
|
160
|
+
- `pm.info.requestName` — Current request's name.
|
|
161
|
+
- `pm.info.requestId` — Current request's id.
|
|
162
|
+
|
|
163
|
+
## pm.execution
|
|
164
|
+
|
|
165
|
+
Collection-run flow control.
|
|
166
|
+
|
|
167
|
+
- `pm.execution.setNextRequest(name)` — Jump to a named request next (collection runs).
|
|
168
|
+
- `pm.execution.skipRequest()` — Skip the current request. _(stages: pre-request)_
|
|
169
|
+
- `pm.execution.location` — Folder path of the current request.
|
|
170
|
+
|
|
171
|
+
## pm.node
|
|
172
|
+
|
|
173
|
+
Scenario workflow context (only meaningful inside scenario script nodes).
|
|
174
|
+
|
|
175
|
+
- `pm.node.nodeLabel` — Current node's label. _(stages: scenario-script)_
|
|
176
|
+
- `pm.node.setNextRequest(name)` — Route the workflow to a named node. _(stages: scenario-script)_
|
|
177
|
+
|
|
178
|
+
## pm.log
|
|
179
|
+
|
|
180
|
+
Structured logging into the run report.
|
|
181
|
+
|
|
182
|
+
- `pm.log(...args)` — Like console.log; entries land in the run's log panel.
|
|
183
|
+
|
|
184
|
+
## CryptoJS
|
|
185
|
+
|
|
186
|
+
crypto-js global (NOT under pm.*).
|
|
187
|
+
|
|
188
|
+
- `CryptoJS.SHA256(msg) / SHA1 / SHA512 / MD5` — Hashes; .toString() or .toString(CryptoJS.enc.Hex).
|
|
189
|
+
- `CryptoJS.HmacSHA256(msg, key)` — HMAC family (SHA1/224/384/512, MD5 variants).
|
|
190
|
+
- `CryptoJS.AES.encrypt(msg, key) / .decrypt(cipher, key)` — AES; decrypt result needs .toString(CryptoJS.enc.Utf8).
|
|
191
|
+
- `CryptoJS.PBKDF2(password, salt, options)` — Key derivation.
|
|
192
|
+
- `CryptoJS.enc.Utf8 / Base64 / Hex / Latin1` — Encoders for .toString(...).
|
|
193
|
+
- `CryptoJS.lib.WordArray.create / random(n)` — Raw word arrays (e.g. random IVs).
|
|
194
|
+
|
|
195
|
+
## _
|
|
196
|
+
|
|
197
|
+
lodash global (NOT under pm.*).
|
|
198
|
+
|
|
199
|
+
- `_.get(obj, path, default?) / _.pick / _.groupBy / _.sortBy / _.uniq / ...` — Full lodash surface for data wrangling.
|
|
200
|
+
|
|
201
|
+
## timers
|
|
202
|
+
|
|
203
|
+
Safe per-execution timer wrappers (callbacks never outlive the run).
|
|
204
|
+
|
|
205
|
+
- `setTimeout(fn, ms) / clearTimeout(id)` — Use with await new Promise(r => setTimeout(r, ms)) for polling loops.
|
|
206
|
+
- `setInterval(fn, ms) / clearInterval(id)` — Interval variant.
|
|
207
|
+
|
|
208
|
+
## Stage rules
|
|
209
|
+
|
|
210
|
+
- `pre-request`: runs BEFORE the HTTP call. `pm.response` does not exist; `pm.request` mutations take effect.
|
|
211
|
+
- `post-response` / `tests`: run AFTER the call. `pm.response` is available; `pm.request` mutations have no effect.
|
|
212
|
+
- `scenario-script`: a scenario Script node. Prior node outputs are readable via `pm.variables.resolve("{{NodeLabel.path}}")`; the script's return value becomes the node output.
|
|
213
|
+
- Members without a stage note are available in every stage.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<!-- GENERATED FILE — do not edit by hand. Source: callman_core (npm run ai:packs). -->
|
|
2
|
+
|
|
3
|
+
# Script sandbox — available and blocked globals
|
|
4
|
+
|
|
5
|
+
The sandbox is a Node `vm` context. Generated code must never reference a blocked global — the script fails at runtime.
|
|
6
|
+
|
|
7
|
+
## Available built-ins
|
|
8
|
+
|
|
9
|
+
`AggregateError`, `Array`, `ArrayBuffer`, `BigInt`, `BigInt64Array`, `BigUint64Array`, `Boolean`, `DataView`, `Date`, `Error`, `EvalError`, `Float32Array`, `Float64Array`, `Infinity`, `Int16Array`, `Int32Array`, `Int8Array`, `JSON`, `Map`, `Math`, `NaN`, `Number`, `Object`, `Promise`, `RangeError`, `ReferenceError`, `RegExp`, `Set`, `String`, `Symbol`, `SyntaxError`, `TextDecoder`, `TextEncoder`, `TypeError`, `URIError`, `URL`, `URLSearchParams`, `Uint16Array`, `Uint32Array`, `Uint8Array`, `Uint8ClampedArray`, `WeakMap`, `WeakSet`, `atob`, `btoa`, `decodeURIComponent`, `encodeURIComponent`, `isFinite`, `isNaN`, `parseFloat`, `parseInt`, `structuredClone`, `undefined`
|
|
10
|
+
|
|
11
|
+
Plus the injected helpers: `pm`, `console`, `CryptoJS`, `_` (lodash), `setTimeout`/`clearTimeout`/`setInterval`/`clearInterval` (safe per-run wrappers).
|
|
12
|
+
|
|
13
|
+
## Blocked (never use)
|
|
14
|
+
|
|
15
|
+
`Buffer`, `Function`, `WebSocket`, `Worker`, `XMLHttpRequest`, `document`, `eval`, `exports`, `fetch`, `global`, `globalThis`, `importScripts`, `module`, `navigator`, `process`, `require`, `self`, `window`
|
|
16
|
+
|
|
17
|
+
Notes:
|
|
18
|
+
- No `fetch` — use `pm.sendRequest` for HTTP.
|
|
19
|
+
- No `Buffer` — use `atob`/`btoa`/`TextEncoder`/`Uint8Array`.
|
|
20
|
+
- No `require`/`import` — `CryptoJS` and `_` are already in scope.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<!-- GENERATED FILE — do not edit by hand. Source: callman_core (npm run ai:packs). -->
|
|
2
|
+
|
|
3
|
+
# Template tokens (`{{...}}`)
|
|
4
|
+
|
|
5
|
+
Anywhere a `{{...}}` is accepted (URLs, headers, bodies, DB queries, Kafka payloads, scenario node configs), substitution is PLAIN TEXT replacement — no quoting, no escaping. Quote SQL strings yourself (`WHERE id = '{{userId}}'`). A missing variable resolves to an empty string.
|
|
6
|
+
|
|
7
|
+
## Variable lookups
|
|
8
|
+
|
|
9
|
+
- `{{name}}` — environment → globals lookup.
|
|
10
|
+
- `{{env.name}}` / `{{global.name}}` — forced scope.
|
|
11
|
+
- `{{response.body.<path>}}` — current request's response (request context only; dot-indexed arrays: `items.0.id`).
|
|
12
|
+
- `{{<NodeLabel>.<path>}}` — a prior scenario node's output (scenario context only; bracket-indexed arrays: `rows[0].id`).
|
|
13
|
+
|
|
14
|
+
## Random generators
|
|
15
|
+
|
|
16
|
+
| Token | Meaning | Example output |
|
|
17
|
+
| --- | --- | --- |
|
|
18
|
+
| `{{random.email}}` | Random email address | `sam.user42@example.com` |
|
|
19
|
+
| `{{random.string}}` | Random alphanumeric string | `aZ19xPq20LmN` |
|
|
20
|
+
| `{{random.uuid}}` | Random UUID v4 | `1d7fe6b6-6f47-4fa9-b57a-d2e1d285be51` |
|
|
21
|
+
| `{{random.int}}` | Random integer | `48291` |
|
|
22
|
+
| `{{random.bigdecimal}}` | Random decimal number | `1842.552190` |
|
|
23
|
+
| `{{random.boolean}}` | Random boolean | `true` |
|
|
24
|
+
| `{{random.phone}}` | Random phone number | `+15558675309` |
|
|
25
|
+
| `{{random.date("YYYY-MM-DD")}}` | Random date | `2026-04-06` |
|
|
26
|
+
| `{{random.name}}` | Random human name | `Aylin Karimli` |
|
|
27
|
+
|
|
28
|
+
## Counters
|
|
29
|
+
|
|
30
|
+
| Token | Meaning | Example output |
|
|
31
|
+
| --- | --- | --- |
|
|
32
|
+
| `{{counter}}` | Incrementing counter per request | `1, 2, 3...` |
|
|
33
|
+
| `{{counter.start(100)}}` | Counter starting at 100 | `100, 101, 102...` |
|
|
34
|
+
|
|
35
|
+
## Postman-compatible `$` tokens
|
|
36
|
+
|
|
37
|
+
| Token | Meaning | Example output |
|
|
38
|
+
| --- | --- | --- |
|
|
39
|
+
| `{{$guid}}` | Postman compat — UUID v4 | `1d7fe6b6-6f47-4fa9-b57a-d2e1d285be51` |
|
|
40
|
+
| `{{$randomUUID}}` | Postman compat — UUID v4 | `1d7fe6b6-6f47-4fa9-b57a-d2e1d285be51` |
|
|
41
|
+
| `{{$timestamp}}` | Postman compat — unix seconds | `1718793600` |
|
|
42
|
+
| `{{$isoTimestamp}}` | Postman compat — ISO 8601 | `2026-05-18T10:24:00.123Z` |
|
|
43
|
+
| `{{$randomInt}}` | Postman compat — 0-1000 | `482` |
|
|
44
|
+
| `{{$randomBoolean}}` | Postman compat | `true` |
|
|
45
|
+
| `{{$randomAlphaNumeric}}` | Postman compat — 8 chars | `aZ19xPq2` |
|
|
46
|
+
| `{{$randomHexaDecimal}}` | Postman compat — 0xNNNNNNNN | `0x4f3a1c2d` |
|
|
47
|
+
| `{{$randomString}}` | Postman compat — 12 chars | `aZ19xPq20LmN` |
|
|
48
|
+
| `{{$randomFirstName}}` | Postman compat | `Aylin` |
|
|
49
|
+
| `{{$randomLastName}}` | Postman compat | `Karimov` |
|
|
50
|
+
| `{{$randomFullName}}` | Postman compat | `Aylin Karimov` |
|
|
51
|
+
| `{{$randomUserName}}` | Postman compat | `aylin.karimov42` |
|
|
52
|
+
| `{{$randomNamePrefix}}` | Postman compat | `Dr.` |
|
|
53
|
+
| `{{$randomNameSuffix}}` | Postman compat | `Jr.` |
|
|
54
|
+
| `{{$randomEmail}}` | Postman compat | `sam.user42@example.com` |
|
|
55
|
+
| `{{$randomUrl}}` | Postman compat | `https://acme.io/q1w2e3` |
|
|
56
|
+
| `{{$randomDomainName}}` | Postman compat | `acme.io` |
|
|
57
|
+
| `{{$randomDomainSuffix}}` | Postman compat | `io` |
|
|
58
|
+
| `{{$randomUserAgent}}` | Postman compat | `Mozilla/5.0 (...)` |
|
|
59
|
+
| `{{$randomIP}}` | Postman compat — IPv4 | `192.168.1.42` |
|
|
60
|
+
| `{{$randomIPV4}}` | Postman compat | `192.168.1.42` |
|
|
61
|
+
| `{{$randomIPV6}}` | Postman compat | `fe80::1ff:fe23:4567:890a` |
|
|
62
|
+
| `{{$randomMACAddress}}` | Postman compat | `1A:2B:3C:4D:5E:6F` |
|
|
63
|
+
| `{{$randomPassword}}` | Postman compat | `x4Z9p2Aq!` |
|
|
64
|
+
| `{{$randomSemver}}` | Postman compat | `3.7.42` |
|
|
65
|
+
| `{{$randomPhoneNumber}}` | Postman compat | `+15558675309` |
|
|
66
|
+
| `{{$randomCity}}` | Postman compat | `Baku` |
|
|
67
|
+
| `{{$randomCountry}}` | Postman compat | `Azerbaijan` |
|
|
68
|
+
| `{{$randomCountryCode}}` | Postman compat | `AZ` |
|
|
69
|
+
| `{{$randomStreetAddress}}` | Postman compat | `742 Maple St` |
|
|
70
|
+
| `{{$randomZipCode}}` | Postman compat | `10042` |
|
|
71
|
+
| `{{$randomLatitude}}` | Postman compat | `40.412345` |
|
|
72
|
+
| `{{$randomLongitude}}` | Postman compat | `-74.012345` |
|
|
73
|
+
| `{{$randomCompanyName}}` | Postman compat | `Acme Labs Inc.` |
|
|
74
|
+
| `{{$randomJobTitle}}` | Postman compat | `Senior Software Engineer` |
|
|
75
|
+
| `{{$randomJobArea}}` | Postman compat | `Engineering` |
|
|
76
|
+
| `{{$randomDepartment}}` | Postman compat | `Engineering` |
|
|
77
|
+
| `{{$randomProduct}}` | Postman compat | `Acme Cloud` |
|
|
78
|
+
| `{{$randomCatchPhrase}}` | Postman compat | `Scalable mesh` |
|
|
79
|
+
| `{{$randomCreditCardMask}}` | Postman compat | `****-****-****-4242` |
|
|
80
|
+
| `{{$randomCreditCardNumber}}` | Postman compat | `4242424242424242` |
|
|
81
|
+
| `{{$randomBankAccount}}` | Postman compat | `0123456789` |
|
|
82
|
+
| `{{$randomBankRoutingNumber}}` | Postman compat | `021000089` |
|
|
83
|
+
| `{{$randomCurrencyCode}}` | Postman compat | `USD` |
|
|
84
|
+
| `{{$randomPrice}}` | Postman compat | `42.99` |
|
|
85
|
+
| `{{$randomTransactionType}}` | Postman compat | `payment` |
|
|
86
|
+
| `{{$randomDatetime}}` | Postman compat | `2026-04-06T10:24:00.000Z` |
|
|
87
|
+
| `{{$randomDatePast}}` | Postman compat | `2025-10-12T...` |
|
|
88
|
+
| `{{$randomDateFuture}}` | Postman compat | `2026-11-04T...` |
|
|
89
|
+
| `{{$randomDateRecent}}` | Postman compat — last 7 days | `2026-05-15T...` |
|
|
90
|
+
| `{{$randomDateSoon}}` | Postman compat — next 7 days | `2026-05-22T...` |
|
|
91
|
+
| `{{$randomTime}}` | Postman compat | `14:23:07` |
|
|
92
|
+
| `{{$randomWeekday}}` | Postman compat | `Wednesday` |
|
|
93
|
+
| `{{$randomMonth}}` | Postman compat | `April` |
|
|
94
|
+
| `{{$randomColor}}` | Postman compat | `purple` |
|
|
95
|
+
| `{{$randomHexColor}}` | Postman compat | `#A78BFA` |
|
|
96
|
+
| `{{$randomWord}}` | Postman compat — lorem | `ipsum` |
|
|
97
|
+
| `{{$randomWords}}` | Postman compat — lorem phrase | `lorem ipsum dolor` |
|
|
98
|
+
| `{{$randomSentence}}` | Postman compat | `Lorem ipsum dolor sit amet.` |
|
|
99
|
+
| `{{$randomParagraph}}` | Postman compat | `Lorem ipsum dolor sit amet...` |
|
|
100
|
+
| `{{$randomFileName}}` | Postman compat | `q1w2e3r4.pdf` |
|
|
101
|
+
| `{{$randomFileExt}}` | Postman compat | `json` |
|
|
102
|
+
| `{{$randomFileType}}` | Postman compat | `image` |
|
|
103
|
+
| `{{$randomMimeType}}` | Postman compat | `application/json` |
|
|
104
|
+
| `{{$randomImageUrl}}` | Postman compat | `https://picsum.photos/400/300` |
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ScriptDbExecutionInput, ScriptDbExecutionResult, ScriptRedisCapability } from "../script/types.js";
|
|
2
|
+
import type { DbConnectionType, DbConnectionMode } from "./db/types.js";
|
|
3
|
+
import type { RedisCommandExecutionResult, RedisCommandPhase } from "./redis/types.js";
|
|
4
|
+
export interface DbConnectionRuntime {
|
|
5
|
+
kind: "db";
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
type: DbConnectionType;
|
|
9
|
+
connectionMode?: DbConnectionMode;
|
|
10
|
+
connectionString?: string;
|
|
11
|
+
host?: string;
|
|
12
|
+
port?: number;
|
|
13
|
+
database?: string;
|
|
14
|
+
serviceName?: string;
|
|
15
|
+
username?: string;
|
|
16
|
+
password?: string;
|
|
17
|
+
ssl?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface RedisConnectionRuntime {
|
|
20
|
+
kind: "redis";
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
host: string;
|
|
24
|
+
port: number;
|
|
25
|
+
password?: string;
|
|
26
|
+
dbIndex?: number;
|
|
27
|
+
ssl?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export type ConnectionRuntime = DbConnectionRuntime | RedisConnectionRuntime;
|
|
30
|
+
export type ConnectionRuntimeMap = Record<string, ConnectionRuntime>;
|
|
31
|
+
export interface DbNodeConfig {
|
|
32
|
+
enabled?: boolean;
|
|
33
|
+
connectionId?: string | null;
|
|
34
|
+
query?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface RequestDatabaseRuntimeConfig {
|
|
37
|
+
preRequest?: DbNodeConfig;
|
|
38
|
+
postResponse?: DbNodeConfig;
|
|
39
|
+
}
|
|
40
|
+
export interface RequestRedisRuntimeConfig {
|
|
41
|
+
enabled?: boolean;
|
|
42
|
+
connectionId?: string | null;
|
|
43
|
+
preCommands?: string[];
|
|
44
|
+
postCommands?: string[];
|
|
45
|
+
}
|
|
46
|
+
export interface ScriptTemplateContext {
|
|
47
|
+
response?: unknown | null;
|
|
48
|
+
env?: Record<string, string>;
|
|
49
|
+
global?: Record<string, string>;
|
|
50
|
+
}
|
|
51
|
+
export declare const buildDbExecuteCapability: (connections: ConnectionRuntimeMap) => (input: ScriptDbExecutionInput) => Promise<ScriptDbExecutionResult>;
|
|
52
|
+
export declare const runConfiguredDbQuery: (input: {
|
|
53
|
+
connections: ConnectionRuntimeMap;
|
|
54
|
+
config: DbNodeConfig | undefined;
|
|
55
|
+
phase: "pre" | "post";
|
|
56
|
+
context: ScriptTemplateContext;
|
|
57
|
+
}) => Promise<ScriptDbExecutionResult | null>;
|
|
58
|
+
export declare const runRedisCommandsForPhase: (input: {
|
|
59
|
+
connections: ConnectionRuntimeMap;
|
|
60
|
+
connectionId: string | null | undefined;
|
|
61
|
+
commands: string[];
|
|
62
|
+
phase: RedisCommandPhase;
|
|
63
|
+
context: ScriptTemplateContext;
|
|
64
|
+
}) => Promise<RedisCommandExecutionResult[]>;
|
|
65
|
+
export declare const buildRedisValueCache: (results: RedisCommandExecutionResult[]) => Record<string, unknown>;
|
|
66
|
+
export declare const buildRedisCapability: (pre: RedisCommandExecutionResult[], post: RedisCommandExecutionResult[]) => ScriptRedisCapability;
|
|
67
|
+
//# sourceMappingURL=connections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../../src/host/connections.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAEV,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAEV,gBAAgB,EAChB,gBAAgB,EAGjB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EACV,2BAA2B,EAC3B,iBAAiB,EAElB,MAAM,kBAAkB,CAAC;AAI1B,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,IAAI,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IAC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ACvB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAkED,eAAO,MAAM,wBAAwB,GAClC,aAAa,oBAAoB,MAC3B,OAAO,sBAAsB,KAAG,OAAO,CAAC,uBAAuB,CAuBrE,CAAC;AAKJ,eAAO,MAAM,oBAAoB,GAAU,OAAO;IAChD,WAAW,EAAE,oBAAoB,CAAC;IAClC,MAAM,EAAE,YAAY,GAAG,SAAS,CAAC;IACjC,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC;IACtB,OAAO,EAAE,qBAAqB,CAAC;CAChC,KAAG,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAiBzC,CAAC;AAIF,eAAO,MAAM,wBAAwB,GAAU,OAAO;IACpD,WAAW,EAAE,oBAAoB,CAAC;IAClC,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,EAAE,iBAAiB,CAAC;IACzB,OAAO,EAAE,qBAAqB,CAAC;CAChC,KAAG,OAAO,CAAC,2BAA2B,EAAE,CAsBxC,CAAC;AAKF,eAAO,MAAM,oBAAoB,GAC/B,SAAS,2BAA2B,EAAE,KACrC,MAAM,CAAC,MAAM,EAAE,OAAO,CAwBxB,CAAC;AAGF,eAAO,MAAM,oBAAoB,GAC/B,KAAK,2BAA2B,EAAE,EAClC,MAAM,2BAA2B,EAAE,KAClC,qBAGD,CAAC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// Bridges resolved connection runtimes (from the pipeline bundle) into the
|
|
2
|
+
// script capabilities callman-core's executor understands. This is the glue
|
|
3
|
+
// that lets the collection runner execute `pm.db.query`, pre-/post-request DB
|
|
4
|
+
// nodes, and Redis commands locally — the same surface the Electron host wires
|
|
5
|
+
// up, but driven by connections the runner receives instead of an in-process
|
|
6
|
+
// store.
|
|
7
|
+
import { executeQuery } from "./db/queryExecutor.js";
|
|
8
|
+
import { executeRedisCommands } from "./redis/redisService.js";
|
|
9
|
+
const toDbConnectionInput = (runtime) => ({
|
|
10
|
+
id: runtime.id,
|
|
11
|
+
name: runtime.name,
|
|
12
|
+
type: runtime.type,
|
|
13
|
+
connectionMode: runtime.connectionMode ??
|
|
14
|
+
(runtime.connectionString?.trim() ? "connectionString" : "detailed"),
|
|
15
|
+
connectionString: runtime.connectionString,
|
|
16
|
+
host: runtime.host ?? "",
|
|
17
|
+
port: runtime.port ?? 0,
|
|
18
|
+
database: runtime.database,
|
|
19
|
+
serviceName: runtime.serviceName,
|
|
20
|
+
username: runtime.username ?? "",
|
|
21
|
+
password: runtime.password ?? "",
|
|
22
|
+
ssl: runtime.ssl,
|
|
23
|
+
});
|
|
24
|
+
const toRedisConnectionInput = (runtime) => ({
|
|
25
|
+
id: runtime.id,
|
|
26
|
+
name: runtime.name,
|
|
27
|
+
type: "redis",
|
|
28
|
+
host: runtime.host,
|
|
29
|
+
port: runtime.port,
|
|
30
|
+
password: runtime.password,
|
|
31
|
+
dbIndex: runtime.dbIndex,
|
|
32
|
+
});
|
|
33
|
+
const toScriptDbResult = (result) => ({
|
|
34
|
+
success: result.success,
|
|
35
|
+
error: result.error ?? null,
|
|
36
|
+
phase: result.phase,
|
|
37
|
+
connectionId: result.connectionId,
|
|
38
|
+
connectionName: result.connectionName,
|
|
39
|
+
connectionType: result.connectionType,
|
|
40
|
+
query: result.query,
|
|
41
|
+
resolvedQuery: result.resolvedQuery,
|
|
42
|
+
rows: result.rows,
|
|
43
|
+
rowCount: result.rowCount,
|
|
44
|
+
durationMs: result.durationMs,
|
|
45
|
+
executedAt: result.executedAt,
|
|
46
|
+
});
|
|
47
|
+
const buildMissingConnectionResult = (input) => ({
|
|
48
|
+
success: false,
|
|
49
|
+
error: `Database connection "${input.connectionId}" was not found in the run bundle`,
|
|
50
|
+
phase: input.phase,
|
|
51
|
+
connectionId: input.connectionId,
|
|
52
|
+
connectionName: "",
|
|
53
|
+
connectionType: "mongo",
|
|
54
|
+
query: input.query,
|
|
55
|
+
resolvedQuery: input.query,
|
|
56
|
+
rows: [],
|
|
57
|
+
rowCount: 0,
|
|
58
|
+
durationMs: 0,
|
|
59
|
+
executedAt: new Date().toISOString(),
|
|
60
|
+
});
|
|
61
|
+
// ── DB capability ───────────────────────────────────────────────────
|
|
62
|
+
// Builds the `execute` callback powering `pm.db.query(...)`. Resolves the
|
|
63
|
+
// connectionId against the bundle, runs the query against the right driver,
|
|
64
|
+
// and maps the result into the canonical `ScriptDbExecutionResult`.
|
|
65
|
+
export const buildDbExecuteCapability = (connections) => async (input) => {
|
|
66
|
+
const runtime = connections[input.connectionId];
|
|
67
|
+
if (!runtime || runtime.kind !== "db") {
|
|
68
|
+
return buildMissingConnectionResult({
|
|
69
|
+
connectionId: input.connectionId,
|
|
70
|
+
query: input.query,
|
|
71
|
+
phase: input.phase,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
const result = await executeQuery({
|
|
75
|
+
connectionId: input.connectionId,
|
|
76
|
+
connection: toDbConnectionInput(runtime),
|
|
77
|
+
query: input.query,
|
|
78
|
+
phase: input.phase,
|
|
79
|
+
context: {
|
|
80
|
+
response: input.context?.response ?? null,
|
|
81
|
+
env: input.context?.env ?? {},
|
|
82
|
+
global: input.context?.global ?? {},
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
return toScriptDbResult(result);
|
|
86
|
+
};
|
|
87
|
+
// Runs a configured pre-request / post-response DB node, producing the result
|
|
88
|
+
// surfaced as `pm.db.pre` / `pm.db.post`. Returns null when the node is
|
|
89
|
+
// disabled or incomplete (so it's never wired into the capability).
|
|
90
|
+
export const runConfiguredDbQuery = async (input) => {
|
|
91
|
+
const { config } = input;
|
|
92
|
+
if (!config?.enabled || !config.connectionId || !config.query?.trim()) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
const execute = buildDbExecuteCapability(input.connections);
|
|
96
|
+
return execute({
|
|
97
|
+
connectionId: config.connectionId,
|
|
98
|
+
query: config.query,
|
|
99
|
+
phase: input.phase,
|
|
100
|
+
context: {
|
|
101
|
+
response: input.context.response ?? null,
|
|
102
|
+
env: input.context.env ?? {},
|
|
103
|
+
global: input.context.global ?? {},
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
// ── Redis capability ────────────────────────────────────────────────
|
|
108
|
+
export const runRedisCommandsForPhase = async (input) => {
|
|
109
|
+
const connectionId = input.connectionId?.trim() ?? "";
|
|
110
|
+
const commands = (input.commands ?? []).map((command) => command.trim()).filter(Boolean);
|
|
111
|
+
if (!connectionId || commands.length === 0) {
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
const runtime = input.connections[connectionId];
|
|
115
|
+
const connection = runtime && runtime.kind === "redis" ? toRedisConnectionInput(runtime) : undefined;
|
|
116
|
+
return executeRedisCommands({
|
|
117
|
+
connectionId,
|
|
118
|
+
connection,
|
|
119
|
+
commands,
|
|
120
|
+
phase: input.phase,
|
|
121
|
+
context: {
|
|
122
|
+
response: input.context.response ?? null,
|
|
123
|
+
env: input.context.env ?? {},
|
|
124
|
+
global: input.context.global ?? {},
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
// Mirror of the desktop `buildRedisValueCache`
|
|
129
|
+
// (`pmanfrontend/src/features/redis/lib/redisAssertions.ts`). Maps successful
|
|
130
|
+
// command results to a `key → value` map for `pm.redis.get(key)`.
|
|
131
|
+
export const buildRedisValueCache = (results) => {
|
|
132
|
+
const cache = {};
|
|
133
|
+
for (const result of results) {
|
|
134
|
+
if (!result.success || !result.key) {
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (result.commandName === "GET" || result.commandName === "SET") {
|
|
138
|
+
cache[result.key] = result.result;
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (result.commandName === "DEL") {
|
|
142
|
+
cache[result.key] = null;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (result.commandName === "EXISTS" && result.result === false) {
|
|
146
|
+
cache[result.key] = null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return cache;
|
|
150
|
+
};
|
|
151
|
+
// Assembles the read-only `pm.redis` capability from pre/post command results.
|
|
152
|
+
export const buildRedisCapability = (pre, post) => ({
|
|
153
|
+
values: buildRedisValueCache([...pre, ...post]),
|
|
154
|
+
results: { pre, post },
|
|
155
|
+
});
|
|
156
|
+
//# sourceMappingURL=connections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connections.js","sourceRoot":"","sources":["../../src/host/connections.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,4EAA4E;AAC5E,8EAA8E;AAC9E,+EAA+E;AAC/E,6EAA6E;AAC7E,SAAS;AAQT,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAQrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAkE/D,MAAM,mBAAmB,GAAG,CAAC,OAA4B,EAAqB,EAAE,CAAC,CAAC;IAChF,EAAE,EAAE,OAAO,CAAC,EAAE;IACd,IAAI,EAAE,OAAO,CAAC,IAAI;IAClB,IAAI,EAAE,OAAO,CAAC,IAAI;IAClB,cAAc,EACZ,OAAO,CAAC,cAAc;QACtB,CAAC,OAAO,CAAC,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,UAAU,CAAC;IACtE,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;IAC1C,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,EAAE;IACxB,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,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AAC,WAAW,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;YAC/D,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,+EAA+E;AAC/E,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,GAAkC,EAClC,IAAmC,EACZ,EAAE,CAAC,CAAC;IAC3B,MAAM,EAAE,oBAAoB,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAC/C,OAAO,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;CACvB,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DbConnection } from "./types.js";
|
|
2
|
+
export declare const testMongoConnection: (connection: DbConnection) => Promise<void>;
|
|
3
|
+
export declare const executeMongoQuery: (connection: DbConnection, query: unknown) => Promise<{
|
|
4
|
+
rows: unknown[];
|
|
5
|
+
rowCount: number;
|
|
6
|
+
}>;
|
|
7
|
+
//# sourceMappingURL=mongoAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongoAdapter.d.ts","sourceRoot":"","sources":["../../../src/host/db/mongoAdapter.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAid/C,eAAO,MAAM,mBAAmB,GAAU,YAAY,YAAY,KAAG,OAAO,CAAC,IAAI,CAWhF,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,YAAY,YAAY,EACxB,OAAO,OAAO,KACb,OAAO,CAAC;IAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CA6F/C,CAAC"}
|