@azure/storage-queue
Version:
Microsoft Azure Storage SDK for JavaScript - Queue
232 lines (231 loc) • 7.08 kB
JavaScript
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var messages_exports = {};
__export(messages_exports, {
MessagesImpl: () => MessagesImpl
});
module.exports = __toCommonJS(messages_exports);
var coreClient = __toESM(require("@azure/core-client"));
var Mappers = __toESM(require("../models/mappers.js"));
var Parameters = __toESM(require("../models/parameters.js"));
class MessagesImpl {
client;
/**
* Initialize a new instance of the class Messages class.
* @param client Reference to the service client
*/
constructor(client) {
this.client = client;
}
/**
* The Dequeue operation retrieves one or more messages from the front of the queue.
* @param options The options parameters.
*/
dequeue(options) {
return this.client.sendOperationRequest({ options }, dequeueOperationSpec);
}
/**
* The Clear operation deletes all messages from the specified queue.
* @param options The options parameters.
*/
clear(options) {
return this.client.sendOperationRequest({ options }, clearOperationSpec);
}
/**
* The Enqueue operation adds a new message to the back of the message queue. A visibility timeout can
* also be specified to make the message invisible until the visibility timeout expires. A message must
* be in a format that can be included in an XML request with UTF-8 encoding. The encoded message can
* be up to 64 KB in size for versions 2011-08-18 and newer, or 8 KB in size for previous versions.
* @param queueMessage A Message object which can be stored in a Queue
* @param options The options parameters.
*/
enqueue(queueMessage, options) {
return this.client.sendOperationRequest(
{ queueMessage, options },
enqueueOperationSpec
);
}
/**
* The Peek operation retrieves one or more messages from the front of the queue, but does not alter
* the visibility of the message.
* @param options The options parameters.
*/
peek(options) {
return this.client.sendOperationRequest({ options }, peekOperationSpec);
}
}
const xmlSerializer = coreClient.createSerializer(
Mappers,
/* isXml */
true
);
const dequeueOperationSpec = {
path: "/{queueName}/messages",
httpMethod: "GET",
responses: {
200: {
bodyMapper: {
type: {
name: "Sequence",
element: {
type: { name: "Composite", className: "DequeuedMessageItem" }
}
},
serializedName: "DequeuedMessagesList",
xmlName: "QueueMessagesList",
xmlIsWrapped: true,
xmlElementName: "QueueMessage"
},
headersMapper: Mappers.MessagesDequeueHeaders
},
default: {
bodyMapper: Mappers.StorageError,
headersMapper: Mappers.MessagesDequeueExceptionHeaders
}
},
queryParameters: [
Parameters.timeoutInSeconds,
Parameters.numberOfMessages,
Parameters.visibilityTimeout
],
urlParameters: [Parameters.url],
headerParameters: [
Parameters.version,
Parameters.requestId,
Parameters.accept1
],
isXML: true,
serializer: xmlSerializer
};
const clearOperationSpec = {
path: "/{queueName}/messages",
httpMethod: "DELETE",
responses: {
204: {
headersMapper: Mappers.MessagesClearHeaders
},
default: {
bodyMapper: Mappers.StorageError,
headersMapper: Mappers.MessagesClearExceptionHeaders
}
},
queryParameters: [Parameters.timeoutInSeconds],
urlParameters: [Parameters.url],
headerParameters: [
Parameters.version,
Parameters.requestId,
Parameters.accept1
],
isXML: true,
serializer: xmlSerializer
};
const enqueueOperationSpec = {
path: "/{queueName}/messages",
httpMethod: "POST",
responses: {
201: {
bodyMapper: {
type: {
name: "Sequence",
element: {
type: { name: "Composite", className: "EnqueuedMessage" }
}
},
serializedName: "EnqueuedMessageList",
xmlName: "QueueMessagesList",
xmlIsWrapped: true,
xmlElementName: "QueueMessage"
},
headersMapper: Mappers.MessagesEnqueueHeaders
},
default: {
bodyMapper: Mappers.StorageError,
headersMapper: Mappers.MessagesEnqueueExceptionHeaders
}
},
requestBody: Parameters.queueMessage,
queryParameters: [
Parameters.timeoutInSeconds,
Parameters.visibilityTimeout,
Parameters.messageTimeToLive
],
urlParameters: [Parameters.url],
headerParameters: [
Parameters.contentType,
Parameters.accept,
Parameters.version,
Parameters.requestId
],
isXML: true,
contentType: "application/xml; charset=utf-8",
mediaType: "xml",
serializer: xmlSerializer
};
const peekOperationSpec = {
path: "/{queueName}/messages",
httpMethod: "GET",
responses: {
200: {
bodyMapper: {
type: {
name: "Sequence",
element: {
type: { name: "Composite", className: "PeekedMessageItem" }
}
},
serializedName: "PeekedMessagesList",
xmlName: "QueueMessagesList",
xmlIsWrapped: true,
xmlElementName: "QueueMessage"
},
headersMapper: Mappers.MessagesPeekHeaders
},
default: {
bodyMapper: Mappers.StorageError,
headersMapper: Mappers.MessagesPeekExceptionHeaders
}
},
queryParameters: [
Parameters.timeoutInSeconds,
Parameters.numberOfMessages,
Parameters.peekonly
],
urlParameters: [Parameters.url],
headerParameters: [
Parameters.version,
Parameters.requestId,
Parameters.accept1
],
isXML: true,
serializer: xmlSerializer
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
MessagesImpl
});
//# sourceMappingURL=messages.js.map