callman-core 1.3.0 → 1.5.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 (139) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/scenario-runner/adapters/connection-config.d.ts +34 -0
  6. package/dist/scenario-runner/adapters/connection-config.d.ts.map +1 -0
  7. package/dist/scenario-runner/adapters/connection-config.js +6 -0
  8. package/dist/scenario-runner/adapters/connection-config.js.map +1 -0
  9. package/dist/scenario-runner/adapters/db-executor.d.ts +4 -0
  10. package/dist/scenario-runner/adapters/db-executor.d.ts.map +1 -0
  11. package/dist/scenario-runner/adapters/db-executor.js +42 -0
  12. package/dist/scenario-runner/adapters/db-executor.js.map +1 -0
  13. package/dist/scenario-runner/adapters/helpers/abort.d.ts +4 -0
  14. package/dist/scenario-runner/adapters/helpers/abort.d.ts.map +1 -0
  15. package/dist/scenario-runner/adapters/helpers/abort.js +47 -0
  16. package/dist/scenario-runner/adapters/helpers/abort.js.map +1 -0
  17. package/dist/scenario-runner/adapters/helpers/failure-messages.d.ts +29 -0
  18. package/dist/scenario-runner/adapters/helpers/failure-messages.d.ts.map +1 -0
  19. package/dist/scenario-runner/adapters/helpers/failure-messages.js +64 -0
  20. package/dist/scenario-runner/adapters/helpers/failure-messages.js.map +1 -0
  21. package/dist/scenario-runner/adapters/helpers/mutations.d.ts +7 -0
  22. package/dist/scenario-runner/adapters/helpers/mutations.d.ts.map +1 -0
  23. package/dist/scenario-runner/adapters/helpers/mutations.js +28 -0
  24. package/dist/scenario-runner/adapters/helpers/mutations.js.map +1 -0
  25. package/dist/scenario-runner/adapters/helpers/request-helpers.d.ts +31 -0
  26. package/dist/scenario-runner/adapters/helpers/request-helpers.d.ts.map +1 -0
  27. package/dist/scenario-runner/adapters/helpers/request-helpers.js +247 -0
  28. package/dist/scenario-runner/adapters/helpers/request-helpers.js.map +1 -0
  29. package/dist/scenario-runner/adapters/helpers/response-shapes.d.ts +3 -0
  30. package/dist/scenario-runner/adapters/helpers/response-shapes.d.ts.map +1 -0
  31. package/dist/scenario-runner/adapters/helpers/response-shapes.js +32 -0
  32. package/dist/scenario-runner/adapters/helpers/response-shapes.js.map +1 -0
  33. package/dist/scenario-runner/adapters/helpers/templates.d.ts +2 -0
  34. package/dist/scenario-runner/adapters/helpers/templates.d.ts.map +1 -0
  35. package/dist/scenario-runner/adapters/helpers/templates.js +30 -0
  36. package/dist/scenario-runner/adapters/helpers/templates.js.map +1 -0
  37. package/dist/scenario-runner/adapters/index.d.ts +12 -0
  38. package/dist/scenario-runner/adapters/index.d.ts.map +1 -0
  39. package/dist/scenario-runner/adapters/index.js +30 -0
  40. package/dist/scenario-runner/adapters/index.js.map +1 -0
  41. package/dist/scenario-runner/adapters/kafka-executor.d.ts +4 -0
  42. package/dist/scenario-runner/adapters/kafka-executor.d.ts.map +1 -0
  43. package/dist/scenario-runner/adapters/kafka-executor.js +35 -0
  44. package/dist/scenario-runner/adapters/kafka-executor.js.map +1 -0
  45. package/dist/scenario-runner/adapters/notification-executor.d.ts +4 -0
  46. package/dist/scenario-runner/adapters/notification-executor.d.ts.map +1 -0
  47. package/dist/scenario-runner/adapters/notification-executor.js +67 -0
  48. package/dist/scenario-runner/adapters/notification-executor.js.map +1 -0
  49. package/dist/scenario-runner/adapters/redis-executor.d.ts +4 -0
  50. package/dist/scenario-runner/adapters/redis-executor.d.ts.map +1 -0
  51. package/dist/scenario-runner/adapters/redis-executor.js +78 -0
  52. package/dist/scenario-runner/adapters/redis-executor.js.map +1 -0
  53. package/dist/scenario-runner/adapters/request-executor.d.ts +4 -0
  54. package/dist/scenario-runner/adapters/request-executor.d.ts.map +1 -0
  55. package/dist/scenario-runner/adapters/request-executor.js +262 -0
  56. package/dist/scenario-runner/adapters/request-executor.js.map +1 -0
  57. package/dist/scenario-runner/adapters/script-executor.d.ts +4 -0
  58. package/dist/scenario-runner/adapters/script-executor.d.ts.map +1 -0
  59. package/dist/scenario-runner/adapters/script-executor.js +113 -0
  60. package/dist/scenario-runner/adapters/script-executor.js.map +1 -0
  61. package/dist/scenario-runner/adapters/types.d.ts +82 -0
  62. package/dist/scenario-runner/adapters/types.d.ts.map +1 -0
  63. package/dist/scenario-runner/adapters/types.js +9 -0
  64. package/dist/scenario-runner/adapters/types.js.map +1 -0
  65. package/dist/scenario-runner/index.d.ts +1 -0
  66. package/dist/scenario-runner/index.d.ts.map +1 -1
  67. package/dist/scenario-runner/index.js +1 -0
  68. package/dist/scenario-runner/index.js.map +1 -1
  69. package/dist/templating/counter-store.d.ts +7 -0
  70. package/dist/templating/counter-store.d.ts.map +1 -0
  71. package/dist/templating/counter-store.js +64 -0
  72. package/dist/templating/counter-store.js.map +1 -0
  73. package/dist/templating/generator-metadata.d.ts +5 -0
  74. package/dist/templating/generator-metadata.d.ts.map +1 -0
  75. package/dist/templating/generator-metadata.js +102 -0
  76. package/dist/templating/generator-metadata.js.map +1 -0
  77. package/dist/templating/index.d.ts +6 -0
  78. package/dist/templating/index.d.ts.map +1 -0
  79. package/dist/templating/index.js +11 -0
  80. package/dist/templating/index.js.map +1 -0
  81. package/dist/templating/random-generators.d.ts +10 -0
  82. package/dist/templating/random-generators.d.ts.map +1 -0
  83. package/dist/templating/random-generators.js +16 -0
  84. package/dist/templating/random-generators.js.map +1 -0
  85. package/dist/templating/template-engine.d.ts +14 -0
  86. package/dist/templating/template-engine.d.ts.map +1 -0
  87. package/dist/templating/template-engine.js +148 -0
  88. package/dist/templating/template-engine.js.map +1 -0
  89. package/dist/templating/types.d.ts +22 -0
  90. package/dist/templating/types.d.ts.map +1 -0
  91. package/dist/templating/types.js +10 -0
  92. package/dist/templating/types.js.map +1 -0
  93. package/dist-cjs/index.js +2 -4
  94. package/dist-cjs/index.js.map +1 -1
  95. package/dist-cjs/scenario-runner/adapters/connection-config.js +7 -0
  96. package/dist-cjs/scenario-runner/adapters/connection-config.js.map +1 -0
  97. package/dist-cjs/scenario-runner/adapters/db-executor.js +46 -0
  98. package/dist-cjs/scenario-runner/adapters/db-executor.js.map +1 -0
  99. package/dist-cjs/scenario-runner/adapters/helpers/abort.js +52 -0
  100. package/dist-cjs/scenario-runner/adapters/helpers/abort.js.map +1 -0
  101. package/dist-cjs/scenario-runner/adapters/helpers/failure-messages.js +69 -0
  102. package/dist-cjs/scenario-runner/adapters/helpers/failure-messages.js.map +1 -0
  103. package/dist-cjs/scenario-runner/adapters/helpers/mutations.js +32 -0
  104. package/dist-cjs/scenario-runner/adapters/helpers/mutations.js.map +1 -0
  105. package/dist-cjs/scenario-runner/adapters/helpers/request-helpers.js +263 -0
  106. package/dist-cjs/scenario-runner/adapters/helpers/request-helpers.js.map +1 -0
  107. package/dist-cjs/scenario-runner/adapters/helpers/response-shapes.js +36 -0
  108. package/dist-cjs/scenario-runner/adapters/helpers/response-shapes.js.map +1 -0
  109. package/dist-cjs/scenario-runner/adapters/helpers/templates.js +34 -0
  110. package/dist-cjs/scenario-runner/adapters/helpers/templates.js.map +1 -0
  111. package/dist-cjs/scenario-runner/adapters/index.js +40 -0
  112. package/dist-cjs/scenario-runner/adapters/index.js.map +1 -0
  113. package/dist-cjs/scenario-runner/adapters/kafka-executor.js +39 -0
  114. package/dist-cjs/scenario-runner/adapters/kafka-executor.js.map +1 -0
  115. package/dist-cjs/scenario-runner/adapters/notification-executor.js +71 -0
  116. package/dist-cjs/scenario-runner/adapters/notification-executor.js.map +1 -0
  117. package/dist-cjs/scenario-runner/adapters/redis-executor.js +82 -0
  118. package/dist-cjs/scenario-runner/adapters/redis-executor.js.map +1 -0
  119. package/dist-cjs/scenario-runner/adapters/request-executor.js +266 -0
  120. package/dist-cjs/scenario-runner/adapters/request-executor.js.map +1 -0
  121. package/dist-cjs/scenario-runner/adapters/script-executor.js +117 -0
  122. package/dist-cjs/scenario-runner/adapters/script-executor.js.map +1 -0
  123. package/dist-cjs/scenario-runner/adapters/types.js +10 -0
  124. package/dist-cjs/scenario-runner/adapters/types.js.map +1 -0
  125. package/dist-cjs/scenario-runner/index.js +1 -0
  126. package/dist-cjs/scenario-runner/index.js.map +1 -1
  127. package/dist-cjs/templating/counter-store.js +72 -0
  128. package/dist-cjs/templating/counter-store.js.map +1 -0
  129. package/dist-cjs/templating/generator-metadata.js +105 -0
  130. package/dist-cjs/templating/generator-metadata.js.map +1 -0
  131. package/dist-cjs/templating/index.js +35 -0
  132. package/dist-cjs/templating/index.js.map +1 -0
  133. package/dist-cjs/templating/random-generators.js +28 -0
  134. package/dist-cjs/templating/random-generators.js.map +1 -0
  135. package/dist-cjs/templating/template-engine.js +155 -0
  136. package/dist-cjs/templating/template-engine.js.map +1 -0
  137. package/dist-cjs/templating/types.js +11 -0
  138. package/dist-cjs/templating/types.js.map +1 -0
  139. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis-executor.js","sourceRoot":"","sources":["../../../src/scenario-runner/adapters/redis-executor.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,4DAA4D;AAC5D,uEAAuE;AACvE,gEAAgE;AAChE,EAAE;AACF,gCAAgC;AAChC,mEAAmE;AACnE,oDAAoD;AACpD,kDAAkD;AAClD,iCAAiC;AAQjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAGzD,MAAM,mBAAmB,GAAG,CAAC,KAAc,EAAU,EAAE;IACrD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC5D,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,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G,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAElD,OAAO;YACL,cAAc;YACd,WAAW;YACX,UAAU,EAAE,WAAW;YACvB,cAAc,EAAE,IAAI;SACrB,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,cAAc,CAAC,IAAI,CAAC;YAClB,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,IAAI;YACZ,UAAU,EAAE,EAAE;YACd,KAAK,EAAE,OAAO;SACf,CAAC,CAAC;QACH,OAAO;YACL,cAAc;YACd,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE;YACxC,cAAc,EAAE,OAAO,IAAI,uBAAuB;SACnD,CAAC;IACJ,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ScenarioRequestExecutionInput, ScenarioRequestExecutionResult } from "../types.js";
2
+ import type { ScenarioRuntimeAdapterFactoryOptions } from "./types.js";
3
+ export declare const buildRequestExecutor: (options: ScenarioRuntimeAdapterFactoryOptions) => (input: ScenarioRequestExecutionInput) => Promise<ScenarioRequestExecutionResult>;
4
+ //# sourceMappingURL=request-executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-executor.d.ts","sourceRoot":"","sources":["../../../src/scenario-runner/adapters/request-executor.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACV,6BAA6B,EAC7B,8BAA8B,EAE/B,MAAM,aAAa,CAAC;AAuBrB,OAAO,KAAK,EAEV,oCAAoC,EACrC,MAAM,YAAY,CAAC;AAiBpB,eAAO,MAAM,oBAAoB,GAC/B,SAAS,oCAAoC,MAEtC,OAAO,6BAA6B,KAAG,OAAO,CAAC,8BAA8B,CA8OnF,CAAC"}
@@ -0,0 +1,262 @@
1
+ // Canonical request executor — orchestrates a single Request scenario node:
2
+ // 1. (optional) pre-request script → mutate environment/globals/request
3
+ // 2. resolve auth + templates + body → executable shape
4
+ // 3. (optional) Kafka prefetch — start consumer, run HTTP, capture matched message
5
+ // 4. fall through to plain HTTP when no prefetch is configured
6
+ // 5. (optional) post-response script → mutate env/globals
7
+ // 6. (optional) tests script → collect test results, mutate env/globals
8
+ // 7. validate contract assertions
9
+ // 8. assemble failure message + return ScenarioRequestExecutionResult
10
+ //
11
+ // Driver injection point: `httpExecutor` and `kafkaExecutor`. Everything
12
+ // else (script execution, contract validation, template resolution) uses
13
+ // canonical core utilities.
14
+ import { buildScenarioTemplateValues, resolveScenarioJsonTemplateString, resolveScenarioTemplateString, replaceScenarioTemplateTokensForJsonValidation, } from "../templateResolver.js";
15
+ import { validateContracts } from "../../contract/contractValidator.js";
16
+ import { withAbortAndTimeout } from "./helpers/abort.js";
17
+ import { buildRequestFailureMessage, summarizeContractResults, } from "./helpers/failure-messages.js";
18
+ import { applyVariableMutations } from "./helpers/mutations.js";
19
+ import { buildResponseRoot } from "./helpers/response-shapes.js";
20
+ import { createRequestStateFromNode, normalizeExecuteRequestFailure, normalizeRequestForExecution, toRequestResponse, toRequestScriptResponse, } from "./helpers/request-helpers.js";
21
+ const buildBodyResolverHelpers = () => ({
22
+ replaceScenarioTemplateTokensForJsonValidation,
23
+ resolveScenarioJsonTemplateString,
24
+ resolveScenarioTemplateString,
25
+ });
26
+ const httpResultToExecuteRequestResult = (http) => ({
27
+ status: http.status,
28
+ data: http.data,
29
+ headers: http.headers,
30
+ duration: http.duration,
31
+ });
32
+ export const buildRequestExecutor = (options) => async (input) => {
33
+ // We can't directly call the canonical scriptExecutor from here —
34
+ // it lives on the same factory result and may be the host's override.
35
+ // Instead, we receive it via closure when the factory wires up.
36
+ // For now, we depend on the host's `scriptExecutor` being supplied
37
+ // via options so request-stage scripts run through whatever sandbox
38
+ // the host configured.
39
+ //
40
+ // Note: the script executor in this orchestration path runs *request
41
+ // stage* scripts (pre-request / post-response / tests). The default
42
+ // implementation in script-executor.ts knows how to dispatch to the
43
+ // canonical sandbox; hosts that want to customize override it.
44
+ const requestState = createRequestStateFromNode(input.node);
45
+ const scopes = {
46
+ environment: { ...input.context.environment },
47
+ globals: { ...input.context.globals },
48
+ };
49
+ let currentRequestState = requestState;
50
+ const runRequestStageScript = async (stage, script, response) => {
51
+ // The host's scriptExecutor adapter handles request-stage scripts
52
+ // when it receives a payload with `stage !== "script"`. We delegate
53
+ // through the same adapter shape that runScenario uses so behavior
54
+ // matches the script-only flow exactly.
55
+ const scriptResult = await invokeRequestStageScript(options, {
56
+ stage,
57
+ script,
58
+ timeoutMs: options.scriptTimeoutMs,
59
+ request: currentRequestState,
60
+ response: response
61
+ ? toRequestScriptResponse(response)
62
+ : null,
63
+ environment: scopes.environment,
64
+ globals: scopes.globals,
65
+ workflowContext: input.context.workflowContext,
66
+ nodeMetaByLabel: input.context.nodeMetaByLabel,
67
+ });
68
+ if (scriptResult.request) {
69
+ currentRequestState = scriptResult.request;
70
+ }
71
+ applyVariableMutations(scopes, scriptResult.variableMutations);
72
+ return scriptResult;
73
+ };
74
+ // 1. Pre-request script ------------------------------------------------
75
+ if (input.node.data.config.preRequestScript?.trim()) {
76
+ const preResult = await runRequestStageScript("pre-request", input.node.data.config.preRequestScript, null);
77
+ if (preResult.error) {
78
+ const failureResponse = toRequestResponse(normalizeExecuteRequestFailure(preResult.error.message));
79
+ return {
80
+ cancelled: false,
81
+ response: failureResponse,
82
+ responseRoot: null,
83
+ environment: scopes.environment,
84
+ globals: scopes.globals,
85
+ outputData: null,
86
+ testResults: preResult.testResults,
87
+ contractResults: [],
88
+ contractSummary: null,
89
+ contractValidationError: null,
90
+ dbAssertionResults: [],
91
+ redisAssertionResults: [],
92
+ prefetchedKafkaResults: [],
93
+ failureMessage: `Pre-request script failed: ${preResult.error.message}`,
94
+ };
95
+ }
96
+ }
97
+ // 2. Resolve templates + auth + body ----------------------------------
98
+ const templateValues = buildScenarioTemplateValues({
99
+ environment: scopes.environment,
100
+ globals: scopes.globals,
101
+ workflowContext: input.context.workflowContext,
102
+ nodeMetaByLabel: input.context.nodeMetaByLabel,
103
+ responseRoot: input.context.responseRoot,
104
+ dbResult: input.context.dbResult,
105
+ kafkaEvent: input.context.kafkaEvent,
106
+ redisResult: input.context.redisResult,
107
+ });
108
+ const runtimeRequest = normalizeRequestForExecution(currentRequestState, input.node.data.config.auth, buildBodyResolverHelpers(), templateValues);
109
+ // 3+4. Execute the HTTP call (with optional Kafka prefetch) -----------
110
+ const requestTimeoutMs = options.requestTimeoutMs;
111
+ const runHttp = async () => {
112
+ try {
113
+ const httpResult = await withAbortAndTimeout(options.drivers.httpExecutor({
114
+ method: runtimeRequest.method,
115
+ url: runtimeRequest.url,
116
+ headers: runtimeRequest.headers,
117
+ query: runtimeRequest.query,
118
+ body: runtimeRequest.body,
119
+ timeoutMs: requestTimeoutMs,
120
+ }), requestTimeoutMs, `Request node ${input.stepId}`, input.signal);
121
+ return httpResultToExecuteRequestResult(httpResult);
122
+ }
123
+ catch (error) {
124
+ return normalizeExecuteRequestFailure(error);
125
+ }
126
+ };
127
+ let executionResult;
128
+ let prefetchedKafkaResults = [];
129
+ const transientCapture = input.kafkaCapturePlans.length === 1 ? input.kafkaCapturePlans[0] ?? null : null;
130
+ if (transientCapture?.connectionId && transientCapture.topic.trim()) {
131
+ try {
132
+ const kafkaConnection = await options.resolveConnection(transientCapture.connectionId);
133
+ const captureResult = await options.drivers.kafkaExecutor({
134
+ connection: kafkaConnection,
135
+ topic: transientCapture.topic.trim(),
136
+ matcher: null,
137
+ timeoutMs: options.nodeTimeoutMs,
138
+ operation: async () => {
139
+ const er = await runHttp();
140
+ return {
141
+ status: er.status,
142
+ headers: er.headers,
143
+ data: er.data,
144
+ duration: er.duration,
145
+ };
146
+ },
147
+ });
148
+ executionResult = captureResult.operationResult
149
+ ? httpResultToExecuteRequestResult(captureResult.operationResult)
150
+ : await runHttp();
151
+ prefetchedKafkaResults = input.kafkaCapturePlans.map((plan) => ({
152
+ stepId: plan.stepId,
153
+ result: captureResult.capture,
154
+ }));
155
+ }
156
+ catch {
157
+ // Kafka prefetch setup failed — fall through to plain HTTP.
158
+ // Backend's existing behavior is to silently degrade and rely
159
+ // on a separate kafka node (if any) to report the issue.
160
+ executionResult = await runHttp();
161
+ }
162
+ }
163
+ else {
164
+ executionResult = await runHttp();
165
+ }
166
+ const response = toRequestResponse(executionResult);
167
+ const combinedTestResults = [];
168
+ // 5. Post-response script ---------------------------------------------
169
+ let postResponseError = null;
170
+ if (input.node.data.config.postResponseScript?.trim()) {
171
+ const postResult = await runRequestStageScript("post-response", input.node.data.config.postResponseScript, response);
172
+ combinedTestResults.push(...postResult.testResults);
173
+ if (postResult.error) {
174
+ postResponseError = { message: postResult.error.message };
175
+ }
176
+ }
177
+ // 6. Tests script -----------------------------------------------------
178
+ let testsError = null;
179
+ if (input.node.data.config.testsScript?.trim()) {
180
+ const testsResult = await runRequestStageScript("tests", input.node.data.config.testsScript, response);
181
+ combinedTestResults.push(...testsResult.testResults);
182
+ if (testsResult.error) {
183
+ testsError = { message: testsResult.error.message };
184
+ }
185
+ }
186
+ // 7. Contract validation ----------------------------------------------
187
+ const contractResults = validateContracts(input.node.data.config.contractAssertions ?? [], {
188
+ status: executionResult.status,
189
+ data: executionResult.data,
190
+ headers: executionResult.headers,
191
+ duration: executionResult.duration,
192
+ });
193
+ const contractCounts = summarizeContractResults(contractResults);
194
+ const contractSummary = {
195
+ total: contractCounts.total,
196
+ passed: contractCounts.passed,
197
+ failed: contractCounts.failed,
198
+ };
199
+ // 8. Failure message + return -----------------------------------------
200
+ const failureMessage = buildRequestFailureMessage({
201
+ response,
202
+ postResponseError,
203
+ testsError,
204
+ testResults: combinedTestResults,
205
+ contractResults,
206
+ });
207
+ const responseRoot = buildResponseRoot(response);
208
+ return {
209
+ cancelled: Boolean(input.signal?.aborted),
210
+ response,
211
+ responseRoot,
212
+ environment: scopes.environment,
213
+ globals: scopes.globals,
214
+ outputData: responseRoot,
215
+ testResults: combinedTestResults,
216
+ contractResults,
217
+ contractSummary,
218
+ contractValidationError: null,
219
+ dbAssertionResults: [],
220
+ redisAssertionResults: [],
221
+ prefetchedKafkaResults,
222
+ failureMessage,
223
+ };
224
+ };
225
+ // ---------------------------------------------------------------------
226
+ // Request-stage script invocation. The host supplies a script executor
227
+ // either as `options.scriptExecutor` (which handles the standalone
228
+ // "script" stage from runScenario) or via the dedicated request-stage
229
+ // hook below. Default routes to the canonical executeScript with the
230
+ // "stage" capability set so pre/post/test scripts get the request +
231
+ // response surface they expect.
232
+ // ---------------------------------------------------------------------
233
+ import { executeScript } from "../../script/executor.js";
234
+ const invokeRequestStageScript = async (options, input) => {
235
+ // Hosts can swap the request-stage script behavior by overriding
236
+ // `scriptExecutor` and inspecting the input to dispatch to their own
237
+ // pre/post/tests handler. In this default path we go directly to the
238
+ // canonical sandbox.
239
+ const result = await executeScript({
240
+ script: input.script,
241
+ timeoutMs: input.timeoutMs,
242
+ filename: "callman-request.script.js",
243
+ stage: input.stage,
244
+ capabilities: {
245
+ environment: { values: input.environment, emitMutations: true },
246
+ globals: { values: input.globals, emitMutations: true },
247
+ request: input.request,
248
+ response: input.response ?? undefined,
249
+ workflowContext: input.workflowContext,
250
+ nodeMetaByLabel: input.nodeMetaByLabel,
251
+ exposeLabelsAsGlobals: true,
252
+ extensions: { log: true, node: true },
253
+ },
254
+ });
255
+ return {
256
+ request: result.request,
257
+ variableMutations: result.variableMutations,
258
+ testResults: result.testResults,
259
+ error: result.error,
260
+ };
261
+ };
262
+ //# sourceMappingURL=request-executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-executor.js","sourceRoot":"","sources":["../../../src/scenario-runner/adapters/request-executor.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,0EAA0E;AAC1E,0DAA0D;AAC1D,qFAAqF;AACrF,iEAAiE;AACjE,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Aa,EAAE,IAAI,EAAE;YAC/D,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE;YACvD,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,SAAS;YACrC,eAAe,EAAE,KAAK,CAAC,eAAe;YACtC,eAAe,EAAE,KAAK,CAAC,eAAoD;YAC3E,qBAAqB,EAAE,IAAI;YAC3B,UAAU,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE;SACtC;KACF,CAAC,CAAC;IAEH,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;QAC3C,WAAW,EAAE,MAAM,CAAC,WAAiC;QACrD,KAAK,EAAE,MAAM,CAAC,KAAK;KACpB,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ScenarioScriptExecutionInput, ScenarioScriptExecutionResult } from "../types.js";
2
+ import type { ScenarioRuntimeAdapterFactoryOptions } from "./types.js";
3
+ export declare const buildScriptExecutor: (options: ScenarioRuntimeAdapterFactoryOptions) => (input: ScenarioScriptExecutionInput) => Promise<ScenarioScriptExecutionResult>;
4
+ //# sourceMappingURL=script-executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"script-executor.d.ts","sourceRoot":"","sources":["../../../src/scenario-runner/adapters/script-executor.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,4BAA4B,EAC5B,6BAA6B,EAE9B,MAAM,aAAa,CAAC;AAOrB,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,YAAY,CAAC;AAkBvE,eAAO,MAAM,mBAAmB,GAC9B,SAAS,oCAAoC,MAEtC,OAAO,4BAA4B,KAAG,OAAO,CAAC,6BAA6B,CA4GjF,CAAC"}
@@ -0,0 +1,113 @@
1
+ // Canonical script executor — orchestrates a standalone Script scenario
2
+ // node. Wraps callman-core's `executeScript` with scenario-specific
3
+ // input mapping + post-processing:
4
+ // - mutation values get template-resolved against the live runtime
5
+ // scope (so `pm.environment.set("token", "{{response.data.token}}")`
6
+ // works even though the script sandbox doesn't see the runtime
7
+ // scope directly)
8
+ // - return value gets deep template-resolved
9
+ // - failed pm.test entries surface in `failureMessage` for the runner
10
+ import { buildScenarioTemplateValues, resolveScenarioTemplateString } from "../templateResolver.js";
11
+ import { executeScript } from "../../script/executor.js";
12
+ import { withAbortAndTimeout } from "./helpers/abort.js";
13
+ import { resolveScenarioScriptTemplatesDeep } from "./helpers/templates.js";
14
+ const toScenarioMutation = (mutation) => mutation.type === "set"
15
+ ? {
16
+ scope: mutation.scope,
17
+ type: "set",
18
+ key: mutation.key,
19
+ value: mutation.value,
20
+ }
21
+ : {
22
+ scope: mutation.scope,
23
+ type: "unset",
24
+ key: mutation.key,
25
+ };
26
+ export const buildScriptExecutor = (options) => async (input) => {
27
+ const script = input.node.data.config.script;
28
+ const baseTimeoutMs = Math.min(options.nodeTimeoutMs, input.node.data.config.timeoutMs ?? options.scriptTimeoutMs);
29
+ if (!script.trim()) {
30
+ return {
31
+ variableMutations: [],
32
+ testResults: [],
33
+ logs: [],
34
+ error: {
35
+ stage: "script",
36
+ message: "Script node is empty.",
37
+ lineNumber: null,
38
+ column: null,
39
+ stack: null,
40
+ },
41
+ hasReturnValue: false,
42
+ returnValue: null,
43
+ outputData: null,
44
+ scriptSource: script,
45
+ timeoutMs: baseTimeoutMs,
46
+ failureMessage: "Script node is empty.",
47
+ };
48
+ }
49
+ const scriptResult = await withAbortAndTimeout(executeScript({
50
+ script,
51
+ timeoutMs: baseTimeoutMs,
52
+ filename: "callman-scenario.script.js",
53
+ stage: "script",
54
+ capabilities: {
55
+ environment: { values: input.context.environment, emitMutations: true },
56
+ globals: { values: input.context.globals, emitMutations: true },
57
+ workflowContext: input.context.workflowContext,
58
+ nodeMetaByLabel: input.context.nodeMetaByLabel,
59
+ exposeLabelsAsGlobals: true,
60
+ extensions: { log: true, node: true },
61
+ },
62
+ }), baseTimeoutMs, `Script node ${input.stepId}`, input.signal);
63
+ // Templates may contain `{{...}}` tokens that reference live runtime
64
+ // values not available inside the sandbox (response.body, db.result,
65
+ // etc.). Resolve them against the current scenario runtime scope
66
+ // *after* the script returns so node consumers see substituted text.
67
+ const templateValues = buildScenarioTemplateValues({
68
+ environment: input.context.environment,
69
+ globals: input.context.globals,
70
+ workflowContext: input.context.workflowContext,
71
+ nodeMetaByLabel: input.context.nodeMetaByLabel,
72
+ responseRoot: input.context.responseRoot,
73
+ dbResult: input.context.dbResult,
74
+ kafkaEvent: input.context.kafkaEvent,
75
+ redisResult: input.context.redisResult,
76
+ });
77
+ const resolvedMutations = scriptResult.variableMutations.map((mutation) => mutation.type === "set" && typeof mutation.value === "string"
78
+ ? {
79
+ ...mutation,
80
+ value: resolveScenarioTemplateString(mutation.value, templateValues),
81
+ }
82
+ : mutation);
83
+ const resolvedReturnValue = scriptResult.hasReturnValue
84
+ ? resolveScenarioScriptTemplatesDeep(scriptResult.returnValue, templateValues, resolveScenarioTemplateString)
85
+ : null;
86
+ const failedScriptTest = scriptResult.testResults.find((entry) => entry.status === "FAIL");
87
+ const failureMessage = scriptResult.error
88
+ ? scriptResult.error.message
89
+ : failedScriptTest
90
+ ? failedScriptTest.error
91
+ ? `Script test failed: ${failedScriptTest.name} (${failedScriptTest.error})`
92
+ : `Script test failed: ${failedScriptTest.name}`
93
+ : null;
94
+ return {
95
+ variableMutations: resolvedMutations.map(toScenarioMutation),
96
+ testResults: scriptResult.testResults,
97
+ logs: scriptResult.logs,
98
+ error: scriptResult.error,
99
+ hasReturnValue: scriptResult.hasReturnValue,
100
+ returnValue: resolvedReturnValue,
101
+ outputData: {
102
+ ...(scriptResult.hasReturnValue ? { returnValue: resolvedReturnValue } : {}),
103
+ testResults: scriptResult.testResults,
104
+ logs: scriptResult.logs,
105
+ variableMutations: resolvedMutations.map(toScenarioMutation),
106
+ error: scriptResult.error,
107
+ },
108
+ scriptSource: script,
109
+ timeoutMs: baseTimeoutMs,
110
+ failureMessage,
111
+ };
112
+ };
113
+ //# sourceMappingURL=script-executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"script-executor.js","sourceRoot":"","sources":["../../../src/scenario-runner/adapters/script-executor.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,oEAAoE;AACpE,mCAAmC;AACnC,qEAAqE;AACrE,yEAAyE;AACzE,mEAAmE;AACnE,sBAAsB;AACtB,+CAA+C;AAC/C,wEAAwE;AAOxE,OAAO,EAAE,2BAA2B,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AACpG,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,kCAAkC,EAAE,MAAM,wBAAwB,CAAC;AAG5E,MAAM,kBAAkB,GAAG,CACzB,QAAgC,EACN,EAAE,CAC5B,QAAQ,CAAC,IAAI,KAAK,KAAK;IACrB,CAAC,CAAC;QACE,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,IAAI,EAAE,KAAK;QACX,GAAG,EAAE,QAAQ,CAAC,GAAG;QACjB,KAAK,EAAE,QAAQ,CAAC,KAAK;KACtB;IACH,CAAC,CAAC;QACE,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,IAAI,EAAE,OAAO;QACb,GAAG,EAAE,QAAQ,CAAC,GAAG;KAClB,CAAC;AAER,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,OAA6C,EAC7C,EAAE,CACF,KAAK,EAAE,KAAmC,EAA0C,EAAE;IACpF,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC7C,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAC5B,OAAO,CAAC,aAAa,EACrB,KAAK,CAAC,IAAI,C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CAAC,uBAAuB,gBAAgB,CAAC,IAAI,KAAK,gBAAgB,CAAC,KAAK,GAAG;gBAC5E,CAAC,CAAC,uBAAuB,gBAAgB,CAAC,IAAI,EAAE;YAClD,CAAC,CAAC,IAAI,CAAC;IAEX,OAAO;QACL,iBAAiB,EAAE,iBAAiB,CAAC,GAAG,CAAC,kBAAkB,CAAC;QAC5D,WAAW,EAAE,YAAY,CAAC,WAAW;QACrC,IAAI,EAAE,YAAY,CAAC,IAAI;QACvB,KAAK,EAAE,YAAY,CAAC,KAAK;QACzB,cAAc,EAAE,YAAY,CAAC,cAAc;QAC3C,WAAW,EAAE,mBAAmB;QAChC,UAAU,EAAE;YACV,GAAG,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5E,WAAW,EAAE,YAAY,CAAC,WAAW;YACrC,IAAI,EAAE,YAAY,CAAC,IAAI;YACvB,iBAAiB,EAAE,iBAAiB,CAAC,GAAG,CAAC,kBAAkB,CAAC;YAC5D,KAAK,EAAE,YAAY,CAAC,KAAK;SAC1B;QACD,YAAY,EAAE,MAAM;QACpB,SAAS,EAAE,aAAa;QACxB,cAAc;KACf,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,82 @@
1
+ import type { DatabaseConnectionConfig, KafkaConnectionConfig, NotificationConnectionConfig, RedisConnectionConfig } from "./connection-config.js";
2
+ import type { ScenarioKafkaCaptureResult, ScenarioKafkaCapturedMessage } from "../types.js";
3
+ export type ScenarioConnectionType = "database" | "redis" | "kafka" | "notification";
4
+ export type ScenarioConnectionProvider = "oracle" | "mongodb" | "postgresql" | "mysql" | "redis" | "kafka" | "slack";
5
+ export interface ScenarioConnectionRuntime {
6
+ id: string;
7
+ workspaceId: string;
8
+ type: ScenarioConnectionType;
9
+ provider: ScenarioConnectionProvider;
10
+ name: string;
11
+ config: DatabaseConnectionConfig | RedisConnectionConfig | KafkaConnectionConfig | NotificationConnectionConfig;
12
+ }
13
+ export interface HttpExecuteInput {
14
+ method: string;
15
+ url: string;
16
+ headers?: Record<string, string>;
17
+ query?: Record<string, string>;
18
+ body?: unknown;
19
+ timeoutMs?: number;
20
+ }
21
+ export interface HttpExecuteResult {
22
+ status: number;
23
+ data: unknown;
24
+ headers: Record<string, string>;
25
+ duration: number;
26
+ }
27
+ export interface DatabaseExecuteInput {
28
+ connection: ScenarioConnectionRuntime;
29
+ resolvedQuery: string;
30
+ }
31
+ export interface DatabaseExecuteResult {
32
+ rows: unknown[];
33
+ rowCount: number;
34
+ }
35
+ export interface RedisExecuteInput {
36
+ connection: ScenarioConnectionRuntime;
37
+ resolvedCommands: string[];
38
+ }
39
+ export interface RedisCommandOutcome {
40
+ command: string;
41
+ result: unknown;
42
+ durationMs: number;
43
+ }
44
+ export type RedisExecuteResult = RedisCommandOutcome[];
45
+ export interface KafkaCaptureInput {
46
+ connection: ScenarioConnectionRuntime;
47
+ topic: string;
48
+ matcher: {
49
+ mode: "regex" | "rules";
50
+ rules: string[];
51
+ templateValues: Record<string, string>;
52
+ } | null;
53
+ timeoutMs: number;
54
+ operation?: () => Promise<HttpExecuteResult>;
55
+ }
56
+ export interface KafkaCaptureOutcome {
57
+ capture: ScenarioKafkaCaptureResult;
58
+ matched: ScenarioKafkaCapturedMessage | null;
59
+ operationResult?: HttpExecuteResult;
60
+ }
61
+ export interface ScenarioRuntimeAdapterDrivers {
62
+ httpExecutor: (input: HttpExecuteInput) => Promise<HttpExecuteResult>;
63
+ databaseExecutor: (input: DatabaseExecuteInput) => Promise<DatabaseExecuteResult>;
64
+ redisExecutor: (input: RedisExecuteInput) => Promise<RedisExecuteResult>;
65
+ kafkaExecutor: (input: KafkaCaptureInput) => Promise<KafkaCaptureOutcome>;
66
+ }
67
+ export interface ScenarioRuntimeAdapterFactoryOptions {
68
+ workspaceId: string;
69
+ requestTimeoutMs: number;
70
+ nodeTimeoutMs: number;
71
+ scriptTimeoutMs: number;
72
+ drivers: ScenarioRuntimeAdapterDrivers;
73
+ resolveConnection: (connectionId: string) => Promise<ScenarioConnectionRuntime>;
74
+ scriptExecutor?: ScenarioRuntimeAdapters["scriptExecutor"];
75
+ notificationExecutor?: ScenarioRuntimeAdapters["notificationExecutor"];
76
+ }
77
+ export type { ScenarioRuntimeAdapters } from "../types.js";
78
+ export interface ExecutorContext {
79
+ options: ScenarioRuntimeAdapterFactoryOptions;
80
+ }
81
+ import type { ScenarioRuntimeAdapters } from "../types.js";
82
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/scenario-runner/adapters/types.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,wBAAwB,EACxB,qBAAqB,EACrB,4BAA4B,EAC5B,qBAAqB,EACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EACV,0BAA0B,EAC1B,4BAA4B,EAE7B,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,sBAAsB,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,cAAc,CAAC;AAErF,MAAM,MAAM,0BAA0B,GAClC,QAAQ,GACR,SAAS,GACT,YAAY,GACZ,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,CAAC;AAEZ,MAAM,WAAW,yBAAyB;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,sBAAsB,CAAC;IAC7B,QAAQ,EAAE,0BAA0B,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EACF,wBAAwB,GACxB,qBAAqB,GACrB,qBAAqB,GACrB,4BAA4B,CAAC;CAClC;AAOD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,KAAK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AA4B,GAAG,IAAI,CAAC;IAE7C,eAAe,CAAC,EAAE,iBAAiB,CAAC;CACrC;AAID,MAAM,WAAW,6BAA6B;IAC5C,YAAY,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACtE,gBAAgB,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAClF,aAAa,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACzE,aAAa,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAC3E;AAED,MAAM,WAAW,oCAAoC;IACnD,WAAW,EAAE,MAAM,CAAC;IAEpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IAExB,OAAO,EAAE,6BAA6B,CAAC;IAEvC,iBAAiB,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAKhF,cAAc,CAAC,EAAE,uBAAuB,CAAC,gBAAgB,CAAC,CAAC;IAC3D,oBAAoB,CAAC,EAAE,uBAAuB,CAAC,sBAAsB,CAAC,CAAC;CACxE;AAID,YAAY,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAI3D,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,oCAAoC,CAAC;CAC/C;AAKD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,9 @@
1
+ // Adapter-factory specific types. The factory accepts driver callbacks
2
+ // (host-injected I/O) and returns the canonical `ScenarioRuntimeAdapters`
3
+ // interface that `runScenario(...)` consumes.
4
+ //
5
+ // Connection shape (`ScenarioConnectionRuntime`) is intentionally generic
6
+ // — host-side types (Mongoose ObjectId, Postgres Pool, etc.) flatten into
7
+ // this shape at the resolver boundary so the core stays framework-agnostic.
8
+ export {};
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/scenario-runner/adapters/types.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,0EAA0E;AAC1E,8CAA8C;AAC9C,EAAE;AACF,0EAA0E;AAC1E,0EAA0E;AAC1E,4EAA4E"}
@@ -6,4 +6,5 @@ export * from "./waitNodeExecutor.js";
6
6
  export * from "./conditionTypes.js";
7
7
  export * from "./graphTraversal.js";
8
8
  export * from "./types.js";
9
+ export * from "./adapters/index.js";
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/scenario-runner/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,6BAA6B,EAC7B,0BAA0B,EAC1B,8CAA8C,EAC9C,iCAAiC,EACjC,6BAA6B,GAC9B,MAAM,uBAAuB,CAAC;AAM/B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EACL,gCAAgC,EAChC,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/scenario-runner/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,6BAA6B,EAC7B,0BAA0B,EAC1B,8CAA8C,EAC9C,iCAAiC,EACjC,6BAA6B,GAC9B,MAAM,uBAAuB,CAAC;AAM/B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EACL,gCAAgC,EAChC,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC"}
@@ -11,4 +11,5 @@ export * from "./waitNodeExecutor.js";
11
11
  export * from "./conditionTypes.js";
12
12
  export * from "./graphTraversal.js";
13
13
  export * from "./types.js";
14
+ export * from "./adapters/index.js";
14
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/scenario-runner/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,6BAA6B,EAC7B,0BAA0B,EAC1B,8CAA8C,EAC9C,iCAAiC,EACjC,6BAA6B,GAC9B,MAAM,uBAAuB,CAAC;AAC/B,iEAAiE;AACjE,qEAAqE;AACrE,uEAAuE;AACvE,uEAAuE;AACvE,iCAAiC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EACL,gCAAgC,EAChC,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/scenario-runner/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,6BAA6B,EAC7B,0BAA0B,EAC1B,8CAA8C,EAC9C,iCAAiC,EACjC,6BAA6B,GAC9B,MAAM,uBAAuB,CAAC;AAC/B,iEAAiE;AACjE,qEAAqE;AACrE,uEAAuE;AACvE,uEAAuE;AACvE,iCAAiC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EACL,gCAAgC,EAChC,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { CounterSnapshotEntry, CounterStore } from "./types.js";
2
+ export declare const createCounterStore: (initialSnapshot?: CounterSnapshotEntry[]) => CounterStore;
3
+ export declare const getNextCounterValue: (key: string, startAt?: number) => number;
4
+ export declare const resetCounterValue: (key: string) => void;
5
+ export declare const getCounterSnapshot: () => CounterSnapshotEntry[];
6
+ export declare const hydrateCounterStore: (snapshot: CounterSnapshotEntry[]) => void;
7
+ //# sourceMappingURL=counter-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"counter-store.d.ts","sourceRoot":"","sources":["../../src/templating/counter-store.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAoCrE,eAAO,MAAM,kBAAkB,GAC7B,kBAAiB,oBAAoB,EAAO,KAC3C,YAgBF,CAAC;AAIF,eAAO,MAAM,mBAAmB,GAAI,KAAK,MAAM,EAAE,gBAAW,KAAG,MACtB,CAAC;AAE1C,eAAO,MAAM,iBAAiB,GAAI,KAAK,MAAM,KAAG,IAE/C,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAO,oBAAoB,EACjC,CAAC;AAE1B,eAAO,MAAM,mBAAmB,GAAI,UAAU,oBAAoB,EAAE,KAAG,IAEtE,CAAC"}
@@ -0,0 +1,64 @@
1
+ // Counter store for the Postman-style template engine.
2
+ //
3
+ // Two access modes:
4
+ // 1. `createCounterStore()` — fresh instance with snapshot/hydrate API.
5
+ // Hosts that need explicit lifecycle control (electron Node singleton
6
+ // with IPC snapshot transfer to renderer) construct their own.
7
+ // 2. Module-level default singleton via `getNextCounterValue` /
8
+ // `getCounterSnapshot` / `hydrateCounterStore` — convenient default
9
+ // shared across calls in the same process.
10
+ //
11
+ // Both modes use identical advance semantics: `counter` and
12
+ // `counter.start:N` are independent keys; missing key returns the
13
+ // requested startAt; subsequent calls increment.
14
+ const advance = (store, key, startAt) => {
15
+ const normalizedStartAt = Number.isFinite(startAt) ? Math.trunc(startAt) : 1;
16
+ if (!store.has(key)) {
17
+ store.set(key, normalizedStartAt);
18
+ return normalizedStartAt;
19
+ }
20
+ const next = (store.get(key) ?? normalizedStartAt) + 1;
21
+ store.set(key, next);
22
+ return next;
23
+ };
24
+ const hydrateStore = (store, snapshot) => {
25
+ store.clear();
26
+ for (const entry of snapshot) {
27
+ if (!Array.isArray(entry) || entry.length !== 2) {
28
+ continue;
29
+ }
30
+ const [key, value] = entry;
31
+ const normalizedKey = String(key ?? "").trim();
32
+ const normalizedValue = Number(value);
33
+ if (!normalizedKey || !Number.isFinite(normalizedValue)) {
34
+ continue;
35
+ }
36
+ store.set(normalizedKey, Math.trunc(normalizedValue));
37
+ }
38
+ };
39
+ export const createCounterStore = (initialSnapshot = []) => {
40
+ const store = new Map();
41
+ hydrateStore(store, initialSnapshot);
42
+ return {
43
+ getNextValue: (key, startAt = 1) => advance(store, key, startAt),
44
+ snapshot: () => Array.from(store.entries()),
45
+ hydrate: (snapshot) => hydrateStore(store, snapshot),
46
+ reset: (key) => {
47
+ if (key === undefined) {
48
+ store.clear();
49
+ return;
50
+ }
51
+ store.delete(key);
52
+ },
53
+ };
54
+ };
55
+ const defaultStore = createCounterStore();
56
+ export const getNextCounterValue = (key, startAt = 1) => defaultStore.getNextValue(key, startAt);
57
+ export const resetCounterValue = (key) => {
58
+ defaultStore.reset(key);
59
+ };
60
+ export const getCounterSnapshot = () => defaultStore.snapshot();
61
+ export const hydrateCounterStore = (snapshot) => {
62
+ defaultStore.hydrate(snapshot);
63
+ };
64
+ //# sourceMappingURL=counter-store.js.map
@@ -0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