Comparing version 1.0.0 to 2.0.0
@@ -12,3 +12,3 @@ #!/usr/bin/env node | ||
if (argv.help) { | ||
return console.log( | ||
console.log( | ||
[ | ||
@@ -26,7 +26,7 @@ '', | ||
); | ||
} else { | ||
sqslite({}).listen(argv.port || DEFAULT_PORT, (err, address) => { | ||
if (err) throw err; | ||
console.log(`server listening on ${address}`); | ||
}); | ||
} | ||
sqslite({}).listen(argv.port || DEFAULT_PORT, (err, address) => { | ||
if (err) throw err; | ||
console.log(`server listening on ${address}`); | ||
}); |
149
CHANGELOG.md
@@ -10,2 +10,151 @@ ## Changelog | ||
### v2.0.0 (2021-10-29) | ||
- [`#458`](https://github.com/lifion/sqslite/pull/458): Bump aws-sdk from 2.1014.0 to 2.1015.0 | ||
- [`#440`](https://github.com/lifion/sqslite/pull/440): adding JSDocs and typings | ||
- [`#452`](https://github.com/lifion/sqslite/pull/452): Bump jest from 27.2.1 to 27.2.5 | ||
- [`#451`](https://github.com/lifion/sqslite/pull/451): Bump typescript from 4.4.3 to 4.4.4 | ||
- [`#450`](https://github.com/lifion/sqslite/pull/450): Bump lint-staged from 11.1.2 to 11.2.3 | ||
- [`#449`](https://github.com/lifion/sqslite/pull/449): Bump superstruct from 0.15.2 to 0.15.3 | ||
- [`#448`](https://github.com/lifion/sqslite/pull/448): Bump @types/node from 16.9.1 to 16.10.4 | ||
- [`#447`](https://github.com/lifion/sqslite/pull/447): Bump aws-sdk from 2.989.0 to 2.1006.0 | ||
- [`#445`](https://github.com/lifion/sqslite/pull/445): Bump fastify from 3.21.1 to 3.22.0 | ||
- [`#433`](https://github.com/lifion/sqslite/pull/433): Bump prettier from 2.4.0 to 2.4.1 | ||
- [`#431`](https://github.com/lifion/sqslite/pull/431): Bump jest from 27.2.0 to 27.2.1 | ||
- [`#430`](https://github.com/lifion/sqslite/pull/430): Bump jest from 27.1.0 to 27.2.0 | ||
- [`#429`](https://github.com/lifion/sqslite/pull/429): Bump prettier from 2.3.2 to 2.4.0 | ||
- [`#428`](https://github.com/lifion/sqslite/pull/428): Bump typescript from 4.4.2 to 4.4.3 | ||
- [`#427`](https://github.com/lifion/sqslite/pull/427): Bump aws-sdk from 2.980.0 to 2.989.0 | ||
- [`#426`](https://github.com/lifion/sqslite/pull/426): Bump fastify from 3.20.2 to 3.21.1 | ||
- [`#425`](https://github.com/lifion/sqslite/pull/425): Bump @types/node from 16.7.9 to 16.9.1 | ||
- [`#421`](https://github.com/lifion/sqslite/pull/421): Bump aws-sdk from 2.979.0 to 2.980.0 | ||
- [`#420`](https://github.com/lifion/sqslite/pull/420): Bump @types/node from 16.7.8 to 16.7.9 | ||
- [`#419`](https://github.com/lifion/sqslite/pull/419): Bump browserslist from 4.16.3 to 4.16.8 | ||
- [`#418`](https://github.com/lifion/sqslite/pull/418): Bump hosted-git-info from 2.8.8 to 2.8.9 | ||
- [`#417`](https://github.com/lifion/sqslite/pull/417): Bump path-parse from 1.0.6 to 1.0.7 | ||
- [`#416`](https://github.com/lifion/sqslite/pull/416): Upgrade dependencies | ||
- [`#415`](https://github.com/lifion/sqslite/pull/415): Bump @types/node from 16.3.3 to 16.7.1 | ||
- [`#414`](https://github.com/lifion/sqslite/pull/414): Bump aws-sdk from 2.950.0 to 2.975.0 | ||
- [`#407`](https://github.com/lifion/sqslite/pull/407): Bump chalk from 4.1.1 to 4.1.2 | ||
- [`#404`](https://github.com/lifion/sqslite/pull/404): Bump eslint from 7.31.0 to 7.32.0 | ||
- [`#402`](https://github.com/lifion/sqslite/pull/402): Bump npm-watch from 0.10.0 to 0.11.0 | ||
- [`#394`](https://github.com/lifion/sqslite/pull/394): Bump aws-sdk from 2.945.0 to 2.950.0 | ||
- [`#396`](https://github.com/lifion/sqslite/pull/396): Bump codecov from 3.8.2 to 3.8.3 | ||
- [`#395`](https://github.com/lifion/sqslite/pull/395): Bump eslint from 7.30.0 to 7.31.0 | ||
- [`#393`](https://github.com/lifion/sqslite/pull/393): Bump @types/node from 16.3.2 to 16.3.3 | ||
- [`#392`](https://github.com/lifion/sqslite/pull/392): updated node versions | ||
- [`#390`](https://github.com/lifion/sqslite/pull/390): Bump lint-staged from 11.0.0 to 11.0.1 | ||
- [`#389`](https://github.com/lifion/sqslite/pull/389): Bump fastify from 3.19.0 to 3.19.1 | ||
- [`#388`](https://github.com/lifion/sqslite/pull/388): Bump aws-sdk from 2.943.0 to 2.945.0 | ||
- [`#386`](https://github.com/lifion/sqslite/pull/386): Bump @types/node from 15.14.2 to 16.3.1 | ||
- [`#381`](https://github.com/lifion/sqslite/pull/381): Bump jest from 26.6.3 to 27.0.6 | ||
- [`#368`](https://github.com/lifion/sqslite/pull/368): Bump npm-watch from 0.9.0 to 0.10.0 | ||
- [`#385`](https://github.com/lifion/sqslite/pull/385): Bump husky from 6.0.0 to 7.0.1 | ||
- [`#339`](https://github.com/lifion/sqslite/pull/339): Bump lint-staged from 10.5.4 to 11.0.0 | ||
- [`#363`](https://github.com/lifion/sqslite/pull/363): Bump glob-parent from 5.1.1 to 5.1.2 | ||
- [`#351`](https://github.com/lifion/sqslite/pull/351): Bump browserslist from 4.16.3 to 4.16.6 | ||
- [`#343`](https://github.com/lifion/sqslite/pull/343): Bump hosted-git-info from 2.8.8 to 2.8.9 | ||
- [`#384`](https://github.com/lifion/sqslite/pull/384): brought all the dependencies up to date | ||
- [`#361`](https://github.com/lifion/sqslite/pull/361): Upgraded dependencies | ||
- [`#337`](https://github.com/lifion/sqslite/pull/337): Bump superstruct from 0.15.1 to 0.15.2 | ||
- [`#336`](https://github.com/lifion/sqslite/pull/336): Bump eslint from 7.25.0 to 7.26.0 | ||
- [`#332`](https://github.com/lifion/sqslite/pull/332): Bump aws-sdk from 2.893.0 to 2.899.0 | ||
- [`#334`](https://github.com/lifion/sqslite/pull/334): Bump codecov from 3.8.1 to 3.8.2 | ||
- [`#335`](https://github.com/lifion/sqslite/pull/335): Bump @types/node from 15.0.0 to 15.0.1 | ||
- [`#333`](https://github.com/lifion/sqslite/pull/333): Bump fastify from 3.15.0 to 3.15.1 | ||
- [`#331`](https://github.com/lifion/sqslite/pull/331): Bump aws-sdk from 2.889.0 to 2.893.0 | ||
- [`#330`](https://github.com/lifion/sqslite/pull/330): Bump eslint from 7.24.0 to 7.25.0 | ||
- [`#329`](https://github.com/lifion/sqslite/pull/329): Bump chalk from 4.1.0 to 4.1.1 | ||
- [`#328`](https://github.com/lifion/sqslite/pull/328): Bump fastify from 3.14.2 to 3.15.0 | ||
- [`#327`](https://github.com/lifion/sqslite/pull/327): Bump @types/node from 14.14.41 to 15.0.0 | ||
- [`#326`](https://github.com/lifion/sqslite/pull/326): Bump @types/node from 14.14.37 to 14.14.41 | ||
- [`#325`](https://github.com/lifion/sqslite/pull/325): Bump aws-sdk from 2.885.0 to 2.889.0 | ||
- [`#316`](https://github.com/lifion/sqslite/pull/316): Bump husky from 5.2.0 to 6.0.0 | ||
- [`#324`](https://github.com/lifion/sqslite/pull/324): Bump fastify from 3.14.1 to 3.14.2 | ||
- [`#322`](https://github.com/lifion/sqslite/pull/322): Bump aws-sdk from 2.880.0 to 2.885.0 | ||
- [`#321`](https://github.com/lifion/sqslite/pull/321): Bump eslint-config-lifion from 2.0.2 to 2.0.3 | ||
- [`#320`](https://github.com/lifion/sqslite/pull/320): Bump eslint from 7.23.0 to 7.24.0 | ||
- [`#323`](https://github.com/lifion/sqslite/pull/323): Bump typescript from 4.2.3 to 4.2.4 | ||
- [`#319`](https://github.com/lifion/sqslite/pull/319): Bump aws-sdk from 2.875.0 to 2.880.0 | ||
- [`#318`](https://github.com/lifion/sqslite/pull/318): Bump jsdoc-to-markdown from 7.0.0 to 7.0.1 | ||
- [`#317`](https://github.com/lifion/sqslite/pull/317): Bump @types/node from 14.14.35 to 14.14.37 | ||
- [`#314`](https://github.com/lifion/sqslite/pull/314): Bump superstruct from 0.14.2 to 0.15.1 | ||
- [`#315`](https://github.com/lifion/sqslite/pull/315): Bump eslint from 7.22.0 to 7.23.0 | ||
- [`#313`](https://github.com/lifion/sqslite/pull/313): Bump fastify from 3.14.0 to 3.14.1 | ||
- [`#312`](https://github.com/lifion/sqslite/pull/312): Bump aws-sdk from 2.869.0 to 2.875.0 | ||
- [`#309`](https://github.com/lifion/sqslite/pull/309): Bump husky from 5.1.3 to 5.2.0 | ||
- [`#310`](https://github.com/lifion/sqslite/pull/310): Bump aws-sdk from 2.864.0 to 2.869.0 | ||
- [`#311`](https://github.com/lifion/sqslite/pull/311): Bump semver from 7.3.4 to 7.3.5 | ||
- [`#307`](https://github.com/lifion/sqslite/pull/307): Bump npm-watch from 0.7.0 to 0.9.0 | ||
- [`#304`](https://github.com/lifion/sqslite/pull/304): Bump eslint from 7.21.0 to 7.22.0 | ||
- [`#305`](https://github.com/lifion/sqslite/pull/305): Bump fastify from 3.13.0 to 3.14.0 | ||
- [`#306`](https://github.com/lifion/sqslite/pull/306): Bump @types/node from 14.14.32 to 14.14.35 | ||
- [`#308`](https://github.com/lifion/sqslite/pull/308): Bump aws-sdk from 2.859.0 to 2.864.0 | ||
- [`#303`](https://github.com/lifion/sqslite/pull/303): Bump aws-sdk from 2.858.0 to 2.859.0 | ||
- [`#302`](https://github.com/lifion/sqslite/pull/302): Remove automerge, and change interval to weekly | ||
- [`#297`](https://github.com/lifion/sqslite/pull/297): Bump fastify/github-action-merge-dependabot from v1.2.0 to v1.2.1 | ||
- [`#299`](https://github.com/lifion/sqslite/pull/299): Bump typescript from 4.2.2 to 4.2.3 | ||
- [`#300`](https://github.com/lifion/sqslite/pull/300): Bump @types/node from 14.14.31 to 14.14.32 | ||
- [`#301`](https://github.com/lifion/sqslite/pull/301): Bump aws-sdk from 2.857.0 to 2.858.0 | ||
- [`#298`](https://github.com/lifion/sqslite/pull/298): Bump aws-sdk from 2.856.0 to 2.857.0 | ||
- [`#296`](https://github.com/lifion/sqslite/pull/296): Modify automerge to act on PR approval | ||
- [`#295`](https://github.com/lifion/sqslite/pull/295): Bump fastify/github-action-merge-dependabot from v1.1.1 to v1.2.0 | ||
- [`#294`](https://github.com/lifion/sqslite/pull/294): Bump aws-sdk from 2.855.0 to 2.856.0 | ||
- [`#293`](https://github.com/lifion/sqslite/pull/293): Bump fastify from 3.12.0 to 3.13.0 | ||
- [`#292`](https://github.com/lifion/sqslite/pull/292): Bump aws-sdk from 2.854.0 to 2.855.0 | ||
- [`#291`](https://github.com/lifion/sqslite/pull/291): Bump husky from 5.1.2 to 5.1.3 | ||
- [`#290`](https://github.com/lifion/sqslite/pull/290): Bump aws-sdk from 2.853.0 to 2.854.0 | ||
- [`#288`](https://github.com/lifion/sqslite/pull/288): Bump aws-sdk from 2.852.0 to 2.853.0 | ||
- [`#287`](https://github.com/lifion/sqslite/pull/287): Bump eslint from 7.20.0 to 7.21.0 | ||
- [`#286`](https://github.com/lifion/sqslite/pull/286): Bump husky from 5.1.1 to 5.1.2 | ||
- [`#285`](https://github.com/lifion/sqslite/pull/285): Bump jsdoc-to-markdown from 6.0.1 to 7.0.0 | ||
- [`#284`](https://github.com/lifion/sqslite/pull/284): Bump aws-sdk from 2.851.0 to 2.852.0 | ||
- [`#279`](https://github.com/lifion/sqslite/pull/279): Bump eslint-config-lifion from 1.4.0 to 2.0.2 | ||
- [`#280`](https://github.com/lifion/sqslite/pull/280): Bump aws-sdk from 2.850.0 to 2.851.0 | ||
- [`#282`](https://github.com/lifion/sqslite/pull/282): Bump fastify/github-action-merge-dependabot from v1 to v1.1.1 | ||
- [`#283`](https://github.com/lifion/sqslite/pull/283): Update dependabot | ||
- [`#281`](https://github.com/lifion/sqslite/pull/281): Update dependabot setup | ||
- [`#278`](https://github.com/lifion/sqslite/pull/278): Fake old dependencies | ||
- [`#261`](https://github.com/lifion/sqslite/pull/261): Update package.json dependencies | ||
- [`986a30f`](https://github.com/lifion/sqslite/commit/986a30f6f6626b5fd628820cd62f3ab5d39fc330): added core-commons to project | ||
- [`58e0b15`](https://github.com/lifion/sqslite/commit/58e0b15fb745a79f4d7506ee886d9d0dad1cf26f): Update engine to 14, remove unused dev dependencies | ||
- [`7b1afc4`](https://github.com/lifion/sqslite/commit/7b1afc40993a4a85a2e133a7ce78fdda7c22b220): Revert "Upgrade dependencies" | ||
- [`7125c97`](https://github.com/lifion/sqslite/commit/7125c972c21c99836b7f7e9c23adc2487014d178): Update dependencies | ||
- [`1c111f8`](https://github.com/lifion/sqslite/commit/1c111f8a20a7d472d0919d2b3cf7995e1c2f3801): added package.json files, removed test jsons | ||
- [`7bb9083`](https://github.com/lifion/sqslite/commit/7bb90838c2a81c145dff511cae05b49340061ca1): Update package-lock | ||
- [`08e577b`](https://github.com/lifion/sqslite/commit/08e577b59397b10f436e5e3560449e84147b0f1f): Fake old dependency | ||
- [`620de87`](https://github.com/lifion/sqslite/commit/620de876a56897c200af1f338272cc6cd854cb16): Fixed typescript errors, Added queue null check in tag functions, fixed eslint | ||
- [`0e0a13f`](https://github.com/lifion/sqslite/commit/0e0a13fa793fe4640a7d65611234da03af51628f): fixed no-secrets, fixed eslint warnings | ||
- [`21a6819`](https://github.com/lifion/sqslite/commit/21a681932c5b4534967d7692c9b7c5becddaf16c): finished documenting actions | ||
- [`9b33be3`](https://github.com/lifion/sqslite/commit/9b33be352c417376d3faf5e458525df13cc78a57): Revert README | ||
- [`ab1ed16`](https://github.com/lifion/sqslite/commit/ab1ed166587f0a017aba3c85c6bbe71e472aa6ab): refactored array reduce, fixed eslint and typings, bumped node to 12 | ||
- [`d5fe41e`](https://github.com/lifion/sqslite/commit/d5fe41e88f9bb2b9db54f8586cdfa5e428412ccb): Add rest of documentation | ||
- [`57507f8`](https://github.com/lifion/sqslite/commit/57507f8ca7b9d83a65343a3c9de3ea2124f11b58): updated jsdoc based on comments | ||
- [`d3035fa`](https://github.com/lifion/sqslite/commit/d3035fa8567827d4bc903d9023e20a92ffa2adca): prettier | ||
- [`5e63f83`](https://github.com/lifion/sqslite/commit/5e63f830ee3c6ac300f0d72e58344e2ed7f02998): Upgrade husky | ||
- [`541e7ce`](https://github.com/lifion/sqslite/commit/541e7ce5031fb50fbda38686851c81948401c84f): Add type definitons | ||
- [`fdf0ab4`](https://github.com/lifion/sqslite/commit/fdf0ab4f8223a21e977a50b196c8743d17e3b716): Add documentation to a few functions in sqs | ||
- [`e6a61ed`](https://github.com/lifion/sqslite/commit/e6a61ed9274e540ca8e815431513b48c8029e43b): Update package-lock | ||
- [`c9e417f`](https://github.com/lifion/sqslite/commit/c9e417f9ed5932001427138340a106e568d2b299): Add type definitons | ||
- [`795fa78`](https://github.com/lifion/sqslite/commit/795fa7835ec6c788bfc00dd14c48b8531ff12e87): reverted docs to simple object declaration | ||
- [`6a6b530`](https://github.com/lifion/sqslite/commit/6a6b530905929789eb376797962beb0302ce4525): updated types, fixed docs | ||
- [`5247fda`](https://github.com/lifion/sqslite/commit/5247fda912959dc99fb6b44ac65f4f776d8600fa): Update issue templates | ||
- [`1444d2f`](https://github.com/lifion/sqslite/commit/1444d2fd786d88f9d00a1c3e18a8559470a609b3): Remove old husky config | ||
- [`f7ed815`](https://github.com/lifion/sqslite/commit/f7ed8158882527f1ad25e36080dad9473fded36d): added exceptions to jsdoc | ||
- [`4bfe30f`](https://github.com/lifion/sqslite/commit/4bfe30f10b41b11c68de288398d421b06b7dd7d9): Fix spacing to be consistent | ||
- [`9690f29`](https://github.com/lifion/sqslite/commit/9690f29a493badb609e52acbac6fe8dc865df472): edited jsdoc descriptions | ||
- [`50abbe4`](https://github.com/lifion/sqslite/commit/50abbe475d0043a7f9f800af0f8c4c70d9c2deaa): reworded comments | ||
- [`fb3fa83`](https://github.com/lifion/sqslite/commit/fb3fa83274c1021aa1b89d9d1621b0a9b8d2b5c8): set no-secret as rule, not override | ||
- [`3e68ca6`](https://github.com/lifion/sqslite/commit/3e68ca62b3c2ba7dd70f66a5f893215c43d22156): reworded comments | ||
- [`fa29670`](https://github.com/lifion/sqslite/commit/fa296704745992c67d300023e5285e6a000f7551): Fix license | ||
- [`7f12f2d`](https://github.com/lifion/sqslite/commit/7f12f2debef835e9c43636fd7191ae0a234d2313): Update node versions for build pipeline | ||
- [`26a44e4`](https://github.com/lifion/sqslite/commit/26a44e426a8ecb2b5bc2d3eadaeed24d2903e581): Update package-lock | ||
- [`97c0390`](https://github.com/lifion/sqslite/commit/97c03909b901eaf27bb90b0a9c3634d40bb185ba): Add description for param | ||
- [`c8c6cbb`](https://github.com/lifion/sqslite/commit/c8c6cbb90a59e943897961f8fa341379d17ca921): Remove old husky config | ||
- [`4c8ba64`](https://github.com/lifion/sqslite/commit/4c8ba64f1b5d774d3a761ebac3c4d97335619350): added 16 version | ||
- [`83aaaa7`](https://github.com/lifion/sqslite/commit/83aaaa73e1c4687c258982fdcdf1507f9029fcd9): added maintainers | ||
- [`b64372c`](https://github.com/lifion/sqslite/commit/b64372c92e28f69a649dc0a090b2975071e6582c): Remove unnecessary comment | ||
- [`ce8b0a4`](https://github.com/lifion/sqslite/commit/ce8b0a44cd88887ac8303ad9b6a3ffcd1abf08ce): Another test branch | ||
- [`3812bb6`](https://github.com/lifion/sqslite/commit/3812bb6fa8186b8ac6be5f5a1f6e67067232b166): Resolve conflicts | ||
### v1.0.0 (2021-02-23) | ||
@@ -12,0 +161,0 @@ |
@@ -6,2 +6,12 @@ 'use strict'; | ||
/** | ||
* Changes the queue's message visibility timeout. | ||
* | ||
* @param {Object} body - Request body. | ||
* @param {string} body.QueueUrl - The url for the queue that contains the message. | ||
* @param {string} body.ReceiptHandle - The receipt handle identifier. | ||
* @param {number} body.VisibilityTimeout - The new visibility time out value. | ||
* @returns {string} ChangeMessageVisibilityResponse in XML format. | ||
* @throws ErrorResponse in XML format, based on `changeMessageVisibility` errors. | ||
*/ | ||
module.exports = ({ QueueUrl, ReceiptHandle, VisibilityTimeout }) => { | ||
@@ -8,0 +18,0 @@ try { |
@@ -6,2 +6,10 @@ 'use strict'; | ||
/** | ||
* Creates a message queue. | ||
* | ||
* @param {Object.<string, string>} body - Request body. | ||
* @param {string} host - The host of the queue. | ||
* @returns {string} CreateQueueResponse in XML format. | ||
* @throws ErrorResponse in XML format, based on `createQueue` errors. | ||
*/ | ||
module.exports = (body, host) => { | ||
@@ -14,2 +22,4 @@ const params = { QueueName: body.QueueName }; | ||
const attributeKeys = keys.filter((key) => key.startsWith('Attribute')); | ||
/** @type {Object.<string, any>} */ | ||
const Attributes = {}; | ||
@@ -22,2 +32,4 @@ for (let i = 1; i <= attributeKeys.length / 2; i += 1) { | ||
const tagKeys = keys.filter((key) => key.startsWith('Tag')); | ||
/** @type {Object.<string, any>} */ | ||
const Tags = {}; | ||
@@ -24,0 +36,0 @@ for (let i = 1; i <= tagKeys.length / 2; i += 1) { |
@@ -6,2 +6,9 @@ 'use strict'; | ||
/** | ||
* Delete messages in batch from the queue. | ||
* | ||
* @param {Object.<string, string>} body - Request body. | ||
* @returns {string} DeleteMessageBatchResponse in XML format. | ||
* @throws ErrorResponse in XML format, based on `deleteMessageBatch` errors. | ||
*/ | ||
module.exports = (body) => { | ||
@@ -8,0 +15,0 @@ const { QueueUrl } = body; |
@@ -6,2 +6,10 @@ 'use strict'; | ||
/** | ||
* Deletes a message from the queue. | ||
* | ||
* @param {Object} body - Request body. | ||
* @param {string} body.QueueUrl - The url of the queue. | ||
* @param {string} body.ReceiptHandle - The receipt handle identifier of the message to be deleted. | ||
* @returns {string} DeleteMessageResponse in XML format. | ||
*/ | ||
module.exports = ({ QueueUrl, ReceiptHandle }) => { | ||
@@ -8,0 +16,0 @@ const params = { QueueUrl, ReceiptHandle }; |
@@ -6,2 +6,9 @@ 'use strict'; | ||
/** | ||
* Deletes a queue. | ||
* | ||
* @param {Object} body - Request body. | ||
* @param {string} body.QueueUrl - The url of the queue. | ||
* @returns {string} DeleteQueueResponse in XML format. | ||
*/ | ||
module.exports = ({ QueueUrl }) => { | ||
@@ -8,0 +15,0 @@ const params = { QueueUrl }; |
@@ -6,2 +6,9 @@ 'use strict'; | ||
/** | ||
* Retrieve attributes of the queue. | ||
* | ||
* @param {Object.<string, string>} body - Request body. | ||
* @returns {string} GetQueueAttributesResponse in XML format. | ||
* @throws ErrorResponse in XML format, based on `getQueueAttributes` errors. | ||
*/ | ||
module.exports = (body) => { | ||
@@ -17,2 +24,3 @@ const { QueueUrl } = body; | ||
try { | ||
/** @type {Object.<string, any>} */ | ||
const res = getQueueAttributes(QueueUrl, attributes); | ||
@@ -19,0 +27,0 @@ return toXml('GetQueueAttributesResponse', { |
@@ -6,2 +6,11 @@ 'use strict'; | ||
/** | ||
* Retrieves the url of the queue. | ||
* | ||
* @param {Object} body - Request body. | ||
* @param {string} body.QueueName - The name of the queue. | ||
* @param {string} host - The host of the queue. | ||
* @returns {string} GetQueueUrlResponse in XML format. | ||
* @throws ErrorReponse in XML format, based on `getQueueUrl` errors. | ||
*/ | ||
module.exports = ({ QueueName }, host) => { | ||
@@ -8,0 +17,0 @@ try { |
@@ -6,2 +6,11 @@ 'use strict'; | ||
/** | ||
* Retrieves list of queues with configured RedrivePolicy set to a dead-letter queues. | ||
* | ||
* @param {Object} body - Request body. | ||
* @param {string} body.QueueUrl - The url of the queue. | ||
* @param {string} host - The host of the queue. | ||
* @returns {string} ListDeadLetterSourceQueuesResponse in XML format. | ||
* @throws ErrorReponse in XML format, based on `listDeadLetterSourceQueues` errors. | ||
*/ | ||
module.exports = ({ QueueUrl }, host) => { | ||
@@ -8,0 +17,0 @@ try { |
@@ -6,3 +6,11 @@ 'use strict'; | ||
/** | ||
* Retrieve tags for the queue. | ||
* | ||
* @param {Object} body - Request body. | ||
* @param {string} body.QueueUrl - The url of the queue. | ||
* @returns {string} ListQueueTagsResponse in XML format. | ||
*/ | ||
module.exports = ({ QueueUrl }) => { | ||
/** @type {Object.<string, string>} */ | ||
const tags = listQueueTags(QueueUrl); | ||
@@ -9,0 +17,0 @@ |
@@ -6,2 +6,7 @@ 'use strict'; | ||
/** | ||
* Retrieves the total list of queues. | ||
* | ||
* @returns {string} ListQueuesResponse in XML format. | ||
*/ | ||
module.exports = () => | ||
@@ -8,0 +13,0 @@ toXml('ListQueuesResponse', { |
@@ -6,2 +6,10 @@ 'use strict'; | ||
/** | ||
* Delete all messages in the queue. | ||
* | ||
* @param {Object} body - Request body. | ||
* @param {string} body.QueueUrl - The url of the queue. | ||
* @returns {string} ListQueueTagsResponse in XML format. | ||
* @throws ErrorResponse in XML format, based on `purgeQueue` errors. | ||
*/ | ||
module.exports = ({ QueueUrl }) => { | ||
@@ -8,0 +16,0 @@ try { |
@@ -6,2 +6,9 @@ 'use strict'; | ||
/** | ||
* Retrieves a message from the queue. | ||
* | ||
* @param {Object.<string, any>} body - Request body. | ||
* @returns {string} ReceiveMessageResponse in XML format. | ||
* @throws ErrorResponse in XML format, based on `receiveMessage` errors. | ||
*/ | ||
module.exports = (body) => { | ||
@@ -11,2 +18,7 @@ const { MaxNumberOfMessages, QueueUrl, VisibilityTimeout, WaitTimeSeconds } = body; | ||
const { attributes, messageAttributes } = Object.entries(body).reduce( | ||
/** | ||
* @param {{ attributes: string[], messageAttributes: string[] }} acc - Accumulator. | ||
* @param {string[]} keyValue - KeyValue. | ||
* @returns {{ attributes: string[], messageAttributes: string[] }} | ||
*/ | ||
(acc, [key, value]) => { | ||
@@ -13,0 +25,0 @@ if (key.startsWith('MessageAttributeName')) { |
'use strict'; | ||
const { sendMessageBatch } = require('../sqs'); | ||
const { MessageBatchObject, sendMessageBatch } = require('../sqs'); | ||
const { toXml, toXmlError } = require('../utils/xml-helper'); | ||
/** | ||
* Helper for processing the params for send batch messages. | ||
* | ||
* @param {Object.<string, any>} body - Request body. | ||
* @returns {MessageBatchObject} Sanitized parameter object. | ||
*/ | ||
function processParams(body) { | ||
const { DelaySeconds, Id, MessageBody } = body; | ||
/** @type {MessageBatchObject} */ | ||
const params = { DelaySeconds, Id, MessageBody }; | ||
@@ -14,5 +21,7 @@ | ||
const messageAttributes = objs.reduce((acc, obj, index) => { | ||
const i = index + 1; // Starts at 1 | ||
acc[body[`MessageAttribute.${i}.Name`]] = { | ||
/** @type {Object.<string, any>} */ | ||
const messageAttributes = {}; | ||
for (let i = 1; i <= objs.length; i += 1) { | ||
messageAttributes[body[`MessageAttribute.${i}.Name`]] = { | ||
DataType: body[`MessageAttribute.${i}.Value.DataType`] | ||
@@ -22,3 +31,3 @@ }; | ||
if (body[`MessageAttribute.${i}.Value.StringValue`]) { | ||
acc[body[`MessageAttribute.${i}.Name`]].StringValue = | ||
messageAttributes[body[`MessageAttribute.${i}.Name`]].StringValue = | ||
body[`MessageAttribute.${i}.Value.StringValue`]; | ||
@@ -28,9 +37,7 @@ } | ||
if (body[`MessageAttribute.${i}.Value.BinaryValue`]) { | ||
acc[body[`MessageAttribute.${i}.Name`]].BinaryValue = | ||
messageAttributes[body[`MessageAttribute.${i}.Name`]].BinaryValue = | ||
body[`MessageAttribute.${i}.Value.BinaryValue`]; | ||
} | ||
} | ||
return acc; | ||
}, {}); | ||
if (Object.keys(messageAttributes).length > 0) { | ||
@@ -43,4 +50,12 @@ params.MessageAttributes = messageAttributes; | ||
/** | ||
* Send messages in batch to the queue. | ||
* | ||
* @param {Object.<string, any>} body - Request body. | ||
* @returns {string} SendMessageBatchResponse in XML format. | ||
* @throws ErrorResponse in XML format, based on sendMessageBatch's errors. | ||
*/ | ||
module.exports = (body) => { | ||
const bodyKeys = Object.keys(body); | ||
/** @type {Object.<string, any>} */ | ||
const result = {}; | ||
@@ -68,2 +83,3 @@ | ||
for (let i = 1; i <= Object.keys(result).length; i += 1) { | ||
/** @type {Object.<string, any>} */ | ||
const prep = {}; | ||
@@ -70,0 +86,0 @@ for (const key of result[i]) { |
'use strict'; | ||
const { sendMessage } = require('../sqs'); | ||
const { SendMessageParams, sendMessage } = require('../sqs'); | ||
const { toXml, toXmlError } = require('../utils/xml-helper'); | ||
@@ -9,3 +9,13 @@ const { ErrorWithCode } = require('../utils/errors'); | ||
/** | ||
* Sends a message to the queue. | ||
* | ||
* @param {Object.<string, any>} body - Request body. | ||
* @returns {string} XMLSendMessageResponse. | ||
* @throws InvalidParameterValue, thrown when number of attributes exceed the maximum (10). | ||
* @throws InvalidParameterValue, thrown when an attribute's name is invalid. | ||
* @throws XMLErrors, based on sendMessage's errors. | ||
*/ | ||
module.exports = (body) => { | ||
/** @type {SendMessageParams} */ | ||
const params = { | ||
@@ -29,5 +39,7 @@ DelaySeconds: body.DelaySeconds, | ||
const messageAttributes = objs.reduce((acc, obj, index) => { | ||
const i = index + 1; // Starts at 1 | ||
acc[body[`MessageAttribute.${i}.Name`]] = { | ||
/** @type {Object.<string, any>} */ | ||
const messageAttributes = {}; | ||
for (let i = 1; i <= objs.length; i += 1) { | ||
messageAttributes[body[`MessageAttribute.${i}.Name`]] = { | ||
DataType: body[`MessageAttribute.${i}.Value.DataType`] | ||
@@ -37,3 +49,3 @@ }; | ||
if (body[`MessageAttribute.${i}.Value.StringValue`]) { | ||
acc[body[`MessageAttribute.${i}.Name`]].StringValue = | ||
messageAttributes[body[`MessageAttribute.${i}.Name`]].StringValue = | ||
body[`MessageAttribute.${i}.Value.StringValue`]; | ||
@@ -43,9 +55,7 @@ } | ||
if (body[`MessageAttribute.${i}.Value.BinaryValue`]) { | ||
acc[body[`MessageAttribute.${i}.Name`]].BinaryValue = | ||
messageAttributes[body[`MessageAttribute.${i}.Name`]].BinaryValue = | ||
body[`MessageAttribute.${i}.Value.BinaryValue`]; | ||
} | ||
} | ||
return acc; | ||
}, {}); | ||
if (Object.keys(messageAttributes).length > 0) { | ||
@@ -55,2 +65,3 @@ params.MessageAttributes = messageAttributes; | ||
/** @type {Object.<string, any>} */ | ||
const messageSystemAttributes = {}; | ||
@@ -57,0 +68,0 @@ |
@@ -6,2 +6,9 @@ 'use strict'; | ||
/** | ||
* Set attributes for the queue. | ||
* | ||
* @param {Object.<string, string>} body - Request body. | ||
* @returns {string} SetQueueAttributesResponse in XML format. | ||
* @throws ErrorResponse in XML format, based on `setQueueAttributes` errors. | ||
*/ | ||
module.exports = (body) => { | ||
@@ -12,2 +19,4 @@ const { QueueUrl } = body; | ||
const attributeKeys = keys.filter((key) => key.startsWith('Attribute')); | ||
/** @type {Object.<string, any>} */ | ||
const Attributes = {}; | ||
@@ -14,0 +23,0 @@ for (let i = 1; i <= attributeKeys.length / 2; i += 1) { |
@@ -6,2 +6,8 @@ 'use strict'; | ||
/** | ||
* Add tags to the queue. | ||
* | ||
* @param {Object.<string, string>} body - Request body. | ||
* @returns {string} TagQueueResponse in XML format. | ||
*/ | ||
module.exports = (body) => { | ||
@@ -11,2 +17,4 @@ const { QueueUrl } = body; | ||
const tagKeys = Object.keys(body).filter((key) => key.startsWith('Tag')); | ||
/** @type {Object.<string, string>} */ | ||
const Tags = {}; | ||
@@ -13,0 +21,0 @@ for (let i = 1; i <= tagKeys.length / 2; i += 1) { |
@@ -6,2 +6,8 @@ 'use strict'; | ||
/** | ||
* Remove tags from the queue. | ||
* | ||
* @param {Object.<string, string>} body - Request body. | ||
* @returns {string} UntagQueueResponse in XML format. | ||
*/ | ||
module.exports = (body) => { | ||
@@ -8,0 +14,0 @@ const tagKeys = Object.keys(body).filter((key) => key.startsWith('Tag')); |
'use strict'; | ||
const fastify = require('fastify'); | ||
/** @type {*} */ | ||
const fastifyFormBody = require('fastify-formbody'); | ||
@@ -24,4 +25,10 @@ | ||
/** | ||
* Sets up the server instance. | ||
* | ||
* @param {Object} opts - Additional server options | ||
* @returns {fastify.FastifyInstance} - Returns the server instance. | ||
*/ | ||
module.exports = (opts) => { | ||
const app = fastify({ | ||
const app = fastify.default({ | ||
logger: true, | ||
@@ -34,2 +41,3 @@ ...opts | ||
app.post('/', async (request, reply) => { | ||
/** @type {*} */ | ||
const { body, headers } = request; | ||
@@ -78,3 +86,3 @@ const { host } = headers; | ||
} | ||
} catch (err) { | ||
} catch (/** @type {*} */ err) { | ||
reply.status(400); | ||
@@ -81,0 +89,0 @@ return err.xml; |
418
lib/sqs.js
@@ -17,4 +17,15 @@ 'use strict'; | ||
/** | ||
* @type {Map.<string, QueueObject>} | ||
*/ | ||
const queues = new Map(); | ||
/** | ||
* Validates if the queue name follows naming convention. | ||
* | ||
* @param {string} queueName - The name of the queue. | ||
* @param {boolean} isFifo - FiFo queue check to determine name suffix. | ||
* @returns {void} | ||
* @throws InvalidParameterValue, thrown when queue name is invalid. | ||
*/ | ||
function validateQueueName(queueName, isFifo) { | ||
@@ -29,2 +40,10 @@ if ((isFifo && !queueName.endsWith('.fifo')) || (!isFifo && queueName.endsWith('.fifo'))) { | ||
/** | ||
* Validates existence of dead letter queue. | ||
* | ||
* @param {string} deadLetterQueueArn - Amazon Resource Name for dead letter queue. | ||
* @param {boolean} isFifo - Fifo queue check to match source. | ||
* @returns {void} | ||
* @throws InvalidParameterValue, thrown when dead letter queue fails validation. | ||
*/ | ||
function validateDeadLetterQueue(deadLetterQueueArn, isFifo) { | ||
@@ -54,2 +73,9 @@ let foundArn; | ||
/** | ||
* Content based deduplication flag. | ||
* | ||
* @param {boolean} contentBasedDeduplication - Content based deduplication. | ||
* @returns {void} | ||
* @throws InvalidAttributeName | ||
*/ | ||
function validateNoContentBasedDeduplication(contentBasedDeduplication) { | ||
@@ -61,2 +87,10 @@ if (contentBasedDeduplication) { | ||
/** | ||
* Checks if there is an existing queue with the same attributes. | ||
* | ||
* @param {string} queueName - The name of the queue. | ||
* @param {Object.<string, any>} attributes - The attributes of the queue. | ||
* @returns {void} | ||
* @throws QueueAlreadyExists, thrown when queue with the same name and different attribute already exists. | ||
*/ | ||
function queueAlreadyExists(queueName, attributes) { | ||
@@ -92,2 +126,6 @@ const queueWithSameName = queues.get(queueName); | ||
const wrongAttr = compareAttributes.find( | ||
/** | ||
* @param {string} attr - attributes. | ||
* @returns {boolean} | ||
*/ | ||
(attr) => | ||
@@ -107,2 +145,7 @@ queueWithSameName.Attributes[attr] && | ||
/** | ||
* Clears all queues. | ||
* | ||
* @returns {void} | ||
*/ | ||
function clearQueues() { | ||
@@ -112,2 +155,8 @@ queues.clear(); | ||
/** | ||
* Gets state of queue. | ||
* | ||
* @param {string} QueueUrl - The url for the queue. | ||
* @returns {QueueObject|undefined} The requested queue. | ||
*/ | ||
function getQueueState(QueueUrl) { | ||
@@ -119,5 +168,12 @@ const convertedQueue = QueueUrl.replace(QUEUE_URL_REGEX, ''); | ||
/** | ||
* Creates a queue. | ||
* | ||
* @param {CreateQueueParams} params - Parameters for createQueue. | ||
* @param {string} host - Host name for the queue url. | ||
* @returns {string} The queue URL. | ||
*/ | ||
function createQueue(params, host) { | ||
const queueParams = assertQueue(params); | ||
/** @type {*} */ | ||
const { Attributes, QueueName, tags = {} } = queueParams; | ||
@@ -153,3 +209,3 @@ | ||
const queueArn = `${QUEUE_ARN}${QueueName}`; | ||
queues.set(QueueName, { | ||
const queueObject = { | ||
'@State': {}, | ||
@@ -172,7 +228,17 @@ Attributes: { | ||
tags | ||
}); | ||
}; | ||
queues.set(QueueName, queueObject); | ||
return queueUrl; | ||
} | ||
/** | ||
* Sends a message. | ||
* | ||
* @param {SendMessageParams} params - Parameters for the message. | ||
* @returns {EncodedMessage} - The encoded message. | ||
* @throws AWS.SimpleQueueService.NonExistentQueue, thrown if queue does not exist. | ||
* @throws MissingParameter, thrown if parameter MessageGroupId is missing. | ||
*/ | ||
function sendMessage(params) { | ||
@@ -249,3 +315,5 @@ const { | ||
MessageId, | ||
...(MessageAttributes && { MD5OfMessageAttributes: md5(MessageAttributes) }), | ||
...(MessageAttributes && { | ||
MD5OfMessageAttributes: md5(MessageAttributes) | ||
}), | ||
...(MessageDeduplicationId && { | ||
@@ -256,3 +324,5 @@ MessageDeduplicationId, | ||
...(DelaySeconds && { DelaySeconds }), | ||
...(MessageSystemAttributes && { MD5OfMessageSystemAttributes: md5(MessageSystemAttributes) }) | ||
...(MessageSystemAttributes && { | ||
MD5OfMessageSystemAttributes: md5(MessageSystemAttributes) | ||
}) | ||
}; | ||
@@ -264,2 +334,9 @@ | ||
/** | ||
* Send messages in a batch to a specified queue | ||
* | ||
* @param {SendMessageBatchParams} params - Parameters for the messages. | ||
* @returns {Array<EncodedMessage>} - The array of messages sent. | ||
* @throws AWS.SimpleQueueService.NonExistentQueue, thrown if queue does not exist. | ||
*/ | ||
function sendMessageBatch(params) { | ||
@@ -336,2 +413,7 @@ const { QueueUrl, messages } = params; | ||
/** | ||
* Get the current list of queues. | ||
* | ||
* @returns {Array<QueueObject>} - The array of queues. | ||
*/ | ||
function listQueues() { | ||
@@ -346,31 +428,61 @@ const list = []; | ||
} | ||
/** | ||
* Prepare received messages by mapping them into the correct format. | ||
* | ||
* @param {Array<string>} AttributeNames - The names of the queue attributes. | ||
* @param {Array<string>} MessageAttributeNames - The names of the message attributes. | ||
* @param {string} ReceiptHandle - The receipt handle identifier. | ||
* @param {Array<MessageObject>} messages - The array of messages. | ||
* @returns {Array<PreparedMessages>} - The prepared messages. | ||
*/ | ||
function prepareMessages(AttributeNames, MessageAttributeNames, ReceiptHandle, messages) { | ||
return messages.map(({ Attributes, MessageAttributes, MessageBody, MessageId }) => ({ | ||
Body: MessageBody, | ||
MD5OfBody: md5(MessageBody), | ||
MessageId, | ||
ReceiptHandle, | ||
...(AttributeNames && { | ||
Attributes: AttributeNames.includes('All') | ||
? Attributes | ||
: AttributeNames.reduce((acc, item) => { | ||
const value = Attributes[item]; | ||
if (value === undefined) return acc; | ||
return { ...acc, [item]: value }; | ||
}, {}) | ||
}), | ||
...(MessageAttributeNames && | ||
MessageAttributeNames.length > 0 && { | ||
MD5OfMessageAttributes: md5(MessageAttributeNames.join(',')), | ||
MessageAttributes: MessageAttributeNames.includes('All') | ||
? MessageAttributes | ||
: MessageAttributeNames.reduce((acc, item) => { | ||
const value = MessageAttributes[item]; | ||
if (value === undefined) return acc; | ||
return { ...acc, [item]: value }; | ||
}, {}) | ||
}) | ||
})); | ||
return messages.map( | ||
/** | ||
* @param {Object} msg - Message object. | ||
* @param {Object.<string, any>} msg.Attributes - Attributes. | ||
* @param {Object.<string, any>} msg.MessageAttributes - MessageAttributes. | ||
* @param {string} msg.MessageBody - MessageBody. | ||
* @param {string} msg.MessageId - MessageId. | ||
* @returns {PreparedMessages} | ||
*/ | ||
({ Attributes, MessageAttributes, MessageBody, MessageId }) => ({ | ||
Body: MessageBody, | ||
MD5OfBody: md5(MessageBody), | ||
MessageId, | ||
ReceiptHandle, | ||
...(AttributeNames && { | ||
Attributes: AttributeNames.includes('All') | ||
? Attributes | ||
: Object.fromEntries( | ||
Object.entries(Attributes).filter(([key]) => AttributeNames.includes(key)) | ||
) | ||
}), | ||
...(MessageAttributeNames && | ||
MessageAttributeNames.length > 0 && { | ||
MD5OfMessageAttributes: md5(MessageAttributeNames.join(',')), | ||
MessageAttributes: MessageAttributeNames.includes('All') | ||
? MessageAttributes | ||
: Object.fromEntries( | ||
Object.entries(MessageAttributes).filter(([key]) => | ||
MessageAttributeNames.includes(key) | ||
) | ||
) | ||
}) | ||
}) | ||
); | ||
} | ||
/** | ||
* Retrieves messages from the specified queue. | ||
* | ||
* @param {Object} params - The receive message parameters. | ||
* @param {Array<string>} params.AttributeNames - The names of the queue attributes. | ||
* @param {number} [params.MaxNumberOfMessages] - The names of the message attributes. | ||
* @param {Array<string>} params.MessageAttributeNames - The message attribute names. | ||
* @param {number} [params.VisibilityTimeout] - Timeout for the message being processed by other consumers. | ||
* @param {string} params.QueueUrl - The url of the queue to retrieve from. | ||
* @returns {Array<PreparedMessages>} - The retrieved and prepared messages. | ||
* @throws AWS.SimpleQueueService.NonExistentQueue, thrown if queue does not exist. | ||
*/ | ||
function receiveMessage({ | ||
@@ -393,2 +505,3 @@ AttributeNames, | ||
/** @type {Array<*>} */ | ||
let messages = []; | ||
@@ -407,2 +520,3 @@ let remainingMessages = []; | ||
/** @type {Object.<string, any>} */ | ||
const messageTest = {}; | ||
@@ -441,2 +555,3 @@ | ||
for (let j = 0; j < keys.length; j += 1) { | ||
/** @type {*} */ | ||
const index = keys[j]; | ||
@@ -467,2 +582,10 @@ queue.messages[index] = messageTest[index]; | ||
/** | ||
* Deletes message from the specified queue. | ||
* | ||
* @param {Object} params - Parameters for deleteMessage. | ||
* @param {string} params.QueueUrl - The url for the queue to delete from. | ||
* @param {string} params.ReceiptHandle - The receipt handle identifier. | ||
* @throws AWS.SimpleQueueService.NonExistentQueue, thrown if queue does not exist. | ||
*/ | ||
function deleteMessage({ QueueUrl, ReceiptHandle }) { | ||
@@ -479,2 +602,10 @@ const convertedQueue = QueueUrl.replace(QUEUE_URL_REGEX, ''); | ||
/** | ||
* Delete messages in a batch from the specified queue. | ||
* | ||
* @param {string} QueueUrl - The url for the queue to delete from. | ||
* @param {Array<DeleteMessageBatchRequestEntry>} Entries - List of messages to delete. | ||
* @returns {Array<string>} - The list of Ids of deleted messages. | ||
* @throws AWS.SimpleQueueService.NonExistentQueue, thrown if queue does not exist. | ||
*/ | ||
function deleteMessageBatch(QueueUrl, Entries) { | ||
@@ -495,2 +626,10 @@ const convertedQueue = QueueUrl.replace(QUEUE_URL_REGEX, ''); | ||
/** | ||
* Deletes specified queue. | ||
* | ||
* @param {Object} Params - The params for deleteQueue. | ||
* @param {string} Params.QueueUrl - The url for the queue to be deleted. | ||
* @returns {void} | ||
* @throws AWS.SimpleQueueService.NonExistentQueue, thrown if queue does not exist. | ||
*/ | ||
function deleteQueue({ QueueUrl }) { | ||
@@ -506,17 +645,51 @@ const convertedQueue = QueueUrl.replace(QUEUE_URL_REGEX, ''); | ||
/** | ||
* Add tags to specified queue. | ||
* | ||
* @param {string} QueueUrl - The url for the queue to add tags to. | ||
* @param {Object.<string,string>} tags - Tags to add. | ||
* @returns {void} | ||
* @throws AWS.SimpleQueueService.NonExistentQueue, thrown if queue does not exist. | ||
*/ | ||
function tagQueue(QueueUrl, tags) { | ||
const convertedQueue = QueueUrl.replace(QUEUE_URL_REGEX, ''); | ||
const queue = queues.get(convertedQueue); | ||
if (!queue) { | ||
throw new ErrorWithCode(NON_EXISTENT_QUEUE_MESSAGE, NON_EXISTENT_QUEUE_CODE); | ||
} | ||
queue.tags = { ...queue.tags, ...tags }; | ||
} | ||
/** | ||
* View tags of specified queue. | ||
* | ||
* @param {string} QueueUrl - The url for the queue to add tags to. | ||
* @returns {Object.<string, string>} Returns map of tags. | ||
* @throws AWS.SimpleQueueService.NonExistentQueue, thrown if queue does not exist. | ||
*/ | ||
function listQueueTags(QueueUrl) { | ||
const convertedQueue = QueueUrl.replace(QUEUE_URL_REGEX, ''); | ||
const queue = queues.get(convertedQueue); | ||
if (!queue) { | ||
throw new ErrorWithCode(NON_EXISTENT_QUEUE_MESSAGE, NON_EXISTENT_QUEUE_CODE); | ||
} | ||
return queue.tags; | ||
} | ||
/** | ||
* Removes tags from specified queue. | ||
* | ||
* @param {string} QueueUrl - The url for the queue to remove tags from. | ||
* @param {Array<string>} removeTags - Tags to be removed. | ||
* @returns {void} | ||
* @throws AWS.SimpleQueueService.NonExistentQueue, thrown if queue does not exist. | ||
*/ | ||
function untagQueue(QueueUrl, removeTags) { | ||
const convertedQueue = QueueUrl.replace(QUEUE_URL_REGEX, ''); | ||
const queue = queues.get(convertedQueue); | ||
if (!queue) { | ||
throw new ErrorWithCode(NON_EXISTENT_QUEUE_MESSAGE, NON_EXISTENT_QUEUE_CODE); | ||
} | ||
@@ -528,2 +701,10 @@ for (const tag of removeTags) { | ||
/** | ||
* Add attributes to specified queue. | ||
* | ||
* @param {string} QueueUrl - The url for the queue to add attributes to. | ||
* @param {Object.<string, any>} Attributes - The queue attributes to set. | ||
* @returns {void} | ||
* @throws AWS.SimpleQueueService.NonExistentQueue, thrown if queue does not exist. | ||
*/ | ||
function setQueueAttributes(QueueUrl, Attributes) { | ||
@@ -551,2 +732,10 @@ const convertedQueue = QueueUrl.replace(QUEUE_URL_REGEX, ''); | ||
/** | ||
* Retrieve attributes from the specified queue. | ||
* | ||
* @param {string} QueueUrl - The url for the queue to remove tags from. | ||
* @param {Array<string>} Attributes - The name of attributes to retrieve information from. | ||
* @returns {Object.<string, any>} - Returns attribute object. | ||
* @throws AWS.SimpleQueueService.NonExistentQueue, thrown if queue does not exist. | ||
*/ | ||
function getQueueAttributes(QueueUrl, Attributes) { | ||
@@ -559,2 +748,4 @@ const convertedQueue = QueueUrl.replace(QUEUE_URL_REGEX, ''); | ||
} | ||
/** @type {Object.<string, any>} */ | ||
const response = { | ||
@@ -580,2 +771,10 @@ ...queue.Attributes, | ||
/** | ||
* Retrieves the queue url. | ||
* | ||
* @param {string} QueueName - Name for the queue. | ||
* @param {string} host - Host name for the queue url. | ||
* @returns {string} - The queue URL. | ||
* @throws AWS.SimpleQueueService.NonExistentQueue, thrown if queue does not exist. | ||
*/ | ||
function getQueueUrl(QueueName, host) { | ||
@@ -588,2 +787,9 @@ if (!queues.get(QueueName)) { | ||
/** | ||
* Delete all messages from the specified queue. | ||
* | ||
* @param {string} QueueUrl - The url of the queue to purge. | ||
* @returns {void} | ||
* @throws AWS.SimpleQueueService.NonExistentQueue, thrown if queue does not exist. | ||
*/ | ||
function purgeQueue(QueueUrl) { | ||
@@ -599,2 +805,10 @@ const convertedQueue = QueueUrl.replace(QUEUE_URL_REGEX, ''); | ||
/** | ||
* Retrieve all queues with the RedrivePolicy attribute set to a dead letter queue. | ||
* | ||
* @param {string} QueueUrl - The url of the queue to search. | ||
* @param {string} host - Host name for the queue url. | ||
* @returns {Array<string>} - The list of queue urls. | ||
* @throws AWS.SimpleQueueService.NonExistentQueue, thrown if queue does not exist for specific wsdl version. | ||
*/ | ||
function listDeadLetterSourceQueues(QueueUrl, host) { | ||
@@ -626,2 +840,13 @@ const convertedQueue = QueueUrl.replace(QUEUE_URL_REGEX, ''); | ||
/** | ||
* Sets the visibility timeout for a specified message in the queue. | ||
* | ||
* @param {Object} params - The params for changeMessageVisibility. | ||
* @param {string} params.QueueUrl - The url for the queue that contains the message. | ||
* @param {string} params.ReceiptHandle - The receipt handle identifier. | ||
* @param {number} params.VisibilityTimeout - The new visibility timeout value. | ||
* @returns {void} | ||
* @throws AWS.SimpleQueueService.NonExistentQueue, thrown if queue does not exist for specific wsdl version. | ||
* @throws ClientError, thrown if VisibilityTimeout is outside of range 0 - 43200. | ||
*/ | ||
function changeMessageVisibility({ QueueUrl, ReceiptHandle, VisibilityTimeout }) { | ||
@@ -673,1 +898,132 @@ const convertedQueue = QueueUrl.replace(QUEUE_URL_REGEX, ''); | ||
}; | ||
/** | ||
* | ||
* Type for parameters of the `createQueue` method. | ||
* | ||
* @typedef {Object} CreateQueueParams | ||
* @property {Object.<string, any>} [Attributes] - The attributes for the queue. | ||
* @property {string} QueueName - The name of the queue. | ||
* @property {Object.<string, string>} [tags] - Tags for the queue | ||
*/ | ||
/** | ||
* | ||
* Type for queue attributes. | ||
* | ||
* @typedef {Object} QueueAttributes | ||
* @property {boolean} ContentBasedDeduplication - Content based deduplication flag. | ||
* @property {number} CreatedTimestamp - Timestamp of when the queue was created. | ||
* @property {number} DelaySeconds - Delay amount in seconds. | ||
* @property {boolean} FifoQueue - Fifo queue flag. | ||
* @property {number} KmsDataKeyReusePeriodSeconds - Amount of time data key can be reused in seconds. | ||
* @property {string} KmsMasterKeyId - Key Id. | ||
* @property {number} MaximumMessageSize - Maximum Message Size in bytes. | ||
* @property {number} MessageRetentionPeriod - Amount of time message will be retained in seconds. | ||
* @property {string} QueueArn - The Amazon Resource Name of the queue. | ||
* @property {number} ReceiveMessageWaitTimeSeconds - Wait time to receive message in seconds. | ||
* @property {Object} RedrivePolicy - Redrive policy. | ||
* @property {string} RedrivePolicy.deadLetterTargetArn - Amazon Resource Name of the dead letter queue. | ||
* @property {number} RedrivePolicy.maxReceiveCount - Maximum number of times a message gets delivered before being moved to dead letter queue. | ||
* @property {number} VisibilityTimeout - Visibility timeout in seconds. | ||
*/ | ||
/** | ||
* | ||
* Type for parameters of the `sendMessage` method. | ||
* | ||
* @typedef {Object} SendMessageParams | ||
* @property {number} [DelaySeconds] - Delay amount in seconds. | ||
* @property {any} [MessageAttributes] - The message attributes | ||
* @property {string} MessageBody - The body of the message. | ||
* @property {string} [MessageDeduplicationId] - The deduplication Id. | ||
* @property {string} [MessageGroupId] - Group Id for the message. | ||
* @property {any} [MessageSystemAttributes] - Consists of the same options as MessageAttributes. | ||
* @property {string} QueueUrl - The url for the queue. | ||
*/ | ||
/** | ||
* | ||
* Type for Queue Objects | ||
* | ||
* @typedef {Object} QueueObject | ||
* @property {(QueueAttributes|Object.<string|number, any>)} Attributes - The queue attributes. | ||
* @property {Array<Object.<string, any>>} messages - Messages in the queue. | ||
* @property {Object<string, string>} tags - Key-value pairs for tags. | ||
*/ | ||
/** | ||
* | ||
* Type for Message Objects | ||
* | ||
* @typedef {Object} MessageObject | ||
* @property {Object.<string, any>} Attributes - The queue attributes. | ||
* @property {number} DelaySeconds - Delay for messages in seconds. | ||
* @property {Object.<string, any>} MessageAttributes - The message attributes. | ||
* @property {string} MessageBody - The body of the message. | ||
* @property {string} MessageDeduplicationId - The deduplication Id. | ||
* @property {string} MessageGroupId - Group Id for the message. | ||
* @property {string} MessageId - The message ID. | ||
* @property {Object.<string, any>} MessageSystemAttributes - Consists of the same options as MessageAttributes. | ||
*/ | ||
/** | ||
* | ||
* Type for Message Objects in batch request. | ||
* | ||
* @typedef {Object} MessageBatchObject | ||
* @property {number} DelaySeconds - Delay for messages in seconds. | ||
* @property {string} Id - The queue ID. | ||
* @property {Object} [MessageAttributes] - The message attributes. | ||
* @property {string} MessageBody - The body of the message. | ||
* @property {string} [MessageDeduplicationId] - The deduplication Id. | ||
* @property {string} [MessageGroupId] - Group Id for the message. | ||
* @property {Object} [MessageSystemAttributes] - Consists of the same options as MessageAttributes. | ||
*/ | ||
/** | ||
* | ||
* Type for parameters of the `sendMessageBatch` method. | ||
* | ||
* @typedef {Object} SendMessageBatchParams | ||
* @property {Array<MessageBatchObject>} messages - The messages to send in the same format, with individual messages in the same format as SendMessageParams | ||
* @property {string} QueueUrl - The url for the queue. | ||
*/ | ||
/** | ||
* | ||
* Type for returned object of `preparedMessages` method. | ||
* | ||
* @typedef {Object} PreparedMessages | ||
* @property {Object.<string, any>} [Attributes] - The attributes for the queue. | ||
* @property {string} Body - The body of the message. | ||
* @property {string} [MD5OfBody] - MD5 of the body of the message. | ||
* @property {string} [MD5OfMessageAttributes] - MD5 of the message attributes. | ||
* @property {Object.<string, any>} [MessageAttributes] - The message attributes. | ||
* @property {string} MessageId - The message Id. | ||
* @property {string} ReceiptHandle - The receipt handle identifier. | ||
*/ | ||
/** | ||
* | ||
* Type for parameter object of `deleteMessageBatch` method. | ||
* | ||
* @typedef {Object} DeleteMessageBatchRequestEntry | ||
* @property {string} Id - Message ID. | ||
* @property {string} ReceiptHandle - The receipt handle identifier. | ||
*/ | ||
/** | ||
* | ||
* Type for encoded messages | ||
* | ||
* @typedef {Object} EncodedMessage | ||
* @property {number} [DelaySeconds] - Amount of delay in seconds. | ||
* @property {string} [Id] - Batch request ID. | ||
* @property {string} [MD5OfMessageAttributes] - MD5 of message attributes. | ||
* @property {string} [MD5OfMessageSystemAttributes] - MD5 of Message System Attributes. | ||
* @property {string} [MD5OfMessageBody] - MD5 of message body. | ||
* @property {string} [MessageDeduplicationId] - The message dedupliaction ID. | ||
* @property {string} MessageId - Message ID. | ||
* @property {string} [SequenceNumber] - The large nonconsecutive number attached to each message. | ||
*/ |
'use strict'; | ||
class ErrorWithCode extends Error { | ||
/** | ||
* @param {string} message - Error message. | ||
* @param {string} code - Error code. | ||
*/ | ||
constructor(message, code) { | ||
@@ -5,0 +9,0 @@ super(message); |
@@ -9,2 +9,9 @@ 'use strict'; | ||
/** | ||
* Creates hash for message attributes. | ||
* | ||
* @param {Object.<string, any>} messageAttributes - Message Attributes. | ||
* @returns {string} MD5 hash of messageAttributes. | ||
* @throws {Error} Throws error when binary value is detected, currently not supported. | ||
*/ | ||
module.exports = (messageAttributes) => { | ||
@@ -11,0 +18,0 @@ const buffers = []; |
@@ -8,3 +8,3 @@ 'use strict'; | ||
const structs = { | ||
delaySeconds: define('delaySeconds', (delaySeconds) => { | ||
delaySeconds: define('delaySeconds', (/** @type {*} */ delaySeconds) => { | ||
if (delaySeconds < 0 || delaySeconds > 900) { | ||
@@ -18,16 +18,16 @@ throw new ErrorWithCode( | ||
}), | ||
kmsDataKeyReusePeriodSeconds: define('kmsDataKeyReusePeriodSeconds', ( | ||
kmsDataKeyReusePeriodSeconds | ||
) => { | ||
if (kmsDataKeyReusePeriodSeconds < 60 || kmsDataKeyReusePeriodSeconds > 86400) { | ||
throw new ErrorWithCode( | ||
'Invalid value for the parameter KmsDataKeyReusePeriodSeconds.', | ||
'InvalidAttributeValue' | ||
); | ||
kmsDataKeyReusePeriodSeconds: define( | ||
'kmsDataKeyReusePeriodSeconds', | ||
(/** @type {*} */ kmsDataKeyReusePeriodSeconds) => { | ||
if (kmsDataKeyReusePeriodSeconds < 60 || kmsDataKeyReusePeriodSeconds > 86400) { | ||
throw new ErrorWithCode( | ||
'Invalid value for the parameter KmsDataKeyReusePeriodSeconds.', | ||
'InvalidAttributeValue' | ||
); | ||
} | ||
return true; | ||
} | ||
return true; | ||
}), | ||
), | ||
maximumMessageSize: define('maximumMessageSize', (maximumMessageSize) => { | ||
maximumMessageSize: define('maximumMessageSize', (/** @type {*} */ maximumMessageSize) => { | ||
if (maximumMessageSize < 1024 || maximumMessageSize > 262144) { | ||
@@ -42,13 +42,16 @@ throw new ErrorWithCode( | ||
messageRetentionPeriod: define('messageRetentionPeriod', (messageRetentionPeriod) => { | ||
if (messageRetentionPeriod < 60 || messageRetentionPeriod > 1209600) { | ||
throw new ErrorWithCode( | ||
'Invalid value for the parameter MessageRetentionPeriod.', | ||
'InvalidAttributeValue' | ||
); | ||
messageRetentionPeriod: define( | ||
'messageRetentionPeriod', | ||
(/** @type {*} */ messageRetentionPeriod) => { | ||
if (messageRetentionPeriod < 60 || messageRetentionPeriod > 1209600) { | ||
throw new ErrorWithCode( | ||
'Invalid value for the parameter MessageRetentionPeriod.', | ||
'InvalidAttributeValue' | ||
); | ||
} | ||
return true; | ||
} | ||
return true; | ||
}), | ||
), | ||
queueName: define('queueName', (queueName) => { | ||
queueName: define('queueName', (/** @type {*} */ queueName) => { | ||
if (queueName.length > 80) { | ||
@@ -70,15 +73,16 @@ throw new ErrorWithCode( | ||
receiveMessageWaitTimeSeconds: define('receiveMessageWaitTimeSeconds', ( | ||
receiveMessageWaitTimeSeconds | ||
) => { | ||
if (receiveMessageWaitTimeSeconds < 0 || receiveMessageWaitTimeSeconds > 20) { | ||
throw new ErrorWithCode( | ||
'Invalid value for the parameter ReceiveMessageWaitTimeSeconds.', | ||
'InvalidAttributeValue' | ||
); | ||
receiveMessageWaitTimeSeconds: define( | ||
'receiveMessageWaitTimeSeconds', | ||
(/** @type {*} */ receiveMessageWaitTimeSeconds) => { | ||
if (receiveMessageWaitTimeSeconds < 0 || receiveMessageWaitTimeSeconds > 20) { | ||
throw new ErrorWithCode( | ||
'Invalid value for the parameter ReceiveMessageWaitTimeSeconds.', | ||
'InvalidAttributeValue' | ||
); | ||
} | ||
return true; | ||
} | ||
return true; | ||
}), | ||
), | ||
redrivePolicy: define('redrivePolicy', (redrivePolicy) => { | ||
redrivePolicy: define('redrivePolicy', (/** @type {*} */ redrivePolicy) => { | ||
if (!redrivePolicy) return true; | ||
@@ -103,3 +107,3 @@ | ||
visibilityTimeout: define('visibilityTimeout', (visibilityTimeout) => { | ||
visibilityTimeout: define('visibilityTimeout', (/** @type {*} */ visibilityTimeout) => { | ||
if (visibilityTimeout < 0 || visibilityTimeout > 43200) { | ||
@@ -150,2 +154,7 @@ throw new ErrorWithCode( | ||
/** | ||
* | ||
* @param {Object} params - Parameter object. | ||
* @returns {Object} | ||
*/ | ||
const assertMessage = (params) => { | ||
@@ -155,2 +164,7 @@ return create(params, Message); | ||
/** | ||
* | ||
* @param {Object} params - Parameter object. | ||
* @returns {Object} | ||
*/ | ||
const assertQueue = (params) => { | ||
@@ -157,0 +171,0 @@ return create(params, Queue); |
@@ -5,2 +5,9 @@ 'use strict'; | ||
/** | ||
* Converts object to xml format. | ||
* | ||
* @param {string} rootName - The name of the object. | ||
* @param {*} obj - The object to convert. | ||
* @returns {string} XMLString | ||
*/ | ||
function toXml(rootName, obj) { | ||
@@ -17,2 +24,8 @@ return builder | ||
/** | ||
* Converts error object with a code to xml format. | ||
* | ||
* @param {*} error - The error object. | ||
* @returns {Object} ErrorResponse | ||
*/ | ||
function toXmlError(error) { | ||
@@ -19,0 +32,0 @@ const xml = toXml('ErrorResponse', { |
{ | ||
"name": "sqslite", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "Lightweight module for integration testing AWS SQS.", | ||
@@ -9,3 +9,4 @@ "keywords": [], | ||
"Edgardo Avilés <Edgardo.Aviles@ADP.com>", | ||
"Jenny Eckstein <Jenny.Eckstein@ADP.com>" | ||
"Jenny Eckstein <Jenny.Eckstein@ADP.com>", | ||
"Hanna Rzheutskaya <Hanna.Rzheutskaya@adp.com>" | ||
], | ||
@@ -15,3 +16,3 @@ "contributors": [ | ||
], | ||
"license": "MIT", | ||
"license": "Apache-2.0", | ||
"repository": { | ||
@@ -26,22 +27,30 @@ "type": "git", | ||
"main": "lib/index.js", | ||
"files": [ | ||
"lib", | ||
"bin", | ||
"!*.test.js" | ||
], | ||
"bin": "bin/cli.js", | ||
"engines": { | ||
"node": ">=v10.23.3" | ||
"node": ">=v14" | ||
}, | ||
"scripts": { | ||
"build-docs": "jsdoc2md -t ./templates/README.hbs ./lib/*.js > ./README.md && git add ./README.md", | ||
"build-docs-watch": "npm-watch build-docs", | ||
"eslint": "eslint . --ext .js,.json --ignore-pattern='!.*.*'", | ||
"format": "prettier --write '**/*.{md,js,json,ts}' '!coverage/**/*.{js,json}'", | ||
"prepare": "check-engines", | ||
"test": "jest -c ./.jest.json", | ||
"version": "auto-changelog -p && git add CHANGELOG.md" | ||
"build-docs": "commons", | ||
"build-types": "commons", | ||
"check-types": "commons", | ||
"clean-types": "commons", | ||
"eslint": "commons", | ||
"prepare": "commons", | ||
"prepublishOnly": "npm run build-types && npm run prettier", | ||
"prettier": "commons", | ||
"test": "commons", | ||
"version": "commons" | ||
}, | ||
"dependencies": { | ||
"dedent": "^0.7.0", | ||
"fastify": "^3.12.0", | ||
"fastify-formbody": "^5.0.0", | ||
"fastify": "^3.22.1", | ||
"fastify-formbody": "^5.1.0", | ||
"md5": "^2.3.0", | ||
"minimist": "^1.2.5", | ||
"superstruct": "^0.14.2", | ||
"superstruct": "^0.15.3", | ||
"uuid": "^8.3.2", | ||
@@ -51,38 +60,9 @@ "xmlbuilder": "^15.1.1" | ||
"devDependencies": { | ||
"@types/node": "^14.14.31", | ||
"auto-changelog": "^2.2.1", | ||
"aws-sdk": "^2.850.0", | ||
"chalk": "^4.1.0", | ||
"check-engines": "^1.5.0", | ||
"codecov": "^3.8.1", | ||
"eslint": "^7.20.0", | ||
"eslint-config-lifion": "^2.0.2", | ||
"husky": "^5.1.1", | ||
"jest": "^26.6.3", | ||
"jest-xml-matcher": "^1.2.0", | ||
"jsdoc-to-markdown": "^6.0.1", | ||
"lint-staged": "^10.5.4", | ||
"npm-watch": "^0.7.0", | ||
"prettier": "^2.2.1", | ||
"semver": "^7.3.4", | ||
"typescript": "^4.1.5" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "npm run build-docs && lint-staged", | ||
"pre-push": "npm run eslint && npm test" | ||
} | ||
}, | ||
"watch": { | ||
"build-docs": { | ||
"patterns": [ | ||
"lib" | ||
] | ||
} | ||
}, | ||
"@lifion/core-commons": { | ||
"template": "public", | ||
"updated": "2020-06-26T20:08:10.211Z", | ||
"version": "2.4.0" | ||
"@types/md5": "^2.3.1", | ||
"@types/node": "^16.11.2", | ||
"@types/uuid": "^8.3.1", | ||
"aws-sdk": "^2.1012.0", | ||
"core-commons": "^1.0.0-alpha.2", | ||
"jest-xml-matcher": "^1.2.0" | ||
} | ||
} |
@@ -9,5 +9,7 @@ # SQSLite | ||
Localstack was an inspiration for this project. We used Localstack for our SQS needs before this project was started. We chose to create this implementation for the following reasons: | ||
Localstack was an inspiration for this project. We used Localstack for our SQS needs before this project was started. We | ||
chose to create this implementation for the following reasons: | ||
- **Decoupled from Localstack.** Localstack runs many AWS service imitations and therefore builky for local development. Our goal is to have a lightweight implementation. | ||
- **Decoupled from Localstack.** Localstack runs many AWS service imitations and therefore builky for local development. | ||
Our goal is to have a lightweight implementation. | ||
- **Native JavaScript module.** This module can be used as Command Line Interface (CLI) application or as an npm module. | ||
@@ -97,2 +99,2 @@ | ||
[MIT](./LICENSE) | ||
[Apache-2.0](./LICENSE) |
Sorry, the diff of this file is not supported yet
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
153414
6
32
2023
99
+ Addedsuperstruct@0.15.5(transitive)
- Removedsuperstruct@0.14.2(transitive)
Updatedfastify@^3.22.1
Updatedfastify-formbody@^5.1.0
Updatedsuperstruct@^0.15.3