@azure/core-amqp
Version:
Common library for amqp based azure sdks like @azure/event-hubs.
123 lines (122 loc) • 4.28 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var messageProperties_exports = {};
__export(messageProperties_exports, {
AmqpMessageProperties: () => AmqpMessageProperties
});
module.exports = __toCommonJS(messageProperties_exports);
var import_log = require("./log.js");
const AmqpMessageProperties = {
/**
* Converts MessageProperties to RheaMessageProperties.
* @param props - Message properties.
* @returns RheaMessageProperties.
*/
toRheaMessageProperties(props) {
const amqpProperties = {};
if (props.absoluteExpiryTime != void 0) {
amqpProperties.absolute_expiry_time = new Date(props.absoluteExpiryTime);
}
if (props.contentEncoding != void 0) {
amqpProperties.content_encoding = props.contentEncoding;
}
if (props.contentType != void 0) {
amqpProperties.content_type = props.contentType;
}
if (props.correlationId != void 0) {
amqpProperties.correlation_id = props.correlationId;
}
if (props.creationTime != void 0) {
amqpProperties.creation_time = new Date(props.creationTime);
}
if (props.groupId != void 0) {
amqpProperties.group_id = props.groupId;
}
if (props.groupSequence != void 0) {
amqpProperties.group_sequence = props.groupSequence;
}
if (props.messageId != void 0) {
amqpProperties.message_id = props.messageId;
}
if (props.replyTo != void 0) {
amqpProperties.reply_to = props.replyTo;
}
if (props.replyToGroupId != void 0) {
amqpProperties.reply_to_group_id = props.replyToGroupId;
}
if (props.subject != void 0) {
amqpProperties.subject = props.subject;
}
if (props.to != void 0) {
amqpProperties.to = props.to;
}
import_log.logger.verbose("To RheaMessageProperties: %O", amqpProperties);
return amqpProperties;
},
/**
* Converts RheaMessageProperties to MessageProperties.
* @param props - Amqp message properties.
* @returns MessageProperties.
*/
fromRheaMessageProperties(props) {
const msgProperties = {};
if (props.absolute_expiry_time != void 0) {
msgProperties.absoluteExpiryTime = props.absolute_expiry_time.getTime();
}
if (props.content_encoding != void 0) {
msgProperties.contentEncoding = props.content_encoding;
}
if (props.content_type != void 0) {
msgProperties.contentType = props.content_type;
}
if (props.correlation_id != void 0) {
msgProperties.correlationId = props.correlation_id;
}
if (props.creation_time != void 0) {
msgProperties.creationTime = props.creation_time.getTime();
}
if (props.group_id != void 0) {
msgProperties.groupId = props.group_id;
}
if (props.group_sequence != void 0) {
msgProperties.groupSequence = props.group_sequence;
}
if (props.message_id != void 0) {
msgProperties.messageId = props.message_id;
}
if (props.reply_to != void 0) {
msgProperties.replyTo = props.reply_to;
}
if (props.reply_to_group_id != void 0) {
msgProperties.replyToGroupId = props.reply_to_group_id;
}
if (props.subject != void 0) {
msgProperties.subject = props.subject;
}
if (props.to != void 0) {
msgProperties.to = props.to;
}
import_log.logger.verbose("From RheaMessageProperties: %O", msgProperties);
return msgProperties;
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
AmqpMessageProperties
});
//# sourceMappingURL=messageProperties.js.map