sqs-producer
Advanced tools
Comparing version 2.0.1 to 2.0.2
"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", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1
448
21697
15
20
- Removedts-node-register@^1.0.0
- Removed@cspotcode/source-map-support@0.8.1(transitive)
- Removed@jridgewell/resolve-uri@3.1.2(transitive)
- Removed@jridgewell/sourcemap-codec@1.5.0(transitive)
- Removed@jridgewell/trace-mapping@0.3.9(transitive)
- Removed@tsconfig/node10@1.0.11(transitive)
- Removed@tsconfig/node12@1.0.11(transitive)
- Removed@tsconfig/node14@1.0.3(transitive)
- Removed@tsconfig/node16@1.0.4(transitive)
- Removed@types/node@22.9.0(transitive)
- Removedacorn@8.14.0(transitive)
- Removedacorn-walk@8.3.4(transitive)
- Removedarg@4.1.3(transitive)
- Removedcreate-require@1.1.1(transitive)
- Removeddiff@4.0.2(transitive)
- Removedmake-error@1.3.6(transitive)
- Removedts-node@10.9.2(transitive)
- Removedts-node-register@1.0.0(transitive)
- Removedtypescript@5.6.3(transitive)
- Removedundici-types@6.19.8(transitive)
- Removedv8-compile-cache-lib@3.0.1(transitive)
- Removedyn@3.1.1(transitive)