diff --git a/app.json b/app.json index cac08c0..1052b20 100644 --- a/app.json +++ b/app.json @@ -1,7 +1,7 @@ { "id": "53fd430f-3924-4c6c-8774-b23fabfeb0e5", "version": "0.0.1", - "requiredApiVersion": "^1.19.0", + "requiredApiVersion": "^1.31.0", "iconFile": "icon.png", "author": { "name": "IndieHosters", diff --git a/package-lock.json b/package-lock.json index 424bf07..4129ca5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,10 +6,10 @@ "": { "devDependencies": { "@rocket.chat/apps-cli": "1.9.0", - "@rocket.chat/apps-engine": "^1.19.0", + "@rocket.chat/apps-engine": "^1.31.0", "@types/node": "14.14.6", - "tslint": "^5.10.0", - "typescript": "^4.0.5" + "tslint": "^5.20.1", + "typescript": "^4.6.2" } }, "node_modules/@babel/code-frame": { @@ -415,9 +415,9 @@ } }, "node_modules/@oclif/color/node_modules/ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", + "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", "dev": true, "engines": { "node": ">=6" @@ -874,9 +874,9 @@ } }, "node_modules/@oclif/plugin-help/node_modules/ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", + "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", "dev": true, "engines": { "node": ">=6" @@ -1288,15 +1288,6 @@ "node": ">=8.0.0" } }, - "node_modules/@rocket.chat/apps-cli/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true, - "bin": { - "semver": "bin/semver.js" - } - }, "node_modules/@rocket.chat/apps-cli/node_modules/typescript": { "version": "3.9.10", "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", @@ -1344,9 +1335,9 @@ } }, "node_modules/@rocket.chat/apps-engine": { - "version": "1.30.0", - "resolved": "https://registry.npmjs.org/@rocket.chat/apps-engine/-/apps-engine-1.30.0.tgz", - "integrity": "sha512-04X4nQPgZEz9w4b/8zCyW+EVixfzdrugW4u6YUYnB4tc9lDALawSvhz88XlDGvKwbsUKFfSx6ejdhASwSssPcA==", + "version": "1.31.0", + "resolved": "https://registry.npmjs.org/@rocket.chat/apps-engine/-/apps-engine-1.31.0.tgz", + "integrity": "sha512-OAPSjqqFvX8kFgqq0aou05qm1hbIPv0ircUEpimM12DD5lfvmVAFhM5yqRod/DQjgFX2bJDD9NRCgBDRs5L5cw==", "dev": true, "dependencies": { "adm-zip": "^0.4.9", @@ -1357,6 +1348,15 @@ "uuid": "^3.2.1" } }, + "node_modules/@rocket.chat/apps-engine/node_modules/semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true, + "bin": { + "semver": "bin/semver" + } + }, "node_modules/@types/node": { "version": "14.14.6", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.6.tgz", @@ -1885,15 +1885,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/conf/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true, - "bin": { - "semver": "bin/semver.js" - } - }, "node_modules/cross-spawn": { "version": "6.0.5", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", @@ -1910,6 +1901,15 @@ "node": ">=4.8" } }, + "node_modules/cross-spawn/node_modules/semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true, + "bin": { + "semver": "bin/semver" + } + }, "node_modules/cryptiles": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-4.1.3.tgz", @@ -1933,9 +1933,9 @@ } }, "node_modules/debug": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", - "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, "dependencies": { "ms": "2.1.2" @@ -2548,9 +2548,9 @@ } }, "node_modules/inquirer/node_modules/ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", + "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", "dev": true, "engines": { "node": ">=6" @@ -2857,15 +2857,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/make-dir/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true, - "bin": { - "semver": "bin/semver.js" - } - }, "node_modules/merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", @@ -2898,26 +2889,17 @@ } }, "node_modules/mime-types": { - "version": "2.1.34", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", - "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", "dev": true, "dependencies": { - "mime-db": "1.51.0" + "mime-db": "1.52.0" }, "engines": { "node": ">= 0.6" } }, - "node_modules/mime-types/node_modules/mime-db": { - "version": "1.51.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", - "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==", - "dev": true, - "engines": { - "node": ">= 0.6" - } - }, "node_modules/mimic-fn": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", @@ -2928,9 +2910,9 @@ } }, "node_modules/minimatch": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.5.tgz", - "integrity": "sha512-tUpxzX0VAzJHjLu0xUfFv1gwVp9ba3IOuRAVH2EGuRW8a5emA2FlACLqiT/lDVtS1W+TGNwqz3sWaNyLgDJWuw==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "dependencies": { "brace-expansion": "^1.1.7" @@ -3406,12 +3388,12 @@ "dev": true }, "node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", "dev": true, "bin": { - "semver": "bin/semver" + "semver": "bin/semver.js" } }, "node_modules/shebang-command": { @@ -3665,6 +3647,15 @@ "typescript": ">=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev || >=3.0.0-dev || >= 3.1.0-dev || >= 3.2.0-dev" } }, + "node_modules/tslint/node_modules/semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true, + "bin": { + "semver": "bin/semver" + } + }, "node_modules/tsutils": { "version": "2.29.0", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", @@ -3708,9 +3699,9 @@ } }, "node_modules/typescript": { - "version": "4.5.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", - "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.2.tgz", + "integrity": "sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -4258,9 +4249,9 @@ }, "dependencies": { "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", + "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", "dev": true }, "chalk": { @@ -4621,9 +4612,9 @@ }, "dependencies": { "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", + "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", "dev": true }, "emoji-regex": { @@ -4948,12 +4939,6 @@ "yazl": "^2.5.1" }, "dependencies": { - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true - }, "typescript": { "version": "3.9.10", "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", @@ -4988,9 +4973,9 @@ } }, "@rocket.chat/apps-engine": { - "version": "1.30.0", - "resolved": "https://registry.npmjs.org/@rocket.chat/apps-engine/-/apps-engine-1.30.0.tgz", - "integrity": "sha512-04X4nQPgZEz9w4b/8zCyW+EVixfzdrugW4u6YUYnB4tc9lDALawSvhz88XlDGvKwbsUKFfSx6ejdhASwSssPcA==", + "version": "1.31.0", + "resolved": "https://registry.npmjs.org/@rocket.chat/apps-engine/-/apps-engine-1.31.0.tgz", + "integrity": "sha512-OAPSjqqFvX8kFgqq0aou05qm1hbIPv0ircUEpimM12DD5lfvmVAFhM5yqRod/DQjgFX2bJDD9NRCgBDRs5L5cw==", "dev": true, "requires": { "adm-zip": "^0.4.9", @@ -4999,6 +4984,14 @@ "semver": "^5.5.0", "stack-trace": "0.0.10", "uuid": "^3.2.1" + }, + "dependencies": { + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + } } }, "@types/node": { @@ -5410,14 +5403,6 @@ "pkg-up": "^3.0.1", "semver": "^6.2.0", "write-file-atomic": "^3.0.0" - }, - "dependencies": { - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true - } } }, "cross-spawn": { @@ -5431,6 +5416,14 @@ "semver": "^5.5.0", "shebang-command": "^1.2.0", "which": "^1.2.9" + }, + "dependencies": { + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + } } }, "cryptiles": { @@ -5452,9 +5445,9 @@ } }, "debug": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", - "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, "requires": { "ms": "2.1.2" @@ -5821,9 +5814,9 @@ "dev": true }, "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", + "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", "dev": true }, "figures": { @@ -6170,14 +6163,6 @@ "dev": true, "requires": { "semver": "^6.0.0" - }, - "dependencies": { - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true - } } }, "merge2": { @@ -6203,20 +6188,12 @@ "dev": true }, "mime-types": { - "version": "2.1.34", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", - "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", "dev": true, "requires": { - "mime-db": "1.51.0" - }, - "dependencies": { - "mime-db": { - "version": "1.51.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", - "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==", - "dev": true - } + "mime-db": "1.52.0" } }, "mimic-fn": { @@ -6226,9 +6203,9 @@ "dev": true }, "minimatch": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.5.tgz", - "integrity": "sha512-tUpxzX0VAzJHjLu0xUfFv1gwVp9ba3IOuRAVH2EGuRW8a5emA2FlACLqiT/lDVtS1W+TGNwqz3sWaNyLgDJWuw==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "requires": { "brace-expansion": "^1.1.7" @@ -6564,9 +6541,9 @@ "dev": true }, "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", "dev": true }, "shebang-command": { @@ -6747,6 +6724,14 @@ "semver": "^5.3.0", "tslib": "^1.8.0", "tsutils": "^2.29.0" + }, + "dependencies": { + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + } } }, "tsutils": { @@ -6780,9 +6765,9 @@ } }, "typescript": { - "version": "4.5.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", - "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.2.tgz", + "integrity": "sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg==", "dev": true }, "universalify": { diff --git a/package.json b/package.json index ee69954..f9bee73 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,9 @@ }, "devDependencies": { "@rocket.chat/apps-cli": "1.9.0", - "@rocket.chat/apps-engine": "^1.19.0", + "@rocket.chat/apps-engine": "^1.31.0", "@types/node": "14.14.6", - "tslint": "^5.10.0", - "typescript": "^4.0.5" + "tslint": "^5.20.1", + "typescript": "^4.6.2" } } diff --git a/src/endpoints/Context.ts b/src/endpoints/Context.ts index 3e0a49b..251c561 100644 --- a/src/endpoints/Context.ts +++ b/src/endpoints/Context.ts @@ -1,5 +1,6 @@ import { IHttp, + ILogger, IModify, IPersistence, IRead, @@ -22,6 +23,7 @@ export class Context { public readonly modify: IModify; public readonly http: IHttp; public readonly persis: IPersistence; + public readonly log: ILogger; constructor( request: IApiRequest, endpoint: IApiEndpointInfo, @@ -29,8 +31,9 @@ export class Context { modify: IModify, http: IHttp, persis: IPersistence, + log: ILogger, ) { - this.rc = new RcSdk(http, read); + this.rc = new RcSdk(http, read, log); this.store = new Store(read, persis); this.request = request; this.endpoint = endpoint; @@ -38,6 +41,7 @@ export class Context { this.modify = modify; this.http = http; this.persis = persis; + this.log = log; } public id(): string { diff --git a/src/endpoints/ScimEndpoint.ts b/src/endpoints/ScimEndpoint.ts index 3e6eae4..745fdb0 100644 --- a/src/endpoints/ScimEndpoint.ts +++ b/src/endpoints/ScimEndpoint.ts @@ -117,6 +117,7 @@ export abstract class ScimEndpoint extends ApiEndpoint { http: IHttp, persis: IPersistence, ): Promise => { + const logger = this.app.getLogger(); try { const ctx = new Context( request, @@ -125,9 +126,16 @@ export abstract class ScimEndpoint extends ApiEndpoint { modify, http, persis, + logger, ); await ctx.checkAuth(); - return await method.bind(this)(ctx); + logger.debug( + `SCIM Request ${name.toUpperCase()} /${this.path}`, + request.content, + ); + const response = await method.bind(this)(ctx); + logger.debug("SCIM Response", response); + return response; } catch (e) { let err: SCIMError; if (e.toSCIMError && typeof e.toSCIMError === "function") { @@ -138,7 +146,7 @@ export abstract class ScimEndpoint extends ApiEndpoint { .setScimType(SCIMErrorType.INVALID_VALUE) .setDetail(e.message); } - + logger.error(e); return this.error(err); } }; diff --git a/src/rc-sdk/RcSdk.ts b/src/rc-sdk/RcSdk.ts index 07b24a3..dc9493e 100644 --- a/src/rc-sdk/RcSdk.ts +++ b/src/rc-sdk/RcSdk.ts @@ -2,6 +2,7 @@ import { IHttp, IHttpRequest, IHttpResponse, + ILogger, IRead, } from "@rocket.chat/apps-engine/definition/accessors"; import { EmptyResponseError } from "../errors/EmptyResponseError"; @@ -9,53 +10,45 @@ import { JsonParseError } from "../errors/JsonParseError"; import { RcSdkTeam } from "./RcSdkTeam"; import { RcSdkUser } from "./RcSdkUser"; +type RequestCallback = ( + url: string, + options: IHttpRequest, +) => Promise; + export class RcSdk { public user: RcSdkUser; public team: RcSdkTeam; private readonly baseUrl = "http://localhost:3000/api/v1"; private readonly http: IHttp; private readonly read: IRead; + private readonly logger: ILogger; - constructor(http: IHttp, read: IRead) { + constructor(http: IHttp, read: IRead, logger: ILogger) { this.http = http; this.read = read; + this.logger = logger; this.user = new RcSdkUser(this); this.team = new RcSdkTeam(this); } - public async get(url: string, content?: any): Promise { - return this.http.get( - this.buildUrl(url), - await this.buildOptions(content), - ); + public get(url: string, content?: any): Promise { + return this.request(this.http.get, url, content); } - public async post(url: string, content?: any): Promise { - return this.http.post( - this.buildUrl(url), - await this.buildOptions(content), - ); + public post(url: string, content?: any): Promise { + return this.request(this.http.post, url, content); } - public async put(url: string, content?: any): Promise { - return this.http.put( - this.buildUrl(url), - await this.buildOptions(content), - ); + public put(url: string, content?: any): Promise { + return this.request(this.http.put, url, content); } - public async del(url: string, content?: any): Promise { - return this.http.del( - this.buildUrl(url), - await this.buildOptions(content), - ); + public del(url: string, content?: any): Promise { + return this.request(this.http.del, url, content); } - public async patch(url: string, content?: any): Promise { - return this.http.patch( - this.buildUrl(url), - await this.buildOptions(content), - ); + public patch(url: string, content?: any): Promise { + return this.request(this.http.patch, url, content); } public parseResponse(response: IHttpResponse): any { @@ -98,4 +91,19 @@ export class RcSdk { } return options; } + + private async request( + method: RequestCallback, + url: string, + content?: any, + ): Promise { + this.logger.debug(`API Request ${url}`, content); + const response = await method.bind(this.http)( + this.buildUrl(url), + await this.buildOptions(content), + ); + const o = this.parseResponse(response); + this.logger.debug(`API Response`, o); + return o; + } } diff --git a/src/rc-sdk/RcSdkTeam.ts b/src/rc-sdk/RcSdkTeam.ts index 0a9db37..e5dba73 100644 --- a/src/rc-sdk/RcSdkTeam.ts +++ b/src/rc-sdk/RcSdkTeam.ts @@ -91,42 +91,35 @@ export class RcSdkTeam { this.sdk = sdk; } - public async listAll(): Promise { - const response = await this.sdk.get(`teams.listAll`); - return this.sdk.parseResponse(response); + public listAll(): Promise { + return this.sdk.get(`teams.listAll`); } - public async members(teamId: string): Promise { - const response = await this.sdk.get(`teams.members?teamId=${teamId}`); - return this.sdk.parseResponse(response); + public members(teamId: string): Promise { + return this.sdk.get(`teams.members?teamId=${teamId}`); } - public async info(teamId: string): Promise { - const response = await this.sdk.get(`teams.info?teamId=${teamId}`); - return this.sdk.parseResponse(response); + public info(teamId: string): Promise { + return this.sdk.get(`teams.info?teamId=${teamId}`); } - public async delete(body: ITeamDeleteBody): Promise { - const response = await this.sdk.post(`teams.delete`, body); - return this.sdk.parseResponse(response); + public delete(body: ITeamDeleteBody): Promise { + return this.sdk.post(`teams.delete`, body); } - public async create(body: ITeamCreateBody): Promise { - const response = await this.sdk.post(`teams.create`, body); - return this.sdk.parseResponse(response); + public create(body: ITeamCreateBody): Promise { + return this.sdk.post(`teams.create`, body); } - public async removeMember( + public removeMember( body: ITeamRemoveMemberBody, ): Promise { - const response = await this.sdk.post(`teams.removeMember`, body); - return this.sdk.parseResponse(response); + return this.sdk.post(`teams.removeMember`, body); } - public async addMembers( + public addMembers( body: ITeamAddMemberBody, ): Promise { - const response = await this.sdk.post(`teams.addMembers`, body); - return this.sdk.parseResponse(response); + return this.sdk.post(`teams.addMembers`, body); } } diff --git a/src/rc-sdk/RcSdkUser.ts b/src/rc-sdk/RcSdkUser.ts index e66a0e7..ef4b5b6 100644 --- a/src/rc-sdk/RcSdkUser.ts +++ b/src/rc-sdk/RcSdkUser.ts @@ -72,30 +72,25 @@ export class RcSdkUser { this.sdk = sdk; } - public async list(): Promise { - const response = await this.sdk.get( + public list(): Promise { + return this.sdk.get( `users.list?query={"type":{"$eq":"user"}}&fields={"createdAt":1}`, ); - return this.sdk.parseResponse(response); } - public async info(userId: string): Promise { - const response = await this.sdk.get(`users.info?userId=${userId}`); - return this.sdk.parseResponse(response); + public info(userId: string): Promise { + return this.sdk.get(`users.info?userId=${userId}`); } - public async update(body: IUserUpdate): Promise { - const response = await this.sdk.post(`users.update`, body); - return this.sdk.parseResponse(response); + public update(body: IUserUpdate): Promise { + return this.sdk.post(`users.update`, body); } - public async delete(body: IUserDelete): Promise { - const response = await this.sdk.post(`users.delete`, body); - return this.sdk.parseResponse(response); + public delete(body: IUserDelete): Promise { + return this.sdk.post(`users.delete`, body); } - public async create(body: IUserCreate): Promise { - const response = await this.sdk.post(`users.create`, body); - return this.sdk.parseResponse(response); + public create(body: IUserCreate): Promise { + return this.sdk.post(`users.create`, body); } }