@cognigy/rest-api-client
Version:
Cognigy REST-Client
27 lines • 1.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.prepareParams = void 0;
function stringify(value) {
const result = JSON.stringify(value);
return typeof result === "string" ? result : String(value);
}
function prepareParams(input, log, contextLabel = "prepareParams") {
if (Array.isArray(input)) {
return input.map((p) => typeof p === "string" ? p : stringify(p));
}
if (typeof input === "string") {
try {
const parsed = JSON.parse(input);
if (Array.isArray(parsed)) {
return parsed.map((p) => typeof p === "string" ? p : stringify(p));
}
}
catch (_a) {
const truncated = input.length > 200 ? input.slice(0, 200) + "…" : input;
log === null || log === void 0 ? void 0 : log("warn", `${contextLabel}: Could not parse as JSON: ${truncated}`);
}
}
return [];
}
exports.prepareParams = prepareParams;
//# sourceMappingURL=prepareParams.js.map