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

sqs-producer

Package Overview
Dependencies
Maintainers
2
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 3.0.1 to 3.1.0

.github/ISSUE_TEMPLATE/bug-report.yml

10

.github/CONTRIBUTING.md

@@ -37,2 +37,12 @@ # Contributing

## Contributors Licence Agreement
In order to accept contributions, we need all contributors grant Us a licence to the intellectual
property rights in their Contributions. This Agreement (“Agreement”) is intended to protect your
rights as a contributor, and to help ensure that the intellectual property contained
within is available to the whole community, to use and build on.
When you raise a pull request and you haven't previously signed a CLA, the bot will automatically
ask you to do this. You must complete this step in order for your PR to be merged.
## Pull Request Process

@@ -39,0 +49,0 @@

1

dist/index.d.ts
export { Producer } from './producer';
export * from './types';
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -6,1 +20,2 @@ exports.Producer = void 0;

Object.defineProperty(exports, "Producer", { enumerable: true, get: function () { return producer_1.Producer; } });
__exportStar(require("./types"), exports);

9

dist/producer.d.ts
import { SQSClient, SendMessageBatchResultEntry } from '@aws-sdk/client-sqs';
import { Message } from './types';
interface ProducerOptions {
queueUrl?: string;
batchSize?: number;
sqs?: SQSClient;
region?: string;
}
import { Message, ProducerOptions } from './types';
export declare class Producer {

@@ -21,2 +15,1 @@ static create: (options: ProducerOptions) => Producer;

}
export {};

@@ -5,3 +5,3 @@ "use strict";

const client_sqs_1 = require("@aws-sdk/client-sqs");
const types_1 = require("./types");
const format_1 = require("./format");
const requiredOptions = ['queueUrl'];

@@ -50,3 +50,3 @@ class Producer {

QueueUrl: this.queueUrl,
Entries: batch.map(types_1.toEntry)
Entries: batch.map(format_1.toEntry)
};

@@ -53,0 +53,0 @@ const command = new client_sqs_1.SendMessageBatchCommand(params);

@@ -1,2 +0,8 @@

import { SendMessageBatchRequestEntry, MessageAttributeValue } from '@aws-sdk/client-sqs';
import { MessageAttributeValue, SQSClient } from '@aws-sdk/client-sqs';
export interface ProducerOptions {
queueUrl: string;
batchSize?: number;
sqs?: SQSClient;
region?: string;
}
export interface Message {

@@ -12,2 +18,1 @@ id: string;

}
export declare function toEntry(message: string | Message): SendMessageBatchRequestEntry;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toEntry = void 0;
const validation_1 = require("./validation");
function entryFromObject(message) {
if (!message.body) {
throw new Error(`Object messages must have 'body' prop`);
}
if (!message.groupId && !message.deduplicationId && !message.id) {
throw new Error(`Object messages must have 'id' prop`);
}
if (message.deduplicationId && !message.groupId) {
throw new Error(`FIFO Queue messages must have 'groupId' prop`);
}
if (message.id) {
if (!(0, validation_1.isString)(message.id)) {
throw new Error('Message.id value must be a string');
}
}
const entry = {
Id: message.id,
MessageBody: message.body
};
if (message.delaySeconds) {
if (typeof message.delaySeconds !== 'number' ||
message.delaySeconds < 0 ||
message.delaySeconds > 900) {
throw new Error('Message.delaySeconds value must be a number contained within [0 - 900]');
}
entry.DelaySeconds = message.delaySeconds;
}
if (message.messageAttributes) {
if (!(0, validation_1.isObject)(message.messageAttributes)) {
throw new Error('Message.messageAttributes must be an object');
}
Object.values(message.messageAttributes).every(validation_1.isMessageAttributeValid);
entry.MessageAttributes = message.messageAttributes;
}
if (message.groupId) {
if (!(0, validation_1.isString)(message.groupId)) {
throw new Error('Message.groupId value must be a string');
}
entry.MessageGroupId = message.groupId;
}
if (message.deduplicationId) {
if (!(0, validation_1.isString)(message.deduplicationId)) {
throw new Error('Message.deduplicationId value must be a string');
}
entry.MessageDeduplicationId = message.deduplicationId;
}
return entry;
}
function entryFromString(message) {
return {
Id: message,
MessageBody: message
};
}
function toEntry(message) {
if ((0, validation_1.isString)(message)) {
return entryFromString(message);
}
if ((0, validation_1.isObject)(message)) {
return entryFromObject(message);
}
throw new Error('A message can either be an object or a string');
}
exports.toEntry = toEntry;
{
"name": "sqs-producer",
"version": "3.0.1",
"version": "3.1.0",
"description": "Enqueues messages onto a given SQS queue",

@@ -17,3 +17,3 @@ "main": "dist/index.js",

"build": "npm run clean && tsc",
"prepare": "npm run build",
"prepublishOnly": "npm run build",
"pretest": "npm run build",

@@ -20,0 +20,0 @@ "watch": "tsc --watch",

export { Producer } from './producer';
export * from './types';

@@ -7,12 +7,7 @@ import {

} from '@aws-sdk/client-sqs';
import { Message, toEntry } from './types';
import { Message, ProducerOptions } from './types';
import { toEntry } from './format';
const requiredOptions = ['queueUrl'];
interface ProducerOptions {
queueUrl?: string;
batchSize?: number;
sqs?: SQSClient;
region?: string;
}
export class Producer {

@@ -19,0 +14,0 @@ static create: (options: ProducerOptions) => Producer;

@@ -1,7 +0,10 @@

import {
SendMessageBatchRequestEntry,
MessageAttributeValue
} from '@aws-sdk/client-sqs';
import { isObject, isString, isMessageAttributeValid } from './validation';
import { MessageAttributeValue, SQSClient } from '@aws-sdk/client-sqs';
export interface ProducerOptions {
queueUrl: string;
batchSize?: number;
sqs?: SQSClient;
region?: string;
}
export interface Message {

@@ -15,88 +18,1 @@ id: string;

}
function entryFromObject(message: Message): SendMessageBatchRequestEntry {
if (!message.body) {
throw new Error(`Object messages must have 'body' prop`);
}
if (!message.groupId && !message.deduplicationId && !message.id) {
throw new Error(`Object messages must have 'id' prop`);
}
if (message.deduplicationId && !message.groupId) {
throw new Error(`FIFO Queue messages must have 'groupId' prop`);
}
if (message.id) {
if (!isString(message.id)) {
throw new Error('Message.id value must be a string');
}
}
const entry: SendMessageBatchRequestEntry = {
Id: message.id,
MessageBody: message.body
};
if (message.delaySeconds) {
if (
typeof message.delaySeconds !== 'number' ||
message.delaySeconds < 0 ||
message.delaySeconds > 900
) {
throw new Error(
'Message.delaySeconds value must be a number contained within [0 - 900]'
);
}
entry.DelaySeconds = message.delaySeconds;
}
if (message.messageAttributes) {
if (!isObject(message.messageAttributes)) {
throw new Error('Message.messageAttributes must be an object');
}
Object.values(message.messageAttributes).every(isMessageAttributeValid);
entry.MessageAttributes = message.messageAttributes;
}
if (message.groupId) {
if (!isString(message.groupId)) {
throw new Error('Message.groupId value must be a string');
}
entry.MessageGroupId = message.groupId;
}
if (message.deduplicationId) {
if (!isString(message.deduplicationId)) {
throw new Error('Message.deduplicationId value must be a string');
}
entry.MessageDeduplicationId = message.deduplicationId;
}
return entry;
}
function entryFromString(message: string): SendMessageBatchRequestEntry {
return {
Id: message,
MessageBody: message
};
}
export function toEntry(
message: string | Message
): SendMessageBatchRequestEntry {
if (isString(message)) {
return entryFromString(message as string);
}
if (isObject(message)) {
return entryFromObject(message as Message);
}
throw new Error('A message can either be an object or a string');
}
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