Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sqs-producer

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sqs-producer - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

2

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var producer_js_1 = require("./producer.js");
exports.Producer = producer_js_1.Producer;
Object.defineProperty(exports, "Producer", { enumerable: true, get: function () { return producer_js_1.Producer; } });
import { SQS } from 'aws-sdk';
import { SendMessageBatchResultEntryList } from 'aws-sdk/clients/sqs';
interface ProducerOptions {

@@ -16,3 +17,3 @@ queueUrl?: string;

queueSize(): Promise<number>;
send(messages: string | string[]): Promise<string[]>;
send(messages: string | string[]): Promise<SendMessageBatchResultEntryList>;
private validate;

@@ -19,0 +20,0 @@ private sendBatch;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Producer = void 0;
const aws_sdk_1 = require("aws-sdk");

@@ -24,2 +25,3 @@ const types_1 = require("./types");

const failedMessages = [];
const successfulMessages = [];
const startIndex = 0;

@@ -30,3 +32,3 @@ if (!Array.isArray(messages)) {

}
return this.sendBatch(failedMessages, messages, startIndex);
return this.sendBatch(failedMessages, successfulMessages, messages, startIndex);
}

@@ -43,3 +45,3 @@ validate(options) {

}
async sendBatch(failedMessages, messages, startIndex) {
async sendBatch(failedMessages, successfulMessages, messages, startIndex) {
const endIndex = startIndex + this.batchSize;

@@ -53,7 +55,8 @@ const batch = messages.slice(startIndex, endIndex);

const failedMessagesBatch = failedMessages.concat(result.Failed.map((entry) => entry.Id));
const successfulMessagesBatch = successfulMessages.concat(result.Successful);
if (endIndex < messages.length) {
return this.sendBatch(failedMessagesBatch, messages, endIndex);
return this.sendBatch(failedMessagesBatch, successfulMessagesBatch, messages, endIndex);
}
if (failedMessagesBatch.length === 0) {
return undefined;
return successfulMessagesBatch;
}

@@ -60,0 +63,0 @@ throw new Error(`Failed to send messages: ${failedMessagesBatch.join(', ')}`);

import { SQS } from 'aws-sdk';
import { SendMessageBatchRequestEntry } from "aws-sdk/clients/sqs";
import { SendMessageBatchRequestEntry } from 'aws-sdk/clients/sqs';
interface Message {

@@ -4,0 +4,0 @@ id: string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toEntry = void 0;
const { isObject, isString, isMessageAttributeValid } = require('./validation');

@@ -58,8 +59,10 @@ function entryFromObject(message) {

function toEntry(message) {
if (isString(message))
if (isString(message)) {
return entryFromString(message);
if (isObject(message))
}
if (isObject(message)) {
return entryFromObject(message);
}
throw new Error('A message can either be an object or a string');
}
exports.toEntry = toEntry;

@@ -1,9 +0,3 @@

declare function isString(value: any): boolean;
declare function isObject(value: any): boolean;
declare function isMessageAttributeValid(messageAttribute: any): boolean;
declare const _default: {
isObject: typeof isObject;
isString: typeof isString;
isMessageAttributeValid: typeof isMessageAttributeValid;
};
export = _default;
export declare function isString(value: any): boolean;
export declare function isObject(value: any): boolean;
export declare function isMessageAttributeValid(messageAttribute: any): boolean;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isMessageAttributeValid = exports.isObject = exports.isString = void 0;
function isString(value) {
return typeof value === 'string' || value instanceof String;
}
exports.isString = isString;
function isObject(value) {
return value && typeof value === 'object' && value instanceof Object;
}
exports.isObject = isObject;
function isMessageAttributeValid(messageAttribute) {

@@ -17,2 +21,2 @@ if (!messageAttribute.DataType) {

}
module.exports = { isObject, isString, isMessageAttributeValid };
exports.isMessageAttributeValid = isMessageAttributeValid;
{
"name": "sqs-producer",
"version": "2.0.1",
"version": "2.0.2",
"description": "Enqueues messages onto a given SQS queue",

@@ -13,2 +13,4 @@ "main": "dist/index.js",

"build": "npm run clean && tsc",
"prepublish": "npm run build",
"pretest": "npm run build",
"watch": "tsc --watch",

@@ -18,3 +20,3 @@ "clean": "rm -fr dist/*"

"engines": {
"node": ">=8.0.0"
"node": ">=12.0.0"
},

@@ -37,4 +39,3 @@ "repository": {

"dependencies": {
"aws-sdk": "^2.673.0",
"ts-node-register": "^1.0.0"
"aws-sdk": "^2.673.0"
},

@@ -52,2 +53,3 @@ "devDependencies": {

"sinon": "^9.0.2",
"ts-node": "^8.10.1",
"tslint": "^6.1.2",

@@ -54,0 +56,0 @@ "tslint-config-airbnb": "^5.3.1",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc