From 5404402be1c0934837b364e7b5433304317963c3 Mon Sep 17 00:00:00 2001 From: Matt O'Keefe Date: Fri, 5 Jan 2024 18:08:48 -0600 Subject: [PATCH] fix: Time parse fix (#178) * Adding some event object handlers and modifying tests to match expectations * Helper date/str management * Bump and oss * Fix timezone test issue --- README.md | 55 ++- package-lock.json | 582 +++++++++++++-------------- package.json | 2 +- src/eventHandlers.js | 14 +- src/eventHandlers.test.js | 6 +- src/events/helpers.js | 28 ++ src/events/plusPlus.js | 77 ++++ src/events/plusPlusFalsePositive.js | 38 ++ src/lib/helpers.js | 37 ++ src/lib/helpers.test.js | 82 ++++ src/lib/messageFactory.js | 16 +- src/lib/services/plusplus.js | 58 +-- src/lib/services/token.js | 45 +-- src/messageHandlers/plusplus.test.js | 28 +- 14 files changed, 663 insertions(+), 405 deletions(-) create mode 100644 src/events/helpers.js create mode 100644 src/events/plusPlus.js create mode 100644 src/events/plusPlusFalsePositive.js diff --git a/README.md b/README.md index a2ec94e..b615561 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,41 @@ -hubot-plusplus-expanded -============== +# hubot-plusplus-expanded + +--- [![Known Vulnerabilities](https://snyk.io//test/github/Mutmatt/hubot-plusplus-expanded/badge.svg?targetFile=package.json)](https://snyk.io//test/github/Mutmatt/hubot-plusplus-expanded?targetFile=package.json) [![Node CI](https://github.com/O-Mutt/hubot-plusplus-expanded/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/O-Mutt/hubot-plusplus-expanded/actions/workflows/test.yml) Give or take away points. Keeps track and even prints out graphs. +## API -API --- -* \++ [\] - Increment score for a name (for a reason) -* \-- [\] - Decrement score for a name (for a reason) -* {name1, name2, name3}++ [\] - Increment score for all names (for a reason) -* {name1, name2, name3}-- [\] - Decrement score for all names (for a reason) -* hubot score - Display the score for a name and some of the reasons -* hubot top - Display the top scoring -* hubot bottom - Display the bottom scoring -* hubot erase [\] - Remove the score for a name (for a reason) -* how much are hubot points worth (how much point) - Shows how much hubot points are worth + +* `++ []` - Increment score for a name (for a reason) +* `-- []` - Decrement score for a name (for a reason) +* `{name1, name2, name3}++ []` - Increment score for all names (for a reason) +* `{name1, name2, name3}-- []` - Decrement score for all names (for a reason) +* ` score ` - Display the score for a name and some of the reasons +* `bot_name top ` - Display the top scoring +* `bot_name bottom ` - Display the bottom scoring +* `bot_name erase []` - Remove the score for a name (for a reason) +* `how much are bot_name points worth (how much point)` - Shows how much hubot points are worth Uses Hubot brain. Also exposes the following events, should you wish to hook into it to do things like print out funny gifs for point streaks: -```coffeescript -robot.emit "plus-plus", { - name: 'Jack' - direction: '++' # (or --) - room: 'chatRoomAlpha' - reason: 'being awesome' -} +[PlusPlusEvent Class](./src/events/PlusPlusEvent.js) + +```javascript +robot.emit("plus-plus", +[ + { + name: 'Jack' + direction: '++' # (or --) + room: 'chatRoomAlpha' + reason: 'being awesome' + } +]); ``` ## Installation @@ -46,7 +53,9 @@ Then to make sure the dependencies are installed: To enable the script, add a `hubot-plusplus-expanded` entry to the `external-scripts.json` file (you may need to create this file). - ["hubot-plusplus-expanded"] +```json +["hubot-plusplus-expanded"] +``` ## Configuration @@ -72,6 +81,7 @@ Some of the behavior of this plugin is configured in the environment: `db.scoreLog.createIndex( { "date": 1 }, { expireAfterSeconds: 5 } )` ## Mongo data Layout + ``` javascript scores: [ { @@ -103,11 +113,16 @@ PointsGivenObject: ## Testing +All the unit tests are run using `jest` + Individual run: `npm run test` Tdd: `npm run test:watch` +You can use `npm run test -- --testPathPattern=helpers.test.js` to test a specific file or any other cli options that jest has available + ## Known issue + As of now there is an issue that has shown up a couple times without a root cause. The `$setOnInsert` excludes the `reasons: {}` object. The fix, currently, is to identify the bad document in mongo `db.scores.find({ "reasons: null"});` and update them `db.scores.updateMany({ "reasons: null"}, { $set: { "reasons": {} });` diff --git a/package-lock.json b/package-lock.json index 5316ce5..675c7f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "hubot-plusplus-expanded", - "version": "3.5.4", + "version": "3.5.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "hubot-plusplus-expanded", - "version": "3.5.4", + "version": "3.5.5", "license": "MIT", "dependencies": { "@slack/client": "^5.0.2", @@ -169,49 +169,49 @@ "optional": true }, "node_modules/@aws-sdk/client-cognito-identity": { - "version": "3.484.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-cognito-identity/-/client-cognito-identity-3.484.0.tgz", - "integrity": "sha512-xjibqYYx8I8lYM17q3THMC8WpJihzio3+Wd6oAMdcaw+EBsgUcphsRHL5YO8wNEzNiMeXrXOPPUBapxpBmFPBA==", + "version": "3.485.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-cognito-identity/-/client-cognito-identity-3.485.0.tgz", + "integrity": "sha512-1SYhvRu/dNqQ5HcIgm7wIpyn1FsthbgG04o6QyVAnfOxmawFt4nqCEtNCwsmlX7o1ZCTYY+qNrozb7XZy+GKSQ==", "optional": true, "dependencies": { "@aws-crypto/sha256-browser": "3.0.0", "@aws-crypto/sha256-js": "3.0.0", - "@aws-sdk/client-sts": "3.484.0", - "@aws-sdk/core": "3.481.0", - "@aws-sdk/credential-provider-node": "3.484.0", - "@aws-sdk/middleware-host-header": "3.468.0", - "@aws-sdk/middleware-logger": "3.468.0", - "@aws-sdk/middleware-recursion-detection": "3.468.0", - "@aws-sdk/middleware-signing": "3.468.0", - "@aws-sdk/middleware-user-agent": "3.478.0", - "@aws-sdk/region-config-resolver": "3.484.0", - "@aws-sdk/types": "3.468.0", - "@aws-sdk/util-endpoints": "3.478.0", - "@aws-sdk/util-user-agent-browser": "3.468.0", - "@aws-sdk/util-user-agent-node": "3.470.0", - "@smithy/config-resolver": "^2.0.22", - "@smithy/core": "^1.2.1", - "@smithy/fetch-http-handler": "^2.3.1", - "@smithy/hash-node": "^2.0.17", - "@smithy/invalid-dependency": "^2.0.15", - "@smithy/middleware-content-length": "^2.0.17", - "@smithy/middleware-endpoint": "^2.2.3", - "@smithy/middleware-retry": "^2.0.25", - "@smithy/middleware-serde": "^2.0.15", - "@smithy/middleware-stack": "^2.0.9", - "@smithy/node-config-provider": "^2.1.8", - "@smithy/node-http-handler": "^2.2.1", - "@smithy/protocol-http": "^3.0.11", - "@smithy/smithy-client": "^2.2.0", - "@smithy/types": "^2.7.0", - "@smithy/url-parser": "^2.0.15", + "@aws-sdk/client-sts": "3.485.0", + "@aws-sdk/core": "3.485.0", + "@aws-sdk/credential-provider-node": "3.485.0", + "@aws-sdk/middleware-host-header": "3.485.0", + "@aws-sdk/middleware-logger": "3.485.0", + "@aws-sdk/middleware-recursion-detection": "3.485.0", + "@aws-sdk/middleware-signing": "3.485.0", + "@aws-sdk/middleware-user-agent": "3.485.0", + "@aws-sdk/region-config-resolver": "3.485.0", + "@aws-sdk/types": "3.485.0", + "@aws-sdk/util-endpoints": "3.485.0", + "@aws-sdk/util-user-agent-browser": "3.485.0", + "@aws-sdk/util-user-agent-node": "3.485.0", + "@smithy/config-resolver": "^2.0.23", + "@smithy/core": "^1.2.2", + "@smithy/fetch-http-handler": "^2.3.2", + "@smithy/hash-node": "^2.0.18", + "@smithy/invalid-dependency": "^2.0.16", + "@smithy/middleware-content-length": "^2.0.18", + "@smithy/middleware-endpoint": "^2.3.0", + "@smithy/middleware-retry": "^2.0.26", + "@smithy/middleware-serde": "^2.0.16", + "@smithy/middleware-stack": "^2.0.10", + "@smithy/node-config-provider": "^2.1.9", + "@smithy/node-http-handler": "^2.2.2", + "@smithy/protocol-http": "^3.0.12", + "@smithy/smithy-client": "^2.2.1", + "@smithy/types": "^2.8.0", + "@smithy/url-parser": "^2.0.16", "@smithy/util-base64": "^2.0.1", "@smithy/util-body-length-browser": "^2.0.1", "@smithy/util-body-length-node": "^2.1.0", - "@smithy/util-defaults-mode-browser": "^2.0.23", - "@smithy/util-defaults-mode-node": "^2.0.31", - "@smithy/util-endpoints": "^1.0.7", - "@smithy/util-retry": "^2.0.8", + "@smithy/util-defaults-mode-browser": "^2.0.24", + "@smithy/util-defaults-mode-node": "^2.0.32", + "@smithy/util-endpoints": "^1.0.8", + "@smithy/util-retry": "^2.0.9", "@smithy/util-utf8": "^2.0.2", "tslib": "^2.5.0" }, @@ -220,46 +220,46 @@ } }, "node_modules/@aws-sdk/client-sso": { - "version": "3.484.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso/-/client-sso-3.484.0.tgz", - "integrity": "sha512-eHKXDHqgPt99977hNissa1y/efwXZ9kg3EKPLK13b6VzTC8s0+Ih+YZemNE22ahw6SYnRiGglYdkdypJ/uPHkg==", + "version": "3.485.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso/-/client-sso-3.485.0.tgz", + "integrity": "sha512-apN2bEn0PZs0jD4jAfvwO3dlWqw9YIQJ6TAudM1bd3S5vzWqlBBcLfQpK6taHoQaI+WqgUWXLuOf7gRFbGXKPg==", "optional": true, "dependencies": { "@aws-crypto/sha256-browser": "3.0.0", "@aws-crypto/sha256-js": "3.0.0", - "@aws-sdk/core": "3.481.0", - "@aws-sdk/middleware-host-header": "3.468.0", - "@aws-sdk/middleware-logger": "3.468.0", - "@aws-sdk/middleware-recursion-detection": "3.468.0", - "@aws-sdk/middleware-user-agent": "3.478.0", - "@aws-sdk/region-config-resolver": "3.484.0", - "@aws-sdk/types": "3.468.0", - "@aws-sdk/util-endpoints": "3.478.0", - "@aws-sdk/util-user-agent-browser": "3.468.0", - "@aws-sdk/util-user-agent-node": "3.470.0", - "@smithy/config-resolver": "^2.0.22", - "@smithy/core": "^1.2.1", - "@smithy/fetch-http-handler": "^2.3.1", - "@smithy/hash-node": "^2.0.17", - "@smithy/invalid-dependency": "^2.0.15", - "@smithy/middleware-content-length": "^2.0.17", - "@smithy/middleware-endpoint": "^2.2.3", - "@smithy/middleware-retry": "^2.0.25", - "@smithy/middleware-serde": "^2.0.15", - "@smithy/middleware-stack": "^2.0.9", - "@smithy/node-config-provider": "^2.1.8", - "@smithy/node-http-handler": "^2.2.1", - "@smithy/protocol-http": "^3.0.11", - "@smithy/smithy-client": "^2.2.0", - "@smithy/types": "^2.7.0", - "@smithy/url-parser": "^2.0.15", + "@aws-sdk/core": "3.485.0", + "@aws-sdk/middleware-host-header": "3.485.0", + "@aws-sdk/middleware-logger": "3.485.0", + "@aws-sdk/middleware-recursion-detection": "3.485.0", + "@aws-sdk/middleware-user-agent": "3.485.0", + "@aws-sdk/region-config-resolver": "3.485.0", + "@aws-sdk/types": "3.485.0", + "@aws-sdk/util-endpoints": "3.485.0", + "@aws-sdk/util-user-agent-browser": "3.485.0", + "@aws-sdk/util-user-agent-node": "3.485.0", + "@smithy/config-resolver": "^2.0.23", + "@smithy/core": "^1.2.2", + "@smithy/fetch-http-handler": "^2.3.2", + "@smithy/hash-node": "^2.0.18", + "@smithy/invalid-dependency": "^2.0.16", + "@smithy/middleware-content-length": "^2.0.18", + "@smithy/middleware-endpoint": "^2.3.0", + "@smithy/middleware-retry": "^2.0.26", + "@smithy/middleware-serde": "^2.0.16", + "@smithy/middleware-stack": "^2.0.10", + "@smithy/node-config-provider": "^2.1.9", + "@smithy/node-http-handler": "^2.2.2", + "@smithy/protocol-http": "^3.0.12", + "@smithy/smithy-client": "^2.2.1", + "@smithy/types": "^2.8.0", + "@smithy/url-parser": "^2.0.16", "@smithy/util-base64": "^2.0.1", "@smithy/util-body-length-browser": "^2.0.1", "@smithy/util-body-length-node": "^2.1.0", - "@smithy/util-defaults-mode-browser": "^2.0.23", - "@smithy/util-defaults-mode-node": "^2.0.31", - "@smithy/util-endpoints": "^1.0.7", - "@smithy/util-retry": "^2.0.8", + "@smithy/util-defaults-mode-browser": "^2.0.24", + "@smithy/util-defaults-mode-node": "^2.0.32", + "@smithy/util-endpoints": "^1.0.8", + "@smithy/util-retry": "^2.0.9", "@smithy/util-utf8": "^2.0.2", "tslib": "^2.5.0" }, @@ -268,48 +268,48 @@ } }, "node_modules/@aws-sdk/client-sts": { - "version": "3.484.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.484.0.tgz", - "integrity": "sha512-psQxH0mYhTVvZhfca3s9NbXgnuOM8l+5LtF7fZBF5y4xaPpfAPicPWp6po69J3ynwyXi/MpHNXd/13d/L09TTA==", + "version": "3.485.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.485.0.tgz", + "integrity": "sha512-PI4q36kVF0fpIPZyeQhrwwJZ6SRkOGvU3rX5Qn4b5UY5X+Ct1aLhqSX8/OB372UZIcnh6eSvERu8POHleDO7Jw==", "optional": true, "dependencies": { "@aws-crypto/sha256-browser": "3.0.0", "@aws-crypto/sha256-js": "3.0.0", - "@aws-sdk/core": "3.481.0", - "@aws-sdk/credential-provider-node": "3.484.0", - "@aws-sdk/middleware-host-header": "3.468.0", - "@aws-sdk/middleware-logger": "3.468.0", - "@aws-sdk/middleware-recursion-detection": "3.468.0", - "@aws-sdk/middleware-user-agent": "3.478.0", - "@aws-sdk/region-config-resolver": "3.484.0", - "@aws-sdk/types": "3.468.0", - "@aws-sdk/util-endpoints": "3.478.0", - "@aws-sdk/util-user-agent-browser": "3.468.0", - "@aws-sdk/util-user-agent-node": "3.470.0", - "@smithy/config-resolver": "^2.0.22", - "@smithy/core": "^1.2.1", - "@smithy/fetch-http-handler": "^2.3.1", - "@smithy/hash-node": "^2.0.17", - "@smithy/invalid-dependency": "^2.0.15", - "@smithy/middleware-content-length": "^2.0.17", - "@smithy/middleware-endpoint": "^2.2.3", - "@smithy/middleware-retry": "^2.0.25", - "@smithy/middleware-serde": "^2.0.15", - "@smithy/middleware-stack": "^2.0.9", - "@smithy/node-config-provider": "^2.1.8", - "@smithy/node-http-handler": "^2.2.1", - "@smithy/protocol-http": "^3.0.11", - "@smithy/smithy-client": "^2.2.0", - "@smithy/types": "^2.7.0", - "@smithy/url-parser": "^2.0.15", + "@aws-sdk/core": "3.485.0", + "@aws-sdk/credential-provider-node": "3.485.0", + "@aws-sdk/middleware-host-header": "3.485.0", + "@aws-sdk/middleware-logger": "3.485.0", + "@aws-sdk/middleware-recursion-detection": "3.485.0", + "@aws-sdk/middleware-user-agent": "3.485.0", + "@aws-sdk/region-config-resolver": "3.485.0", + "@aws-sdk/types": "3.485.0", + "@aws-sdk/util-endpoints": "3.485.0", + "@aws-sdk/util-user-agent-browser": "3.485.0", + "@aws-sdk/util-user-agent-node": "3.485.0", + "@smithy/config-resolver": "^2.0.23", + "@smithy/core": "^1.2.2", + "@smithy/fetch-http-handler": "^2.3.2", + "@smithy/hash-node": "^2.0.18", + "@smithy/invalid-dependency": "^2.0.16", + "@smithy/middleware-content-length": "^2.0.18", + "@smithy/middleware-endpoint": "^2.3.0", + "@smithy/middleware-retry": "^2.0.26", + "@smithy/middleware-serde": "^2.0.16", + "@smithy/middleware-stack": "^2.0.10", + "@smithy/node-config-provider": "^2.1.9", + "@smithy/node-http-handler": "^2.2.2", + "@smithy/protocol-http": "^3.0.12", + "@smithy/smithy-client": "^2.2.1", + "@smithy/types": "^2.8.0", + "@smithy/url-parser": "^2.0.16", "@smithy/util-base64": "^2.0.1", "@smithy/util-body-length-browser": "^2.0.1", "@smithy/util-body-length-node": "^2.1.0", - "@smithy/util-defaults-mode-browser": "^2.0.23", - "@smithy/util-defaults-mode-node": "^2.0.31", - "@smithy/util-endpoints": "^1.0.7", - "@smithy/util-middleware": "^2.0.8", - "@smithy/util-retry": "^2.0.8", + "@smithy/util-defaults-mode-browser": "^2.0.24", + "@smithy/util-defaults-mode-node": "^2.0.32", + "@smithy/util-endpoints": "^1.0.8", + "@smithy/util-middleware": "^2.0.9", + "@smithy/util-retry": "^2.0.9", "@smithy/util-utf8": "^2.0.2", "fast-xml-parser": "4.2.5", "tslib": "^2.5.0" @@ -319,16 +319,16 @@ } }, "node_modules/@aws-sdk/core": { - "version": "3.481.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.481.0.tgz", - "integrity": "sha512-UeyAc2FnWQDts81vPVBWKEj0WagYK4SVAgNfGcg6zCzzqsUG4unr4NPKQoca2L+XOU55yMCy+5l2K6R3YsFGKg==", + "version": "3.485.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.485.0.tgz", + "integrity": "sha512-Yvi80DQcbjkYCft471ClE3HuetuNVqntCs6eFOomDcrJaqdOFrXv2kJAxky84MRA/xb7bGlDGAPbTuj1ICputg==", "optional": true, "dependencies": { - "@smithy/core": "^1.2.1", - "@smithy/protocol-http": "^3.0.11", + "@smithy/core": "^1.2.2", + "@smithy/protocol-http": "^3.0.12", "@smithy/signature-v4": "^2.0.0", - "@smithy/smithy-client": "^2.2.0", - "@smithy/types": "^2.7.0", + "@smithy/smithy-client": "^2.2.1", + "@smithy/types": "^2.8.0", "tslib": "^2.5.0" }, "engines": { @@ -336,15 +336,15 @@ } }, "node_modules/@aws-sdk/credential-provider-cognito-identity": { - "version": "3.484.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-cognito-identity/-/credential-provider-cognito-identity-3.484.0.tgz", - "integrity": "sha512-kIusxi5f9jcNfLjNv/fv6eNRHN1bSQhN8nS31jBRemQL3zBuUePk50MqbciZUh29Rf/ATOVvH6UStaxnV6ivlg==", + "version": "3.485.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-cognito-identity/-/credential-provider-cognito-identity-3.485.0.tgz", + "integrity": "sha512-XIy5h1AcDiY3V286X7KrLA5HAxLfzLGrUGBPFY+GTJGYetDhlJwFz12q6BOkIfeAhUbT2Umb4ptujX9eqpZJHQ==", "optional": true, "dependencies": { - "@aws-sdk/client-cognito-identity": "3.484.0", - "@aws-sdk/types": "3.468.0", + "@aws-sdk/client-cognito-identity": "3.485.0", + "@aws-sdk/types": "3.485.0", "@smithy/property-provider": "^2.0.0", - "@smithy/types": "^2.7.0", + "@smithy/types": "^2.8.0", "tslib": "^2.5.0" }, "engines": { @@ -352,14 +352,14 @@ } }, "node_modules/@aws-sdk/credential-provider-env": { - "version": "3.468.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-env/-/credential-provider-env-3.468.0.tgz", - "integrity": "sha512-k/1WHd3KZn0EQYjadooj53FC0z24/e4dUZhbSKTULgmxyO62pwh9v3Brvw4WRa/8o2wTffU/jo54tf4vGuP/ZA==", + "version": "3.485.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-env/-/credential-provider-env-3.485.0.tgz", + "integrity": "sha512-3XkFgwVU1XOB33dV7t9BKJ/ptdl2iS+0dxE7ecq8aqT2/gsfKmLCae1G17P8WmdD3z0kMDTvnqM2aWgUnSOkmg==", "optional": true, "dependencies": { - "@aws-sdk/types": "3.468.0", + "@aws-sdk/types": "3.485.0", "@smithy/property-provider": "^2.0.0", - "@smithy/types": "^2.7.0", + "@smithy/types": "^2.8.0", "tslib": "^2.5.0" }, "engines": { @@ -367,19 +367,19 @@ } }, "node_modules/@aws-sdk/credential-provider-http": { - "version": "3.481.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-http/-/credential-provider-http-3.481.0.tgz", - "integrity": "sha512-A2DJKLc37orM9w/Y9kajZWQ4qK6KD+5QKowXwh5/suhrJjNPKKomHFhAvnqPjJAYaSlES2+wk9O+Mfj0t9X2dw==", + "version": "3.485.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-http/-/credential-provider-http-3.485.0.tgz", + "integrity": "sha512-2/2Y3Z7cpKf8vbQ+FzoBPxRyb0hGJZB1YrnH7hptVi5gSVe1NiwV5ZtsDnv4cwUfOBqEu97nMXw5IrRO26S0DA==", "optional": true, "dependencies": { - "@aws-sdk/types": "3.468.0", - "@smithy/fetch-http-handler": "^2.3.1", - "@smithy/node-http-handler": "^2.2.1", + "@aws-sdk/types": "3.485.0", + "@smithy/fetch-http-handler": "^2.3.2", + "@smithy/node-http-handler": "^2.2.2", "@smithy/property-provider": "^2.0.0", - "@smithy/protocol-http": "^3.0.11", - "@smithy/smithy-client": "^2.2.0", - "@smithy/types": "^2.7.0", - "@smithy/util-stream": "^2.0.23", + "@smithy/protocol-http": "^3.0.12", + "@smithy/smithy-client": "^2.2.1", + "@smithy/types": "^2.8.0", + "@smithy/util-stream": "^2.0.24", "tslib": "^2.5.0" }, "engines": { @@ -387,20 +387,20 @@ } }, "node_modules/@aws-sdk/credential-provider-ini": { - "version": "3.484.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.484.0.tgz", - "integrity": "sha512-BbvU7seI0RPPwpujnz4LA1lC53Cj4BOSRpYYZbrxA6C7SzW0D/IQBZQP3JBbrxIhqewSROSsYGDjvYbyi5aDEw==", + "version": "3.485.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.485.0.tgz", + "integrity": "sha512-cFYF/Bdw7EnT4viSxYpNIv3IBkri/Yb+JpQXl8uDq7bfVJfAN5qZmK07vRkg08xL6TC4F41wshhMSAucGdTwIw==", "optional": true, "dependencies": { - "@aws-sdk/credential-provider-env": "3.468.0", - "@aws-sdk/credential-provider-process": "3.468.0", - "@aws-sdk/credential-provider-sso": "3.484.0", - "@aws-sdk/credential-provider-web-identity": "3.468.0", - "@aws-sdk/types": "3.468.0", + "@aws-sdk/credential-provider-env": "3.485.0", + "@aws-sdk/credential-provider-process": "3.485.0", + "@aws-sdk/credential-provider-sso": "3.485.0", + "@aws-sdk/credential-provider-web-identity": "3.485.0", + "@aws-sdk/types": "3.485.0", "@smithy/credential-provider-imds": "^2.0.0", "@smithy/property-provider": "^2.0.0", "@smithy/shared-ini-file-loader": "^2.0.6", - "@smithy/types": "^2.7.0", + "@smithy/types": "^2.8.0", "tslib": "^2.5.0" }, "engines": { @@ -408,21 +408,21 @@ } }, "node_modules/@aws-sdk/credential-provider-node": { - "version": "3.484.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.484.0.tgz", - "integrity": "sha512-Ylqej3FqRwUD3I7929k214LRH1bUz7f2hfV4ZqY7teM9hQC5Ov5SpVtOtLKNfgaaxAkhD2ffMNfmq8TAg824+g==", + "version": "3.485.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.485.0.tgz", + "integrity": "sha512-2DwzO2azkSzngifKDT61W/DL0tSzewuaFHiLJWdfc8Et3mdAQJ9x3KAj8u7XFpjIcGNqk7FiKjN+zeGUuNiEhA==", "optional": true, "dependencies": { - "@aws-sdk/credential-provider-env": "3.468.0", - "@aws-sdk/credential-provider-ini": "3.484.0", - "@aws-sdk/credential-provider-process": "3.468.0", - "@aws-sdk/credential-provider-sso": "3.484.0", - "@aws-sdk/credential-provider-web-identity": "3.468.0", - "@aws-sdk/types": "3.468.0", + "@aws-sdk/credential-provider-env": "3.485.0", + "@aws-sdk/credential-provider-ini": "3.485.0", + "@aws-sdk/credential-provider-process": "3.485.0", + "@aws-sdk/credential-provider-sso": "3.485.0", + "@aws-sdk/credential-provider-web-identity": "3.485.0", + "@aws-sdk/types": "3.485.0", "@smithy/credential-provider-imds": "^2.0.0", "@smithy/property-provider": "^2.0.0", "@smithy/shared-ini-file-loader": "^2.0.6", - "@smithy/types": "^2.7.0", + "@smithy/types": "^2.8.0", "tslib": "^2.5.0" }, "engines": { @@ -430,15 +430,15 @@ } }, "node_modules/@aws-sdk/credential-provider-process": { - "version": "3.468.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-process/-/credential-provider-process-3.468.0.tgz", - "integrity": "sha512-OYSn1A/UsyPJ7Z8Q2cNhTf55O36shPmSsvOfND04nSfu1nPaR+VUvvsP7v+brhGpwC/GAKTIdGAo4blH31BS6A==", + "version": "3.485.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-process/-/credential-provider-process-3.485.0.tgz", + "integrity": "sha512-X9qS6ZO/rDKYDgWqD1YmSX7sAUUHax9HbXlgGiTTdtfhZvQh1ZmnH6wiPu5WNliafHZFtZT2W07kgrDLPld/Ug==", "optional": true, "dependencies": { - "@aws-sdk/types": "3.468.0", + "@aws-sdk/types": "3.485.0", "@smithy/property-provider": "^2.0.0", "@smithy/shared-ini-file-loader": "^2.0.6", - "@smithy/types": "^2.7.0", + "@smithy/types": "^2.8.0", "tslib": "^2.5.0" }, "engines": { @@ -446,17 +446,17 @@ } }, "node_modules/@aws-sdk/credential-provider-sso": { - "version": "3.484.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.484.0.tgz", - "integrity": "sha512-Fl7+YhrlU2icZkz18z9aj4SiWb2aQlWp5LsVqMfSzTlJFc9yPlD9e7F33gnL7kKLVSnAVxsr5v4y4pFC6FZUSw==", + "version": "3.485.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.485.0.tgz", + "integrity": "sha512-l0oC8GTrWh+LFQQfSmG1Jai1PX7Mhj9arb/CaS1/tmeZE0hgIXW++tvljYs/Dds4LGXUlaWG+P7BrObf6OyIXA==", "optional": true, "dependencies": { - "@aws-sdk/client-sso": "3.484.0", - "@aws-sdk/token-providers": "3.484.0", - "@aws-sdk/types": "3.468.0", + "@aws-sdk/client-sso": "3.485.0", + "@aws-sdk/token-providers": "3.485.0", + "@aws-sdk/types": "3.485.0", "@smithy/property-provider": "^2.0.0", "@smithy/shared-ini-file-loader": "^2.0.6", - "@smithy/types": "^2.7.0", + "@smithy/types": "^2.8.0", "tslib": "^2.5.0" }, "engines": { @@ -464,14 +464,14 @@ } }, "node_modules/@aws-sdk/credential-provider-web-identity": { - "version": "3.468.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-web-identity/-/credential-provider-web-identity-3.468.0.tgz", - "integrity": "sha512-rexymPmXjtkwCPfhnUq3EjO1rSkf39R4Jz9CqiM7OsqK2qlT5Y/V3gnMKn0ZMXsYaQOMfM3cT5xly5R+OKDHlw==", + "version": "3.485.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-web-identity/-/credential-provider-web-identity-3.485.0.tgz", + "integrity": "sha512-WpBFZFE0iXtnibH5POMEKITj/hR0YV5l2n9p8BEvKjdJ63s3Xke1RN20ZdIyKDaRDwj8adnKDgNPEnAKdS4kLw==", "optional": true, "dependencies": { - "@aws-sdk/types": "3.468.0", + "@aws-sdk/types": "3.485.0", "@smithy/property-provider": "^2.0.0", - "@smithy/types": "^2.7.0", + "@smithy/types": "^2.8.0", "tslib": "^2.5.0" }, "engines": { @@ -479,26 +479,26 @@ } }, "node_modules/@aws-sdk/credential-providers": { - "version": "3.484.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-providers/-/credential-providers-3.484.0.tgz", - "integrity": "sha512-Yl4YPlML79TUir6QPUsgBWFwDu3FOiQGdAnN2eei4ce76ZI5JwPIiBNP0S2qK63R40CeoBqRlSIveBX9v10jjQ==", + "version": "3.485.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-providers/-/credential-providers-3.485.0.tgz", + "integrity": "sha512-SpGEmiVr+C9Dtc5tZFfFYXSNxbl1jShLlyZPWERHBn4QwGvdXcgPB96I0yvUuitBKrM0winHsCWH7CR/z24kmg==", "optional": true, "dependencies": { - "@aws-sdk/client-cognito-identity": "3.484.0", - "@aws-sdk/client-sso": "3.484.0", - "@aws-sdk/client-sts": "3.484.0", - "@aws-sdk/credential-provider-cognito-identity": "3.484.0", - "@aws-sdk/credential-provider-env": "3.468.0", - "@aws-sdk/credential-provider-http": "3.481.0", - "@aws-sdk/credential-provider-ini": "3.484.0", - "@aws-sdk/credential-provider-node": "3.484.0", - "@aws-sdk/credential-provider-process": "3.468.0", - "@aws-sdk/credential-provider-sso": "3.484.0", - "@aws-sdk/credential-provider-web-identity": "3.468.0", - "@aws-sdk/types": "3.468.0", + "@aws-sdk/client-cognito-identity": "3.485.0", + "@aws-sdk/client-sso": "3.485.0", + "@aws-sdk/client-sts": "3.485.0", + "@aws-sdk/credential-provider-cognito-identity": "3.485.0", + "@aws-sdk/credential-provider-env": "3.485.0", + "@aws-sdk/credential-provider-http": "3.485.0", + "@aws-sdk/credential-provider-ini": "3.485.0", + "@aws-sdk/credential-provider-node": "3.485.0", + "@aws-sdk/credential-provider-process": "3.485.0", + "@aws-sdk/credential-provider-sso": "3.485.0", + "@aws-sdk/credential-provider-web-identity": "3.485.0", + "@aws-sdk/types": "3.485.0", "@smithy/credential-provider-imds": "^2.0.0", "@smithy/property-provider": "^2.0.0", - "@smithy/types": "^2.7.0", + "@smithy/types": "^2.8.0", "tslib": "^2.5.0" }, "engines": { @@ -506,14 +506,14 @@ } }, "node_modules/@aws-sdk/middleware-host-header": { - "version": "3.468.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-host-header/-/middleware-host-header-3.468.0.tgz", - "integrity": "sha512-gwQ+/QhX+lhof304r6zbZ/V5l5cjhGRxLL3CjH1uJPMcOAbw9wUlMdl+ibr8UwBZ5elfKFGiB1cdW/0uMchw0w==", + "version": "3.485.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-host-header/-/middleware-host-header-3.485.0.tgz", + "integrity": "sha512-1mAUX9dQNGo2RIKseVj7SI/D5abQJQ/Os8hQ0NyVAyyVYF+Yjx5PphKgfhM5yoBwuwZUl6q71XPYEGNx7be6SA==", "optional": true, "dependencies": { - "@aws-sdk/types": "3.468.0", - "@smithy/protocol-http": "^3.0.11", - "@smithy/types": "^2.7.0", + "@aws-sdk/types": "3.485.0", + "@smithy/protocol-http": "^3.0.12", + "@smithy/types": "^2.8.0", "tslib": "^2.5.0" }, "engines": { @@ -521,13 +521,13 @@ } }, "node_modules/@aws-sdk/middleware-logger": { - "version": "3.468.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-logger/-/middleware-logger-3.468.0.tgz", - "integrity": "sha512-X5XHKV7DHRXI3f29SAhJPe/OxWRFgDWDMMCALfzhmJfCi6Jfh0M14cJKoC+nl+dk9lB+36+jKjhjETZaL2bPlA==", + "version": "3.485.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-logger/-/middleware-logger-3.485.0.tgz", + "integrity": "sha512-O8IgJ0LHi5wTs5GlpI7nqmmSSagkVdd1shpGgQWY2h0kMSCII8CJZHBG97dlFFpGTvx5EDlhPNek7rl/6F4dRw==", "optional": true, "dependencies": { - "@aws-sdk/types": "3.468.0", - "@smithy/types": "^2.7.0", + "@aws-sdk/types": "3.485.0", + "@smithy/types": "^2.8.0", "tslib": "^2.5.0" }, "engines": { @@ -535,14 +535,14 @@ } }, "node_modules/@aws-sdk/middleware-recursion-detection": { - "version": "3.468.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-recursion-detection/-/middleware-recursion-detection-3.468.0.tgz", - "integrity": "sha512-vch9IQib2Ng9ucSyRW2eKNQXHUPb5jUPCLA5otTW/8nGjcOU37LxQG4WrxO7uaJ9Oe8hjHO+hViE3P0KISUhtA==", + "version": "3.485.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-recursion-detection/-/middleware-recursion-detection-3.485.0.tgz", + "integrity": "sha512-ZeVNATGNFcqkWDut3luVszROTUzkU5u+rJpB/xmeMoenlDAjPRiHt/ca3WkI5wAnIJ1VSNGpD2sOFLMCH+EWag==", "optional": true, "dependencies": { - "@aws-sdk/types": "3.468.0", - "@smithy/protocol-http": "^3.0.11", - "@smithy/types": "^2.7.0", + "@aws-sdk/types": "3.485.0", + "@smithy/protocol-http": "^3.0.12", + "@smithy/types": "^2.8.0", "tslib": "^2.5.0" }, "engines": { @@ -550,17 +550,17 @@ } }, "node_modules/@aws-sdk/middleware-signing": { - "version": "3.468.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-signing/-/middleware-signing-3.468.0.tgz", - "integrity": "sha512-s+7fSB1gdnnTj5O0aCCarX3z5Vppop8kazbNSZADdkfHIDWCN80IH4ZNjY3OWqaAz0HmR4LNNrovdR304ojb4Q==", + "version": "3.485.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-signing/-/middleware-signing-3.485.0.tgz", + "integrity": "sha512-41xzT2p1sOibhsLkdE5rwPJkNbBtKD8Gp36/ySfu0KE415wfXKacElSVxAaBw39/j7iSWDYqqybeEYbAzk+3GQ==", "optional": true, "dependencies": { - "@aws-sdk/types": "3.468.0", + "@aws-sdk/types": "3.485.0", "@smithy/property-provider": "^2.0.0", - "@smithy/protocol-http": "^3.0.11", + "@smithy/protocol-http": "^3.0.12", "@smithy/signature-v4": "^2.0.0", - "@smithy/types": "^2.7.0", - "@smithy/util-middleware": "^2.0.8", + "@smithy/types": "^2.8.0", + "@smithy/util-middleware": "^2.0.9", "tslib": "^2.5.0" }, "engines": { @@ -568,15 +568,15 @@ } }, "node_modules/@aws-sdk/middleware-user-agent": { - "version": "3.478.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.478.0.tgz", - "integrity": "sha512-Rec+nAPIzzwxgHPW+xqY6tooJGFOytpYg/xSRv8/IXl3xKGhmpMGs6gDWzmMBv/qy5nKTvLph/csNWJ98GWXCw==", + "version": "3.485.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.485.0.tgz", + "integrity": "sha512-CddCVOn+OPQ0CcchketIg+WF6v+MDLAf3GOYTR2htUxxIm7HABuRd6R3kvQ5Jny9CV8gMt22G1UZITsFexSJlQ==", "optional": true, "dependencies": { - "@aws-sdk/types": "3.468.0", - "@aws-sdk/util-endpoints": "3.478.0", - "@smithy/protocol-http": "^3.0.11", - "@smithy/types": "^2.7.0", + "@aws-sdk/types": "3.485.0", + "@aws-sdk/util-endpoints": "3.485.0", + "@smithy/protocol-http": "^3.0.12", + "@smithy/types": "^2.8.0", "tslib": "^2.5.0" }, "engines": { @@ -584,15 +584,15 @@ } }, "node_modules/@aws-sdk/region-config-resolver": { - "version": "3.484.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/region-config-resolver/-/region-config-resolver-3.484.0.tgz", - "integrity": "sha512-qfYSwSIc9GasHFrJidydlQE433mB93d31dfypFWhrJPXRv1fhopO72NSfsY2WCcbaRkADc4AajLZFly4J96abw==", + "version": "3.485.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/region-config-resolver/-/region-config-resolver-3.485.0.tgz", + "integrity": "sha512-2FB2EQ0sIE+YgFqGtkE1lDIMIL6nYe6MkOHBwBM7bommadKIrbbr2L22bPZGs3ReTsxiJabjzxbuCAVhrpHmhg==", "optional": true, "dependencies": { - "@smithy/node-config-provider": "^2.1.8", - "@smithy/types": "^2.7.0", + "@smithy/node-config-provider": "^2.1.9", + "@smithy/types": "^2.8.0", "@smithy/util-config-provider": "^2.1.0", - "@smithy/util-middleware": "^2.0.8", + "@smithy/util-middleware": "^2.0.9", "tslib": "^2.5.0" }, "engines": { @@ -600,46 +600,46 @@ } }, "node_modules/@aws-sdk/token-providers": { - "version": "3.484.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/token-providers/-/token-providers-3.484.0.tgz", - "integrity": "sha512-9Eb7X0sNhJANfYCeEYWCvfeD4shMZEse3YUz5EALzbpzi/So56ZaeA/lWWeh0fkYiByq74eA2QkC/tXZkHw6EQ==", + "version": "3.485.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/token-providers/-/token-providers-3.485.0.tgz", + "integrity": "sha512-kOXA1WKIVIFNRqHL8ynVZ3hCKLsgnEmGr2iDR6agDNw5fYIlCO/6N2xR6QdGcLTvUUbwOlz4OvKLUQnWMKAnnA==", "optional": true, "dependencies": { "@aws-crypto/sha256-browser": "3.0.0", "@aws-crypto/sha256-js": "3.0.0", - "@aws-sdk/middleware-host-header": "3.468.0", - "@aws-sdk/middleware-logger": "3.468.0", - "@aws-sdk/middleware-recursion-detection": "3.468.0", - "@aws-sdk/middleware-user-agent": "3.478.0", - "@aws-sdk/region-config-resolver": "3.484.0", - "@aws-sdk/types": "3.468.0", - "@aws-sdk/util-endpoints": "3.478.0", - "@aws-sdk/util-user-agent-browser": "3.468.0", - "@aws-sdk/util-user-agent-node": "3.470.0", - "@smithy/config-resolver": "^2.0.22", - "@smithy/fetch-http-handler": "^2.3.1", - "@smithy/hash-node": "^2.0.17", - "@smithy/invalid-dependency": "^2.0.15", - "@smithy/middleware-content-length": "^2.0.17", - "@smithy/middleware-endpoint": "^2.2.3", - "@smithy/middleware-retry": "^2.0.25", - "@smithy/middleware-serde": "^2.0.15", - "@smithy/middleware-stack": "^2.0.9", - "@smithy/node-config-provider": "^2.1.8", - "@smithy/node-http-handler": "^2.2.1", + "@aws-sdk/middleware-host-header": "3.485.0", + "@aws-sdk/middleware-logger": "3.485.0", + "@aws-sdk/middleware-recursion-detection": "3.485.0", + "@aws-sdk/middleware-user-agent": "3.485.0", + "@aws-sdk/region-config-resolver": "3.485.0", + "@aws-sdk/types": "3.485.0", + "@aws-sdk/util-endpoints": "3.485.0", + "@aws-sdk/util-user-agent-browser": "3.485.0", + "@aws-sdk/util-user-agent-node": "3.485.0", + "@smithy/config-resolver": "^2.0.23", + "@smithy/fetch-http-handler": "^2.3.2", + "@smithy/hash-node": "^2.0.18", + "@smithy/invalid-dependency": "^2.0.16", + "@smithy/middleware-content-length": "^2.0.18", + "@smithy/middleware-endpoint": "^2.3.0", + "@smithy/middleware-retry": "^2.0.26", + "@smithy/middleware-serde": "^2.0.16", + "@smithy/middleware-stack": "^2.0.10", + "@smithy/node-config-provider": "^2.1.9", + "@smithy/node-http-handler": "^2.2.2", "@smithy/property-provider": "^2.0.0", - "@smithy/protocol-http": "^3.0.11", + "@smithy/protocol-http": "^3.0.12", "@smithy/shared-ini-file-loader": "^2.0.6", - "@smithy/smithy-client": "^2.2.0", - "@smithy/types": "^2.7.0", - "@smithy/url-parser": "^2.0.15", + "@smithy/smithy-client": "^2.2.1", + "@smithy/types": "^2.8.0", + "@smithy/url-parser": "^2.0.16", "@smithy/util-base64": "^2.0.1", "@smithy/util-body-length-browser": "^2.0.1", "@smithy/util-body-length-node": "^2.1.0", - "@smithy/util-defaults-mode-browser": "^2.0.23", - "@smithy/util-defaults-mode-node": "^2.0.31", - "@smithy/util-endpoints": "^1.0.7", - "@smithy/util-retry": "^2.0.8", + "@smithy/util-defaults-mode-browser": "^2.0.24", + "@smithy/util-defaults-mode-node": "^2.0.32", + "@smithy/util-endpoints": "^1.0.8", + "@smithy/util-retry": "^2.0.9", "@smithy/util-utf8": "^2.0.2", "tslib": "^2.5.0" }, @@ -648,12 +648,12 @@ } }, "node_modules/@aws-sdk/types": { - "version": "3.468.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/types/-/types-3.468.0.tgz", - "integrity": "sha512-rx/9uHI4inRbp2tw3Y4Ih4PNZkVj32h7WneSg3MVgVjAoVD5Zti9KhS5hkvsBxfgmQmg0AQbE+b1sy5WGAgntA==", + "version": "3.485.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/types/-/types-3.485.0.tgz", + "integrity": "sha512-+QW32YQdvZRDOwrAQPo/qCyXoSjgXB6RwJwCwkd8ebJXRXw6tmGKIHaZqYHt/LtBymvnaBgBBADNa4+qFvlOFw==", "optional": true, "dependencies": { - "@smithy/types": "^2.7.0", + "@smithy/types": "^2.8.0", "tslib": "^2.5.0" }, "engines": { @@ -661,13 +661,13 @@ } }, "node_modules/@aws-sdk/util-endpoints": { - "version": "3.478.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.478.0.tgz", - "integrity": "sha512-u9Mcg3euGJGs5clPt9mBuhBjHiEKiD0PnfvArhfq9i+dcY5mbCq/i1Dezp3iv1fZH9xxQt7hPXDfSpt1yUSM6g==", + "version": "3.485.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.485.0.tgz", + "integrity": "sha512-dTd642F7nJisApF8YjniqQ6U59CP/DCtar11fXf1nG9YNBCBsNNVw5ZfZb5nSNzaIdy27mQioWTCV18JEj1mxg==", "optional": true, "dependencies": { - "@aws-sdk/types": "3.468.0", - "@smithy/util-endpoints": "^1.0.7", + "@aws-sdk/types": "3.485.0", + "@smithy/util-endpoints": "^1.0.8", "tslib": "^2.5.0" }, "engines": { @@ -687,26 +687,26 @@ } }, "node_modules/@aws-sdk/util-user-agent-browser": { - "version": "3.468.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-user-agent-browser/-/util-user-agent-browser-3.468.0.tgz", - "integrity": "sha512-OJyhWWsDEizR3L+dCgMXSUmaCywkiZ7HSbnQytbeKGwokIhD69HTiJcibF/sgcM5gk4k3Mq3puUhGnEZ46GIig==", + "version": "3.485.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-user-agent-browser/-/util-user-agent-browser-3.485.0.tgz", + "integrity": "sha512-QliWbjg0uOhGTcWgWTKPMY0SBi07g253DjwrCINT1auqDrdQPxa10xozpZExBYjAK2KuhYDNUzni127ae6MHOw==", "optional": true, "dependencies": { - "@aws-sdk/types": "3.468.0", - "@smithy/types": "^2.7.0", + "@aws-sdk/types": "3.485.0", + "@smithy/types": "^2.8.0", "bowser": "^2.11.0", "tslib": "^2.5.0" } }, "node_modules/@aws-sdk/util-user-agent-node": { - "version": "3.470.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-user-agent-node/-/util-user-agent-node-3.470.0.tgz", - "integrity": "sha512-QxsZ9iVHcBB/XRdYvwfM5AMvNp58HfqkIrH88mY0cmxuvtlIGDfWjczdDrZMJk9y0vIq+cuoCHsGXHu7PyiEAQ==", + "version": "3.485.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-user-agent-node/-/util-user-agent-node-3.485.0.tgz", + "integrity": "sha512-QF+aQ9jnDlPUlFBxBRqOylPf86xQuD3aEPpOErR+50qJawVvKa94uiAFdvtI9jv6hnRZmuFsTj2rsyytnbAYBA==", "optional": true, "dependencies": { - "@aws-sdk/types": "3.468.0", - "@smithy/node-config-provider": "^2.1.8", - "@smithy/types": "^2.7.0", + "@aws-sdk/types": "3.485.0", + "@smithy/node-config-provider": "^2.1.9", + "@smithy/types": "^2.8.0", "tslib": "^2.5.0" }, "engines": { @@ -2658,15 +2658,15 @@ } }, "node_modules/@slack/web-api": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/@slack/web-api/-/web-api-6.11.0.tgz", - "integrity": "sha512-DLShYUc2dE8QrhmrJZ7YuhAuh/VW88Dt3LL7s2KrkEOyxbdfjAtF9bzPOBMlXuWmO6nWLGVevPuhShcYyjwTEw==", + "version": "6.11.1", + "resolved": "https://registry.npmjs.org/@slack/web-api/-/web-api-6.11.1.tgz", + "integrity": "sha512-AU7Sty+NwkMU0qT/cKSIYV1NZ+bGDYqmJ3LAJD/3vtrxJvV9F9DdALgRSV2zRhrRjzjOgLhCRXVuOikQsKQhAg==", "dependencies": { "@slack/logger": "^3.0.0", "@slack/types": "^2.11.0", "@types/is-stream": "^1.1.0", "@types/node": ">=12.0.0", - "axios": "^1.6.0", + "axios": "^1.6.3", "eventemitter3": "^3.1.0", "form-data": "^2.5.0", "is-electron": "2.2.2", @@ -3467,9 +3467,9 @@ "integrity": "sha512-yg6E+u0/+Zjva+buc3EIb+29XEg4wltq7cSmd4Uc2EE/1nUVmxyzpX6gUXD0V8jIrG0r7YeOGVIbYRkxeooCtw==" }, "node_modules/@types/luxon": { - "version": "3.3.7", - "resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.3.7.tgz", - "integrity": "sha512-gKc9P2d4g5uYwmy4s/MO/yOVPmvHyvzka1YH6i5dM03UrFofHSmgc0D0ymbDRStFWHusk6cwwF6nhLm/ckBbbQ==" + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.3.8.tgz", + "integrity": "sha512-jYvz8UMLDgy3a5SkGJne8H7VA7zPV2Lwohjx0V8V31+SqAjNmurWMkk9cQhfvlcnXWudBpK9xPM1n4rljOcHYQ==" }, "node_modules/@types/markdown-it": { "version": "12.2.3", @@ -4189,11 +4189,11 @@ } }, "node_modules/axios": { - "version": "1.6.3", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.3.tgz", - "integrity": "sha512-fWyNdeawGam70jXSVlKl+SUNVcL6j6W79CuSIPfi6HnDUmSCH6gyUys/HrqHeA/wU0Az41rRgean494d0Jb+ww==", + "version": "1.6.5", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.5.tgz", + "integrity": "sha512-Ii012v05KEVuUoFWmMW/UQv9aRIc3ZwkWDcM+h5Il8izZCtRVpDUfwpoFf7eOtajT3QiGR4yDUx7lPqHJULgbg==", "dependencies": { - "follow-redirects": "^1.15.0", + "follow-redirects": "^1.15.4", "form-data": "^4.0.0", "proxy-from-env": "^1.1.0" } @@ -4899,9 +4899,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001572", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001572.tgz", - "integrity": "sha512-1Pbh5FLmn5y4+QhNyJE9j3/7dK44dGB83/ZMjv/qJk86TvDbjk0LosiZo0i0WB0Vx607qMX9jYrn1VLHCkN4rw==", + "version": "1.0.30001574", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001574.tgz", + "integrity": "sha512-BtYEK4r/iHt/txm81KBudCUcTy7t+s9emrIaHqjYurQ10x71zJ5VQ9x1dYPcz/b+pKSp4y/v1xSI67A+LzpNyg==", "dev": true, "funding": [ { @@ -5651,9 +5651,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/electron-to-chromium": { - "version": "1.4.616", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.616.tgz", - "integrity": "sha512-1n7zWYh8eS0L9Uy+GskE0lkBUNK83cXTVJI0pU3mGprFsbfSdAc15VTFbo+A+Bq4pwstmL30AVcEU3Fo463lNg==", + "version": "1.4.623", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.623.tgz", + "integrity": "sha512-lKoz10iCYlP1WtRYdh5MvocQPWVRoI7ysp6qf18bmeBgR8abE6+I2CsfyNKztRDZvhdWc+krKT6wS7Neg8sw3A==", "dev": true }, "node_modules/elliptic": { diff --git a/package.json b/package.json index beae768..79d7228 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hubot-plusplus-expanded", - "version": "3.5.4", + "version": "3.5.5", "description": "A hubot script for micro praise", "main": "index.js", "engines": { diff --git a/src/eventHandlers.js b/src/eventHandlers.js index 2045dcd..453eca1 100644 --- a/src/eventHandlers.js +++ b/src/eventHandlers.js @@ -11,13 +11,13 @@ const { ehs } = require('./lib/services/eventHandler'); module.exports = function events(robot) { - robot.on('plus-plus', (eventArgs) => - ehs.sendPlusPlusNotification(robot, eventArgs), + // Reference ./events/plusPlusEvent.js for the event object + robot.on('plus-plus', (...plusPlusObjects) => + ehs.sendPlusPlusNotification(robot, ...plusPlusObjects), ); - robot.on('plus-plus-failure', (eventArgs) => - ehs.sendPlusPlusFalsePositiveNotification(robot, eventArgs), - ); - robot.on('plus-plus-spam', (eventArgs) => - ehs.logAndNotifySpam(robot, eventArgs), + + robot.on('plus-plus-failure', (...args) => + ehs.sendPlusPlusFalsePositiveNotification(robot, ...args), ); + robot.on('plus-plus-spam', (...args) => ehs.logAndNotifySpam(robot, ...args)); }; diff --git a/src/eventHandlers.test.js b/src/eventHandlers.test.js index 31a2b67..6179f0c 100644 --- a/src/eventHandlers.test.js +++ b/src/eventHandlers.test.js @@ -1,6 +1,7 @@ const TestHelper = require('hubot-test-helper'); const { relativeTestHelperPathHelper } = require('../test/test_helpers'); +const { GeneratePlusPlusEventObject } = require('./events/plusPlus'); describe('EventHandlers', () => { let room; @@ -9,7 +10,6 @@ describe('EventHandlers', () => { let msgSpy; beforeAll(async () => { process.env.HUBOT_PLUSPLUS_NOTIFICATION_ROOM = undefined; - tokenHelper = new TestHelper( relativeTestHelperPathHelper('src/eventHandlers.js'), ); @@ -30,7 +30,7 @@ describe('EventHandlers', () => { describe('plus-plus event', () => { describe('when the HUBOT_PLUSPLUS_NOTIFICATION_ROOM is undefined', () => { it(`shouldn't do anything`, async () => { - room.emit('plus-plus', [{}]); + room.emit('plus-plus', [GeneratePlusPlusEventObject()]); expect(room.messages.length).toBe(0); expect(msgSpy).not.toHaveBeenCalled(); }); @@ -39,7 +39,7 @@ describe('EventHandlers', () => { describe('when the HUBOT_PLUSPLUS_NOTIFICATION_ROOM is defined', () => { it('should message room with empty message if empty object in array', async () => { process.env.HUBOT_PLUSPLUS_NOTIFICATION_ROOM = 'test'; - roomRobot.emit('plus-plus', [{}]); + roomRobot.emit('plus-plus', [GeneratePlusPlusEventObject()]); expect(room.messages.length).toBe(0); expect(msgSpy).toHaveBeenCalled(); expect(msgSpy).toHaveBeenCalledWith('test', ''); diff --git a/src/events/helpers.js b/src/events/helpers.js new file mode 100644 index 0000000..938eb01 --- /dev/null +++ b/src/events/helpers.js @@ -0,0 +1,28 @@ +module.exports = { + getRoomStr(msg) { + if (msg.room) { + return `<#${msg.room}>`; + } + if (msg.message && msg.message.room) { + return `<#${msg.message.room}>`; + } + if (msg.envelope && msg.envelope.room) { + return `<#${msg.envelope.room}>`; + } + return 'Unknown Room'; + }, + + getUserStr(user) { + if (!user) { + return 'Unknown User'; + } + + if (user.slackId) { + return `<@${user.slackId}>`; + } + if (user.id) { + return `<@${user.id}>`; + } + return user.name; + }, +}; diff --git a/src/events/plusPlus.js b/src/events/plusPlus.js new file mode 100644 index 0000000..bf87c46 --- /dev/null +++ b/src/events/plusPlus.js @@ -0,0 +1,77 @@ +const { H } = require('../lib/helpers'); +const { getRoomStr, getUserStr } = require('./helpers'); + +module.exports.GeneratePlusPlusEventObject = + function GeneratePlusPlusEventObject( + { + msg = {}, + operator = undefined, + direction = '++', + fromUser = {}, + toUser = {}, + cleanReason, + amount = 1, + } = { + msg: {}, + operator: undefined, + direction: '++', + fromUser: {}, + toUser: {}, + cleanReason: undefined, + amount: 1, + }, + ) { + // check if everything is defaults + if ( + Object.keys(msg).length === 0 && + operator === undefined && + direction === '++' && + Object.keys(fromUser).length === 0 && + Object.keys(toUser).length === 0 && + cleanReason === undefined && + amount === 1 + ) { + return {}; + } + const plusPlusEvent = {}; + + plusPlusEvent.msg = msg; + plusPlusEvent.direction = operator ?? direction; + plusPlusEvent.fromUser = fromUser; + plusPlusEvent.toUser = toUser; + plusPlusEvent.room = getRoomStr(msg); + plusPlusEvent.robotName = msg?.robot?.name ?? 'hubot'; + plusPlusEvent.capitalRobotName = H.capitalizeFirstLetter( + plusPlusEvent.robotName, + ); + plusPlusEvent.cleanReason = + cleanReason ?? `point given through ${plusPlusEvent.robotName}`; + try { + plusPlusEvent.amount = parseInt(amount, 10) ?? 1; + } catch (e) { + plusPlusEvent.amount = 1; + } + plusPlusEvent.pluralStrAddition = plusPlusEvent.amount > 1 ? 's' : ''; + + const fromStr = getUserStr(plusPlusEvent.fromUser); + const toStr = getUserStr(plusPlusEvent.toUser); + + let amountStr = plusPlusEvent.amount; + if (plusPlusEvent.amount === 1) { + amountStr = `a`; + if (plusPlusEvent.toUser.name.match(/^[aeiou]/i)) { + amountStr = `an`; + } + } + + return { + notificationMessage: `${fromStr} sent ${amountStr} ${plusPlusEvent.capitalRobotName} point${plusPlusEvent.pluralStrAddition} to ${toStr} in ${plusPlusEvent.room}`, + recipient: plusPlusEvent.toUser, + sender: plusPlusEvent.fromUser, + direction: plusPlusEvent.direction, + amount: plusPlusEvent.amount, + room: plusPlusEvent.room, + reason: plusPlusEvent.cleanReason, + msg: plusPlusEvent.msg, + }; + }; diff --git a/src/events/plusPlusFalsePositive.js b/src/events/plusPlusFalsePositive.js new file mode 100644 index 0000000..ef4503b --- /dev/null +++ b/src/events/plusPlusFalsePositive.js @@ -0,0 +1,38 @@ +const { getRoomStr, getUserStr } = require('./helpers'); + +module.exports.GeneratePlusPlusFailureEventObject = + function GeneratePlusPlusFailureEventObject( + { msg = {} } = { + msg: {}, + }, + ) { + if (Object.keys(msg).length === 0) { + return {}; + } + const falsePos = {}; + falsePos.room = getRoomStr(msg); + const [fullText, premessage, _name, _number, conjunction, reason] = + msg.match; + if (fullText.length >= 150) { + falsePos.messageStr = 'It was really long (>=150)'; + } else { + falsePos.messageStr = 'It was a short message (<150)'; + } + falsePos.fromUser = getUserStr(msg.message.user); + + falsePos.notificationMessage = `False positive detected in ${ + falsePos.room + } from ${falsePos.fromUser}: +Has Pre-Message: [${!!premessage}]. +Has Conjunction: [${!!conjunction}]. +Has Reason: [${!!reason}]. + + + +${falsePos.messageStr}`; + + return { + notificationMessage: falsePos.notificationMessage, + room: falsePos.room, + }; + }; diff --git a/src/lib/helpers.js b/src/lib/helpers.js index 1cacb51..48a7fc8 100644 --- a/src/lib/helpers.js +++ b/src/lib/helpers.js @@ -10,6 +10,8 @@ const { isFriday, isSaturday, getWeekOfMonth, + parseISO, + parse, } = require('date-fns'); const { rpp } = require('./regExpPlusPlus'); @@ -285,6 +287,41 @@ class Helpers { static isSameDayOfYear(date1, date2) { return Helpers.getDayOfYear(date1) === Helpers.getDayOfYear(date2); } + + /** + * @param {string} dateStr - The date string to parse + * @param {object?} robot - The robot object + * @returns {object} - The parsed date object + * @static + */ + static parseDateStrAndFormat(dateStr, robot, formatStr = 'MMM. do yyyy') { + if (!dateStr) { + return 'unknown'; + } + + try { + // 2018-10-01T16:55:04.000Z + const date = parseISO(dateStr); + return format(date, formatStr); + } catch (e) { + // Mon Oct 01 2018 16:55:04 GMT+0000 (Coordinated Universal Time) + try { + const date = parse(dateStr, 'EEE MMM dd yyyy HH:mm:ss', new Date()); + return format(date, formatStr); + } catch (e2) { + try { + // who tf knows what this is + const date = new Date(dateStr); + return format(date, formatStr); + } catch (e3) { + if (robot && robot.logger) { + robot.logger.error('Failed to parse date string', dateStr); + } + return 'unknown'; + } + } + } + } } module.exports = Helpers; diff --git a/src/lib/helpers.test.js b/src/lib/helpers.test.js index 617d69c..a2d33ca 100644 --- a/src/lib/helpers.test.js +++ b/src/lib/helpers.test.js @@ -143,4 +143,86 @@ describe('Helpers', () => { expect(H.decode(encoded)).toBe(cleaned); }); }); + + describe('parseDateStrAndFormat', () => { + it('should parse "2018-01-01" to a date object', () => { + const dateStr = '2018-01-01'; + const result = H.parseDateStrAndFormat(dateStr); + + expect(typeof result).toEqual('string'); + expect(result).toEqual('Jan. 1st 2018'); + }); + + it('should parse "2018-01-01T00:00:00.000Z" to a date object', () => { + const dateStr = '2018-01-01T12:00:00.000Z'; + const result = H.parseDateStrAndFormat(dateStr); + + expect(typeof result).toEqual('string'); + expect(result).toEqual('Jan. 1st 2018'); + }); + + it('should parse "2020-01-01T00:00:00.000" to a date object', () => { + const dateStr = '2020-01-01T00:00:00.000'; + const result = H.parseDateStrAndFormat(dateStr); + + expect(typeof result).toEqual('string'); + expect(result).toEqual('Jan. 1st 2020'); + }); + + it('should parse "2018-01-01T00:00:00" to a date object', () => { + const dateStr = '2018-01-01T00:00:00'; + const result = H.parseDateStrAndFormat(dateStr); + + expect(typeof result).toEqual('string'); + expect(result).toEqual('Jan. 1st 2018'); + }); + + it('should parse "2020-08-18T19:10:23.500+00:00" to a date object', () => { + const dateStr = '2020-08-18T19:10:23.500+00:00'; + const result = H.parseDateStrAndFormat(dateStr); + + expect(typeof result).toEqual('string'); + expect(result).toEqual('Aug. 18th 2020'); + }); + + it('should parse "2020-08-13T20" to a date object', () => { + const dateStr = '2020-08-13T20'; + const result = H.parseDateStrAndFormat(dateStr); + + expect(typeof result).toEqual('string'); + expect(result).toEqual('Aug. 13th 2020'); + }); + + it('should parse "2018-01-01T" to a date object', () => { + const dateStr = '2018-01-01T'; + const result = H.parseDateStrAndFormat(dateStr); + + expect(typeof result).toEqual('string'); + expect(result).toEqual('Jan. 1st 2018'); + }); + + it('should parse "2020-07-23T12:13:48.593Z" to a date object', () => { + const dateStr = '2020-07-23T12:13:48.593Z'; + const result = H.parseDateStrAndFormat(dateStr); + + expect(typeof result).toEqual('string'); + expect(result).toEqual('Jul. 23rd 2020'); + }); + + it('should parse "2020-11-19T20:57:36.526+00:00" to a date object', () => { + const dateStr = '2020-11-19T20:57:36.526+00:00'; + const result = H.parseDateStrAndFormat(dateStr); + + expect(typeof result).toEqual('string'); + expect(result).toEqual('Nov. 19th 2020'); + }); + + it(`should parse dennis's hubotDay "2020-11-19T20:57:36.526+00:00" to a date object`, () => { + const dateStr = '2020-11-19T20:57:36.526+00:00'; + const result = H.parseDateStrAndFormat(dateStr); + + expect(typeof result).toEqual('string'); + expect(result).toEqual('Nov. 19th 2020'); + }); + }); }); diff --git a/src/lib/messageFactory.js b/src/lib/messageFactory.js index 7402958..f16bbf9 100644 --- a/src/lib/messageFactory.js +++ b/src/lib/messageFactory.js @@ -30,19 +30,9 @@ class MessageFactory { baseString += `\nTotal Points Given: ${user.totalPointsGiven}`; if (user[`${robotName}Day`]) { - try { - const dateObj = parseISO(user[`${robotName}Day`]); - baseString += `\n:birthday: ${H.capitalizeFirstLetter( - robotName, - )}day is ${format(dateObj, 'MMM. do yyyy')}`; - } catch (e) { - robot.logger.error( - `Robot day failed to be parsed: ${robotName}, ${ - user[`${robotName}Day`] - }`, - e, - ); - } + baseString += `\n:birthday: ${H.capitalizeFirstLetter( + robotName, + )}day is ${H.parseDateStrAndFormat(user[`${robotName}Day`])}`; } const keys = Object.keys(user.reasons || {}); if (keys.length > 1) { diff --git a/src/lib/services/plusplus.js b/src/lib/services/plusplus.js index bb0c23b..2d2d6a6 100644 --- a/src/lib/services/plusplus.js +++ b/src/lib/services/plusplus.js @@ -2,6 +2,10 @@ const { sks } = require('./scorekeeper'); const { H } = require('../helpers'); const { rpp } = require('../regExpPlusPlus'); const { mfs } = require('../messageFactory'); +const { GeneratePlusPlusEventObject } = require('../../events/plusPlus'); +const { + GeneratePlusPlusFailureEventObject, +} = require('../../events/plusPlusFalsePositive'); class PlusPlusService { static buildPlusPlusNotification( @@ -11,6 +15,7 @@ class PlusPlusService { toUser, room, cleanReason, + amount = 1, ) { const capRobotName = H.capitalizeFirstLetter(msg.robot.name); const sentOrRem = operator.match(rpp.positiveOperators) @@ -28,7 +33,7 @@ class PlusPlusService { sender: fromUser, recipient: toUser, direction: operator, - amount: 1, + amount, room, reason: cleanReason, msg, @@ -39,25 +44,15 @@ class PlusPlusService { * Functions for responding to commands */ static async upOrDownVote(msg) { - const [fullText, premessage, name, operator, conjunction, reason] = + const [_fullText, premessage, name, operator, conjunction, reason] = msg.match; if (H.isKnownFalsePositive(premessage, conjunction, reason, operator)) { // circuit break a plus plus - msg.robot.emit('plus-plus-failure', { - notificationMessage: - `False positive detected in <#${msg.message.room}> ` + - `from <@${msg.message.user.id}>` + - `\nHas pre-Message text: [${!!premessage}].\n` + - `Missing Conjunction: [${!!(!conjunction && reason)}]` + - '\n\n ' + - `${ - fullText.length >= 150 - ? 'It was really long (>=150)' - : 'It was a short message (<150)' - }`, - room: msg.message.room, - }); + msg.robot.emit( + 'plus-plus-failure', + GeneratePlusPlusFailureEventObject({ msg }), + ); return; } const increment = operator.match(rpp.positiveOperators) ? 1 : -1; @@ -102,38 +97,30 @@ class PlusPlusService { if (message) { msg.send(message); - msg.robot.emit( - 'plus-plus', - PlusPlusService.buildPlusPlusNotification( + msg.robot.emit('plus-plus', [ + GeneratePlusPlusEventObject({ msg, operator, fromUser, toUser, - room, cleanReason, - ), - ); + }), + ]); } } static async multipleUsersVote(msg) { - const [fullText, premessage, names, operator, conjunction, reason] = + const [_fullText, premessage, names, operator, conjunction, reason] = msg.match; if (!names) { return; } if (H.isKnownFalsePositive(premessage, conjunction, reason, operator)) { // circuit break a plus plus - msg.robot.emit('plus-plus-failure', { - notificationMessage: `False positive detected in <#${ - msg.message.room - }> from <@${ - msg.message.user.id - }>:\nPre-Message text: [${!!premessage}].\nMissing Conjunction: [${!!( - !conjunction && reason - )}]\n\n${fullText}`, - room: msg.message.room, - }); + msg.robot.emit( + 'plus-plus-failure', + GeneratePlusPlusFailureEventObject({ msg }), + ); return; } @@ -206,14 +193,13 @@ class PlusPlusService { ); pointEmits.push( - PlusPlusService.buildPlusPlusNotification( + GeneratePlusPlusEventObject({ msg, operator, fromUser, toUser, - room, cleanReason, - ), + }), ); } } diff --git a/src/lib/services/token.js b/src/lib/services/token.js index 9dac1de..3a6e77c 100644 --- a/src/lib/services/token.js +++ b/src/lib/services/token.js @@ -1,5 +1,9 @@ const ScoreKeeperService = require('./scorekeeper'); const { H } = require('../helpers'); +const { GeneratePlusPlusEventObject } = require('../../events/plusPlus'); +const { + GeneratePlusPlusFailureEventObject, +} = require('../../events/plusPlusFalsePositive'); class TokenService { /** @@ -8,19 +12,14 @@ class TokenService { * @returns {Promise} */ static async giveTokenBetweenUsers(msg) { - const [fullText, premessage, name, number, conjunction, reason] = msg.match; + const [_fullText, _premessage, name, number, conjunction, reason] = + msg.match; if (!conjunction && reason) { // circuit break a plus plus - msg.robot.emit('plus-plus-failure', { - notificationMessage: `False positive detected in <#${ - msg.message.room - }> from <@${ - msg.message.user.id - }>:\nPre-Message text: [${!!premessage}].\nMissing Conjunction: [${!!( - !conjunction && reason - )}]\n\n${fullText}`, - room: msg.message.room, - }); + msg.robot.emit( + 'plus-plus-failure', + GeneratePlusPlusFailureEventObject({ msg }), + ); return; } const { room, mentions } = msg.message; @@ -71,20 +70,16 @@ class TokenService { if (message) { msg.send(message); - msg.robot.emit('plus-plus', { - notificationMessage: `<@${ - response.fromUser.slackId - }> sent ${number} ${H.capitalizeFirstLetter(msg.robot.name)} point${ - parseInt(number, 10) > 1 ? 's' : '' - } to <@${response.toUser.slackId}> in <#${room}>`, - recipient: response.toUser, - sender: response.fromUser, - direction: '++', - amount: number, - room, - reason: cleanReason, - msg, - }); + msg.robot.emit('plus-plus', [ + GeneratePlusPlusEventObject({ + msg, + operator: '++', + fromUser: response.fromUser, + toUser: response.toUser, + cleanReason, + amount: number, + }), + ]); } } } diff --git a/src/messageHandlers/plusplus.test.js b/src/messageHandlers/plusplus.test.js index b335c4b..42cefe4 100644 --- a/src/messageHandlers/plusplus.test.js +++ b/src/messageHandlers/plusplus.test.js @@ -11,11 +11,13 @@ describe('PlusPlus', () => { let room; let plusPlusHelper; let emitSpy; + let onSpy; beforeAll(async () => { process.env.HUBOT_CRYPTO_FURTHER_HELP_URL = undefined; - plusPlusHelper = new TestHelper( + plusPlusHelper = new TestHelper([ relativeTestHelperPathHelper('src/messageHandlers/plusplus.js'), - ); + relativeTestHelperPathHelper('src/eventHandlers.js'), + ]); }); afterAll(async () => {}); @@ -29,8 +31,10 @@ describe('PlusPlus', () => { isA1Day: jest.fn().mockReturnValue(false), }; }); + room = await plusPlusHelper.createRoom({ httpd: false }); emitSpy = jest.spyOn(room.robot, 'emit'); + onSpy = jest.spyOn(room.robot, 'on'); }); afterEach(async () => { @@ -155,6 +159,7 @@ describe('PlusPlus', () => { 'plus-plus', expect.any(Array), ); + const scores = room.robot.emit.mock.calls[0][1]; expect(scores[0].notificationMessage).toEqual( @@ -269,15 +274,20 @@ describe('PlusPlus', () => { 'matt.erickson', 'hello, @derp -- i have no idea what you are doing', ); - await wait(); - expect(emitSpy).toHaveBeenCalledWith('plus-plus-failure', { + await wait(2000); + expect(emitSpy).toHaveBeenCalled(); + expect(emitSpy.mock.calls[0][0]).toEqual('plus-plus-failure'); + expect(emitSpy.mock.calls[0][1]).toEqual({ notificationMessage: - 'False positive detected in <#room1> from <@matt.erickson>\n' + - 'Has pre-Message text: [true].\n' + - 'Missing Conjunction: [true]\n' + + 'False positive detected in <#room1> from <@matt.erickson>:\n' + + 'Has Pre-Message: [true].\n' + + 'Has Conjunction: [false].\n' + + 'Has Reason: [true].\n' + '\n' + - ' It was a short message (<150)', - room: 'room1', + '\n' + + '\n' + + 'It was a short message (<150)', + room: '<#room1>', }); const user = await db.collection('scores').findOne({ name: 'derp' });