diff --git a/package-lock.json b/package-lock.json index 1714b39f..eb7ea636 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "auth0-js": "^9.14.2", "axios": "^1.6.8", "change-case": "^4.1.2", + "core-js": "^3.39.0", "lodash.has": "^4.5.2", "lodash.isplainobject": "^4.0.6", "lodash.once": "^4.1.1", @@ -25,6 +26,7 @@ "@babel/core": "^7.26.0", "@babel/eslint-parser": "^7.25.9", "@babel/preset-env": "^7.26.0", + "@babel/register": "^7.25.9", "@eslint/compat": "^1.2.2", "babel-plugin-istanbul": "^7.0.0", "chai": "^4.1.2", @@ -1676,6 +1678,26 @@ "@babel/core": "^7.0.0-0 || ^8.0.0-0 <8.0.0" } }, + "node_modules/@babel/register": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/register/-/register-7.25.9.tgz", + "integrity": "sha512-8D43jXtGsYmEeDvm4MWHYUpWf8iiXgWYx3fW7E7Wb7Oe6FWqJPl5K6TuFW0dOwNZzEE5rjlaSJYH9JjrUKJszA==", + "dev": true, + "license": "MIT", + "dependencies": { + "clone-deep": "^4.0.1", + "find-cache-dir": "^2.0.0", + "make-dir": "^2.1.0", + "pirates": "^4.0.6", + "source-map-support": "^0.5.16" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/runtime": { "version": "7.26.0", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.26.0.tgz", @@ -3014,6 +3036,13 @@ "ieee754": "^1.2.1" } }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true, + "license": "MIT" + }, "node_modules/cache-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/cache-point/-/cache-point-2.0.0.tgz", @@ -3291,6 +3320,21 @@ "node": ">=0.8" } }, + "node_modules/clone-deep": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/clone-deep/-/clone-deep-4.0.1.tgz", + "integrity": "sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-plain-object": "^2.0.4", + "kind-of": "^6.0.2", + "shallow-clone": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/clone-stats": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz", @@ -3434,6 +3478,13 @@ "node": ">=8" } }, + "node_modules/commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", + "dev": true, + "license": "MIT" + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -3501,6 +3552,17 @@ "node": ">=0.10.0" } }, + "node_modules/core-js": { + "version": "3.39.0", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.39.0.tgz", + "integrity": "sha512-raM0ew0/jJUqkJ0E6e8UDtl+y/7ktFivgWvqw8dNSQeNWoSDLvQ1H/RN3aPXB9tBd4/FhyR4RDPGhsNIMsAn7g==", + "hasInstallScript": true, + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, "node_modules/core-js-compat": { "version": "3.39.0", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.39.0.tgz", @@ -4519,6 +4581,21 @@ "node": ">=8" } }, + "node_modules/find-cache-dir": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-2.1.0.tgz", + "integrity": "sha512-Tq6PixE0w/VMFfCgbONnkiQIVol/JJL7nRMi20fqzA4NRs9AfeqMGeRdPi3wIhYkxjeBaWh2rxwapn5Tu3IqOQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "commondir": "^1.0.1", + "make-dir": "^2.0.0", + "pkg-dir": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/find-replace": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-replace/-/find-replace-3.0.0.tgz", @@ -5902,6 +5979,16 @@ "json-buffer": "3.0.1" } }, + "node_modules/kind-of": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/klaw": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/klaw/-/klaw-3.0.0.tgz", @@ -7075,6 +7162,95 @@ "node": ">=6" } }, + "node_modules/pirates": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz", + "integrity": "sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/pkg-dir": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", + "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==", + "dev": true, + "license": "MIT", + "dependencies": { + "find-up": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/pkg-dir/node_modules/find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/pkg-dir/node_modules/locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/pkg-dir/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/pkg-dir/node_modules/p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^2.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/pkg-dir/node_modules/path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/plugin-error": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-1.0.1.tgz", @@ -7617,6 +7793,19 @@ "randombytes": "^2.1.0" } }, + "node_modules/shallow-clone": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz", + "integrity": "sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==", + "dev": true, + "license": "MIT", + "dependencies": { + "kind-of": "^6.0.2" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -7761,6 +7950,27 @@ "urix": "^0.1.0" } }, + "node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dev": true, + "license": "MIT", + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/source-map-support/node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/source-map-url": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.1.tgz", @@ -9951,6 +10161,19 @@ "esutils": "^2.0.2" } }, + "@babel/register": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/register/-/register-7.25.9.tgz", + "integrity": "sha512-8D43jXtGsYmEeDvm4MWHYUpWf8iiXgWYx3fW7E7Wb7Oe6FWqJPl5K6TuFW0dOwNZzEE5rjlaSJYH9JjrUKJszA==", + "dev": true, + "requires": { + "clone-deep": "^4.0.1", + "find-cache-dir": "^2.0.0", + "make-dir": "^2.1.0", + "pirates": "^4.0.6", + "source-map-support": "^0.5.16" + } + }, "@babel/runtime": { "version": "7.26.0", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.26.0.tgz", @@ -10898,6 +11121,12 @@ "ieee754": "^1.2.1" } }, + "buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true + }, "cache-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/cache-point/-/cache-point-2.0.0.tgz", @@ -11108,6 +11337,17 @@ "integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==", "dev": true }, + "clone-deep": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/clone-deep/-/clone-deep-4.0.1.tgz", + "integrity": "sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4", + "kind-of": "^6.0.2", + "shallow-clone": "^3.0.0" + } + }, "clone-stats": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz", @@ -11223,6 +11463,12 @@ "integrity": "sha512-jAg09gkdkrDO9EWTdXfv80WWH3yeZl5oT69fGfedBNS9pXUKYInVJ1bJ+/ht2+Moeei48TmSbQDYMc8EOx9G0g==", "dev": true }, + "commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", + "dev": true + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -11285,6 +11531,11 @@ } } }, + "core-js": { + "version": "3.39.0", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.39.0.tgz", + "integrity": "sha512-raM0ew0/jJUqkJ0E6e8UDtl+y/7ktFivgWvqw8dNSQeNWoSDLvQ1H/RN3aPXB9tBd4/FhyR4RDPGhsNIMsAn7g==" + }, "core-js-compat": { "version": "3.39.0", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.39.0.tgz", @@ -12034,6 +12285,17 @@ "to-regex-range": "^5.0.1" } }, + "find-cache-dir": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-2.1.0.tgz", + "integrity": "sha512-Tq6PixE0w/VMFfCgbONnkiQIVol/JJL7nRMi20fqzA4NRs9AfeqMGeRdPi3wIhYkxjeBaWh2rxwapn5Tu3IqOQ==", + "dev": true, + "requires": { + "commondir": "^1.0.1", + "make-dir": "^2.0.0", + "pkg-dir": "^3.0.0" + } + }, "find-replace": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-replace/-/find-replace-3.0.0.tgz", @@ -13027,6 +13289,12 @@ "json-buffer": "3.0.1" } }, + "kind-of": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", + "dev": true + }, "klaw": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/klaw/-/klaw-3.0.0.tgz", @@ -13940,6 +14208,66 @@ "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", "dev": true }, + "pirates": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz", + "integrity": "sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==", + "dev": true + }, + "pkg-dir": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", + "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==", + "dev": true, + "requires": { + "find-up": "^3.0.0" + }, + "dependencies": { + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==", + "dev": true + } + } + }, "plugin-error": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-1.0.1.tgz", @@ -14339,6 +14667,15 @@ "randombytes": "^2.1.0" } }, + "shallow-clone": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz", + "integrity": "sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==", + "dev": true, + "requires": { + "kind-of": "^6.0.2" + } + }, "shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -14455,6 +14792,24 @@ "urix": "^0.1.0" } }, + "source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, "source-map-url": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.1.tgz", diff --git a/package.json b/package.json index d1af22be..7c8613a1 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "", "main": "lib/index.js", "module": "esm/index.js", + "type": "commonjs", "publishConfig": { "access": "public" }, @@ -53,6 +54,7 @@ "auth0-js": "^9.14.2", "axios": "^1.6.8", "change-case": "^4.1.2", + "core-js": "^3.39.0", "lodash.has": "^4.5.2", "lodash.isplainobject": "^4.0.6", "lodash.once": "^4.1.1", @@ -66,6 +68,7 @@ "@babel/core": "^7.26.0", "@babel/eslint-parser": "^7.25.9", "@babel/preset-env": "^7.26.0", + "@babel/register": "^7.25.9", "@eslint/compat": "^1.2.2", "babel-plugin-istanbul": "^7.0.0", "chai": "^4.1.2", diff --git a/src/bus/channels.js b/src/bus/channels.js index f275c795..833fcc15 100644 --- a/src/bus/channels.js +++ b/src/bus/channels.js @@ -1,5 +1,5 @@ import isPlainObject from 'lodash.isplainobject'; -import { toCamelCase, toSnakeCase } from '../utils/objects'; +import ObjectUtils from '../utils/objects'; /** * @typedef {Object} MessageBusChannel @@ -71,9 +71,9 @@ class Channels { `${this._baseUrl}/organizations/${channel.organizationId}/services/${ channel.serviceId }/channels`, - toSnakeCase(channel) + ObjectUtils.toSnakeCase(channel) ) - .then((response) => toCamelCase(response)); + .then((response) => ObjectUtils.toCamelCase(response)); } /** @@ -166,7 +166,7 @@ class Channels { this._baseUrl }/organizations/${organizationId}/services/${serviceId}/channels/${channelId}` ) - .then((response) => toCamelCase(response)); + .then((response) => ObjectUtils.toCamelCase(response)); } /** @@ -228,7 +228,7 @@ class Channels { `${ this._baseUrl }/organizations/${organizationId}/services/${serviceId}/channels/${channelId}`, - toSnakeCase(update) + ObjectUtils.toSnakeCase(update) ); } @@ -283,7 +283,7 @@ class Channels { }/organizations/${organizationId}/services/${serviceId}/channels/${channelId}/peek/${subscription}`, { params: { messagePos } } ) - .then((response) => toCamelCase(response)); + .then((response) => ObjectUtils.toCamelCase(response)); } } diff --git a/src/bus/channels.spec.js b/src/bus/channels.spec.js index 71b2cc58..8b233cad 100644 --- a/src/bus/channels.spec.js +++ b/src/bus/channels.spec.js @@ -1,6 +1,6 @@ import omit from 'lodash.omit'; import Channels from './channels'; -import * as objectUtils from '../utils/objects'; +import objectUtils from '../utils/objects'; describe('Bus/Channels', function() { let baseRequest; diff --git a/src/coordinator/applications.js b/src/coordinator/applications.js index cf77aee9..8f6cb739 100644 --- a/src/coordinator/applications.js +++ b/src/coordinator/applications.js @@ -1,4 +1,4 @@ -import { toCamelCase } from '../utils/objects'; +import ObjectUtils from '../utils/objects'; /** * @typedef {Object} ContxtApplication @@ -107,7 +107,7 @@ class Applications { return this._request .post(`${this._baseUrl}/applications/${applicationId}/favorites`) - .then((favoriteApplication) => toCamelCase(favoriteApplication)); + .then((favoriteApplication) => ObjectUtils.toCamelCase(favoriteApplication)); } /** @@ -129,7 +129,7 @@ class Applications { getAll() { return this._request .get(`${this._baseUrl}/applications`) - .then((apps) => apps.map((app) => toCamelCase(app))); + .then((apps) => apps.map((app) => ObjectUtils.toCamelCase(app))); } /** @@ -153,7 +153,7 @@ class Applications { getFavorites() { return this._request .get(`${this._baseUrl}/applications/favorites`) - .then((favoriteApps) => toCamelCase(favoriteApps)); + .then((favoriteApps) => ObjectUtils.toCamelCase(favoriteApps)); } /** @@ -181,7 +181,7 @@ class Applications { if (this._organizationId) { return this._request .get(`${this._baseUrl}/applications/featured`) - .then((featuredApplications) => toCamelCase(featuredApplications)); + .then((featuredApplications) => ObjectUtils.toCamelCase(featuredApplications)); } if (!organizationId) { @@ -196,7 +196,7 @@ class Applications { .get( `${this._baseUrl}/organizations/${organizationId}/applications/featured` ) - .then((featuredApplications) => toCamelCase(featuredApplications)); + .then((featuredApplications) => ObjectUtils.toCamelCase(featuredApplications)); } /** @@ -221,7 +221,7 @@ class Applications { getGroupings(applicationId) { return this._request .get(`${this._baseUrl}/applications/${applicationId}/groupings`) - .then((groupings) => toCamelCase(groupings)); + .then((groupings) => ObjectUtils.toCamelCase(groupings)); } /** diff --git a/src/coordinator/applications.spec.js b/src/coordinator/applications.spec.js index 03f420d6..5542263e 100644 --- a/src/coordinator/applications.spec.js +++ b/src/coordinator/applications.spec.js @@ -1,4 +1,4 @@ -import * as objectUtils from '../utils/objects'; +import objectUtils from '../utils/objects'; import Applications from './applications'; describe('Coordinator/Applications', function() { diff --git a/src/coordinator/consent.js b/src/coordinator/consent.js index 3cbd481d..e7b2b481 100644 --- a/src/coordinator/consent.js +++ b/src/coordinator/consent.js @@ -1,4 +1,4 @@ -import { toCamelCase } from '../utils/objects'; +import ObjectUtils from '../utils/objects'; /** * @typedef {Object} ContxtApplicationConsent @@ -102,7 +102,7 @@ class Consent { .post(`${this._baseUrl}/consents/${consentId}/accept`, { access_token: accessToken }) - .then((userApproval) => toCamelCase(userApproval)); + .then((userApproval) => ObjectUtils.toCamelCase(userApproval)); }); } @@ -136,7 +136,7 @@ class Consent { .post(`${this._baseUrl}/applications/consent`, { access_token: accessToken }) - .then((applicationConsent) => toCamelCase(applicationConsent)); + .then((applicationConsent) => ObjectUtils.toCamelCase(applicationConsent)); }); } } diff --git a/src/coordinator/edgeNodes.js b/src/coordinator/edgeNodes.js index 5fdf4a99..d2423359 100644 --- a/src/coordinator/edgeNodes.js +++ b/src/coordinator/edgeNodes.js @@ -1,4 +1,4 @@ -import { toCamelCase } from '../utils/objects'; +import ObjectUtils from '../utils/objects'; /** * @typedef {Object} EdgeNode @@ -60,7 +60,7 @@ class EdgeNodes { return this._request .get(`${this._baseUrl}/edgenodes/${edgeNodeClientId}`) - .then((edgeNode) => toCamelCase(edgeNode)); + .then((edgeNode) => ObjectUtils.toCamelCase(edgeNode)); } if (!organizationId) { @@ -81,7 +81,7 @@ class EdgeNodes { this._baseUrl }/organizations/${organizationId}/edgenodes/${edgeNodeClientId}` ) - .then((edgeNode) => toCamelCase(edgeNode)); + .then((edgeNode) => ObjectUtils.toCamelCase(edgeNode)); } } diff --git a/src/coordinator/edgeNodes.spec.js b/src/coordinator/edgeNodes.spec.js index 345461ee..e25e4679 100644 --- a/src/coordinator/edgeNodes.spec.js +++ b/src/coordinator/edgeNodes.spec.js @@ -1,4 +1,4 @@ -import * as objectUtils from '../utils/objects'; +import objectUtils from '../utils/objects'; import EdgeNodes from './edgeNodes'; describe('edgeNodes', function() { diff --git a/src/coordinator/organizations.js b/src/coordinator/organizations.js index 4cbac97e..54ffd2dd 100644 --- a/src/coordinator/organizations.js +++ b/src/coordinator/organizations.js @@ -1,4 +1,4 @@ -import { toCamelCase } from '../utils/objects'; +import ObjectUtils from '../utils/objects'; /** * @typedef {Object} ContxtOrganization @@ -51,7 +51,7 @@ class Organizations { if (this._organizationId) { return this._request .get(`${this._baseUrl}/${this._organizationId}`) - .then((org) => toCamelCase(org)); + .then((org) => ObjectUtils.toCamelCase(org)); } if (!organizationId) { @@ -64,7 +64,7 @@ class Organizations { return this._request .get(`${this._baseUrl}/organizations/${organizationId}`) - .then((org) => toCamelCase(org)); + .then((org) => ObjectUtils.toCamelCase(org)); } /** @@ -86,7 +86,7 @@ class Organizations { getAll() { return this._request .get(`${this._baseUrl}/organizations`) - .then((orgs) => orgs.map((org) => toCamelCase(org))); + .then((orgs) => orgs.map((org) => ObjectUtils.toCamelCase(org))); } } diff --git a/src/coordinator/organizations.spec.js b/src/coordinator/organizations.spec.js index 72ffafcd..5129f5e8 100644 --- a/src/coordinator/organizations.spec.js +++ b/src/coordinator/organizations.spec.js @@ -1,4 +1,4 @@ -import * as objectUtils from '../utils/objects'; +import objectUtils from '../utils/objects'; import Organizations from './organizations'; describe('Coordinator/Organizations', function() { diff --git a/src/coordinator/permissions.js b/src/coordinator/permissions.js index 724841f8..dcdc8bc9 100644 --- a/src/coordinator/permissions.js +++ b/src/coordinator/permissions.js @@ -1,4 +1,4 @@ -import { toCamelCase } from '../utils/objects'; +import ObjectUtils from '../utils/objects'; /** * @typedef {Object} ContxtUserPermissions @@ -52,7 +52,7 @@ class Permissions { if (this._organizationId) { return this._request .get(`${this._baseUrl}/users/permissions`) - .then((userPermissions) => toCamelCase(userPermissions)); + .then((userPermissions) => ObjectUtils.toCamelCase(userPermissions)); } if (!organizationId) { @@ -65,7 +65,7 @@ class Permissions { return this._request .get(`${this._baseUrl}/organizations/${organizationId}/users/permissions`) - .then((userPermissions) => toCamelCase(userPermissions)); + .then((userPermissions) => ObjectUtils.toCamelCase(userPermissions)); } /** @@ -100,7 +100,7 @@ class Permissions { return this._request .get(`${this._baseUrl}/users/${userId}/permissions`) - .then((userPermissions) => toCamelCase(userPermissions)); + .then((userPermissions) => ObjectUtils.toCamelCase(userPermissions)); } if (!organizationId) { @@ -125,7 +125,7 @@ class Permissions { this._baseUrl }/organizations/${organizationId}/users/${userId}/permissions` ) - .then((userPermissions) => toCamelCase(userPermissions)); + .then((userPermissions) => ObjectUtils.toCamelCase(userPermissions)); } /** @@ -158,7 +158,7 @@ class Permissions { ); } - // NOTE: This response is not run through the `toCamelCase` method because + // NOTE: This response is not run through the `ObjectUtils.toCamelCase` method because // it could errantly remove underscores from service IDs. return this._request.get(`${this._baseUrl}/users/${userId}/permissions`); } diff --git a/src/coordinator/permissions.spec.js b/src/coordinator/permissions.spec.js index 99580040..bde32d92 100644 --- a/src/coordinator/permissions.spec.js +++ b/src/coordinator/permissions.spec.js @@ -1,4 +1,4 @@ -import * as objectUtils from '../utils/objects'; +import objectUtils from '../utils/objects'; import Permissions from './permissions'; describe('Coordinator/Permissions', function() { diff --git a/src/coordinator/roles.js b/src/coordinator/roles.js index 52fe59d1..2e4ebc2b 100644 --- a/src/coordinator/roles.js +++ b/src/coordinator/roles.js @@ -1,4 +1,4 @@ -import { toSnakeCase, toCamelCase } from '../utils/objects'; +import ObjectUtils from '../utils/objects'; /** * @typedef {Object} ContxtRole @@ -98,7 +98,7 @@ class Roles { return this._request .post(`${this._baseUrl}/roles/${roleId}/applications/${applicationId}`) - .then((response) => toCamelCase(response)); + .then((response) => ObjectUtils.toCamelCase(response)); } /** @@ -155,7 +155,7 @@ class Roles { access_type: accessType } ) - .then((response) => toCamelCase(response)); + .then((response) => ObjectUtils.toCamelCase(response)); } /** @@ -194,8 +194,8 @@ class Roles { } return this._request - .post(`${this._baseUrl}/roles`, toSnakeCase(role)) - .then((response) => toCamelCase(response)); + .post(`${this._baseUrl}/roles`, ObjectUtils.toSnakeCase(role)) + .then((response) => ObjectUtils.toCamelCase(response)); } if (!organizationId) { @@ -221,9 +221,9 @@ class Roles { return this._request .post( `${this._baseUrl}/organizations/${organizationId}/roles`, - toSnakeCase(role) + ObjectUtils.toSnakeCase(role) ) - .then((response) => toCamelCase(response)); + .then((response) => ObjectUtils.toCamelCase(response)); } /** @@ -294,7 +294,7 @@ class Roles { if (this._organizationId) { return this._request .get(`${this._baseUrl}/roles`) - .then((roles) => toCamelCase(roles)); + .then((roles) => ObjectUtils.toCamelCase(roles)); } if (!organizationId) { @@ -307,7 +307,7 @@ class Roles { return this._request .get(`${this._baseUrl}/organizations/${organizationId}/roles`) - .then((roles) => toCamelCase(roles)); + .then((roles) => ObjectUtils.toCamelCase(roles)); } /** diff --git a/src/coordinator/roles.spec.js b/src/coordinator/roles.spec.js index 6a0960f2..0855d6a7 100644 --- a/src/coordinator/roles.spec.js +++ b/src/coordinator/roles.spec.js @@ -1,4 +1,4 @@ -import * as objectUtils from '../utils/objects'; +import objectUtils from '../utils/objects'; import Roles from './roles'; describe('Coordinator/Roles', function() { diff --git a/src/coordinator/users.js b/src/coordinator/users.js index ef17f789..583b4a6d 100644 --- a/src/coordinator/users.js +++ b/src/coordinator/users.js @@ -1,6 +1,6 @@ import axios from 'axios'; -import { toCamelCase, toSnakeCase } from '../utils/objects'; +import ObjectUtils from '../utils/objects'; /** * @typedef {Object} ContxtUser @@ -137,7 +137,7 @@ class Users { // Uses axios directly instead of this.request to bypass authorization interceptors return axios.post( `${this._getBaseUrl('access')}/users/${userId}/activate`, - toSnakeCase(user) + ObjectUtils.toSnakeCase(user) ); } @@ -179,7 +179,7 @@ class Users { .post( `${this._getBaseUrl()}/users/${userId}/applications/${applicationId}` ) - .then((response) => toCamelCase(response)); + .then((response) => ObjectUtils.toCamelCase(response)); } /** @@ -216,7 +216,7 @@ class Users { return this._request .post(`${this._getBaseUrl()}/users/${userId}/roles/${roleId}`) - .then((response) => toCamelCase(response)); + .then((response) => ObjectUtils.toCamelCase(response)); } /** @@ -271,7 +271,7 @@ class Users { access_type: accessType } ) - .then((response) => toCamelCase(response)); + .then((response) => ObjectUtils.toCamelCase(response)); } /** @@ -301,7 +301,7 @@ class Users { return this._request .get(`${this._getBaseUrl('access')}/users/${userId}`) - .then((user) => toCamelCase(user)); + .then((user) => ObjectUtils.toCamelCase(user)); } /** @@ -327,7 +327,7 @@ class Users { if (this._organizationId) { return this._request .get(`${this._getBaseUrl()}/users`) - .then((orgUsers) => toCamelCase(orgUsers)); + .then((orgUsers) => ObjectUtils.toCamelCase(orgUsers)); } if (!organizationId) { @@ -342,7 +342,7 @@ class Users { .get( `${this._getBaseUrl('legacy')}/organizations/${organizationId}/users` ) - .then((orgUsers) => toCamelCase(orgUsers)); + .then((orgUsers) => ObjectUtils.toCamelCase(orgUsers)); } /** @@ -395,8 +395,8 @@ class Users { } return this._request - .post(`${this._getBaseUrl()}/users`, toSnakeCase(user)) - .then((response) => toCamelCase(response)); + .post(`${this._getBaseUrl()}/users`, ObjectUtils.toSnakeCase(user)) + .then((response) => ObjectUtils.toCamelCase(response)); } if (!organizationId) { @@ -420,9 +420,9 @@ class Users { return this._request .post( `${this._getBaseUrl('legacy')}/organizations/${organizationId}/users`, - toSnakeCase(user) + ObjectUtils.toSnakeCase(user) ) - .then((response) => toCamelCase(response)); + .then((response) => ObjectUtils.toCamelCase(response)); } /** diff --git a/src/coordinator/users.spec.js b/src/coordinator/users.spec.js index 8bbb6994..30e4037d 100644 --- a/src/coordinator/users.spec.js +++ b/src/coordinator/users.spec.js @@ -1,7 +1,7 @@ import axios from 'axios'; import { expect } from 'chai'; import omit from 'lodash.omit'; -import * as objectUtils from '../utils/objects'; +import objectUtils from '../utils/objects'; import Users from './users'; describe('Coordinator/Users', function() { diff --git a/src/events/index.js b/src/events/index.js index 7eed7b65..b7c664ab 100644 --- a/src/events/index.js +++ b/src/events/index.js @@ -1,8 +1,8 @@ import has from 'lodash.has'; import isPlainObject from 'lodash.isplainobject'; -import { formatEventUpdateToServer } from '../utils/events'; -import { toCamelCase, toSnakeCase } from '../utils/objects'; -import { formatPaginatedDataFromServer } from '../utils/pagination'; +import EventUtils from '../utils/events'; +import ObjectUtils from '../utils/objects'; +import PaginationUtils from '../utils/pagination'; /** * @typedef {Object} Event @@ -189,8 +189,8 @@ class Events { } return this._request - .post(`${this._baseUrl}/events`, toSnakeCase(event)) - .then((response) => toCamelCase(response)); + .post(`${this._baseUrl}/events`, ObjectUtils.toSnakeCase(event)) + .then((response) => ObjectUtils.toCamelCase(response)); } /** @@ -247,7 +247,7 @@ class Events { return this._request .get(`${this._baseUrl}/events/${eventId}`) - .then((event) => toCamelCase(event)); + .then((event) => ObjectUtils.toCamelCase(event)); } /** @@ -278,9 +278,9 @@ class Events { return this._request .get(`${this._baseUrl}/clients/${clientId}/types`, { - params: toSnakeCase(paginationOptions) + params: ObjectUtils.toSnakeCase(paginationOptions) }) - .then((response) => formatPaginatedDataFromServer(response)); + .then((response) => PaginationUtils.formatPaginatedDataFromServer(response)); } /** @@ -322,9 +322,9 @@ class Events { return this._request .get(`${this._baseUrl}/types/${eventTypeId}/events`, { - params: toSnakeCase(eventFilters) + params: ObjectUtils.toSnakeCase(eventFilters) }) - .then((events) => formatPaginatedDataFromServer(events)); + .then((events) => PaginationUtils.formatPaginatedDataFromServer(events)); } /** @@ -351,12 +351,12 @@ class Events { return this._request .get(`${this._baseUrl}/facilities/${facilityId}/triggered-events`, { - params: toSnakeCase(triggeredEventFilters, { + params: ObjectUtils.toSnakeCase(triggeredEventFilters, { deep: true, excludeTransform: ['orderBy', 'reverseOrder'] }) }) - .then((events) => formatPaginatedDataFromServer(events)); + .then((events) => PaginationUtils.formatPaginatedDataFromServer(events)); } /** @@ -386,7 +386,7 @@ class Events { return this._request .get(`${this._baseUrl}/users/${userId}`) - .then((user) => toCamelCase(user)); + .then((user) => ObjectUtils.toCamelCase(user)); } /** @@ -425,9 +425,9 @@ class Events { return this._request .post( `${this._baseUrl}/users/${userId}/events/${eventId}`, - toSnakeCase(subscribeOpts) + ObjectUtils.toSnakeCase(subscribeOpts) ) - .then((response) => toCamelCase(response)); + .then((response) => ObjectUtils.toCamelCase(response)); } /** @@ -512,7 +512,7 @@ class Events { ); } - const formattedUpdate = formatEventUpdateToServer(update); + const formattedUpdate = EventUtils.formatEventUpdateToServer(update); return this._request.put( `${this._baseUrl}/events/${eventId}`, @@ -574,8 +574,8 @@ class Events { } return this._request - .post(`${this._baseUrl}/types`, toSnakeCase(eventType)) - .then((response) => toCamelCase(response)); + .post(`${this._baseUrl}/types`, ObjectUtils.toSnakeCase(eventType)) + .then((response) => ObjectUtils.toCamelCase(response)); } } diff --git a/src/events/index.spec.js b/src/events/index.spec.js index a8da8a75..6497ea53 100644 --- a/src/events/index.spec.js +++ b/src/events/index.spec.js @@ -1,7 +1,7 @@ import omit from 'lodash.omit'; -import * as eventsUtils from '../utils/events'; -import * as objectUtils from '../utils/objects'; -import * as paginationUtils from '../utils/pagination'; +import eventsUtils from '../utils/events'; +import objectUtils from '../utils/objects'; +import paginationUtils from '../utils/pagination'; import Events from './index'; describe('Events', function() { diff --git a/src/files/index.js b/src/files/index.js index 592b4c69..2c2c6a19 100644 --- a/src/files/index.js +++ b/src/files/index.js @@ -1,6 +1,6 @@ import axios from 'axios'; -import { toCamelCase, toSnakeCase } from '../utils/objects'; -import { formatPaginatedDataFromServer } from '../utils/pagination'; +import ObjectUtils from '../utils/objects'; +import PaginationUtils from '../utils/pagination'; /** * @typedef {Object} File @@ -142,11 +142,11 @@ class Files { } return this._request - .post(`${this._baseUrl}/files`, toSnakeCase(fileInfo)) + .post(`${this._baseUrl}/files`, ObjectUtils.toSnakeCase(fileInfo)) .then(({ upload_info, ...createdFile }) => { return { - ...toCamelCase(createdFile), - uploadInfo: toCamelCase(upload_info, { + ...ObjectUtils.toCamelCase(createdFile), + uploadInfo: ObjectUtils.toCamelCase(upload_info, { deep: false, excludeTransform: ['headers'] }) @@ -321,7 +321,7 @@ class Files { return this._request .get(`${this._baseUrl}/files/${fileId}/download`) - .then((file) => toCamelCase(file)); + .then((file) => ObjectUtils.toCamelCase(file)); } /** @@ -351,7 +351,7 @@ class Files { return this._request .get(`${this._baseUrl}/files/${fileId}`) - .then((file) => toCamelCase(file)); + .then((file) => ObjectUtils.toCamelCase(file)); } /** @@ -381,9 +381,9 @@ class Files { getAll(filesFilters) { return this._request .get(`${this._baseUrl}/files`, { - params: toSnakeCase(filesFilters) + params: ObjectUtils.toSnakeCase(filesFilters) }) - .then((assetsData) => formatPaginatedDataFromServer(assetsData)); + .then((assetsData) => PaginationUtils.formatPaginatedDataFromServer(assetsData)); } /** diff --git a/src/files/index.spec.js b/src/files/index.spec.js index f1237cf8..42ef263a 100644 --- a/src/files/index.spec.js +++ b/src/files/index.spec.js @@ -1,8 +1,8 @@ import axios from 'axios'; import omit from 'lodash.omit'; import pick from 'lodash.pick'; -import * as objectUtils from '../utils/objects'; -import * as paginationUtils from '../utils/pagination'; +import objectUtils from '../utils/objects'; +import paginationUtils from '../utils/pagination'; import Files from './index'; describe('Files', function() { diff --git a/src/index.js b/src/index.js index 3497aeb1..7854ac06 100644 --- a/src/index.js +++ b/src/index.js @@ -7,7 +7,7 @@ import Iot from './iot'; import Nionic from './nionic'; import Request from './request'; import * as sessionTypes from './sessionTypes'; -import { toSnakeCase, toCamelCase } from './utils/objects'; +import ObjectUtils from './utils/objects'; /** * An adapter that allows the SDK to authenticate with different services and manage various tokens. @@ -197,5 +197,7 @@ class ContxtSdk { } } +const { toSnakeCase, toCamelCase } = ObjectUtils + export default ContxtSdk; export { toSnakeCase, toCamelCase }; diff --git a/src/iot/feedTypes.js b/src/iot/feedTypes.js index f3471e3e..a43c6f3d 100644 --- a/src/iot/feedTypes.js +++ b/src/iot/feedTypes.js @@ -1,4 +1,4 @@ -import { toCamelCase } from '../utils/objects'; +import ObjectUtils from '../utils/objects'; /** * @typedef {Object} FeedType @@ -48,7 +48,7 @@ class FeedTypes { getAll() { return this._request .get(`${this._baseUrl}/feeds/types`) - .then((feedTypes) => toCamelCase(feedTypes)); + .then((feedTypes) => ObjectUtils.toCamelCase(feedTypes)); } } diff --git a/src/iot/feeds.js b/src/iot/feeds.js index 91fe11a3..b2818aef 100644 --- a/src/iot/feeds.js +++ b/src/iot/feeds.js @@ -1,4 +1,4 @@ -import { toCamelCase, toSnakeCase } from '../utils/objects'; +import ObjectUtils from '../utils/objects'; /** * @typedef {Object} Feed @@ -111,9 +111,9 @@ class Feeds { return this._request .get(`${this._baseUrl}/feeds`, { - params: toSnakeCase({ facilityId }) + params: ObjectUtils.toSnakeCase({ facilityId }) }) - .then((response) => toCamelCase(response)); + .then((response) => ObjectUtils.toCamelCase(response)); } /** @@ -143,7 +143,7 @@ class Feeds { return this._request .get(`${this._baseUrl}/facilities/${facilityId}/status`) - .then((response) => toCamelCase(response)); + .then((response) => ObjectUtils.toCamelCase(response)); } } diff --git a/src/iot/feeds.spec.js b/src/iot/feeds.spec.js index 130ff410..1e70c89e 100644 --- a/src/iot/feeds.spec.js +++ b/src/iot/feeds.spec.js @@ -1,4 +1,4 @@ -import * as objectUtils from '../utils/objects'; +import objectUtils from '../utils/objects'; import Feeds from './feeds'; describe('Iot/Feeds', function() { diff --git a/src/iot/fieldCategories.js b/src/iot/fieldCategories.js index 0448b0eb..2a2693b5 100644 --- a/src/iot/fieldCategories.js +++ b/src/iot/fieldCategories.js @@ -1,6 +1,6 @@ import isPlainObject from 'lodash.isplainobject'; -import { toCamelCase, toSnakeCase } from '../utils/objects'; -import { formatPaginatedDataFromServer } from '../utils/pagination'; +import ObjectUtils from '../utils/objects'; +import PaginationUtils from '../utils/pagination'; /** * @typedef {Object} FieldCategory @@ -77,11 +77,11 @@ class FieldCategories { } } - const formattedCategory = toSnakeCase(fieldCategory); + const formattedCategory = ObjectUtils.toSnakeCase(fieldCategory); return this._request .post(`${this._baseUrl}/categories`, formattedCategory) - .then((fieldCategory) => toCamelCase(fieldCategory)); + .then((fieldCategory) => ObjectUtils.toCamelCase(fieldCategory)); } /** @@ -139,7 +139,7 @@ class FieldCategories { return this._request .get(`${this._baseUrl}/categories/${categoryId}`) - .then((fieldCategory) => toCamelCase(fieldCategory)); + .then((fieldCategory) => ObjectUtils.toCamelCase(fieldCategory)); } /** @@ -163,10 +163,10 @@ class FieldCategories { getAll(paginationOptions) { return this._request .get(`${this._baseUrl}/categories`, { - params: toSnakeCase(paginationOptions) + params: ObjectUtils.toSnakeCase(paginationOptions) }) .then((fieldCategories) => - formatPaginatedDataFromServer(fieldCategories) + PaginationUtils.formatPaginatedDataFromServer(fieldCategories) ); } @@ -199,7 +199,7 @@ class FieldCategories { return this._request .get(`${this._baseUrl}/facilities/${facilityId}/categories`) - .then((fieldCategories) => toCamelCase(fieldCategories)); + .then((fieldCategories) => ObjectUtils.toCamelCase(fieldCategories)); } /** @@ -251,13 +251,13 @@ class FieldCategories { ); } - const formattedUpdate = toSnakeCase(update, { + const formattedUpdate = ObjectUtils.toSnakeCase(update, { excludeKeys: ['id', 'organizationId'] }); return this._request .put(`${this._baseUrl}/categories/${categoryId}`, formattedUpdate) - .then((fieldCategory) => toCamelCase(fieldCategory)); + .then((fieldCategory) => ObjectUtils.toCamelCase(fieldCategory)); } } diff --git a/src/iot/fieldCategories.spec.js b/src/iot/fieldCategories.spec.js index 86b6ff6b..46ee4b56 100644 --- a/src/iot/fieldCategories.spec.js +++ b/src/iot/fieldCategories.spec.js @@ -1,6 +1,6 @@ import omit from 'lodash.omit'; -import * as objectUtils from '../utils/objects'; -import * as paginationUtils from '../utils/pagination'; +import objectUtils from '../utils/objects'; +import paginationUtils from '../utils/pagination'; import FieldCategories from './fieldCategories'; describe('Iot/FieldCategories', function() { diff --git a/src/iot/fieldGroupings.js b/src/iot/fieldGroupings.js index 46898f5c..311f4631 100644 --- a/src/iot/fieldGroupings.js +++ b/src/iot/fieldGroupings.js @@ -1,6 +1,6 @@ import isPlainObject from 'lodash.isplainobject'; -import { toCamelCase, toSnakeCase } from '../utils/objects'; -import { formatPaginatedDataFromServer } from '../utils/pagination'; +import ObjectUtils from '../utils/objects'; +import PaginationUtils from '../utils/pagination'; /** * @typedef {Object} FieldGrouping @@ -88,7 +88,7 @@ class FieldGroupings { .post( `${this._baseUrl}/groupings/${fieldGroupingId}/fields/${outputFieldId}` ) - .then((grouping) => toCamelCase(grouping)); + .then((grouping) => ObjectUtils.toCamelCase(grouping)); } /** @@ -137,14 +137,14 @@ class FieldGroupings { } } - const formattedGrouping = toSnakeCase(fieldGrouping); + const formattedGrouping = ObjectUtils.toSnakeCase(fieldGrouping); return this._request .post( `${this._baseUrl}/facilities/${facilityId}/groupings`, formattedGrouping ) - .then((fieldGrouping) => toCamelCase(fieldGrouping)); + .then((fieldGrouping) => ObjectUtils.toCamelCase(fieldGrouping)); } /** @@ -202,7 +202,7 @@ class FieldGroupings { return this._request .get(`${this._baseUrl}/groupings/${groupingId}`) - .then((fieldGrouping) => toCamelCase(fieldGrouping)); + .then((fieldGrouping) => ObjectUtils.toCamelCase(fieldGrouping)); } /** @@ -234,9 +234,9 @@ class FieldGroupings { return this._request .get(`${this._baseUrl}/facilities/${facilityId}/groupings`, { - params: toSnakeCase(paginationOptions) + params: ObjectUtils.toSnakeCase(paginationOptions) }) - .then((fieldGrouping) => formatPaginatedDataFromServer(fieldGrouping)); + .then((fieldGrouping) => PaginationUtils.formatPaginatedDataFromServer(fieldGrouping)); } /** @@ -327,13 +327,13 @@ class FieldGroupings { ); } - const formattedUpdate = toSnakeCase(update, { + const formattedUpdate = ObjectUtils.toSnakeCase(update, { excludeKeys: ['facilityId', 'id', 'ownerId', 'slug'] }); return this._request .put(`${this._baseUrl}/groupings/${groupingId}`, formattedUpdate) - .then((fieldGrouping) => toCamelCase(fieldGrouping)); + .then((fieldGrouping) => ObjectUtils.toCamelCase(fieldGrouping)); } } diff --git a/src/iot/fieldGroupings.spec.js b/src/iot/fieldGroupings.spec.js index 29ea4796..f8886eeb 100644 --- a/src/iot/fieldGroupings.spec.js +++ b/src/iot/fieldGroupings.spec.js @@ -1,6 +1,6 @@ import omit from 'lodash.omit'; -import * as objectUtils from '../utils/objects'; -import * as paginationUtils from '../utils/pagination'; +import objectUtils from '../utils/objects'; +import paginationUtils from '../utils/pagination'; import FieldGroupings from './fieldGroupings'; describe('Iot/FieldGroupings', function() { diff --git a/src/iot/fields.js b/src/iot/fields.js index 8d2709bd..cbd96395 100644 --- a/src/iot/fields.js +++ b/src/iot/fields.js @@ -1,4 +1,4 @@ -import { toCamelCase } from '../utils/objects'; +import ObjectUtils from '../utils/objects'; /** * @typedef {Object} OutputField @@ -70,7 +70,7 @@ class Fields { return this._request .get(`${this._baseUrl}/fields/${outputFieldId}`) - .then((outputField) => toCamelCase(outputField)); + .then((outputField) => ObjectUtils.toCamelCase(outputField)); } } diff --git a/src/iot/fields.spec.js b/src/iot/fields.spec.js index 8aed0ac4..d1d7d743 100644 --- a/src/iot/fields.spec.js +++ b/src/iot/fields.spec.js @@ -1,5 +1,5 @@ import Fields from './fields'; -import * as objectUtils from '../utils/objects'; +import objectUtils from '../utils/objects'; describe('Iot/Fields', function() { let baseRequest; diff --git a/src/iot/outputs.js b/src/iot/outputs.js index 84c14eaf..e2662acc 100644 --- a/src/iot/outputs.js +++ b/src/iot/outputs.js @@ -1,4 +1,4 @@ -import { formatOutputFieldDataFromServer } from '../utils/iot'; +import IotUtils from '../utils/iot'; /** * @typedef {Object} OutputFieldDataResponse * @property {Object} meta @@ -98,7 +98,7 @@ class Outputs { `${this._baseUrl}/outputs/${outputId}/fields/${fieldHumanName}/data`, { params: options } ) - .then((fieldData) => formatOutputFieldDataFromServer(fieldData)); + .then((fieldData) => IotUtils.formatOutputFieldDataFromServer(fieldData)); } } diff --git a/src/iot/outputs.spec.js b/src/iot/outputs.spec.js index aebacd06..fe3d52ae 100644 --- a/src/iot/outputs.spec.js +++ b/src/iot/outputs.spec.js @@ -1,4 +1,4 @@ -import * as iotUtils from '../utils/iot'; +import iotUtils from '../utils/iot'; import Outputs from './outputs'; describe('Iot/Outputs', function() { diff --git a/src/utils/events/index.js b/src/utils/events/index.js index b1ef3736..2edccb21 100644 --- a/src/utils/events/index.js +++ b/src/utils/events/index.js @@ -1,3 +1,4 @@ import formatEventUpdateToServer from './formatEventUpdateToServer'; -export { formatEventUpdateToServer }; +const EventUtils = { formatEventUpdateToServer }; +export default EventUtils; diff --git a/src/utils/iot/formatOutputFieldDataFromServer.js b/src/utils/iot/formatOutputFieldDataFromServer.js index 164b0472..976b25e0 100644 --- a/src/utils/iot/formatOutputFieldDataFromServer.js +++ b/src/utils/iot/formatOutputFieldDataFromServer.js @@ -1,5 +1,5 @@ -import { parseOutputFieldNextPageUrlMetadata } from './index'; -import { toCamelCase } from '../objects'; +import IotUtils from './index'; +import ObjectUtils from '../objects'; /** * Normalizes the output field data and metadata returned from the API server @@ -38,15 +38,15 @@ import { toCamelCase } from '../objects'; */ function formatOutputFieldDataFromServer(input = {}) { const meta = input.meta || {}; - const query = parseOutputFieldNextPageUrlMetadata(meta.next_page_url); + const query = IotUtils.parseOutputFieldNextPageUrlMetadata(meta.next_page_url); const records = input.records || []; return { meta: { - ...toCamelCase(input.meta, { excludeKeys: ['next_page_url'] }), + ...ObjectUtils.toCamelCase(input.meta, { excludeKeys: ['next_page_url'] }), ...query }, - records: toCamelCase(records) + records: ObjectUtils.toCamelCase(records) }; } diff --git a/src/utils/iot/formatOutputFieldDataFromServer.spec.js b/src/utils/iot/formatOutputFieldDataFromServer.spec.js index 4f8d4e79..48526952 100644 --- a/src/utils/iot/formatOutputFieldDataFromServer.spec.js +++ b/src/utils/iot/formatOutputFieldDataFromServer.spec.js @@ -1,8 +1,8 @@ import omit from 'lodash.omit'; import URL from 'url-parse'; -import * as objectUtils from '../objects'; +import objectUtils from '../objects'; import formatOutputFieldDataFromServer from './formatOutputFieldDataFromServer'; -import * as iotUtils from './index'; +import iotUtils from './index'; describe('utils/iot/formatOutputFieldDataFromServer', function() { let expectedOutputFieldDataRecords; diff --git a/src/utils/iot/index.js b/src/utils/iot/index.js index 700adc31..3f47692c 100644 --- a/src/utils/iot/index.js +++ b/src/utils/iot/index.js @@ -1,4 +1,5 @@ import formatOutputFieldDataFromServer from './formatOutputFieldDataFromServer'; import parseOutputFieldNextPageUrlMetadata from './parseOutputFieldNextPageUrlMetadata'; -export { formatOutputFieldDataFromServer, parseOutputFieldNextPageUrlMetadata }; +const IotUtils = { formatOutputFieldDataFromServer, parseOutputFieldNextPageUrlMetadata } +export default IotUtils; diff --git a/src/utils/objects/index.js b/src/utils/objects/index.js index 0133b1b1..7a164405 100644 --- a/src/utils/objects/index.js +++ b/src/utils/objects/index.js @@ -1,4 +1,5 @@ import toCamelCase from './toCamelCase'; import toSnakeCase from './toSnakeCase'; -export { toCamelCase, toSnakeCase }; +const ObjectUtils = { toCamelCase, toSnakeCase }; +export default ObjectUtils diff --git a/src/utils/pagination/formatPaginatedDataFromServer.js b/src/utils/pagination/formatPaginatedDataFromServer.js index e79b51a4..ff234222 100644 --- a/src/utils/pagination/formatPaginatedDataFromServer.js +++ b/src/utils/pagination/formatPaginatedDataFromServer.js @@ -1,4 +1,4 @@ -import { toCamelCase } from '../objects'; +import ObjectUtils from '../objects'; /** * Default formatter. Returns the original value in case no formatter is @@ -11,7 +11,7 @@ import { toCamelCase } from '../objects'; * @private */ function defaultFormatter(value) { - return toCamelCase(value); + return ObjectUtils.toCamelCase(value); } /** @@ -38,7 +38,7 @@ function formatPaginatedDataFromServer( const records = input.records || []; return { - _metadata: toCamelCase(_metadata), + _metadata: ObjectUtils.toCamelCase(_metadata), records: records.map(recordFormatter) }; } diff --git a/src/utils/pagination/formatPaginatedDataFromServer.spec.js b/src/utils/pagination/formatPaginatedDataFromServer.spec.js index 48749744..f15cac7f 100644 --- a/src/utils/pagination/formatPaginatedDataFromServer.spec.js +++ b/src/utils/pagination/formatPaginatedDataFromServer.spec.js @@ -1,5 +1,5 @@ import times from 'lodash.times'; -import * as objectUtils from '../objects'; +import objectUtils from '../objects'; import formatPaginatedDataFromServer from './formatPaginatedDataFromServer'; describe('utils/pagination/formatPaginatedDataFromServer', function() { diff --git a/src/utils/pagination/index.js b/src/utils/pagination/index.js index afb6d850..fa3e4c7b 100644 --- a/src/utils/pagination/index.js +++ b/src/utils/pagination/index.js @@ -1,3 +1,4 @@ import formatPaginatedDataFromServer from './formatPaginatedDataFromServer'; -export { formatPaginatedDataFromServer }; +const PaginationUtils = { formatPaginatedDataFromServer }; +export default PaginationUtils diff --git a/support/mocharc.yml b/support/mocharc.yml index 5c64b386..c57318d0 100644 --- a/support/mocharc.yml +++ b/support/mocharc.yml @@ -1,4 +1,4 @@ require: - - "babel-register" + - "@babel/register" - "support/addons.js" - "support/globals.js"