mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
format files in app, src, tests
This commit is contained in:
+17
-13
@@ -163,7 +163,7 @@ class Auth
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function passwordGenerator(int $length = 20):string
|
||||
public static function passwordGenerator(int $length = 20): string
|
||||
{
|
||||
return \bin2hex(\random_bytes($length));
|
||||
}
|
||||
@@ -179,7 +179,7 @@ class Auth
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function tokenGenerator(int $length = 128):string
|
||||
public static function tokenGenerator(int $length = 128): string
|
||||
{
|
||||
return \bin2hex(\random_bytes($length));
|
||||
}
|
||||
@@ -196,12 +196,14 @@ class Auth
|
||||
public static function tokenVerify(array $tokens, int $type, string $secret)
|
||||
{
|
||||
foreach ($tokens as $token) { /** @var Document $token */
|
||||
if ($token->isSet('type') &&
|
||||
if (
|
||||
$token->isSet('type') &&
|
||||
$token->isSet('secret') &&
|
||||
$token->isSet('expire') &&
|
||||
$token->getAttribute('type') == $type &&
|
||||
$token->getAttribute('secret') === self::hash($secret) &&
|
||||
$token->getAttribute('expire') >= \time()) {
|
||||
$token->getAttribute('expire') >= \time()
|
||||
) {
|
||||
return (string)$token->getId();
|
||||
}
|
||||
}
|
||||
@@ -220,11 +222,13 @@ class Auth
|
||||
public static function sessionVerify(array $sessions, string $secret)
|
||||
{
|
||||
foreach ($sessions as $session) { /** @var Document $session */
|
||||
if ($session->isSet('secret') &&
|
||||
if (
|
||||
$session->isSet('secret') &&
|
||||
$session->isSet('expire') &&
|
||||
$session->isSet('provider') &&
|
||||
$session->getAttribute('secret') === self::hash($secret) &&
|
||||
$session->getAttribute('expire') >= \time()) {
|
||||
$session->getAttribute('expire') >= \time()
|
||||
) {
|
||||
return (string)$session->getId();
|
||||
}
|
||||
}
|
||||
@@ -242,9 +246,9 @@ class Auth
|
||||
public static function isPrivilegedUser(array $roles): bool
|
||||
{
|
||||
if (
|
||||
in_array('role:'.self::USER_ROLE_OWNER, $roles) ||
|
||||
in_array('role:'.self::USER_ROLE_DEVELOPER, $roles) ||
|
||||
in_array('role:'.self::USER_ROLE_ADMIN, $roles)
|
||||
in_array('role:' . self::USER_ROLE_OWNER, $roles) ||
|
||||
in_array('role:' . self::USER_ROLE_DEVELOPER, $roles) ||
|
||||
in_array('role:' . self::USER_ROLE_ADMIN, $roles)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
@@ -261,7 +265,7 @@ class Auth
|
||||
*/
|
||||
public static function isAppUser(array $roles): bool
|
||||
{
|
||||
if (in_array('role:'.self::USER_ROLE_APP, $roles)) {
|
||||
if (in_array('role:' . self::USER_ROLE_APP, $roles)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -280,10 +284,10 @@ class Auth
|
||||
|
||||
if (!self::isPrivilegedUser(Authorization::getRoles()) && !self::isAppUser(Authorization::getRoles())) {
|
||||
if ($user->getId()) {
|
||||
$roles[] = 'user:'.$user->getId();
|
||||
$roles[] = 'role:'.Auth::USER_ROLE_MEMBER;
|
||||
$roles[] = 'user:' . $user->getId();
|
||||
$roles[] = 'role:' . Auth::USER_ROLE_MEMBER;
|
||||
} else {
|
||||
return ['role:'.Auth::USER_ROLE_GUEST];
|
||||
return ['role:' . Auth::USER_ROLE_GUEST];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,9 +82,9 @@ abstract class OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function isEmailVerified(string $accessToken): bool;
|
||||
@@ -189,7 +189,7 @@ abstract class OAuth2
|
||||
\curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
||||
}
|
||||
|
||||
$headers[] = 'Content-length: '.\strlen($payload);
|
||||
$headers[] = 'Content-length: ' . \strlen($payload);
|
||||
\curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
|
||||
// Send the request & save response to $response
|
||||
|
||||
@@ -140,11 +140,11 @@ class Amazon extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* If present, the email is verified. This was verfied through a manual Amazon sign up process
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
|
||||
@@ -137,11 +137,11 @@ class Apple extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* @link https://developer.apple.com/forums/thread/121411
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
|
||||
@@ -132,11 +132,11 @@ class Auth0 extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* @link https://auth0.com/docs/api/authentication?javascript#user-profile
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
@@ -180,7 +180,7 @@ class Auth0 extends OAuth2
|
||||
|
||||
/**
|
||||
* Extracts the Client Secret from the JSON stored in appSecret
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getClientSecret(): string
|
||||
@@ -192,7 +192,7 @@ class Auth0 extends OAuth2
|
||||
|
||||
/**
|
||||
* Extracts the Auth0 Domain from the JSON stored in appSecret
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getAuth0Domain(): string
|
||||
@@ -204,7 +204,7 @@ class Auth0 extends OAuth2
|
||||
|
||||
/**
|
||||
* Decode the JSON stored in appSecret
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getAppSecret(): array
|
||||
|
||||
@@ -124,9 +124,9 @@ class Bitbucket extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
|
||||
@@ -9,7 +9,6 @@ use Appwrite\Auth\OAuth2;
|
||||
|
||||
class Bitly extends OAuth2
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@@ -149,11 +148,11 @@ class Bitly extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* @link https://dev.bitly.com/api-reference#getUser
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
|
||||
@@ -141,11 +141,11 @@ class Box extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* If present, the email is verified. This was verfied through a manual Box sign up process
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
|
||||
@@ -18,7 +18,7 @@ class Discord extends OAuth2
|
||||
* @var array
|
||||
*/
|
||||
protected array $user = [];
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
@@ -45,7 +45,7 @@ class Discord extends OAuth2
|
||||
*/
|
||||
public function getLoginURL(): string
|
||||
{
|
||||
$url = $this->endpoint . '/oauth2/authorize?'.
|
||||
$url = $this->endpoint . '/oauth2/authorize?' .
|
||||
\http_build_query([
|
||||
'response_type' => 'code',
|
||||
'client_id' => $this->appID,
|
||||
@@ -64,7 +64,7 @@ class Discord extends OAuth2
|
||||
*/
|
||||
protected function getTokens(string $code): array
|
||||
{
|
||||
if(empty($this->tokens)) {
|
||||
if (empty($this->tokens)) {
|
||||
$this->tokens = \json_decode($this->request(
|
||||
'POST',
|
||||
$this->endpoint . '/oauth2/token',
|
||||
@@ -88,7 +88,7 @@ class Discord extends OAuth2
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function refreshTokens(string $refreshToken):array
|
||||
public function refreshTokens(string $refreshToken): array
|
||||
{
|
||||
$this->tokens = \json_decode($this->request(
|
||||
'POST',
|
||||
@@ -102,7 +102,7 @@ class Discord extends OAuth2
|
||||
])
|
||||
), true);
|
||||
|
||||
if(empty($this->tokens['refresh_token'])) {
|
||||
if (empty($this->tokens['refresh_token'])) {
|
||||
$this->tokens['refresh_token'] = $refreshToken;
|
||||
}
|
||||
|
||||
@@ -135,11 +135,11 @@ class Discord extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* @link https://discord.com/developers/docs/resources/user
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
@@ -176,7 +176,7 @@ class Discord extends OAuth2
|
||||
$user = $this->request(
|
||||
'GET',
|
||||
$this->endpoint . '/users/@me',
|
||||
['Authorization: Bearer '.\urlencode($accessToken)]
|
||||
['Authorization: Bearer ' . \urlencode($accessToken)]
|
||||
);
|
||||
$this->user = \json_decode($user, true);
|
||||
}
|
||||
|
||||
@@ -125,11 +125,11 @@ class Dropbox extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* @link https://www.dropbox.com/developers/documentation/http/documentation#users-get_current_account
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
|
||||
@@ -122,11 +122,11 @@ class Facebook extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* If present, the email is verified. This was verfied through a manual Facebook sign up process
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
|
||||
@@ -128,11 +128,11 @@ class Github extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* @link https://docs.github.com/en/rest/users/emails#list-email-addresses-for-the-authenticated-user
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
|
||||
@@ -125,11 +125,11 @@ class Gitlab extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* @link https://docs.gitlab.com/ee/api/users.html#list-current-user-for-normal-users
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
|
||||
@@ -131,11 +131,11 @@ class Google extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* @link https://www.oauth.com/oauth2-servers/signing-in-with-google/verifying-the-user-info/
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
|
||||
@@ -137,11 +137,11 @@ class Linkedin extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* If present, the email is verified. This was verfied through a manual Linkedin sign up process
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
|
||||
@@ -131,11 +131,11 @@ class Microsoft extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* If present, the email is verified. This was verfied through a manual Microsoft sign up process
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
@@ -175,7 +175,7 @@ class Microsoft extends OAuth2
|
||||
|
||||
/**
|
||||
* Decode the JSON stored in appSecret
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getAppSecret(): array
|
||||
@@ -190,7 +190,7 @@ class Microsoft extends OAuth2
|
||||
|
||||
/**
|
||||
* Extracts the Client Secret from the JSON stored in appSecret
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getClientSecret(): string
|
||||
@@ -202,7 +202,7 @@ class Microsoft extends OAuth2
|
||||
|
||||
/**
|
||||
* Extracts the Tenant Id from the JSON stored in appSecret. Defaults to 'common' as a fallback
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getTenantID(): string
|
||||
|
||||
@@ -124,9 +124,9 @@ class Mock extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
|
||||
@@ -128,11 +128,11 @@ class Notion extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* If present, the email is verified. This was verfied through a manual Notion sign up process
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
|
||||
@@ -132,11 +132,11 @@ class Okta extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* @link https://developer.okta.com/docs/reference/api/oidc/#userinfo
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
@@ -180,7 +180,7 @@ class Okta extends OAuth2
|
||||
|
||||
/**
|
||||
* Extracts the Client Secret from the JSON stored in appSecret
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getClientSecret(): string
|
||||
@@ -192,7 +192,7 @@ class Okta extends OAuth2
|
||||
|
||||
/**
|
||||
* Extracts the Okta Domain from the JSON stored in appSecret
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getOktaDomain(): string
|
||||
@@ -204,7 +204,7 @@ class Okta extends OAuth2
|
||||
|
||||
/**
|
||||
* Extracts the Okta Authorization Server ID from the JSON stored in appSecret
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getAuthorizationServerId(): string
|
||||
@@ -216,7 +216,7 @@ class Okta extends OAuth2
|
||||
|
||||
/**
|
||||
* Decode the JSON stored in appSecret
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getAppSecret(): array
|
||||
|
||||
@@ -158,11 +158,11 @@ class Paypal extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* @link https://developer.paypal.com/docs/api/identity/v1/#userinfo_get
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
|
||||
@@ -142,11 +142,11 @@ class Salesforce extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* @link https://help.salesforce.com/s/articleView?id=sf.remoteaccess_using_userinfo_endpoint.htm&type=5
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
|
||||
@@ -121,13 +121,13 @@ class Slack extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* If present, the email is verified. This was verfied through a manual Slack sign up process
|
||||
*
|
||||
*
|
||||
* @link https://slack.com/help/articles/207262907-Change-your-email-address
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
@@ -151,7 +151,7 @@ class Slack extends OAuth2
|
||||
|
||||
/**
|
||||
* @link https://api.slack.com/methods/users.identity
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
* @return array
|
||||
|
||||
@@ -9,7 +9,6 @@ use Appwrite\Auth\OAuth2;
|
||||
|
||||
class Spotify extends OAuth2
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@@ -135,13 +134,13 @@ class Spotify extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
* Spotify does not assure that the email is verified
|
||||
*
|
||||
*
|
||||
* Spotify does not assure that the email is verified
|
||||
*
|
||||
* @link https://developer.spotify.com/documentation/web-api/reference/#/operations/get-current-users-profile
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
|
||||
@@ -138,11 +138,11 @@ class Stripe extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* If present, the email is verified. This was verfied through a manual Stripe sign up process
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
|
||||
@@ -42,7 +42,7 @@ class Tradeshift extends OAuth2
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected array$scopes = [
|
||||
protected array $scopes = [
|
||||
'openid',
|
||||
'offline',
|
||||
];
|
||||
@@ -145,11 +145,11 @@ class Tradeshift extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* If present, the email is verified. This was verfied through a manual Tradeshift sign up process
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
|
||||
@@ -9,7 +9,6 @@ use Appwrite\Auth\OAuth2;
|
||||
|
||||
class Twitch extends OAuth2
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@@ -134,13 +133,13 @@ class Twitch extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* If present, the email is verified
|
||||
*
|
||||
*
|
||||
* @link https://dev.twitch.tv/docs/api/reference#get-users
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
|
||||
@@ -129,11 +129,11 @@ class WordPress extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* @link https://developer.wordpress.com/docs/api/1.1/get/me/
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
|
||||
@@ -9,7 +9,6 @@ use Appwrite\Auth\OAuth2;
|
||||
|
||||
class Yahoo extends OAuth2
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@@ -155,11 +154,11 @@ class Yahoo extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* If present, the email is verified. This was verfied through a manual Yahoo sign up process
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
|
||||
@@ -124,11 +124,11 @@ class Yammer extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* If present, the email is verified. This was verfied through a manual Yammer sign up process
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
|
||||
@@ -138,9 +138,9 @@ class Yandex extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
|
||||
@@ -130,11 +130,11 @@ class Zoom extends OAuth2
|
||||
|
||||
/**
|
||||
* Check if the OAuth email is verified
|
||||
*
|
||||
*
|
||||
* @link https://marketplace.zoom.us/docs/api-reference/zoom-api/methods/#operation/user
|
||||
*
|
||||
*
|
||||
* @param string $accessToken
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
|
||||
@@ -34,7 +34,7 @@ class Password extends Validator
|
||||
{
|
||||
if (!\is_string($value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (\strlen($value) < 8) {
|
||||
return false;
|
||||
|
||||
@@ -21,7 +21,7 @@ class Compose
|
||||
|
||||
$this->compose['services'] = (isset($this->compose['services']) && is_array($this->compose['services']))
|
||||
? $this->compose['services'] : [];
|
||||
|
||||
|
||||
foreach ($this->compose['services'] as $key => &$service) {
|
||||
$service = new Service($service);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class Service
|
||||
public function __construct(array $service)
|
||||
{
|
||||
$this->service = $service;
|
||||
|
||||
|
||||
$ports = (isset($this->service['ports']) && is_array($this->service['ports'])) ? $this->service['ports'] : [];
|
||||
$this->service['ports'] = [];
|
||||
|
||||
@@ -54,7 +54,7 @@ class Service
|
||||
public function getImageVersion(): string
|
||||
{
|
||||
$image = $this->getImage();
|
||||
return substr($image, ((int)strpos($image, ':'))+1);
|
||||
return substr($image, ((int)strpos($image, ':')) + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -70,7 +70,7 @@ class Env
|
||||
$output = '';
|
||||
|
||||
foreach ($this->vars as $key => $value) {
|
||||
$output .= $key.'='.$value."\n";
|
||||
$output .= $key . '=' . $value . "\n";
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
@@ -127,4 +127,4 @@ class Audit extends Event
|
||||
'events' => Event::generateEvents($this->getEvent(), $this->getParams())
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class Build extends Event
|
||||
/**
|
||||
* Returns set resource document for the build event.
|
||||
*
|
||||
* @return null|Document
|
||||
* @return null|Document
|
||||
*/
|
||||
public function getResource(): ?Document
|
||||
{
|
||||
|
||||
@@ -31,7 +31,7 @@ class Database extends Event
|
||||
|
||||
/**
|
||||
* Returns the set type for the database event.
|
||||
* @return string
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
@@ -100,4 +100,4 @@ class Database extends Event
|
||||
'events' => Event::generateEvents($this->getEvent(), $this->getParams())
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class Delete extends Event
|
||||
/**
|
||||
* Returns the set type for the delete event.
|
||||
*
|
||||
* @return string
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
|
||||
@@ -392,7 +392,9 @@ class Event
|
||||
$events[] = \str_replace($paramKeys, '*', $eventPattern);
|
||||
foreach ($paramKeys as $key) {
|
||||
foreach ($paramKeys as $current) {
|
||||
if ($current === $key) continue;
|
||||
if ($current === $key) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$filtered = \array_filter($paramKeys, fn(string $k) => $k === $current);
|
||||
$events[] = \str_replace($paramKeys, $paramValues, \str_replace($filtered, '*', $eventPattern));
|
||||
|
||||
@@ -36,7 +36,7 @@ class Func extends Event
|
||||
/**
|
||||
* Returns set function document for the function event.
|
||||
*
|
||||
* @return null|Document
|
||||
* @return null|Document
|
||||
*/
|
||||
public function getFunction(): ?Document
|
||||
{
|
||||
|
||||
@@ -6,10 +6,10 @@ class Exception extends \Exception
|
||||
{
|
||||
/**
|
||||
* Error Codes
|
||||
*
|
||||
* Naming the error types based on the following convention
|
||||
*
|
||||
* Naming the error types based on the following convention
|
||||
* <ENTITY>_<ERROR_TYPE>
|
||||
*
|
||||
*
|
||||
* Appwrite has the follwing entities:
|
||||
* - General
|
||||
* - Users
|
||||
@@ -73,7 +73,7 @@ class Exception extends \Exception
|
||||
const TEAM_INVITE_NOT_FOUND = 'team_invite_not_found';
|
||||
const TEAM_INVALID_SECRET = 'team_invalid_secret';
|
||||
const TEAM_MEMBERSHIP_MISMATCH = 'team_membership_mismatch';
|
||||
const TEAM_INVITE_MISMATCH = 'team_invite_mismatch';
|
||||
const TEAM_INVITE_MISMATCH = 'team_invite_mismatch';
|
||||
|
||||
/** Membership */
|
||||
const MEMBERSHIP_NOT_FOUND = 'membership_not_found';
|
||||
@@ -116,7 +116,7 @@ class Exception extends \Exception
|
||||
const COLLECTION_NOT_FOUND = 'collection_not_found';
|
||||
const COLLECTION_ALREADY_EXISTS = 'collection_already_exists';
|
||||
const COLLECTION_LIMIT_EXCEEDED = 'collection_limit_exceeded';
|
||||
|
||||
|
||||
/** Documents */
|
||||
const DOCUMENT_NOT_FOUND = 'document_not_found';
|
||||
const DOCUMENT_INVALID_STRUCTURE = 'document_invalid_structure';
|
||||
@@ -174,9 +174,9 @@ class Exception extends \Exception
|
||||
|
||||
/**
|
||||
* Get the type of the exception.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
@@ -184,14 +184,13 @@ class Exception extends \Exception
|
||||
|
||||
/**
|
||||
* Set the type of the exception.
|
||||
*
|
||||
*
|
||||
* @param string $type
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setType(string $type): void
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,8 +99,8 @@ class PDO extends PDONative
|
||||
{
|
||||
$this->pdo = new PDONative($this->dsn, $this->username, $this->passwd, $this->options);
|
||||
|
||||
echo '[PDO] MySQL connection restarted'.PHP_EOL;
|
||||
|
||||
echo '[PDO] MySQL connection restarted' . PHP_EOL;
|
||||
|
||||
// Connection settings
|
||||
$this->pdo->setAttribute(PDONative::ATTR_DEFAULT_FETCH_MODE, PDONative::FETCH_ASSOC); // Return arrays
|
||||
$this->pdo->setAttribute(PDONative::ATTR_ERRMODE, PDONative::ERRMODE_EXCEPTION); // Handle all errors with exceptions
|
||||
|
||||
@@ -76,7 +76,7 @@ class PDOStatement extends PDOStatementNative
|
||||
foreach ($this->values as $key => $set) {
|
||||
$this->PDOStatement->bindValue($key, $set['value'], $set['data_type']);
|
||||
}
|
||||
|
||||
|
||||
foreach ($this->params as $key => $set) {
|
||||
$this->PDOStatement->bindParam($key, $set['variable'], $set['data_type'], $set['length'], $set['driver_options']);
|
||||
}
|
||||
@@ -109,7 +109,7 @@ class PDOStatement extends PDOStatementNative
|
||||
public function fetchAll(int $fetch_style = PDO::FETCH_BOTH, mixed ...$fetch_args)
|
||||
{
|
||||
$result = $this->PDOStatement->fetchAll();
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Appwrite\Messaging;
|
||||
|
||||
abstract class Adapter
|
||||
{
|
||||
public abstract function subscribe(string $projectId, mixed $identifier, array $roles, array $channels): void;
|
||||
public abstract function unsubscribe(mixed $identifier): void;
|
||||
public static abstract function send(string $projectId, array $payload, array $events, array $channels, array $roles, array $options): void;
|
||||
abstract public function subscribe(string $projectId, mixed $identifier, array $roles, array $channels): void;
|
||||
abstract public function unsubscribe(mixed $identifier): void;
|
||||
abstract public static function send(string $projectId, array $payload, array $events, array $channels, array $roles, array $options): void;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class Realtime extends Adapter
|
||||
{
|
||||
/**
|
||||
* Connection Tree
|
||||
*
|
||||
*
|
||||
* [CONNECTION_ID] ->
|
||||
* 'projectId' -> [PROJECT_ID]
|
||||
* 'roles' -> [ROLE_x, ROLE_Y]
|
||||
@@ -67,7 +67,7 @@ class Realtime extends Adapter
|
||||
|
||||
/**
|
||||
* Removes Subscription.
|
||||
*
|
||||
*
|
||||
* @param mixed $connection
|
||||
* @return void
|
||||
*/
|
||||
@@ -129,7 +129,9 @@ class Realtime extends Adapter
|
||||
*/
|
||||
public static function send(string $projectId, array $payload, array $events, array $channels, array $roles, array $options = []): void
|
||||
{
|
||||
if (empty($channels) || empty($roles) || empty($projectId)) return;
|
||||
if (empty($channels) || empty($roles) || empty($projectId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$permissionsChanged = array_key_exists('permissionsChanged', $options) && $options['permissionsChanged'];
|
||||
$userId = array_key_exists('userId', $options) ? $options['userId'] : null;
|
||||
@@ -154,12 +156,12 @@ class Realtime extends Adapter
|
||||
* Identifies the receivers of all subscriptions, based on the permissions and event.
|
||||
*
|
||||
* Example of performance with an event with user:XXX permissions and with X users spread across 10 different channels:
|
||||
* - 0.014 ms (±6.88%) | 10 Connections / 100 Subscriptions
|
||||
* - 0.070 ms (±3.71%) | 100 Connections / 1,000 Subscriptions
|
||||
* - 0.014 ms (±6.88%) | 10 Connections / 100 Subscriptions
|
||||
* - 0.070 ms (±3.71%) | 100 Connections / 1,000 Subscriptions
|
||||
* - 0.846 ms (±2.74%) | 1,000 Connections / 10,000 Subscriptions
|
||||
* - 10.866 ms (±1.01%) | 10,000 Connections / 100,000 Subscriptions
|
||||
* - 110.201 ms (±2.32%) | 100,000 Connections / 1,000,000 Subscriptions
|
||||
* - 1,121.328 ms (±0.84%) | 1,000,000 Connections / 10,000,000 Subscriptions
|
||||
* - 1,121.328 ms (±0.84%) | 1,000,000 Connections / 10,000,000 Subscriptions
|
||||
*
|
||||
* @param array $event
|
||||
*/
|
||||
@@ -209,7 +211,7 @@ class Realtime extends Adapter
|
||||
* Also renames the account channel to account.USER_ID and removes all illegal account channel variations.
|
||||
* @param array $channels
|
||||
* @param string $userId
|
||||
* @return array
|
||||
* @return array
|
||||
*/
|
||||
public static function convertChannels(array $channels, string $userId): array
|
||||
{
|
||||
@@ -238,7 +240,7 @@ class Realtime extends Adapter
|
||||
* @param string $event
|
||||
* @param Document $payload
|
||||
* @param Document|null $project
|
||||
* @return array
|
||||
* @return array
|
||||
*/
|
||||
public static function fromPayload(string $event, Document $payload, Document $project = null, Document $collection = null, Document $bucket = null): array
|
||||
{
|
||||
|
||||
@@ -102,7 +102,9 @@ abstract class Migration
|
||||
Runtime::enableCoroutine(SWOOLE_HOOK_ALL);
|
||||
|
||||
foreach ($this->collections as $collection) {
|
||||
if ($collection['$collection'] !== Database::METADATA) return;
|
||||
if ($collection['$collection'] !== Database::METADATA) {
|
||||
return;
|
||||
}
|
||||
$sum = 0;
|
||||
$nextDocument = null;
|
||||
$collectionCount = $this->projectDB->count($collection['$id']);
|
||||
|
||||
@@ -300,11 +300,11 @@ class V12 extends Migration
|
||||
/**
|
||||
* Migrates permissions to dedicated table.
|
||||
*
|
||||
* @param \Utopia\Database\Document $document
|
||||
* @param string $internalId
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
* @throws \PDOException
|
||||
* @param \Utopia\Database\Document $document
|
||||
* @param string $internalId
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
* @throws \PDOException
|
||||
*/
|
||||
protected function migratePermissionsToDedicatedTable(string $collection, Document $document): void
|
||||
{
|
||||
@@ -499,8 +499,8 @@ class V12 extends Migration
|
||||
/**
|
||||
* Fix run on each document
|
||||
*
|
||||
* @param \Utopia\Database\Document $document
|
||||
* @return \Utopia\Database\Document
|
||||
* @param \Utopia\Database\Document $document
|
||||
* @return \Utopia\Database\Document
|
||||
*/
|
||||
protected function fixDocument(Document $document)
|
||||
{
|
||||
|
||||
@@ -223,8 +223,8 @@ class V13 extends Migration
|
||||
/**
|
||||
* Fix run on each document
|
||||
*
|
||||
* @param \Utopia\Database\Document $document
|
||||
* @return \Utopia\Database\Document
|
||||
* @param \Utopia\Database\Document $document
|
||||
* @return \Utopia\Database\Document
|
||||
*/
|
||||
protected function fixDocument(Document $document)
|
||||
{
|
||||
@@ -273,7 +273,9 @@ class V13 extends Migration
|
||||
public function migrateEvents(array $events): array
|
||||
{
|
||||
return array_filter(array_unique(array_map(function ($event) {
|
||||
if (!in_array($event, $this->events)) return $event;
|
||||
if (!in_array($event, $this->events)) {
|
||||
return $event;
|
||||
}
|
||||
$parts = \explode('.', $event);
|
||||
$first = array_shift($parts);
|
||||
switch ($first) {
|
||||
|
||||
@@ -66,7 +66,7 @@ class IP extends Validator
|
||||
if (\filter_var($value, FILTER_VALIDATE_IP)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case self::V4:
|
||||
if (\filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
||||
|
||||
@@ -95,8 +95,8 @@ class Origin extends Validator
|
||||
return 'Unsupported platform';
|
||||
}
|
||||
|
||||
return 'Invalid Origin. Register your new client ('.$this->host.') as a new '
|
||||
.$this->platforms[$this->client].' platform on your project console dashboard';
|
||||
return 'Invalid Origin. Register your new client (' . $this->host . ') as a new '
|
||||
. $this->platforms[$this->client] . ' platform on your project console dashboard';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,7 +124,7 @@ class Origin extends Validator
|
||||
}
|
||||
|
||||
$validator = new Hostname($this->clients);
|
||||
|
||||
|
||||
return $validator->isValid($host);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ use Utopia\Storage\Device\Linode;
|
||||
use Utopia\Storage\Device\Wasabi;
|
||||
use Utopia\Storage\Device\Backblaze;
|
||||
use Utopia\Storage\Device\S3;
|
||||
|
||||
use Exception;
|
||||
|
||||
abstract class Worker
|
||||
@@ -26,7 +25,7 @@ abstract class Worker
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static protected array $errorCallbacks = [];
|
||||
protected static array $errorCallbacks = [];
|
||||
|
||||
/**
|
||||
* Associative array holding all information passed into the worker
|
||||
@@ -53,7 +52,8 @@ abstract class Worker
|
||||
* @return void
|
||||
* @throws \Exception|\Throwable
|
||||
*/
|
||||
public function init() {
|
||||
public function init()
|
||||
{
|
||||
throw new Exception("Please implement init method in worker");
|
||||
}
|
||||
|
||||
@@ -64,7 +64,8 @@ abstract class Worker
|
||||
* @return void
|
||||
* @throws \Exception|\Throwable
|
||||
*/
|
||||
public function run() {
|
||||
public function run()
|
||||
{
|
||||
throw new Exception("Please implement run method in worker");
|
||||
}
|
||||
|
||||
@@ -75,7 +76,8 @@ abstract class Worker
|
||||
* @return void
|
||||
* @throws \Exception|\Throwable
|
||||
*/
|
||||
public function shutdown() {
|
||||
public function shutdown()
|
||||
{
|
||||
throw new Exception("Please implement shutdown method in worker");
|
||||
}
|
||||
|
||||
@@ -92,7 +94,7 @@ abstract class Worker
|
||||
{
|
||||
try {
|
||||
$this->init();
|
||||
} catch(\Throwable $error) {
|
||||
} catch (\Throwable $error) {
|
||||
foreach (self::$errorCallbacks as $errorCallback) {
|
||||
$errorCallback($error, "init", $this->getName());
|
||||
}
|
||||
@@ -111,7 +113,7 @@ abstract class Worker
|
||||
{
|
||||
try {
|
||||
$this->run();
|
||||
} catch(\Throwable $error) {
|
||||
} catch (\Throwable $error) {
|
||||
foreach (self::$errorCallbacks as $errorCallback) {
|
||||
$errorCallback($error, "run", $this->getName(), $this->args);
|
||||
}
|
||||
@@ -130,7 +132,7 @@ abstract class Worker
|
||||
{
|
||||
try {
|
||||
$this->shutdown();
|
||||
} catch(\Throwable $error) {
|
||||
} catch (\Throwable $error) {
|
||||
foreach (self::$errorCallbacks as $errorCallback) {
|
||||
$errorCallback($error, "shutdown", $this->getName());
|
||||
}
|
||||
@@ -217,10 +219,10 @@ abstract class Worker
|
||||
}
|
||||
|
||||
break; // leave loop if successful
|
||||
} catch(\Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
Console::warning("Database not ready. Retrying connection ({$attempts})...");
|
||||
if ($attempts >= DATABASE_RECONNECT_MAX_ATTEMPTS) {
|
||||
throw new \Exception('Failed to connect to database: '. $e->getMessage());
|
||||
throw new \Exception('Failed to connect to database: ' . $e->getMessage());
|
||||
}
|
||||
sleep($sleep);
|
||||
}
|
||||
@@ -234,7 +236,8 @@ abstract class Worker
|
||||
* @param string $projectId of the project
|
||||
* @return Device
|
||||
*/
|
||||
protected function getFunctionsDevice($projectId): Device {
|
||||
protected function getFunctionsDevice($projectId): Device
|
||||
{
|
||||
return $this->getDevice(APP_STORAGE_FUNCTIONS . '/app-' . $projectId);
|
||||
}
|
||||
|
||||
@@ -243,7 +246,8 @@ abstract class Worker
|
||||
* @param string $projectId of the project
|
||||
* @return Device
|
||||
*/
|
||||
protected function getFilesDevice($projectId): Device {
|
||||
protected function getFilesDevice($projectId): Device
|
||||
{
|
||||
return $this->getDevice(APP_STORAGE_UPLOADS . '/app-' . $projectId);
|
||||
}
|
||||
|
||||
@@ -253,7 +257,8 @@ abstract class Worker
|
||||
* @param string $projectId of the project
|
||||
* @return Device
|
||||
*/
|
||||
protected function getBuildsDevice($projectId): Device {
|
||||
protected function getBuildsDevice($projectId): Device
|
||||
{
|
||||
return $this->getDevice(APP_STORAGE_BUILDS . '/app-' . $projectId);
|
||||
}
|
||||
|
||||
@@ -265,43 +270,44 @@ abstract class Worker
|
||||
public function getDevice($root): Device
|
||||
{
|
||||
switch (App::getEnv('_APP_STORAGE_DEVICE', Storage::DEVICE_LOCAL)) {
|
||||
case Storage::DEVICE_LOCAL:default:
|
||||
return new Local($root);
|
||||
case Storage::DEVICE_S3:
|
||||
$s3AccessKey = App::getEnv('_APP_STORAGE_S3_ACCESS_KEY', '');
|
||||
$s3SecretKey = App::getEnv('_APP_STORAGE_S3_SECRET', '');
|
||||
$s3Region = App::getEnv('_APP_STORAGE_S3_REGION', '');
|
||||
$s3Bucket = App::getEnv('_APP_STORAGE_S3_BUCKET', '');
|
||||
$s3Acl = 'private';
|
||||
return new S3($root, $s3AccessKey, $s3SecretKey, $s3Bucket, $s3Region, $s3Acl);
|
||||
case Storage::DEVICE_DO_SPACES:
|
||||
$doSpacesAccessKey = App::getEnv('_APP_STORAGE_DO_SPACES_ACCESS_KEY', '');
|
||||
$doSpacesSecretKey = App::getEnv('_APP_STORAGE_DO_SPACES_SECRET', '');
|
||||
$doSpacesRegion = App::getEnv('_APP_STORAGE_DO_SPACES_REGION', '');
|
||||
$doSpacesBucket = App::getEnv('_APP_STORAGE_DO_SPACES_BUCKET', '');
|
||||
$doSpacesAcl = 'private';
|
||||
return new DOSpaces($root, $doSpacesAccessKey, $doSpacesSecretKey, $doSpacesBucket, $doSpacesRegion, $doSpacesAcl);
|
||||
case Storage::DEVICE_BACKBLAZE:
|
||||
$backblazeAccessKey = App::getEnv('_APP_STORAGE_BACKBLAZE_ACCESS_KEY', '');
|
||||
$backblazeSecretKey = App::getEnv('_APP_STORAGE_BACKBLAZE_SECRET', '');
|
||||
$backblazeRegion = App::getEnv('_APP_STORAGE_BACKBLAZE_REGION', '');
|
||||
$backblazeBucket = App::getEnv('_APP_STORAGE_BACKBLAZE_BUCKET', '');
|
||||
$backblazeAcl = 'private';
|
||||
return new Backblaze($root, $backblazeAccessKey, $backblazeSecretKey, $backblazeBucket, $backblazeRegion, $backblazeAcl);
|
||||
case Storage::DEVICE_LINODE:
|
||||
$linodeAccessKey = App::getEnv('_APP_STORAGE_LINODE_ACCESS_KEY', '');
|
||||
$linodeSecretKey = App::getEnv('_APP_STORAGE_LINODE_SECRET', '');
|
||||
$linodeRegion = App::getEnv('_APP_STORAGE_LINODE_REGION', '');
|
||||
$linodeBucket = App::getEnv('_APP_STORAGE_LINODE_BUCKET', '');
|
||||
$linodeAcl = 'private';
|
||||
return new Linode($root, $linodeAccessKey, $linodeSecretKey, $linodeBucket, $linodeRegion, $linodeAcl);
|
||||
case Storage::DEVICE_WASABI:
|
||||
$wasabiAccessKey = App::getEnv('_APP_STORAGE_WASABI_ACCESS_KEY', '');
|
||||
$wasabiSecretKey = App::getEnv('_APP_STORAGE_WASABI_SECRET', '');
|
||||
$wasabiRegion = App::getEnv('_APP_STORAGE_WASABI_REGION', '');
|
||||
$wasabiBucket = App::getEnv('_APP_STORAGE_WASABI_BUCKET', '');
|
||||
$wasabiAcl = 'private';
|
||||
return new Wasabi($root, $wasabiAccessKey, $wasabiSecretKey, $wasabiBucket, $wasabiRegion, $wasabiAcl);
|
||||
case Storage::DEVICE_LOCAL:
|
||||
default:
|
||||
return new Local($root);
|
||||
case Storage::DEVICE_S3:
|
||||
$s3AccessKey = App::getEnv('_APP_STORAGE_S3_ACCESS_KEY', '');
|
||||
$s3SecretKey = App::getEnv('_APP_STORAGE_S3_SECRET', '');
|
||||
$s3Region = App::getEnv('_APP_STORAGE_S3_REGION', '');
|
||||
$s3Bucket = App::getEnv('_APP_STORAGE_S3_BUCKET', '');
|
||||
$s3Acl = 'private';
|
||||
return new S3($root, $s3AccessKey, $s3SecretKey, $s3Bucket, $s3Region, $s3Acl);
|
||||
case Storage::DEVICE_DO_SPACES:
|
||||
$doSpacesAccessKey = App::getEnv('_APP_STORAGE_DO_SPACES_ACCESS_KEY', '');
|
||||
$doSpacesSecretKey = App::getEnv('_APP_STORAGE_DO_SPACES_SECRET', '');
|
||||
$doSpacesRegion = App::getEnv('_APP_STORAGE_DO_SPACES_REGION', '');
|
||||
$doSpacesBucket = App::getEnv('_APP_STORAGE_DO_SPACES_BUCKET', '');
|
||||
$doSpacesAcl = 'private';
|
||||
return new DOSpaces($root, $doSpacesAccessKey, $doSpacesSecretKey, $doSpacesBucket, $doSpacesRegion, $doSpacesAcl);
|
||||
case Storage::DEVICE_BACKBLAZE:
|
||||
$backblazeAccessKey = App::getEnv('_APP_STORAGE_BACKBLAZE_ACCESS_KEY', '');
|
||||
$backblazeSecretKey = App::getEnv('_APP_STORAGE_BACKBLAZE_SECRET', '');
|
||||
$backblazeRegion = App::getEnv('_APP_STORAGE_BACKBLAZE_REGION', '');
|
||||
$backblazeBucket = App::getEnv('_APP_STORAGE_BACKBLAZE_BUCKET', '');
|
||||
$backblazeAcl = 'private';
|
||||
return new Backblaze($root, $backblazeAccessKey, $backblazeSecretKey, $backblazeBucket, $backblazeRegion, $backblazeAcl);
|
||||
case Storage::DEVICE_LINODE:
|
||||
$linodeAccessKey = App::getEnv('_APP_STORAGE_LINODE_ACCESS_KEY', '');
|
||||
$linodeSecretKey = App::getEnv('_APP_STORAGE_LINODE_SECRET', '');
|
||||
$linodeRegion = App::getEnv('_APP_STORAGE_LINODE_REGION', '');
|
||||
$linodeBucket = App::getEnv('_APP_STORAGE_LINODE_BUCKET', '');
|
||||
$linodeAcl = 'private';
|
||||
return new Linode($root, $linodeAccessKey, $linodeSecretKey, $linodeBucket, $linodeRegion, $linodeAcl);
|
||||
case Storage::DEVICE_WASABI:
|
||||
$wasabiAccessKey = App::getEnv('_APP_STORAGE_WASABI_ACCESS_KEY', '');
|
||||
$wasabiSecretKey = App::getEnv('_APP_STORAGE_WASABI_SECRET', '');
|
||||
$wasabiRegion = App::getEnv('_APP_STORAGE_WASABI_REGION', '');
|
||||
$wasabiBucket = App::getEnv('_APP_STORAGE_WASABI_BUCKET', '');
|
||||
$wasabiAcl = 'private';
|
||||
return new Wasabi($root, $wasabiAccessKey, $wasabiSecretKey, $wasabiBucket, $wasabiRegion, $wasabiAcl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,32 +12,32 @@ abstract class Format
|
||||
* @var App
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $services;
|
||||
|
||||
|
||||
/**
|
||||
* @var Route[]
|
||||
*/
|
||||
protected $routes;
|
||||
|
||||
|
||||
/**
|
||||
* @var Model[]
|
||||
*/
|
||||
protected $models;
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $keys;
|
||||
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $authCount;
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
@@ -99,7 +99,7 @@ abstract class Format
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
*
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setParam(string $key, string $value): self
|
||||
@@ -116,16 +116,15 @@ abstract class Format
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $default
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getParam(string $key, string $default = ''): string
|
||||
{
|
||||
if(!isset($this->params[$key])) {
|
||||
if (!isset($this->params[$key])) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
return $this->params[$key];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class OpenAPI3 extends Format
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Open API 3';
|
||||
}
|
||||
@@ -100,7 +100,7 @@ class OpenAPI3 extends Format
|
||||
}
|
||||
|
||||
$id = $route->getLabel('sdk.method', \uniqid());
|
||||
$desc = (!empty($route->getLabel('sdk.description', ''))) ? \realpath(__DIR__.'/../../../../'.$route->getLabel('sdk.description', '')) : null;
|
||||
$desc = (!empty($route->getLabel('sdk.description', ''))) ? \realpath(__DIR__ . '/../../../../' . $route->getLabel('sdk.description', '')) : null;
|
||||
$produces = $route->getLabel('sdk.response.type', null);
|
||||
$model = $route->getLabel('sdk.response.model', 'none');
|
||||
$routeSecurity = $route->getLabel('sdk.auth', []);
|
||||
@@ -123,13 +123,13 @@ class OpenAPI3 extends Format
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($routeSecurity)) {
|
||||
if (empty($routeSecurity)) {
|
||||
$sdkPlatofrms[] = APP_PLATFORM_CLIENT;
|
||||
}
|
||||
|
||||
$temp = [
|
||||
'summary' => $route->getDesc(),
|
||||
'operationId' => $route->getLabel('sdk.namespace', 'default').ucfirst($id),
|
||||
'operationId' => $route->getLabel('sdk.namespace', 'default') . ucfirst($id),
|
||||
// 'consumes' => [],
|
||||
// 'produces' => [$produces],
|
||||
'tags' => [$route->getLabel('sdk.namespace', 'default')],
|
||||
@@ -140,7 +140,7 @@ class OpenAPI3 extends Format
|
||||
'weight' => $route->getOrder(),
|
||||
'cookies' => $route->getLabel('sdk.cookies', false),
|
||||
'type' => $route->getLabel('sdk.methodType', ''),
|
||||
'demo' => Template::fromCamelCaseToDash($route->getLabel('sdk.namespace', 'default')).'/'.Template::fromCamelCaseToDash($id).'.md',
|
||||
'demo' => Template::fromCamelCaseToDash($route->getLabel('sdk.namespace', 'default')) . '/' . Template::fromCamelCaseToDash($id) . '.md',
|
||||
'edit' => 'https://github.com/appwrite/appwrite/edit/master' . $route->getLabel('sdk.description', ''),
|
||||
'rate-limit' => $route->getLabel('abuse-limit', 0),
|
||||
'rate-time' => $route->getLabel('abuse-time', 3600),
|
||||
@@ -152,24 +152,23 @@ class OpenAPI3 extends Format
|
||||
];
|
||||
|
||||
foreach ($this->models as $key => $value) {
|
||||
if(\is_array($model)) {
|
||||
$model = \array_map(function($m) use($value) {
|
||||
if($m === $value->getType()) {
|
||||
if (\is_array($model)) {
|
||||
$model = \array_map(function ($m) use ($value) {
|
||||
if ($m === $value->getType()) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
return $m;
|
||||
}, $model);
|
||||
} else {
|
||||
if($value->getType() === $model) {
|
||||
if ($value->getType() === $model) {
|
||||
$model = $value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!(\is_array($model)) && $model->isNone()) {
|
||||
if (!(\is_array($model)) && $model->isNone()) {
|
||||
$temp['responses'][(string)$route->getLabel('sdk.response.code', '500')] = [
|
||||
'description' => (in_array($produces, [
|
||||
'image/*',
|
||||
@@ -186,7 +185,7 @@ class OpenAPI3 extends Format
|
||||
// ],
|
||||
];
|
||||
} else {
|
||||
if(\is_array($model)) {
|
||||
if (\is_array($model)) {
|
||||
$modelDescription = \join(', or ', \array_map(function ($m) {
|
||||
return $m->getName();
|
||||
}, $model));
|
||||
@@ -201,8 +200,8 @@ class OpenAPI3 extends Format
|
||||
'content' => [
|
||||
$produces => [
|
||||
'schema' => [
|
||||
'oneOf' => \array_map(function($m) {
|
||||
return ['$ref' => '#/components/schemas/'.$m->getType()];
|
||||
'oneOf' => \array_map(function ($m) {
|
||||
return ['$ref' => '#/components/schemas/' . $m->getType()];
|
||||
}, $model)
|
||||
],
|
||||
],
|
||||
@@ -216,16 +215,15 @@ class OpenAPI3 extends Format
|
||||
'content' => [
|
||||
$produces => [
|
||||
'schema' => [
|
||||
'$ref' => '#/components/schemas/'.$model->getType(),
|
||||
'$ref' => '#/components/schemas/' . $model->getType(),
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($route->getLabel('sdk.response.code', 500) === 204) {
|
||||
if ($route->getLabel('sdk.response.code', 500) === 204) {
|
||||
$temp['responses'][(string)$route->getLabel('sdk.response.code', '500')]['description'] = 'No content';
|
||||
unset($temp['responses'][(string)$route->getLabel('sdk.response.code', '500')]['schema']);
|
||||
}
|
||||
@@ -233,8 +231,8 @@ class OpenAPI3 extends Format
|
||||
if ((!empty($scope))) { // && 'public' != $scope
|
||||
$securities = ['Project' => []];
|
||||
|
||||
foreach($route->getLabel('sdk.auth', []) as $security) {
|
||||
if(array_key_exists($security, $this->keys)) {
|
||||
foreach ($route->getLabel('sdk.auth', []) as $security) {
|
||||
if (array_key_exists($security, $this->keys)) {
|
||||
$securities[$security] = [];
|
||||
}
|
||||
}
|
||||
@@ -268,7 +266,7 @@ class OpenAPI3 extends Format
|
||||
switch ((!empty($validator)) ? \get_class($validator) : '') {
|
||||
case 'Utopia\Validator\Text':
|
||||
$node['schema']['type'] = $validator->getType();
|
||||
$node['schema']['x-example'] = '['.\strtoupper(Template::fromCamelCaseToSnake($node['name'])).']';
|
||||
$node['schema']['x-example'] = '[' . \strtoupper(Template::fromCamelCaseToSnake($node['name'])) . ']';
|
||||
break;
|
||||
case 'Utopia\Validator\Boolean':
|
||||
$node['schema']['type'] = $validator->getType();
|
||||
@@ -276,14 +274,14 @@ class OpenAPI3 extends Format
|
||||
break;
|
||||
case 'Utopia\Database\Validator\UID':
|
||||
$node['schema']['type'] = $validator->getType();
|
||||
$node['schema']['x-example'] = '['.\strtoupper(Template::fromCamelCaseToSnake($node['name'])).']';
|
||||
$node['schema']['x-example'] = '[' . \strtoupper(Template::fromCamelCaseToSnake($node['name'])) . ']';
|
||||
break;
|
||||
case 'Appwrite\Utopia\Database\Validator\CustomId':
|
||||
if($route->getLabel('sdk.methodType', '') === 'upload') {
|
||||
if ($route->getLabel('sdk.methodType', '') === 'upload') {
|
||||
$node['schema']['x-upload-id'] = true;
|
||||
}
|
||||
$node['schema']['type'] = $validator->getType();
|
||||
$node['schema']['x-example'] = '['.\strtoupper(Template::fromCamelCaseToSnake($node['name'])).']';
|
||||
$node['schema']['x-example'] = '[' . \strtoupper(Template::fromCamelCaseToSnake($node['name'])) . ']';
|
||||
break;
|
||||
case 'Appwrite\Network\Validator\Email':
|
||||
$node['schema']['type'] = $validator->getType();
|
||||
@@ -326,7 +324,7 @@ class OpenAPI3 extends Format
|
||||
$node['schema']['x-example'] = 'password';
|
||||
break;
|
||||
case 'Utopia\Validator\Range': /** @var \Utopia\Validator\Range $validator */
|
||||
$node['schema']['type'] = $validator->getType() === Validator::TYPE_FLOAT ? 'number': $validator->getType();
|
||||
$node['schema']['type'] = $validator->getType() === Validator::TYPE_FLOAT ? 'number' : $validator->getType();
|
||||
$node['schema']['format'] = $validator->getType() == Validator::TYPE_INTEGER ? 'int32' : 'float';
|
||||
$node['schema']['x-example'] = $validator->getMin();
|
||||
break;
|
||||
@@ -364,14 +362,14 @@ class OpenAPI3 extends Format
|
||||
$node['schema']['default'] = $param['default'];
|
||||
}
|
||||
|
||||
if (false !== \strpos($url, ':'.$name)) { // Param is in URL path
|
||||
if (false !== \strpos($url, ':' . $name)) { // Param is in URL path
|
||||
$node['in'] = 'path';
|
||||
$temp['parameters'][] = $node;
|
||||
} elseif ($route->getMethod() == 'GET') { // Param is in query
|
||||
$node['in'] = 'query';
|
||||
$temp['parameters'][] = $node;
|
||||
} else { // Param is in payload
|
||||
if(!$param['optional']) {
|
||||
if (!$param['optional']) {
|
||||
$bodyRequired[] = $name;
|
||||
}
|
||||
|
||||
@@ -381,27 +379,27 @@ class OpenAPI3 extends Format
|
||||
'x-example' => $node['schema']['x-example'] ?? null
|
||||
];
|
||||
|
||||
if($node['schema']['x-upload-id'] ?? false) {
|
||||
if ($node['schema']['x-upload-id'] ?? false) {
|
||||
$body['content'][$consumes[0]]['schema']['properties'][$name]['x-upload-id'] = $node['schema']['x-upload-id'];
|
||||
}
|
||||
|
||||
if(isset($node['default'])) {
|
||||
if (isset($node['default'])) {
|
||||
$body['content'][$consumes[0]]['schema']['properties'][$name]['default'] = $node['default'];
|
||||
}
|
||||
|
||||
if(\array_key_exists('items', $node['schema'])) {
|
||||
if (\array_key_exists('items', $node['schema'])) {
|
||||
$body['content'][$consumes[0]]['schema']['properties'][$name]['items'] = $node['schema']['items'];
|
||||
}
|
||||
}
|
||||
|
||||
$url = \str_replace(':'.$name, '{'.$name.'}', $url);
|
||||
$url = \str_replace(':' . $name, '{' . $name . '}', $url);
|
||||
}
|
||||
|
||||
if(!empty($bodyRequired)) {
|
||||
if (!empty($bodyRequired)) {
|
||||
$body['content'][$consumes[0]]['schema']['required'] = $bodyRequired;
|
||||
}
|
||||
|
||||
if(!empty($body['content'][$consumes[0]]['schema']['properties'])) {
|
||||
if (!empty($body['content'][$consumes[0]]['schema']['properties'])) {
|
||||
$temp['requestBody'] = $body;
|
||||
}
|
||||
|
||||
@@ -434,19 +432,19 @@ class OpenAPI3 extends Format
|
||||
'type' => 'object',
|
||||
];
|
||||
|
||||
if(!empty($rules)) {
|
||||
if (!empty($rules)) {
|
||||
$output['components']['schemas'][$model->getType()]['properties'] = [];
|
||||
}
|
||||
|
||||
if($model->isAny()) {
|
||||
if ($model->isAny()) {
|
||||
$output['components']['schemas'][$model->getType()]['additionalProperties'] = true;
|
||||
}
|
||||
|
||||
if(!empty($required)) {
|
||||
if (!empty($required)) {
|
||||
$output['components']['schemas'][$model->getType()]['required'] = $required;
|
||||
}
|
||||
|
||||
foreach($model->getRules() as $name => $rule) {
|
||||
foreach ($model->getRules() as $name => $rule) {
|
||||
$type = '';
|
||||
$format = null;
|
||||
$items = null;
|
||||
@@ -484,29 +482,29 @@ class OpenAPI3 extends Format
|
||||
$type = 'object';
|
||||
$rule['type'] = ($rule['type']) ? $rule['type'] : 'none';
|
||||
|
||||
if(\is_array($rule['type'])) {
|
||||
if($rule['array']) {
|
||||
if (\is_array($rule['type'])) {
|
||||
if ($rule['array']) {
|
||||
$items = [
|
||||
'anyOf' => \array_map(function($type) {
|
||||
return ['$ref' => '#/components/schemas/'.$type];
|
||||
'anyOf' => \array_map(function ($type) {
|
||||
return ['$ref' => '#/components/schemas/' . $type];
|
||||
}, $rule['type'])
|
||||
];
|
||||
} else {
|
||||
$items = [
|
||||
'oneOf' => \array_map(function($type) {
|
||||
return ['$ref' => '#/components/schemas/'.$type];
|
||||
'oneOf' => \array_map(function ($type) {
|
||||
return ['$ref' => '#/components/schemas/' . $type];
|
||||
}, $rule['type'])
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$items = [
|
||||
'$ref' => '#/components/schemas/'.$rule['type'],
|
||||
'$ref' => '#/components/schemas/' . $rule['type'],
|
||||
];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if($rule['array']) {
|
||||
if ($rule['array']) {
|
||||
$output['components']['schemas'][$model->getType()]['properties'][$name] = [
|
||||
'type' => 'array',
|
||||
'description' => $rule['description'] ?? '',
|
||||
@@ -516,10 +514,9 @@ class OpenAPI3 extends Format
|
||||
'x-example' => $rule['example'] ?? null,
|
||||
];
|
||||
|
||||
if($format) {
|
||||
if ($format) {
|
||||
$output['components']['schemas'][$model->getType()]['properties'][$name]['items']['format'] = $format;
|
||||
}
|
||||
|
||||
} else {
|
||||
$output['components']['schemas'][$model->getType()]['properties'][$name] = [
|
||||
'type' => $type,
|
||||
@@ -527,12 +524,11 @@ class OpenAPI3 extends Format
|
||||
'x-example' => $rule['example'] ?? null,
|
||||
];
|
||||
|
||||
if($format) {
|
||||
if ($format) {
|
||||
$output['components']['schemas'][$model->getType()]['properties'][$name]['format'] = $format;
|
||||
}
|
||||
|
||||
}
|
||||
if($items) {
|
||||
if ($items) {
|
||||
$output['components']['schemas'][$model->getType()]['properties'][$name]['items'] = $items;
|
||||
}
|
||||
if (!in_array($name, $required)) {
|
||||
|
||||
@@ -15,7 +15,7 @@ class Swagger2 extends Format
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Swagger 2';
|
||||
}
|
||||
@@ -98,7 +98,7 @@ class Swagger2 extends Format
|
||||
}
|
||||
|
||||
$id = $route->getLabel('sdk.method', \uniqid());
|
||||
$desc = (!empty($route->getLabel('sdk.description', ''))) ? \realpath(__DIR__.'/../../../../'.$route->getLabel('sdk.description', '')) : null;
|
||||
$desc = (!empty($route->getLabel('sdk.description', ''))) ? \realpath(__DIR__ . '/../../../../' . $route->getLabel('sdk.description', '')) : null;
|
||||
$produces = $route->getLabel('sdk.response.type', null);
|
||||
$model = $route->getLabel('sdk.response.model', 'none');
|
||||
$routeSecurity = $route->getLabel('sdk.auth', []);
|
||||
@@ -121,13 +121,13 @@ class Swagger2 extends Format
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($routeSecurity)) {
|
||||
if (empty($routeSecurity)) {
|
||||
$sdkPlatofrms[] = APP_PLATFORM_CLIENT;
|
||||
}
|
||||
|
||||
$temp = [
|
||||
'summary' => $route->getDesc(),
|
||||
'operationId' => $route->getLabel('sdk.namespace', 'default').ucfirst($id),
|
||||
'operationId' => $route->getLabel('sdk.namespace', 'default') . ucfirst($id),
|
||||
'consumes' => [],
|
||||
'produces' => [],
|
||||
'tags' => [$route->getLabel('sdk.namespace', 'default')],
|
||||
@@ -138,7 +138,7 @@ class Swagger2 extends Format
|
||||
'weight' => $route->getOrder(),
|
||||
'cookies' => $route->getLabel('sdk.cookies', false),
|
||||
'type' => $route->getLabel('sdk.methodType', ''),
|
||||
'demo' => Template::fromCamelCaseToDash($route->getLabel('sdk.namespace', 'default')).'/'.Template::fromCamelCaseToDash($id).'.md',
|
||||
'demo' => Template::fromCamelCaseToDash($route->getLabel('sdk.namespace', 'default')) . '/' . Template::fromCamelCaseToDash($id) . '.md',
|
||||
'edit' => 'https://github.com/appwrite/appwrite/edit/master' . $route->getLabel('sdk.description', ''),
|
||||
'rate-limit' => $route->getLabel('abuse-limit', 0),
|
||||
'rate-time' => $route->getLabel('abuse-time', 3600),
|
||||
@@ -149,27 +149,27 @@ class Swagger2 extends Format
|
||||
],
|
||||
];
|
||||
|
||||
if($produces) {
|
||||
if ($produces) {
|
||||
$temp['produces'][] = $produces;
|
||||
}
|
||||
|
||||
foreach ($this->models as $key => $value) {
|
||||
if(\is_array($model)) {
|
||||
$model = \array_map(function($m) use($value) {
|
||||
if($m === $value->getType()) {
|
||||
if (\is_array($model)) {
|
||||
$model = \array_map(function ($m) use ($value) {
|
||||
if ($m === $value->getType()) {
|
||||
return $value;
|
||||
}
|
||||
return $m;
|
||||
}, $model);
|
||||
} else {
|
||||
if($value->getType() === $model) {
|
||||
if ($value->getType() === $model) {
|
||||
$model = $value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!(\is_array($model)) && $model->isNone()) {
|
||||
if (!(\is_array($model)) && $model->isNone()) {
|
||||
$temp['responses'][(string)$route->getLabel('sdk.response.code', '500')] = [
|
||||
'description' => (in_array($produces, [
|
||||
'image/*',
|
||||
@@ -186,8 +186,7 @@ class Swagger2 extends Format
|
||||
],
|
||||
];
|
||||
} else {
|
||||
|
||||
if(\is_array($model)) {
|
||||
if (\is_array($model)) {
|
||||
$modelDescription = \join(', or ', \array_map(function ($m) {
|
||||
return $m->getName();
|
||||
}, $model));
|
||||
@@ -198,8 +197,8 @@ class Swagger2 extends Format
|
||||
$temp['responses'][(string)$route->getLabel('sdk.response.code', '500')] = [
|
||||
'description' => $modelDescription,
|
||||
'schema' => [
|
||||
'x-oneOf' => \array_map(function($m) {
|
||||
return ['$ref' => '#/definitions/'.$m->getType()];
|
||||
'x-oneOf' => \array_map(function ($m) {
|
||||
return ['$ref' => '#/definitions/' . $m->getType()];
|
||||
}, $model)
|
||||
],
|
||||
];
|
||||
@@ -209,13 +208,13 @@ class Swagger2 extends Format
|
||||
$temp['responses'][(string)$route->getLabel('sdk.response.code', '500')] = [
|
||||
'description' => $model->getName(),
|
||||
'schema' => [
|
||||
'$ref' => '#/definitions/'.$model->getType(),
|
||||
'$ref' => '#/definitions/' . $model->getType(),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if(in_array($route->getLabel('sdk.response.code', 500), [204, 301, 302, 308], true)) {
|
||||
if (in_array($route->getLabel('sdk.response.code', 500), [204, 301, 302, 308], true)) {
|
||||
$temp['responses'][(string)$route->getLabel('sdk.response.code', '500')]['description'] = 'No content';
|
||||
unset($temp['responses'][(string)$route->getLabel('sdk.response.code', '500')]['schema']);
|
||||
}
|
||||
@@ -223,8 +222,8 @@ class Swagger2 extends Format
|
||||
if ((!empty($scope))) { // && 'public' != $scope
|
||||
$securities = ['Project' => []];
|
||||
|
||||
foreach($route->getLabel('sdk.auth', []) as $security) {
|
||||
if(array_key_exists($security, $this->keys)) {
|
||||
foreach ($route->getLabel('sdk.auth', []) as $security) {
|
||||
if (array_key_exists($security, $this->keys)) {
|
||||
$securities[$security] = [];
|
||||
}
|
||||
}
|
||||
@@ -256,22 +255,22 @@ class Swagger2 extends Format
|
||||
switch ((!empty($validator)) ? \get_class($validator) : '') {
|
||||
case 'Utopia\Validator\Text':
|
||||
$node['type'] = $validator->getType();
|
||||
$node['x-example'] = '['.\strtoupper(Template::fromCamelCaseToSnake($node['name'])).']';
|
||||
$node['x-example'] = '[' . \strtoupper(Template::fromCamelCaseToSnake($node['name'])) . ']';
|
||||
break;
|
||||
case 'Utopia\Validator\Boolean':
|
||||
$node['type'] = $validator->getType();
|
||||
$node['x-example'] = false;
|
||||
break;
|
||||
case 'Appwrite\Utopia\Database\Validator\CustomId':
|
||||
if($route->getLabel('sdk.methodType', '') === 'upload') {
|
||||
if ($route->getLabel('sdk.methodType', '') === 'upload') {
|
||||
$node['x-upload-id'] = true;
|
||||
}
|
||||
$node['type'] = $validator->getType();
|
||||
$node['x-example'] = '['.\strtoupper(Template::fromCamelCaseToSnake($node['name'])).']';
|
||||
$node['x-example'] = '[' . \strtoupper(Template::fromCamelCaseToSnake($node['name'])) . ']';
|
||||
break;
|
||||
case 'Utopia\Database\Validator\UID':
|
||||
$node['type'] = $validator->getType();
|
||||
$node['x-example'] = '['.\strtoupper(Template::fromCamelCaseToSnake($node['name'])).']';
|
||||
$node['x-example'] = '[' . \strtoupper(Template::fromCamelCaseToSnake($node['name'])) . ']';
|
||||
break;
|
||||
case 'Appwrite\Network\Validator\Email':
|
||||
$node['type'] = $validator->getType();
|
||||
@@ -316,7 +315,7 @@ class Swagger2 extends Format
|
||||
$node['x-example'] = 'password';
|
||||
break;
|
||||
case 'Utopia\Validator\Range': /** @var \Utopia\Validator\Range $validator */
|
||||
$node['type'] = $validator->getType() === Validator::TYPE_FLOAT ? 'number': $validator->getType();
|
||||
$node['type'] = $validator->getType() === Validator::TYPE_FLOAT ? 'number' : $validator->getType();
|
||||
$node['format'] = $validator->getType() == Validator::TYPE_INTEGER ? 'int32' : 'float';
|
||||
$node['x-example'] = $validator->getMin();
|
||||
break;
|
||||
@@ -354,14 +353,13 @@ class Swagger2 extends Format
|
||||
$node['default'] = $param['default'];
|
||||
}
|
||||
|
||||
if (false !== \strpos($url, ':'.$name)) { // Param is in URL path
|
||||
if (false !== \strpos($url, ':' . $name)) { // Param is in URL path
|
||||
$node['in'] = 'path';
|
||||
$temp['parameters'][] = $node;
|
||||
} elseif ($route->getMethod() == 'GET') { // Param is in query
|
||||
$node['in'] = 'query';
|
||||
$temp['parameters'][] = $node;
|
||||
} else { // Param is in payload
|
||||
|
||||
if (\in_array('multipart/form-data', $consumes)) {
|
||||
$node['in'] = 'formData';
|
||||
$temp['parameters'][] = $node;
|
||||
@@ -380,19 +378,19 @@ class Swagger2 extends Format
|
||||
'x-example' => $node['x-example'] ?? null,
|
||||
];
|
||||
|
||||
if(\array_key_exists('items', $node)) {
|
||||
if (\array_key_exists('items', $node)) {
|
||||
$body['schema']['properties'][$name]['items'] = $node['items'];
|
||||
}
|
||||
}
|
||||
|
||||
$url = \str_replace(':'.$name, '{'.$name.'}', $url);
|
||||
$url = \str_replace(':' . $name, '{' . $name . '}', $url);
|
||||
}
|
||||
|
||||
if(!empty($bodyRequired)) {
|
||||
if (!empty($bodyRequired)) {
|
||||
$body['schema']['required'] = $bodyRequired;
|
||||
}
|
||||
|
||||
if(!empty($body['schema']['properties'])) {
|
||||
if (!empty($body['schema']['properties'])) {
|
||||
$temp['parameters'][] = $body;
|
||||
}
|
||||
|
||||
@@ -425,19 +423,19 @@ class Swagger2 extends Format
|
||||
'type' => 'object',
|
||||
];
|
||||
|
||||
if(!empty($rules)) {
|
||||
if (!empty($rules)) {
|
||||
$output['definitions'][$model->getType()]['properties'] = [];
|
||||
}
|
||||
|
||||
if($model->isAny()) {
|
||||
if ($model->isAny()) {
|
||||
$output['definitions'][$model->getType()]['additionalProperties'] = true;
|
||||
}
|
||||
|
||||
if(!empty($required)) {
|
||||
if (!empty($required)) {
|
||||
$output['definitions'][$model->getType()]['required'] = $required;
|
||||
}
|
||||
|
||||
foreach($model->getRules() as $name => $rule) {
|
||||
foreach ($model->getRules() as $name => $rule) {
|
||||
$type = '';
|
||||
$format = null;
|
||||
$items = null;
|
||||
@@ -474,24 +472,24 @@ class Swagger2 extends Format
|
||||
$type = 'object';
|
||||
$rule['type'] = ($rule['type']) ?: 'none';
|
||||
|
||||
if(\is_array($rule['type'])) {
|
||||
if($rule['array']) {
|
||||
if (\is_array($rule['type'])) {
|
||||
if ($rule['array']) {
|
||||
$items = [
|
||||
'x-anyOf' => \array_map(function($type) {
|
||||
return ['$ref' => '#/definitions/'.$type];
|
||||
'x-anyOf' => \array_map(function ($type) {
|
||||
return ['$ref' => '#/definitions/' . $type];
|
||||
}, $rule['type'])
|
||||
];
|
||||
} else {
|
||||
$items = [
|
||||
'x-oneOf' => \array_map(function($type) {
|
||||
return ['$ref' => '#/definitions/'.$type];
|
||||
'x-oneOf' => \array_map(function ($type) {
|
||||
return ['$ref' => '#/definitions/' . $type];
|
||||
}, $rule['type'])
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$items = [
|
||||
'type' => $type,
|
||||
'$ref' => '#/definitions/'.$rule['type'],
|
||||
'$ref' => '#/definitions/' . $rule['type'],
|
||||
];
|
||||
}
|
||||
break;
|
||||
@@ -507,7 +505,7 @@ class Swagger2 extends Format
|
||||
continue;
|
||||
}
|
||||
|
||||
if($rule['array']) {
|
||||
if ($rule['array']) {
|
||||
$output['definitions'][$model->getType()]['properties'][$name] = [
|
||||
'type' => 'array',
|
||||
'description' => $rule['description'] ?? '',
|
||||
@@ -517,10 +515,9 @@ class Swagger2 extends Format
|
||||
'x-example' => $rule['example'] ?? null,
|
||||
];
|
||||
|
||||
if($format) {
|
||||
if ($format) {
|
||||
$output['definitions'][$model->getType()]['properties'][$name]['items']['format'] = $format;
|
||||
}
|
||||
|
||||
} else {
|
||||
$output['definitions'][$model->getType()]['properties'][$name] = [
|
||||
'type' => $type,
|
||||
@@ -528,12 +525,11 @@ class Swagger2 extends Format
|
||||
'x-example' => $rule['example'] ?? null,
|
||||
];
|
||||
|
||||
if($format) {
|
||||
if ($format) {
|
||||
$output['definitions'][$model->getType()]['properties'][$name]['format'] = $format;
|
||||
}
|
||||
|
||||
}
|
||||
if($items) {
|
||||
if ($items) {
|
||||
$output['definitions'][$model->getType()]['properties'][$name]['items'] = $items;
|
||||
}
|
||||
if (!in_array($name, $required)) {
|
||||
|
||||
@@ -24,7 +24,7 @@ class Specification
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->format->getName();
|
||||
}
|
||||
@@ -40,4 +40,4 @@ class Specification
|
||||
{
|
||||
return $this->format->parse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ class Stats
|
||||
foreach ($sessionsMetrics as $metric) {
|
||||
$value = $this->params[$metric] ?? 0;
|
||||
if ($value >= 1) {
|
||||
$tags = ",projectId={$projectId},provider=". ($this->params['provider'] ?? '');
|
||||
$tags = ",projectId={$projectId},provider=" . ($this->params['provider'] ?? '');
|
||||
$this->statsd->count($metric . $tags, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class Template extends View
|
||||
} elseif (!empty($this->content)) {
|
||||
$template = $this->print($this->content, self::FILTER_NL2P);
|
||||
} else {
|
||||
throw new Exception('"'.$this->path.'" template is not readable or not found');
|
||||
throw new Exception('"' . $this->path . '" template is not readable or not found');
|
||||
}
|
||||
|
||||
// First replace the variables inside the params. Then replace the variables in the template
|
||||
@@ -109,20 +109,20 @@ class Template extends View
|
||||
*/
|
||||
public static function unParseURL(array $url)
|
||||
{
|
||||
$scheme = isset($url['scheme']) ? $url['scheme'].'://' : '';
|
||||
$scheme = isset($url['scheme']) ? $url['scheme'] . '://' : '';
|
||||
$host = isset($url['host']) ? $url['host'] : '';
|
||||
$port = isset($url['port']) ? ':'.$url['port'] : '';
|
||||
$port = isset($url['port']) ? ':' . $url['port'] : '';
|
||||
|
||||
$user = isset($url['user']) ? $url['user'] : '';
|
||||
$pass = isset($url['pass']) ? ':'.$url['pass'] : '';
|
||||
$pass = isset($url['pass']) ? ':' . $url['pass'] : '';
|
||||
$pass = ($user || $pass) ? "$pass@" : '';
|
||||
|
||||
$path = isset($url['path']) ? $url['path'] : '';
|
||||
$query = isset($url['query']) && !empty($url['query']) ? '?'.$url['query'] : '';
|
||||
$query = isset($url['query']) && !empty($url['query']) ? '?' . $url['query'] : '';
|
||||
|
||||
$fragment = isset($url['fragment']) ? '#'.$url['fragment'] : '';
|
||||
$fragment = isset($url['fragment']) ? '#' . $url['fragment'] : '';
|
||||
|
||||
return $scheme.$user.$pass.$host.$port.$path.$query.$fragment;
|
||||
return $scheme . $user . $pass . $host . $port . $path . $query . $fragment;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,28 +42,28 @@ class URL
|
||||
public static function unparse(array $url, array $ommit = []): string
|
||||
{
|
||||
if (isset($url['path']) && \mb_substr($url['path'], 0, 1) !== '/') {
|
||||
$url['path'] = '/'.$url['path'];
|
||||
$url['path'] = '/' . $url['path'];
|
||||
}
|
||||
|
||||
$parts = [];
|
||||
|
||||
$parts['scheme'] = isset($url['scheme']) ? $url['scheme'].'://' : '';
|
||||
$parts['scheme'] = isset($url['scheme']) ? $url['scheme'] . '://' : '';
|
||||
|
||||
$parts['host'] = isset($url['host']) ? $url['host'] : '';
|
||||
|
||||
$parts['port'] = isset($url['port']) ? ':'.$url['port'] : '';
|
||||
$parts['port'] = isset($url['port']) ? ':' . $url['port'] : '';
|
||||
|
||||
$parts['user'] = isset($url['user']) ? $url['user'] : '';
|
||||
|
||||
$parts['pass'] = isset($url['pass']) ? ':'.$url['pass'] : '';
|
||||
$parts['pass'] = isset($url['pass']) ? ':' . $url['pass'] : '';
|
||||
|
||||
$parts['pass'] = ($parts['user'] || $parts['pass']) ? $parts['pass'].'@' : '';
|
||||
$parts['pass'] = ($parts['user'] || $parts['pass']) ? $parts['pass'] . '@' : '';
|
||||
|
||||
$parts['path'] = isset($url['path']) ? $url['path'] : '';
|
||||
|
||||
$parts['query'] = isset($url['query']) && !empty($url['query']) ? '?'.$url['query'] : '';
|
||||
$parts['query'] = isset($url['query']) && !empty($url['query']) ? '?' . $url['query'] : '';
|
||||
|
||||
$parts['fragment'] = isset($url['fragment']) ? '#'.$url['fragment'] : '';
|
||||
$parts['fragment'] = isset($url['fragment']) ? '#' . $url['fragment'] : '';
|
||||
|
||||
if ($ommit) {
|
||||
foreach ($ommit as $key) {
|
||||
@@ -73,7 +73,7 @@ class URL
|
||||
}
|
||||
}
|
||||
|
||||
return $parts['scheme'].$parts['user'].$parts['pass'].$parts['host'].$parts['port'].$parts['path'].$parts['query'].$parts['fragment'];
|
||||
return $parts['scheme'] . $parts['user'] . $parts['pass'] . $parts['host'] . $parts['port'] . $parts['path'] . $parts['query'] . $parts['fragment'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Database\Validator;
|
||||
|
||||
use Utopia\Database\Validator\Key;
|
||||
|
||||
class CustomId extends Key {
|
||||
class CustomId extends Key
|
||||
{
|
||||
/**
|
||||
* Is valid.
|
||||
*
|
||||
@@ -18,4 +20,4 @@ class CustomId extends Key {
|
||||
|
||||
return $value == 'unique()' || parent::isValid($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Database\Validator;
|
||||
|
||||
use Utopia\Database\Document;
|
||||
@@ -14,12 +15,12 @@ class OrderAttributes extends ValidatorOrderAttributes
|
||||
* @param bool $strict
|
||||
*/
|
||||
public function __construct($attributes, $indexes, $strict)
|
||||
{
|
||||
{
|
||||
// Remove failed/stuck/processing indexes
|
||||
$indexes = \array_filter($indexes, function($index) {
|
||||
$indexes = \array_filter($indexes, function ($index) {
|
||||
return $index->getAttribute('status') === 'available';
|
||||
});
|
||||
|
||||
parent::__construct($attributes, $indexes, $strict);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Database\Validator;
|
||||
|
||||
use Utopia\Database\Document;
|
||||
@@ -16,10 +17,10 @@ class Queries extends ValidatorQueries
|
||||
public function __construct($attributes, $indexes, $strict)
|
||||
{
|
||||
// Remove failed/stuck/processing indexes
|
||||
$indexes = \array_filter($indexes, function($index) {
|
||||
$indexes = \array_filter($indexes, function ($index) {
|
||||
return $index->getAttribute('status') === 'available';
|
||||
});
|
||||
|
||||
parent::__construct($attributes, $indexes, $strict);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Appwrite\Utopia;
|
||||
|
||||
use Appwrite\Utopia\Request\Filter;
|
||||
@@ -39,7 +38,7 @@ class Request extends UtopiaRequest
|
||||
{
|
||||
$requestParameters = [];
|
||||
|
||||
switch($this->getMethod()) {
|
||||
switch ($this->getMethod()) {
|
||||
case self::METHOD_GET:
|
||||
$requestParameters = (!empty($this->swoole->get)) ? $this->swoole->get : [];
|
||||
break;
|
||||
@@ -125,4 +124,4 @@ class Request extends UtopiaRequest
|
||||
{
|
||||
return self::$route != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace Appwrite\Utopia\Request;
|
||||
|
||||
abstract class Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* Parse params to another format.
|
||||
*
|
||||
|
||||
@@ -93,9 +93,15 @@ class V12 extends Filter
|
||||
|
||||
protected function removeParentProperties(array $content): array
|
||||
{
|
||||
if (isset($content['parentDocument'])) unset($content['parentDocument']);
|
||||
if (isset($content['parentProperty'])) unset($content['parentProperty']);
|
||||
if (isset($content['parentPropertyType'])) unset($content['parentPropertyType']);
|
||||
if (isset($content['parentDocument'])) {
|
||||
unset($content['parentDocument']);
|
||||
}
|
||||
if (isset($content['parentProperty'])) {
|
||||
unset($content['parentProperty']);
|
||||
}
|
||||
if (isset($content['parentPropertyType'])) {
|
||||
unset($content['parentPropertyType']);
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
@@ -128,7 +134,7 @@ class V12 extends Filter
|
||||
{
|
||||
$queries = [];
|
||||
|
||||
if(!empty($content['filters'])) {
|
||||
if (!empty($content['filters'])) {
|
||||
foreach ($content['filters'] as $filter) {
|
||||
$operators = ['=' => 'equal', '!=' => 'notEqual', '>' => 'greater', '<' => 'lesser', '<=' => 'lesserEqual', '>=' => 'greaterEqual'];
|
||||
foreach ($operators as $operator => $operatorVerbose) {
|
||||
@@ -138,10 +144,10 @@ class V12 extends Filter
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($usedOperator)) {
|
||||
if (isset($usedOperator)) {
|
||||
[ $attributeKey, $filterValue ] = \explode($usedOperator, $filter);
|
||||
|
||||
if($filterValue === 'true' || $filterValue === 'false') {
|
||||
if ($filterValue === 'true' || $filterValue === 'false') {
|
||||
// Let's keep it at true and false string, but without "" around
|
||||
// No action needed
|
||||
} else {
|
||||
|
||||
@@ -92,7 +92,7 @@ class Response extends SwooleResponse
|
||||
const MODEL_USAGE_STORAGE = 'usageStorage';
|
||||
const MODEL_USAGE_FUNCTIONS = 'usageFunctions';
|
||||
const MODEL_USAGE_PROJECT = 'usageProject';
|
||||
|
||||
|
||||
// Database
|
||||
const MODEL_COLLECTION = 'collection';
|
||||
const MODEL_COLLECTION_LIST = 'collectionList';
|
||||
@@ -111,7 +111,7 @@ class Response extends SwooleResponse
|
||||
const MODEL_ATTRIBUTE_EMAIL = 'attributeEmail';
|
||||
const MODEL_ATTRIBUTE_ENUM = 'attributeEnum';
|
||||
const MODEL_ATTRIBUTE_IP = 'attributeIp';
|
||||
const MODEL_ATTRIBUTE_URL= 'attributeUrl';
|
||||
const MODEL_ATTRIBUTE_URL = 'attributeUrl';
|
||||
|
||||
// Users
|
||||
const MODEL_USER = 'user';
|
||||
@@ -121,7 +121,7 @@ class Response extends SwooleResponse
|
||||
const MODEL_TOKEN = 'token';
|
||||
const MODEL_JWT = 'jwt';
|
||||
const MODEL_PREFERENCES = 'preferences';
|
||||
|
||||
|
||||
// Storage
|
||||
const MODEL_FILE = 'file';
|
||||
const MODEL_FILE_LIST = 'fileList';
|
||||
@@ -159,7 +159,7 @@ class Response extends SwooleResponse
|
||||
const MODEL_BUILD = 'build';
|
||||
const MODEL_BUILD_LIST = 'buildList'; // Not used anywhere yet
|
||||
const MODEL_FUNC_PERMISSIONS = 'funcPermissions';
|
||||
|
||||
|
||||
// Project
|
||||
const MODEL_PROJECT = 'project';
|
||||
const MODEL_PROJECT_LIST = 'projectList';
|
||||
@@ -178,7 +178,7 @@ class Response extends SwooleResponse
|
||||
const MODEL_HEALTH_QUEUE = 'healthQueue';
|
||||
const MODEL_HEALTH_TIME = 'healthTime';
|
||||
const MODEL_HEALTH_ANTIVIRUS = 'healthAntivirus';
|
||||
|
||||
|
||||
// Deprecated
|
||||
const MODEL_PERMISSIONS = 'permissions';
|
||||
const MODEL_RULE = 'rule';
|
||||
@@ -329,7 +329,7 @@ class Response extends SwooleResponse
|
||||
public function getModel(string $key): Model
|
||||
{
|
||||
if (!isset($this->models[$key])) {
|
||||
throw new Exception('Undefined model: '.$key);
|
||||
throw new Exception('Undefined model: ' . $key);
|
||||
}
|
||||
|
||||
return $this->models[$key];
|
||||
@@ -392,13 +392,13 @@ class Response extends SwooleResponse
|
||||
if (!is_null($rule['default'])) {
|
||||
$document->setAttribute($key, $rule['default']);
|
||||
} else {
|
||||
throw new Exception('Model '.$model->getName().' is missing response key: '.$key);
|
||||
throw new Exception('Model ' . $model->getName() . ' is missing response key: ' . $key);
|
||||
}
|
||||
}
|
||||
|
||||
if ($rule['array']) {
|
||||
if (!is_array($data[$key])) {
|
||||
throw new Exception($key.' must be an array of type '.$rule['type']);
|
||||
throw new Exception($key . ' must be an array of type ' . $rule['type']);
|
||||
}
|
||||
|
||||
foreach ($data[$key] as &$item) {
|
||||
@@ -408,7 +408,7 @@ class Response extends SwooleResponse
|
||||
$condition = false;
|
||||
foreach ($this->getModel($type)->conditions as $attribute => $val) {
|
||||
$condition = $item->getAttribute($attribute) === $val;
|
||||
if(!$condition) {
|
||||
if (!$condition) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -422,7 +422,7 @@ class Response extends SwooleResponse
|
||||
}
|
||||
|
||||
if (!array_key_exists($ruleType, $this->models)) {
|
||||
throw new Exception('Missing model for rule: '. $ruleType);
|
||||
throw new Exception('Missing model for rule: ' . $ruleType);
|
||||
}
|
||||
|
||||
$item = $this->output($item, $ruleType);
|
||||
@@ -465,7 +465,7 @@ class Response extends SwooleResponse
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getPayload():array
|
||||
public function getPayload(): array
|
||||
{
|
||||
return $this->payload;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace Appwrite\Utopia\Response;
|
||||
|
||||
abstract class Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* Parse the content to another format.
|
||||
*
|
||||
|
||||
@@ -27,21 +27,21 @@ class V11 extends Filter
|
||||
case Response::MODEL_FILE_LIST:
|
||||
$parsedResponse = $this->parseFileList($content);
|
||||
break;
|
||||
|
||||
|
||||
case Response::MODEL_EXECUTION:
|
||||
$parsedResponse = $this->parseExecutionPermissions($content);
|
||||
break;
|
||||
case Response::MODEL_EXECUTION_LIST:
|
||||
$parsedResponse = $this->parseExecutionsList($content);
|
||||
break;
|
||||
|
||||
|
||||
case Response::MODEL_FUNCTION:
|
||||
$parsedResponse = $this->parseFunctionPermissions($content);
|
||||
break;
|
||||
case Response::MODEL_FUNCTION_LIST:
|
||||
$parsedResponse = $this->parseFunctionsList($content);
|
||||
break;
|
||||
|
||||
|
||||
// Convert status from boolean to int
|
||||
case Response::MODEL_USER:
|
||||
$parsedResponse = $this->parseStatus($content);
|
||||
@@ -49,7 +49,7 @@ class V11 extends Filter
|
||||
case Response::MODEL_USER_LIST:
|
||||
$parsedResponse = $this->parseUserList($content);
|
||||
break;
|
||||
|
||||
|
||||
// Convert all Health responses back to original
|
||||
case Response::MODEL_HEALTH_STATUS:
|
||||
$parsedResponse = $this->parseHealthStatus($content);
|
||||
@@ -93,7 +93,7 @@ class V11 extends Filter
|
||||
return $parsedResponse;
|
||||
}
|
||||
|
||||
protected function parseDocumentList(array $content)
|
||||
protected function parseDocumentList(array $content)
|
||||
{
|
||||
$documents = $content['documents'];
|
||||
$parsedResponse = [];
|
||||
@@ -104,7 +104,7 @@ class V11 extends Filter
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected function parseFileList(array $content)
|
||||
protected function parseFileList(array $content)
|
||||
{
|
||||
$files = $content['files'];
|
||||
$parsedResponse = [];
|
||||
@@ -115,7 +115,7 @@ class V11 extends Filter
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected function parseExecutionsList(array $content)
|
||||
protected function parseExecutionsList(array $content)
|
||||
{
|
||||
$executions = $content['executions'];
|
||||
$parsedResponse = [];
|
||||
@@ -126,7 +126,7 @@ class V11 extends Filter
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected function parseFunctionsList(array $content)
|
||||
protected function parseFunctionsList(array $content)
|
||||
{
|
||||
$functions = $content['functions'];
|
||||
$parsedResponse = [];
|
||||
@@ -137,7 +137,7 @@ class V11 extends Filter
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected function parseUserList(array $content)
|
||||
protected function parseUserList(array $content)
|
||||
{
|
||||
$users = $content['users'];
|
||||
$parsedResponse = [];
|
||||
@@ -148,7 +148,7 @@ class V11 extends Filter
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected function parseCollection(array $content)
|
||||
protected function parseCollection(array $content)
|
||||
{
|
||||
$parsedResponse = [];
|
||||
$parsedResponse = $this->parsePermissions($content);
|
||||
@@ -162,7 +162,7 @@ class V11 extends Filter
|
||||
return $parsedResponse;
|
||||
}
|
||||
|
||||
protected function parseCollectionList(array $content)
|
||||
protected function parseCollectionList(array $content)
|
||||
{
|
||||
$collections = $content['collections'];
|
||||
$parsedResponse = [];
|
||||
@@ -173,7 +173,7 @@ class V11 extends Filter
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected function parseLog(array $content)
|
||||
protected function parseLog(array $content)
|
||||
{
|
||||
$parsedResponse = [];
|
||||
$parsedResponse = $this->removeRule($content, 'userId');
|
||||
@@ -184,7 +184,7 @@ class V11 extends Filter
|
||||
return $parsedResponse;
|
||||
}
|
||||
|
||||
protected function parseLogList(array $content)
|
||||
protected function parseLogList(array $content)
|
||||
{
|
||||
$logs = $content['logs'];
|
||||
$parsedResponse = [];
|
||||
@@ -206,7 +206,7 @@ class V11 extends Filter
|
||||
return $parsedResponse;
|
||||
}
|
||||
|
||||
protected function parseProjectList(array $content)
|
||||
protected function parseProjectList(array $content)
|
||||
{
|
||||
$projects = $content['projects'];
|
||||
$parsedResponse = [];
|
||||
@@ -219,11 +219,11 @@ class V11 extends Filter
|
||||
|
||||
protected function parseHealthAntivirus(array $content)
|
||||
{
|
||||
if($content['status'] === 'pass') {
|
||||
if ($content['status'] === 'pass') {
|
||||
$content['status'] = 'online';
|
||||
}
|
||||
|
||||
if($content['status'] === 'fail') {
|
||||
if ($content['status'] === 'fail') {
|
||||
$content['status'] = 'offline';
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ class V11 extends Filter
|
||||
|
||||
protected function parseAttributes(array $content)
|
||||
{
|
||||
$content['rules'] = \array_map(function($attribute) use($content) {
|
||||
$content['rules'] = \array_map(function ($attribute) use ($content) {
|
||||
return [
|
||||
'$id' => $attribute['key'],
|
||||
'$collection' => $content['$id'],
|
||||
@@ -307,7 +307,7 @@ class V11 extends Filter
|
||||
|
||||
foreach ($content as $key => $value) {
|
||||
\preg_match_all($regexPattern, $key, $regexGroups);
|
||||
if(\count($regexGroups[1]) > 0 && \count($regexGroups[2]) > 0) {
|
||||
if (\count($regexGroups[1]) > 0 && \count($regexGroups[2]) > 0) {
|
||||
$providerName = $regexGroups[1][0];
|
||||
$valueKey = $regexGroups[2][0];
|
||||
$content['usersOauth2' . $providerName . $valueKey] = $value;
|
||||
@@ -324,7 +324,7 @@ class V11 extends Filter
|
||||
|
||||
foreach ($content as $key => $value) {
|
||||
\preg_match_all($regexPattern, $key, $regexGroups);
|
||||
if(\count($regexGroups[1]) > 0) {
|
||||
if (\count($regexGroups[1]) > 0) {
|
||||
$providerName = $regexGroups[1][0];
|
||||
|
||||
$content[$providerName] = $value;
|
||||
@@ -340,7 +340,7 @@ class V11 extends Filter
|
||||
// Such a key is part of new response, but is not part of old one. We simply remove it, older version never
|
||||
// expected it anyway.
|
||||
foreach ($content as $key => $value) {
|
||||
if(\str_starts_with($key, 'serviceStatusFor')) {
|
||||
if (\str_starts_with($key, 'serviceStatusFor')) {
|
||||
unset($content[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,14 +219,16 @@ class V12 extends Filter
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected function parseExecution($content) {
|
||||
protected function parseExecution($content)
|
||||
{
|
||||
$content['exitCode'] = $content['statusCode'];
|
||||
unset($content['statusCode']);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected function parseExecutionList($content) {
|
||||
protected function parseExecutionList($content)
|
||||
{
|
||||
$executions = $content['executions'];
|
||||
$parsedResponse = [];
|
||||
foreach ($executions as $document) {
|
||||
@@ -238,13 +240,15 @@ class V12 extends Filter
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected function parseTeam($content) {
|
||||
protected function parseTeam($content)
|
||||
{
|
||||
$content['sum'] = $content['total'];
|
||||
unset($content['total']);
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected function parseTeamList($content) {
|
||||
protected function parseTeamList($content)
|
||||
{
|
||||
$teams = $content['teams'];
|
||||
$parsedResponse = [];
|
||||
foreach ($teams as $document) {
|
||||
@@ -256,9 +260,10 @@ class V12 extends Filter
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected function parseList($content) {
|
||||
protected function parseList($content)
|
||||
{
|
||||
$content['sum'] = $content['total'];
|
||||
unset($content['total']);
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,14 +39,16 @@ class V13 extends Filter
|
||||
return $parsedResponse;
|
||||
}
|
||||
|
||||
protected function parseExecution($content) {
|
||||
protected function parseExecution($content)
|
||||
{
|
||||
$content['stdout'] = $content['response'];
|
||||
unset($content['response']);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected function parseExecutionList($content) {
|
||||
protected function parseExecutionList($content)
|
||||
{
|
||||
$executions = $content['executions'];
|
||||
$parsedResponse = [];
|
||||
foreach ($executions as $document) {
|
||||
@@ -56,14 +58,16 @@ class V13 extends Filter
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected function parseProject($content) {
|
||||
protected function parseProject($content)
|
||||
{
|
||||
$content['providers'] = $content['authProviders'];
|
||||
unset($content['authProviders']);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected function parseProjectList($content) {
|
||||
protected function parseProjectList($content)
|
||||
{
|
||||
$projects = $content['projects'];
|
||||
$parsedResponse = [];
|
||||
foreach ($projects as $document) {
|
||||
@@ -73,7 +77,8 @@ class V13 extends Filter
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected function parseMembership($content) {
|
||||
protected function parseMembership($content)
|
||||
{
|
||||
$content['name'] = $content['userName'];
|
||||
unset($content['userName']);
|
||||
|
||||
@@ -85,7 +90,8 @@ class V13 extends Filter
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected function parseMembershipList($content) {
|
||||
protected function parseMembershipList($content)
|
||||
{
|
||||
$memberships = $content['memberships'];
|
||||
$parsedResponse = [];
|
||||
foreach ($memberships as $document) {
|
||||
@@ -94,4 +100,4 @@ class V13 extends Filter
|
||||
$content['memberships'] = $parsedResponse;
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ abstract class Model
|
||||
|
||||
/**
|
||||
* Filter Document Structure
|
||||
*
|
||||
*
|
||||
* @return Document
|
||||
*/
|
||||
public function filter(Document $document): Document
|
||||
|
||||
@@ -17,7 +17,7 @@ class Any extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Any';
|
||||
}
|
||||
@@ -27,7 +27,7 @@ class Any extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_ANY;
|
||||
}
|
||||
|
||||
@@ -48,20 +48,20 @@ class Attribute extends Model
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Attribute';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Collection
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_ATTRIBUTE;
|
||||
}
|
||||
|
||||
@@ -41,21 +41,21 @@ class AttributeBoolean extends Attribute
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'AttributeBoolean';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Type
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_ATTRIBUTE_BOOLEAN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,21 +50,21 @@ class AttributeEmail extends Attribute
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'AttributeEmail';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Type
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_ATTRIBUTE_EMAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ class AttributeEnum extends Attribute
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'AttributeEnum';
|
||||
}
|
||||
@@ -71,8 +71,8 @@ class AttributeEnum extends Attribute
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_ATTRIBUTE_ENUM;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,21 +57,21 @@ class AttributeFloat extends Attribute
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'AttributeFloat';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Type
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_ATTRIBUTE_FLOAT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,21 +50,21 @@ class AttributeIP extends Attribute
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'AttributeIP';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Type
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_ATTRIBUTE_IP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,21 +56,21 @@ class AttributeInteger extends Attribute
|
||||
];
|
||||
|
||||
/**
|
||||
* Get Name *
|
||||
* Get Name *
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'AttributeInteger';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Type
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_ATTRIBUTE_INTEGER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class AttributeList extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Attributes List';
|
||||
}
|
||||
@@ -50,8 +50,8 @@ class AttributeList extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_ATTRIBUTE_LIST;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,20 +35,20 @@ class AttributeString extends Attribute
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'AttributeString';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Type
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_ATTRIBUTE_STRING;
|
||||
}
|
||||
|
||||
@@ -50,21 +50,21 @@ class AttributeURL extends Attribute
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'AttributeURL';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Type
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_ATTRIBUTE_URL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ class BaseList extends Model
|
||||
* @var string
|
||||
*/
|
||||
protected $name = '';
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@@ -53,7 +53,7 @@ class BaseList extends Model
|
||||
}
|
||||
$this->addRule($key, [
|
||||
'type' => $model,
|
||||
'description' => 'List of '.$key.'.',
|
||||
'description' => 'List of ' . $key . '.',
|
||||
'default' => [],
|
||||
'array' => true,
|
||||
]);
|
||||
@@ -64,7 +64,7 @@ class BaseList extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
@@ -74,7 +74,7 @@ class BaseList extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class Bucket extends Model
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
|
||||
@@ -61,14 +61,14 @@ class Collection extends Model
|
||||
],
|
||||
'description' => 'Collection attributes.',
|
||||
'default' => [],
|
||||
'example' => new \stdClass,
|
||||
'example' => new \stdClass(),
|
||||
'array' => true,
|
||||
])
|
||||
->addRule('indexes', [
|
||||
'type' => Response::MODEL_INDEX,
|
||||
'description' => 'Collection indexes.',
|
||||
'default' => [],
|
||||
'example' => new \stdClass,
|
||||
'example' => new \stdClass(),
|
||||
'array' => true
|
||||
])
|
||||
;
|
||||
@@ -79,7 +79,7 @@ class Collection extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Collection';
|
||||
}
|
||||
@@ -89,7 +89,7 @@ class Collection extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_COLLECTION;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class Continent extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Continent';
|
||||
}
|
||||
@@ -40,7 +40,7 @@ class Continent extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_CONTINENT;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class Country extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Country';
|
||||
}
|
||||
@@ -40,7 +40,7 @@ class Country extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_COUNTRY;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class Currency extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Currency';
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class Currency extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_CURRENCY;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class Deployment extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Deployment';
|
||||
}
|
||||
@@ -94,7 +94,7 @@ class Deployment extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_DEPLOYMENT;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ class Domain extends Model
|
||||
* @var bool
|
||||
*/
|
||||
protected $public = false;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
@@ -59,7 +59,7 @@ class Domain extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Domain';
|
||||
}
|
||||
@@ -69,7 +69,7 @@ class Domain extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_DOMAIN;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ class Error extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Error';
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class Error extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_ERROR;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class ErrorDev extends Error
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
$this
|
||||
->addRule('file', [
|
||||
'type' => self::TYPE_STRING,
|
||||
@@ -43,7 +43,7 @@ class ErrorDev extends Error
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_ERROR_DEV;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class Execution extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Execution';
|
||||
}
|
||||
@@ -89,7 +89,7 @@ class Execution extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_EXECUTION;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ class File extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'File';
|
||||
}
|
||||
@@ -96,7 +96,7 @@ class File extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_FILE;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ class Func extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Function';
|
||||
}
|
||||
@@ -116,27 +116,27 @@ class Func extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_FUNCTION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter Function
|
||||
*
|
||||
*
|
||||
* Automatically converts a [] default to a stdClass, this is called while grabbing the document.
|
||||
*
|
||||
*
|
||||
* @param Document $document
|
||||
* @return Document
|
||||
*/
|
||||
public function filter(Document $document): Document
|
||||
{
|
||||
$vars = $document->getAttribute('vars');
|
||||
if($vars instanceof Document) {
|
||||
if ($vars instanceof Document) {
|
||||
$vars = $vars->getArrayCopy();
|
||||
}
|
||||
|
||||
if(is_array($vars) && empty($vars)) {
|
||||
if (is_array($vars) && empty($vars)) {
|
||||
$document->setAttribute('vars', new stdClass());
|
||||
}
|
||||
return $document;
|
||||
|
||||
@@ -30,7 +30,7 @@ class HealthAntivirus extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Health Antivirus';
|
||||
}
|
||||
@@ -40,7 +40,7 @@ class HealthAntivirus extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_HEALTH_ANTIVIRUS;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class HealthQueue extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Health Queue';
|
||||
}
|
||||
@@ -34,7 +34,7 @@ class HealthQueue extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_HEALTH_QUEUE;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class HealthStatus extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Health Status';
|
||||
}
|
||||
@@ -40,7 +40,7 @@ class HealthStatus extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_HEALTH_STATUS;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class HealthTime extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Health Time';
|
||||
}
|
||||
@@ -46,7 +46,7 @@ class HealthTime extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_HEALTH_TIME;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class HealthVersion extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Health Version';
|
||||
}
|
||||
@@ -34,7 +34,7 @@ class HealthVersion extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_HEALTH_VERSION;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user