callman-core 1.2.0 → 1.4.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/dist/scenario-runner/adapters/connection-config.d.ts +34 -0
- package/dist/scenario-runner/adapters/connection-config.d.ts.map +1 -0
- package/dist/scenario-runner/adapters/connection-config.js +6 -0
- package/dist/scenario-runner/adapters/connection-config.js.map +1 -0
- package/dist/scenario-runner/adapters/db-executor.d.ts +4 -0
- package/dist/scenario-runner/adapters/db-executor.d.ts.map +1 -0
- package/dist/scenario-runner/adapters/db-executor.js +42 -0
- package/dist/scenario-runner/adapters/db-executor.js.map +1 -0
- package/dist/scenario-runner/adapters/helpers/abort.d.ts +4 -0
- package/dist/scenario-runner/adapters/helpers/abort.d.ts.map +1 -0
- package/dist/scenario-runner/adapters/helpers/abort.js +47 -0
- package/dist/scenario-runner/adapters/helpers/abort.js.map +1 -0
- package/dist/scenario-runner/adapters/helpers/failure-messages.d.ts +29 -0
- package/dist/scenario-runner/adapters/helpers/failure-messages.d.ts.map +1 -0
- package/dist/scenario-runner/adapters/helpers/failure-messages.js +64 -0
- package/dist/scenario-runner/adapters/helpers/failure-messages.js.map +1 -0
- package/dist/scenario-runner/adapters/helpers/mutations.d.ts +7 -0
- package/dist/scenario-runner/adapters/helpers/mutations.d.ts.map +1 -0
- package/dist/scenario-runner/adapters/helpers/mutations.js +28 -0
- package/dist/scenario-runner/adapters/helpers/mutations.js.map +1 -0
- package/dist/scenario-runner/adapters/helpers/request-helpers.d.ts +31 -0
- package/dist/scenario-runner/adapters/helpers/request-helpers.d.ts.map +1 -0
- package/dist/scenario-runner/adapters/helpers/request-helpers.js +247 -0
- package/dist/scenario-runner/adapters/helpers/request-helpers.js.map +1 -0
- package/dist/scenario-runner/adapters/helpers/response-shapes.d.ts +3 -0
- package/dist/scenario-runner/adapters/helpers/response-shapes.d.ts.map +1 -0
- package/dist/scenario-runner/adapters/helpers/response-shapes.js +32 -0
- package/dist/scenario-runner/adapters/helpers/response-shapes.js.map +1 -0
- package/dist/scenario-runner/adapters/helpers/templates.d.ts +2 -0
- package/dist/scenario-runner/adapters/helpers/templates.d.ts.map +1 -0
- package/dist/scenario-runner/adapters/helpers/templates.js +30 -0
- package/dist/scenario-runner/adapters/helpers/templates.js.map +1 -0
- package/dist/scenario-runner/adapters/index.d.ts +12 -0
- package/dist/scenario-runner/adapters/index.d.ts.map +1 -0
- package/dist/scenario-runner/adapters/index.js +30 -0
- package/dist/scenario-runner/adapters/index.js.map +1 -0
- package/dist/scenario-runner/adapters/kafka-executor.d.ts +4 -0
- package/dist/scenario-runner/adapters/kafka-executor.d.ts.map +1 -0
- package/dist/scenario-runner/adapters/kafka-executor.js +35 -0
- package/dist/scenario-runner/adapters/kafka-executor.js.map +1 -0
- package/dist/scenario-runner/adapters/notification-executor.d.ts +4 -0
- package/dist/scenario-runner/adapters/notification-executor.d.ts.map +1 -0
- package/dist/scenario-runner/adapters/notification-executor.js +67 -0
- package/dist/scenario-runner/adapters/notification-executor.js.map +1 -0
- package/dist/scenario-runner/adapters/redis-executor.d.ts +4 -0
- package/dist/scenario-runner/adapters/redis-executor.d.ts.map +1 -0
- package/dist/scenario-runner/adapters/redis-executor.js +78 -0
- package/dist/scenario-runner/adapters/redis-executor.js.map +1 -0
- package/dist/scenario-runner/adapters/request-executor.d.ts +4 -0
- package/dist/scenario-runner/adapters/request-executor.d.ts.map +1 -0
- package/dist/scenario-runner/adapters/request-executor.js +262 -0
- package/dist/scenario-runner/adapters/request-executor.js.map +1 -0
- package/dist/scenario-runner/adapters/script-executor.d.ts +4 -0
- package/dist/scenario-runner/adapters/script-executor.d.ts.map +1 -0
- package/dist/scenario-runner/adapters/script-executor.js +113 -0
- package/dist/scenario-runner/adapters/script-executor.js.map +1 -0
- package/dist/scenario-runner/adapters/types.d.ts +82 -0
- package/dist/scenario-runner/adapters/types.d.ts.map +1 -0
- package/dist/scenario-runner/adapters/types.js +9 -0
- package/dist/scenario-runner/adapters/types.js.map +1 -0
- package/dist/scenario-runner/condition.d.ts.map +1 -1
- package/dist/scenario-runner/condition.js +87 -78
- package/dist/scenario-runner/condition.js.map +1 -1
- package/dist/scenario-runner/index.d.ts +2 -1
- package/dist/scenario-runner/index.d.ts.map +1 -1
- package/dist/scenario-runner/index.js +7 -1
- package/dist/scenario-runner/index.js.map +1 -1
- package/dist-cjs/scenario-runner/adapters/connection-config.js +7 -0
- package/dist-cjs/scenario-runner/adapters/connection-config.js.map +1 -0
- package/dist-cjs/scenario-runner/adapters/db-executor.js +46 -0
- package/dist-cjs/scenario-runner/adapters/db-executor.js.map +1 -0
- package/dist-cjs/scenario-runner/adapters/helpers/abort.js +52 -0
- package/dist-cjs/scenario-runner/adapters/helpers/abort.js.map +1 -0
- package/dist-cjs/scenario-runner/adapters/helpers/failure-messages.js +69 -0
- package/dist-cjs/scenario-runner/adapters/helpers/failure-messages.js.map +1 -0
- package/dist-cjs/scenario-runner/adapters/helpers/mutations.js +32 -0
- package/dist-cjs/scenario-runner/adapters/helpers/mutations.js.map +1 -0
- package/dist-cjs/scenario-runner/adapters/helpers/request-helpers.js +263 -0
- package/dist-cjs/scenario-runner/adapters/helpers/request-helpers.js.map +1 -0
- package/dist-cjs/scenario-runner/adapters/helpers/response-shapes.js +36 -0
- package/dist-cjs/scenario-runner/adapters/helpers/response-shapes.js.map +1 -0
- package/dist-cjs/scenario-runner/adapters/helpers/templates.js +34 -0
- package/dist-cjs/scenario-runner/adapters/helpers/templates.js.map +1 -0
- package/dist-cjs/scenario-runner/adapters/index.js +40 -0
- package/dist-cjs/scenario-runner/adapters/index.js.map +1 -0
- package/dist-cjs/scenario-runner/adapters/kafka-executor.js +39 -0
- package/dist-cjs/scenario-runner/adapters/kafka-executor.js.map +1 -0
- package/dist-cjs/scenario-runner/adapters/notification-executor.js +71 -0
- package/dist-cjs/scenario-runner/adapters/notification-executor.js.map +1 -0
- package/dist-cjs/scenario-runner/adapters/redis-executor.js +82 -0
- package/dist-cjs/scenario-runner/adapters/redis-executor.js.map +1 -0
- package/dist-cjs/scenario-runner/adapters/request-executor.js +266 -0
- package/dist-cjs/scenario-runner/adapters/request-executor.js.map +1 -0
- package/dist-cjs/scenario-runner/adapters/script-executor.js +117 -0
- package/dist-cjs/scenario-runner/adapters/script-executor.js.map +1 -0
- package/dist-cjs/scenario-runner/adapters/types.js +10 -0
- package/dist-cjs/scenario-runner/adapters/types.js.map +1 -0
- package/dist-cjs/scenario-runner/condition.js +87 -78
- package/dist-cjs/scenario-runner/condition.js.map +1 -1
- package/dist-cjs/scenario-runner/index.js +8 -5
- package/dist-cjs/scenario-runner/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Canonical request executor — orchestrates a single Request scenario node:
|
|
3
|
+
// 1. (optional) pre-request script → mutate environment/globals/request
|
|
4
|
+
// 2. resolve auth + templates + body → executable shape
|
|
5
|
+
// 3. (optional) Kafka prefetch — start consumer, run HTTP, capture matched message
|
|
6
|
+
// 4. fall through to plain HTTP when no prefetch is configured
|
|
7
|
+
// 5. (optional) post-response script → mutate env/globals
|
|
8
|
+
// 6. (optional) tests script → collect test results, mutate env/globals
|
|
9
|
+
// 7. validate contract assertions
|
|
10
|
+
// 8. assemble failure message + return ScenarioRequestExecutionResult
|
|
11
|
+
//
|
|
12
|
+
// Driver injection point: `httpExecutor` and `kafkaExecutor`. Everything
|
|
13
|
+
// else (script execution, contract validation, template resolution) uses
|
|
14
|
+
// canonical core utilities.
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.buildRequestExecutor = void 0;
|
|
17
|
+
const templateResolver_js_1 = require("../templateResolver.js");
|
|
18
|
+
const contractValidator_js_1 = require("../../contract/contractValidator.js");
|
|
19
|
+
const abort_js_1 = require("./helpers/abort.js");
|
|
20
|
+
const failure_messages_js_1 = require("./helpers/failure-messages.js");
|
|
21
|
+
const mutations_js_1 = require("./helpers/mutations.js");
|
|
22
|
+
const response_shapes_js_1 = require("./helpers/response-shapes.js");
|
|
23
|
+
const request_helpers_js_1 = require("./helpers/request-helpers.js");
|
|
24
|
+
const buildBodyResolverHelpers = () => ({
|
|
25
|
+
replaceScenarioTemplateTokensForJsonValidation: templateResolver_js_1.replaceScenarioTemplateTokensForJsonValidation,
|
|
26
|
+
resolveScenarioJsonTemplateString: templateResolver_js_1.resolveScenarioJsonTemplateString,
|
|
27
|
+
resolveScenarioTemplateString: templateResolver_js_1.resolveScenarioTemplateString,
|
|
28
|
+
});
|
|
29
|
+
const httpResultToExecuteRequestResult = (http) => ({
|
|
30
|
+
status: http.status,
|
|
31
|
+
data: http.data,
|
|
32
|
+
headers: http.headers,
|
|
33
|
+
duration: http.duration,
|
|
34
|
+
});
|
|
35
|
+
const buildRequestExecutor = (options) => async (input) => {
|
|
36
|
+
// We can't directly call the canonical scriptExecutor from here —
|
|
37
|
+
// it lives on the same factory result and may be the host's override.
|
|
38
|
+
// Instead, we receive it via closure when the factory wires up.
|
|
39
|
+
// For now, we depend on the host's `scriptExecutor` being supplied
|
|
40
|
+
// via options so request-stage scripts run through whatever sandbox
|
|
41
|
+
// the host configured.
|
|
42
|
+
//
|
|
43
|
+
// Note: the script executor in this orchestration path runs *request
|
|
44
|
+
// stage* scripts (pre-request / post-response / tests). The default
|
|
45
|
+
// implementation in script-executor.ts knows how to dispatch to the
|
|
46
|
+
// canonical sandbox; hosts that want to customize override it.
|
|
47
|
+
const requestState = (0, request_helpers_js_1.createRequestStateFromNode)(input.node);
|
|
48
|
+
const scopes = {
|
|
49
|
+
environment: { ...input.context.environment },
|
|
50
|
+
globals: { ...input.context.globals },
|
|
51
|
+
};
|
|
52
|
+
let currentRequestState = requestState;
|
|
53
|
+
const runRequestStageScript = async (stage, script, response) => {
|
|
54
|
+
// The host's scriptExecutor adapter handles request-stage scripts
|
|
55
|
+
// when it receives a payload with `stage !== "script"`. We delegate
|
|
56
|
+
// through the same adapter shape that runScenario uses so behavior
|
|
57
|
+
// matches the script-only flow exactly.
|
|
58
|
+
const scriptResult = await invokeRequestStageScript(options, {
|
|
59
|
+
stage,
|
|
60
|
+
script,
|
|
61
|
+
timeoutMs: options.scriptTimeoutMs,
|
|
62
|
+
request: currentRequestState,
|
|
63
|
+
response: response
|
|
64
|
+
? (0, request_helpers_js_1.toRequestScriptResponse)(response)
|
|
65
|
+
: null,
|
|
66
|
+
environment: scopes.environment,
|
|
67
|
+
globals: scopes.globals,
|
|
68
|
+
workflowContext: input.context.workflowContext,
|
|
69
|
+
nodeMetaByLabel: input.context.nodeMetaByLabel,
|
|
70
|
+
});
|
|
71
|
+
if (scriptResult.request) {
|
|
72
|
+
currentRequestState = scriptResult.request;
|
|
73
|
+
}
|
|
74
|
+
(0, mutations_js_1.applyVariableMutations)(scopes, scriptResult.variableMutations);
|
|
75
|
+
return scriptResult;
|
|
76
|
+
};
|
|
77
|
+
// 1. Pre-request script ------------------------------------------------
|
|
78
|
+
if (input.node.data.config.preRequestScript?.trim()) {
|
|
79
|
+
const preResult = await runRequestStageScript("pre-request", input.node.data.config.preRequestScript, null);
|
|
80
|
+
if (preResult.error) {
|
|
81
|
+
const failureResponse = (0, request_helpers_js_1.toRequestResponse)((0, request_helpers_js_1.normalizeExecuteRequestFailure)(preResult.error.message));
|
|
82
|
+
return {
|
|
83
|
+
cancelled: false,
|
|
84
|
+
response: failureResponse,
|
|
85
|
+
responseRoot: null,
|
|
86
|
+
environment: scopes.environment,
|
|
87
|
+
globals: scopes.globals,
|
|
88
|
+
outputData: null,
|
|
89
|
+
testResults: preResult.testResults,
|
|
90
|
+
contractResults: [],
|
|
91
|
+
contractSummary: null,
|
|
92
|
+
contractValidationError: null,
|
|
93
|
+
dbAssertionResults: [],
|
|
94
|
+
redisAssertionResults: [],
|
|
95
|
+
prefetchedKafkaResults: [],
|
|
96
|
+
failureMessage: `Pre-request script failed: ${preResult.error.message}`,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// 2. Resolve templates + auth + body ----------------------------------
|
|
101
|
+
const templateValues = (0, templateResolver_js_1.buildScenarioTemplateValues)({
|
|
102
|
+
environment: scopes.environment,
|
|
103
|
+
globals: scopes.globals,
|
|
104
|
+
workflowContext: input.context.workflowContext,
|
|
105
|
+
nodeMetaByLabel: input.context.nodeMetaByLabel,
|
|
106
|
+
responseRoot: input.context.responseRoot,
|
|
107
|
+
dbResult: input.context.dbResult,
|
|
108
|
+
kafkaEvent: input.context.kafkaEvent,
|
|
109
|
+
redisResult: input.context.redisResult,
|
|
110
|
+
});
|
|
111
|
+
const runtimeRequest = (0, request_helpers_js_1.normalizeRequestForExecution)(currentRequestState, input.node.data.config.auth, buildBodyResolverHelpers(), templateValues);
|
|
112
|
+
// 3+4. Execute the HTTP call (with optional Kafka prefetch) -----------
|
|
113
|
+
const requestTimeoutMs = options.requestTimeoutMs;
|
|
114
|
+
const runHttp = async () => {
|
|
115
|
+
try {
|
|
116
|
+
const httpResult = await (0, abort_js_1.withAbortAndTimeout)(options.drivers.httpExecutor({
|
|
117
|
+
method: runtimeRequest.method,
|
|
118
|
+
url: runtimeRequest.url,
|
|
119
|
+
headers: runtimeRequest.headers,
|
|
120
|
+
query: runtimeRequest.query,
|
|
121
|
+
body: runtimeRequest.body,
|
|
122
|
+
timeoutMs: requestTimeoutMs,
|
|
123
|
+
}), requestTimeoutMs, `Request node ${input.stepId}`, input.signal);
|
|
124
|
+
return httpResultToExecuteRequestResult(httpResult);
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
return (0, request_helpers_js_1.normalizeExecuteRequestFailure)(error);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
let executionResult;
|
|
131
|
+
let prefetchedKafkaResults = [];
|
|
132
|
+
const transientCapture = input.kafkaCapturePlans.length === 1 ? input.kafkaCapturePlans[0] ?? null : null;
|
|
133
|
+
if (transientCapture?.connectionId && transientCapture.topic.trim()) {
|
|
134
|
+
try {
|
|
135
|
+
const kafkaConnection = await options.resolveConnection(transientCapture.connectionId);
|
|
136
|
+
const captureResult = await options.drivers.kafkaExecutor({
|
|
137
|
+
connection: kafkaConnection,
|
|
138
|
+
topic: transientCapture.topic.trim(),
|
|
139
|
+
matcher: null,
|
|
140
|
+
timeoutMs: options.nodeTimeoutMs,
|
|
141
|
+
operation: async () => {
|
|
142
|
+
const er = await runHttp();
|
|
143
|
+
return {
|
|
144
|
+
status: er.status,
|
|
145
|
+
headers: er.headers,
|
|
146
|
+
data: er.data,
|
|
147
|
+
duration: er.duration,
|
|
148
|
+
};
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
executionResult = captureResult.operationResult
|
|
152
|
+
? httpResultToExecuteRequestResult(captureResult.operationResult)
|
|
153
|
+
: await runHttp();
|
|
154
|
+
prefetchedKafkaResults = input.kafkaCapturePlans.map((plan) => ({
|
|
155
|
+
stepId: plan.stepId,
|
|
156
|
+
result: captureResult.capture,
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
// Kafka prefetch setup failed — fall through to plain HTTP.
|
|
161
|
+
// Backend's existing behavior is to silently degrade and rely
|
|
162
|
+
// on a separate kafka node (if any) to report the issue.
|
|
163
|
+
executionResult = await runHttp();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
executionResult = await runHttp();
|
|
168
|
+
}
|
|
169
|
+
const response = (0, request_helpers_js_1.toRequestResponse)(executionResult);
|
|
170
|
+
const combinedTestResults = [];
|
|
171
|
+
// 5. Post-response script ---------------------------------------------
|
|
172
|
+
let postResponseError = null;
|
|
173
|
+
if (input.node.data.config.postResponseScript?.trim()) {
|
|
174
|
+
const postResult = await runRequestStageScript("post-response", input.node.data.config.postResponseScript, response);
|
|
175
|
+
combinedTestResults.push(...postResult.testResults);
|
|
176
|
+
if (postResult.error) {
|
|
177
|
+
postResponseError = { message: postResult.error.message };
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// 6. Tests script -----------------------------------------------------
|
|
181
|
+
let testsError = null;
|
|
182
|
+
if (input.node.data.config.testsScript?.trim()) {
|
|
183
|
+
const testsResult = await runRequestStageScript("tests", input.node.data.config.testsScript, response);
|
|
184
|
+
combinedTestResults.push(...testsResult.testResults);
|
|
185
|
+
if (testsResult.error) {
|
|
186
|
+
testsError = { message: testsResult.error.message };
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
// 7. Contract validation ----------------------------------------------
|
|
190
|
+
const contractResults = (0, contractValidator_js_1.validateContracts)(input.node.data.config.contractAssertions ?? [], {
|
|
191
|
+
status: executionResult.status,
|
|
192
|
+
data: executionResult.data,
|
|
193
|
+
headers: executionResult.headers,
|
|
194
|
+
duration: executionResult.duration,
|
|
195
|
+
});
|
|
196
|
+
const contractCounts = (0, failure_messages_js_1.summarizeContractResults)(contractResults);
|
|
197
|
+
const contractSummary = {
|
|
198
|
+
total: contractCounts.total,
|
|
199
|
+
passed: contractCounts.passed,
|
|
200
|
+
failed: contractCounts.failed,
|
|
201
|
+
};
|
|
202
|
+
// 8. Failure message + return -----------------------------------------
|
|
203
|
+
const failureMessage = (0, failure_messages_js_1.buildRequestFailureMessage)({
|
|
204
|
+
response,
|
|
205
|
+
postResponseError,
|
|
206
|
+
testsError,
|
|
207
|
+
testResults: combinedTestResults,
|
|
208
|
+
contractResults,
|
|
209
|
+
});
|
|
210
|
+
const responseRoot = (0, response_shapes_js_1.buildResponseRoot)(response);
|
|
211
|
+
return {
|
|
212
|
+
cancelled: Boolean(input.signal?.aborted),
|
|
213
|
+
response,
|
|
214
|
+
responseRoot,
|
|
215
|
+
environment: scopes.environment,
|
|
216
|
+
globals: scopes.globals,
|
|
217
|
+
outputData: responseRoot,
|
|
218
|
+
testResults: combinedTestResults,
|
|
219
|
+
contractResults,
|
|
220
|
+
contractSummary,
|
|
221
|
+
contractValidationError: null,
|
|
222
|
+
dbAssertionResults: [],
|
|
223
|
+
redisAssertionResults: [],
|
|
224
|
+
prefetchedKafkaResults,
|
|
225
|
+
failureMessage,
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
exports.buildRequestExecutor = buildRequestExecutor;
|
|
229
|
+
// ---------------------------------------------------------------------
|
|
230
|
+
// Request-stage script invocation. The host supplies a script executor
|
|
231
|
+
// either as `options.scriptExecutor` (which handles the standalone
|
|
232
|
+
// "script" stage from runScenario) or via the dedicated request-stage
|
|
233
|
+
// hook below. Default routes to the canonical executeScript with the
|
|
234
|
+
// "stage" capability set so pre/post/test scripts get the request +
|
|
235
|
+
// response surface they expect.
|
|
236
|
+
// ---------------------------------------------------------------------
|
|
237
|
+
const executor_js_1 = require("../../script/executor.js");
|
|
238
|
+
const invokeRequestStageScript = async (options, input) => {
|
|
239
|
+
// Hosts can swap the request-stage script behavior by overriding
|
|
240
|
+
// `scriptExecutor` and inspecting the input to dispatch to their own
|
|
241
|
+
// pre/post/tests handler. In this default path we go directly to the
|
|
242
|
+
// canonical sandbox.
|
|
243
|
+
const result = await (0, executor_js_1.executeScript)({
|
|
244
|
+
script: input.script,
|
|
245
|
+
timeoutMs: input.timeoutMs,
|
|
246
|
+
filename: "callman-request.script.js",
|
|
247
|
+
stage: input.stage,
|
|
248
|
+
capabilities: {
|
|
249
|
+
environment: { values: input.environment, emitMutations: true },
|
|
250
|
+
globals: { values: input.globals, emitMutations: true },
|
|
251
|
+
request: input.request,
|
|
252
|
+
response: input.response ?? undefined,
|
|
253
|
+
workflowContext: input.workflowContext,
|
|
254
|
+
nodeMetaByLabel: input.nodeMetaByLabel,
|
|
255
|
+
exposeLabelsAsGlobals: true,
|
|
256
|
+
extensions: { log: true, node: true },
|
|
257
|
+
},
|
|
258
|
+
});
|
|
259
|
+
return {
|
|
260
|
+
request: result.request,
|
|
261
|
+
variableMutations: result.variableMutations,
|
|
262
|
+
testResults: result.testResults,
|
|
263
|
+
error: result.error,
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
//# 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,4DAA4D;AAC5D,0EAA0E;AAC1E,oCAAoC;AACpC,wEAAwE;AACxE,EAAE;AACF,yEAAyE;AACzE,yEAAyE;AACzE,4BAA4B;;;AAQ5B,gEAKgC;AAChC,8EAAwE;AAExE,iDAAyD;AACzD,uEAGuC;AACvC,yDAAgE;AAChE,qEAAiE;AACjE,qEAMsC;AAMtC,MAAM,wBAAwB,GAAG,GAAG,EAAE,CAAC,CAAC;IACtC,8CAA8C,EAA9C,oEAA8C;IAC9C,iCAAiC,EAAjC,uDAAiC;IACjC,6BAA6B,EAA7B,mDAA6B;CAC9B,CAAC,CAAC;AAEH,MAAM,gCAAgC,GAAG,CACvC,IAAuB,EACD,EAAE,CAAC,CAAC;IAC1B,MAAM,EAAE,IAAI,CAAC,MAAM;IACnB,IAAI,EAAE,IAAI,CAAC,IAAI;IACf,OAAO,EAAE,IAAI,CAAC,OAAO;IACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;CACxB,CAAC,CAAC;AAEI,MAAM,oBAAoB,GAAG,CAClC,OAA6C,EAC7C,EAAE,CACF,KAAK,EAAE,KAAoC,EAA2C,EAAE;IACtF,kEAAkE;IAClE,sEAAsE;IACtE,gEAAgE;IAChE,mEAAmE;IACnE,oEAAoE;IACpE,uBAAuB;IACvB,EAAE;IACF,qEAAqE;IACrE,oEAAoE;IACpE,oEAAoE;IACpE,+DAA+D;IAE/D,MAAM,YAAY,GAAG,IAAA,+CAA0B,EAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5D,MAAM,MAAM,GAAG;QACb,WAAW,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE;QAC7C,OAAO,EAAE,EAAE,GAAG,KAAK,CA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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,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Canonical script executor — orchestrates a standalone Script scenario
|
|
3
|
+
// node. Wraps callman-core's `executeScript` with scenario-specific
|
|
4
|
+
// input mapping + post-processing:
|
|
5
|
+
// - mutation values get template-resolved against the live runtime
|
|
6
|
+
// scope (so `pm.environment.set("token", "{{response.data.token}}")`
|
|
7
|
+
// works even though the script sandbox doesn't see the runtime
|
|
8
|
+
// scope directly)
|
|
9
|
+
// - return value gets deep template-resolved
|
|
10
|
+
// - failed pm.test entries surface in `failureMessage` for the runner
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.buildScriptExecutor = void 0;
|
|
13
|
+
const templateResolver_js_1 = require("../templateResolver.js");
|
|
14
|
+
const executor_js_1 = require("../../script/executor.js");
|
|
15
|
+
const abort_js_1 = require("./helpers/abort.js");
|
|
16
|
+
const templates_js_1 = require("./helpers/templates.js");
|
|
17
|
+
const toScenarioMutation = (mutation) => mutation.type === "set"
|
|
18
|
+
? {
|
|
19
|
+
scope: mutation.scope,
|
|
20
|
+
type: "set",
|
|
21
|
+
key: mutation.key,
|
|
22
|
+
value: mutation.value,
|
|
23
|
+
}
|
|
24
|
+
: {
|
|
25
|
+
scope: mutation.scope,
|
|
26
|
+
type: "unset",
|
|
27
|
+
key: mutation.key,
|
|
28
|
+
};
|
|
29
|
+
const buildScriptExecutor = (options) => async (input) => {
|
|
30
|
+
const script = input.node.data.config.script;
|
|
31
|
+
const baseTimeoutMs = Math.min(options.nodeTimeoutMs, input.node.data.config.timeoutMs ?? options.scriptTimeoutMs);
|
|
32
|
+
if (!script.trim()) {
|
|
33
|
+
return {
|
|
34
|
+
variableMutations: [],
|
|
35
|
+
testResults: [],
|
|
36
|
+
logs: [],
|
|
37
|
+
error: {
|
|
38
|
+
stage: "script",
|
|
39
|
+
message: "Script node is empty.",
|
|
40
|
+
lineNumber: null,
|
|
41
|
+
column: null,
|
|
42
|
+
stack: null,
|
|
43
|
+
},
|
|
44
|
+
hasReturnValue: false,
|
|
45
|
+
returnValue: null,
|
|
46
|
+
outputData: null,
|
|
47
|
+
scriptSource: script,
|
|
48
|
+
timeoutMs: baseTimeoutMs,
|
|
49
|
+
failureMessage: "Script node is empty.",
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const scriptResult = await (0, abort_js_1.withAbortAndTimeout)((0, executor_js_1.executeScript)({
|
|
53
|
+
script,
|
|
54
|
+
timeoutMs: baseTimeoutMs,
|
|
55
|
+
filename: "callman-scenario.script.js",
|
|
56
|
+
stage: "script",
|
|
57
|
+
capabilities: {
|
|
58
|
+
environment: { values: input.context.environment, emitMutations: true },
|
|
59
|
+
globals: { values: input.context.globals, emitMutations: true },
|
|
60
|
+
workflowContext: input.context.workflowContext,
|
|
61
|
+
nodeMetaByLabel: input.context.nodeMetaByLabel,
|
|
62
|
+
exposeLabelsAsGlobals: true,
|
|
63
|
+
extensions: { log: true, node: true },
|
|
64
|
+
},
|
|
65
|
+
}), baseTimeoutMs, `Script node ${input.stepId}`, input.signal);
|
|
66
|
+
// Templates may contain `{{...}}` tokens that reference live runtime
|
|
67
|
+
// values not available inside the sandbox (response.body, db.result,
|
|
68
|
+
// etc.). Resolve them against the current scenario runtime scope
|
|
69
|
+
// *after* the script returns so node consumers see substituted text.
|
|
70
|
+
const templateValues = (0, templateResolver_js_1.buildScenarioTemplateValues)({
|
|
71
|
+
environment: input.context.environment,
|
|
72
|
+
globals: input.context.globals,
|
|
73
|
+
workflowContext: input.context.workflowContext,
|
|
74
|
+
nodeMetaByLabel: input.context.nodeMetaByLabel,
|
|
75
|
+
responseRoot: input.context.responseRoot,
|
|
76
|
+
dbResult: input.context.dbResult,
|
|
77
|
+
kafkaEvent: input.context.kafkaEvent,
|
|
78
|
+
redisResult: input.context.redisResult,
|
|
79
|
+
});
|
|
80
|
+
const resolvedMutations = scriptResult.variableMutations.map((mutation) => mutation.type === "set" && typeof mutation.value === "string"
|
|
81
|
+
? {
|
|
82
|
+
...mutation,
|
|
83
|
+
value: (0, templateResolver_js_1.resolveScenarioTemplateString)(mutation.value, templateValues),
|
|
84
|
+
}
|
|
85
|
+
: mutation);
|
|
86
|
+
const resolvedReturnValue = scriptResult.hasReturnValue
|
|
87
|
+
? (0, templates_js_1.resolveScenarioScriptTemplatesDeep)(scriptResult.returnValue, templateValues, templateResolver_js_1.resolveScenarioTemplateString)
|
|
88
|
+
: null;
|
|
89
|
+
const failedScriptTest = scriptResult.testResults.find((entry) => entry.status === "FAIL");
|
|
90
|
+
const failureMessage = scriptResult.error
|
|
91
|
+
? scriptResult.error.message
|
|
92
|
+
: failedScriptTest
|
|
93
|
+
? failedScriptTest.error
|
|
94
|
+
? `Script test failed: ${failedScriptTest.name} (${failedScriptTest.error})`
|
|
95
|
+
: `Script test failed: ${failedScriptTest.name}`
|
|
96
|
+
: null;
|
|
97
|
+
return {
|
|
98
|
+
variableMutations: resolvedMutations.map(toScenarioMutation),
|
|
99
|
+
testResults: scriptResult.testResults,
|
|
100
|
+
logs: scriptResult.logs,
|
|
101
|
+
error: scriptResult.error,
|
|
102
|
+
hasReturnValue: scriptResult.hasReturnValue,
|
|
103
|
+
returnValue: resolvedReturnValue,
|
|
104
|
+
outputData: {
|
|
105
|
+
...(scriptResult.hasReturnValue ? { returnValue: resolvedReturnValue } : {}),
|
|
106
|
+
testResults: scriptResult.testResults,
|
|
107
|
+
logs: scriptResult.logs,
|
|
108
|
+
variableMutations: resolvedMutations.map(toScenarioMutation),
|
|
109
|
+
error: scriptResult.error,
|
|
110
|
+
},
|
|
111
|
+
scriptSource: script,
|
|
112
|
+
timeoutMs: baseTimeoutMs,
|
|
113
|
+
failureMessage,
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
exports.buildScriptExecutor = buildScriptExecutor;
|
|
117
|
+
//# 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,gEAAoG;AACpG,0DAAyD;AAGzD,iDAAyD;AACzD,yDAA4E;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;AAED,MAAM,mBAAmB,GAAG,CACjC,OAA6C,EAC7C,EAAE,CACF,KAAK,EAAE,KAAmC,EAA0C,EAAE;IACpF,MAAM,MAAM,GAAG,KAAK,CAAC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CAAC;IACF,MAAM,cAAc,GAAG,YAAY,CAAC,KAAK;QACvC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO;QAC5B,CAAC,CAAC,gBAAgB;YAChB,CAAC,CAAC,gBAAgB,CAAC,KAAK;gBACtB,CAAC,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;AA/GS,QAAA,mBAAmB,uBA+G5B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Adapter-factory specific types. The factory accepts driver callbacks
|
|
3
|
+
// (host-injected I/O) and returns the canonical `ScenarioRuntimeAdapters`
|
|
4
|
+
// interface that `runScenario(...)` consumes.
|
|
5
|
+
//
|
|
6
|
+
// Connection shape (`ScenarioConnectionRuntime`) is intentionally generic
|
|
7
|
+
// — host-side types (Mongoose ObjectId, Postgres Pool, etc.) flatten into
|
|
8
|
+
// this shape at the resolver boundary so the core stays framework-agnostic.
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
//# 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"}
|
|
@@ -4,84 +4,12 @@ exports.convertLegacyConditionOperator = exports.createConditionConfigFromLegacy
|
|
|
4
4
|
const createId = (prefix) => typeof crypto !== "undefined" && typeof crypto.randomUUID === "function"
|
|
5
5
|
? crypto.randomUUID()
|
|
6
6
|
: `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
7
|
+
// Flat "Built-in" autocomplete grouping — HTTP/DB/Kafka/Redis/env/global
|
|
8
|
+
// listed first, workflow.__meta.* metadata at the end. Aligned with the
|
|
9
|
+
// renderer's UX-tuned ordering (formerly split between "System" and
|
|
10
|
+
// "Built-in" in the older core variant; collapsed here so the autocomplete
|
|
11
|
+
// dropdown surfaces user-frequent paths first).
|
|
7
12
|
const BUILT_IN_RUNTIME_SUGGESTIONS = [
|
|
8
|
-
{
|
|
9
|
-
description: "Global workflow execution metadata.",
|
|
10
|
-
exampleValue: "success",
|
|
11
|
-
group: "System",
|
|
12
|
-
path: "workflow.__meta.status",
|
|
13
|
-
valueType: "string",
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
description: "Whether the workflow completed without failures.",
|
|
17
|
-
exampleValue: "true",
|
|
18
|
-
group: "System",
|
|
19
|
-
path: "workflow.__meta.success",
|
|
20
|
-
valueType: "boolean",
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
description: "Whether the workflow has failed.",
|
|
24
|
-
exampleValue: "false",
|
|
25
|
-
group: "System",
|
|
26
|
-
path: "workflow.__meta.failed",
|
|
27
|
-
valueType: "boolean",
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
description: "How many nodes were executed successfully.",
|
|
31
|
-
exampleValue: "5",
|
|
32
|
-
group: "System",
|
|
33
|
-
path: "workflow.__meta.successfulNodes",
|
|
34
|
-
valueType: "number",
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
description: "How many nodes failed during workflow execution.",
|
|
38
|
-
exampleValue: "1",
|
|
39
|
-
group: "System",
|
|
40
|
-
path: "workflow.__meta.failedNodes",
|
|
41
|
-
valueType: "number",
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
description: "How many nodes were skipped during workflow execution.",
|
|
45
|
-
exampleValue: "2",
|
|
46
|
-
group: "System",
|
|
47
|
-
path: "workflow.__meta.skippedNodes",
|
|
48
|
-
valueType: "number",
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
description: "Total retry count across the workflow.",
|
|
52
|
-
exampleValue: "3",
|
|
53
|
-
group: "System",
|
|
54
|
-
path: "workflow.__meta.totalRetries",
|
|
55
|
-
valueType: "number",
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
description: "Workflow duration in milliseconds.",
|
|
59
|
-
exampleValue: "1240",
|
|
60
|
-
group: "System",
|
|
61
|
-
path: "workflow.__meta.durationMs",
|
|
62
|
-
valueType: "number",
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
description: "The currently running node label.",
|
|
66
|
-
exampleValue: "Req1",
|
|
67
|
-
group: "System",
|
|
68
|
-
path: "workflow.__meta.currentNode",
|
|
69
|
-
valueType: "string",
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
description: "The most recently completed node label.",
|
|
73
|
-
exampleValue: "Req1",
|
|
74
|
-
group: "System",
|
|
75
|
-
path: "workflow.__meta.lastNode",
|
|
76
|
-
valueType: "string",
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
description: "The node label that caused workflow failure.",
|
|
80
|
-
exampleValue: "Kafka1",
|
|
81
|
-
group: "System",
|
|
82
|
-
path: "workflow.__meta.failedNode",
|
|
83
|
-
valueType: "string",
|
|
84
|
-
},
|
|
85
13
|
{
|
|
86
14
|
description: "Latest HTTP status code from the most recent request node.",
|
|
87
15
|
exampleValue: "200",
|
|
@@ -152,6 +80,83 @@ const BUILT_IN_RUNTIME_SUGGESTIONS = [
|
|
|
152
80
|
path: "global",
|
|
153
81
|
valueType: "string",
|
|
154
82
|
},
|
|
83
|
+
{
|
|
84
|
+
description: "Overall workflow execution metadata.",
|
|
85
|
+
exampleValue: "success",
|
|
86
|
+
group: "Built-in",
|
|
87
|
+
path: "workflow.__meta.status",
|
|
88
|
+
valueType: "string",
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
description: "Whether the workflow completed without failures.",
|
|
92
|
+
exampleValue: "true",
|
|
93
|
+
group: "Built-in",
|
|
94
|
+
path: "workflow.__meta.success",
|
|
95
|
+
valueType: "boolean",
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
description: "Whether the workflow is currently failed.",
|
|
99
|
+
exampleValue: "false",
|
|
100
|
+
group: "Built-in",
|
|
101
|
+
path: "workflow.__meta.failed",
|
|
102
|
+
valueType: "boolean",
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
description: "Count of successful workflow nodes.",
|
|
106
|
+
exampleValue: "3",
|
|
107
|
+
group: "Built-in",
|
|
108
|
+
path: "workflow.__meta.successfulNodes",
|
|
109
|
+
valueType: "number",
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
description: "Count of failed workflow nodes.",
|
|
113
|
+
exampleValue: "1",
|
|
114
|
+
group: "Built-in",
|
|
115
|
+
path: "workflow.__meta.failedNodes",
|
|
116
|
+
valueType: "number",
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
description: "Count of skipped workflow nodes.",
|
|
120
|
+
exampleValue: "2",
|
|
121
|
+
group: "Built-in",
|
|
122
|
+
path: "workflow.__meta.skippedNodes",
|
|
123
|
+
valueType: "number",
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
description: "Total retry count across the workflow.",
|
|
127
|
+
exampleValue: "1",
|
|
128
|
+
group: "Built-in",
|
|
129
|
+
path: "workflow.__meta.totalRetries",
|
|
130
|
+
valueType: "number",
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
description: "Workflow duration in milliseconds.",
|
|
134
|
+
exampleValue: "1280",
|
|
135
|
+
group: "Built-in",
|
|
136
|
+
path: "workflow.__meta.durationMs",
|
|
137
|
+
valueType: "number",
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
description: "Current node label while the workflow is running.",
|
|
141
|
+
exampleValue: "Req1",
|
|
142
|
+
group: "Built-in",
|
|
143
|
+
path: "workflow.__meta.currentNode",
|
|
144
|
+
valueType: "string",
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
description: "Last completed node label.",
|
|
148
|
+
exampleValue: "Req1",
|
|
149
|
+
group: "Built-in",
|
|
150
|
+
path: "workflow.__meta.lastNode",
|
|
151
|
+
valueType: "string",
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
description: "Last failed node label.",
|
|
155
|
+
exampleValue: "Kafka1",
|
|
156
|
+
group: "Built-in",
|
|
157
|
+
path: "workflow.__meta.failedNode",
|
|
158
|
+
valueType: "string",
|
|
159
|
+
},
|
|
155
160
|
];
|
|
156
161
|
exports.CONDITION_OPERATOR_META = [
|
|
157
162
|
{ category: "Equality", label: "Equals", value: "equals" },
|
|
@@ -233,7 +238,11 @@ const VALUE_TYPE_LABELS = {
|
|
|
233
238
|
array: "Array",
|
|
234
239
|
};
|
|
235
240
|
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
236
|
-
|
|
241
|
+
// Strict array-index detection: only digits, no leading sign, no whitespace.
|
|
242
|
+
// Looser variants (e.g., `Number.isInteger(Number(" 5 "))`) used to accept
|
|
243
|
+
// whitespace-padded inputs which never appear in legitimate JSON paths and
|
|
244
|
+
// could mask malformed templates. Aligned with the renderer's regex check.
|
|
245
|
+
const isArrayIndexProperty = (value) => /^\d+$/.test(value);
|
|
237
246
|
const normalizeWhitespace = (value) => value.replace(/\s+/g, " ").trim();
|
|
238
247
|
const normalizeAlias = (value) => value.trim().toUpperCase();
|
|
239
248
|
const isBoundaryCharacter = (value) => value.length === 0 || /[\s()[\]{},"']/.test(value);
|