From 15bbd5e6d3377b767d0ab9f8d624048a2bc4a069 Mon Sep 17 00:00:00 2001 From: ekremney Date: Tue, 12 Dec 2023 14:58:32 +0100 Subject: [PATCH 1/3] feat: rum api client --- package-lock.json | 551 +++++++++--------- .../.jsdoc.json | 17 + .../.mocha-multi.json | 6 + .../spacecat-shared-rum-api-client/.npmignore | 9 + .../.nycrc.json | 10 + .../CHANGELOG.md | 25 + .../LICENSE.txt | 264 +++++++++ .../spacecat-shared-rum-api-client/README.md | 16 + .../package.json | 47 ++ .../src/index.d.ts | 43 ++ .../src/index.js | 97 +++ .../src/utils.js | 24 + .../test/create-backlink.test.js | 116 ++++ .../test/rum-api-client.test.js | 61 ++ .../test/rumapi-data.js | 92 +++ .../test/setup-env.js | 14 + 16 files changed, 1101 insertions(+), 291 deletions(-) create mode 100644 packages/spacecat-shared-rum-api-client/.jsdoc.json create mode 100644 packages/spacecat-shared-rum-api-client/.mocha-multi.json create mode 100644 packages/spacecat-shared-rum-api-client/.npmignore create mode 100644 packages/spacecat-shared-rum-api-client/.nycrc.json create mode 100644 packages/spacecat-shared-rum-api-client/CHANGELOG.md create mode 100644 packages/spacecat-shared-rum-api-client/LICENSE.txt create mode 100644 packages/spacecat-shared-rum-api-client/README.md create mode 100644 packages/spacecat-shared-rum-api-client/package.json create mode 100644 packages/spacecat-shared-rum-api-client/src/index.d.ts create mode 100644 packages/spacecat-shared-rum-api-client/src/index.js create mode 100644 packages/spacecat-shared-rum-api-client/src/utils.js create mode 100644 packages/spacecat-shared-rum-api-client/test/create-backlink.test.js create mode 100644 packages/spacecat-shared-rum-api-client/test/rum-api-client.test.js create mode 100644 packages/spacecat-shared-rum-api-client/test/rumapi-data.js create mode 100644 packages/spacecat-shared-rum-api-client/test/setup-env.js diff --git a/package-lock.json b/package-lock.json index 9bd716a13..8af1962f1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -106,6 +106,10 @@ "resolved": "packages/spacecat-shared-example", "link": true }, + "node_modules/@adobe/spacecat-shared-rum-api-client": { + "resolved": "packages/spacecat-shared-rum-api-client", + "link": true + }, "node_modules/@adobe/spacecat-shared-utils": { "resolved": "packages/spacecat-shared-utils", "link": true @@ -253,33 +257,6 @@ "node": ">=14.0.0" } }, - "node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/core": { - "version": "3.465.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.465.0.tgz", - "integrity": "sha512-fHSIw/Rgex3KbrEKn6ZrUc2VcsOTpdBMeyYtfmsTOLSyDDOG9k3jelOvVbCbrK5N6uEUSM8hrnySEKg94UB0cg==", - "dependencies": { - "@smithy/smithy-client": "^2.1.15", - "tslib": "^2.5.0" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/region-config-resolver": { - "version": "3.465.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/region-config-resolver/-/region-config-resolver-3.465.0.tgz", - "integrity": "sha512-h0Phd2Ae873dsPSWuxqxz2yRC5NMeeWxQiJPh4j42HF8g7dZK7tMQPkYznAoA/BzSBsEX87sbr3MmigquSyUTA==", - "dependencies": { - "@smithy/node-config-provider": "^2.1.5", - "@smithy/types": "^2.5.0", - "@smithy/util-config-provider": "^2.0.0", - "@smithy/util-middleware": "^2.0.6", - "tslib": "^2.5.0" - }, - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/@aws-sdk/client-dynamodb/node_modules/uuid": { "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", @@ -334,33 +311,6 @@ "node": ">=14.0.0" } }, - "node_modules/@aws-sdk/client-sso/node_modules/@aws-sdk/core": { - "version": "3.465.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.465.0.tgz", - "integrity": "sha512-fHSIw/Rgex3KbrEKn6ZrUc2VcsOTpdBMeyYtfmsTOLSyDDOG9k3jelOvVbCbrK5N6uEUSM8hrnySEKg94UB0cg==", - "dependencies": { - "@smithy/smithy-client": "^2.1.15", - "tslib": "^2.5.0" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/@aws-sdk/client-sso/node_modules/@aws-sdk/region-config-resolver": { - "version": "3.465.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/region-config-resolver/-/region-config-resolver-3.465.0.tgz", - "integrity": "sha512-h0Phd2Ae873dsPSWuxqxz2yRC5NMeeWxQiJPh4j42HF8g7dZK7tMQPkYznAoA/BzSBsEX87sbr3MmigquSyUTA==", - "dependencies": { - "@smithy/node-config-provider": "^2.1.5", - "@smithy/types": "^2.5.0", - "@smithy/util-config-provider": "^2.0.0", - "@smithy/util-middleware": "^2.0.6", - "tslib": "^2.5.0" - }, - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/@aws-sdk/client-sts": { "version": "3.465.0", "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.465.0.tgz", @@ -411,7 +361,7 @@ "node": ">=14.0.0" } }, - "node_modules/@aws-sdk/client-sts/node_modules/@aws-sdk/core": { + "node_modules/@aws-sdk/core": { "version": "3.465.0", "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.465.0.tgz", "integrity": "sha512-fHSIw/Rgex3KbrEKn6ZrUc2VcsOTpdBMeyYtfmsTOLSyDDOG9k3jelOvVbCbrK5N6uEUSM8hrnySEKg94UB0cg==", @@ -423,21 +373,6 @@ "node": ">=14.0.0" } }, - "node_modules/@aws-sdk/client-sts/node_modules/@aws-sdk/region-config-resolver": { - "version": "3.465.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/region-config-resolver/-/region-config-resolver-3.465.0.tgz", - "integrity": "sha512-h0Phd2Ae873dsPSWuxqxz2yRC5NMeeWxQiJPh4j42HF8g7dZK7tMQPkYznAoA/BzSBsEX87sbr3MmigquSyUTA==", - "dependencies": { - "@smithy/node-config-provider": "^2.1.5", - "@smithy/types": "^2.5.0", - "@smithy/util-config-provider": "^2.0.0", - "@smithy/util-middleware": "^2.0.6", - "tslib": "^2.5.0" - }, - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/@aws-sdk/credential-provider-env": { "version": "3.465.0", "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-env/-/credential-provider-env-3.465.0.tgz", @@ -539,6 +474,18 @@ "node": ">=14.0.0" } }, + "node_modules/@aws-sdk/endpoint-cache": { + "version": "3.465.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/endpoint-cache/-/endpoint-cache-3.465.0.tgz", + "integrity": "sha512-0cuotk23hVSrqxHkJ3TTWC9MVMRgwlUvCatyegJEauJnk8kpLSGXE5KVdExlUBwShGNlj7ac29okZ9m17iTi5Q==", + "dependencies": { + "mnemonist": "0.38.3", + "tslib": "^2.5.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/@aws-sdk/lib-dynamodb": { "version": "3.465.0", "resolved": "https://registry.npmjs.org/@aws-sdk/lib-dynamodb/-/lib-dynamodb-3.465.0.tgz", @@ -572,18 +519,6 @@ "node": ">=14.0.0" } }, - "node_modules/@aws-sdk/middleware-endpoint-discovery/node_modules/@aws-sdk/endpoint-cache": { - "version": "3.465.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/endpoint-cache/-/endpoint-cache-3.465.0.tgz", - "integrity": "sha512-0cuotk23hVSrqxHkJ3TTWC9MVMRgwlUvCatyegJEauJnk8kpLSGXE5KVdExlUBwShGNlj7ac29okZ9m17iTi5Q==", - "dependencies": { - "mnemonist": "0.38.3", - "tslib": "^2.5.0" - }, - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/@aws-sdk/middleware-host-header": { "version": "3.465.0", "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-host-header/-/middleware-host-header-3.465.0.tgz", @@ -671,6 +606,21 @@ "node": ">=14.0.0" } }, + "node_modules/@aws-sdk/region-config-resolver": { + "version": "3.465.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/region-config-resolver/-/region-config-resolver-3.465.0.tgz", + "integrity": "sha512-h0Phd2Ae873dsPSWuxqxz2yRC5NMeeWxQiJPh4j42HF8g7dZK7tMQPkYznAoA/BzSBsEX87sbr3MmigquSyUTA==", + "dependencies": { + "@smithy/node-config-provider": "^2.1.5", + "@smithy/types": "^2.5.0", + "@smithy/util-config-provider": "^2.0.0", + "@smithy/util-middleware": "^2.0.6", + "tslib": "^2.5.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/@aws-sdk/token-providers": { "version": "3.465.0", "resolved": "https://registry.npmjs.org/@aws-sdk/token-providers/-/token-providers-3.465.0.tgz", @@ -718,21 +668,6 @@ "node": ">=14.0.0" } }, - "node_modules/@aws-sdk/token-providers/node_modules/@aws-sdk/region-config-resolver": { - "version": "3.465.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/region-config-resolver/-/region-config-resolver-3.465.0.tgz", - "integrity": "sha512-h0Phd2Ae873dsPSWuxqxz2yRC5NMeeWxQiJPh4j42HF8g7dZK7tMQPkYznAoA/BzSBsEX87sbr3MmigquSyUTA==", - "dependencies": { - "@smithy/node-config-provider": "^2.1.5", - "@smithy/types": "^2.5.0", - "@smithy/util-config-provider": "^2.0.0", - "@smithy/util-middleware": "^2.0.6", - "tslib": "^2.5.0" - }, - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/@aws-sdk/types": { "version": "3.465.0", "resolved": "https://registry.npmjs.org/@aws-sdk/types/-/types-3.465.0.tgz", @@ -773,9 +708,9 @@ } }, "node_modules/@aws-sdk/util-locate-window": { - "version": "3.310.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-locate-window/-/util-locate-window-3.310.0.tgz", - "integrity": "sha512-qo2t/vBTnoXpjKxlsC2e1gBrRm80M3bId27r0BRB2VniSSe7bL1mmzM+/HFtujm0iAxtPM+aLEflLJlJeDPg0w==", + "version": "3.465.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-locate-window/-/util-locate-window-3.465.0.tgz", + "integrity": "sha512-f+QNcWGswredzC1ExNAB/QzODlxwaTdXkNT5cvke2RLX8SFU5pYk6h4uCtWC0vWPELzOfMfloBrJefBzlarhsw==", "dependencies": { "tslib": "^2.5.0" }, @@ -825,9 +760,9 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.23.4", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.23.4.tgz", - "integrity": "sha512-r1IONyb6Ia+jYR2vvIDhdWdlTGhqbBoFqLTQidzZ4kepUFH15ejXvFHxCVbtl7BOXIudsIubf4E81xeA3h3IXA==", + "version": "7.23.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.23.5.tgz", + "integrity": "sha512-CgH3s1a96LipHCmSUmYFPwY7MNx8C3avkq7i4Wl3cfa662ldtUe4VM1TPXX70pfmrlWTb6jLqTYrZyT2ZTJBgA==", "dev": true, "dependencies": { "@babel/highlight": "^7.23.4", @@ -1003,9 +938,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.23.4", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.4.tgz", - "integrity": "sha512-vf3Xna6UEprW+7t6EtOmFpHNAuxw3xqPZghy+brsnusscJRW5BMUzzHZc5ICjULee81WeUV2jjakG09MDglJXQ==", + "version": "7.23.6", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.6.tgz", + "integrity": "sha512-Z2uID7YJ7oNvAI20O9X0bblw7Qqs8Q2hFy0R9tAfnfLkp5MW0UH9eUvnDSnFwKZ0AvgS1ucqR4KzvVHgnke1VQ==", "dev": true, "bin": { "parser": "bin/babel-parser.js" @@ -1176,9 +1111,9 @@ } }, "node_modules/@jsdoc/salty": { - "version": "0.2.6", - "resolved": "https://registry.npmjs.org/@jsdoc/salty/-/salty-0.2.6.tgz", - "integrity": "sha512-aA+awb5yoml8TQ3CzI5Ue7sM3VMRC4l1zJJW4fgZ8OCL1wshJZhNzaf0PL85DSnOUw6QuFgeHGD/eq/xwwAF2g==", + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/@jsdoc/salty/-/salty-0.2.7.tgz", + "integrity": "sha512-mh8LbS9d4Jq84KLw8pzho7XC2q2/IJGiJss3xwRoLD1A+EE16SjN4PfaG4jRCzKegTFLlN0Zd8SdUPE6XdoPFg==", "dev": true, "dependencies": { "lodash": "^4.17.21" @@ -1615,11 +1550,11 @@ "dev": true }, "node_modules/@smithy/abort-controller": { - "version": "2.0.14", - "resolved": "https://registry.npmjs.org/@smithy/abort-controller/-/abort-controller-2.0.14.tgz", - "integrity": "sha512-zXtteuYLWbSXnzI3O6xq3FYvigYZFW8mdytGibfarLL2lxHto9L3ILtGVnVGmFZa7SDh62l39EnU5hesLN87Fw==", + "version": "2.0.15", + "resolved": "https://registry.npmjs.org/@smithy/abort-controller/-/abort-controller-2.0.15.tgz", + "integrity": "sha512-JkS36PIS3/UCbq/MaozzV7jECeL+BTt4R75bwY8i+4RASys4xOyUS1HsRyUNSqUXFP4QyCz5aNnh3ltuaxv+pw==", "dependencies": { - "@smithy/types": "^2.6.0", + "@smithy/types": "^2.7.0", "tslib": "^2.5.0" }, "engines": { @@ -1627,14 +1562,14 @@ } }, "node_modules/@smithy/config-resolver": { - "version": "2.0.19", - "resolved": "https://registry.npmjs.org/@smithy/config-resolver/-/config-resolver-2.0.19.tgz", - "integrity": "sha512-JsghnQ5zjWmjEVY8TFOulLdEOCj09SjRLugrHlkPZTIBBm7PQitCFVLThbsKPZQOP7N3ME1DU1nKUc1UaVnBog==", + "version": "2.0.21", + "resolved": "https://registry.npmjs.org/@smithy/config-resolver/-/config-resolver-2.0.21.tgz", + "integrity": "sha512-rlLIGT+BeqjnA6C2FWumPRJS1UW07iU5ZxDHtFuyam4W65gIaOFMjkB90ofKCIh+0mLVQrQFrl/VLtQT/6FWTA==", "dependencies": { - "@smithy/node-config-provider": "^2.1.6", - "@smithy/types": "^2.6.0", + "@smithy/node-config-provider": "^2.1.8", + "@smithy/types": "^2.7.0", "@smithy/util-config-provider": "^2.0.0", - "@smithy/util-middleware": "^2.0.7", + "@smithy/util-middleware": "^2.0.8", "tslib": "^2.5.0" }, "engines": { @@ -1642,14 +1577,14 @@ } }, "node_modules/@smithy/credential-provider-imds": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@smithy/credential-provider-imds/-/credential-provider-imds-2.1.2.tgz", - "integrity": "sha512-Y62jBWdoLPSYjr9fFvJf+KwTa1EunjVr6NryTEWCnwIY93OJxwV4t0qxjwdPl/XMsUkq79ppNJSEQN6Ohnhxjw==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@smithy/credential-provider-imds/-/credential-provider-imds-2.1.4.tgz", + "integrity": "sha512-cwPJN1fa1YOQzhBlTXRavABEYRRchci1X79QRwzaNLySnIMJfztyv1Zkst0iZPLMnpn8+CnHu3wOHS11J5Dr3A==", "dependencies": { - "@smithy/node-config-provider": "^2.1.6", - "@smithy/property-provider": "^2.0.15", - "@smithy/types": "^2.6.0", - "@smithy/url-parser": "^2.0.14", + "@smithy/node-config-provider": "^2.1.8", + "@smithy/property-provider": "^2.0.16", + "@smithy/types": "^2.7.0", + "@smithy/url-parser": "^2.0.15", "tslib": "^2.5.0" }, "engines": { @@ -1657,34 +1592,34 @@ } }, "node_modules/@smithy/eventstream-codec": { - "version": "2.0.14", - "resolved": "https://registry.npmjs.org/@smithy/eventstream-codec/-/eventstream-codec-2.0.14.tgz", - "integrity": "sha512-g/OU/MeWGfHDygoXgMWfG/Xb0QqDnAGcM9t2FRrVAhleXYRddGOEnfanR5cmHgB9ue52MJsyorqFjckzXsylaA==", + "version": "2.0.15", + "resolved": "https://registry.npmjs.org/@smithy/eventstream-codec/-/eventstream-codec-2.0.15.tgz", + "integrity": "sha512-crjvz3j1gGPwA0us6cwS7+5gAn35CTmqu/oIxVbYJo2Qm/sGAye6zGJnMDk3BKhWZw5kcU1G4MxciTkuBpOZPg==", "dependencies": { "@aws-crypto/crc32": "3.0.0", - "@smithy/types": "^2.6.0", + "@smithy/types": "^2.7.0", "@smithy/util-hex-encoding": "^2.0.0", "tslib": "^2.5.0" } }, "node_modules/@smithy/fetch-http-handler": { - "version": "2.2.7", - "resolved": "https://registry.npmjs.org/@smithy/fetch-http-handler/-/fetch-http-handler-2.2.7.tgz", - "integrity": "sha512-iSDBjxuH9TgrtMYAr7j5evjvkvgwLY3y+9D547uep+JNkZ1ZT+BaeU20j6I/bO/i26ilCWFImrlXTPsfQtZdIQ==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@smithy/fetch-http-handler/-/fetch-http-handler-2.3.1.tgz", + "integrity": "sha512-6MNk16fqb8EwcYY8O8WxB3ArFkLZ2XppsSNo1h7SQcFdDDwIumiJeO6wRzm7iB68xvsOQzsdQKbdtTieS3hfSQ==", "dependencies": { - "@smithy/protocol-http": "^3.0.10", - "@smithy/querystring-builder": "^2.0.14", - "@smithy/types": "^2.6.0", + "@smithy/protocol-http": "^3.0.11", + "@smithy/querystring-builder": "^2.0.15", + "@smithy/types": "^2.7.0", "@smithy/util-base64": "^2.0.1", "tslib": "^2.5.0" } }, "node_modules/@smithy/hash-node": { - "version": "2.0.16", - "resolved": "https://registry.npmjs.org/@smithy/hash-node/-/hash-node-2.0.16.tgz", - "integrity": "sha512-Wbi9A0PacMYUOwjAulQP90Wl3mQ6NDwnyrZQzFjDz+UzjXOSyQMgBrTkUBz+pVoYVlX3DUu24gWMZBcit+wOGg==", + "version": "2.0.17", + "resolved": "https://registry.npmjs.org/@smithy/hash-node/-/hash-node-2.0.17.tgz", + "integrity": "sha512-Il6WuBcI1nD+e2DM7tTADMf01wEPGK8PAhz4D+YmDUVaoBqlA+CaH2uDJhiySifmuKBZj748IfygXty81znKhw==", "dependencies": { - "@smithy/types": "^2.6.0", + "@smithy/types": "^2.7.0", "@smithy/util-buffer-from": "^2.0.0", "@smithy/util-utf8": "^2.0.2", "tslib": "^2.5.0" @@ -1694,11 +1629,11 @@ } }, "node_modules/@smithy/invalid-dependency": { - "version": "2.0.14", - "resolved": "https://registry.npmjs.org/@smithy/invalid-dependency/-/invalid-dependency-2.0.14.tgz", - "integrity": "sha512-d8ohpwZo9RzTpGlAfsWtfm1SHBSU7+N4iuZ6MzR10xDTujJJWtmXYHK1uzcr7rggbpUTaWyHpPFgnf91q0EFqQ==", + "version": "2.0.15", + "resolved": "https://registry.npmjs.org/@smithy/invalid-dependency/-/invalid-dependency-2.0.15.tgz", + "integrity": "sha512-dlEKBFFwVfzA5QroHlBS94NpgYjXhwN/bFfun+7w3rgxNvVy79SK0w05iGc7UAeC5t+D7gBxrzdnD6hreZnDVQ==", "dependencies": { - "@smithy/types": "^2.6.0", + "@smithy/types": "^2.7.0", "tslib": "^2.5.0" } }, @@ -1714,12 +1649,12 @@ } }, "node_modules/@smithy/middleware-content-length": { - "version": "2.0.16", - "resolved": "https://registry.npmjs.org/@smithy/middleware-content-length/-/middleware-content-length-2.0.16.tgz", - "integrity": "sha512-9ddDia3pp1d3XzLXKcm7QebGxLq9iwKf+J1LapvlSOhpF8EM9SjMeSrMOOFgG+2TfW5K3+qz4IAJYYm7INYCng==", + "version": "2.0.17", + "resolved": "https://registry.npmjs.org/@smithy/middleware-content-length/-/middleware-content-length-2.0.17.tgz", + "integrity": "sha512-OyadvMcKC7lFXTNBa8/foEv7jOaqshQZkjWS9coEXPRZnNnihU/Ls+8ZuJwGNCOrN2WxXZFmDWhegbnM4vak8w==", "dependencies": { - "@smithy/protocol-http": "^3.0.10", - "@smithy/types": "^2.6.0", + "@smithy/protocol-http": "^3.0.11", + "@smithy/types": "^2.7.0", "tslib": "^2.5.0" }, "engines": { @@ -1727,16 +1662,16 @@ } }, "node_modules/@smithy/middleware-endpoint": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@smithy/middleware-endpoint/-/middleware-endpoint-2.2.1.tgz", - "integrity": "sha512-dVDS7HNJl/wb0lpByXor6whqDbb1YlLoaoWYoelyYzLHioXOE7y/0iDwJWtDcN36/tVCw9EPBFZ3aans84jLpg==", - "dependencies": { - "@smithy/middleware-serde": "^2.0.14", - "@smithy/node-config-provider": "^2.1.6", - "@smithy/shared-ini-file-loader": "^2.2.5", - "@smithy/types": "^2.6.0", - "@smithy/url-parser": "^2.0.14", - "@smithy/util-middleware": "^2.0.7", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/@smithy/middleware-endpoint/-/middleware-endpoint-2.2.3.tgz", + "integrity": "sha512-nYfxuq0S/xoAjdLbyn1ixeVB6cyH9wYCMtbbOCpcCRYR5u2mMtqUtVjjPAZ/DIdlK3qe0tpB0Q76szFGNuz+kQ==", + "dependencies": { + "@smithy/middleware-serde": "^2.0.15", + "@smithy/node-config-provider": "^2.1.8", + "@smithy/shared-ini-file-loader": "^2.2.7", + "@smithy/types": "^2.7.0", + "@smithy/url-parser": "^2.0.15", + "@smithy/util-middleware": "^2.0.8", "tslib": "^2.5.0" }, "engines": { @@ -1744,16 +1679,17 @@ } }, "node_modules/@smithy/middleware-retry": { - "version": "2.0.21", - "resolved": "https://registry.npmjs.org/@smithy/middleware-retry/-/middleware-retry-2.0.21.tgz", - "integrity": "sha512-EZS1EXv1k6IJX6hyu/0yNQuPcPaXwG8SWljQHYueyRbOxmqYgoWMWPtfZj0xRRQ4YtLawQSpBgAeiJltq8/MPw==", - "dependencies": { - "@smithy/node-config-provider": "^2.1.6", - "@smithy/protocol-http": "^3.0.10", - "@smithy/service-error-classification": "^2.0.7", - "@smithy/types": "^2.6.0", - "@smithy/util-middleware": "^2.0.7", - "@smithy/util-retry": "^2.0.7", + "version": "2.0.24", + "resolved": "https://registry.npmjs.org/@smithy/middleware-retry/-/middleware-retry-2.0.24.tgz", + "integrity": "sha512-q2SvHTYu96N7lYrn3VSuX3vRpxXHR/Cig6MJpGWxd0BWodUQUWlKvXpWQZA+lTaFJU7tUvpKhRd4p4MU3PbeJg==", + "dependencies": { + "@smithy/node-config-provider": "^2.1.8", + "@smithy/protocol-http": "^3.0.11", + "@smithy/service-error-classification": "^2.0.8", + "@smithy/smithy-client": "^2.1.18", + "@smithy/types": "^2.7.0", + "@smithy/util-middleware": "^2.0.8", + "@smithy/util-retry": "^2.0.8", "tslib": "^2.5.0", "uuid": "^8.3.2" }, @@ -1770,11 +1706,11 @@ } }, "node_modules/@smithy/middleware-serde": { - "version": "2.0.14", - "resolved": "https://registry.npmjs.org/@smithy/middleware-serde/-/middleware-serde-2.0.14.tgz", - "integrity": "sha512-hFi3FqoYWDntCYA2IGY6gJ6FKjq2gye+1tfxF2HnIJB5uW8y2DhpRNBSUMoqP+qvYzRqZ6ntv4kgbG+o3pX57g==", + "version": "2.0.15", + "resolved": "https://registry.npmjs.org/@smithy/middleware-serde/-/middleware-serde-2.0.15.tgz", + "integrity": "sha512-FOZRFk/zN4AT4wzGuBY+39XWe+ZnCFd0gZtyw3f9Okn2CJPixl9GyWe98TIaljeZdqWkgrzGyPre20AcW2UMHQ==", "dependencies": { - "@smithy/types": "^2.6.0", + "@smithy/types": "^2.7.0", "tslib": "^2.5.0" }, "engines": { @@ -1782,11 +1718,11 @@ } }, "node_modules/@smithy/middleware-stack": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/@smithy/middleware-stack/-/middleware-stack-2.0.8.tgz", - "integrity": "sha512-7/N59j0zWqVEKExJcA14MrLDZ/IeN+d6nbkN8ucs+eURyaDUXWYlZrQmMOd/TyptcQv0+RDlgag/zSTTV62y/Q==", + "version": "2.0.9", + "resolved": "https://registry.npmjs.org/@smithy/middleware-stack/-/middleware-stack-2.0.9.tgz", + "integrity": "sha512-bCB5dUtGQ5wh7QNL2ELxmDc6g7ih7jWU3Kx6MYH1h4mZbv9xL3WyhKHojRltThCB1arLPyTUFDi+x6fB/oabtA==", "dependencies": { - "@smithy/types": "^2.6.0", + "@smithy/types": "^2.7.0", "tslib": "^2.5.0" }, "engines": { @@ -1794,13 +1730,13 @@ } }, "node_modules/@smithy/node-config-provider": { - "version": "2.1.6", - "resolved": "https://registry.npmjs.org/@smithy/node-config-provider/-/node-config-provider-2.1.6.tgz", - "integrity": "sha512-HLqTs6O78m3M3z1cPLFxddxhEPv5MkVatfPuxoVO3A+cHZanNd/H5I6btcdHy6N2CB1MJ/lihJC92h30SESsBA==", + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/@smithy/node-config-provider/-/node-config-provider-2.1.8.tgz", + "integrity": "sha512-+w26OKakaBUGp+UG+dxYZtFb5fs3tgHg3/QrRrmUZj+rl3cIuw840vFUXX35cVPTUCQIiTqmz7CpVF7+hdINdQ==", "dependencies": { - "@smithy/property-provider": "^2.0.15", - "@smithy/shared-ini-file-loader": "^2.2.5", - "@smithy/types": "^2.6.0", + "@smithy/property-provider": "^2.0.16", + "@smithy/shared-ini-file-loader": "^2.2.7", + "@smithy/types": "^2.7.0", "tslib": "^2.5.0" }, "engines": { @@ -1808,14 +1744,14 @@ } }, "node_modules/@smithy/node-http-handler": { - "version": "2.1.10", - "resolved": "https://registry.npmjs.org/@smithy/node-http-handler/-/node-http-handler-2.1.10.tgz", - "integrity": "sha512-lkALAwtN6odygIM4nB8aHDahINM6WXXjNrZmWQAh0RSossySRT2qa31cFv0ZBuAYVWeprskRk13AFvvLmf1WLw==", - "dependencies": { - "@smithy/abort-controller": "^2.0.14", - "@smithy/protocol-http": "^3.0.10", - "@smithy/querystring-builder": "^2.0.14", - "@smithy/types": "^2.6.0", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@smithy/node-http-handler/-/node-http-handler-2.2.1.tgz", + "integrity": "sha512-8iAKQrC8+VFHPAT8pg4/j6hlsTQh+NKOWlctJBrYtQa4ExcxX7aSg3vdQ2XLoYwJotFUurg/NLqFCmZaPRrogw==", + "dependencies": { + "@smithy/abort-controller": "^2.0.15", + "@smithy/protocol-http": "^3.0.11", + "@smithy/querystring-builder": "^2.0.15", + "@smithy/types": "^2.7.0", "tslib": "^2.5.0" }, "engines": { @@ -1823,11 +1759,11 @@ } }, "node_modules/@smithy/property-provider": { - "version": "2.0.15", - "resolved": "https://registry.npmjs.org/@smithy/property-provider/-/property-provider-2.0.15.tgz", - "integrity": "sha512-YbRFBn8oiiC3o1Kn3a4KjGa6k47rCM9++5W9cWqYn9WnkyH+hBWgfJAckuxpyA2Hq6Ys4eFrWzXq6fqHEw7iew==", + "version": "2.0.16", + "resolved": "https://registry.npmjs.org/@smithy/property-provider/-/property-provider-2.0.16.tgz", + "integrity": "sha512-28Ky0LlOqtEjwg5CdHmwwaDRHcTWfPRzkT6HrhwOSRS2RryAvuDfJrZpM+BMcrdeCyEg1mbcgIMoqTla+rdL8Q==", "dependencies": { - "@smithy/types": "^2.6.0", + "@smithy/types": "^2.7.0", "tslib": "^2.5.0" }, "engines": { @@ -1835,11 +1771,11 @@ } }, "node_modules/@smithy/protocol-http": { - "version": "3.0.10", - "resolved": "https://registry.npmjs.org/@smithy/protocol-http/-/protocol-http-3.0.10.tgz", - "integrity": "sha512-6+tjNk7rXW7YTeGo9qwxXj/2BFpJTe37kTj3EnZCoX/nH+NP/WLA7O83fz8XhkGqsaAhLUPo/bB12vvd47nsmg==", + "version": "3.0.11", + "resolved": "https://registry.npmjs.org/@smithy/protocol-http/-/protocol-http-3.0.11.tgz", + "integrity": "sha512-3ziB8fHuXIRamV/akp/sqiWmNPR6X+9SB8Xxnozzj+Nq7hSpyKdFHd1FLpBkgfGFUTzzcBJQlDZPSyxzmdcx5A==", "dependencies": { - "@smithy/types": "^2.6.0", + "@smithy/types": "^2.7.0", "tslib": "^2.5.0" }, "engines": { @@ -1847,11 +1783,11 @@ } }, "node_modules/@smithy/querystring-builder": { - "version": "2.0.14", - "resolved": "https://registry.npmjs.org/@smithy/querystring-builder/-/querystring-builder-2.0.14.tgz", - "integrity": "sha512-lQ4pm9vTv9nIhl5jt6uVMPludr6syE2FyJmHsIJJuOD7QPIJnrf9HhUGf1iHh9KJ4CUv21tpOU3X6s0rB6uJ0g==", + "version": "2.0.15", + "resolved": "https://registry.npmjs.org/@smithy/querystring-builder/-/querystring-builder-2.0.15.tgz", + "integrity": "sha512-e1q85aT6HutvouOdN+dMsN0jcdshp50PSCvxDvo6aIM57LqeXimjfONUEgfqQ4IFpYWAtVixptyIRE5frMp/2A==", "dependencies": { - "@smithy/types": "^2.6.0", + "@smithy/types": "^2.7.0", "@smithy/util-uri-escape": "^2.0.0", "tslib": "^2.5.0" }, @@ -1860,11 +1796,11 @@ } }, "node_modules/@smithy/querystring-parser": { - "version": "2.0.14", - "resolved": "https://registry.npmjs.org/@smithy/querystring-parser/-/querystring-parser-2.0.14.tgz", - "integrity": "sha512-+cbtXWI9tNtQjlgQg3CA+pvL3zKTAxPnG3Pj6MP89CR3vi3QMmD0SOWoq84tqZDnJCxlsusbgIXk1ngMReXo+A==", + "version": "2.0.15", + "resolved": "https://registry.npmjs.org/@smithy/querystring-parser/-/querystring-parser-2.0.15.tgz", + "integrity": "sha512-jbBvoK3cc81Cj1c1TH1qMYxNQKHrYQ2DoTntN9FBbtUWcGhc+T4FP6kCKYwRLXyU4AajwGIZstvNAmIEgUUNTQ==", "dependencies": { - "@smithy/types": "^2.6.0", + "@smithy/types": "^2.7.0", "tslib": "^2.5.0" }, "engines": { @@ -1872,22 +1808,22 @@ } }, "node_modules/@smithy/service-error-classification": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/@smithy/service-error-classification/-/service-error-classification-2.0.7.tgz", - "integrity": "sha512-LLxgW12qGz8doYto15kZ4x1rHjtXl0BnCG6T6Wb8z2DI4PT9cJfOSvzbuLzy7+5I24PAepKgFeWHRd9GYy3Z9w==", + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/@smithy/service-error-classification/-/service-error-classification-2.0.8.tgz", + "integrity": "sha512-jCw9+005im8tsfYvwwSc4TTvd29kXRFkH9peQBg5R/4DD03ieGm6v6Hpv9nIAh98GwgYg1KrztcINC1s4o7/hg==", "dependencies": { - "@smithy/types": "^2.6.0" + "@smithy/types": "^2.7.0" }, "engines": { "node": ">=14.0.0" } }, "node_modules/@smithy/shared-ini-file-loader": { - "version": "2.2.5", - "resolved": "https://registry.npmjs.org/@smithy/shared-ini-file-loader/-/shared-ini-file-loader-2.2.5.tgz", - "integrity": "sha512-LHA68Iu7SmNwfAVe8egmjDCy648/7iJR/fK1UnVw+iAOUJoEYhX2DLgVd5pWllqdDiRbQQzgaHLcRokM+UFR1w==", + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/@smithy/shared-ini-file-loader/-/shared-ini-file-loader-2.2.7.tgz", + "integrity": "sha512-0Qt5CuiogIuvQIfK+be7oVHcPsayLgfLJGkPlbgdbl0lD28nUKu4p11L+UG3SAEsqc9UsazO+nErPXw7+IgDpQ==", "dependencies": { - "@smithy/types": "^2.6.0", + "@smithy/types": "^2.7.0", "tslib": "^2.5.0" }, "engines": { @@ -1895,15 +1831,15 @@ } }, "node_modules/@smithy/signature-v4": { - "version": "2.0.16", - "resolved": "https://registry.npmjs.org/@smithy/signature-v4/-/signature-v4-2.0.16.tgz", - "integrity": "sha512-ilLY85xS2kZZzTb83diQKYLIYALvart0KnBaKnIRnMBHAGEio5aHSlANQoxVn0VsonwmQ3CnWhnCT0sERD8uTg==", + "version": "2.0.18", + "resolved": "https://registry.npmjs.org/@smithy/signature-v4/-/signature-v4-2.0.18.tgz", + "integrity": "sha512-SJRAj9jT/l9ocm8D0GojMbnA1sp7I4JeStOQ4lEXI8A5eHE73vbjlzlqIFB7cLvIgau0oUl4cGVpF9IGCrvjlw==", "dependencies": { - "@smithy/eventstream-codec": "^2.0.14", + "@smithy/eventstream-codec": "^2.0.15", "@smithy/is-array-buffer": "^2.0.0", - "@smithy/types": "^2.6.0", + "@smithy/types": "^2.7.0", "@smithy/util-hex-encoding": "^2.0.0", - "@smithy/util-middleware": "^2.0.7", + "@smithy/util-middleware": "^2.0.8", "@smithy/util-uri-escape": "^2.0.0", "@smithy/util-utf8": "^2.0.2", "tslib": "^2.5.0" @@ -1913,13 +1849,13 @@ } }, "node_modules/@smithy/smithy-client": { - "version": "2.1.16", - "resolved": "https://registry.npmjs.org/@smithy/smithy-client/-/smithy-client-2.1.16.tgz", - "integrity": "sha512-Lw67+yQSpLl4YkDLUzI2KgS8TXclXmbzSeOJUmRFS4ueT56B4pw3RZRF/SRzvgyxM/HxgkUan8oSHXCujPDafQ==", + "version": "2.1.18", + "resolved": "https://registry.npmjs.org/@smithy/smithy-client/-/smithy-client-2.1.18.tgz", + "integrity": "sha512-7FqdbaJiVaHJDD9IfDhmzhSDbpjyx+ZsfdYuOpDJF09rl8qlIAIlZNoSaflKrQ3cEXZN2YxGPaNWGhbYimyIRQ==", "dependencies": { - "@smithy/middleware-stack": "^2.0.8", - "@smithy/types": "^2.6.0", - "@smithy/util-stream": "^2.0.21", + "@smithy/middleware-stack": "^2.0.9", + "@smithy/types": "^2.7.0", + "@smithy/util-stream": "^2.0.23", "tslib": "^2.5.0" }, "engines": { @@ -1927,9 +1863,9 @@ } }, "node_modules/@smithy/types": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/@smithy/types/-/types-2.6.0.tgz", - "integrity": "sha512-PgqxJq2IcdMF9iAasxcqZqqoOXBHufEfmbEUdN1pmJrJltT42b0Sc8UiYSWWzKkciIp9/mZDpzYi4qYG1qqg6g==", + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/@smithy/types/-/types-2.7.0.tgz", + "integrity": "sha512-1OIFyhK+vOkMbu4aN2HZz/MomREkrAC/HqY5mlJMUJfGrPRwijJDTeiN8Rnj9zUaB8ogXAfIOtZrrgqZ4w7Wnw==", "dependencies": { "tslib": "^2.5.0" }, @@ -1938,12 +1874,12 @@ } }, "node_modules/@smithy/url-parser": { - "version": "2.0.14", - "resolved": "https://registry.npmjs.org/@smithy/url-parser/-/url-parser-2.0.14.tgz", - "integrity": "sha512-kbu17Y1AFXi5lNlySdDj7ZzmvupyWKCX/0jNZ8ffquRyGdbDZb+eBh0QnWqsSmnZa/ctyWaTf7n4l/pXLExrnw==", + "version": "2.0.15", + "resolved": "https://registry.npmjs.org/@smithy/url-parser/-/url-parser-2.0.15.tgz", + "integrity": "sha512-sADUncUj9rNbOTrdDGm4EXlUs0eQ9dyEo+V74PJoULY4jSQxS+9gwEgsPYyiu8PUOv16JC/MpHonOgqP/IEDZA==", "dependencies": { - "@smithy/querystring-parser": "^2.0.14", - "@smithy/types": "^2.6.0", + "@smithy/querystring-parser": "^2.0.15", + "@smithy/types": "^2.7.0", "tslib": "^2.5.0" } }, @@ -1960,9 +1896,9 @@ } }, "node_modules/@smithy/util-body-length-browser": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@smithy/util-body-length-browser/-/util-body-length-browser-2.0.0.tgz", - "integrity": "sha512-JdDuS4ircJt+FDnaQj88TzZY3+njZ6O+D3uakS32f2VNnDo3vyEuNdBOh/oFd8Df1zSZOuH1HEChk2AOYDezZg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@smithy/util-body-length-browser/-/util-body-length-browser-2.0.1.tgz", + "integrity": "sha512-NXYp3ttgUlwkaug4bjBzJ5+yIbUbUx8VsSLuHZROQpoik+gRkIBeEG9MPVYfvPNpuXb/puqodeeUXcKFe7BLOQ==", "dependencies": { "tslib": "^2.5.0" } @@ -2002,13 +1938,13 @@ } }, "node_modules/@smithy/util-defaults-mode-browser": { - "version": "2.0.20", - "resolved": "https://registry.npmjs.org/@smithy/util-defaults-mode-browser/-/util-defaults-mode-browser-2.0.20.tgz", - "integrity": "sha512-QJtnbTIl0/BbEASkx1MUFf6EaoWqWW1/IM90N++8NNscePvPf77GheYfpoPis6CBQawUWq8QepTP2QUSAdrVkw==", + "version": "2.0.22", + "resolved": "https://registry.npmjs.org/@smithy/util-defaults-mode-browser/-/util-defaults-mode-browser-2.0.22.tgz", + "integrity": "sha512-qcF20IHHH96FlktvBRICDXDhLPtpVmtksHmqNGtotb9B0DYWXsC6jWXrkhrrwF7tH26nj+npVTqh9isiFV1gdA==", "dependencies": { - "@smithy/property-provider": "^2.0.15", - "@smithy/smithy-client": "^2.1.16", - "@smithy/types": "^2.6.0", + "@smithy/property-provider": "^2.0.16", + "@smithy/smithy-client": "^2.1.18", + "@smithy/types": "^2.7.0", "bowser": "^2.11.0", "tslib": "^2.5.0" }, @@ -2017,16 +1953,16 @@ } }, "node_modules/@smithy/util-defaults-mode-node": { - "version": "2.0.26", - "resolved": "https://registry.npmjs.org/@smithy/util-defaults-mode-node/-/util-defaults-mode-node-2.0.26.tgz", - "integrity": "sha512-lGFPOFCHv1ql019oegYqa54BZH7HREw6EBqjDLbAr0wquMX0BDi2sg8TJ6Eq+JGLijkZbJB73m4+aK8OFAapMg==", - "dependencies": { - "@smithy/config-resolver": "^2.0.19", - "@smithy/credential-provider-imds": "^2.1.2", - "@smithy/node-config-provider": "^2.1.6", - "@smithy/property-provider": "^2.0.15", - "@smithy/smithy-client": "^2.1.16", - "@smithy/types": "^2.6.0", + "version": "2.0.29", + "resolved": "https://registry.npmjs.org/@smithy/util-defaults-mode-node/-/util-defaults-mode-node-2.0.29.tgz", + "integrity": "sha512-+uG/15VoUh6JV2fdY9CM++vnSuMQ1VKZ6BdnkUM7R++C/vLjnlg+ToiSR1FqKZbMmKBXmsr8c/TsDWMAYvxbxQ==", + "dependencies": { + "@smithy/config-resolver": "^2.0.21", + "@smithy/credential-provider-imds": "^2.1.4", + "@smithy/node-config-provider": "^2.1.8", + "@smithy/property-provider": "^2.0.16", + "@smithy/smithy-client": "^2.1.18", + "@smithy/types": "^2.7.0", "tslib": "^2.5.0" }, "engines": { @@ -2034,12 +1970,12 @@ } }, "node_modules/@smithy/util-endpoints": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@smithy/util-endpoints/-/util-endpoints-1.0.5.tgz", - "integrity": "sha512-K7qNuCOD5K/90MjHvHm9kJldrfm40UxWYQxNEShMFxV/lCCCRIg8R4uu1PFAxRvPxNpIdcrh1uK6I1ISjDXZJw==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/@smithy/util-endpoints/-/util-endpoints-1.0.7.tgz", + "integrity": "sha512-Q2gEind3jxoLk6hdKWyESMU7LnXz8aamVwM+VeVjOYzYT1PalGlY/ETa48hv2YpV4+YV604y93YngyzzzQ4IIA==", "dependencies": { - "@smithy/node-config-provider": "^2.1.6", - "@smithy/types": "^2.6.0", + "@smithy/node-config-provider": "^2.1.8", + "@smithy/types": "^2.7.0", "tslib": "^2.5.0" }, "engines": { @@ -2058,11 +1994,11 @@ } }, "node_modules/@smithy/util-middleware": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/@smithy/util-middleware/-/util-middleware-2.0.7.tgz", - "integrity": "sha512-tRINOTlf1G9B0ECarFQAtTgMhpnrMPSa+5j4ZEwEawCLfTFTavk6757sxhE4RY5RMlD/I3x+DCS8ZUiR8ho9Pw==", + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/@smithy/util-middleware/-/util-middleware-2.0.8.tgz", + "integrity": "sha512-qkvqQjM8fRGGA8P2ydWylMhenCDP8VlkPn8kiNuFEaFz9xnUKC2irfqsBSJrfrOB9Qt6pQsI58r3zvvumhFMkw==", "dependencies": { - "@smithy/types": "^2.6.0", + "@smithy/types": "^2.7.0", "tslib": "^2.5.0" }, "engines": { @@ -2070,12 +2006,12 @@ } }, "node_modules/@smithy/util-retry": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/@smithy/util-retry/-/util-retry-2.0.7.tgz", - "integrity": "sha512-fIe5yARaF0+xVT1XKcrdnHKTJ1Vc4+3e3tLDjCuIcE9b6fkBzzGFY7AFiX4M+vj6yM98DrwkuZeHf7/hmtVp0Q==", + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/@smithy/util-retry/-/util-retry-2.0.8.tgz", + "integrity": "sha512-cQTPnVaVFMjjS6cb44WV2yXtHVyXDC5icKyIbejMarJEApYeJWpBU3LINTxHqp/tyLI+MZOUdosr2mZ3sdziNg==", "dependencies": { - "@smithy/service-error-classification": "^2.0.7", - "@smithy/types": "^2.6.0", + "@smithy/service-error-classification": "^2.0.8", + "@smithy/types": "^2.7.0", "tslib": "^2.5.0" }, "engines": { @@ -2083,13 +2019,13 @@ } }, "node_modules/@smithy/util-stream": { - "version": "2.0.21", - "resolved": "https://registry.npmjs.org/@smithy/util-stream/-/util-stream-2.0.21.tgz", - "integrity": "sha512-0BUE16d7n1x7pi1YluXJdB33jOTyBChT0j/BlOkFa9uxfg6YqXieHxjHNuCdJRARa7AZEj32LLLEPJ1fSa4inA==", + "version": "2.0.23", + "resolved": "https://registry.npmjs.org/@smithy/util-stream/-/util-stream-2.0.23.tgz", + "integrity": "sha512-OJMWq99LAZJUzUwTk+00plyxX3ESktBaGPhqNIEVab+53gLULiWN9B/8bRABLg0K6R6Xg4t80uRdhk3B/LZqMQ==", "dependencies": { - "@smithy/fetch-http-handler": "^2.2.7", - "@smithy/node-http-handler": "^2.1.10", - "@smithy/types": "^2.6.0", + "@smithy/fetch-http-handler": "^2.3.1", + "@smithy/node-http-handler": "^2.2.1", + "@smithy/types": "^2.7.0", "@smithy/util-base64": "^2.0.1", "@smithy/util-buffer-from": "^2.0.0", "@smithy/util-hex-encoding": "^2.0.0", @@ -2124,12 +2060,12 @@ } }, "node_modules/@smithy/util-waiter": { - "version": "2.0.14", - "resolved": "https://registry.npmjs.org/@smithy/util-waiter/-/util-waiter-2.0.14.tgz", - "integrity": "sha512-Q6gSz4GUNjNGhrfNg+2Mjy+7K4pEI3r82x1b/+3dSc03MQqobMiUrRVN/YK/4nHVagvBELCoXsiHAFQJNQ5BeA==", + "version": "2.0.15", + "resolved": "https://registry.npmjs.org/@smithy/util-waiter/-/util-waiter-2.0.15.tgz", + "integrity": "sha512-9Y+btzzB7MhLADW7xgD6SjvmoYaRkrb/9SCbNGmNdfO47v38rxb90IGXyDtAK0Shl9bMthTmLgjlfYc+vtz2Qw==", "dependencies": { - "@smithy/abort-controller": "^2.0.14", - "@smithy/types": "^2.6.0", + "@smithy/abort-controller": "^2.0.15", + "@smithy/types": "^2.7.0", "tslib": "^2.5.0" }, "engines": { @@ -4755,9 +4691,9 @@ } }, "node_modules/globals": { - "version": "13.23.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.23.0.tgz", - "integrity": "sha512-XAmF0RjlrjY23MA51q3HltdlGxUpXPvg0GioKiD9X6HD28iMjo2dKC8Vqwm7lne4GNr78+RHTfliktR6ZH09wA==", + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", "dev": true, "dependencies": { "type-fest": "^0.20.2" @@ -9543,13 +9479,13 @@ } }, "node_modules/object.assign": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.4.tgz", - "integrity": "sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==", + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.5.tgz", + "integrity": "sha512-byy+U7gp+FVwmyzKPYhW2h5l3crpmGsxl7X2s8y43IgxvG4g3QZ6CffDtsNQy1WsmZpQbO+ybo0AlW7TY6DcBQ==", "dev": true, "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", + "call-bind": "^1.0.5", + "define-properties": "^1.2.1", "has-symbols": "^1.0.3", "object-keys": "^1.1.1" }, @@ -11169,6 +11105,16 @@ "url": "https://opencollective.com/sinon" } }, + "node_modules/sinon-chai": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-3.7.0.tgz", + "integrity": "sha512-mf5NURdUaSdnatJx3uhoBOrY9dtL19fiOtAdT1Azxg3+lNJFiuN0uzaU3xX1LeAfL17kHQhTAJgpsfhbMJMY2g==", + "dev": true, + "peerDependencies": { + "chai": "^4.0.0", + "sinon": ">=4.0.0" + } + }, "node_modules/sinon/node_modules/diff": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/diff/-/diff-5.1.0.tgz", @@ -12374,7 +12320,7 @@ }, "packages/spacecat-shared-data-access": { "name": "@adobe/spacecat-shared-data-access", - "version": "1.1.2", + "version": "1.2.7", "license": "Apache-2.0", "dependencies": { "@adobe/spacecat-shared-dynamo": "1.2.4", @@ -12390,6 +12336,10 @@ "sinon": "17.0.1" } }, + "packages/spacecat-shared-data-access/node_modules/@adobe/spacecat-shared-utils": { + "version": "1.2.0", + "license": "Apache-2.0" + }, "packages/spacecat-shared-dynamo": { "name": "@adobe/spacecat-shared-dynamo", "version": "1.2.4", @@ -12405,8 +12355,7 @@ }, "packages/spacecat-shared-dynamo/node_modules/@adobe/spacecat-shared-utils": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@adobe/spacecat-shared-utils/-/spacecat-shared-utils-1.1.0.tgz", - "integrity": "sha512-yq6o47d6IuMApgvlGWdIfUOkqYNwcEm4IzO5WHnrTpWXPK4vvssfAfFtoeki7NQ+A4nFoc7/esqOfX42Q452nA==" + "license": "Apache-2.0" }, "packages/spacecat-shared-example": { "name": "@adobe/spacecat-shared-example", @@ -12420,9 +12369,29 @@ }, "devDependencies": {} }, + "packages/spacecat-shared-rum-api-client": { + "name": "@adobe/spacecat-shared-rum-api-client", + "version": "1.1.0", + "license": "Apache-2.0", + "dependencies": { + "@adobe/fetch": "4.1.1", + "@adobe/helix-shared-wrap": "2.0.0", + "@adobe/helix-universal": "4.4.1", + "@adobe/spacecat-shared-utils": "1.3.0", + "aws4": "1.12.0" + }, + "devDependencies": { + "chai": "4.3.10", + "chai-as-promised": "7.1.1", + "nock": "13.4.0", + "sinon": "17.0.1", + "sinon-chai": "3.7.0", + "typescript": "5.3.2" + } + }, "packages/spacecat-shared-utils": { "name": "@adobe/spacecat-shared-utils", - "version": "1.2.0", + "version": "1.3.0", "license": "Apache-2.0", "devDependencies": { "chai": "4.3.10" diff --git a/packages/spacecat-shared-rum-api-client/.jsdoc.json b/packages/spacecat-shared-rum-api-client/.jsdoc.json new file mode 100644 index 000000000..405090f4b --- /dev/null +++ b/packages/spacecat-shared-rum-api-client/.jsdoc.json @@ -0,0 +1,17 @@ +{ + "plugins": [], + "recurseDepth": 10, + "source": { + "includePattern": ".+\\.js(doc|x)?$", + "excludePattern": "(^|\\/|\\\\)_" + }, + "sourceType": "module", + "tags": { + "allowUnknownTags": true, + "dictionaries": ["jsdoc","closure"] + }, + "templates": { + "cleverLinks": false, + "monospaceLinks": false + } +} \ No newline at end of file diff --git a/packages/spacecat-shared-rum-api-client/.mocha-multi.json b/packages/spacecat-shared-rum-api-client/.mocha-multi.json new file mode 100644 index 000000000..aa2be2a23 --- /dev/null +++ b/packages/spacecat-shared-rum-api-client/.mocha-multi.json @@ -0,0 +1,6 @@ +{ + "reporterEnabled": "spec,xunit", + "xunitReporterOptions": { + "output": "junit/test-results.xml" + } +} diff --git a/packages/spacecat-shared-rum-api-client/.npmignore b/packages/spacecat-shared-rum-api-client/.npmignore new file mode 100644 index 000000000..868317d21 --- /dev/null +++ b/packages/spacecat-shared-rum-api-client/.npmignore @@ -0,0 +1,9 @@ +coverage/ +node_modules/ +junit/ +test/ +docs/ +logs/ +test-results.xml +renovate.json +.* diff --git a/packages/spacecat-shared-rum-api-client/.nycrc.json b/packages/spacecat-shared-rum-api-client/.nycrc.json new file mode 100644 index 000000000..78e7a0b14 --- /dev/null +++ b/packages/spacecat-shared-rum-api-client/.nycrc.json @@ -0,0 +1,10 @@ +{ + "reporter": [ + "lcov", + "text" + ], + "check-coverage": true, + "lines": 100, + "branches": 97, + "statements": 100 +} diff --git a/packages/spacecat-shared-rum-api-client/CHANGELOG.md b/packages/spacecat-shared-rum-api-client/CHANGELOG.md new file mode 100644 index 000000000..152148743 --- /dev/null +++ b/packages/spacecat-shared-rum-api-client/CHANGELOG.md @@ -0,0 +1,25 @@ +# [@adobe/spacecat-shared-example-v1.1.0](https://github.com/adobe-rnd/spacecat-shared/compare/@adobe/spacecat-shared-example-v1.0.0...@adobe/spacecat-shared-example-v1.1.0) (2023-11-29) + + +### Features + +* add guards and use spacecat-shared-utils ([#6](https://github.com/adobe-rnd/spacecat-shared/issues/6)) ([27143cf](https://github.com/adobe-rnd/spacecat-shared/commit/27143cf2d4a439f1b5904e62756e59e501b3f67d)) + +# @adobe/spacecat-shared-example-v1.0.0 (2023-11-27) + + +### Bug Fixes + +* bogus change to force release ([e77e830](https://github.com/adobe-rnd/spacecat-shared/commit/e77e8305c96ac2504aeb22af44d45cb4acbcae56)) +* package name to "adobe" ([475434e](https://github.com/adobe-rnd/spacecat-shared/commit/475434e6619c2128ba1a8308a4eed23cf3d40691)) +* remove unneeded import (force release) ([49964f9](https://github.com/adobe-rnd/spacecat-shared/commit/49964f99906d5a0fafeb68b460cb19f98a51fc86)) +* repo reference ([881487d](https://github.com/adobe-rnd/spacecat-shared/commit/881487dce4c840ac2bf02a285f17cac511d39c88)) +* roll-back esm monorepo ([ab77518](https://github.com/adobe-rnd/spacecat-shared/commit/ab775187dc79a7f2cdb0ca4fa31198202be78143)) +* set package version to semantic, remove dev deps ([bf62c5f](https://github.com/adobe-rnd/spacecat-shared/commit/bf62c5fe013dbbb7425eb21cffa23e7f01322aee)) +* set to semantic-release versioning ([9209799](https://github.com/adobe-rnd/spacecat-shared/commit/92097995b657207996dd6a35277fdfcd3f3e8fb9)) +* variouss ([ea9d44f](https://github.com/adobe-rnd/spacecat-shared/commit/ea9d44f6071c1a53d2c31515966e7cdf44be7ae9)) + + +### Features + +* test ([bd3cc5d](https://github.com/adobe-rnd/spacecat-shared/commit/bd3cc5df89ccde75b86b000e8495893f4b099b5b)) diff --git a/packages/spacecat-shared-rum-api-client/LICENSE.txt b/packages/spacecat-shared-rum-api-client/LICENSE.txt new file mode 100644 index 000000000..883ab098f --- /dev/null +++ b/packages/spacecat-shared-rum-api-client/LICENSE.txt @@ -0,0 +1,264 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +APACHE JACKRABBIT SUBCOMPONENTS + +Apache Jackrabbit includes parts with separate copyright notices and license +terms. Your use of these subcomponents is subject to the terms and conditions +of the following licenses: + + XPath 2.0/XQuery 1.0 Parser: + http://www.w3.org/2002/11/xquery-xpath-applets/xgrammar.zip + + Copyright (C) 2002 World Wide Web Consortium, (Massachusetts Institute of + Technology, European Research Consortium for Informatics and Mathematics, + Keio University). All Rights Reserved. + + This work is distributed under the W3C(R) Software License in the hope + that it will be useful, but WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + W3C(R) SOFTWARE NOTICE AND LICENSE + http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 + + This work (and included software, documentation such as READMEs, or + other related items) is being provided by the copyright holders under + the following license. By obtaining, using and/or copying this work, + you (the licensee) agree that you have read, understood, and will comply + with the following terms and conditions. + + Permission to copy, modify, and distribute this software and its + documentation, with or without modification, for any purpose and + without fee or royalty is hereby granted, provided that you include + the following on ALL copies of the software and documentation or + portions thereof, including modifications: + + 1. The full text of this NOTICE in a location viewable to users + of the redistributed or derivative work. + + 2. Any pre-existing intellectual property disclaimers, notices, + or terms and conditions. If none exist, the W3C Software Short + Notice should be included (hypertext is preferred, text is + permitted) within the body of any redistributed or derivative code. + + 3. Notice of any changes or modifications to the files, including + the date changes were made. (We recommend you provide URIs to the + location from which the code is derived.) + + THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT + HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, + INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS + FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR + DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, + TRADEMARKS OR OTHER RIGHTS. + + COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL + OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR + DOCUMENTATION. + + The name and trademarks of copyright holders may NOT be used in + advertising or publicity pertaining to the software without specific, + written prior permission. Title to copyright in this software and + any associated documentation will at all times remain with + copyright holders. diff --git a/packages/spacecat-shared-rum-api-client/README.md b/packages/spacecat-shared-rum-api-client/README.md new file mode 100644 index 000000000..91445677c --- /dev/null +++ b/packages/spacecat-shared-rum-api-client/README.md @@ -0,0 +1,16 @@ +# Spacecat Shared - Example Wrapper + +When writing universal serverless functions with Helix Universal, then `spacecat-shared-example` will wrap your function +to print a hello world. + +## Usage + +```js +import wrap from '@adobe/helix-shared-wrap'; +import example from '@adobe/spacecat-shared-example'; + +... + +export const main = wrap(run) + .with(example); +``` diff --git a/packages/spacecat-shared-rum-api-client/package.json b/packages/spacecat-shared-rum-api-client/package.json new file mode 100644 index 000000000..131e171b8 --- /dev/null +++ b/packages/spacecat-shared-rum-api-client/package.json @@ -0,0 +1,47 @@ +{ + "name": "@adobe/spacecat-shared-rum-api-client", + "version": "1.1.0", + "description": "Shared modules of the Spacecat Services - Rum API client", + "type": "module", + "main": "src/index.js", + "types": "src/index.d.ts", + "scripts": { + "test": "c8 mocha", + "lint": "eslint .", + "clean": "rm -rf package-lock.json node_modules" + }, + "mocha": { + "require": "test/setup-env.js", + "reporter": "mocha-multi-reporters", + "reporter-options": "configFile=.mocha-multi.json", + "spec": "test/*.test.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/adobe-rnd/spacecat-shared.git" + }, + "author": "", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/adobe-rnd/spacecat-shared/issues" + }, + "homepage": "https://github.com/adobe-rnd/spacecat-shared#readme", + "publishConfig": { + "access": "public" + }, + "dependencies": { + "@adobe/fetch": "4.1.1", + "@adobe/helix-shared-wrap": "2.0.0", + "@adobe/helix-universal": "4.4.1", + "@adobe/spacecat-shared-utils": "1.3.0", + "aws4": "1.12.0" + }, + "devDependencies": { + "chai": "4.3.10", + "chai-as-promised": "7.1.1", + "nock": "13.4.0", + "sinon": "17.0.1", + "sinon-chai": "3.7.0", + "typescript": "5.3.2" + } +} diff --git a/packages/spacecat-shared-rum-api-client/src/index.d.ts b/packages/spacecat-shared-rum-api-client/src/index.d.ts new file mode 100644 index 000000000..6a5b306ab --- /dev/null +++ b/packages/spacecat-shared-rum-api-client/src/index.d.ts @@ -0,0 +1,43 @@ +/* + * Copyright 2023 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + +import { UniversalContext } from '@adobe/helix-universal'; + +export declare class RUMAPIClient { + /** + * Static factory method to create an instance of RUMAPIClient. + * @param {UniversalContext} context - An object containing the AWS Lambda context information + * @returns An instance of RUMAPIClient. + * @remarks This method is designed to create a new instance from an AWS Lambda context. + * The created instance is stored in the Lambda context, and subsequent calls to + * this method will return the singleton instance if previously created. + */ + static createFrom(context: UniversalContext): RUMAPIClient; + + /** + * Constructor for creating an instance of RUMAPIClient. + * @param {string} domainkey - A string parameter representing the domain key of the RUM API. + * This key is used to authenticate and interact with the RUM API. + * @remarks The domain key is specific to the RUM API. + */ + constructor(domainkey: string); + + /** + * Asynchronous method to create a backlink. + * @param {string} url - A string representing the URL for the backlink. + * @param {number} expiry - An integer representing the expiry value for the backlink. + * @returns A Promise resolving to a string representing url of the created backlink. + * @remarks This method creates a backlink to the RUM dashboard, allowing users + * to view their reports and monitor real user activities. + */ + createBacklink(url: string, expiry: number): Promise; +} diff --git a/packages/spacecat-shared-rum-api-client/src/index.js b/packages/spacecat-shared-rum-api-client/src/index.js new file mode 100644 index 000000000..1021a554a --- /dev/null +++ b/packages/spacecat-shared-rum-api-client/src/index.js @@ -0,0 +1,97 @@ +/* + * Copyright 2023 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +import { createUrl } from '@adobe/fetch'; +import { hasText, isArray, isInteger } from '@adobe/spacecat-shared-utils'; +import { dateAfterDays, fetch } from './utils.js'; + +const APIS = { + ROTATE_DOMAINKEYS: 'https://helix-pages.anywhere.run/helix-services/run-query@v3/rotate-domainkeys', + RUM_DASHBOARD: 'https://main--franklin-dashboard--adobe.hlx.live/views/rum-dashboard', +}; + +export async function sendRequest(url, opts) { + let respJson; + try { + const resp = await fetch(url, opts); + // const resp = await (isObject(opts) ? fetch(url, opts) : fetch(url)); + respJson = await resp.json(); + } catch (e) { + throw new Error(`Error during rum api call: ${e.message}`); + } + + const data = respJson?.results?.data; + if (!isArray(data)) { + throw new Error('Unexpected response from rum api. $.results.data is not array'); + } + + return data; +} + +async function generateDomainKey(domainkey, url, expiry) { + if (!hasText(url) || !isInteger(expiry)) { + throw new Error('Invalid input: url and expiry date parameters are required'); + } + + const params = { + domainkey, + url, + expiry: dateAfterDays(expiry).toISOString(), + note: 'generated by spacecat alerting', + }; + + const data = await sendRequest(createUrl(APIS.ROTATE_DOMAINKEYS, params), { method: 'POST' }); + + if (data.length === 0) { + throw new Error('Unexpected response: Rum api returned empty result'); + } + + if (data[0].status !== 'success') { + throw new Error('Unexpected response: Response was not successful'); + } + + if (!hasText(data[0].key)) { + throw new Error('Unexpected response: Rum api returned null domain key'); + } + + return data[0].key; +} + +/** + * + * @param context + * @returns RUMAPIClient + * @constructor + */ +export default class RUMAPIClient { + static createFrom(context) { + if (context.rumApiClient) return context.rumApiClient; + + const { RUM_API_KEY: domainkey } = context.env; + + const client = new RUMAPIClient(domainkey); + context.rumApiClient = client; + return client; + } + + constructor(domainkey) { + if (!hasText(domainkey)) { + throw Error('RUM API Client needs a domain key to be set'); + } + + this.domainkey = domainkey; + } + + async createBacklink(url, expiry) { + const scopedDomainKey = await generateDomainKey(this.domainkey, url, expiry); + return `${APIS.RUM_DASHBOARD}?interval=${expiry}&offset=0&limit=100&url=${url}&domainkey=${scopedDomainKey}`; + } +} diff --git a/packages/spacecat-shared-rum-api-client/src/utils.js b/packages/spacecat-shared-rum-api-client/src/utils.js new file mode 100644 index 000000000..cab523cf3 --- /dev/null +++ b/packages/spacecat-shared-rum-api-client/src/utils.js @@ -0,0 +1,24 @@ +/* + * Copyright 2023 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + +import { context as h2, h1 } from '@adobe/fetch'; + +/* c8 ignore next 3 */ +export const { fetch } = process.env.HELIX_FETCH_FORCE_HTTP1 + ? h1() + : h2(); + +export function dateAfterDays(days) { + const currentDate = new Date(); + currentDate.setDate(currentDate.getDate() + days); + return currentDate; +} diff --git a/packages/spacecat-shared-rum-api-client/test/create-backlink.test.js b/packages/spacecat-shared-rum-api-client/test/create-backlink.test.js new file mode 100644 index 000000000..5f2bddc82 --- /dev/null +++ b/packages/spacecat-shared-rum-api-client/test/create-backlink.test.js @@ -0,0 +1,116 @@ +/* + * Copyright 2023 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +/* eslint-env mocha */ +/* eslint-disable no-unused-expressions */ // expect statements + +import sinon from 'sinon'; +import chai from 'chai'; +import chaiAsPromised from 'chai-as-promised'; +import nock from 'nock'; +import RUMAPIClient from '../src/index.js'; +import { + emptyResponse, nullKeyResponse, successKeyResponse, wrongKeyResponse, +} from './rumapi-data.js'; + +chai.use(chaiAsPromised); +const { expect } = chai; + +const sandbox = sinon.createSandbox(); +const mockDate = '2023-11-27T12:30:01.124Z'; +const sevenDaysLater = '2023-12-04T12:30:01.124Z'; + +describe('backlink creation', () => { + const context = { + env: { + RUM_API_KEY: 'domain-key', + }, + }; + const finalUrl = 'www.space.cat'; + const params = { + domainkey: context.env.RUM_API_KEY, + url: finalUrl, + expiry: sevenDaysLater, + note: 'generated by spacecat alerting', + }; + + before('setup', function () { + this.clock = sandbox.useFakeTimers({ + now: new Date(mockDate).getTime(), + }); + }); + + after('clean', () => { + sandbox.restore(); + }); + + afterEach('clean each', () => { + nock.cleanAll(); + }); + + it('rejects when required params not provided', async () => { + const client = RUMAPIClient.createFrom(context); + + await expect(client.createBacklink()) + .to.be.rejectedWith('Invalid input: url and expiry date parameters are required'); + await expect(client.createBacklink('url')) + .to.be.rejectedWith('Invalid input: url and expiry date parameters are required'); + }); + + it('rejects when rum api returns empty repsonse', async () => { + const client = RUMAPIClient.createFrom(context); + + nock('https://helix-pages.anywhere.run') + .post('/helix-services/run-query@v3/rotate-domainkeys') + .query(params) + .reply(200, emptyResponse); + + await expect(client.createBacklink(finalUrl, 7)) + .to.be.rejectedWith('Unexpected response: Rum api returned empty result'); + }); + + it('rejects when rum api returns unsuccessful repsonse', async () => { + const client = RUMAPIClient.createFrom(context); + + nock('https://helix-pages.anywhere.run') + .post('/helix-services/run-query@v3/rotate-domainkeys') + .query(params) + .reply(200, wrongKeyResponse); + + await expect(client.createBacklink(finalUrl, 7)) + .to.be.rejectedWith('Unexpected response: Response was not successful'); + }); + + it('rejects when rum api returns null key', async () => { + const client = RUMAPIClient.createFrom(context); + + nock('https://helix-pages.anywhere.run') + .post('/helix-services/run-query@v3/rotate-domainkeys') + .query(params) + .reply(200, nullKeyResponse); + + await expect(client.createBacklink(finalUrl, 7)) + .to.be.rejectedWith('Rum api returned null domain key'); + }); + + it('returns scoped domain key when successful', async () => { + const client = RUMAPIClient.createFrom(context); + const expectedBacklink = 'https://main--franklin-dashboard--adobe.hlx.live/views/rum-dashboard?interval=7&offset=0&limit=100&url=www.space.cat&domainkey=scoped-domain-key'; + + nock('https://helix-pages.anywhere.run') + .post('/helix-services/run-query@v3/rotate-domainkeys') + .query(params) + .reply(200, successKeyResponse); + + const backlink = await client.createBacklink(finalUrl, 7); + expect(backlink).to.equal(expectedBacklink); + }); +}); diff --git a/packages/spacecat-shared-rum-api-client/test/rum-api-client.test.js b/packages/spacecat-shared-rum-api-client/test/rum-api-client.test.js new file mode 100644 index 000000000..2f54a2f69 --- /dev/null +++ b/packages/spacecat-shared-rum-api-client/test/rum-api-client.test.js @@ -0,0 +1,61 @@ +/* + * Copyright 2023 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +/* eslint-env mocha */ +import chai from 'chai'; +import chaiAsPromised from 'chai-as-promised'; +import nock from 'nock'; +import RUMAPIClient, { sendRequest } from '../src/index.js'; + +chai.use(chaiAsPromised); +const { expect } = chai; + +describe('rum api client', () => { + afterEach('clean each', () => { + nock.cleanAll(); + }); + + it('does not create a new instance if previously initialized', async () => { + const rumApiClient = RUMAPIClient.createFrom({ rumApiClient: 'hebele', env: {} }); + expect(rumApiClient).to.equal('hebele'); + }); + + it('rejects no domain key set', async () => { + expect(() => RUMAPIClient.createFrom({ env: {} })).to.throw('RUM API Client needs a domain key to be set'); + }); + + it('rejects when rum api returns 500', async () => { + nock('https://space.cat') + .get('/dummy-page') + .reply(500); + + await expect(sendRequest('https://space.cat/dummy-page')).to.be.rejectedWith('Error during rum api call: Unexpected end of JSON input'); + }); + + it('rejects when rum api returns invalid json', async () => { + nock('https://space.cat') + .get('/dummy-page') + .query(true) + .reply(200, 'invalid-json'); + + await expect(sendRequest('https://space.cat/dummy-page')).to.be.rejectedWith('Error during rum api call: Unexpected token i in JSON at position 0'); + }); + + it('rejects when rum api returns unexpected format', async () => { + nock('https://space.cat') + .get('/dummy-page') + .query(true) + .reply(200, '{ "key": "value" }'); + + await expect(sendRequest('https://space.cat/dummy-page')) + .to.be.rejectedWith('Unexpected response from rum api. $.results.data is not array'); + }); +}); diff --git a/packages/spacecat-shared-rum-api-client/test/rumapi-data.js b/packages/spacecat-shared-rum-api-client/test/rumapi-data.js new file mode 100644 index 000000000..d176f5cf2 --- /dev/null +++ b/packages/spacecat-shared-rum-api-client/test/rumapi-data.js @@ -0,0 +1,92 @@ +/* + * Copyright 2023 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + +export const emptyResponse = { + ':names': ['results', 'meta'], + ':type': 'multi-sheet', + ':version': 3, + results: { + limit: 1, + offset: 0, + total: 0, + data: [], + columns: ['key', 'hostname_prefix', 'status', 'revoke_date'], + }, + meta: { + limit: 9, offset: 0, total: 9, columns: ['name', 'value', 'type'], data: [{ name: 'description', value: 'Rotate domain keys', type: 'query description' }, { name: 'timezone', value: 'UTC', type: 'request parameter' }, { name: 'url', value: '-', type: 'request parameter' }, { name: 'newkey', value: '-', type: 'request parameter' }, { name: 'graceperiod', value: '-1', type: 'request parameter' }, { name: 'expiry', value: '-', type: 'request parameter' }, { name: 'readonly', value: true, type: 'request parameter' }, { name: 'note', value: '-', type: 'request parameter' }, { name: 'limit', value: null, type: 'request parameter' }], + }, +}; +export const nullKeyResponse = { + ':names': ['results', 'meta'], + ':type': 'multi-sheet', + ':version': 3, + results: { + limit: 1, + offset: 0, + total: 1, + data: [ + { + key: null, + hostname_prefix: 'www.adobe.com', + status: 'success', + revoke_date: '2023-11-29T12:22:00.340Z', + }, + ], + columns: ['key', 'hostname_prefix', 'status', 'revoke_date'], + }, + meta: { + limit: 9, offset: 0, total: 9, columns: ['name', 'value', 'type'], data: [{ name: 'description', value: 'Rotate domain keys', type: 'query description' }, { name: 'timezone', value: 'UTC', type: 'request parameter' }, { name: 'url', value: 'www.adobe.com', type: 'request parameter' }, { name: 'newkey', value: '-', type: 'request parameter' }, { name: 'graceperiod', value: '-1', type: 'request parameter' }, { name: 'expiry', value: '2023-11-29T12:22:00.340Z', type: 'request parameter' }, { name: 'readonly', value: true, type: 'request parameter' }, { name: 'note', value: 'spacecat on the fly test', type: 'request parameter' }, { name: 'limit', value: null, type: 'request parameter' }], + }, +}; +export const wrongKeyResponse = { + ':names': ['results', 'meta'], + ':type': 'multi-sheet', + ':version': 3, + results: { + limit: 1, + offset: 0, + total: 1, + data: [{ + key: null, + hostname_prefix: '', + status: 'failure', + revoke_date: null, + }], + columns: ['key', 'hostname_prefix', 'status', 'revoke_date'], + }, + meta: { + limit: 9, offset: 0, total: 9, columns: ['name', 'value', 'type'], data: [{ name: 'description', value: 'Rotate domain keys', type: 'query description' }, { name: 'timezone', value: 'UTC', type: 'request parameter' }, { name: 'url', value: '-', type: 'request parameter' }, { name: 'newkey', value: '-', type: 'request parameter' }, { name: 'graceperiod', value: '-1', type: 'request parameter' }, { name: 'expiry', value: '-', type: 'request parameter' }, { name: 'readonly', value: true, type: 'request parameter' }, { name: 'note', value: '-', type: 'request parameter' }, { name: 'limit', value: null, type: 'request parameter' }], + }, +}; + +export const successKeyResponse = { + ':names': ['results', 'meta'], + ':type': 'multi-sheet', + ':version': 3, + results: { + limit: 1, + offset: 0, + total: 1, + data: [ + { + key: 'scoped-domain-key', + hostname_prefix: 'www.space.cat', + status: 'success', + revoke_date: '2023-12-04T12:30:01.123Z', + }, + ], + columns: ['key', 'hostname_prefix', 'status', 'revoke_date'], + }, + meta: { + limit: 9, offset: 0, total: 9, columns: ['name', 'value', 'type'], data: [{ name: 'description', value: 'Rotate domain keys', type: 'query description' }, { name: 'timezone', value: 'UTC', type: 'request parameter' }, { name: 'url', value: '-', type: 'request parameter' }, { name: 'newkey', value: '-', type: 'request parameter' }, { name: 'graceperiod', value: '-1', type: 'request parameter' }, { name: 'expiry', value: '-', type: 'request parameter' }, { name: 'readonly', value: true, type: 'request parameter' }, { name: 'note', value: '-', type: 'request parameter' }, { name: 'limit', value: null, type: 'request parameter' }], + }, +}; diff --git a/packages/spacecat-shared-rum-api-client/test/setup-env.js b/packages/spacecat-shared-rum-api-client/test/setup-env.js new file mode 100644 index 000000000..e447d7039 --- /dev/null +++ b/packages/spacecat-shared-rum-api-client/test/setup-env.js @@ -0,0 +1,14 @@ +/* + * Copyright 2021 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +// eslint-disable-next-line no-console +console.log('Forcing HTTP/1.1 for Adobe Fetch'); +process.env.HELIX_FETCH_FORCE_HTTP1 = 'true'; From 88af71727e3d0ca941b5253a3e8d319390843951 Mon Sep 17 00:00:00 2001 From: ekremney Date: Tue, 12 Dec 2023 15:00:36 +0100 Subject: [PATCH 2/3] fix: move jsdoc to types file --- packages/spacecat-shared-rum-api-client/src/index.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/spacecat-shared-rum-api-client/src/index.js b/packages/spacecat-shared-rum-api-client/src/index.js index 1021a554a..743778824 100644 --- a/packages/spacecat-shared-rum-api-client/src/index.js +++ b/packages/spacecat-shared-rum-api-client/src/index.js @@ -65,12 +65,6 @@ async function generateDomainKey(domainkey, url, expiry) { return data[0].key; } -/** - * - * @param context - * @returns RUMAPIClient - * @constructor - */ export default class RUMAPIClient { static createFrom(context) { if (context.rumApiClient) return context.rumApiClient; From 5377bc2ca81be0895dcffc6da933e14ed9562279 Mon Sep 17 00:00:00 2001 From: ekremney Date: Tue, 12 Dec 2023 15:48:31 +0100 Subject: [PATCH 3/3] fix: pr reviews --- .../spacecat-shared-rum-api-client/README.md | 67 ++++++++++++++++--- .../src/index.js | 9 +-- .../src/utils.js | 6 -- .../test/create-backlink.test.js | 1 - .../test/rum-api-client.test.js | 1 + packages/spacecat-shared-utils/README.md | 1 + packages/spacecat-shared-utils/package.json | 3 +- .../spacecat-shared-utils/src/functions.js | 20 ++++++ packages/spacecat-shared-utils/src/index.d.ts | 2 + packages/spacecat-shared-utils/src/index.js | 1 + .../test/functions.test.js | 24 +++++++ .../spacecat-shared-utils/test/index.test.js | 1 + 12 files changed, 116 insertions(+), 20 deletions(-) diff --git a/packages/spacecat-shared-rum-api-client/README.md b/packages/spacecat-shared-rum-api-client/README.md index 91445677c..a6aadcecc 100644 --- a/packages/spacecat-shared-rum-api-client/README.md +++ b/packages/spacecat-shared-rum-api-client/README.md @@ -1,16 +1,67 @@ -# Spacecat Shared - Example Wrapper +# Spacecat Shared - RUM API Client -When writing universal serverless functions with Helix Universal, then `spacecat-shared-example` will wrap your function -to print a hello world. +A JavaScript client for Adobe's Real User Monitoring (RUM) API, part of the SpaceCat Shared library. + +## Installation + +Install the package using npm: + +```bash +npm install @adobe/spacecat-shared-rum-api-client +``` ## Usage +### Creating and instance from Helix UniversalContext + +```js +const context = {}; // Your AWS Lambda context object +const rumApiClient = RUMAPIClient.createFrom(context); + +``` + +### Constructor + +`RUMAPIClient` class needs RUM API domain key to be instantiated: + +```js +const domainKey = "your-domain-key"; +const rumApiClient = new RUMAPIClient(domainKey); +``` + +### Creating a Backlink + ```js -import wrap from '@adobe/helix-shared-wrap'; -import example from '@adobe/spacecat-shared-example'; +const url = "https://example.com"; +const expiry = 7; // in days -... +const backlink = await rumApiClient.createBacklink(url, expiry); +console.log(`Backlink created: ${backlink}`) +``` -export const main = wrap(run) - .with(example); +## Testing +Run the included tests with the following command: +``` +npm test +``` + +## Linting +Lint the codebase using: +``` +npm run lint ``` + +## Cleaning +To clean the package (remove `node_modules` and `package-lock.json`): +``` +npm run clean +``` + +## Repository +Find the source code and contribute [here](https://github.com/adobe-rnd/spacecat-shared.git). + +## Issues +Report issues or bugs [here](https://github.com/adobe-rnd/spacecat-shared/issues). + +## License +This project is licensed under the Apache-2.0 License. diff --git a/packages/spacecat-shared-rum-api-client/src/index.js b/packages/spacecat-shared-rum-api-client/src/index.js index 743778824..195fd2a74 100644 --- a/packages/spacecat-shared-rum-api-client/src/index.js +++ b/packages/spacecat-shared-rum-api-client/src/index.js @@ -10,8 +10,10 @@ * governing permissions and limitations under the License. */ import { createUrl } from '@adobe/fetch'; -import { hasText, isArray, isInteger } from '@adobe/spacecat-shared-utils'; -import { dateAfterDays, fetch } from './utils.js'; +import { + hasText, isArray, isInteger, isObject, dateAfterDays, +} from '@adobe/spacecat-shared-utils'; +import { fetch } from './utils.js'; const APIS = { ROTATE_DOMAINKEYS: 'https://helix-pages.anywhere.run/helix-services/run-query@v3/rotate-domainkeys', @@ -21,8 +23,7 @@ const APIS = { export async function sendRequest(url, opts) { let respJson; try { - const resp = await fetch(url, opts); - // const resp = await (isObject(opts) ? fetch(url, opts) : fetch(url)); + const resp = await (isObject(opts) ? fetch(url, opts) : fetch(url)); respJson = await resp.json(); } catch (e) { throw new Error(`Error during rum api call: ${e.message}`); diff --git a/packages/spacecat-shared-rum-api-client/src/utils.js b/packages/spacecat-shared-rum-api-client/src/utils.js index cab523cf3..c671a9a92 100644 --- a/packages/spacecat-shared-rum-api-client/src/utils.js +++ b/packages/spacecat-shared-rum-api-client/src/utils.js @@ -16,9 +16,3 @@ import { context as h2, h1 } from '@adobe/fetch'; export const { fetch } = process.env.HELIX_FETCH_FORCE_HTTP1 ? h1() : h2(); - -export function dateAfterDays(days) { - const currentDate = new Date(); - currentDate.setDate(currentDate.getDate() + days); - return currentDate; -} diff --git a/packages/spacecat-shared-rum-api-client/test/create-backlink.test.js b/packages/spacecat-shared-rum-api-client/test/create-backlink.test.js index 5f2bddc82..f1069d762 100644 --- a/packages/spacecat-shared-rum-api-client/test/create-backlink.test.js +++ b/packages/spacecat-shared-rum-api-client/test/create-backlink.test.js @@ -10,7 +10,6 @@ * governing permissions and limitations under the License. */ /* eslint-env mocha */ -/* eslint-disable no-unused-expressions */ // expect statements import sinon from 'sinon'; import chai from 'chai'; diff --git a/packages/spacecat-shared-rum-api-client/test/rum-api-client.test.js b/packages/spacecat-shared-rum-api-client/test/rum-api-client.test.js index 2f54a2f69..fad0eb76d 100644 --- a/packages/spacecat-shared-rum-api-client/test/rum-api-client.test.js +++ b/packages/spacecat-shared-rum-api-client/test/rum-api-client.test.js @@ -10,6 +10,7 @@ * governing permissions and limitations under the License. */ /* eslint-env mocha */ + import chai from 'chai'; import chaiAsPromised from 'chai-as-promised'; import nock from 'nock'; diff --git a/packages/spacecat-shared-utils/README.md b/packages/spacecat-shared-utils/README.md index bc7db61f5..8734f467d 100644 --- a/packages/spacecat-shared-utils/README.md +++ b/packages/spacecat-shared-utils/README.md @@ -43,6 +43,7 @@ The library includes the following utility functions: - `arrayEquals(a, b)`: Compares two arrays for equality. - `isValidUrl(urlString)`: Validates whether the given string is a valid URL with http or https protocol. - `hasText(str)`: Checks if the given string is not empty. +- `dateAfterDays(number)`: Calculates the date after a specified number of days from the current date. ## Testing diff --git a/packages/spacecat-shared-utils/package.json b/packages/spacecat-shared-utils/package.json index 0735ba032..70db3adbd 100644 --- a/packages/spacecat-shared-utils/package.json +++ b/packages/spacecat-shared-utils/package.json @@ -29,6 +29,7 @@ "access": "public" }, "devDependencies": { - "chai": "4.3.10" + "chai": "4.3.10", + "sinon": "17.0.1" } } diff --git a/packages/spacecat-shared-utils/src/functions.js b/packages/spacecat-shared-utils/src/functions.js index 87b786b5a..4d087dbce 100644 --- a/packages/spacecat-shared-utils/src/functions.js +++ b/packages/spacecat-shared-utils/src/functions.js @@ -165,6 +165,25 @@ const arrayEquals = (a, b) => isArray(a) && a.length === b.length && a.every((val, index) => val === b[index]); +/** + * Calculates the date after a specified number of days from the current date. + * + * @param {number} days - The number of days to add to the current date. + * @returns {Date} A new Date object representing the calculated date after the specified days. + * @throws {TypeError} If the provided 'days' parameter is not a number. + * @throws {RangeError} If the calculated date is outside the valid JavaScript date range. + * + * @example + * // Get the date 7 days from now + * const sevenDaysLater = dateAfterDays(7); + * console.log(sevenDaysLater); // Outputs a Date object representing the date 7 days from now + */ +function dateAfterDays(days) { + const currentDate = new Date(); + currentDate.setDate(currentDate.getDate() + days); + return currentDate; +} + export { arrayEquals, hasText, @@ -179,4 +198,5 @@ export { isString, toBoolean, isValidUrl, + dateAfterDays, }; diff --git a/packages/spacecat-shared-utils/src/index.d.ts b/packages/spacecat-shared-utils/src/index.d.ts index 93989ddf5..5f7a590be 100644 --- a/packages/spacecat-shared-utils/src/index.d.ts +++ b/packages/spacecat-shared-utils/src/index.d.ts @@ -33,3 +33,5 @@ export function isString(value: unknown): boolean; export function toBoolean(value: unknown): boolean; export function isValidUrl(urlString: string): boolean; + +export function dateAfterDays(days: string): Date; diff --git a/packages/spacecat-shared-utils/src/index.js b/packages/spacecat-shared-utils/src/index.js index 4c570913a..1378686b3 100644 --- a/packages/spacecat-shared-utils/src/index.js +++ b/packages/spacecat-shared-utils/src/index.js @@ -24,6 +24,7 @@ export { isString, toBoolean, isValidUrl, + dateAfterDays, } from './functions.js'; export { resolveSecretsName } from './helpers.js'; diff --git a/packages/spacecat-shared-utils/test/functions.test.js b/packages/spacecat-shared-utils/test/functions.test.js index ff86f94d3..8f956d0f6 100644 --- a/packages/spacecat-shared-utils/test/functions.test.js +++ b/packages/spacecat-shared-utils/test/functions.test.js @@ -14,6 +14,7 @@ /* eslint-disable no-unused-expressions */ import { expect } from 'chai'; +import sinon from 'sinon'; import { hasText, @@ -29,6 +30,7 @@ import { toBoolean, arrayEquals, isValidUrl, + dateAfterDays, } from '../src/functions.js'; describe('Shared functions', () => { @@ -279,4 +281,26 @@ describe('Shared functions', () => { expect(isValidDate(new Date('2022-01-01T01:23:45.678Z'))).to.be.true; }); }); + + describe('daysAfter', () => { + const sandbox = sinon.createSandbox(); + + const mockDate = '2023-11-27T12:30:01.124Z'; + const sevenDaysLaterExpected = '2023-12-04T12:30:01.124Z'; + + before('setup', function () { + this.clock = sandbox.useFakeTimers({ + now: new Date(mockDate).getTime(), + }); + }); + + after('clean', () => { + sandbox.restore(); + }); + + it('returns days after now', async () => { + const sevenDaysLater = dateAfterDays(7); + expect(sevenDaysLater.toISOString()).to.equal(sevenDaysLaterExpected); + }); + }); }); diff --git a/packages/spacecat-shared-utils/test/index.test.js b/packages/spacecat-shared-utils/test/index.test.js index ef0eb59ae..e6333939d 100644 --- a/packages/spacecat-shared-utils/test/index.test.js +++ b/packages/spacecat-shared-utils/test/index.test.js @@ -31,6 +31,7 @@ describe('Index Exports', () => { 'toBoolean', 'isValidUrl', 'resolveSecretsName', + 'dateAfterDays', ]; it('exports all expected functions', () => {