Convert rocketchat-apps to main module structure (#13409)

* Remove some dependencies inside rocketchat-lib/client  (#13210)

* Move function to rc-utils

* Change import from to export directly

* Removing duplicated dependency and remove old code

* Import some variables to remove dependency of RC namespace

* Remove some dependencies inside rocketchat-lib/lib (#13212)

* Move some functions from lib to rc-ui-utils

* Move some functions from lib ro rc-utils

* Remove hostname from RC namespace

* Import variables to remove dependency of RC namespace

* Remove some dependencies inside rocketchat-lib/server/functions (#13214)

* Move integrations models to rc-models

* Move composeMessage function to rc-utils

* Move PushNotifications class to push-notifications package

* Import variables to remove dependency of RC namespace

* Remove some dependencies inside rocketchat-lib/server/lib (#13217)

* Move integrations models to rc-models

* Move composeMessage function to rc-utils

* Move PushNotifications class to push-notifications package

* Import variables to remove dependency of RC namespace

* Import variables to remove RC namespace dependency inside rc-lib/server/lib

* Remove some dependencies inside rocketchat-lib/server/methods (#13218)

* Move integrations models to rc-models

* Move composeMessage function to rc-utils

* Move PushNotifications class to push-notifications package

* Import variables to remove dependency of RC namespace

* Import variables to remove RC namespace dependency inside rc-lib/server/lib

* Import variables to remove RC namespace inside rc-lib/server/methods

* Remove some dependencies inside rocketchat-lib/server/startup, publications... (#13222)

* Move integrations models to rc-models

* Move composeMessage function to rc-utils

* Move PushNotifications class to push-notifications package

* Import variables to remove dependency of RC namespace

* Import variables to remove RC namespace dependency inside rc-lib/server/lib

* Import variables to remove RC namespace inside rc-lib/server/methods

* Import variables to remove dependency with RC namespace

* Remove duplicated server settings (#13223)

* Move integrations models to rc-models

* Move composeMessage function to rc-utils

* Move PushNotifications class to push-notifications package

* Import variables to remove dependency of RC namespace

* Import variables to remove RC namespace dependency inside rc-lib/server/lib

* Import variables to remove RC namespace inside rc-lib/server/methods

* Import variables to remove dependency with RC namespace

* Remove duplicated server settings located in rc-lib

*  Export functions and lib function of rc-lib but keep it inside RC namespace (#13225)

* Move integrations models to rc-models

* Move composeMessage function to rc-utils

* Move PushNotifications class to push-notifications package

* Import variables to remove dependency of RC namespace

* Import variables to remove RC namespace dependency inside rc-lib/server/lib

* Import variables to remove RC namespace inside rc-lib/server/methods

* Import variables to remove dependency with RC namespace

* Remove duplicated server settings located in rc-lib

* Export function and lib function of rc-lib but keep it inside RC namespace

* Fix missed exports and re-add some functions to RC namespace

*  Import variables from functions and lib to remove RC namespace dependency (#13226)

* Move integrations models to rc-models

* Move composeMessage function to rc-utils

* Move PushNotifications class to push-notifications package

* Import variables to remove dependency of RC namespace

* Import variables to remove RC namespace dependency inside rc-lib/server/lib

* Import variables to remove RC namespace inside rc-lib/server/methods

* Import variables to remove dependency with RC namespace

* Remove duplicated server settings located in rc-lib

* Export function and lib function of rc-lib but keep it inside RC namespace

* Import variables from functions and lib to remove RC namespace dependency

*  Remove dependency of RC namespace in rc-sandstorm (#13227)

* Move integrations models to rc-models

* Move composeMessage function to rc-utils

* Move PushNotifications class to push-notifications package

* Import variables to remove dependency of RC namespace

* Import variables to remove RC namespace dependency inside rc-lib/server/lib

* Import variables to remove RC namespace inside rc-lib/server/methods

* Import variables to remove dependency with RC namespace

* Remove duplicated server settings located in rc-lib

* Export function and lib function of rc-lib but keep it inside RC namespace

* Import variables from functions and lib to remove RC namespace dependency

* Remove dependency of RC namespace in rc-sandstorm

*  Remove dependency of RC namespace in chatpal-search (#13231)

* Move integrations models to rc-models

* Move composeMessage function to rc-utils

* Move PushNotifications class to push-notifications package

* Import variables to remove dependency of RC namespace

* Import variables to remove RC namespace dependency inside rc-lib/server/lib

* Import variables to remove RC namespace inside rc-lib/server/methods

* Import variables to remove dependency with RC namespace

* Remove duplicated server settings located in rc-lib

* Export function and lib function of rc-lib but keep it inside RC namespace

* Import variables from functions and lib to remove RC namespace dependency

* Remove dependency of RC namespace in rc-sandstorm

* Remove dependency of RC namespace in chatpal-search

*  Remove dependency of RC namespace in meteor saml (#13233)

* Move integrations models to rc-models

* Move composeMessage function to rc-utils

* Move PushNotifications class to push-notifications package

* Import variables to remove dependency of RC namespace

* Import variables to remove RC namespace dependency inside rc-lib/server/lib

* Import variables to remove RC namespace inside rc-lib/server/methods

* Import variables to remove dependency with RC namespace

* Remove duplicated server settings located in rc-lib

* Export function and lib function of rc-lib but keep it inside RC namespace

* Import variables from functions and lib to remove RC namespace dependency

* Remove dependency of RC namespace in rc-sandstorm

* Remove dependency of RC namespace in chatpal-search

* Move CreadentialTokens model to rc-models

* Move getUsernameSuggestion function and method from server/ to rc-lib

* Remove dependency of RC namespace in meteor saml

*  Remove dependency of RC namespace in rc-theme (#13234)

* Move integrations models to rc-models

* Move composeMessage function to rc-utils

* Move PushNotifications class to push-notifications package

* Import variables to remove dependency of RC namespace

* Import variables to remove RC namespace dependency inside rc-lib/server/lib

* Import variables to remove RC namespace inside rc-lib/server/methods

* Import variables to remove dependency with RC namespace

* Remove duplicated server settings located in rc-lib

* Export function and lib function of rc-lib but keep it inside RC namespace

* Import variables from functions and lib to remove RC namespace dependency

* Remove dependency of RC namespace in rc-sandstorm

* Remove dependency of RC namespace in chatpal-search

* Move CreadentialTokens model to rc-models

* Move getUsernameSuggestion function and method from server/ to rc-lib

* Remove dependency of RC namespace in meteor saml

* Remove dependency of RC namespace in rc-theme

*  Remove dependency of RC namespace in rc-2fa (#13235)

* Move integrations models to rc-models

* Move composeMessage function to rc-utils

* Move PushNotifications class to push-notifications package

* Import variables to remove dependency of RC namespace

* Import variables to remove RC namespace dependency inside rc-lib/server/lib

* Import variables to remove RC namespace inside rc-lib/server/methods

* Import variables to remove dependency with RC namespace

* Remove duplicated server settings located in rc-lib

* Export function and lib function of rc-lib but keep it inside RC namespace

* Import variables from functions and lib to remove RC namespace dependency

* Remove dependency of RC namespace in rc-sandstorm

* Remove dependency of RC namespace in chatpal-search

* Move CreadentialTokens model to rc-models

* Move getUsernameSuggestion function and method from server/ to rc-lib

* Remove dependency of RC namespace in meteor saml

* Remove dependency of RC namespace in rc-theme

* Move 2FA Users model to rc-models

* Remove dependency of RC namespace in rc-2fa

*  Remove dependency of RC namespace in rc-action-links (#13236)

* Move integrations models to rc-models

* Move composeMessage function to rc-utils

* Move PushNotifications class to push-notifications package

* Import variables to remove dependency of RC namespace

* Import variables to remove RC namespace dependency inside rc-lib/server/lib

* Import variables to remove RC namespace inside rc-lib/server/methods

* Import variables to remove dependency with RC namespace

* Remove duplicated server settings located in rc-lib

* Export function and lib function of rc-lib but keep it inside RC namespace

* Import variables from functions and lib to remove RC namespace dependency

* Remove dependency of RC namespace in rc-sandstorm

* Remove dependency of RC namespace in chatpal-search

* Move CreadentialTokens model to rc-models

* Move getUsernameSuggestion function and method from server/ to rc-lib

* Remove dependency of RC namespace in meteor saml

* Remove dependency of RC namespace in rc-theme

* Move 2FA Users model to rc-models

* Remove dependency of RC namespace in rc-2fa

* Remove dependency of RC namespace in rc-action-links

* Add action links in the RC namespace

*  Remove dependency of RC namespace in rc-analytics and rc-assets (#13237)

* Move integrations models to rc-models

* Move composeMessage function to rc-utils

* Move PushNotifications class to push-notifications package

* Import variables to remove dependency of RC namespace

* Import variables to remove RC namespace dependency inside rc-lib/server/lib

* Import variables to remove RC namespace inside rc-lib/server/methods

* Import variables to remove dependency with RC namespace

* Remove duplicated server settings located in rc-lib

* Export function and lib function of rc-lib but keep it inside RC namespace

* Import variables from functions and lib to remove RC namespace dependency

* Remove dependency of RC namespace in rc-sandstorm

* Remove dependency of RC namespace in chatpal-search

* Move CreadentialTokens model to rc-models

* Move getUsernameSuggestion function and method from server/ to rc-lib

* Remove dependency of RC namespace in meteor saml

* Remove dependency of RC namespace in rc-theme

* Move 2FA Users model to rc-models

* Remove dependency of RC namespace in rc-2fa

* Remove dependency of RC namespace in rc-action-links

* Add action links in the RC namespace

* Remove dependency of RC namespace in rc-analytics

* Remove dependency of RC namespace in rc-assets

* Add Assets in RC namespace

* Rename Assets variable to avoid conflicts

* Fix rename Assets

*  Remove dependency of RC namespace in rc-markdown, rc-autolinker and rc-autotranslate (#13240)

* Move integrations models to rc-models

* Move composeMessage function to rc-utils

* Move PushNotifications class to push-notifications package

* Import variables to remove dependency of RC namespace

* Import variables to remove RC namespace dependency inside rc-lib/server/lib

* Import variables to remove RC namespace inside rc-lib/server/methods

* Import variables to remove dependency with RC namespace

* Remove duplicated server settings located in rc-lib

* Export function and lib function of rc-lib but keep it inside RC namespace

* Import variables from functions and lib to remove RC namespace dependency

* Remove dependency of RC namespace in rc-sandstorm

* Remove dependency of RC namespace in chatpal-search

* Move CreadentialTokens model to rc-models

* Move getUsernameSuggestion function and method from server/ to rc-lib

* Remove dependency of RC namespace in meteor saml

* Remove dependency of RC namespace in rc-theme

* Move 2FA Users model to rc-models

* Remove dependency of RC namespace in rc-2fa

* Remove dependency of RC namespace in rc-action-links

* Add action links in the RC namespace

* Remove dependency of RC namespace in rc-analytics

* Remove dependency of RC namespace in rc-assets

* Add Assets in RC namespace

* Remove dependency of RC namespace in rc-autolinker

* Move autotranslate models to rc-models

* Partial remove dependency of Rc namespace in rc-autotranslate

* Remove dependency of RC namespace in rc-markdown

* Finish of remotion of RC namespace in rc-autotranslate

* Import Autotranslate where it has been used

* Fix lint

* Rename Assets variable to avoid conflicts

* Fix rename Assets

* Fix wrong imports

*  Remove dependency of RC namespace in rc-blockstack, bot-helpers and cas (#13246)

* Move integrations models to rc-models

* Move composeMessage function to rc-utils

* Move PushNotifications class to push-notifications package

* Import variables to remove dependency of RC namespace

* Import variables to remove RC namespace dependency inside rc-lib/server/lib

* Import variables to remove RC namespace inside rc-lib/server/methods

* Import variables to remove dependency with RC namespace

* Remove duplicated server settings located in rc-lib

* Export function and lib function of rc-lib but keep it inside RC namespace

* Import variables from functions and lib to remove RC namespace dependency

* Remove dependency of RC namespace in rc-sandstorm

* Remove dependency of RC namespace in chatpal-search

* Move CreadentialTokens model to rc-models

* Move getUsernameSuggestion function and method from server/ to rc-lib

* Remove dependency of RC namespace in meteor saml

* Remove dependency of RC namespace in rc-theme

* Move 2FA Users model to rc-models

* Remove dependency of RC namespace in rc-2fa

* Remove dependency of RC namespace in rc-action-links

* Add action links in the RC namespace

* Remove dependency of RC namespace in rc-analytics

* Remove dependency of RC namespace in rc-assets

* Add Assets in RC namespace

* Remove dependency of RC namespace in rc-autolinker

* Move autotranslate models to rc-models

* Partial remove dependency of Rc namespace in rc-autotranslate

* Remove dependency of RC namespace in rc-markdown

* Finish of remotion of RC namespace in rc-autotranslate

* Import Autotranslate where it has been used

* Fix lint

* Rename Assets variable to avoid conflicts

* Fix rename Assets

* Remove dependency of RC namespace in rc-blockstack

* Remove RC dependency in bot-helpers

* Remove RC dependency in rc-cas

* Fix wrong imports

* Remove dependency of RC namespace in rc-channel-settings (#13251)

* Move integrations models to rc-models

* Move composeMessage function to rc-utils

* Move PushNotifications class to push-notifications package

* Import variables to remove dependency of RC namespace

* Import variables to remove RC namespace dependency inside rc-lib/server/lib

* Import variables to remove RC namespace inside rc-lib/server/methods

* Import variables to remove dependency with RC namespace

* Remove duplicated server settings located in rc-lib

* Export function and lib function of rc-lib but keep it inside RC namespace

* Import variables from functions and lib to remove RC namespace dependency

* Remove dependency of RC namespace in rc-sandstorm

* Remove dependency of RC namespace in chatpal-search

* Move CreadentialTokens model to rc-models

* Move getUsernameSuggestion function and method from server/ to rc-lib

* Remove dependency of RC namespace in meteor saml

* Remove dependency of RC namespace in rc-theme

* Move 2FA Users model to rc-models

* Remove dependency of RC namespace in rc-2fa

* Remove dependency of RC namespace in rc-action-links

* Add action links in the RC namespace

* Remove dependency of RC namespace in rc-analytics

* Remove dependency of RC namespace in rc-assets

* Add Assets in RC namespace

* Remove dependency of RC namespace in rc-autolinker

* Move autotranslate models to rc-models

* Partial remove dependency of Rc namespace in rc-autotranslate

* Remove dependency of RC namespace in rc-markdown

* Finish of remotion of RC namespace in rc-autotranslate

* Import Autotranslate where it has been used

* Fix lint

* Rename Assets variable to avoid conflicts

* Fix rename Assets

* Remove dependency of RC namespace in rc-blockstack

* Remove RC dependency in bot-helpers

* Remove RC dependency in rc-cas

* Move some functions from tokenpass to channel settings and models

* Move some function from livestream to channel settings

* Remove dependency of RC namespace in rc-channel-settings

* Fix wrong imports

* readd saveRoomName to RC namespace

*  Remove dependency of RC namespace in rc-channel-mail-messages and cloud (#13254)

* Move integrations models to rc-models

* Move composeMessage function to rc-utils

* Move PushNotifications class to push-notifications package

* Import variables to remove dependency of RC namespace

* Import variables to remove RC namespace dependency inside rc-lib/server/lib

* Import variables to remove RC namespace inside rc-lib/server/methods

* Import variables to remove dependency with RC namespace

* Remove duplicated server settings located in rc-lib

* Export function and lib function of rc-lib but keep it inside RC namespace

* Import variables from functions and lib to remove RC namespace dependency

* Remove dependency of RC namespace in rc-sandstorm

* Remove dependency of RC namespace in chatpal-search

* Move CreadentialTokens model to rc-models

* Move getUsernameSuggestion function and method from server/ to rc-lib

* Remove dependency of RC namespace in meteor saml

* Remove dependency of RC namespace in rc-theme

* Move 2FA Users model to rc-models

* Remove dependency of RC namespace in rc-2fa

* Remove dependency of RC namespace in rc-action-links

* Add action links in the RC namespace

* Remove dependency of RC namespace in rc-analytics

* Remove dependency of RC namespace in rc-assets

* Add Assets in RC namespace

* Remove dependency of RC namespace in rc-autolinker

* Move autotranslate models to rc-models

* Partial remove dependency of Rc namespace in rc-autotranslate

* Remove dependency of RC namespace in rc-markdown

* Finish of remotion of RC namespace in rc-autotranslate

* Import Autotranslate where it has been used

* Fix lint

* Rename Assets variable to avoid conflicts

* Fix rename Assets

* Remove dependency of RC namespace in rc-blockstack

* Remove RC dependency in bot-helpers

* Remove RC dependency in rc-cas

* Move some functions from tokenpass to channel settings and models

* Move some function from livestream to channel settings

* Remove dependency of RC namespace in rc-channel-settings

* Fix wrong imports

* Remove dependency of RC namespace in rc-channel-mail-messages

* Remove dependency of RC namespace in rc-cloud

*  Remove dependency of RC namespace in rc-colors, cors, crowd and dolphin (#13255)

* Move integrations models to rc-models

* Move composeMessage function to rc-utils

* Move PushNotifications class to push-notifications package

* Import variables to remove dependency of RC namespace

* Import variables to remove RC namespace dependency inside rc-lib/server/lib

* Import variables to remove RC namespace inside rc-lib/server/methods

* Import variables to remove dependency with RC namespace

* Remove duplicated server settings located in rc-lib

* Export function and lib function of rc-lib but keep it inside RC namespace

* Import variables from functions and lib to remove RC namespace dependency

* Remove dependency of RC namespace in rc-sandstorm

* Remove dependency of RC namespace in chatpal-search

* Move CreadentialTokens model to rc-models

* Move getUsernameSuggestion function and method from server/ to rc-lib

* Remove dependency of RC namespace in meteor saml

* Remove dependency of RC namespace in rc-theme

* Move 2FA Users model to rc-models

* Remove dependency of RC namespace in rc-2fa

* Remove dependency of RC namespace in rc-action-links

* Add action links in the RC namespace

* Remove dependency of RC namespace in rc-analytics

* Remove dependency of RC namespace in rc-assets

* Add Assets in RC namespace

* Remove dependency of RC namespace in rc-autolinker

* Move autotranslate models to rc-models

* Partial remove dependency of Rc namespace in rc-autotranslate

* Remove dependency of RC namespace in rc-markdown

* Finish of remotion of RC namespace in rc-autotranslate

* Import Autotranslate where it has been used

* Fix lint

* Rename Assets variable to avoid conflicts

* Fix rename Assets

* Remove dependency of RC namespace in rc-blockstack

* Remove RC dependency in bot-helpers

* Remove RC dependency in rc-cas

* Move some functions from tokenpass to channel settings and models

* Move some function from livestream to channel settings

* Remove dependency of RC namespace in rc-channel-settings

* Fix wrong imports

* Remove dependency of RC namespace in rc-channel-mail-messages

* Remove dependency of RC namespace in rc-cloud

* Remove dependency of RC namespace in rc-colors

* Remove dependency of RC namespace in rc-cors

* Remove dependency of RC namespace in rc-crowd

* Remove dependency of RC namespace in rc-dolphin

*  Remove dependency of RC namespace in rc-emoji-custom and drupal (#13256)

* Move integrations models to rc-models

* Move composeMessage function to rc-utils

* Move PushNotifications class to push-notifications package

* Import variables to remove dependency of RC namespace

* Import variables to remove RC namespace dependency inside rc-lib/server/lib

* Import variables to remove RC namespace inside rc-lib/server/methods

* Import variables to remove dependency with RC namespace

* Remove duplicated server settings located in rc-lib

* Export function and lib function of rc-lib but keep it inside RC namespace

* Import variables from functions and lib to remove RC namespace dependency

* Remove dependency of RC namespace in rc-sandstorm

* Remove dependency of RC namespace in chatpal-search

* Move CreadentialTokens model to rc-models

* Move getUsernameSuggestion function and method from server/ to rc-lib

* Remove dependency of RC namespace in meteor saml

* Remove dependency of RC namespace in rc-theme

* Move 2FA Users model to rc-models

* Remove dependency of RC namespace in rc-2fa

* Remove dependency of RC namespace in rc-action-links

* Add action links in the RC namespace

* Remove dependency of RC namespace in rc-analytics

* Remove dependency of RC namespace in rc-assets

* Add Assets in RC namespace

* Remove dependency of RC namespace in rc-autolinker

* Move autotranslate models to rc-models

* Partial remove dependency of Rc namespace in rc-autotranslate

* Remove dependency of RC namespace in rc-markdown

* Finish of remotion of RC namespace in rc-autotranslate

* Import Autotranslate where it has been used

* Fix lint

* Rename Assets variable to avoid conflicts

* Fix rename Assets

* Remove dependency of RC namespace in rc-blockstack

* Remove RC dependency in bot-helpers

* Remove RC dependency in rc-cas

* Move some functions from tokenpass to channel settings and models

* Move some function from livestream to channel settings

* Remove dependency of RC namespace in rc-channel-settings

* Fix wrong imports

* Remove dependency of RC namespace in rc-channel-mail-messages

* Remove dependency of RC namespace in rc-cloud

* Remove dependency of RC namespace in rc-colors

* Remove dependency of RC namespace in rc-cors

* Remove dependency of RC namespace in rc-crowd

* Remove dependency of RC namespace in rc-dolphin

* Remove dependency of RC namespace in rc-drupal

* Move Emoji custom server and client models to rc-models

* Remove dependency of RC namespace in rc-emoji-custom

* Remove dependency of RC namespace in rc-emojione, error-handler, gh-enterprise and gitlab (#13257)

* Move integrations models to rc-models

* Move composeMessage function to rc-utils

* Move PushNotifications class to push-notifications package

* Import variables to remove dependency of RC namespace

* Import variables to remove RC namespace dependency inside rc-lib/server/lib

* Import variables to remove RC namespace inside rc-lib/server/methods

* Import variables to remove dependency with RC namespace

* Remove duplicated server settings located in rc-lib

* Export function and lib function of rc-lib but keep it inside RC namespace

* Import variables from functions and lib to remove RC namespace dependency

* Remove dependency of RC namespace in rc-sandstorm

* Remove dependency of RC namespace in chatpal-search

* Move CreadentialTokens model to rc-models

* Move getUsernameSuggestion function and method from server/ to rc-lib

* Remove dependency of RC namespace in meteor saml

* Remove dependency of RC namespace in rc-theme

* Move 2FA Users model to rc-models

* Remove dependency of RC namespace in rc-2fa

* Remove dependency of RC namespace in rc-action-links

* Add action links in the RC namespace

* Remove dependency of RC namespace in rc-analytics

* Remove dependency of RC namespace in rc-assets

* Add Assets in RC namespace

* Remove dependency of RC namespace in rc-autolinker

* Move autotranslate models to rc-models

* Partial remove dependency of Rc namespace in rc-autotranslate

* Remove dependency of RC namespace in rc-markdown

* Finish of remotion of RC namespace in rc-autotranslate

* Import Autotranslate where it has been used

* Fix lint

* Rename Assets variable to avoid conflicts

* Fix rename Assets

* Remove dependency of RC namespace in rc-blockstack

* Remove RC dependency in bot-helpers

* Remove RC dependency in rc-cas

* Move some functions from tokenpass to channel settings and models

* Move some function from livestream to channel settings

* Remove dependency of RC namespace in rc-channel-settings

* Fix wrong imports

* Remove dependency of RC namespace in rc-channel-mail-messages

* Remove dependency of RC namespace in rc-cloud

* Remove dependency of RC namespace in rc-colors

* Remove dependency of RC namespace in rc-cors

* Remove dependency of RC namespace in rc-crowd

* Remove dependency of RC namespace in rc-dolphin

* Remove dependency of RC namespace in rc-drupal

* Move Emoji custom server and client models to rc-models

* Remove dependency of RC namespace in rc-emoji-custom

* Remove dependency of RC namespace in rc-emojione

* Remove dependency of RC namespace in rc-error-handler

* Remove dependency of RC namespace in rc-gh-enterprise

* Remove dependency of RC namespace in rc-gitlab

* Remove dependency of RC namespace in rc-google-natural-language, grant, google-vision and highlight-words (#13258)

* Move integrations models to rc-models

* Move composeMessage function to rc-utils

* Move PushNotifications class to push-notifications package

* Import variables to remove dependency of RC namespace

* Import variables to remove RC namespace dependency inside rc-lib/server/lib

* Import variables to remove RC namespace inside rc-lib/server/methods

* Import variables to remove dependency with RC namespace

* Remove duplicated server settings located in rc-lib

* Export function and lib function of rc-lib but keep it inside RC namespace

* Import variables from functions and lib to remove RC namespace dependency

* Remove dependency of RC namespace in rc-sandstorm

* Remove dependency of RC namespace in chatpal-search

* Move CreadentialTokens model to rc-models

* Move getUsernameSuggestion function and method from server/ to rc-lib

* Remove dependency of RC namespace in meteor saml

* Remove dependency of RC namespace in rc-theme

* Move 2FA Users model to rc-models

* Remove dependency of RC namespace in rc-2fa

* Remove dependency of RC namespace in rc-action-links

* Add action links in the RC namespace

* Remove dependency of RC namespace in rc-analytics

* Remove dependency of RC namespace in rc-assets

* Add Assets in RC namespace

* Remove dependency of RC namespace in rc-autolinker

* Move autotranslate models to rc-models

* Partial remove dependency of Rc namespace in rc-autotranslate

* Remove dependency of RC namespace in rc-markdown

* Finish of remotion of RC namespace in rc-autotranslate

* Import Autotranslate where it has been used

* Fix lint

* Rename Assets variable to avoid conflicts

* Fix rename Assets

* Remove dependency of RC namespace in rc-blockstack

* Remove RC dependency in bot-helpers

* Remove RC dependency in rc-cas

* Move some functions from tokenpass to channel settings and models

* Move some function from livestream to channel settings

* Remove dependency of RC namespace in rc-channel-settings

* Fix wrong imports

* Remove dependency of RC namespace in rc-channel-mail-messages

* Remove dependency of RC namespace in rc-cloud

* Remove dependency of RC namespace in rc-colors

* Remove dependency of RC namespace in rc-cors

* Remove dependency of RC namespace in rc-crowd

* Remove dependency of RC namespace in rc-dolphin

* Remove dependency of RC namespace in rc-drupal

* Move Emoji custom server and client models to rc-models

* Remove dependency of RC namespace in rc-emoji-custom

* Remove dependency of RC namespace in rc-emojione

* Remove dependency of RC namespace in rc-error-handler

* Remove dependency of RC namespace in rc-gh-enterprise

* Remove dependency of RC namespace in rc-gitlab

* Remove dependency of RC namespace in rc-google-natural-language

* Remove dependency of RC namespace in rc-grant

* Remove dependency of RC namespace in rc-highlight-words

* Remove dependency of RC namespace in rc-google-vision

* Fix lint

*  Remove dependency of RC namespace in rc-iframe-login and all imports, except hipchat-enterprise (#13259)

* Move integrations models to rc-models

* Move composeMessage function to rc-utils

* Move PushNotifications class to push-notifications package

* Import variables to remove dependency of RC namespace

* Import variables to remove RC namespace dependency inside rc-lib/server/lib

* Import variables to remove RC namespace inside rc-lib/server/methods

* Import variables to remove dependency with RC namespace

* Remove duplicated server settings located in rc-lib

* Export function and lib function of rc-lib but keep it inside RC namespace

* Import variables from functions and lib to remove RC namespace dependency

* Remove dependency of RC namespace in rc-sandstorm

* Remove dependency of RC namespace in chatpal-search

* Move CreadentialTokens model to rc-models

* Move getUsernameSuggestion function and method from server/ to rc-lib

* Remove dependency of RC namespace in meteor saml

* Remove dependency of RC namespace in rc-theme

* Move 2FA Users model to rc-models

* Remove dependency of RC namespace in rc-2fa

* Remove dependency of RC namespace in rc-action-links

* Add action links in the RC namespace

* Remove dependency of RC namespace in rc-analytics

* Remove dependency of RC namespace in rc-assets

* Add Assets in RC namespace

* Remove dependency of RC namespace in rc-autolinker

* Move autotranslate models to rc-models

* Partial remove dependency of Rc namespace in rc-autotranslate

* Remove dependency of RC namespace in rc-markdown

* Finish of remotion of RC namespace in rc-autotranslate

* Import Autotranslate where it has been used

* Fix lint

* Rename Assets variable to avoid conflicts

* Fix rename Assets

* Remove dependency of RC namespace in rc-blockstack

* Remove RC dependency in bot-helpers

* Remove RC dependency in rc-cas

* Move some functions from tokenpass to channel settings and models

* Move some function from livestream to channel settings

* Remove dependency of RC namespace in rc-channel-settings

* Fix wrong imports

* Remove dependency of RC namespace in rc-channel-mail-messages

* Remove dependency of RC namespace in rc-cloud

* Remove dependency of RC namespace in rc-colors

* Remove dependency of RC namespace in rc-cors

* Remove dependency of RC namespace in rc-crowd

* Remove dependency of RC namespace in rc-dolphin

* Remove dependency of RC namespace in rc-drupal

* Move Emoji custom server and client models to rc-models

* Remove dependency of RC namespace in rc-emoji-custom

* Remove dependency of RC namespace in rc-emojione

* Remove dependency of RC namespace in rc-error-handler

* Remove dependency of RC namespace in rc-gh-enterprise

* Remove dependency of RC namespace in rc-gitlab

* Remove dependency of RC namespace in rc-google-natural-language

* Remove dependency of RC namespace in rc-grant

* Remove dependency of RC namespace in rc-highlight-words

* Remove dependency of RC namespace in rc-google-vision

* Fix lint

* Remove dependency of RC namespace in rc-iframe-login

* Remove dependency of RC namespace in all importes, except hipchat-enterprise

* Move RestAPI client to rc-api package

* Remove dependency of RC namespace in rc-api/helpers and api.js

* Remove dependency of RC namespace on half of api files

* Partial Remove dependency of RC namespace in rc-api

* import API where it was being used by the RC namespace

* Move processWebhookMessage function to rc-lib package

* Remove API from RC namespace and import missing function that was being used with namespace

* Remove dependency of RC namespace in rc-graphql

* Fix import from wrong package

* Remove dependency of RC namespace in rc-importer

* Remove dependency of RC namespace in rc-issue-links

* Remove dependency of RC namespace in rc-katex

* Move templateVarHandler fn to rc-utils

* Remove dependency of RC namespace in rc-ldap

* Remove dependency of RC namespace in rc-livestream

* Remove dependency of RC namespace in rc-mail-messages

* Remove dependency of RC namespace in rc-mapview

* Remove dependency of RC namespace in rc-mentions

* Remove dependency of RC namespace in rc-mentions-flextab

* Remove depedency of RC namespace in rc-message-attachements

* Remove dependdency of RC namespace in rc-message-mark-as-unread

* Remove dependency of RC namespace in rc-message-pin

* Fix templateVarHandler that was in wrong folder

* Remove namespace in the new livechat endpoint

* Remove dependency of RC namespace in rc-message-snippet

* Remove dependency of RC namespace in rc-message-star

* Remove dependency of RC namespace in rc-oauth2

* Remove dependency of RC namespace in rc-oembed

* Remove dependency of RC namespace in rc-otr

* Remove dependency of RC namespace in rc-reactions

* Remove dependency of RC namespace in rc-retention-policy

* Remove dependency of RC namespace in rc-earch

* Remove dependency of RC namespace in rc-setup-wizard

* Remove dependency of RC namespace in rc-slackbridge

* Remove dependency of Rc namespace in slashcommands-asciiarts

* Remove depedency of RC namespace in rc-slash-archiveroom

* Remove dependency of RC namespace in rc-slash-create

* Remove dependency of RC namespace in rc-slash-help

* Remove dependency of RC namespace in rc-slash-hide

* Remove dependency of RC namespace in rc-slash-invite

* Remove dependency of RC namespace in rc-slash-inviteall

* Remove dependency of RC namespace in rc-slash-join

* Remove dependency of RC namespace in rc-slash-kick

* Remove dependency of RC namespace in rc-slash-leave

* Remove dependency of RC namespace in rc-slash-me

* Remove dependency of RC namespace in rc-slash-msg

* Remove dependency of RC namespace in rc-slash-mute

* Remove dependency of RC namespace in rc-slash-open

* Remove dependency of RC namespace in rc-slash-topic

* Remove dependency of RC namespace in rc-slash-unarchiveroom

* Remove dependency of RC namespace in rc-smarsh-connector

* Remove dependency of RC namespace in rc-sms

* Remove dependency of RC namespace in rc-spotify

* Remove dependency of RC namespace in rc-statistics

* Move tokenpass models methods to rc-models

* Remove dependency of RC namespace in rc-tokenpass

* import tokenpass inside rc-lib

* Remove dependency of RC namespace in rc-ui

* Move webdavAccounts models to rc-model

* Remove dependency of RC namespace in rc-ui-account

* Remove dependency of RC namespace in rc-ui-admin

* Remove dependency of RC namespace in rc-ui-clean-history

* Remove dependency of RC namespace in rc-ui-flextab

* Remove dependency of RC namespace in rc-ui-login

* Remove dependency of RC namespace in rc-ui-master

* Remove dependency of RC namespace in rc-ui-message

* REmove dependency of RC namespace in rc-user-data-download

* Remove dependency of RC namespace in rc-version-check

* Remove dependency of RC namespace in rc-videobridge

* Remove dependency of RC namespace in rc-webdav

* Remove dependency of RC namespace in rc-wordpress

* Remove some RC namespace use in chatpal-search

* Remove dependency of RC namespace in rc-irc

* Remove dependency of RC namespace in livechat/client

* Move methods in common livechat models to rc-models

* Remove dependency of RC namespace in rc-livechat/server/models

* Remove LIvechat global variable from RC namespace

* Remove dependency of RC namespace in rc-livechat/imports, lib, server/api, server/hooks and server/lib

* Remove dependency of RC namespace in rc-livechat/server/methods

* Fix duplicated import

* Remove unused import

* Remove dependency of RC namespace in rc-livechat/server/publications

* MOve rc-livechat server models to rc-models

* Change imports of livechat server models to rc-models package

*  Remove dependency of RC namespace in rc-api/helpers and api.js (#13273)

* Move RestAPI client to rc-api package

* Remove dependency of RC namespace in rc-api/helpers and api.js

*  Remove dependency of RC namespace on half of api files (#13275)

* Move RestAPI client to rc-api package

* Remove dependency of RC namespace in rc-api/helpers and api.js

* Remove dependency of RC namespace on half of api files

* Remove dependency of RC namespace in rc-integrations

* Import missed functions in rc-irc

* Remove dependency of RC namespace in rc-hipchat-enterprise-importer

* Partial Remove dependency of RC namespace in rc-api (#13277)

* Move RestAPI client to rc-api package

* Remove dependency of RC namespace in rc-api/helpers and api.js

* Remove dependency of RC namespace on half of api files

* Partial Remove dependency of RC namespace in rc-api

* Remove dependency of RC namespace in root client folder

* Remove dependency of RC namespace in imports/message-read-receipt

* Remove dependency of RC namespace in imports/personal-access-tokens

* Remove dependency of RC namespace in rc-api (#13278)

* Move RestAPI client to rc-api package

* Remove dependency of RC namespace in rc-api/helpers and api.js

* Remove dependency of RC namespace on half of api files

* Partial Remove dependency of RC namespace in rc-api

* import API where it was being used by the RC namespace

* Move processWebhookMessage function to rc-lib package

* Remove API from RC namespace and import missing function that was being used with namespace

* Remove namespace in the new livechat endpoint

*  Remove dependency of RC namespace in rc-graphql (#13279)

* Move RestAPI client to rc-api package

* Remove dependency of RC namespace in rc-api/helpers and api.js

* Remove dependency of RC namespace on half of api files

* Partial Remove dependency of RC namespace in rc-api

* import API where it was being used by the RC namespace

* Move processWebhookMessage function to rc-lib package

* Remove API from RC namespace and import missing function that was being used with namespace

* Remove dependency of RC namespace in rc-graphql

* Fix import from wrong package

* Remove namespace in the new livechat endpoint

* Remove dependency of RC namespace in root server folder - step 1

* Remove dependency of RC namespace in rc-importer (#13280)

* Move RestAPI client to rc-api package

* Remove dependency of RC namespace in rc-api/helpers and api.js

* Remove dependency of RC namespace on half of api files

* Partial Remove dependency of RC namespace in rc-api

* import API where it was being used by the RC namespace

* Move processWebhookMessage function to rc-lib package

* Remove API from RC namespace and import missing function that was being used with namespace

* Remove dependency of RC namespace in rc-graphql

* Fix import from wrong package

* Remove dependency of RC namespace in rc-importer

* Remove namespace in the new livechat endpoint

*  Remove dependency of RC namespace in rc-ldap, katex and issue-links (#13281)

* Move RestAPI client to rc-api package

* Remove dependency of RC namespace in rc-api/helpers and api.js

* Remove dependency of RC namespace on half of api files

* Partial Remove dependency of RC namespace in rc-api

* import API where it was being used by the RC namespace

* Move processWebhookMessage function to rc-lib package

* Remove API from RC namespace and import missing function that was being used with namespace

* Remove dependency of RC namespace in rc-graphql

* Fix import from wrong package

* Remove dependency of RC namespace in rc-importer

* Remove dependency of RC namespace in rc-issue-links

* Remove dependency of RC namespace in rc-katex

* Move templateVarHandler fn to rc-utils

* Remove dependency of RC namespace in rc-ldap

* Fix templateVarHandler that was in wrong folder

* Remove namespace in the new livechat endpoint

*  Remove dependency of RC namespace in rc-livestream and rc-mail-messages (#13320)

* Move RestAPI client to rc-api package

* Remove dependency of RC namespace in rc-api/helpers and api.js

* Remove dependency of RC namespace on half of api files

* Partial Remove dependency of RC namespace in rc-api

* import API where it was being used by the RC namespace

* Move processWebhookMessage function to rc-lib package

* Remove API from RC namespace and import missing function that was being used with namespace

* Remove dependency of RC namespace in rc-graphql

* Fix import from wrong package

* Remove dependency of RC namespace in rc-importer

* Remove dependency of RC namespace in rc-issue-links

* Remove dependency of RC namespace in rc-katex

* Move templateVarHandler fn to rc-utils

* Remove dependency of RC namespace in rc-ldap

* Remove dependency of RC namespace in rc-livestream

* Remove dependency of RC namespace in rc-mail-messages

* Fix templateVarHandler that was in wrong folder

* Remove namespace in the new livechat endpoint

* Remove dependency of RC namespace in root server folder - step 2

* Remove dependency of RC namespace in root server folder - step 3

* Remove dependency of RC namespace in root server folder - step 4

* Remove dependency of RC namespace in root server folder - step 5

* Remove dependency of RC namespace in root server folder - step 6

* Move RestAPIClient to package rc-utils to remove cyclic dependency between lib, apps and api

* Move apps model to rc-models

* Convert rocketchat-apps to main module structure

* Import Apps where it is being used

* Remove global variable Apps from eslintrc
pull/13414/head^2
Marcos Spessatto Defendi 6 years ago committed by Rodrigo Nascimento
parent a587a0bdc3
commit b9d76fea00
  1. 1
      .eslintrc
  2. 1
      packages/rocketchat-api/client/index.js
  3. 2
      packages/rocketchat-api/package.js
  4. 10
      packages/rocketchat-apps/client/admin/appInstall.js
  5. 6
      packages/rocketchat-apps/client/admin/appLogs.js
  6. 39
      packages/rocketchat-apps/client/admin/appManage.js
  7. 3
      packages/rocketchat-apps/client/admin/appWhatIsIt.js
  8. 18
      packages/rocketchat-apps/client/admin/apps.js
  9. 17
      packages/rocketchat-apps/client/communication/websockets.js
  10. 11
      packages/rocketchat-apps/client/index.js
  11. 25
      packages/rocketchat-apps/client/orchestrator.js
  12. 2
      packages/rocketchat-apps/lib/Apps.js
  13. 90
      packages/rocketchat-apps/package.js
  14. 21
      packages/rocketchat-apps/server/bridges/commands.js
  15. 4
      packages/rocketchat-apps/server/bridges/internal.js
  16. 20
      packages/rocketchat-apps/server/bridges/messages.js
  17. 22
      packages/rocketchat-apps/server/bridges/rooms.js
  18. 4
      packages/rocketchat-apps/server/bridges/settings.js
  19. 10
      packages/rocketchat-apps/server/communication/methods.js
  20. 104
      packages/rocketchat-apps/server/communication/rest.js
  21. 9
      packages/rocketchat-apps/server/converters/messages.js
  22. 7
      packages/rocketchat-apps/server/converters/rooms.js
  23. 3
      packages/rocketchat-apps/server/converters/settings.js
  24. 5
      packages/rocketchat-apps/server/converters/users.js
  25. 1
      packages/rocketchat-apps/server/index.js
  26. 29
      packages/rocketchat-apps/server/orchestrator.js
  27. 5
      packages/rocketchat-apps/server/storage/apps-logs-model.js
  28. 5
      packages/rocketchat-apps/server/storage/apps-model.js
  29. 5
      packages/rocketchat-apps/server/storage/apps-persistence-model.js
  30. 5
      packages/rocketchat-apps/server/storage/index.js
  31. 5
      packages/rocketchat-importer/client/admin/adminImportHistory.js
  32. 9
      packages/rocketchat-importer/client/admin/adminImportPrepare.js
  33. 10
      packages/rocketchat-lib/client/lib/startup/commands.js
  34. 1
      packages/rocketchat-lib/package.js
  35. 1
      packages/rocketchat-lib/server/functions/createRoom.js
  36. 1
      packages/rocketchat-lib/server/functions/deleteMessage.js
  37. 1
      packages/rocketchat-lib/server/functions/sendMessage.js
  38. 1
      packages/rocketchat-lib/server/functions/updateMessage.js
  39. 4
      packages/rocketchat-models/server/index.js
  40. 7
      packages/rocketchat-models/server/models/apps-logs-model.js
  41. 7
      packages/rocketchat-models/server/models/apps-model.js
  42. 7
      packages/rocketchat-models/server/models/apps-persistence-model.js
  43. 1
      packages/rocketchat-utils/client/index.js
  44. 22
      packages/rocketchat-utils/client/lib/RestApiClient.js
  45. 1
      server/methods/eraseRoom.js

@ -4,7 +4,6 @@
"globals": {
"__meteor_bootstrap__" : false,
"__meteor_runtime_config__" : false,
"Apps" : false,
"Assets" : false,
"chrome" : false,
"DynamicCss" : false,

@ -1 +0,0 @@
export { API } from './lib/RestApiClient';

@ -20,7 +20,5 @@ Package.onUse(function(api) {
'rocketchat:file-upload',
'rocketchat:authorization',
]);
api.mainModule('client/index.js', 'client');
api.mainModule('server/index.js', 'server');
});

@ -10,7 +10,7 @@
import { ReactiveVar } from 'meteor/reactive-var';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';
import { API } from 'meteor/rocketchat:api';
import { APIClient } from 'meteor/rocketchat:utils';
Template.appInstall.helpers({
appFile() {
@ -73,9 +73,9 @@ Template.appInstall.events({
let result;
if (isUpdating) {
result = await API.post(`apps/${ t.isUpdatingId.get() }`, { url });
result = await APIClient.post(`apps/${ t.isUpdatingId.get() }`, { url });
} else {
result = await API.post('apps', { url });
result = await APIClient.post('apps', { url });
}
if (result.compilerErrors.length !== 0 || result.app.status === 'compiler_error') {
@ -116,9 +116,9 @@ Template.appInstall.events({
let result;
if (isUpdating) {
result = await API.upload(`apps/${ t.isUpdatingId.get() }`, data);
result = await APIClient.upload(`apps/${ t.isUpdatingId.get() }`, data);
} else {
result = await API.upload('apps', data);
result = await APIClient.upload('apps', data);
}
console.log('install result', result);

@ -2,7 +2,7 @@ import { ReactiveVar } from 'meteor/reactive-var';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';
import { TAPi18n } from 'meteor/tap:i18n';
import { API } from 'meteor/rocketchat:api';
import { APIClient } from 'meteor/rocketchat:utils';
import moment from 'moment';
import hljs from 'highlight.js';
@ -18,8 +18,8 @@ Template.appLogs.onCreated(function() {
const id = this.id.get();
Promise.all([
API.get(`apps/${ id }`),
API.get(`apps/${ id }/logs`),
APIClient.get(`apps/${ id }`),
APIClient.get(`apps/${ id }/logs`),
]).then((results) => {
instance.app.set(results[0].app);

@ -4,15 +4,16 @@ import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';
import { TAPi18n } from 'meteor/tap:i18n';
import { TAPi18next } from 'meteor/tap:i18n';
import { isEmail } from 'meteor/rocketchat:utils';
import { API } from 'meteor/rocketchat:api';
import { isEmail, Info, APIClient } from 'meteor/rocketchat:utils';
import { settings } from 'meteor/rocketchat:settings';
import { Markdown } from 'meteor/rocketchat:markdown';
import _ from 'underscore';
import s from 'underscore.string';
import toastr from 'toastr';
import { AppEvents } from '../communication';
import { Utilities } from '../../lib/misc/Utilities';
import { Apps } from '../orchestrator';
import semver from 'semver';
const HOST = 'https://marketplace.rocket.chat'; // TODO move this to inside RocketChat.API
@ -21,8 +22,8 @@ function getApps(instance) {
const id = instance.id.get();
return Promise.all([
fetch(`${ HOST }/v1/apps/${ id }?version=${ RocketChat.Info.marketplaceApiVersion }`).then((data) => data.json()),
API.get('apps/').then((result) => result.apps.filter((app) => app.id === id)),
fetch(`${ HOST }/v1/apps/${ id }?version=${ Info.marketplaceApiVersion }`).then((data) => data.json()),
APIClient.get('apps/').then((result) => result.apps.filter((app) => app.id === id)),
]).then(([remoteApps, [localApp]]) => {
remoteApps = remoteApps.sort((a, b) => {
if (semver.gt(a.version, b.version)) {
@ -46,10 +47,10 @@ function getApps(instance) {
instance.onSettingUpdated({ appId: id });
window.Apps.getWsListener().unregisterListener(AppEvents.APP_STATUS_CHANGE, instance.onStatusChanged);
window.Apps.getWsListener().unregisterListener(AppEvents.APP_SETTING_UPDATED, instance.onSettingUpdated);
window.Apps.getWsListener().registerListener(AppEvents.APP_STATUS_CHANGE, instance.onStatusChanged);
window.Apps.getWsListener().registerListener(AppEvents.APP_SETTING_UPDATED, instance.onSettingUpdated);
Apps.getWsListener().unregisterListener(AppEvents.APP_STATUS_CHANGE, instance.onStatusChanged);
Apps.getWsListener().unregisterListener(AppEvents.APP_SETTING_UPDATED, instance.onSettingUpdated);
Apps.getWsListener().registerListener(AppEvents.APP_STATUS_CHANGE, instance.onStatusChanged);
Apps.getWsListener().registerListener(AppEvents.APP_SETTING_UPDATED, instance.onSettingUpdated);
}
instance.app.set(localApp || remoteApp);
@ -77,7 +78,7 @@ Template.appManage.onCreated(function() {
const id = this.id.get();
this.getApis = async() => {
this.apis.set(await window.Apps.getAppApis(id));
this.apis.set(await Apps.getAppApis(id));
};
this.getApis();
@ -115,7 +116,7 @@ Template.appManage.onCreated(function() {
return;
}
API.get(`apps/${ id }/settings`).then((result) => {
APIClient.get(`apps/${ id }/settings`).then((result) => {
_morphSettings(result.settings);
});
};
@ -124,8 +125,8 @@ Template.appManage.onCreated(function() {
Template.apps.onDestroyed(function() {
const instance = this;
window.Apps.getWsListener().unregisterListener(AppEvents.APP_STATUS_CHANGE, instance.onStatusChanged);
window.Apps.getWsListener().unregisterListener(AppEvents.APP_SETTING_UPDATED, instance.onSettingUpdated);
Apps.getWsListener().unregisterListener(AppEvents.APP_STATUS_CHANGE, instance.onStatusChanged);
Apps.getWsListener().unregisterListener(AppEvents.APP_SETTING_UPDATED, instance.onSettingUpdated);
});
Template.appManage.helpers({
@ -155,7 +156,7 @@ Template.appManage.helpers({
return result;
},
appLanguage(key) {
const setting = RocketChat.settings.get('Language');
const setting = settings.get('Language');
return setting && setting.split('-').shift().toLowerCase() === key;
},
selectedOption(_id, val) {
@ -230,7 +231,7 @@ Template.appManage.helpers({
return Template.instance().apis.get();
},
parseDescription(i18nDescription) {
const item = RocketChat.Markdown.parseMessageNotEscaped({ html: Template.instance().__(i18nDescription) });
const item = Markdown.parseMessageNotEscaped({ html: Template.instance().__(i18nDescription) });
item.tokens.forEach((t) => item.html = item.html.replace(t.token, t.text));
@ -264,7 +265,7 @@ async function setActivate(actiavate, e, t) {
const status = actiavate ? 'manually_enabled' : 'manually_disabled';
try {
const result = await API.post(`apps/${ t.id.get() }/status`, { status });
const result = await APIClient.post(`apps/${ t.id.get() }/status`, { status });
const info = t.app.get();
info.status = result.status;
t.app.set(info);
@ -302,7 +303,7 @@ Template.appManage.events({
'click .js-uninstall': async(e, t) => {
t.ready.set(false);
try {
await API.delete(`apps/${ t.id.get() }`);
await APIClient.delete(`apps/${ t.id.get() }`);
FlowRouter.go('/admin/apps');
} catch (err) {
console.warn('Error:', err);
@ -322,7 +323,7 @@ Template.appManage.events({
const api = app.newVersion ? `apps/${ t.id.get() }` : 'apps/';
API.post(api, { url }).then(() => {
APIClient.post(api, { url }).then(() => {
getApps(t).then(() => {
el.prop('disabled', false);
el.removeClass('loading');
@ -372,7 +373,7 @@ Template.appManage.events({
if (toSave.length === 0) {
throw 'Nothing to save..';
}
const result = await API.post(`apps/${ t.id.get() }/settings`, undefined, { settings: toSave });
const result = await APIClient.post(`apps/${ t.id.get() }/settings`, undefined, { settings: toSave });
console.log('Updating results:', result);
result.updated.forEach((setting) => {
settings[setting.id].value = settings[setting.id].oldValue = setting.value;

@ -2,6 +2,7 @@ import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';
import { Apps } from '../orchestrator';
Template.appWhatIsIt.onCreated(function() {
this.isLoading = new ReactiveVar(false);
@ -36,7 +37,7 @@ Template.appWhatIsIt.events({
return;
}
window.Apps.load(true);
Apps.load(true);
FlowRouter.go('/admin/apps');
});

@ -2,9 +2,9 @@ import toastr from 'toastr';
import { ReactiveVar } from 'meteor/reactive-var';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';
import { t } from 'meteor/rocketchat:utils';
import { t, Info, APIClient } from 'meteor/rocketchat:utils';
import { AppEvents } from '../communication';
import { API } from 'meteor/rocketchat:api';
import { Apps } from '../orchestrator';
const ENABLED_STATUS = ['auto_enabled', 'manually_enabled'];
const HOST = 'https://marketplace.rocket.chat';
@ -36,7 +36,7 @@ const tagAlreadyInstalledApps = (installedApps, apps) => {
const getApps = (instance) => {
instance.isLoading.set(true);
fetch(`${ HOST }/v1/apps?version=${ RocketChat.Info.marketplaceApiVersion }`)
fetch(`${ HOST }/v1/apps?version=${ Info.marketplaceApiVersion }`)
.then((response) => response.json())
.then((data) => {
const tagged = tagAlreadyInstalledApps(instance.installedApps.get(), data);
@ -49,7 +49,7 @@ const getApps = (instance) => {
const getInstalledApps = (instance) => {
API.get('apps').then((data) => {
APIClient.get('apps').then((data) => {
const apps = data.apps.map((app) => ({ latest: app }));
instance.installedApps.set(apps);
@ -109,15 +109,15 @@ Template.apps.onCreated(function() {
instance.apps.set(apps);
};
window.Apps.getWsListener().registerListener(AppEvents.APP_ADDED, instance.onAppAdded);
window.Apps.getWsListener().registerListener(AppEvents.APP_REMOVED, instance.onAppAdded);
Apps.getWsListener().registerListener(AppEvents.APP_ADDED, instance.onAppAdded);
Apps.getWsListener().registerListener(AppEvents.APP_REMOVED, instance.onAppAdded);
});
Template.apps.onDestroyed(function() {
const instance = this;
window.Apps.getWsListener().unregisterListener(AppEvents.APP_ADDED, instance.onAppAdded);
window.Apps.getWsListener().unregisterListener(AppEvents.APP_REMOVED, instance.onAppAdded);
Apps.getWsListener().unregisterListener(AppEvents.APP_ADDED, instance.onAppAdded);
Apps.getWsListener().unregisterListener(AppEvents.APP_REMOVED, instance.onAppAdded);
});
Template.apps.helpers({
@ -257,7 +257,7 @@ Template.apps.events({
// play animation
e.currentTarget.parentElement.classList.add('loading');
API.post('apps/', { url })
APIClient.post('apps/', { url })
.then(() => {
getApps(template);
getInstalledApps(template);

@ -1,5 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { API } from 'meteor/rocketchat:api';
import { slashCommands, APIClient } from 'meteor/rocketchat:utils';
import { CachedCollectionManager } from 'meteor/rocketchat:ui-cached-collection';
export const AppEvents = Object.freeze({
APP_ADDED: 'app/added',
@ -18,7 +19,7 @@ export class AppWebsocketReceiver {
this.orch = orch;
this.streamer = new Meteor.Streamer('apps');
RocketChat.CachedCollectionManager.onLogin(() => {
CachedCollectionManager.onLogin(() => {
this.listenStreamerEvents();
});
@ -50,7 +51,7 @@ export class AppWebsocketReceiver {
}
onAppAdded(appId) {
API.get(`apps/${ appId }/languages`).then((result) => {
APIClient.get(`apps/${ appId }/languages`).then((result) => {
this.orch.parseAndLoadLanguages(result.languages, appId);
});
@ -74,18 +75,18 @@ export class AppWebsocketReceiver {
}
onCommandAdded(command) {
API.v1.get('commands.get', { command }).then((result) => {
RocketChat.slashCommands.commands[command] = result.command;
APIClient.v1.get('commands.get', { command }).then((result) => {
slashCommands.commands[command] = result.command;
});
}
onCommandDisabled(command) {
delete RocketChat.slashCommands.commands[command];
delete slashCommands.commands[command];
}
onCommandUpdated(command) {
API.v1.get('commands.get', { command }).then((result) => {
RocketChat.slashCommands.commands[command] = result.command;
APIClient.v1.get('commands.get', { command }).then((result) => {
slashCommands.commands[command] = result.command;
});
}
}

@ -0,0 +1,11 @@
export { Apps } from './orchestrator';
import './admin/apps.html';
import './admin/apps';
import './admin/appInstall.html';
import './admin/appInstall';
import './admin/appLogs.html';
import './admin/appLogs';
import './admin/appManage.html';
import './admin/appManage';
import './admin/appWhatIsIt.html';
import './admin/appWhatIsIt';

@ -4,7 +4,12 @@ import { Utilities } from '../lib/misc/Utilities';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { BlazeLayout } from 'meteor/kadira:blaze-layout';
import { TAPi18next } from 'meteor/tap:i18n';
import { API } from 'meteor/rocketchat:api';
import { APIClient } from 'meteor/rocketchat:utils';
import { AdminBox } from 'meteor/rocketchat:ui-utils';
import { CachedCollectionManager } from 'meteor/rocketchat:ui-cached-collection';
import { hasAtLeastOnePermission } from 'meteor/rocketchat:authorization';
export let Apps;
class AppClientOrchestrator {
constructor() {
@ -61,18 +66,18 @@ class AppClientOrchestrator {
}
_addAdminMenuOption() {
RocketChat.AdminBox.addOption({
AdminBox.addOption({
icon: 'cube',
href: 'apps',
i18nLabel: 'Apps',
permissionGranted() {
return RocketChat.authz.hasAtLeastOnePermission(['manage-apps']);
return hasAtLeastOnePermission(['manage-apps']);
},
});
}
_loadLanguages() {
return API.get('apps/languages').then((info) => {
return APIClient.get('apps/languages').then((info) => {
info.apps.forEach((rlInfo) => this.parseAndLoadLanguages(rlInfo.languages, rlInfo.id));
});
}
@ -93,23 +98,23 @@ class AppClientOrchestrator {
}
async getAppApis(appId) {
const result = await API.get(`apps/${ appId }/apis`);
const result = await APIClient.get(`apps/${ appId }/apis`);
return result.apis;
}
}
Meteor.startup(function _rlClientOrch() {
window.Apps = new AppClientOrchestrator();
Apps = new AppClientOrchestrator();
RocketChat.CachedCollectionManager.onLogin(() => {
CachedCollectionManager.onLogin(() => {
Meteor.call('apps/is-enabled', (error, isEnabled) => {
window.Apps.load(isEnabled);
Apps.load(isEnabled);
});
});
});
const appsRouteAction = function _theRealAction(whichCenter) {
Meteor.defer(() => window.Apps.getLoadingPromise().then((isEnabled) => {
Meteor.defer(() => Apps.getLoadingPromise().then((isEnabled) => {
if (isEnabled) {
BlazeLayout.render('main', { center: whichCenter, old: true }); // TODO remove old
} else {
@ -150,7 +155,7 @@ FlowRouter.route('/admin/apps/:appId/logs', {
FlowRouter.route('/admin/app/what-is-it', {
name: 'app-what-is-it',
action() {
Meteor.defer(() => window.Apps.getLoadingPromise().then((isEnabled) => {
Meteor.defer(() => Apps.getLoadingPromise().then((isEnabled) => {
if (isEnabled) {
FlowRouter.go('apps');
} else {

@ -1,2 +0,0 @@
// Please see both server and client's repsective "orchestrator" file for the contents
Apps = {};

@ -6,84 +6,22 @@ Package.describe({
Package.onUse(function(api) {
api.use([
'ecmascript',
'rocketchat:lib',
'rocketchat:api',
'rocketchat:markdown',
'rocketchat:utils',
'rocketchat:settings',
'rocketchat:models',
'rocketchat:notifications',
'rocketchat:ui-utils',
'rocketchat:authorization',
'rocketchat:ui-cached-collection',
'templating',
]);
api.use(['reactive-var', 'kadira:flow-router', 'kadira:blaze-layout', 'underscore'], 'client');
api.addFiles('lib/Apps.js', ['client', 'server']);
// Storage
api.addFiles([
'server/storage/apps-logs-model.js',
'server/storage/apps-model.js',
'server/storage/apps-persistence-model.js',
'server/storage/storage.js',
'server/storage/index.js',
], 'server');
// Bridges
api.addFiles([
'server/bridges/activation.js',
'server/bridges/bridges.js',
'server/bridges/commands.js',
'server/bridges/environmental.js',
'server/bridges/messages.js',
'server/bridges/persistence.js',
'server/bridges/rooms.js',
'server/bridges/settings.js',
'server/bridges/users.js',
'server/bridges/index.js',
], 'server');
// Communication pieces
api.addFiles([
'server/communication/methods.js',
'server/communication/rest.js',
'server/communication/websockets.js',
'server/communication/index.js',
], 'server');
// RocketChat <-> App Data Converters
api.addFiles([
'server/converters/messages.js',
'server/converters/rooms.js',
'server/converters/settings.js',
'server/converters/users.js',
'server/converters/index.js',
], 'server');
// Server Orchestrator
api.addFiles('server/orchestrator.js', 'server');
// Client communication pieces
api.addFiles([
'client/communication/websockets.js',
'client/communication/index.js',
], 'client');
// Client Admin Management
api.addFiles([
'client/admin/apps.html',
'client/admin/apps.js',
'client/admin/appManage.html',
'client/admin/appManage.js',
'client/admin/appInstall.html',
'client/admin/appInstall.js',
'client/admin/appLogs.html',
'client/admin/appLogs.js',
'client/admin/appWhatIsIt.html',
'client/admin/appWhatIsIt.js',
api.use([
'reactive-var',
'kadira:flow-router',
'kadira:blaze-layout',
'underscore',
], 'client');
api.addFiles('assets/stylesheets/apps.css', 'client');
// Client orchestrator
api.addFiles('client/orchestrator.js', 'client');
// Add what this package actually does export (needs updated to the module import style)
api.export('Apps');
api.mainModule('client/index.js', 'client');
api.mainModule('server/index.js', 'server');
});

@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { slashCommands } from 'meteor/rocketchat:utils';
import { SlashCommandContext } from '@rocket.chat/apps-engine/definition/slashcommands';
import { Utilities } from '../../lib/misc/Utilities';
@ -16,7 +17,7 @@ export class AppCommandsBridge {
}
const cmd = command.toLowerCase();
return typeof RocketChat.slashCommands.commands[cmd] === 'object' || this.disabledCommands.has(cmd);
return typeof slashCommands.commands[cmd] === 'object' || this.disabledCommands.has(cmd);
}
enableCommand(command, appId) {
@ -31,7 +32,7 @@ export class AppCommandsBridge {
throw new Error(`The command is not currently disabled: "${ cmd }"`);
}
RocketChat.slashCommands.commands[cmd] = this.disabledCommands.get(cmd);
slashCommands.commands[cmd] = this.disabledCommands.get(cmd);
this.disabledCommands.delete(cmd);
this.orch.getNotifier().commandUpdated(cmd);
@ -50,12 +51,12 @@ export class AppCommandsBridge {
return;
}
if (typeof RocketChat.slashCommands.commands[cmd] === 'undefined') {
if (typeof slashCommands.commands[cmd] === 'undefined') {
throw new Error(`Command does not exist in the system currently: "${ cmd }"`);
}
this.disabledCommands.set(cmd, RocketChat.slashCommands.commands[cmd]);
delete RocketChat.slashCommands.commands[cmd];
this.disabledCommands.set(cmd, slashCommands.commands[cmd]);
delete slashCommands.commands[cmd];
this.orch.getNotifier().commandDisabled(cmd);
}
@ -67,11 +68,11 @@ export class AppCommandsBridge {
this._verifyCommand(command);
const cmd = command.toLowerCase();
if (typeof RocketChat.slashCommands.commands[cmd] === 'undefined') {
if (typeof slashCommands.commands[cmd] === 'undefined') {
throw new Error(`Command does not exist in the system currently (or it is disabled): "${ cmd }"`);
}
const item = RocketChat.slashCommands.commands[cmd];
const item = slashCommands.commands[cmd];
item.params = command.paramsExample ? command.paramsExample : item.params;
item.description = command.i18nDescription ? command.i18nDescription : item.params;
item.callback = this._appCommandExecutor.bind(this);
@ -79,7 +80,7 @@ export class AppCommandsBridge {
item.previewer = command.previewer ? this._appCommandPreviewer.bind(this) : item.previewer;
item.previewCallback = command.executePreviewItem ? this._appCommandPreviewExecutor.bind(this) : item.previewCallback;
RocketChat.slashCommands.commands[cmd] = item;
slashCommands.commands[cmd] = item;
this.orch.getNotifier().commandUpdated(cmd);
}
@ -98,7 +99,7 @@ export class AppCommandsBridge {
previewCallback: !command.executePreviewItem ? undefined : this._appCommandPreviewExecutor.bind(this),
};
RocketChat.slashCommands.commands[command.command.toLowerCase()] = item;
slashCommands.commands[command.command.toLowerCase()] = item;
this.orch.getNotifier().commandAdded(command.command.toLowerCase());
}
@ -111,7 +112,7 @@ export class AppCommandsBridge {
const cmd = command.toLowerCase();
this.disabledCommands.delete(cmd);
delete RocketChat.slashCommands.commands[cmd];
delete slashCommands.commands[cmd];
this.orch.getNotifier().commandRemoved(cmd);
}

@ -1,10 +1,12 @@
import { Subscriptions } from 'meteor/rocketchat:models';
export class AppInternalBridge {
constructor(orch) {
this.orch = orch;
}
getUsernamesOfRoomById(roomId) {
const records = RocketChat.models.Subscriptions.findByRoomIdWhenUsernameExists(roomId, {
const records = Subscriptions.findByRoomIdWhenUsernameExists(roomId, {
fields: {
'u.username': 1,
},

@ -1,5 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { Random } from 'meteor/random';
import { Messages, Users, Subscriptions } from 'meteor/rocketchat:models';
import { Notifications } from 'meteor/rocketchat:notifications';
export class AppMessageBridge {
constructor(orch) {
@ -26,19 +28,23 @@ export class AppMessageBridge {
async update(message, appId) {
console.log(`The App ${ appId } is updating a message.`);
if (!this.updateMessage) {
const { updateMessage } = await import('meteor/rocketchat:lib');
this.updateMessage = updateMessage;
}
if (!message.editor) {
throw new Error('Invalid editor assigned to the message for the update.');
}
if (!message.id || !RocketChat.models.Messages.findOneById(message.id)) {
if (!message.id || !Messages.findOneById(message.id)) {
throw new Error('A message must exist to update.');
}
const msg = this.orch.getConverters().get('messages').convertAppMessage(message);
const editor = RocketChat.models.Users.findOneById(message.editor.id);
const editor = Users.findOneById(message.editor.id);
RocketChat.updateMessage(msg, editor);
this.updateMessage(msg, editor);
}
async notifyUser(user, message, appId) {
@ -46,7 +52,7 @@ export class AppMessageBridge {
const msg = this.orch.getConverters().get('messages').convertAppMessage(message);
RocketChat.Notifications.notifyUser(user.id, 'message', Object.assign(msg, {
Notifications.notifyUser(user.id, 'message', Object.assign(msg, {
_id: Random.id(),
ts: new Date(),
u: undefined,
@ -67,13 +73,13 @@ export class AppMessageBridge {
editor: undefined,
});
const users = RocketChat.models.Subscriptions.findByRoomIdWhenUserIdExists(room._id, { fields: { 'u._id': 1 } })
const users = Subscriptions.findByRoomIdWhenUserIdExists(room._id, { fields: { 'u._id': 1 } })
.fetch()
.map((s) => s.u._id);
RocketChat.models.Users.findByIds(users, { fields: { _id: 1 } })
Users.findByIds(users, { fields: { _id: 1 } })
.fetch()
.forEach(({ _id }) =>
RocketChat.Notifications.notifyUser(_id, 'message', rmsg)
Notifications.notifyUser(_id, 'message', rmsg)
);
}
}

@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Rooms, Subscriptions, Users } from 'meteor/rocketchat:models';
import { RoomType } from '@rocket.chat/apps-engine/definition/rooms';
export class AppRoomBridge {
@ -61,7 +62,7 @@ export class AppRoomBridge {
async getCreatorById(roomId, appId) {
console.log(`The App ${ appId } is getting the room's creator by id: "${ roomId }"`);
const room = RocketChat.models.Rooms.findOneById(roomId);
const room = Rooms.findOneById(roomId);
if (!room || !room.u || !room.u._id) {
return undefined;
@ -73,7 +74,7 @@ export class AppRoomBridge {
async getCreatorByName(roomName, appId) {
console.log(`The App ${ appId } is getting the room's creator by name: "${ roomName }"`);
const room = RocketChat.models.Rooms.findOneByName(roomName);
const room = Rooms.findOneByName(roomName);
if (!room || !room.u || !room.u._id) {
return undefined;
@ -84,13 +85,13 @@ export class AppRoomBridge {
async getMembers(roomId, appId) {
console.log(`The App ${ appId } is getting the room's members by room id: "${ roomId }"`);
const subscriptions = await RocketChat.models.Subscriptions.findByRoomId(roomId);
const subscriptions = await Subscriptions.findByRoomId(roomId);
return subscriptions.map((sub) => this.orch.getConverters().get('users').convertById(sub.u && sub.u._id));
}
async getDirectByUsernames(usernames, appId) {
console.log(`The App ${ appId } is getting direct room by usernames: "${ usernames }"`);
const room = await RocketChat.models.Rooms.findDirectRoomContainingAllUsernames(usernames);
const room = await Rooms.findDirectRoomContainingAllUsernames(usernames);
if (!room) {
return undefined;
}
@ -100,22 +101,27 @@ export class AppRoomBridge {
async update(room, members = [], appId) {
console.log(`The App ${ appId } is updating a room.`);
if (!room.id || !RocketChat.models.Rooms.findOneById(room.id)) {
if (!this.addUserToRoom) {
const { addUserToRoom } = await import('meteor/rocketchat:lib');
this.addUserToRoom = addUserToRoom;
}
if (!room.id || !Rooms.findOneById(room.id)) {
throw new Error('A room must exist to update.');
}
const rm = this.orch.getConverters().get('rooms').convertAppRoom(room);
RocketChat.models.Rooms.update(rm._id, rm);
Rooms.update(rm._id, rm);
for (const username of members) {
const member = RocketChat.models.Users.findOneByUsername(username);
const member = Users.findOneByUsername(username);
if (!member) {
continue;
}
RocketChat.addUserToRoom(rm._id, member);
this.addUserToRoom(rm._id, member);
}
}
}

@ -1,3 +1,5 @@
import { Settings } from 'meteor/rocketchat:models';
export class AppSettingBridge {
constructor(orch) {
this.orch = orch;
@ -22,7 +24,7 @@ export class AppSettingBridge {
async getAll(appId) {
console.log(`The App ${ appId } is getting all the settings.`);
return RocketChat.models.Settings.find({ _id: { $nin: this.disallowedSettings } })
return Settings.find({ _id: { $nin: this.disallowedSettings } })
.fetch()
.map((s) => this.orch.getConverters().get('settings').convertToApp(s));
}

@ -1,4 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { settings } from 'meteor/rocketchat:settings';
import { hasPermission } from 'meteor/rocketchat:authorization';
const waitToLoad = function(orch) {
return new Promise((resolve) => {
@ -58,13 +60,13 @@ export class AppMethods {
});
}
if (!RocketChat.authz.hasPermission(Meteor.userId(), 'manage-apps')) {
if (!hasPermission(Meteor.userId(), 'manage-apps')) {
throw new Meteor.Error('error-action-not-allowed', 'Not allowed', {
method: 'apps/go-enable',
});
}
RocketChat.settings.set('Apps_Framework_enabled', true);
settings.set('Apps_Framework_enabled', true);
Promise.await(waitToLoad(instance._orch));
},
@ -76,13 +78,13 @@ export class AppMethods {
});
}
if (!RocketChat.authz.hasPermission(Meteor.userId(), 'manage-apps')) {
if (!hasPermission(Meteor.userId(), 'manage-apps')) {
throw new Meteor.Error('error-action-not-allowed', 'Not allowed', {
method: 'apps/go-enable',
});
}
RocketChat.settings.set('Apps_Framework_enabled', false);
settings.set('Apps_Framework_enabled', false);
Promise.await(waitToUnload(instance._orch));
},

@ -1,21 +1,14 @@
import { Meteor } from 'meteor/meteor';
import { HTTP } from 'meteor/http';
import { API } from 'meteor/rocketchat:api';
import Busboy from 'busboy';
let _API;
export class AppsRestApi {
constructor(orch, manager) {
this._orch = orch;
this._manager = manager;
this.api = new API.ApiClass({
version: 'apps',
useDefaultAuth: true,
prettyJson: false,
enableCors: false,
auth: API.getUserAuth(),
});
this.addManagementRoutes();
this.loadAPI();
}
_handleFile(request, fileField) {
@ -39,6 +32,19 @@ export class AppsRestApi {
})();
}
async loadAPI() {
const { API } = await import('meteor/rocketchat:api');
_API = API;
this.api = new API.ApiClass({
version: 'apps',
useDefaultAuth: true,
prettyJson: false,
enableCors: false,
auth: API.getUserAuth(),
});
this.addManagementRoutes();
}
addManagementRoutes() {
const orchestrator = this._orch;
const manager = this._manager;
@ -54,7 +60,7 @@ export class AppsRestApi {
return info;
});
return API.v1.success({ apps });
return _API.v1.success({ apps });
},
post() {
let buff;
@ -63,7 +69,7 @@ export class AppsRestApi {
const result = HTTP.call('GET', this.bodyParams.url, { npmRequestOptions: { encoding: 'base64' } });
if (result.statusCode !== 200 || !result.headers['content-type'] || result.headers['content-type'] !== 'application/zip') {
return API.v1.failure({ error: 'Invalid url. It doesn\'t exist or is not "application/zip".' });
return _API.v1.failure({ error: 'Invalid url. It doesn\'t exist or is not "application/zip".' });
}
buff = Buffer.from(result.content, 'base64');
@ -72,7 +78,7 @@ export class AppsRestApi {
}
if (!buff) {
return API.v1.failure({ error: 'Failed to get a file to install for the App. ' });
return _API.v1.failure({ error: 'Failed to get a file to install for the App. ' });
}
const aff = Promise.await(manager.add(buff.toString('base64'), false));
@ -85,7 +91,7 @@ export class AppsRestApi {
info.status = 'compiler_error';
}
return API.v1.success({
return _API.v1.success({
app: info,
implemented: aff.getImplementedInferfaces(),
compilerErrors: aff.getCompilerErrors(),
@ -100,7 +106,7 @@ export class AppsRestApi {
languages: prl.getStorageItem().languageContent,
}));
return API.v1.success({ apps });
return _API.v1.success({ apps });
},
});
@ -113,9 +119,9 @@ export class AppsRestApi {
const info = prl.getInfo();
info.status = prl.getStatus();
return API.v1.success({ app: info });
return _API.v1.success({ app: info });
} else {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
return _API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
}
},
post() {
@ -128,7 +134,7 @@ export class AppsRestApi {
const result = HTTP.call('GET', this.bodyParams.url, { npmRequestOptions: { encoding: 'base64' } });
if (result.statusCode !== 200 || !result.headers['content-type'] || result.headers['content-type'] !== 'application/zip') {
return API.v1.failure({ error: 'Invalid url. It doesn\'t exist or is not "application/zip".' });
return _API.v1.failure({ error: 'Invalid url. It doesn\'t exist or is not "application/zip".' });
}
buff = Buffer.from(result.content, 'base64');
@ -137,7 +143,7 @@ export class AppsRestApi {
}
if (!buff) {
return API.v1.failure({ error: 'Failed to get a file to install for the App. ' });
return _API.v1.failure({ error: 'Failed to get a file to install for the App. ' });
}
const aff = Promise.await(manager.update(buff.toString('base64')));
@ -150,7 +156,7 @@ export class AppsRestApi {
info.status = 'compiler_error';
}
return API.v1.success({
return _API.v1.success({
app: info,
implemented: aff.getImplementedInferfaces(),
compilerErrors: aff.getCompilerErrors(),
@ -166,9 +172,9 @@ export class AppsRestApi {
const info = prl.getInfo();
info.status = prl.getStatus();
return API.v1.success({ app: info });
return _API.v1.success({ app: info });
} else {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
return _API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
}
},
});
@ -181,9 +187,9 @@ export class AppsRestApi {
if (prl) {
const info = prl.getInfo();
return API.v1.success({ iconFileContent: info.iconFileContent });
return _API.v1.success({ iconFileContent: info.iconFileContent });
} else {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
return _API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
}
},
});
@ -196,9 +202,9 @@ export class AppsRestApi {
if (prl) {
const languages = prl.getStorageItem().languageContent || {};
return API.v1.success({ languages });
return _API.v1.success({ languages });
} else {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
return _API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
}
},
});
@ -222,9 +228,9 @@ export class AppsRestApi {
const logs = Promise.await(orchestrator.getLogStorage().find(ourQuery, options));
return API.v1.success({ logs });
return _API.v1.success({ logs });
} else {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
return _API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
}
},
});
@ -243,21 +249,21 @@ export class AppsRestApi {
}
});
return API.v1.success({ settings });
return _API.v1.success({ settings });
} else {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
return _API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
}
},
post() {
console.log(`Updating ${ this.urlParams.id }'s settings..`);
if (!this.bodyParams || !this.bodyParams.settings) {
return API.v1.failure('The settings to update must be present.');
return _API.v1.failure('The settings to update must be present.');
}
const prl = manager.getOneById(this.urlParams.id);
if (!prl) {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
return _API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
}
const { settings } = prl.getStorageItem();
@ -271,7 +277,7 @@ export class AppsRestApi {
}
});
return API.v1.success({ updated });
return _API.v1.success({ updated });
},
});
@ -282,14 +288,14 @@ export class AppsRestApi {
try {
const setting = manager.getSettingsManager().getAppSetting(this.urlParams.id, this.urlParams.settingId);
API.v1.success({ setting });
_API.v1.success({ setting });
} catch (e) {
if (e.message.includes('No setting found')) {
return API.v1.notFound(`No Setting found on the App by the id of: "${ this.urlParams.settingId }"`);
return _API.v1.notFound(`No Setting found on the App by the id of: "${ this.urlParams.settingId }"`);
} else if (e.message.includes('No App found')) {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
return _API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
} else {
return API.v1.failure(e.message);
return _API.v1.failure(e.message);
}
}
},
@ -297,20 +303,20 @@ export class AppsRestApi {
console.log(`Updating the App ${ this.urlParams.id }'s setting ${ this.urlParams.settingId }`);
if (!this.bodyParams.setting) {
return API.v1.failure('Setting to update to must be present on the posted body.');
return _API.v1.failure('Setting to update to must be present on the posted body.');
}
try {
Promise.await(manager.getSettingsManager().updateAppSetting(this.urlParams.id, this.bodyParams.setting));
return API.v1.success();
return _API.v1.success();
} catch (e) {
if (e.message.includes('No setting found')) {
return API.v1.notFound(`No Setting found on the App by the id of: "${ this.urlParams.settingId }"`);
return _API.v1.notFound(`No Setting found on the App by the id of: "${ this.urlParams.settingId }"`);
} else if (e.message.includes('No App found')) {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
return _API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
} else {
return API.v1.failure(e.message);
return _API.v1.failure(e.message);
}
}
},
@ -322,11 +328,11 @@ export class AppsRestApi {
const prl = manager.getOneById(this.urlParams.id);
if (prl) {
return API.v1.success({
return _API.v1.success({
apis: manager.apiManager.listApis(this.urlParams.id),
});
} else {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
return _API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
}
},
});
@ -337,14 +343,14 @@ export class AppsRestApi {
const prl = manager.getOneById(this.urlParams.id);
if (prl) {
return API.v1.success({ status: prl.getStatus() });
return _API.v1.success({ status: prl.getStatus() });
} else {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
return _API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
}
},
post() {
if (!this.bodyParams.status || typeof this.bodyParams.status !== 'string') {
return API.v1.failure('Invalid status provided, it must be "status" field and a string.');
return _API.v1.failure('Invalid status provided, it must be "status" field and a string.');
}
console.log(`Updating ${ this.urlParams.id }'s status...`, this.bodyParams.status);
@ -353,9 +359,9 @@ export class AppsRestApi {
if (prl) {
const result = Promise.await(manager.changeStatus(prl.getID(), this.bodyParams.status));
return API.v1.success({ status: result.getStatus() });
return _API.v1.success({ status: result.getStatus() });
} else {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
return _API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
}
},
});

@ -1,4 +1,5 @@
import { Random } from 'meteor/random';
import { Messages, Rooms, Users } from 'meteor/rocketchat:models';
export class AppMessagesConverter {
constructor(orch) {
@ -6,7 +7,7 @@ export class AppMessagesConverter {
}
convertById(msgId) {
const msg = RocketChat.models.Messages.findOneById(msgId);
const msg = Messages.findOneById(msgId);
return this.convertMessage(msg);
}
@ -59,7 +60,7 @@ export class AppMessagesConverter {
return undefined;
}
const room = RocketChat.models.Rooms.findOneById(message.room.id);
const room = Rooms.findOneById(message.room.id);
if (!room) {
throw new Error('Invalid room provided on the message.');
@ -67,7 +68,7 @@ export class AppMessagesConverter {
let u;
if (message.sender && message.sender.id) {
const user = RocketChat.models.Users.findOneById(message.sender.id);
const user = Users.findOneById(message.sender.id);
if (user) {
u = {
@ -86,7 +87,7 @@ export class AppMessagesConverter {
let editedBy;
if (message.editor) {
const editor = RocketChat.models.Users.findOneById(message.editor.id);
const editor = Users.findOneById(message.editor.id);
editedBy = {
_id: editor._id,
username: editor.username,

@ -1,3 +1,4 @@
import { Rooms, Users } from 'meteor/rocketchat:models';
import { RoomType } from '@rocket.chat/apps-engine/definition/rooms';
export class AppRoomsConverter {
@ -6,13 +7,13 @@ export class AppRoomsConverter {
}
convertById(roomId) {
const room = RocketChat.models.Rooms.findOneById(roomId);
const room = Rooms.findOneById(roomId);
return this.convertRoom(room);
}
convertByName(roomName) {
const room = RocketChat.models.Rooms.findOneByName(roomName);
const room = Rooms.findOneByName(roomName);
return this.convertRoom(room);
}
@ -24,7 +25,7 @@ export class AppRoomsConverter {
let u;
if (room.creator) {
const creator = RocketChat.models.Users.findOneById(room.creator.id);
const creator = Users.findOneById(room.creator.id);
u = {
_id: creator._id,
username: creator.username,

@ -1,3 +1,4 @@
import { Settings } from 'meteor/rocketchat:models';
import { SettingType } from '@rocket.chat/apps-engine/definition/settings';
export class AppSettingsConverter {
@ -6,7 +7,7 @@ export class AppSettingsConverter {
}
convertById(settingId) {
const setting = RocketChat.models.Settings.findOneNotHiddenById(settingId);
const setting = Settings.findOneNotHiddenById(settingId);
return this.convertToApp(setting);
}

@ -1,3 +1,4 @@
import { Users } from 'meteor/rocketchat:models';
import { UserStatusConnection, UserType } from '@rocket.chat/apps-engine/definition/users';
export class AppUsersConverter {
@ -6,13 +7,13 @@ export class AppUsersConverter {
}
convertById(userId) {
const user = RocketChat.models.Users.findOneById(userId);
const user = Users.findOneById(userId);
return this.convertToApp(user);
}
convertByUsername(username) {
const user = RocketChat.models.Users.findOneByUsername(username);
const user = Users.findOneByUsername(username);
return this.convertToApp(user);
}

@ -0,0 +1 @@
export { Apps } from './orchestrator';

@ -1,15 +1,18 @@
import { Meteor } from 'meteor/meteor';
import { Permissions, AppsLogsModel, AppsModel, AppsPersistenceModel } from 'meteor/rocketchat:models';
import { settings } from 'meteor/rocketchat:settings';
import { RealAppBridges } from './bridges';
import { AppMethods, AppsRestApi, AppServerNotifier } from './communication';
import { AppMessagesConverter, AppRoomsConverter, AppSettingsConverter, AppUsersConverter } from './converters';
import { AppsLogsModel, AppsModel, AppsPersistenceModel, AppRealStorage, AppRealLogsStorage } from './storage';
import { AppRealStorage, AppRealLogsStorage } from './storage';
import { AppManager } from '@rocket.chat/apps-engine/server/AppManager';
export let Apps;
class AppServerOrchestrator {
constructor() {
if (RocketChat.models && RocketChat.models.Permissions) {
RocketChat.models.Permissions.createOrUpdate('manage-apps', ['admin']);
if (Permissions) {
Permissions.createOrUpdate('manage-apps', ['admin']);
}
this._model = new AppsModel();
@ -67,7 +70,7 @@ class AppServerOrchestrator {
}
isEnabled() {
return RocketChat.settings.get('Apps_Framework_enabled');
return settings.get('Apps_Framework_enabled');
}
isLoaded() {
@ -99,7 +102,7 @@ class AppServerOrchestrator {
}
}
RocketChat.settings.addGroup('General', function() {
settings.addGroup('General', function() {
this.section('Apps', function() {
this.add('Apps_Framework_enabled', true, {
type: 'boolean',
@ -108,23 +111,23 @@ RocketChat.settings.addGroup('General', function() {
});
});
RocketChat.settings.get('Apps_Framework_enabled', (key, isEnabled) => {
settings.get('Apps_Framework_enabled', (key, isEnabled) => {
// In case this gets called before `Meteor.startup`
if (!global.Apps) {
if (!Apps) {
return;
}
if (isEnabled) {
global.Apps.load();
Apps.load();
} else {
global.Apps.unload();
Apps.unload();
}
});
Meteor.startup(function _appServerOrchestrator() {
global.Apps = new AppServerOrchestrator();
Apps = new AppServerOrchestrator();
if (global.Apps.isEnabled()) {
global.Apps.load();
if (Apps.isEnabled()) {
Apps.load();
}
});

@ -1,5 +0,0 @@
export class AppsLogsModel extends RocketChat.models._Base {
constructor() {
super('apps_logs');
}
}

@ -1,5 +0,0 @@
export class AppsModel extends RocketChat.models._Base {
constructor() {
super('apps');
}
}

@ -1,5 +0,0 @@
export class AppsPersistenceModel extends RocketChat.models._Base {
constructor() {
super('apps_persistence');
}
}

@ -1,7 +1,4 @@
import { AppsLogsModel } from './apps-logs-model';
import { AppsModel } from './apps-model';
import { AppsPersistenceModel } from './apps-persistence-model';
import { AppRealLogsStorage } from './logs-storage';
import { AppRealStorage } from './storage';
export { AppsLogsModel, AppsModel, AppsPersistenceModel, AppRealLogsStorage, AppRealStorage };
export { AppRealLogsStorage, AppRealStorage };

@ -2,12 +2,11 @@ import { Meteor } from 'meteor/meteor';
import { Importers } from 'meteor/rocketchat:importer';
import { Template } from 'meteor/templating';
import { hasRole } from 'meteor/rocketchat:authorization';
import { t } from 'meteor/rocketchat:utils';
import { t, APIClient } from 'meteor/rocketchat:utils';
import toastr from 'toastr';
import { ReactiveVar } from 'meteor/reactive-var';
import { ProgressStep } from '../../lib/ImporterProgressStep';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { API } from 'meteor/rocketchat:api';
Template.adminImportHistory.helpers({
isAdmin() {
@ -184,7 +183,7 @@ Template.adminImportHistory.onCreated(function() {
this.preparing = new ReactiveVar(true);
this.history = new ReactiveVar([]);
API.get('v1/getLatestImportOperations').then((data) => {
APIClient.get('v1/getLatestImportOperations').then((data) => {
instance.history.set(data);
instance.preparing.set(false);
}).catch((error) => {

@ -6,8 +6,7 @@ import { Template } from 'meteor/templating';
import { TAPi18n } from 'meteor/tap:i18n';
import { hasRole } from 'meteor/rocketchat:authorization';
import { settings } from 'meteor/rocketchat:settings';
import { t, handleError } from 'meteor/rocketchat:utils';
import { API } from 'meteor/rocketchat:api';
import { t, handleError, APIClient } from 'meteor/rocketchat:utils';
import toastr from 'toastr';
Template.adminImportPrepare.helpers({
@ -97,7 +96,7 @@ function showException(error, defaultErrorString) {
}
function getImportFileData(importer, template) {
API.get(`v1/getImportFileData?importerKey=${ importer.key }`).then((data) => {
APIClient.get(`v1/getImportFileData?importerKey=${ importer.key }`).then((data) => {
if (!data) {
console.warn(`The importer ${ importer.key } is not set up correctly, as it did not return any data.`);
toastr.error(t('Importer_not_setup'));
@ -150,7 +149,7 @@ Template.adminImportPrepare.events({
reader.readAsBinaryString(file);
reader.onloadend = () => {
API.post('v1/uploadImportFile', {
APIClient.post('v1/uploadImportFile', {
binaryContent: reader.result,
contentType: file.type,
fileName: file.name,
@ -176,7 +175,7 @@ Template.adminImportPrepare.events({
template.preparing.set(true);
API.post('v1/downloadPublicImportFile', {
APIClient.post('v1/downloadPublicImportFile', {
fileUrl,
importerKey: importer.key,
}).then(() => {

@ -1,6 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { slashCommands } from 'meteor/rocketchat:utils';
import { slashCommands, APIClient } from 'meteor/rocketchat:utils';
// Track logins and when they login, get the commands
(() => {
@ -9,11 +9,9 @@ import { slashCommands } from 'meteor/rocketchat:utils';
Tracker.autorun(() => {
const newUserId = Meteor.userId();
if (oldUserId === null && newUserId) {
import('meteor/rocketchat:api').then(({ API }) => {
API.v1.get('commands.list').then(function _loadedCommands(result) {
result.commands.forEach((command) => {
slashCommands.commands[command.command] = command;
});
APIClient.v1.get('commands.list').then(function _loadedCommands(result) {
result.commands.forEach((command) => {
slashCommands.commands[command.command] = command;
});
});
}

@ -57,6 +57,7 @@ Package.onUse(function(api) {
api.use('rocketchat:markdown');
api.use('rocketchat:channel-settings');
api.use('rocketchat:tokenpass');
api.use('rocketchat:apps');
api.use('templating', 'client');
api.use('kadira:flow-router');

@ -3,6 +3,7 @@ import { Users, Rooms, Subscriptions } from 'meteor/rocketchat:models';
import { callbacks } from 'meteor/rocketchat:callbacks';
import { hasPermission, addUserRoles } from 'meteor/rocketchat:authorization';
import { getValidRoomName } from 'meteor/rocketchat:utils';
import { Apps } from 'meteor/rocketchat:apps';
import _ from 'underscore';
import s from 'underscore.string';

@ -4,6 +4,7 @@ import { settings } from 'meteor/rocketchat:settings';
import { Messages, Uploads, Rooms } from 'meteor/rocketchat:models';
import { Notifications } from 'meteor/rocketchat:notifications';
import { callbacks } from 'meteor/rocketchat:callbacks';
import { Apps } from 'meteor/rocketchat:apps';
export const deleteMessage = function(message, user) {
const keepHistory = settings.get('Message_KeepHistory');

@ -3,6 +3,7 @@ import { Match, check } from 'meteor/check';
import { settings } from 'meteor/rocketchat:settings';
import { callbacks } from 'meteor/rocketchat:callbacks';
import { Messages } from 'meteor/rocketchat:models';
import { Apps } from 'meteor/rocketchat:apps';
const objectMaybeIncluding = (types) => Match.Where((value) => {
Object.keys(types).forEach((field) => {

@ -2,6 +2,7 @@ import { Meteor } from 'meteor/meteor';
import { Messages, Rooms } from 'meteor/rocketchat:models';
import { settings } from 'meteor/rocketchat:settings';
import { callbacks } from 'meteor/rocketchat:callbacks';
import { Apps } from 'meteor/rocketchat:apps';
export const updateMessage = function(message, user, originalMessage) {
if (!originalMessage) {

@ -32,6 +32,10 @@ import LivechatTrigger from './models/LivechatTrigger';
import LivechatVisitors from './models/LivechatVisitors';
import ReadReceipts from './models/ReadReceipts';
export { AppsLogsModel } from './models/apps-logs-model';
export { AppsPersistenceModel } from './models/apps-persistence-model';
export { AppsModel } from './models/apps-model';
export {
Base,
BaseDb,

@ -0,0 +1,7 @@
import { Base } from './_Base';
export class AppsLogsModel extends Base {
constructor() {
super('apps_logs');
}
}

@ -0,0 +1,7 @@
import { Base } from './_Base';
export class AppsModel extends Base {
constructor() {
super('apps');
}
}

@ -0,0 +1,7 @@
import { Base } from './_Base';
export class AppsPersistenceModel extends Base {
constructor() {
super('apps_persistence');
}
}

@ -18,3 +18,4 @@ export { getURL } from '../lib/getURL';
export { getValidRoomName } from '../lib/getValidRoomName';
export { placeholders } from '../lib/placeholders';
export { templateVarHandler } from '../lib/templateVarHandler';
export { APIClient } from './lib/RestApiClient';

@ -1,10 +1,10 @@
export const API = {
export const APIClient = {
delete(endpoint, params) {
return API._jqueryCall('DELETE', endpoint, params);
return APIClient._jqueryCall('DELETE', endpoint, params);
},
get(endpoint, params) {
return API._jqueryCall('GET', endpoint, params);
return APIClient._jqueryCall('GET', endpoint, params);
},
post(endpoint, params, body) {
@ -13,7 +13,7 @@ export const API = {
params = {};
}
return API._jqueryCall('POST', endpoint, params, body);
return APIClient._jqueryCall('POST', endpoint, params, body);
},
upload(endpoint, params, formData) {
@ -22,7 +22,7 @@ export const API = {
params = {};
}
return API._jqueryFormDataCall(endpoint, params, formData);
return APIClient._jqueryFormDataCall(endpoint, params, formData);
},
_generateQueryFromParams(params) {
@ -39,7 +39,7 @@ export const API = {
},
_jqueryCall(method, endpoint, params, body) {
const query = API._generateQueryFromParams(params);
const query = APIClient._generateQueryFromParams(params);
return new Promise(function _rlRestApiGet(resolve, reject) {
jQuery.ajax({
@ -64,7 +64,7 @@ export const API = {
},
_jqueryFormDataCall(endpoint, params, formData) {
const query = API._generateQueryFromParams(params);
const query = APIClient._generateQueryFromParams(params);
if (!(formData instanceof FormData)) {
throw new Error('The formData parameter MUST be an instance of the FormData class.');
@ -93,19 +93,19 @@ export const API = {
v1: {
delete(endpoint, params) {
return API.delete(`v1/${ endpoint }`, params);
return APIClient.delete(`v1/${ endpoint }`, params);
},
get(endpoint, params) {
return API.get(`v1/${ endpoint }`, params);
return APIClient.get(`v1/${ endpoint }`, params);
},
post(endpoint, params, body) {
return API.post(`v1/${ endpoint }`, params, body);
return APIClient.post(`v1/${ endpoint }`, params, body);
},
upload(endpoint, params, formData) {
return API.upload(`v1/${ endpoint }`, params, formData);
return APIClient.upload(`v1/${ endpoint }`, params, formData);
},
},
};

@ -3,6 +3,7 @@ import { check } from 'meteor/check';
import { roomTypes } from 'meteor/rocketchat:utils';
import { hasPermission } from 'meteor/rocketchat:authorization';
import { Rooms, Messages, Subscriptions } from 'meteor/rocketchat:models';
import { Apps } from 'meteor/rocketchat:apps';
Meteor.methods({
eraseRoom(rid) {

Loading…
Cancel
Save