UNPKG

@microsoft/omnichannel-chat-sdk

Version:
33 lines 2.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StreamingMessagePrinter = void 0; var StreamingMessagePrinter = /** @class */ (function () { function StreamingMessagePrinter() { } StreamingMessagePrinter.printify = function (event) { var _a, _b, _c, _d, _e, _f; var result = {}; if (!event) { return result; } result.id = event.id; result.tags = ((_a = event === null || event === void 0 ? void 0 : event.metadata) === null || _a === void 0 ? void 0 : _a.tags) ? event.metadata.tags.replace(/"/g, "").split(",").filter(function (tag) { return tag.length > 0; }) : []; result.bot = ((_c = (_b = event === null || event === void 0 ? void 0 : event.metadata) === null || _b === void 0 ? void 0 : _b.tags) === null || _c === void 0 ? void 0 : _c.includes("public")) ? false : true; result.card = false; // Privacy: never log raw streaming content. Stamp the byte length only. result.content = (event === null || event === void 0 ? void 0 : event.message) ? "".concat(event.message.length, " chars") : ""; result.created = event.createdOn; // Streaming-specific fields. PrintableMessage doesn't formally carry these // today; the cast lets dashboards consume them as additional context. // eslint-disable-next-line @typescript-eslint/no-explicit-any result.streamingMessageType = (_d = event === null || event === void 0 ? void 0 : event.streamingMetadata) === null || _d === void 0 ? void 0 : _d.streamingMessageType; // eslint-disable-next-line @typescript-eslint/no-explicit-any result.streamingSequenceNumber = (_e = event === null || event === void 0 ? void 0 : event.streamingMetadata) === null || _e === void 0 ? void 0 : _e.streamingSequenceNumber; // eslint-disable-next-line @typescript-eslint/no-explicit-any result.streamEndReason = (_f = event === null || event === void 0 ? void 0 : event.streamingMetadata) === null || _f === void 0 ? void 0 : _f.streamEndReason; return result; }; return StreamingMessagePrinter; }()); exports.StreamingMessagePrinter = StreamingMessagePrinter; //# sourceMappingURL=StreamingMessagePrinter.js.map