From 0671a4d415744a212f0718074a67b2a7acfdf85a Mon Sep 17 00:00:00 2001 From: Samad Yar Khan Date: Sun, 5 Jun 2022 08:32:26 +0000 Subject: [PATCH 01/12] Initilaise RC APP --- .gitignore | 4 + README.md | 24 +- github/.editorconfig | 16 + github/.gitignore | 28 + github/.rcappsconfig | 19 + github/.vscode/extensions.json | 11 + github/GithubApp.ts | 12 + github/app.json | 15 + github/icon.png | Bin 0 -> 7110 bytes github/package-lock.json | 931 +++++++++++++++++++++++++++++++++ github/package.json | 8 + github/tsconfig.json | 17 + github/tslint.json | 15 + 13 files changed, 1098 insertions(+), 2 deletions(-) create mode 100644 github/.editorconfig create mode 100644 github/.gitignore create mode 100644 github/.rcappsconfig create mode 100644 github/.vscode/extensions.json create mode 100644 github/GithubApp.ts create mode 100644 github/app.json create mode 100644 github/icon.png create mode 100644 github/package-lock.json create mode 100644 github/package.json create mode 100644 github/tsconfig.json create mode 100644 github/tslint.json diff --git a/.gitignore b/.gitignore index 6704566..87b1378 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,7 @@ dist # TernJS port file .tern-port + +#RC Server and APP Testing +RC_SERVER +TESTING_APPS \ No newline at end of file diff --git a/README.md b/README.md index 098e2cd..68f5eee 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,22 @@ -# Apps.Github22 -The ultimate app extending Rocket.Chat for all developers collaborating on Github (2022 and beyond) +# Github +The ultimate app extending Rocket.Chat for all developers collaborating on Github + +## Getting Started +Now that you have generated a blank default Rocket.Chat App, what are you supposed to do next? +Start developing! Open up your favorite editor, our recommended one is Visual Studio code, +and start working on your App. Once you have something ready to test, you can either +package it up and manually deploy it to your test instance or you can use the CLI to do so. +Here are some commands to get started: +- `rc-apps package`: this command will generate a packaged app file (zip) which can be installed **if** it compiles with TypeScript +- `rc-apps deploy`: this will do what `package` does but will then ask you for your server url, username, and password to deploy it for you + +## Documentation +Here are some links to examples and documentation: +- [Rocket.Chat Apps TypeScript Definitions Documentation](https://rocketchat.github.io/Rocket.Chat.Apps-engine/) +- [Rocket.Chat Apps TypeScript Definitions Repository](https://github.com/RocketChat/Rocket.Chat.Apps-engine) +- [Example Rocket.Chat Apps](https://github.com/graywolf336/RocketChatApps) +- Community Forums + - [App Requests](https://forums.rocket.chat/c/rocket-chat-apps/requests) + - [App Guides](https://forums.rocket.chat/c/rocket-chat-apps/guides) + - [Top View of Both Categories](https://forums.rocket.chat/c/rocket-chat-apps) +- [#rocketchat-apps on Open.Rocket.Chat](https://open.rocket.chat/channel/rocketchat-apps) diff --git a/github/.editorconfig b/github/.editorconfig new file mode 100644 index 0000000..a1166f2 --- /dev/null +++ b/github/.editorconfig @@ -0,0 +1,16 @@ +# EditorConfig is awesome: http://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +indent_style = space +indent_size = 4 +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false diff --git a/github/.gitignore b/github/.gitignore new file mode 100644 index 0000000..a461715 --- /dev/null +++ b/github/.gitignore @@ -0,0 +1,28 @@ +# ignore modules pulled in from npm +node_modules/ + +# rc-apps package output +dist/ + +# JetBrains IDEs +out/ +.idea/ +.idea_modules/ + +# macOS +.DS_Store +.AppleDouble +.LSOverride +._* +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk diff --git a/github/.rcappsconfig b/github/.rcappsconfig new file mode 100644 index 0000000..f9892ff --- /dev/null +++ b/github/.rcappsconfig @@ -0,0 +1,19 @@ +{ + "url": "http://localhost:3000", + "username": "", + "password": "", + "ignoredFiles": [ + "**/README.md", + "**/package-lock.json", + "**/package.json", + "**/tslint.json", + "**/tsconfig.json", + "**/*.js", + "**/*.js.map", + "**/*.d.ts", + "**/*.spec.ts", + "**/*.test.ts", + "**/dist/**", + "**/.*" + ] +} \ No newline at end of file diff --git a/github/.vscode/extensions.json b/github/.vscode/extensions.json new file mode 100644 index 0000000..b1e1592 --- /dev/null +++ b/github/.vscode/extensions.json @@ -0,0 +1,11 @@ + { + "recommendations": [ + "EditorConfig.editorconfig", + "eamodio.gitlens", + "eg2.vscode-npm-script", + "wayou.vscode-todo-highlight", + "minhthai.vscode-todo-parser", + "ms-vscode.vscode-typescript-tslint-plugin", + "rbbit.typescript-hero" + ] +} diff --git a/github/GithubApp.ts b/github/GithubApp.ts new file mode 100644 index 0000000..64d3ba4 --- /dev/null +++ b/github/GithubApp.ts @@ -0,0 +1,12 @@ +import { + IAppAccessors, + ILogger, +} from '@rocket.chat/apps-engine/definition/accessors'; +import { App } from '@rocket.chat/apps-engine/definition/App'; +import { IAppInfo } from '@rocket.chat/apps-engine/definition/metadata'; + +export class GithubApp extends App { + constructor(info: IAppInfo, logger: ILogger, accessors: IAppAccessors) { + super(info, logger, accessors); + } +} diff --git a/github/app.json b/github/app.json new file mode 100644 index 0000000..a65f5da --- /dev/null +++ b/github/app.json @@ -0,0 +1,15 @@ +{ + "id": "826f0d95-9e25-48a6-a781-a32f147230a5", + "version": "0.0.1", + "requiredApiVersion": "^1.4.0", + "iconFile": "icon.png", + "author": { + "name": "Samad Yar Khan", + "homepage": "https://github.com/samad-yar-khan", + "support": "https://github.com/samad-yar-khan" + }, + "name": "Github", + "nameSlug": "github", + "classFile": "GithubApp.ts", + "description": "The ultimate app extending Rocket.Chat for all developers collaborating on Github" +} \ No newline at end of file diff --git a/github/icon.png b/github/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..081af6c521815bb7c54725b862b9b0c299308b8a GIT binary patch literal 7110 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.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.16.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", + "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight": { + "version": "7.17.12", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.17.12.tgz", + "integrity": "sha512-7yykMVF3hfZY2jsHZEEgLc+3x4o1O+fYyULu11GynEUQNwB6lua+IIQn1FiJxNucd5UlyJryrwsOh8PL9Sn8Qg==", + "dev": true, + "dependencies": { + "@babel/helper-validator-identifier": "^7.16.7", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@rocket.chat/apps-engine": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/@rocket.chat/apps-engine/-/apps-engine-1.32.0.tgz", + "integrity": "sha512-K+5NJto1BfO0NFiJX048tAWJqNQjdHGg5YPB24MQ/cDq206hDPnJakihF02LgardAQShIK3TIw2MnKgX1CB2/w==", + "dev": true, + "dependencies": { + "adm-zip": "^0.4.9", + "cryptiles": "^4.1.3", + "lodash.clonedeep": "^4.5.0", + "semver": "^5.5.0", + "stack-trace": "0.0.10", + "uuid": "^3.2.1" + } + }, + "node_modules/@types/node": { + "version": "14.14.6", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.6.tgz", + "integrity": "sha512-6QlRuqsQ/Ox/aJEQWBEJG7A9+u7oSYl3mem/K8IzxXG/kAGbV1YPD9Bg9Zw3vyxC/YP+zONKwy8hGkSt1jxFMw==", + "dev": true + }, + "node_modules/adm-zip": { + "version": "0.4.16", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.16.tgz", + "integrity": "sha512-TFi4HBKSGfIKsK5YCkKaaFG2m4PEDyViZmEwof3MTIgzimHLto6muaHVpbrljdIvIrFZzEq/p4nafOeLcYegrg==", + "dev": true, + "engines": { + "node": ">=0.3.0" + } + }, + "node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/boom": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/boom/-/boom-7.3.0.tgz", + "integrity": "sha512-Swpoyi2t5+GhOEGw8rEsKvTxFLIDiiKoUc2gsoV6Lyr43LHBIzch3k2MvYUs8RTROrIkVJ3Al0TkaOGjnb+B6A==", + "deprecated": "This module has moved and is now available at @hapi/boom. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.", + "dev": true, + "dependencies": { + "hoek": "6.x.x" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha512-wxXCdllwGhI2kCC0MnvTGYTMvnVZTvqgypkiTI8Pa5tcz2i6VqsqwYGgqwXji+4RgCzms6EajE4IxiUH6HH8nQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, + "node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "node_modules/cryptiles": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-4.1.3.tgz", + "integrity": "sha512-gT9nyTMSUC1JnziQpPbxKGBbUg8VL7Zn2NB4E1cJYvuXdElHrwxrV9bmltZGDzet45zSDGyYceueke1TjynGzw==", + "deprecated": "This module has moved and is now available at @hapi/cryptiles. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.", + "dev": true, + "dependencies": { + "boom": "7.x.x" + } + }, + "node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true, + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, + "node_modules/function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/hoek": { + "version": "6.1.3", + "resolved": "https://registry.npmjs.org/hoek/-/hoek-6.1.3.tgz", + "integrity": "sha512-YXXAAhmF9zpQbC7LEcREFtXfGq5K1fmd+4PHkBq8NUqmzW3G+Dq10bI/i0KucLRwss3YYFQ0fSfoxBZYiGUqtQ==", + "deprecated": "This module has moved and is now available at @hapi/hoek. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.", + "dev": true + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/is-core-module": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz", + "integrity": "sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==", + "dev": true, + "dependencies": { + "has": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/lodash.clonedeep": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", + "integrity": "sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==", + "dev": true + }, + "node_modules/minimatch": { + "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" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", + "dev": true + }, + "node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "node_modules/resolve": { + "version": "1.22.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz", + "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==", + "dev": true, + "dependencies": { + "is-core-module": "^2.8.1", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "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/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "node_modules/stack-trace": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", + "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + }, + "node_modules/tslint": { + "version": "5.20.1", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.1.tgz", + "integrity": "sha512-EcMxhzCFt8k+/UP5r8waCf/lzmeSyVlqxqMEDQE7rWYiQky8KpIBz1JAoYXfROHrPZ1XXd43q8yQnULOLiBRQg==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.0.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^4.0.1", + "glob": "^7.1.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" + }, + "bin": { + "tslint": "bin/tslint" + }, + "engines": { + "node": ">=4.8.0" + }, + "peerDependencies": { + "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/tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "dev": true, + "dependencies": { + "tslib": "^1.8.1" + }, + "peerDependencies": { + "typescript": ">=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=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" + } + }, + "node_modules/typescript": { + "version": "4.7.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.3.tgz", + "integrity": "sha512-WOkT3XYvrpXx4vMMqlD+8R8R37fZkjyLGlxavMc4iB8lrl8L0DeTcHbYgw/v0N/z9wAFsgBhcsF0ruoySS22mA==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", + "dev": true, + "bin": { + "uuid": "bin/uuid" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + } + }, + "dependencies": { + "@babel/code-frame": { + "version": "7.16.7", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.7.tgz", + "integrity": "sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg==", + "dev": true, + "requires": { + "@babel/highlight": "^7.16.7" + } + }, + "@babel/helper-validator-identifier": { + "version": "7.16.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", + "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", + "dev": true + }, + "@babel/highlight": { + "version": "7.17.12", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.17.12.tgz", + "integrity": "sha512-7yykMVF3hfZY2jsHZEEgLc+3x4o1O+fYyULu11GynEUQNwB6lua+IIQn1FiJxNucd5UlyJryrwsOh8PL9Sn8Qg==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.16.7", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + } + }, + "@rocket.chat/apps-engine": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/@rocket.chat/apps-engine/-/apps-engine-1.32.0.tgz", + "integrity": "sha512-K+5NJto1BfO0NFiJX048tAWJqNQjdHGg5YPB24MQ/cDq206hDPnJakihF02LgardAQShIK3TIw2MnKgX1CB2/w==", + "dev": true, + "requires": { + "adm-zip": "^0.4.9", + "cryptiles": "^4.1.3", + "lodash.clonedeep": "^4.5.0", + "semver": "^5.5.0", + "stack-trace": "0.0.10", + "uuid": "^3.2.1" + } + }, + "@types/node": { + "version": "14.14.6", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.6.tgz", + "integrity": "sha512-6QlRuqsQ/Ox/aJEQWBEJG7A9+u7oSYl3mem/K8IzxXG/kAGbV1YPD9Bg9Zw3vyxC/YP+zONKwy8hGkSt1jxFMw==", + "dev": true + }, + "adm-zip": { + "version": "0.4.16", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.16.tgz", + "integrity": "sha512-TFi4HBKSGfIKsK5YCkKaaFG2m4PEDyViZmEwof3MTIgzimHLto6muaHVpbrljdIvIrFZzEq/p4nafOeLcYegrg==", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "boom": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/boom/-/boom-7.3.0.tgz", + "integrity": "sha512-Swpoyi2t5+GhOEGw8rEsKvTxFLIDiiKoUc2gsoV6Lyr43LHBIzch3k2MvYUs8RTROrIkVJ3Al0TkaOGjnb+B6A==", + "dev": true, + "requires": { + "hoek": "6.x.x" + } + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha512-wxXCdllwGhI2kCC0MnvTGYTMvnVZTvqgypkiTI8Pa5tcz2i6VqsqwYGgqwXji+4RgCzms6EajE4IxiUH6HH8nQ==", + "dev": true + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "cryptiles": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-4.1.3.tgz", + "integrity": "sha512-gT9nyTMSUC1JnziQpPbxKGBbUg8VL7Zn2NB4E1cJYvuXdElHrwxrV9bmltZGDzet45zSDGyYceueke1TjynGzw==", + "dev": true, + "requires": { + "boom": "7.x.x" + } + }, + "diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true + }, + "hoek": { + "version": "6.1.3", + "resolved": "https://registry.npmjs.org/hoek/-/hoek-6.1.3.tgz", + "integrity": "sha512-YXXAAhmF9zpQbC7LEcREFtXfGq5K1fmd+4PHkBq8NUqmzW3G+Dq10bI/i0KucLRwss3YYFQ0fSfoxBZYiGUqtQ==", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "is-core-module": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz", + "integrity": "sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "lodash.clonedeep": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", + "integrity": "sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==", + "dev": true + }, + "minimatch": { + "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" + } + }, + "minimist": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", + "dev": true + }, + "mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "requires": { + "minimist": "^1.2.6" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true + }, + "path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "resolve": { + "version": "1.22.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz", + "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==", + "dev": true, + "requires": { + "is-core-module": "^2.8.1", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + } + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "stack-trace": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", + "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true + }, + "tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + }, + "tslint": { + "version": "5.20.1", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.1.tgz", + "integrity": "sha512-EcMxhzCFt8k+/UP5r8waCf/lzmeSyVlqxqMEDQE7rWYiQky8KpIBz1JAoYXfROHrPZ1XXd43q8yQnULOLiBRQg==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^4.0.1", + "glob": "^7.1.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" + } + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + } + }, + "typescript": { + "version": "4.7.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.3.tgz", + "integrity": "sha512-WOkT3XYvrpXx4vMMqlD+8R8R37fZkjyLGlxavMc4iB8lrl8L0DeTcHbYgw/v0N/z9wAFsgBhcsF0ruoySS22mA==", + "dev": true + }, + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + } + } +} diff --git a/github/package.json b/github/package.json new file mode 100644 index 0000000..866f402 --- /dev/null +++ b/github/package.json @@ -0,0 +1,8 @@ +{ + "devDependencies": { + "@rocket.chat/apps-engine": "^1.19.0", + "@types/node": "14.14.6", + "tslint": "^5.10.0", + "typescript": "^4.0.5" + } +} \ No newline at end of file diff --git a/github/tsconfig.json b/github/tsconfig.json new file mode 100644 index 0000000..3f5d85a --- /dev/null +++ b/github/tsconfig.json @@ -0,0 +1,17 @@ +{ +"compilerOptions": { + "target": "es2017", + "module": "commonjs", + "moduleResolution": "node", + "declaration": false, + "noImplicitAny": false, + "removeComments": true, + "strictNullChecks": true, + "noImplicitReturns": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + }, +"include": [ + "**/*.ts" + ] +} diff --git a/github/tslint.json b/github/tslint.json new file mode 100644 index 0000000..b01606a --- /dev/null +++ b/github/tslint.json @@ -0,0 +1,15 @@ +{ + "extends": "tslint:recommended", + "rules": { + "array-type": [true, "generic"], + "member-access": true, + "no-console": [false], + "no-duplicate-variable": true, + "object-literal-sort-keys": false, + "quotemark": [true, "single"], + "max-line-length": [true, { + "limit": 160, + "ignore-pattern": "^import | *export .*? {" + }] + } +} From db75653763f5290710e0525addf8ce87622f86e8 Mon Sep 17 00:00:00 2001 From: Samad Yar Khan Date: Sun, 5 Jun 2022 10:55:20 +0000 Subject: [PATCH 02/12] Make message templates - issues, pulls, repodata , contributors --- github/GithubApp.ts | 1 + github/commands/GithubCommands.ts | 209 +++++++++++++++++++++++++++ github/lib/RepoDataMessage.ts | 74 ++++++++++ github/lib/contributorListMessage.ts | 58 ++++++++ github/lib/initiatorMessage.ts | 85 +++++++++++ github/lib/issuesListMessage.ts | 60 ++++++++ github/lib/pullReqeustListMessage.ts | 59 ++++++++ 7 files changed, 546 insertions(+) create mode 100644 github/commands/GithubCommands.ts create mode 100644 github/lib/RepoDataMessage.ts create mode 100644 github/lib/contributorListMessage.ts create mode 100644 github/lib/initiatorMessage.ts create mode 100644 github/lib/issuesListMessage.ts create mode 100644 github/lib/pullReqeustListMessage.ts diff --git a/github/GithubApp.ts b/github/GithubApp.ts index 64d3ba4..99ca74d 100644 --- a/github/GithubApp.ts +++ b/github/GithubApp.ts @@ -9,4 +9,5 @@ export class GithubApp extends App { constructor(info: IAppInfo, logger: ILogger, accessors: IAppAccessors) { super(info, logger, accessors); } + } diff --git a/github/commands/GithubCommands.ts b/github/commands/GithubCommands.ts new file mode 100644 index 0000000..9ffe4b6 --- /dev/null +++ b/github/commands/GithubCommands.ts @@ -0,0 +1,209 @@ +import { + ISlashCommand, + SlashCommandContext, +} from "@rocket.chat/apps-engine/definition/slashcommands"; +import { + IHttp, + IMessageBuilder, + IModify, + IModifyCreator, + IPersistence, + IRead, +} from "@rocket.chat/apps-engine/definition/accessors"; + +import { GithubApp } from "../GithubApp"; +import { IMessage } from "@rocket.chat/apps-engine/definition/messages"; +import { IRoom } from "@rocket.chat/apps-engine/definition/rooms"; +import { IUser } from "@rocket.chat/apps-engine/definition/users"; +import { initiatorMessage } from "../lib/initiatorMessage"; +import { issueListMessage } from "../lib/issuesListMessage"; +// import { AppPersistence } from "../lib/persistence"; +// import { GithubSDK } from "../lib/githubsdk"; +// import { sendNotification } from "../lib/helpers/sendNotification"; +// import { getWebhookUrl } from "../lib/helpers/getWebhookUrl"; +// import { toDoModal } from "../modals/toDoModal"; +// import { addTokenModal } from "../modals/AddTokenModal"; + +export class GithubCommand implements ISlashCommand { + public constructor(private readonly app: GithubApp) {} + public command = "github"; + public i18nDescription = "fetching githup data"; + public providesPreview = false; + public i18nParamsExample = ""; + + public async executor( + context: SlashCommandContext, + read: IRead, + modify: IModify, + http: IHttp, + persistence: IPersistence + ): Promise { + // const creator: IModifyCreator = modify.getCreator() + // const sender: IUser = (await read.getUserReader().getAppUser()) as IUser + // const room: IRoom = context.getRoom() + // const messageTemplate: IMessage = { + // text: 'Github App working !', + // sender, + // room + // } + // const messageBuilder: IMessageBuilder = creator.startMessage(messageTemplate) + // await creator.finish(messageBuilder) + const command = context.getArguments(); + + + const sender = context.getSender(); // the user calling the slashcommand + const room = context.getRoom(); // the current room + + const data = { + room: room, + sender: sender, + arguments: command, + }; + + if (Array.isArray(command) && command.length === 1) { + + + await initiatorMessage({ data, read, persistence, modify, http }); + + } else if (Array.isArray(command) && command.length === 2) { + const subcommand = command[0]; + const subcommand2 = command[1]; + + switch (subcommand2) { + case "issues": { + await issueListMessage({context,read,persistence,modify,http}); + break; + } + case "contributors": { + const repository = command[0]; + const gitResponse = await http.get( + `https://api.github.com/repos/${repository}/contributors` + ); + const resData = gitResponse.data; + const room: IRoom = context.getRoom(); + const textSender = await modify + .getCreator() + .startMessage() + .setText(`*CONTRIBUTOR LIST*`); + + if (room) { + textSender.setRoom(room); + } + + await modify.getCreator().finish(textSender); + resData.forEach(async (contributor, ind) => { + if (ind < 20) { + const login = contributor.login; + const html_url = contributor.html_url; + + const textSender = await modify + .getCreator() + .startMessage() + .setText(`[ ${login} ](${html_url})`); + + if (room) { + textSender.setRoom(room); + } + + await modify.getCreator().finish(textSender); + } + }); + break; + } + case "pulls": { + const repository = command[0]; + const gitResponse = await http.get( + `https://api.github.com/repos/${repository}/contributors` + ); + const resData = gitResponse.data; + const room: IRoom = context.getRoom(); + const textSender = await modify + .getCreator() + .startMessage() + .setText(`*PULL REQUESTS*`); + + if (room) { + textSender.setRoom(room); + } + + await modify.getCreator().finish(textSender); + resData.forEach(async (pull, ind) => { + if (ind < 10) { + const title = pull.title; + const url = pull.html_url; + + const textSender = await modify + .getCreator() + .startMessage() + .setText( + `[ #${pull.number} ](${url}) *${pull.title}*` + ); + + if (room) { + textSender.setRoom(room); + } + + await modify.getCreator().finish(textSender); + } + }); + break; + } + case "repo": { + const repository = command[0]; + const gitResponse = await http.get( + `https://api.github.com/repos/${repository}` + ); + const resData = gitResponse.data; + const room: IRoom = context.getRoom(); + const fullName = + "[" + + resData.full_name + + "](" + + resData.html_url + + ")" + + " ▫️ "; + const stars = + "` ⭐ Stars " + resData.stargazers_count + " ` "; + const issues = "` ❗ Issues " + resData.open_issues + " ` "; + const forks = "` 🍴 Forks " + resData.forks_count + " ` "; + let tags = ""; + if ( + resData && + resData.topics && + Array.isArray(resData.topics) + ) { + resData.topics.forEach((topic: string) => { + let tempTopic = " ` "; + tempTopic += topic; + tempTopic += " ` "; + tags += tempTopic; + }); + } + + const textSender = await modify + .getCreator() + .startMessage() + .setText( + fullName + + stars + + issues + + forks + + "```" + + resData.description + + "```" + + tags + ); + if (room) { + textSender.setRoom(room); + } + await modify.getCreator().finish(textSender); + break; + } + default: + throw new Error("Error!"); + } + } + + + } +} \ No newline at end of file diff --git a/github/lib/RepoDataMessage.ts b/github/lib/RepoDataMessage.ts new file mode 100644 index 0000000..f1a04a9 --- /dev/null +++ b/github/lib/RepoDataMessage.ts @@ -0,0 +1,74 @@ +import { + IHttp, + IModify, + IPersistence, + IRead, +} from "@rocket.chat/apps-engine/definition/accessors"; +import { IRoom } from "@rocket.chat/apps-engine/definition/rooms"; +import { + SlashCommandContext, +} from "@rocket.chat/apps-engine/definition/slashcommands"; + +export async function pullRequestListMessage({ + context, + read, + persistence, + modify, + http, +}: { + context: SlashCommandContext; + read: IRead; + persistence: IPersistence; + modify: IModify; + http: IHttp; +}) { + const command = context.getArguments(); + const repository = command[0]; + const gitResponse = await http.get( + `https://api.github.com/repos/${repository}` + ); + const resData = gitResponse.data; + const room: IRoom = context.getRoom(); + const fullName = + "[" + + resData.full_name + + "](" + + resData.html_url + + ")" + + " ▫️ "; + const stars = + "` ⭐ Stars " + resData.stargazers_count + " ` "; + const issues = "` ❗ Issues " + resData.open_issues + " ` "; + const forks = "` 🍴 Forks " + resData.forks_count + " ` "; + let tags = ""; + if ( + resData && + resData.topics && + Array.isArray(resData.topics) + ) { + resData.topics.forEach((topic: string) => { + let tempTopic = " ` "; + tempTopic += topic; + tempTopic += " ` "; + tags += tempTopic; + }); + } + + const textSender = await modify + .getCreator() + .startMessage() + .setText( + fullName + + stars + + issues + + forks + + "```" + + resData.description + + "```" + + tags + ); + if (room) { + textSender.setRoom(room); + } + await modify.getCreator().finish(textSender); +} \ No newline at end of file diff --git a/github/lib/contributorListMessage.ts b/github/lib/contributorListMessage.ts new file mode 100644 index 0000000..9f31784 --- /dev/null +++ b/github/lib/contributorListMessage.ts @@ -0,0 +1,58 @@ +import { + IHttp, + IModify, + IPersistence, + IRead, +} from "@rocket.chat/apps-engine/definition/accessors"; +import { IRoom } from "@rocket.chat/apps-engine/definition/rooms"; +import { SlashCommandContext } from "@rocket.chat/apps-engine/definition/slashcommands"; + +export async function issueListMessage({ + context, + read, + persistence, + modify, + http, +}: { + context: SlashCommandContext; + read: IRead; + persistence: IPersistence; + modify: IModify; + http: IHttp; +}) { + const command = context.getArguments(); + const repository = command[0]; + + const gitResponse = await http.get( + `https://api.github.com/repos/${repository}/contributors` + ); + const resData = gitResponse.data; + const room: IRoom = context.getRoom(); + const textSender = await modify + .getCreator() + .startMessage() + .setText(`*CONTRIBUTOR LIST*`); + + if (room) { + textSender.setRoom(room); + } + + await modify.getCreator().finish(textSender); + resData.forEach(async (contributor, ind) => { + if (ind < 20) { + const login = contributor.login; + const html_url = contributor.html_url; + + const textSender = await modify + .getCreator() + .startMessage() + .setText(`[ ${login} ](${html_url})`); + + if (room) { + textSender.setRoom(room); + } + + await modify.getCreator().finish(textSender); + } + }); +} diff --git a/github/lib/initiatorMessage.ts b/github/lib/initiatorMessage.ts new file mode 100644 index 0000000..c217297 --- /dev/null +++ b/github/lib/initiatorMessage.ts @@ -0,0 +1,85 @@ + +import { + IHttp, + IMessageBuilder, + IModify, + IModifyCreator, + IPersistence, + IRead +} from "@rocket.chat/apps-engine/definition/accessors"; +import { ButtonStyle } from "@rocket.chat/apps-engine/definition/uikit"; + +export async function initiatorMessage({ + data, + read, + persistence, + modify, + http, +}: { + data; + read: IRead; + persistence: IPersistence; + modify: IModify; + http: IHttp; +}) { + const greetBuilder = await modify + .getCreator() + .startMessage() + .setRoom(data.room) + .setText(`Hey _${data.sender.username}_ !`); + + if (data.room.type !== "l") { + await modify + .getNotifier() + .notifyUser(data.sender, greetBuilder.getMessage()); + } else { + await modify.getCreator().finish(greetBuilder); + } + + const builder = await modify.getCreator().startMessage().setRoom(data.room); + + const block = modify.getCreator().getBlockBuilder(); + + block.addSectionBlock({ + text: block.newPlainTextObject(`Choose Action for ${data.arguments[0]} 👇 ?`), + }); + + block.addActionsBlock({ + blockId: "githubdata", + elements: [ + block.newButtonElement({ + actionId: "githubDataSelect", + text: block.newPlainTextObject("Overview"), + value: `${data.arguments[0]}`, + style: ButtonStyle.PRIMARY, + }), + block.newButtonElement({ + actionId: "githubDataSelect", + text: block.newPlainTextObject("Issues"), + value: `${data.arguments[0]}/issues`, + style: ButtonStyle.DANGER, + }), + block.newButtonElement({ + actionId: "githubDataSelect", + text: block.newPlainTextObject("Contributors"), + value: `${data.arguments[0]}/contributors`, + style: ButtonStyle.PRIMARY, + }), + block.newButtonElement({ + actionId: "githubDataSelect", + text: block.newPlainTextObject("Pull Requests"), + value: `${data.arguments[0]}/pulls`, + style: ButtonStyle.PRIMARY, + }), + ], + }); + + builder.setBlocks(block); + + await modify + .getNotifier() + .notifyUser(data.sender, builder.getMessage()); + + + +} \ No newline at end of file diff --git a/github/lib/issuesListMessage.ts b/github/lib/issuesListMessage.ts new file mode 100644 index 0000000..010438a --- /dev/null +++ b/github/lib/issuesListMessage.ts @@ -0,0 +1,60 @@ +import { + IHttp, + IMessageBuilder, + IModify, + IModifyCreator, + IPersistence, + IRead, +} from "@rocket.chat/apps-engine/definition/accessors"; +import { IRoom } from "@rocket.chat/apps-engine/definition/rooms"; +import { + ISlashCommand, + SlashCommandContext, +} from "@rocket.chat/apps-engine/definition/slashcommands"; + +export async function issueListMessage({ + context, + read, + persistence, + modify, + http, +}: { + context: SlashCommandContext; + read: IRead; + persistence: IPersistence; + modify: IModify; + http: IHttp; +}) { + const command = context.getArguments(); + const repository = command[0]; + const gitResponse = await http.get( + `https://api.github.com/repos/${repository}/issues` + ); + const resData = gitResponse.data; + const room: IRoom = context.getRoom(); + const textSender = await modify + .getCreator() + .startMessage() + .setText(`*ISSUES LIST*`); + + if (room) { + textSender.setRoom(room); + } + let ind = 0; + await modify.getCreator().finish(textSender); + resData.forEach(async (issue) => { + if (typeof issue.pull_request === "undefined" && ind < 10) { + const textSender = await modify + .getCreator() + .startMessage() + .setText( + `[ #${issue.number} ](${issue.html_url}) *${issue.title}*` + ); + if (room) { + textSender.setRoom(room); + } + await modify.getCreator().finish(textSender); + ind++; + } + }); +} diff --git a/github/lib/pullReqeustListMessage.ts b/github/lib/pullReqeustListMessage.ts new file mode 100644 index 0000000..3bd01fc --- /dev/null +++ b/github/lib/pullReqeustListMessage.ts @@ -0,0 +1,59 @@ +import { + IHttp, + IMessageBuilder, + IModify, + IModifyCreator, + IPersistence, + IRead, +} from "@rocket.chat/apps-engine/definition/accessors"; +import { IRoom } from "@rocket.chat/apps-engine/definition/rooms"; +import { + ISlashCommand, + SlashCommandContext, +} from "@rocket.chat/apps-engine/definition/slashcommands"; + +export async function pullRequestListMessage({ + context, + read, + persistence, + modify, + http, +}: { + context: SlashCommandContext; + read: IRead; + persistence: IPersistence; + modify: IModify; + http: IHttp; +}) { + const command = context.getArguments(); + const repository = command[0]; + const gitResponse = await http.get( + `https://api.github.com/repos/${repository}/pulls` + ); + const resData = gitResponse.data; + const room: IRoom = context.getRoom(); + const textSender = await modify + .getCreator() + .startMessage() + .setText(`*PULL REQUESTS*`); + + if (room) { + textSender.setRoom(room); + } + + await modify.getCreator().finish(textSender); + resData.forEach(async (pull, ind) => { + if (ind < 10) { + const url = pull.html_url; + const textSender = await modify + .getCreator() + .startMessage() + .setText(`[ #${pull.number} ](${url}) *${pull.title}*`); + + if (room) { + textSender.setRoom(room); + } + await modify.getCreator().finish(textSender); + } + }); +} From d0d9987a882d43b3838e47beedc71caedd259ef8 Mon Sep 17 00:00:00 2001 From: Samad Yar Khan Date: Sun, 5 Jun 2022 12:01:56 +0000 Subject: [PATCH 03/12] Register Slahs commands --- github/GithubApp.ts | 209 +++++++++++++++++- github/app.json | 5 +- github/commands/GithubCommand.ts | 82 +++++++ github/commands/GithubCommands.ts | 209 ------------------ github/lib/contributorListMessage.ts | 2 +- ...{RepoDataMessage.ts => repoDataMessage.ts} | 2 +- 6 files changed, 293 insertions(+), 216 deletions(-) create mode 100644 github/commands/GithubCommand.ts delete mode 100644 github/commands/GithubCommands.ts rename github/lib/{RepoDataMessage.ts => repoDataMessage.ts} (97%) diff --git a/github/GithubApp.ts b/github/GithubApp.ts index 99ca74d..5534c26 100644 --- a/github/GithubApp.ts +++ b/github/GithubApp.ts @@ -1,13 +1,216 @@ import { IAppAccessors, + IConfigurationExtend, + IHttp, ILogger, -} from '@rocket.chat/apps-engine/definition/accessors'; -import { App } from '@rocket.chat/apps-engine/definition/App'; -import { IAppInfo } from '@rocket.chat/apps-engine/definition/metadata'; + IModify, + IPersistence, + IRead, +} from "@rocket.chat/apps-engine/definition/accessors"; +import { App } from "@rocket.chat/apps-engine/definition/App"; +import { IAppInfo } from "@rocket.chat/apps-engine/definition/metadata"; +import { GithubCommand } from "./commands/GithubCommand"; +import { ApiSecurity, ApiVisibility } from '@rocket.chat/apps-engine/definition/api'; +import { IUIKitInteractionHandler, UIKitViewCloseInteractionContext, UIKitViewSubmitInteractionContext } from '@rocket.chat/apps-engine/definition/uikit' + +import { + IMessage, + IPostMessageSent, +} from "@rocket.chat/apps-engine/definition/messages"; +import { initiatorMessage } from "./lib/initiatorMessage"; + +import { + IUIKitResponse, + UIKitLivechatBlockInteractionContext, + UIKitBlockInteractionContext, +} from "@rocket.chat/apps-engine/definition/uikit"; + + export class GithubApp extends App { constructor(info: IAppInfo, logger: ILogger, accessors: IAppAccessors) { super(info, logger, accessors); } + + public async executeBlockActionHandler( + context: UIKitBlockInteractionContext, + read: IRead, + http: IHttp, + persistence: IPersistence, + modify: IModify + ) { + + + const data = context.getInteractionData(); + + const { actionId } = data; + console.log(data); + switch (actionId) { + case "githubDataSelect": { + try { + const gitResponse = await http.get( + `https://api.github.com/repos/${data.value}` + ); + + const param = data.value; + let paramVal = ""; + if(param && param.length){ + + for(let i = param.length-1; i>=0 && data.value && data.value[i]!='/' ;i--){ + paramVal = data.value[i] + paramVal; + } + } + + const resData = gitResponse.data; + + const { room } = context.getInteractionData(); + + if (paramVal === "pulls") { + + const textSender = await modify + .getCreator() + .startMessage() + .setText(`*PULL REQUESTS*`); + + if (room) { + textSender.setRoom(room); + } + + await modify.getCreator().finish(textSender); + resData.forEach(async (pull, ind) => { + if (ind < 10) { + const title = pull.title; + const url = pull.html_url; + + const textSender = await modify + .getCreator() + .startMessage() + .setText(`[ #${pull.number} ](${url}) *${pull.title}*`); + + if (room) { + textSender.setRoom(room); + } + + await modify.getCreator().finish(textSender); + } + }); + + } else if (paramVal === "issues") { + const textSender = await modify + .getCreator() + .startMessage() + .setText(`*ISSUES LIST*`); + + if (room) { + textSender.setRoom(room); + } + let ind =0; + await modify.getCreator().finish(textSender); + resData.forEach(async (issue) => { + if (typeof issue.pull_request === "undefined" && ind < 10) { + const title = issue.title; + const url = issue.html_url; + + const textSender = await modify + .getCreator() + .startMessage() + .setText(`[ #${issue.number} ](${url}) *${issue.title}*`); + + if (room) { + textSender.setRoom(room); + } + + await modify.getCreator().finish(textSender); + ind++; + } + }); + } else if(paramVal==='contributors'){ + const textSender = await modify + .getCreator() + .startMessage() + .setText(`*CONTRIBUTOR LIST*`); + + if (room) { + textSender.setRoom(room); + } + + await modify.getCreator().finish(textSender); + resData.forEach(async (contributor, ind) => { + if (ind < 20) { + const login = contributor.login; + const html_url = contributor.html_url; + + const textSender = await modify + .getCreator() + .startMessage() + .setText(`[ ${login} ](${html_url})`); + + if (room) { + textSender.setRoom(room); + } + + await modify.getCreator().finish(textSender); + } + }); + }else{ + + const fullName = + "[" + + resData.full_name + + "](" + + resData.html_url + + ")" + + " ▫️ "; + const stars = + "` ⭐ Stars " + resData.stargazers_count + " ` "; + const issues = + "` ❗ Issues " + resData.open_issues + " ` "; + const forks = "` 🍴 Forks " + resData.forks_count + " ` "; + let tags = ""; + if(resData && resData.topics && Array.isArray(resData.topics)){ + resData.topics.forEach((topic : string) => { + let tempTopic = " ` "; + tempTopic+=topic; + tempTopic+= " ` "; + tags+= tempTopic; + }) + } + + const textSender = await modify + .getCreator() + .startMessage() + .setText(fullName + stars + issues + forks + "```" + resData.description+ "```" + tags); + if (room) { + textSender.setRoom(room); + } + await modify.getCreator().finish(textSender); + + } + + return { + success: true, + }; + } catch (err) { + console.error(err); + return { + success: false, + }; + } + } + } + + return { + success: false, + }; + } + + public async extendConfiguration( + configuration: IConfigurationExtend + ): Promise { + + const gitHubCommand: GithubCommand = new GithubCommand(this); + await configuration.slashCommands.provideSlashCommand(gitHubCommand); + } + } diff --git a/github/app.json b/github/app.json index a65f5da..d52df82 100644 --- a/github/app.json +++ b/github/app.json @@ -1,7 +1,7 @@ { "id": "826f0d95-9e25-48a6-a781-a32f147230a5", "version": "0.0.1", - "requiredApiVersion": "^1.4.0", + "requiredApiVersion": "^1.19.0", "iconFile": "icon.png", "author": { "name": "Samad Yar Khan", @@ -11,5 +11,6 @@ "name": "Github", "nameSlug": "github", "classFile": "GithubApp.ts", - "description": "The ultimate app extending Rocket.Chat for all developers collaborating on Github" + "description": "The ultimate app extending Rocket.Chat for all developers collaborating on Github", + "implements": [] } \ No newline at end of file diff --git a/github/commands/GithubCommand.ts b/github/commands/GithubCommand.ts new file mode 100644 index 0000000..8be9407 --- /dev/null +++ b/github/commands/GithubCommand.ts @@ -0,0 +1,82 @@ +import { + ISlashCommand, + SlashCommandContext, +} from "@rocket.chat/apps-engine/definition/slashcommands"; +import { + IHttp, + IMessageBuilder, + IModify, + IModifyCreator, + IPersistence, + IRead, +} from "@rocket.chat/apps-engine/definition/accessors"; + +import { GithubApp } from "../GithubApp"; +import { IMessage } from "@rocket.chat/apps-engine/definition/messages"; +import { IRoom } from "@rocket.chat/apps-engine/definition/rooms"; +import { IUser } from "@rocket.chat/apps-engine/definition/users"; +import { initiatorMessage } from "../lib/initiatorMessage"; +import { issueListMessage } from "../lib/issuesListMessage"; +import { contributorListMessage } from "../lib/contributorListMessage"; +import { pullRequestListMessage } from "../lib/pullReqeustListMessage"; +import { repoDataMessage } from "../lib/repoDataMessage"; + + +export class GithubCommand implements ISlashCommand { + public constructor(private readonly app: GithubApp) {} + public command = "github"; + public i18nDescription = "fetching githup data"; + public providesPreview = false; + public i18nParamsExample = ""; + + public async executor( + context: SlashCommandContext, + read: IRead, + modify: IModify, + http: IHttp, + persistence: IPersistence + ): Promise { + + const command = context.getArguments(); + const sender = context.getSender(); + const room = context.getRoom(); + + const data = { + room: room, + sender: sender, + arguments: command, + }; + + if (Array.isArray(command) && command.length === 1) { + + await initiatorMessage({ data, read, persistence, modify, http }); + + } else if (Array.isArray(command) && command.length === 2) { + + const subcommand2 = command[1]; + + switch (subcommand2) { + case "issues": { + await issueListMessage({context,read,persistence,modify,http}); + break; + } + case "contributors": { + await contributorListMessage({context,read,persistence,modify,http}); + break; + } + case "pulls": { + await pullRequestListMessage({context,read,persistence,modify,http}); + break; + } + case "repo": { + await repoDataMessage({context,read,persistence,modify,http}) + break; + } + default: + throw new Error("Error!"); + } + } + + + } +} \ No newline at end of file diff --git a/github/commands/GithubCommands.ts b/github/commands/GithubCommands.ts deleted file mode 100644 index 9ffe4b6..0000000 --- a/github/commands/GithubCommands.ts +++ /dev/null @@ -1,209 +0,0 @@ -import { - ISlashCommand, - SlashCommandContext, -} from "@rocket.chat/apps-engine/definition/slashcommands"; -import { - IHttp, - IMessageBuilder, - IModify, - IModifyCreator, - IPersistence, - IRead, -} from "@rocket.chat/apps-engine/definition/accessors"; - -import { GithubApp } from "../GithubApp"; -import { IMessage } from "@rocket.chat/apps-engine/definition/messages"; -import { IRoom } from "@rocket.chat/apps-engine/definition/rooms"; -import { IUser } from "@rocket.chat/apps-engine/definition/users"; -import { initiatorMessage } from "../lib/initiatorMessage"; -import { issueListMessage } from "../lib/issuesListMessage"; -// import { AppPersistence } from "../lib/persistence"; -// import { GithubSDK } from "../lib/githubsdk"; -// import { sendNotification } from "../lib/helpers/sendNotification"; -// import { getWebhookUrl } from "../lib/helpers/getWebhookUrl"; -// import { toDoModal } from "../modals/toDoModal"; -// import { addTokenModal } from "../modals/AddTokenModal"; - -export class GithubCommand implements ISlashCommand { - public constructor(private readonly app: GithubApp) {} - public command = "github"; - public i18nDescription = "fetching githup data"; - public providesPreview = false; - public i18nParamsExample = ""; - - public async executor( - context: SlashCommandContext, - read: IRead, - modify: IModify, - http: IHttp, - persistence: IPersistence - ): Promise { - // const creator: IModifyCreator = modify.getCreator() - // const sender: IUser = (await read.getUserReader().getAppUser()) as IUser - // const room: IRoom = context.getRoom() - // const messageTemplate: IMessage = { - // text: 'Github App working !', - // sender, - // room - // } - // const messageBuilder: IMessageBuilder = creator.startMessage(messageTemplate) - // await creator.finish(messageBuilder) - const command = context.getArguments(); - - - const sender = context.getSender(); // the user calling the slashcommand - const room = context.getRoom(); // the current room - - const data = { - room: room, - sender: sender, - arguments: command, - }; - - if (Array.isArray(command) && command.length === 1) { - - - await initiatorMessage({ data, read, persistence, modify, http }); - - } else if (Array.isArray(command) && command.length === 2) { - const subcommand = command[0]; - const subcommand2 = command[1]; - - switch (subcommand2) { - case "issues": { - await issueListMessage({context,read,persistence,modify,http}); - break; - } - case "contributors": { - const repository = command[0]; - const gitResponse = await http.get( - `https://api.github.com/repos/${repository}/contributors` - ); - const resData = gitResponse.data; - const room: IRoom = context.getRoom(); - const textSender = await modify - .getCreator() - .startMessage() - .setText(`*CONTRIBUTOR LIST*`); - - if (room) { - textSender.setRoom(room); - } - - await modify.getCreator().finish(textSender); - resData.forEach(async (contributor, ind) => { - if (ind < 20) { - const login = contributor.login; - const html_url = contributor.html_url; - - const textSender = await modify - .getCreator() - .startMessage() - .setText(`[ ${login} ](${html_url})`); - - if (room) { - textSender.setRoom(room); - } - - await modify.getCreator().finish(textSender); - } - }); - break; - } - case "pulls": { - const repository = command[0]; - const gitResponse = await http.get( - `https://api.github.com/repos/${repository}/contributors` - ); - const resData = gitResponse.data; - const room: IRoom = context.getRoom(); - const textSender = await modify - .getCreator() - .startMessage() - .setText(`*PULL REQUESTS*`); - - if (room) { - textSender.setRoom(room); - } - - await modify.getCreator().finish(textSender); - resData.forEach(async (pull, ind) => { - if (ind < 10) { - const title = pull.title; - const url = pull.html_url; - - const textSender = await modify - .getCreator() - .startMessage() - .setText( - `[ #${pull.number} ](${url}) *${pull.title}*` - ); - - if (room) { - textSender.setRoom(room); - } - - await modify.getCreator().finish(textSender); - } - }); - break; - } - case "repo": { - const repository = command[0]; - const gitResponse = await http.get( - `https://api.github.com/repos/${repository}` - ); - const resData = gitResponse.data; - const room: IRoom = context.getRoom(); - const fullName = - "[" + - resData.full_name + - "](" + - resData.html_url + - ")" + - " ▫️ "; - const stars = - "` ⭐ Stars " + resData.stargazers_count + " ` "; - const issues = "` ❗ Issues " + resData.open_issues + " ` "; - const forks = "` 🍴 Forks " + resData.forks_count + " ` "; - let tags = ""; - if ( - resData && - resData.topics && - Array.isArray(resData.topics) - ) { - resData.topics.forEach((topic: string) => { - let tempTopic = " ` "; - tempTopic += topic; - tempTopic += " ` "; - tags += tempTopic; - }); - } - - const textSender = await modify - .getCreator() - .startMessage() - .setText( - fullName + - stars + - issues + - forks + - "```" + - resData.description + - "```" + - tags - ); - if (room) { - textSender.setRoom(room); - } - await modify.getCreator().finish(textSender); - break; - } - default: - throw new Error("Error!"); - } - } - - - } -} \ No newline at end of file diff --git a/github/lib/contributorListMessage.ts b/github/lib/contributorListMessage.ts index 9f31784..02ac282 100644 --- a/github/lib/contributorListMessage.ts +++ b/github/lib/contributorListMessage.ts @@ -7,7 +7,7 @@ import { import { IRoom } from "@rocket.chat/apps-engine/definition/rooms"; import { SlashCommandContext } from "@rocket.chat/apps-engine/definition/slashcommands"; -export async function issueListMessage({ +export async function contributorListMessage({ context, read, persistence, diff --git a/github/lib/RepoDataMessage.ts b/github/lib/repoDataMessage.ts similarity index 97% rename from github/lib/RepoDataMessage.ts rename to github/lib/repoDataMessage.ts index f1a04a9..9bcfca7 100644 --- a/github/lib/RepoDataMessage.ts +++ b/github/lib/repoDataMessage.ts @@ -9,7 +9,7 @@ import { SlashCommandContext, } from "@rocket.chat/apps-engine/definition/slashcommands"; -export async function pullRequestListMessage({ +export async function repoDataMessage({ context, read, persistence, From 23225d425663fd450181385a37ba791f53a0b607 Mon Sep 17 00:00:00 2001 From: Samad Yar Khan Date: Sun, 5 Jun 2022 12:36:39 +0000 Subject: [PATCH 04/12] Add minimal Slash Commands Interface --- github/GithubApp.ts | 198 +++++++-------------------- github/commands/GithubCommand.ts | 10 +- github/lib/contributorListMessage.ts | 10 +- github/lib/initiatorMessage.ts | 26 ++-- github/lib/issuesListMessage.ts | 10 +- github/lib/pullReqeustListMessage.ts | 10 +- github/lib/repoDataMessage.ts | 11 +- 7 files changed, 88 insertions(+), 187 deletions(-) diff --git a/github/GithubApp.ts b/github/GithubApp.ts index 5534c26..8238fa0 100644 --- a/github/GithubApp.ts +++ b/github/GithubApp.ts @@ -10,22 +10,14 @@ import { import { App } from "@rocket.chat/apps-engine/definition/App"; import { IAppInfo } from "@rocket.chat/apps-engine/definition/metadata"; import { GithubCommand } from "./commands/GithubCommand"; -import { ApiSecurity, ApiVisibility } from '@rocket.chat/apps-engine/definition/api'; -import { IUIKitInteractionHandler, UIKitViewCloseInteractionContext, UIKitViewSubmitInteractionContext } from '@rocket.chat/apps-engine/definition/uikit' - -import { - IMessage, - IPostMessageSent, -} from "@rocket.chat/apps-engine/definition/messages"; -import { initiatorMessage } from "./lib/initiatorMessage"; - import { - IUIKitResponse, - UIKitLivechatBlockInteractionContext, UIKitBlockInteractionContext, } from "@rocket.chat/apps-engine/definition/uikit"; - - +import { pullRequestListMessage } from "./lib/pullReqeustListMessage"; +import { IRoom } from "@rocket.chat/apps-engine/definition/rooms"; +import { issueListMessage } from "./lib/issuesListMessage"; +import { contributorListMessage } from "./lib/contributorListMessage"; +import { repoDataMessage } from "./lib/repoDataMessage"; export class GithubApp extends App { constructor(info: IAppInfo, logger: ILogger, accessors: IAppAccessors) { @@ -39,8 +31,6 @@ export class GithubApp extends App { persistence: IPersistence, modify: IModify ) { - - const data = context.getInteractionData(); const { actionId } = data; @@ -48,144 +38,65 @@ export class GithubApp extends App { switch (actionId) { case "githubDataSelect": { try { - const gitResponse = await http.get( - `https://api.github.com/repos/${data.value}` - ); - const param = data.value; let paramVal = ""; - if(param && param.length){ - - for(let i = param.length-1; i>=0 && data.value && data.value[i]!='/' ;i--){ + let lengthOfRepoString: number = 0; + if (param && param.length) { + let i = param.length - 1; + for ( + ; + i >= 0 && data.value && data.value[i] != "/"; + i-- + ) { paramVal = data.value[i] + paramVal; } + lengthOfRepoString = i; } + const repository = param?.substring( + 0, + lengthOfRepoString + ) as String; - const resData = gitResponse.data; - - const { room } = context.getInteractionData(); + const room: IRoom = context.getInteractionData() + .room as IRoom; if (paramVal === "pulls") { - - const textSender = await modify - .getCreator() - .startMessage() - .setText(`*PULL REQUESTS*`); - - if (room) { - textSender.setRoom(room); - } - - await modify.getCreator().finish(textSender); - resData.forEach(async (pull, ind) => { - if (ind < 10) { - const title = pull.title; - const url = pull.html_url; - - const textSender = await modify - .getCreator() - .startMessage() - .setText(`[ #${pull.number} ](${url}) *${pull.title}*`); - - if (room) { - textSender.setRoom(room); - } - - await modify.getCreator().finish(textSender); - } - }); - + await pullRequestListMessage({ + repository, + room, + read, + persistence, + modify, + http, + }); } else if (paramVal === "issues") { - const textSender = await modify - .getCreator() - .startMessage() - .setText(`*ISSUES LIST*`); - - if (room) { - textSender.setRoom(room); - } - let ind =0; - await modify.getCreator().finish(textSender); - resData.forEach(async (issue) => { - if (typeof issue.pull_request === "undefined" && ind < 10) { - const title = issue.title; - const url = issue.html_url; - - const textSender = await modify - .getCreator() - .startMessage() - .setText(`[ #${issue.number} ](${url}) *${issue.title}*`); - - if (room) { - textSender.setRoom(room); - } - - await modify.getCreator().finish(textSender); - ind++; - } + await issueListMessage({ + repository, + room, + read, + persistence, + modify, + http, }); - } else if(paramVal==='contributors'){ - const textSender = await modify - .getCreator() - .startMessage() - .setText(`*CONTRIBUTOR LIST*`); - - if (room) { - textSender.setRoom(room); - } - - await modify.getCreator().finish(textSender); - resData.forEach(async (contributor, ind) => { - if (ind < 20) { - const login = contributor.login; - const html_url = contributor.html_url; - - const textSender = await modify - .getCreator() - .startMessage() - .setText(`[ ${login} ](${html_url})`); - - if (room) { - textSender.setRoom(room); - } - - await modify.getCreator().finish(textSender); - } + } else if (paramVal === "contributors") { + await contributorListMessage({ + repository, + room, + read, + persistence, + modify, + http, }); - }else{ - - const fullName = - "[" + - resData.full_name + - "](" + - resData.html_url + - ")" + - " ▫️ "; - const stars = - "` ⭐ Stars " + resData.stargazers_count + " ` "; - const issues = - "` ❗ Issues " + resData.open_issues + " ` "; - const forks = "` 🍴 Forks " + resData.forks_count + " ` "; - let tags = ""; - if(resData && resData.topics && Array.isArray(resData.topics)){ - resData.topics.forEach((topic : string) => { - let tempTopic = " ` "; - tempTopic+=topic; - tempTopic+= " ` "; - tags+= tempTopic; - }) - } - - const textSender = await modify - .getCreator() - .startMessage() - .setText(fullName + stars + issues + forks + "```" + resData.description+ "```" + tags); - if (room) { - textSender.setRoom(room); - } - await modify.getCreator().finish(textSender); - - } + } else { + await repoDataMessage({ + repository, + room, + read, + persistence, + modify, + http, + }); + } return { success: true, @@ -207,10 +118,7 @@ export class GithubApp extends App { public async extendConfiguration( configuration: IConfigurationExtend ): Promise { - const gitHubCommand: GithubCommand = new GithubCommand(this); await configuration.slashCommands.provideSlashCommand(gitHubCommand); } - - } diff --git a/github/commands/GithubCommand.ts b/github/commands/GithubCommand.ts index 8be9407..7d5832c 100644 --- a/github/commands/GithubCommand.ts +++ b/github/commands/GithubCommand.ts @@ -46,7 +46,7 @@ export class GithubCommand implements ISlashCommand { sender: sender, arguments: command, }; - + const repository = command[0]; if (Array.isArray(command) && command.length === 1) { await initiatorMessage({ data, read, persistence, modify, http }); @@ -57,19 +57,19 @@ export class GithubCommand implements ISlashCommand { switch (subcommand2) { case "issues": { - await issueListMessage({context,read,persistence,modify,http}); + await issueListMessage({repository,room,read,persistence,modify,http}); break; } case "contributors": { - await contributorListMessage({context,read,persistence,modify,http}); + await contributorListMessage({repository,room,read,persistence,modify,http}); break; } case "pulls": { - await pullRequestListMessage({context,read,persistence,modify,http}); + await pullRequestListMessage({repository,room,read,persistence,modify,http}); break; } case "repo": { - await repoDataMessage({context,read,persistence,modify,http}) + await repoDataMessage({repository,room,read,persistence,modify,http}) break; } default: diff --git a/github/lib/contributorListMessage.ts b/github/lib/contributorListMessage.ts index 02ac282..60308ab 100644 --- a/github/lib/contributorListMessage.ts +++ b/github/lib/contributorListMessage.ts @@ -8,26 +8,24 @@ import { IRoom } from "@rocket.chat/apps-engine/definition/rooms"; import { SlashCommandContext } from "@rocket.chat/apps-engine/definition/slashcommands"; export async function contributorListMessage({ - context, + repository, + room, read, persistence, modify, http, }: { - context: SlashCommandContext; + repository : String, + room: IRoom; read: IRead; persistence: IPersistence; modify: IModify; http: IHttp; }) { - const command = context.getArguments(); - const repository = command[0]; - const gitResponse = await http.get( `https://api.github.com/repos/${repository}/contributors` ); const resData = gitResponse.data; - const room: IRoom = context.getRoom(); const textSender = await modify .getCreator() .startMessage() diff --git a/github/lib/initiatorMessage.ts b/github/lib/initiatorMessage.ts index c217297..702bb65 100644 --- a/github/lib/initiatorMessage.ts +++ b/github/lib/initiatorMessage.ts @@ -1,11 +1,10 @@ - import { IHttp, IMessageBuilder, IModify, IModifyCreator, IPersistence, - IRead + IRead, } from "@rocket.chat/apps-engine/definition/accessors"; import { ButtonStyle } from "@rocket.chat/apps-engine/definition/uikit"; @@ -23,10 +22,10 @@ export async function initiatorMessage({ http: IHttp; }) { const greetBuilder = await modify - .getCreator() - .startMessage() - .setRoom(data.room) - .setText(`Hey _${data.sender.username}_ !`); + .getCreator() + .startMessage() + .setRoom(data.room) + .setText(`Hey _${data.sender.username}_ !`); if (data.room.type !== "l") { await modify @@ -41,7 +40,9 @@ export async function initiatorMessage({ const block = modify.getCreator().getBlockBuilder(); block.addSectionBlock({ - text: block.newPlainTextObject(`Choose Action for ${data.arguments[0]} 👇 ?`), + text: block.newPlainTextObject( + `Choose Action for ${data.arguments[0]} 👇 ?` + ), }); block.addActionsBlock({ @@ -50,7 +51,7 @@ export async function initiatorMessage({ block.newButtonElement({ actionId: "githubDataSelect", text: block.newPlainTextObject("Overview"), - value: `${data.arguments[0]}`, + value: `${data.arguments[0]}/repo`, style: ButtonStyle.PRIMARY, }), block.newButtonElement({ @@ -76,10 +77,5 @@ export async function initiatorMessage({ builder.setBlocks(block); - await modify - .getNotifier() - .notifyUser(data.sender, builder.getMessage()); - - - -} \ No newline at end of file + await modify.getNotifier().notifyUser(data.sender, builder.getMessage()); +} diff --git a/github/lib/issuesListMessage.ts b/github/lib/issuesListMessage.ts index 010438a..43ddf97 100644 --- a/github/lib/issuesListMessage.ts +++ b/github/lib/issuesListMessage.ts @@ -13,25 +13,25 @@ import { } from "@rocket.chat/apps-engine/definition/slashcommands"; export async function issueListMessage({ - context, + repository, + room, read, persistence, modify, http, }: { - context: SlashCommandContext; + repository : String, + room: IRoom; read: IRead; persistence: IPersistence; modify: IModify; http: IHttp; }) { - const command = context.getArguments(); - const repository = command[0]; + const gitResponse = await http.get( `https://api.github.com/repos/${repository}/issues` ); const resData = gitResponse.data; - const room: IRoom = context.getRoom(); const textSender = await modify .getCreator() .startMessage() diff --git a/github/lib/pullReqeustListMessage.ts b/github/lib/pullReqeustListMessage.ts index 3bd01fc..0ecbc52 100644 --- a/github/lib/pullReqeustListMessage.ts +++ b/github/lib/pullReqeustListMessage.ts @@ -13,25 +13,25 @@ import { } from "@rocket.chat/apps-engine/definition/slashcommands"; export async function pullRequestListMessage({ - context, + repository, + room, read, persistence, modify, http, }: { - context: SlashCommandContext; + repository : String, + room: IRoom; read: IRead; persistence: IPersistence; modify: IModify; http: IHttp; }) { - const command = context.getArguments(); - const repository = command[0]; + const gitResponse = await http.get( `https://api.github.com/repos/${repository}/pulls` ); const resData = gitResponse.data; - const room: IRoom = context.getRoom(); const textSender = await modify .getCreator() .startMessage() diff --git a/github/lib/repoDataMessage.ts b/github/lib/repoDataMessage.ts index 9bcfca7..2149f19 100644 --- a/github/lib/repoDataMessage.ts +++ b/github/lib/repoDataMessage.ts @@ -10,25 +10,24 @@ import { } from "@rocket.chat/apps-engine/definition/slashcommands"; export async function repoDataMessage({ - context, + repository, + room, read, persistence, modify, http, }: { - context: SlashCommandContext; + repository : String, + room: IRoom; read: IRead; persistence: IPersistence; modify: IModify; http: IHttp; -}) { - const command = context.getArguments(); - const repository = command[0]; +}){ const gitResponse = await http.get( `https://api.github.com/repos/${repository}` ); const resData = gitResponse.data; - const room: IRoom = context.getRoom(); const fullName = "[" + resData.full_name + From 8169ff054c3a45d9af70e6704177a03da42e4b68 Mon Sep 17 00:00:00 2001 From: Samad Yar Khan Date: Sun, 5 Jun 2022 12:54:43 +0000 Subject: [PATCH 05/12] Set Helper message template --- github/commands/GithubCommand.ts | 10 ++++++-- github/lib/helperMessage.ts | 44 ++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 github/lib/helperMessage.ts diff --git a/github/commands/GithubCommand.ts b/github/commands/GithubCommand.ts index 7d5832c..cff5608 100644 --- a/github/commands/GithubCommand.ts +++ b/github/commands/GithubCommand.ts @@ -20,6 +20,7 @@ import { issueListMessage } from "../lib/issuesListMessage"; import { contributorListMessage } from "../lib/contributorListMessage"; import { pullRequestListMessage } from "../lib/pullReqeustListMessage"; import { repoDataMessage } from "../lib/repoDataMessage"; +import { helperMessage } from "../lib/helperMessage"; export class GithubCommand implements ISlashCommand { @@ -46,13 +47,18 @@ export class GithubCommand implements ISlashCommand { sender: sender, arguments: command, }; - const repository = command[0]; - if (Array.isArray(command) && command.length === 1) { + + if(Array.isArray(command) && command.length === 0 ){ + + await helperMessage({room,read, persistence, modify, http}); + + }else if (Array.isArray(command) && command.length === 1) { await initiatorMessage({ data, read, persistence, modify, http }); } else if (Array.isArray(command) && command.length === 2) { + const repository = command[0]; const subcommand2 = command[1]; switch (subcommand2) { diff --git a/github/lib/helperMessage.ts b/github/lib/helperMessage.ts new file mode 100644 index 0000000..9b9235a --- /dev/null +++ b/github/lib/helperMessage.ts @@ -0,0 +1,44 @@ +import { + IHttp, + IMessageBuilder, + IModify, + IModifyCreator, + IPersistence, + IRead, +} from "@rocket.chat/apps-engine/definition/accessors"; +import { IRoom } from "@rocket.chat/apps-engine/definition/rooms"; + +export async function helperMessage({ + room, + read, + persistence, + modify, + http, +}: { + room: IRoom; + read: IRead; + persistence: IPersistence; + modify: IModify; + http: IHttp; +}) { + let helperMessageString = ` + Github App Cheet Sheet + + 1) See Interactive Button interface to fetch repository data -> /github GithubUsername/RepositoryName + 2) Get details of a Repository -> /github GithubUsername/RepositoryName repo + 3) Get Issues of a Repository -> /github GithubUsername/RepositoryName issues + 4) Get Comtributors of a Repository -> /github GithubUsername/RepositoryName contributors + 5) Get Recent Pull Request of a Repository -> /github GithubUsername/RepositoryName pulls + + `; + + const textSender = await modify + .getCreator() + .startMessage() + .setText("```" + helperMessageString + "```"); + + if (room) { + textSender.setRoom(room); + } + await modify.getCreator().finish(textSender); +} From b0a4a814308762ca91b5c09d34be071d0d9e78a5 Mon Sep 17 00:00:00 2001 From: Samad Yar Khan Date: Sun, 5 Jun 2022 13:12:36 +0000 Subject: [PATCH 06/12] Make Basic Query Message helper --- github/GithubApp.ts | 47 +++---------------------- github/commands/GithubCommand.ts | 24 ++----------- github/helpers/basicQueryMessage.ts | 53 +++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 63 deletions(-) create mode 100644 github/helpers/basicQueryMessage.ts diff --git a/github/GithubApp.ts b/github/GithubApp.ts index 8238fa0..976ef25 100644 --- a/github/GithubApp.ts +++ b/github/GithubApp.ts @@ -10,14 +10,13 @@ import { import { App } from "@rocket.chat/apps-engine/definition/App"; import { IAppInfo } from "@rocket.chat/apps-engine/definition/metadata"; import { GithubCommand } from "./commands/GithubCommand"; -import { - UIKitBlockInteractionContext, -} from "@rocket.chat/apps-engine/definition/uikit"; +import { UIKitBlockInteractionContext } from "@rocket.chat/apps-engine/definition/uikit"; import { pullRequestListMessage } from "./lib/pullReqeustListMessage"; import { IRoom } from "@rocket.chat/apps-engine/definition/rooms"; import { issueListMessage } from "./lib/issuesListMessage"; import { contributorListMessage } from "./lib/contributorListMessage"; import { repoDataMessage } from "./lib/repoDataMessage"; +import { basicQueryMessage } from "./helpers/basicQueryMessage"; export class GithubApp extends App { constructor(info: IAppInfo, logger: ILogger, accessors: IAppAccessors) { @@ -39,7 +38,7 @@ export class GithubApp extends App { case "githubDataSelect": { try { const param = data.value; - let paramVal = ""; + let query:String = ""; let lengthOfRepoString: number = 0; if (param && param.length) { let i = param.length - 1; @@ -48,7 +47,7 @@ export class GithubApp extends App { i >= 0 && data.value && data.value[i] != "/"; i-- ) { - paramVal = data.value[i] + paramVal; + query = data.value[i] + query; } lengthOfRepoString = i; } @@ -60,43 +59,7 @@ export class GithubApp extends App { const room: IRoom = context.getInteractionData() .room as IRoom; - if (paramVal === "pulls") { - await pullRequestListMessage({ - repository, - room, - read, - persistence, - modify, - http, - }); - } else if (paramVal === "issues") { - await issueListMessage({ - repository, - room, - read, - persistence, - modify, - http, - }); - } else if (paramVal === "contributors") { - await contributorListMessage({ - repository, - room, - read, - persistence, - modify, - http, - }); - } else { - await repoDataMessage({ - repository, - room, - read, - persistence, - modify, - http, - }); - } + await basicQueryMessage ({query,repository,room,read,persistence,modify,http}); return { success: true, diff --git a/github/commands/GithubCommand.ts b/github/commands/GithubCommand.ts index cff5608..de37f4f 100644 --- a/github/commands/GithubCommand.ts +++ b/github/commands/GithubCommand.ts @@ -21,6 +21,7 @@ import { contributorListMessage } from "../lib/contributorListMessage"; import { pullRequestListMessage } from "../lib/pullReqeustListMessage"; import { repoDataMessage } from "../lib/repoDataMessage"; import { helperMessage } from "../lib/helperMessage"; +import { basicQueryMessage } from "../helpers/basicQueryMessage"; export class GithubCommand implements ISlashCommand { @@ -59,28 +60,9 @@ export class GithubCommand implements ISlashCommand { } else if (Array.isArray(command) && command.length === 2) { const repository = command[0]; - const subcommand2 = command[1]; + const query = command[1]; - switch (subcommand2) { - case "issues": { - await issueListMessage({repository,room,read,persistence,modify,http}); - break; - } - case "contributors": { - await contributorListMessage({repository,room,read,persistence,modify,http}); - break; - } - case "pulls": { - await pullRequestListMessage({repository,room,read,persistence,modify,http}); - break; - } - case "repo": { - await repoDataMessage({repository,room,read,persistence,modify,http}) - break; - } - default: - throw new Error("Error!"); - } + await basicQueryMessage ({query,repository,room,read,persistence,modify,http}); } diff --git a/github/helpers/basicQueryMessage.ts b/github/helpers/basicQueryMessage.ts new file mode 100644 index 0000000..a757224 --- /dev/null +++ b/github/helpers/basicQueryMessage.ts @@ -0,0 +1,53 @@ +import { + IHttp, + IMessageBuilder, + IModify, + IModifyCreator, + IPersistence, + IRead, +} from "@rocket.chat/apps-engine/definition/accessors"; +import { IRoom } from "@rocket.chat/apps-engine/definition/rooms"; +import { issueListMessage } from "../lib/issuesListMessage"; +import { contributorListMessage } from "../lib/contributorListMessage"; +import { pullRequestListMessage } from "../lib/pullReqeustListMessage"; +import { repoDataMessage } from "../lib/repoDataMessage"; + +export async function basicQueryMessage({ + query, + repository, + room, + read, + persistence, + modify, + http, +}: { + query: String, + repository:String, + room: IRoom; + read: IRead; + persistence: IPersistence; + modify: IModify; + http: IHttp; +}) { + + switch (query) { + case "issues": { + await issueListMessage({repository,room,read,persistence,modify,http}); + break; + } + case "contributors": { + await contributorListMessage({repository,room,read,persistence,modify,http}); + break; + } + case "pulls": { + await pullRequestListMessage({repository,room,read,persistence,modify,http}); + break; + } + case "repo": { + await repoDataMessage({repository,room,read,persistence,modify,http}) + break; + } + default: + throw new Error("Error!"); + } +} From af28071a0770d0f63248303a84bc56ed2ed807a9 Mon Sep 17 00:00:00 2001 From: Samad Yar Khan Date: Sun, 5 Jun 2022 13:13:32 +0000 Subject: [PATCH 07/12] remove unnecessary imports --- github/GithubApp.ts | 16 ++++++++++------ github/commands/GithubCommand.ts | 7 ------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/github/GithubApp.ts b/github/GithubApp.ts index 976ef25..1758c7e 100644 --- a/github/GithubApp.ts +++ b/github/GithubApp.ts @@ -11,11 +11,7 @@ import { App } from "@rocket.chat/apps-engine/definition/App"; import { IAppInfo } from "@rocket.chat/apps-engine/definition/metadata"; import { GithubCommand } from "./commands/GithubCommand"; import { UIKitBlockInteractionContext } from "@rocket.chat/apps-engine/definition/uikit"; -import { pullRequestListMessage } from "./lib/pullReqeustListMessage"; import { IRoom } from "@rocket.chat/apps-engine/definition/rooms"; -import { issueListMessage } from "./lib/issuesListMessage"; -import { contributorListMessage } from "./lib/contributorListMessage"; -import { repoDataMessage } from "./lib/repoDataMessage"; import { basicQueryMessage } from "./helpers/basicQueryMessage"; export class GithubApp extends App { @@ -38,7 +34,7 @@ export class GithubApp extends App { case "githubDataSelect": { try { const param = data.value; - let query:String = ""; + let query: String = ""; let lengthOfRepoString: number = 0; if (param && param.length) { let i = param.length - 1; @@ -59,7 +55,15 @@ export class GithubApp extends App { const room: IRoom = context.getInteractionData() .room as IRoom; - await basicQueryMessage ({query,repository,room,read,persistence,modify,http}); + await basicQueryMessage({ + query, + repository, + room, + read, + persistence, + modify, + http, + }); return { success: true, diff --git a/github/commands/GithubCommand.ts b/github/commands/GithubCommand.ts index de37f4f..5063d8b 100644 --- a/github/commands/GithubCommand.ts +++ b/github/commands/GithubCommand.ts @@ -12,14 +12,7 @@ import { } from "@rocket.chat/apps-engine/definition/accessors"; import { GithubApp } from "../GithubApp"; -import { IMessage } from "@rocket.chat/apps-engine/definition/messages"; -import { IRoom } from "@rocket.chat/apps-engine/definition/rooms"; -import { IUser } from "@rocket.chat/apps-engine/definition/users"; import { initiatorMessage } from "../lib/initiatorMessage"; -import { issueListMessage } from "../lib/issuesListMessage"; -import { contributorListMessage } from "../lib/contributorListMessage"; -import { pullRequestListMessage } from "../lib/pullReqeustListMessage"; -import { repoDataMessage } from "../lib/repoDataMessage"; import { helperMessage } from "../lib/helperMessage"; import { basicQueryMessage } from "../helpers/basicQueryMessage"; From d4495b36fb06132f0d81730f6f81043860930bca Mon Sep 17 00:00:00 2001 From: Samad Yar Khan Date: Sun, 5 Jun 2022 21:27:30 +0000 Subject: [PATCH 08/12] Update helper message --- github/commands/GithubCommand.ts | 2 -- github/helpers/basicQueryMessage.ts | 5 ++--- github/lib/contributorListMessage.ts | 1 - github/lib/helperMessage.ts | 4 +--- github/lib/pullReqeustListMessage.ts | 4 ---- github/lib/repoDataMessage.ts | 4 +--- 6 files changed, 4 insertions(+), 16 deletions(-) diff --git a/github/commands/GithubCommand.ts b/github/commands/GithubCommand.ts index 5063d8b..63857b2 100644 --- a/github/commands/GithubCommand.ts +++ b/github/commands/GithubCommand.ts @@ -4,9 +4,7 @@ import { } from "@rocket.chat/apps-engine/definition/slashcommands"; import { IHttp, - IMessageBuilder, IModify, - IModifyCreator, IPersistence, IRead, } from "@rocket.chat/apps-engine/definition/accessors"; diff --git a/github/helpers/basicQueryMessage.ts b/github/helpers/basicQueryMessage.ts index a757224..b82fd6d 100644 --- a/github/helpers/basicQueryMessage.ts +++ b/github/helpers/basicQueryMessage.ts @@ -1,8 +1,6 @@ import { IHttp, - IMessageBuilder, IModify, - IModifyCreator, IPersistence, IRead, } from "@rocket.chat/apps-engine/definition/accessors"; @@ -11,6 +9,7 @@ import { issueListMessage } from "../lib/issuesListMessage"; import { contributorListMessage } from "../lib/contributorListMessage"; import { pullRequestListMessage } from "../lib/pullReqeustListMessage"; import { repoDataMessage } from "../lib/repoDataMessage"; +import { helperMessage } from "../lib/helperMessage"; export async function basicQueryMessage({ query, @@ -48,6 +47,6 @@ export async function basicQueryMessage({ break; } default: - throw new Error("Error!"); + await helperMessage({room,read,persistence,modify,http}); } } diff --git a/github/lib/contributorListMessage.ts b/github/lib/contributorListMessage.ts index 60308ab..955c439 100644 --- a/github/lib/contributorListMessage.ts +++ b/github/lib/contributorListMessage.ts @@ -5,7 +5,6 @@ import { IRead, } from "@rocket.chat/apps-engine/definition/accessors"; import { IRoom } from "@rocket.chat/apps-engine/definition/rooms"; -import { SlashCommandContext } from "@rocket.chat/apps-engine/definition/slashcommands"; export async function contributorListMessage({ repository, diff --git a/github/lib/helperMessage.ts b/github/lib/helperMessage.ts index 9b9235a..6441190 100644 --- a/github/lib/helperMessage.ts +++ b/github/lib/helperMessage.ts @@ -1,8 +1,6 @@ import { IHttp, - IMessageBuilder, IModify, - IModifyCreator, IPersistence, IRead, } from "@rocket.chat/apps-engine/definition/accessors"; @@ -22,7 +20,7 @@ export async function helperMessage({ http: IHttp; }) { let helperMessageString = ` - Github App Cheet Sheet + Github App 1) See Interactive Button interface to fetch repository data -> /github GithubUsername/RepositoryName 2) Get details of a Repository -> /github GithubUsername/RepositoryName repo diff --git a/github/lib/pullReqeustListMessage.ts b/github/lib/pullReqeustListMessage.ts index 0ecbc52..1b19bcc 100644 --- a/github/lib/pullReqeustListMessage.ts +++ b/github/lib/pullReqeustListMessage.ts @@ -7,10 +7,6 @@ import { IRead, } from "@rocket.chat/apps-engine/definition/accessors"; import { IRoom } from "@rocket.chat/apps-engine/definition/rooms"; -import { - ISlashCommand, - SlashCommandContext, -} from "@rocket.chat/apps-engine/definition/slashcommands"; export async function pullRequestListMessage({ repository, diff --git a/github/lib/repoDataMessage.ts b/github/lib/repoDataMessage.ts index 2149f19..360b997 100644 --- a/github/lib/repoDataMessage.ts +++ b/github/lib/repoDataMessage.ts @@ -5,9 +5,7 @@ import { IRead, } from "@rocket.chat/apps-engine/definition/accessors"; import { IRoom } from "@rocket.chat/apps-engine/definition/rooms"; -import { - SlashCommandContext, -} from "@rocket.chat/apps-engine/definition/slashcommands"; + export async function repoDataMessage({ repository, From 442927bf0089d5830e85ea54d699e6e85a6e3dc8 Mon Sep 17 00:00:00 2001 From: Samad Yar Khan Date: Sun, 5 Jun 2022 21:50:41 +0000 Subject: [PATCH 09/12] fix helper message typo --- github/lib/helperMessage.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/lib/helperMessage.ts b/github/lib/helperMessage.ts index 6441190..da58390 100644 --- a/github/lib/helperMessage.ts +++ b/github/lib/helperMessage.ts @@ -25,7 +25,7 @@ export async function helperMessage({ 1) See Interactive Button interface to fetch repository data -> /github GithubUsername/RepositoryName 2) Get details of a Repository -> /github GithubUsername/RepositoryName repo 3) Get Issues of a Repository -> /github GithubUsername/RepositoryName issues - 4) Get Comtributors of a Repository -> /github GithubUsername/RepositoryName contributors + 4) Get Contributors of a Repository -> /github GithubUsername/RepositoryName contributors 5) Get Recent Pull Request of a Repository -> /github GithubUsername/RepositoryName pulls `; From e985705331484b7faa953f6176989d84e4b1bd36 Mon Sep 17 00:00:00 2001 From: Samad Yar Khan Date: Tue, 14 Jun 2022 20:49:47 +0000 Subject: [PATCH 10/12] PR Review Modal Logic --- github/GithubApp.ts | 18 +++- github/commands/GithubCommand.ts | 65 ++++++++---- github/enum/App.ts | 6 ++ github/enum/Modals.ts | 12 +++ github/handlers/ExecuteViewClosedHandler.ts | 26 +++++ github/modals/fileCodeModal.ts | 82 +++++++++++++++ github/modals/pullDetailsModal.ts | 107 ++++++++++++++++++++ 7 files changed, 294 insertions(+), 22 deletions(-) create mode 100644 github/enum/App.ts create mode 100644 github/enum/Modals.ts create mode 100644 github/handlers/ExecuteViewClosedHandler.ts create mode 100644 github/modals/fileCodeModal.ts create mode 100644 github/modals/pullDetailsModal.ts diff --git a/github/GithubApp.ts b/github/GithubApp.ts index 1758c7e..70aa3fe 100644 --- a/github/GithubApp.ts +++ b/github/GithubApp.ts @@ -10,9 +10,12 @@ import { import { App } from "@rocket.chat/apps-engine/definition/App"; import { IAppInfo } from "@rocket.chat/apps-engine/definition/metadata"; import { GithubCommand } from "./commands/GithubCommand"; -import { UIKitBlockInteractionContext } from "@rocket.chat/apps-engine/definition/uikit"; import { IRoom } from "@rocket.chat/apps-engine/definition/rooms"; import { basicQueryMessage } from "./helpers/basicQueryMessage"; +import { ModalsEnum } from "./enum/Modals"; +import { fileCodeModal } from "./modals/fileCodeModal"; +import { IUIKitInteractionHandler, IUIKitResponse, UIKitBlockInteractionContext, UIKitViewCloseInteractionContext, UIKitViewSubmitInteractionContext } from '@rocket.chat/apps-engine/definition/uikit'; +import { ExecuteViewClosedHandler } from "./handlers/ExecuteViewClosedHandler"; export class GithubApp extends App { constructor(info: IAppInfo, logger: ILogger, accessors: IAppAccessors) { @@ -29,7 +32,7 @@ export class GithubApp extends App { const data = context.getInteractionData(); const { actionId } = data; - console.log(data); + switch (actionId) { case "githubDataSelect": { try { @@ -74,7 +77,13 @@ export class GithubApp extends App { success: false, }; } + break; } + case ModalsEnum.VIEW_FILE_ACTION:{ + const codeModal = await fileCodeModal({data,modify,read,persistence,http,uikitcontext:context}); + return context.getInteractionResponder().openModalViewResponse(codeModal); + } + } return { @@ -82,6 +91,11 @@ export class GithubApp extends App { }; } + public async executeViewClosedHandler(context: UIKitViewCloseInteractionContext, read: IRead, http: IHttp, persistence: IPersistence, modify: IModify) { + const handler = new ExecuteViewClosedHandler(this, read, http, modify, persistence); + return await handler.run(context); + } + public async extendConfiguration( configuration: IConfigurationExtend ): Promise { diff --git a/github/commands/GithubCommand.ts b/github/commands/GithubCommand.ts index 63857b2..b38cd90 100644 --- a/github/commands/GithubCommand.ts +++ b/github/commands/GithubCommand.ts @@ -13,6 +13,7 @@ import { GithubApp } from "../GithubApp"; import { initiatorMessage } from "../lib/initiatorMessage"; import { helperMessage } from "../lib/helperMessage"; import { basicQueryMessage } from "../helpers/basicQueryMessage"; +import { pullDetailsModal } from "../modals/pullDetailsModal"; export class GithubCommand implements ISlashCommand { @@ -34,28 +35,52 @@ export class GithubCommand implements ISlashCommand { const sender = context.getSender(); const room = context.getRoom(); - const data = { - room: room, - sender: sender, - arguments: command, - }; + if(!Array.isArray(command)){ + return; + } - if(Array.isArray(command) && command.length === 0 ){ - - await helperMessage({room,read, persistence, modify, http}); - - }else if (Array.isArray(command) && command.length === 1) { - - await initiatorMessage({ data, read, persistence, modify, http }); + switch (command?.length) { + case 0:{ + await helperMessage({room,read, persistence, modify, http}); + break; + } + case 1 : { + const data = { + room: room, + sender: sender, + arguments: command, + }; + await initiatorMessage({ data, read, persistence, modify, http }); + break; + } + case 2 : { + const repository = command[0]; + const query = command[1]; + await basicQueryMessage ({query,repository,room,read,persistence,modify,http}); + break; + } + case 3 :{ + const data = { + repository:command[0], + query:command[1], + number:command[2] + } + const triggerId= context.getTriggerId(); + if(triggerId){ + console.log(triggerId); + const modal = await pullDetailsModal({data,modify,read,persistence,http,slashcommandcontext:context}); + await modify.getUiController().openModalView(modal,{triggerId},context.getSender()); + }else{ + console.log("Inavlid Trigger ID !"); + } + break; + } + default:{ + await helperMessage({room,read, persistence, modify, http}); + break; + } - } else if (Array.isArray(command) && command.length === 2) { - - const repository = command[0]; - const query = command[1]; - - await basicQueryMessage ({query,repository,room,read,persistence,modify,http}); } - - + } } \ No newline at end of file diff --git a/github/enum/App.ts b/github/enum/App.ts new file mode 100644 index 0000000..a813e21 --- /dev/null +++ b/github/enum/App.ts @@ -0,0 +1,6 @@ +export enum AppEnum { + DEFAULT_TITLE = 'GitHub', + USERNAME_ALIAS = 'GitHub', + EMOJI_AVATAR = '', + USER_MESSAGED_BOT = 'You have messaged the bot user. This has no effect.', +} \ No newline at end of file diff --git a/github/enum/Modals.ts b/github/enum/Modals.ts new file mode 100644 index 0000000..2ef412d --- /dev/null +++ b/github/enum/Modals.ts @@ -0,0 +1,12 @@ +export enum ModalsEnum { + PULL_VIEW = 'pull-view', + CODE_VIEW = 'code-view', + VIEW_FILE_ACTION = 'view-file-task', + VIEW_FILE_ACTION_LABEL = 'View File', + VIEW_DIFFS_ACTION_LABEL = 'View Changes', + PULL_VIEW_LABEL = 'Pull Request', + MERGE_PULL_REQUEST_ACTION = 'merge-pull-request', + MERGE_PULL_REQUEST_LABEL = 'Merge', + COMMENT_PR_ACTION = 'comment-pull-request', + COMMENT_PR_LABEL = 'Comment', +} \ No newline at end of file diff --git a/github/handlers/ExecuteViewClosedHandler.ts b/github/handlers/ExecuteViewClosedHandler.ts new file mode 100644 index 0000000..0ae21fb --- /dev/null +++ b/github/handlers/ExecuteViewClosedHandler.ts @@ -0,0 +1,26 @@ +import { IHttp, IModify, IPersistence, IRead } from '@rocket.chat/apps-engine/definition/accessors'; +import { IApp } from '@rocket.chat/apps-engine/definition/IApp'; +import { UIKitViewCloseInteractionContext } from '@rocket.chat/apps-engine/definition/uikit'; +import { ModalsEnum } from '../enum/Modals'; +import { pullDetailsModal } from '../modals/pullDetailsModal'; + +export class ExecuteViewClosedHandler { + constructor( + private readonly app: IApp, + private readonly read: IRead, + private readonly http: IHttp, + private readonly modify: IModify, + private readonly persistence: IPersistence, + ) { } + + public async run(context: UIKitViewCloseInteractionContext) { + const { view } = context.getInteractionData(); + switch (view.id) { + case ModalsEnum.PULL_VIEW || ModalsEnum.CODE_VIEW: + const modal = await pullDetailsModal({ modify: this.modify, read: this.read, persistence: this.persistence, http: this.http,uikitcontext: context }); + await this.modify.getUiController().updateModalView(modal, { triggerId: context.getInteractionData().triggerId as string }, context.getInteractionData().user); + break; + } + return { success: true } as any; + } +} \ No newline at end of file diff --git a/github/modals/fileCodeModal.ts b/github/modals/fileCodeModal.ts new file mode 100644 index 0000000..0151548 --- /dev/null +++ b/github/modals/fileCodeModal.ts @@ -0,0 +1,82 @@ + +import { IHttp, IModify, IPersistence, IRead } from '@rocket.chat/apps-engine/definition/accessors'; +import { TextObjectType } from '@rocket.chat/apps-engine/definition/uikit/blocks'; +import { IUIKitModalViewParam } from '@rocket.chat/apps-engine/definition/uikit/UIKitInteractionResponder'; +import { IUser } from '@rocket.chat/apps-engine/definition/users'; +import { ModalsEnum } from '../enum/Modals'; +import { AppEnum } from '../enum/App'; +// import { getRoomTasks, getUIData, persistUIData } from '../lib/persistence'; +import { SlashCommandContext } from '@rocket.chat/apps-engine/definition/slashcommands'; +import { UIKitBlockInteractionContext, UIKitInteractionContext } from '@rocket.chat/apps-engine/definition/uikit'; +import { type } from 'os'; + +export async function fileCodeModal({ data, modify, read, persistence, http, slashcommandcontext, uikitcontext }: { data, modify: IModify, read: IRead, persistence: IPersistence, http: IHttp ,slashcommandcontext?: SlashCommandContext, uikitcontext?: UIKitInteractionContext }): Promise { + const viewId = ModalsEnum.CODE_VIEW; + + const block = modify.getCreator().getBlockBuilder(); + + const room = slashcommandcontext?.getRoom() || uikitcontext?.getInteractionData().room; + const user = slashcommandcontext?.getSender() || uikitcontext?.getInteractionData().user; + + if (user?.id) { + let roomId; + + const pullRawData = await http.get( + data.value + ); + + const pullData = pullRawData.content; + + block.addSectionBlock({ + text: { text: `${pullData}`, type: TextObjectType.MARKDOWN} + + }) + + //shows indentations in input blocks but not inn section block + // block.addInputBlock({ + // blockId: ModalsEnum.TASK_BLOCK, + // label: { text: ModalsEnum.TASK_INPUT_LABEL, type: TextObjectType.PLAINTEXT }, + // element: block.newPlainTextInputElement({ + // initialValue : `${pullData}`, + // multiline:true, + // actionId: ModalsEnum.TASK_INPUT, + // }) + // }); + + block.addDividerBlock(); + + + } + + block.addDividerBlock(); + + block.addActionsBlock({ + elements: [ + block.newButtonElement({ + actionId: ModalsEnum.MERGE_PULL_REQUEST_ACTION, + text: { text: ModalsEnum.MERGE_PULL_REQUEST_LABEL, type: TextObjectType.PLAINTEXT }, + value: room?.id + }), + block.newButtonElement({ + actionId: ModalsEnum.COMMENT_PR_ACTION, + text: { text: ModalsEnum.COMMENT_PR_LABEL, type: TextObjectType.PLAINTEXT }, + value: room?.id + }), + ] + }); + + return { + id: viewId, + title: { + type: TextObjectType.PLAINTEXT, + text: AppEnum.DEFAULT_TITLE, + }, + close: block.newButtonElement({ + text: { + type: TextObjectType.PLAINTEXT, + text: 'Close', + }, + }), + blocks: block.getBlocks() + }; +} \ No newline at end of file diff --git a/github/modals/pullDetailsModal.ts b/github/modals/pullDetailsModal.ts new file mode 100644 index 0000000..37e7f1e --- /dev/null +++ b/github/modals/pullDetailsModal.ts @@ -0,0 +1,107 @@ +import { IHttp, IModify, IPersistence, IRead } from '@rocket.chat/apps-engine/definition/accessors'; +import { TextObjectType } from '@rocket.chat/apps-engine/definition/uikit/blocks'; +import { IUIKitModalViewParam } from '@rocket.chat/apps-engine/definition/uikit/UIKitInteractionResponder'; +import { IUser } from '@rocket.chat/apps-engine/definition/users'; +import { ModalsEnum } from '../enum/Modals'; +import { AppEnum } from '../enum/App'; +// import { getRoomTasks, getUIData, persistUIData } from '../lib/persistence'; +import { SlashCommandContext } from '@rocket.chat/apps-engine/definition/slashcommands'; +import { UIKitBlockInteractionContext, UIKitInteractionContext } from '@rocket.chat/apps-engine/definition/uikit'; + +export async function pullDetailsModal({ data, modify, read, persistence, http, slashcommandcontext, uikitcontext }: { data?, modify: IModify, read: IRead, persistence: IPersistence, http: IHttp ,slashcommandcontext?: SlashCommandContext, uikitcontext?: UIKitInteractionContext }): Promise { + const viewId = ModalsEnum.PULL_VIEW; + + const block = modify.getCreator().getBlockBuilder(); + + const room = slashcommandcontext?.getRoom() || uikitcontext?.getInteractionData().room; + const user = slashcommandcontext?.getSender() || uikitcontext?.getInteractionData().user; + + if (user?.id) { + let roomId; + + const pullRawData = await http.get( + `https://api.github.com/repos/${data?.repository}/pulls/${data?.number}` + ); + const pullData = pullRawData.data; + + const pullRequestFilesRaw = await http.get( + `https://api.github.com/repos/${data?.repository}/pulls/${data?.number}/files` + ); + + const pullRequestFiles= pullRequestFilesRaw.data; + + block.addSectionBlock({ + text: { text: `#${pullData?.title}`, type: TextObjectType.PLAINTEXT }, + accessory: block.newButtonElement({ + actionId: ModalsEnum.VIEW_FILE_ACTION, + text: { + text: ModalsEnum.VIEW_DIFFS_ACTION_LABEL, + type: TextObjectType.PLAINTEXT + }, + value: pullData["diff_url"] + }) + }) + block.addContextBlock({ elements: [ block.newPlainTextObject(`Author: ${pullData?.user?.login} | `),block.newPlainTextObject(`State : ${pullData?.state} | `),block.newPlainTextObject(`Mergeable : ${pullData?.mergeable}`) ]}); + + block.addDividerBlock(); + + let index=1; + + + + for (let file of pullRequestFiles) { + + let fileName = file["filename"]; + let rawUrl = file["raw_url"]; + let status = file["status"]; + let addition = file["additions"]; + let deletions = file["deletions"]; + block.addSectionBlock({ + text: { text: `${index} ${fileName}`, type: TextObjectType.PLAINTEXT }, + accessory: block.newButtonElement({ + actionId: ModalsEnum.VIEW_FILE_ACTION, + text: { + text: ModalsEnum.VIEW_FILE_ACTION_LABEL, + type: TextObjectType.PLAINTEXT + }, + value: rawUrl + }) + }); + block.addContextBlock({ elements: [ block.newPlainTextObject(`Status: ${status} | `),block.newPlainTextObject(`Additions : ${addition} | `),block.newPlainTextObject(`Deletions : ${deletions}`) ]}); + + index++; + } + } + + + + block.addActionsBlock({ + elements: [ + block.newButtonElement({ + actionId: ModalsEnum.MERGE_PULL_REQUEST_ACTION, + text: { text: ModalsEnum.MERGE_PULL_REQUEST_LABEL, type: TextObjectType.PLAINTEXT }, + value: room?.id + }), + block.newButtonElement({ + actionId: ModalsEnum.COMMENT_PR_ACTION, + text: { text: ModalsEnum.COMMENT_PR_LABEL, type: TextObjectType.PLAINTEXT }, + value: room?.id + }), + ] + }); + + return { + id: viewId, + title: { + type: TextObjectType.PLAINTEXT, + text: AppEnum.DEFAULT_TITLE, + }, + close: block.newButtonElement({ + text: { + type: TextObjectType.PLAINTEXT, + text: 'Close', + }, + }), + blocks: block.getBlocks(), + }; +} \ No newline at end of file From 709045fcbadea79aafdd6c750099b9f506a84526 Mon Sep 17 00:00:00 2001 From: Samad Yar Khan Date: Tue, 14 Jun 2022 21:12:03 +0000 Subject: [PATCH 11/12] Add Execute Block Handler --- github/GithubApp.ts | 77 +--------------- github/handlers/ExecuteBlockActionHandler.ts | 97 ++++++++++++++++++++ github/handlers/ExecuteViewClosedHandler.ts | 40 ++++++-- 3 files changed, 132 insertions(+), 82 deletions(-) create mode 100644 github/handlers/ExecuteBlockActionHandler.ts diff --git a/github/GithubApp.ts b/github/GithubApp.ts index 70aa3fe..d949115 100644 --- a/github/GithubApp.ts +++ b/github/GithubApp.ts @@ -10,85 +10,18 @@ import { import { App } from "@rocket.chat/apps-engine/definition/App"; import { IAppInfo } from "@rocket.chat/apps-engine/definition/metadata"; import { GithubCommand } from "./commands/GithubCommand"; -import { IRoom } from "@rocket.chat/apps-engine/definition/rooms"; -import { basicQueryMessage } from "./helpers/basicQueryMessage"; -import { ModalsEnum } from "./enum/Modals"; -import { fileCodeModal } from "./modals/fileCodeModal"; -import { IUIKitInteractionHandler, IUIKitResponse, UIKitBlockInteractionContext, UIKitViewCloseInteractionContext, UIKitViewSubmitInteractionContext } from '@rocket.chat/apps-engine/definition/uikit'; +import { IUIKitResponse, UIKitBlockInteractionContext, UIKitViewCloseInteractionContext } from '@rocket.chat/apps-engine/definition/uikit'; import { ExecuteViewClosedHandler } from "./handlers/ExecuteViewClosedHandler"; +import { ExecuteBlockActionHandler } from "./handlers/ExecuteBlockActionHandler"; export class GithubApp extends App { constructor(info: IAppInfo, logger: ILogger, accessors: IAppAccessors) { super(info, logger, accessors); } - public async executeBlockActionHandler( - context: UIKitBlockInteractionContext, - read: IRead, - http: IHttp, - persistence: IPersistence, - modify: IModify - ) { - const data = context.getInteractionData(); - - const { actionId } = data; - - switch (actionId) { - case "githubDataSelect": { - try { - const param = data.value; - let query: String = ""; - let lengthOfRepoString: number = 0; - if (param && param.length) { - let i = param.length - 1; - for ( - ; - i >= 0 && data.value && data.value[i] != "/"; - i-- - ) { - query = data.value[i] + query; - } - lengthOfRepoString = i; - } - const repository = param?.substring( - 0, - lengthOfRepoString - ) as String; - - const room: IRoom = context.getInteractionData() - .room as IRoom; - - await basicQueryMessage({ - query, - repository, - room, - read, - persistence, - modify, - http, - }); - - return { - success: true, - }; - } catch (err) { - console.error(err); - return { - success: false, - }; - } - break; - } - case ModalsEnum.VIEW_FILE_ACTION:{ - const codeModal = await fileCodeModal({data,modify,read,persistence,http,uikitcontext:context}); - return context.getInteractionResponder().openModalViewResponse(codeModal); - } - - } - - return { - success: false, - }; + public async executeBlockActionHandler(context: UIKitBlockInteractionContext, read: IRead, http: IHttp, persistence: IPersistence, modify: IModify): Promise { + const handler = new ExecuteBlockActionHandler(this, read, http, modify, persistence); + return await handler.run(context); } public async executeViewClosedHandler(context: UIKitViewCloseInteractionContext, read: IRead, http: IHttp, persistence: IPersistence, modify: IModify) { diff --git a/github/handlers/ExecuteBlockActionHandler.ts b/github/handlers/ExecuteBlockActionHandler.ts new file mode 100644 index 0000000..261a9e9 --- /dev/null +++ b/github/handlers/ExecuteBlockActionHandler.ts @@ -0,0 +1,97 @@ +import { + IHttp, + ILogger, + IModify, + IPersistence, + IRead, +} from "@rocket.chat/apps-engine/definition/accessors"; +import { IApp } from "@rocket.chat/apps-engine/definition/IApp"; +import { IRoom } from "@rocket.chat/apps-engine/definition/rooms"; +import { basicQueryMessage } from "../helpers/basicQueryMessage"; +import { ModalsEnum } from "../enum/Modals"; +import { fileCodeModal } from "../modals/fileCodeModal"; +import { + IUIKitResponse, + UIKitBlockInteractionContext, +} from "@rocket.chat/apps-engine/definition/uikit"; + +export class ExecuteBlockActionHandler { + constructor( + private readonly app: IApp, + private readonly read: IRead, + private readonly http: IHttp, + private readonly modify: IModify, + private readonly persistence: IPersistence + ) {} + + public async run( + context: UIKitBlockInteractionContext + ): Promise { + const data = context.getInteractionData(); + + const { actionId } = data; + + switch (actionId) { + case "githubDataSelect": { + try { + const param = data.value; + let query: String = ""; + let lengthOfRepoString: number = 0; + if (param && param.length) { + let i = param.length - 1; + for ( + ; + i >= 0 && data.value && data.value[i] != "/"; + i-- + ) { + query = data.value[i] + query; + } + lengthOfRepoString = i; + } + const repository = param?.substring( + 0, + lengthOfRepoString + ) as String; + + const room: IRoom = context.getInteractionData() + .room as IRoom; + + await basicQueryMessage({ + query, + repository, + room, + read: this.read, + persistence: this.persistence, + modify: this.modify, + http: this.http, + }); + + return { + success: true, + }; + } catch (err) { + console.error(err); + return { + success: false, + }; + } + break; + } + case ModalsEnum.VIEW_FILE_ACTION: { + const codeModal = await fileCodeModal({ + data, + modify: this.modify, + read: this.read, + persistence: this.persistence, + http: this.http, + uikitcontext: context, + }); + return context + .getInteractionResponder() + .openModalViewResponse(codeModal); + } + } + + return context.getInteractionResponder().successResponse(); + } +} diff --git a/github/handlers/ExecuteViewClosedHandler.ts b/github/handlers/ExecuteViewClosedHandler.ts index 0ae21fb..f299f78 100644 --- a/github/handlers/ExecuteViewClosedHandler.ts +++ b/github/handlers/ExecuteViewClosedHandler.ts @@ -1,8 +1,13 @@ -import { IHttp, IModify, IPersistence, IRead } from '@rocket.chat/apps-engine/definition/accessors'; -import { IApp } from '@rocket.chat/apps-engine/definition/IApp'; -import { UIKitViewCloseInteractionContext } from '@rocket.chat/apps-engine/definition/uikit'; -import { ModalsEnum } from '../enum/Modals'; -import { pullDetailsModal } from '../modals/pullDetailsModal'; +import { + IHttp, + IModify, + IPersistence, + IRead, +} from "@rocket.chat/apps-engine/definition/accessors"; +import { IApp } from "@rocket.chat/apps-engine/definition/IApp"; +import { UIKitViewCloseInteractionContext } from "@rocket.chat/apps-engine/definition/uikit"; +import { ModalsEnum } from "../enum/Modals"; +import { pullDetailsModal } from "../modals/pullDetailsModal"; export class ExecuteViewClosedHandler { constructor( @@ -10,17 +15,32 @@ export class ExecuteViewClosedHandler { private readonly read: IRead, private readonly http: IHttp, private readonly modify: IModify, - private readonly persistence: IPersistence, - ) { } + private readonly persistence: IPersistence + ) {} public async run(context: UIKitViewCloseInteractionContext) { const { view } = context.getInteractionData(); switch (view.id) { case ModalsEnum.PULL_VIEW || ModalsEnum.CODE_VIEW: - const modal = await pullDetailsModal({ modify: this.modify, read: this.read, persistence: this.persistence, http: this.http,uikitcontext: context }); - await this.modify.getUiController().updateModalView(modal, { triggerId: context.getInteractionData().triggerId as string }, context.getInteractionData().user); + const modal = await pullDetailsModal({ + modify: this.modify, + read: this.read, + persistence: this.persistence, + http: this.http, + uikitcontext: context, + }); + await this.modify + .getUiController() + .updateModalView( + modal, + { + triggerId: context.getInteractionData() + .triggerId as string, + }, + context.getInteractionData().user + ); break; } return { success: true } as any; } -} \ No newline at end of file +} From b7b4d729382b02748265b4bdf5881436e49bdb82 Mon Sep 17 00:00:00 2001 From: Samad Yar Khan Date: Tue, 14 Jun 2022 21:14:16 +0000 Subject: [PATCH 12/12] Update Helper Mesage --- github/lib/helperMessage.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/github/lib/helperMessage.ts b/github/lib/helperMessage.ts index da58390..f883b7e 100644 --- a/github/lib/helperMessage.ts +++ b/github/lib/helperMessage.ts @@ -27,7 +27,8 @@ export async function helperMessage({ 3) Get Issues of a Repository -> /github GithubUsername/RepositoryName issues 4) Get Contributors of a Repository -> /github GithubUsername/RepositoryName contributors 5) Get Recent Pull Request of a Repository -> /github GithubUsername/RepositoryName pulls - + 6) Review a Pull Request -> /github GithubUsername/RepositoryName pulls pullNumber + `; const textSender = await modify