-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
596 changed files
with
44,702 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
!/gulpfile.js | ||
/client | ||
/definition | ||
/docs | ||
/server | ||
/lib | ||
/deno-runtime | ||
/.deno |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"extends": "@rocket.chat/eslint-config", | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"project": "./tsconfig-lint.json" | ||
}, | ||
"rules": { | ||
"@typescript-eslint/ban-types": [ | ||
"error", | ||
{ | ||
"types": { | ||
"{}": false | ||
} | ||
} | ||
], | ||
"@typescript-eslint/naming-convention": [ | ||
"error", | ||
{ | ||
"selector": ["function", "parameter", "variable"], | ||
"modifiers": ["destructured"], | ||
"format": null | ||
}, | ||
{ | ||
"selector": ["variable"], | ||
"format": ["camelCase", "UPPER_CASE", "PascalCase"], | ||
"leadingUnderscore": "allowSingleOrDouble" | ||
}, | ||
{ | ||
"selector": ["function"], | ||
"format": ["camelCase", "PascalCase"], | ||
"leadingUnderscore": "allowSingleOrDouble" | ||
}, | ||
{ | ||
"selector": ["parameter"], | ||
"format": ["camelCase"], | ||
"leadingUnderscore": "allow" | ||
}, | ||
{ | ||
"selector": ["parameter"], | ||
"format": ["camelCase"], | ||
"modifiers": ["unused"], | ||
"leadingUnderscore": "allow" | ||
}, | ||
{ | ||
"selector": ["interface"], | ||
"format": ["PascalCase"], | ||
"custom": { | ||
"regex": "^I[A-Z]", | ||
"match": true | ||
} | ||
} | ||
], | ||
"@typescript-eslint/no-empty-function": "off", | ||
"@typescript-eslint/no-unused-vars": ["error", { "args": "none" }], | ||
"new-cap": "off", | ||
"no-await-in-loop": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Created by https://www.gitignore.io/api/node | ||
|
||
### Node ### | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
.deno | ||
.deno-cache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
### Typings ### | ||
## Ignore downloaded typings | ||
/typings | ||
|
||
## dev environment stuff | ||
/examples/ | ||
/dev-dist/ | ||
/data/ | ||
/tests/test-data/dbs | ||
/client | ||
/definition | ||
/server | ||
/lib | ||
|
||
.DS_Store | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"tabWidth": 4, | ||
"useTabs": false, | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"printWidth": 160 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015-2023 Rocket.Chat Technologies Corp. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
## Thoughts While Working (for docs) | ||
- Apps which don't provide a valid uuid4 id will be assigned one, but this is not recommended and your App should provide an id | ||
- The language strings are only done on the clients (`TAPi18next.addResourceBundle(lang, projectName, translations);`) | ||
- The implementer of this should restrict the server setting access and environmental variables. Idea is to allow the implementer to have a default set of restricted ones while letting the admin/owner of the server to restrict it even further or lift the restriction on some more. Simple interface with settings and checkbox to allow/disallow them. :thinking: | ||
|
||
## What does the Apps-Engine enable you to do? | ||
The Apps-Engine is Rocket.Chat's _plugin framework_ - it provides the APIs for Rocket.Chat Apps to interact with the host system. | ||
|
||
Currently, a Rocket.Chat App can: | ||
- Listen to message events | ||
- before/after sent | ||
- before/after updated | ||
- before/after deleted | ||
- Listen to room events | ||
- before/after created | ||
- before/after deleted | ||
- Send messages to users and livechat visitors | ||
- Register new slash commands | ||
- Register new HTTP endpoints | ||
|
||
Some features the Engine allows Apps to use: | ||
- Key-Value Storage system | ||
- App specific settings | ||
|
||
## Development environment with Rocket.Chat | ||
When developing new functionalities, you need to integrate the local version of the Apps-Engine with your local version of Rocket.Chat. | ||
|
||
First of all, make sure you've installed all required packages and compiled the changes you've made to the Apps-Engine, since that is what Rocket.Chat will execute: | ||
```sh | ||
npm install | ||
npm run compile | ||
``` | ||
|
||
Now, you need to setup a local Rocket.Chat server, [so head to the project's README for instructions on getting started](https://github.com/RocketChat/Rocket.Chat#development) (if you haven't already). Make sure to actually clone the repo, since you will probably need to add some code to it in order to make your new functionality work. | ||
|
||
After that, `cd` into Rocket.Chat folder and run: | ||
```sh | ||
meteor npm install PATH_TO_APPS_ENGINE | ||
``` | ||
|
||
Where `PATH_TO_APPS_ENGINE` is the path to the Apps-Engine repo you've cloned. | ||
|
||
That's it! Now when you start Rocket.Chat with the `meteor` command, it will use your local Apps-Engine instead of the one on NPM :) | ||
|
||
Whenever you make changes to the engine, run `npm run compile` again - meteor will take care of restarting the server due to the changes. | ||
|
||
## Troubleshooting | ||
1. Sometimes, when you update the Apps-Engine code and compile it while Rocket.Chat is running, you might run on errors similar to these: | ||
|
||
``` | ||
Unable to resolve some modules: | ||
"@rocket.chat/apps-engine/definition/AppStatus" in | ||
/Users/dev/rocket.chat/Rocket.Chat/app/apps/client/admin/helpers.js (web.browser) | ||
If you notice problems related to these missing modules, consider running: | ||
meteor npm install --save @rocket.chat/apps-engine | ||
``` | ||
|
||
Simply restart the meteor process and it should be fixed. | ||
|
||
2. Sometimes when using `meteor npm install PATH_TO_APPS_ENGINE` will cause the following error :- | ||
|
||
``` | ||
npm ERR! code ENOENT | ||
npm ERR! syscall rename | ||
npm ERR! path PATH_TO_ROCKETCHAT/node_modules/.staging/@rocket.chat/apps-engine-c7135600/node_modules/@babel/code-frame | ||
npm ERR! dest PATH_TO_ROCKETCHAT/node_modules/.staging/@babel/code-frame-f3697825 | ||
npm ERR! errno -2 | ||
npm ERR! enoent ENOENT: no such file or directory, rename 'PATH_TO_ROCKETCHAT/node_modules/.staging/@rocket.chat/apps-engine-c7135600/node_modules/@babel/code-frame' -> 'PATH_TO_ROCKETCHAT/node_modules/.staging/@babel/code-frame-f3697825' | ||
npm ERR! enoent This is related to npm not being able to find a file. | ||
npm ERR! enoent | ||
``` | ||
Here `PATH_TO_ROCKETCHAT` is the path to the main rocketchat server repo in your system | ||
To correct this we reinstall the package once again deleting the previous package | ||
``` | ||
~/Rocket.Chat$ rm -rf node_modules/@rocket.chat/apps-engine | ||
~/Rocket.Chat$ cd PATH_TO_APP_ENGINE | ||
~/Rocket.Chat.Apps-engine$ npm install | ||
~/Rocket.Chat.Apps-engine$ cd PATH_TO_ROCKETCHAT | ||
~/Rocket.Chat$ meteor npm install ../Rocket.Chat.Apps-engine | ||
``` | ||
|
||
## Implementer Needs to Implement: | ||
- `src/server/storage/AppStorage` | ||
- `src/server/storage/AppLogStorage` | ||
- `src/server/bridges/*` | ||
|
||
## Testing Framework: | ||
Makes great usage of TypeScript and decorators: https://github.com/alsatian-test/alsatian/wiki | ||
* To run the tests do: `npm run unit-tests` | ||
* To generate the coverage information: `npm run check-coverage` | ||
* To view the coverage: `npm run view-coverage` | ||
|
||
# Rocket.Chat Apps TypeScript Definitions | ||
|
||
## Handlers | ||
Handlers are essentially "listeners" for different events, except there are various ways to handle an event. | ||
When something happens there is `pre` and `post` handlers. | ||
The set of `pre` handlers happens before the event is finalized. | ||
The set of `post` handlers happens after the event is finalized. | ||
With that said, the rule of thumb is that if you are going to modify, extend, or change the data backing the event then that should be done in the `pre` handlers. If you are simply wanting to listen for when something happens and not modify anything, then the `post` is the way to go. | ||
|
||
The order in which they happen is: | ||
* Pre**Event**Prevent | ||
* Pre**Event**Extend | ||
* Pre**Event**Modify | ||
* Post**Event** | ||
|
||
Here is an explanation of what each of them means: | ||
* **Prevent**: This is ran to determine whether the event should be prevented or not. | ||
* **Extend**: This is ran to allow extending the data without being destructive of the data (adding an attachment to a message for example). | ||
* **Modify**: This is ran and allows for destructive changes to the data (change any and everything). | ||
* Post**Event**: Is mostly for simple listening and no changes can be made to the data. | ||
|
||
## Generating/Updating Documentation | ||
To update or generate the documentation, please commit your changes first and then in a second commit provide the updated documentation. | ||
|
||
# Engage with us | ||
## Share your story | ||
We’d love to hear about [your experience](https://survey.zohopublic.com/zs/e4BUFG) and potentially feature it on our [Blog](https://rocket.chat/case-studies/?utm_source=github&utm_medium=readme&utm_campaign=community). | ||
|
||
## Subscribe for Updates | ||
Once a month our marketing team releases an email update with news about product releases, company related topics, events and use cases. [Sign Up!](https://rocket.chat/newsletter/?utm_source=github&utm_medium=readme&utm_campaign=community) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.deno/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export type Maybe<T> = T | null | undefined; | ||
|
||
export const AppObjectRegistry = new class { | ||
registry: Record<string, unknown> = {}; | ||
|
||
public get<T>(key: string): Maybe<T> { | ||
return this.registry[key] as Maybe<T>; | ||
} | ||
|
||
public set(key: string, value: unknown): void { | ||
this.registry[key] = value; | ||
} | ||
|
||
public has(key: string): boolean { | ||
return key in this.registry; | ||
} | ||
|
||
public delete(key: string): void { | ||
delete this.registry[key]; | ||
} | ||
|
||
public clear(): void { | ||
this.registry = {}; | ||
} | ||
} | ||
|
Oops, something went wrong.