1
0
Fork 0
mirror of synced 2024-06-02 10:54:44 +12:00

Merge pull request #776 from appwrite/feat-upgrade-inject-signature

Feat upgrade inject signature
This commit is contained in:
Eldad A. Fux 2020-12-27 08:48:24 +02:00 committed by GitHub
commit 8ff16c3fb8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 668 additions and 267 deletions

View file

@ -44,6 +44,11 @@ App::post('/v1/account')
->param('email', '', new Email(), 'User email.')
->param('password', '', new Password(), 'User password. Must be between 6 to 32 chars.')
->param('name', '', new Text(128), 'User name. Max length: 128 chars.', true)
->inject('request')
->inject('response')
->inject('project')
->inject('projectDB')
->inject('audits')
->action(function ($email, $password, $name, $request, $response, $project, $projectDB, $audits) {
/** @var Utopia\Swoole\Request $request */
/** @var Appwrite\Utopia\Response $response */
@ -123,7 +128,7 @@ App::post('/v1/account')
->setStatusCode(Response::STATUS_CODE_CREATED)
->dynamic($user, Response::MODEL_USER)
;
}, ['request', 'response', 'project', 'projectDB', 'audits']);
});
App::post('/v1/account/sessions')
->desc('Create Account Session')
@ -141,6 +146,12 @@ App::post('/v1/account/sessions')
->label('abuse-key', 'url:{url},email:{param-email}')
->param('email', '', new Email(), 'User email.')
->param('password', '', new Password(), 'User password. Must be between 6 to 32 chars.')
->inject('request')
->inject('response')
->inject('projectDB')
->inject('locale')
->inject('geodb')
->inject('audits')
->action(function ($email, $password, $request, $response, $projectDB, $locale, $geodb, $audits) {
/** @var Utopia\Swoole\Request $request */
/** @var Appwrite\Utopia\Response $response */
@ -262,7 +273,7 @@ App::post('/v1/account/sessions')
;
$response->dynamic($session, Response::MODEL_SESSION);
}, ['request', 'response', 'projectDB', 'locale', 'geodb', 'audits']);
});
App::get('/v1/account/sessions/oauth2/:provider')
->desc('Create Account Session with OAuth2')
@ -282,6 +293,9 @@ App::get('/v1/account/sessions/oauth2/:provider')
->param('success', $oauthDefaultSuccess, function ($clients) { return new Host($clients); }, 'URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.', true, ['clients'])
->param('failure', $oauthDefaultFailure, function ($clients) { return new Host($clients); }, 'URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.', true, ['clients'])
->param('scopes', [], new ArrayList(new Text(128)), 'A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes.', true)
->inject('request')
->inject('response')
->inject('project')
->action(function ($provider, $success, $failure, $scopes, $request, $response, $project) {
/** @var Utopia\Swoole\Request $request */
/** @var Appwrite\Utopia\Response $response */
@ -313,7 +327,7 @@ App::get('/v1/account/sessions/oauth2/:provider')
->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0')
->addHeader('Pragma', 'no-cache')
->redirect($oauth2->getLoginURL());
}, ['request', 'response', 'project']);
});
App::get('/v1/account/sessions/oauth2/callback/:provider/:projectId')
->desc('OAuth2 Callback')
@ -325,6 +339,8 @@ App::get('/v1/account/sessions/oauth2/callback/:provider/:projectId')
->param('provider', '', new WhiteList(\array_keys(Config::getParam('providers')), true), 'OAuth2 provider.')
->param('code', '', new Text(1024), 'OAuth2 code.')
->param('state', '', new Text(2048), 'Login state params.', true)
->inject('request')
->inject('response')
->action(function ($projectId, $provider, $code, $state, $request, $response) {
/** @var Utopia\Swoole\Request $request */
/** @var Appwrite\Utopia\Response $response */
@ -337,7 +353,7 @@ App::get('/v1/account/sessions/oauth2/callback/:provider/:projectId')
->addHeader('Pragma', 'no-cache')
->redirect($protocol.'://'.$domain.'/v1/account/sessions/oauth2/'.$provider.'/redirect?'
.\http_build_query(['project' => $projectId, 'code' => $code, 'state' => $state]));
}, ['request', 'response']);
});
App::post('/v1/account/sessions/oauth2/callback/:provider/:projectId')
->desc('OAuth2 Callback')
@ -350,6 +366,8 @@ App::post('/v1/account/sessions/oauth2/callback/:provider/:projectId')
->param('provider', '', new WhiteList(\array_keys(Config::getParam('providers')), true), 'OAuth2 provider.')
->param('code', '', new Text(1024), 'OAuth2 code.')
->param('state', '', new Text(2048), 'Login state params.', true)
->inject('request')
->inject('response')
->action(function ($projectId, $provider, $code, $state, $request, $response) {
/** @var Utopia\Swoole\Request $request */
/** @var Appwrite\Utopia\Response $response */
@ -362,7 +380,7 @@ App::post('/v1/account/sessions/oauth2/callback/:provider/:projectId')
->addHeader('Pragma', 'no-cache')
->redirect($protocol.'://'.$domain.'/v1/account/sessions/oauth2/'.$provider.'/redirect?'
.\http_build_query(['project' => $projectId, 'code' => $code, 'state' => $state]));
}, ['request', 'response']);
});
App::get('/v1/account/sessions/oauth2/:provider/redirect')
->desc('OAuth2 Redirect')
@ -376,6 +394,13 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect')
->param('provider', '', new WhiteList(\array_keys(Config::getParam('providers')), true), 'OAuth2 provider.')
->param('code', '', new Text(1024), 'OAuth2 code.')
->param('state', '', new Text(2048), 'OAuth2 state params.', true)
->inject('request')
->inject('response')
->inject('project')
->inject('user')
->inject('projectDB')
->inject('geodb')
->inject('audits')
->action(function ($provider, $code, $state, $request, $response, $project, $user, $projectDB, $geodb, $audits) use ($oauthDefaultSuccess) {
/** @var Utopia\Swoole\Request $request */
/** @var Appwrite\Utopia\Response $response */
@ -602,7 +627,7 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect')
->addCookie(Auth::$cookieName, Auth::encodeSession($user->getId(), $secret), $expiry, '/', Config::getParam('cookieDomain'), ('https' == $protocol), true, Config::getParam('cookieSamesite'))
->redirect($state['success'])
;
}, ['request', 'response', 'project', 'user', 'projectDB', 'geodb', 'audits']);
});
App::get('/v1/account')
->desc('Get Account')
@ -615,12 +640,14 @@ App::get('/v1/account')
->label('sdk.response.code', Response::STATUS_CODE_OK)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_USER)
->inject('response')
->inject('user')
->action(function ($response, $user) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Document $user */
$response->dynamic($user, Response::MODEL_USER);
}, ['response', 'user']);
});
App::get('/v1/account/prefs')
->desc('Get Account Preferences')
@ -633,6 +660,8 @@ App::get('/v1/account/prefs')
->label('sdk.response.code', Response::STATUS_CODE_OK)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_ANY)
->inject('response')
->inject('user')
->action(function ($response, $user) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Document $user */
@ -640,7 +669,7 @@ App::get('/v1/account/prefs')
$prefs = $user->getAttribute('prefs', new \stdClass);
$response->dynamic(new Document($prefs), Response::MODEL_ANY);
}, ['response', 'user']);
});
App::get('/v1/account/sessions')
->desc('Get Account Sessions')
@ -653,6 +682,9 @@ App::get('/v1/account/sessions')
->label('sdk.response.code', Response::STATUS_CODE_OK)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_SESSION_LIST)
->inject('response')
->inject('user')
->inject('locale')
->action(function ($response, $user, $locale) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Document $user */
@ -680,7 +712,7 @@ App::get('/v1/account/sessions')
'sum' => count($sessions),
'sessions' => $sessions
]), Response::MODEL_SESSION_LIST);
}, ['response', 'user', 'locale']);
});
App::get('/v1/account/logs')
->desc('Get Account Logs')
@ -693,6 +725,12 @@ App::get('/v1/account/logs')
->label('sdk.response.code', Response::STATUS_CODE_OK)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_LOG_LIST)
->inject('response')
->inject('register')
->inject('project')
->inject('user')
->inject('locale')
->inject('geodb')
->action(function ($response, $register, $project, $user, $locale, $geodb) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Document $project */
@ -780,7 +818,7 @@ App::get('/v1/account/logs')
}
$response->dynamic(new Document(['logs' => $output]), Response::MODEL_LOG_LIST);
}, ['response', 'register', 'project', 'user', 'locale', 'geodb']);
});
App::patch('/v1/account/name')
->desc('Update Account Name')
@ -795,6 +833,10 @@ App::patch('/v1/account/name')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_USER)
->param('name', '', new Text(128), 'User name. Max length: 128 chars.')
->inject('response')
->inject('user')
->inject('projectDB')
->inject('audits')
->action(function ($name, $response, $user, $projectDB, $audits) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Document $user */
@ -816,7 +858,7 @@ App::patch('/v1/account/name')
;
$response->dynamic($user, Response::MODEL_USER);
}, ['response', 'user', 'projectDB', 'audits']);
});
App::patch('/v1/account/password')
->desc('Update Account Password')
@ -832,6 +874,10 @@ App::patch('/v1/account/password')
->label('sdk.response.model', Response::MODEL_USER)
->param('password', '', new Password(), 'New user password. Must be between 6 to 32 chars.')
->param('oldPassword', '', new Password(), 'Old user password. Must be between 6 to 32 chars.')
->inject('response')
->inject('user')
->inject('projectDB')
->inject('audits')
->action(function ($password, $oldPassword, $response, $user, $projectDB, $audits) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Document $user */
@ -857,7 +903,7 @@ App::patch('/v1/account/password')
;
$response->dynamic($user, Response::MODEL_USER);
}, ['response', 'user', 'projectDB', 'audits']);
});
App::patch('/v1/account/email')
->desc('Update Account Email')
@ -873,6 +919,10 @@ App::patch('/v1/account/email')
->label('sdk.response.model', Response::MODEL_USER)
->param('email', '', new Email(), 'User email.')
->param('password', '', new Password(), 'User password. Must be between 6 to 32 chars.')
->inject('response')
->inject('user')
->inject('projectDB')
->inject('audits')
->action(function ($email, $password, $response, $user, $projectDB, $audits) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Document $user */
@ -913,7 +963,7 @@ App::patch('/v1/account/email')
;
$response->dynamic($user, Response::MODEL_USER);
}, ['response', 'user', 'projectDB', 'audits']);
});
App::patch('/v1/account/prefs')
->desc('Update Account Preferences')
@ -928,6 +978,10 @@ App::patch('/v1/account/prefs')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_ANY)
->param('prefs', [], new Assoc(), 'Prefs key-value JSON object.')
->inject('response')
->inject('user')
->inject('projectDB')
->inject('audits')
->action(function ($prefs, $response, $user, $projectDB, $audits) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Document $user */
@ -948,7 +1002,7 @@ App::patch('/v1/account/prefs')
;
$response->dynamic($user, Response::MODEL_USER);
}, ['response', 'user', 'projectDB', 'audits']);
});
App::delete('/v1/account')
->desc('Delete Account')
@ -962,6 +1016,12 @@ App::delete('/v1/account')
->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_NONE)
->inject('request')
->inject('response')
->inject('user')
->inject('projectDB')
->inject('audits')
->inject('events')
->action(function ($request, $response, $user, $projectDB, $audits, $events) {
/** @var Utopia\Swoole\Request $request */
/** @var Appwrite\Utopia\Response $response */
@ -1009,7 +1069,7 @@ App::delete('/v1/account')
->addCookie(Auth::$cookieName, '', \time() - 3600, '/', Config::getParam('cookieDomain'), ('https' == $protocol), true, Config::getParam('cookieSamesite'))
->noContent()
;
}, ['request', 'response', 'user', 'projectDB', 'audits', 'events']);
});
App::delete('/v1/account/sessions/:sessionId')
->desc('Delete Account Session')
@ -1025,6 +1085,12 @@ App::delete('/v1/account/sessions/:sessionId')
->label('sdk.response.model', Response::MODEL_NONE)
->label('abuse-limit', 100)
->param('sessionId', null, new UID(), 'Session unique ID. Use the string \'current\' to delete the current device session.')
->inject('request')
->inject('response')
->inject('user')
->inject('projectDB')
->inject('audits')
->inject('events')
->action(function ($sessionId, $request, $response, $user, $projectDB, $audits, $events) {
/** @var Utopia\Swoole\Request $request */
/** @var Appwrite\Utopia\Response $response */
@ -1078,7 +1144,7 @@ App::delete('/v1/account/sessions/:sessionId')
}
throw new Exception('Session not found', 404);
}, ['request', 'response', 'user', 'projectDB', 'audits', 'events']);
});
App::delete('/v1/account/sessions')
->desc('Delete All Account Sessions')
@ -1093,6 +1159,12 @@ App::delete('/v1/account/sessions')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_NONE)
->label('abuse-limit', 100)
->inject('request')
->inject('response')
->inject('user')
->inject('projectDB')
->inject('audits')
->inject('events')
->action(function ($request, $response, $user, $projectDB, $audits, $events) {
/** @var Utopia\Swoole\Request $request */
/** @var Appwrite\Utopia\Response $response */
@ -1140,7 +1212,7 @@ App::delete('/v1/account/sessions')
;
$response->noContent();
}, ['request', 'response', 'user', 'projectDB', 'audits', 'events']);
});
App::post('/v1/account/recovery')
->desc('Create Password Recovery')
@ -1158,6 +1230,14 @@ App::post('/v1/account/recovery')
->label('abuse-key', 'url:{url},email:{param-email}')
->param('email', '', new Email(), 'User email.')
->param('url', '', function ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the recovery email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.', false, ['clients'])
->inject('request')
->inject('response')
->inject('projectDB')
->inject('project')
->inject('locale')
->inject('mails')
->inject('audits')
->inject('events')
->action(function ($email, $url, $request, $response, $projectDB, $project, $locale, $mails, $audits, $events) {
/** @var Utopia\Swoole\Request $request */
/** @var Appwrite\Utopia\Response $response */
@ -1266,7 +1346,7 @@ App::post('/v1/account/recovery')
->setStatusCode(Response::STATUS_CODE_CREATED)
->dynamic($recovery, Response::MODEL_TOKEN)
;
}, ['request', 'response', 'projectDB', 'project', 'locale', 'mails', 'audits', 'events']);
});
App::put('/v1/account/recovery')
->desc('Complete Password Recovery')
@ -1286,6 +1366,9 @@ App::put('/v1/account/recovery')
->param('secret', '', new Text(256), 'Valid reset token.')
->param('password', '', new Password(), 'New password. Must be between 6 to 32 chars.')
->param('passwordAgain', '', new Password(), 'New password again. Must be between 6 to 32 chars.')
->inject('response')
->inject('projectDB')
->inject('audits')
->action(function ($userId, $secret, $password, $passwordAgain, $response, $projectDB, $audits) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -1342,7 +1425,7 @@ App::put('/v1/account/recovery')
$recovery = $profile->search('$id', $recovery, $profile->getAttribute('tokens', []));
$response->dynamic($recovery, Response::MODEL_TOKEN);
}, ['response', 'projectDB', 'audits']);
});
App::post('/v1/account/verification')
->desc('Create Email Verification')
@ -1359,6 +1442,15 @@ App::post('/v1/account/verification')
->label('abuse-limit', 10)
->label('abuse-key', 'url:{url},email:{param-email}')
->param('url', '', function ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.', false, ['clients']) // TODO add built-in confirm page
->inject('request')
->inject('response')
->inject('project')
->inject('user')
->inject('projectDB')
->inject('locale')
->inject('audits')
->inject('events')
->inject('mails')
->action(function ($url, $request, $response, $project, $user, $projectDB, $locale, $audits, $events, $mails) {
/** @var Utopia\Swoole\Request $request */
/** @var Appwrite\Utopia\Response $response */
@ -1457,7 +1549,7 @@ App::post('/v1/account/verification')
->setStatusCode(Response::STATUS_CODE_CREATED)
->dynamic($verification, Response::MODEL_TOKEN)
;
}, ['request', 'response', 'project', 'user', 'projectDB', 'locale', 'audits', 'events', 'mails']);
});
App::put('/v1/account/verification')
->desc('Complete Email Verification')
@ -1475,6 +1567,10 @@ App::put('/v1/account/verification')
->label('abuse-key', 'url:{url},userId:{param-userId}')
->param('userId', '', new UID(), 'User unique ID.')
->param('secret', '', new Text(256), 'Valid verification token.')
->inject('response')
->inject('user')
->inject('projectDB')
->inject('audits')
->action(function ($userId, $secret, $response, $user, $projectDB, $audits) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Document $user */
@ -1526,4 +1622,4 @@ App::put('/v1/account/verification')
$verification = $profile->search('$id', $verification, $profile->getAttribute('tokens', []));
$response->dynamic($verification, Response::MODEL_TOKEN);
}, ['response', 'user', 'projectDB', 'audits']);
});

View file

@ -95,9 +95,10 @@ App::get('/v1/avatars/credit-cards/:code')
->param('width', 100, new Range(0, 2000), 'Image width. Pass an integer between 0 to 2000. Defaults to 100.', true)
->param('height', 100, new Range(0, 2000), 'Image height. Pass an integer between 0 to 2000. Defaults to 100.', true)
->param('quality', 100, new Range(0, 100), 'Image quality. Pass an integer between 0 to 100. Defaults to 100.', true)
->inject('response')
->action(function ($code, $width, $height, $quality, $response) use ($avatarCallback) {
return $avatarCallback('credit-cards', $code, $width, $height, $quality, $response);
}, ['response']);
});
App::get('/v1/avatars/browsers/:code')
->desc('Get Browser Icon')
@ -114,9 +115,10 @@ App::get('/v1/avatars/browsers/:code')
->param('width', 100, new Range(0, 2000), 'Image width. Pass an integer between 0 to 2000. Defaults to 100.', true)
->param('height', 100, new Range(0, 2000), 'Image height. Pass an integer between 0 to 2000. Defaults to 100.', true)
->param('quality', 100, new Range(0, 100), 'Image quality. Pass an integer between 0 to 100. Defaults to 100.', true)
->inject('response')
->action(function ($code, $width, $height, $quality, $response) use ($avatarCallback) {
return $avatarCallback('browsers', $code, $width, $height, $quality, $response);
}, ['response']);
});
App::get('/v1/avatars/flags/:code')
->desc('Get Country Flag')
@ -133,9 +135,10 @@ App::get('/v1/avatars/flags/:code')
->param('width', 100, new Range(0, 2000), 'Image width. Pass an integer between 0 to 2000. Defaults to 100.', true)
->param('height', 100, new Range(0, 2000), 'Image height. Pass an integer between 0 to 2000. Defaults to 100.', true)
->param('quality', 100, new Range(0, 100), 'Image quality. Pass an integer between 0 to 100. Defaults to 100.', true)
->inject('response')
->action(function ($code, $width, $height, $quality, $response) use ($avatarCallback) {
return $avatarCallback('flags', $code, $width, $height, $quality, $response);
}, ['response']);
});
App::get('/v1/avatars/image')
->desc('Get Image from URL')
@ -151,6 +154,7 @@ App::get('/v1/avatars/image')
->param('url', '', new URL(), 'Image URL which you want to crop.')
->param('width', 400, new Range(0, 2000), 'Resize preview image width, Pass an integer between 0 to 2000.', true)
->param('height', 400, new Range(0, 2000), 'Resize preview image height, Pass an integer between 0 to 2000.', true)
->inject('response')
->action(function ($url, $width, $height, $response) {
/** @var Appwrite\Utopia\Response $response */
@ -203,7 +207,7 @@ App::get('/v1/avatars/image')
;
unset($resize);
}, ['response']);
});
App::get('/v1/avatars/favicon')
->desc('Get Favicon')
@ -217,6 +221,7 @@ App::get('/v1/avatars/favicon')
->label('sdk.response.code', Response::STATUS_CODE_OK)
->label('sdk.response.type', Response::CONTENT_TYPE_IMAGE)
->param('url', '', new URL(), 'Website URL which you want to fetch the favicon from.')
->inject('response')
->action(function ($url, $response) {
/** @var Appwrite\Utopia\Response $response */
@ -355,7 +360,7 @@ App::get('/v1/avatars/favicon')
->send($data);
unset($resize);
}, ['response']);
});
App::get('/v1/avatars/qr')
->desc('Get QR Code')
@ -372,6 +377,7 @@ App::get('/v1/avatars/qr')
->param('size', 400, new Range(0, 1000), 'QR code size. Pass an integer between 0 to 1000. Defaults to 400.', true)
->param('margin', 1, new Range(0, 10), 'Margin from edge. Pass an integer between 0 to 10. Defaults to 1.', true)
->param('download', false, new Boolean(true), 'Return resulting image with \'Content-Disposition: attachment \' headers for the browser to start downloading it. Pass 0 for no header, or 1 for otherwise. Default value is set to 0.', true)
->inject('response')
->action(function ($text, $size, $margin, $download, $response) {
/** @var Appwrite\Utopia\Response $response */
@ -392,7 +398,7 @@ App::get('/v1/avatars/qr')
->setContentType('image/png')
->send($qrcode->render($text))
;
}, ['response']);
});
App::get('/v1/avatars/initials')
->desc('Get User Initials')
@ -410,6 +416,8 @@ App::get('/v1/avatars/initials')
->param('height', 500, new Range(0, 2000), 'Image height. Pass an integer between 0 to 2000. Defaults to 100.', true)
->param('color', '', new HexColor(), 'Changes text color. By default a random color will be picked and stay will persistent to the given name.', true)
->param('background', '', new HexColor(), 'Changes background color. By default a random color will be picked and stay will persistent to the given name.', true)
->inject('response')
->inject('user')
->action(function ($name, $width, $height, $color, $background, $response, $user) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Document $user */
@ -472,4 +480,4 @@ App::get('/v1/avatars/initials')
->setContentType('image/png')
->send($image->getImageBlob())
;
}, ['response', 'user']);
});

View file

@ -34,6 +34,9 @@ App::post('/v1/database/collections')
->param('read', [], new ArrayList(new Text(64)), 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.')
->param('write', [], new ArrayList(new Text(64)), 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.')
->param('rules', [], function ($projectDB) { return new ArrayList(new Collection($projectDB, [Database::SYSTEM_COLLECTION_RULES], ['$collection' => Database::SYSTEM_COLLECTION_RULES, '$permissions' => ['read' => [], 'write' => []]])); }, 'Array of [rule objects](/docs/rules). Each rule define a collection field name, data type and validation.', false, ['projectDB'])
->inject('response')
->inject('projectDB')
->inject('audits')
->action(function ($name, $read, $write, $rules, $response, $projectDB, $audits) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -86,7 +89,7 @@ App::post('/v1/database/collections')
->setStatusCode(Response::STATUS_CODE_CREATED)
->dynamic($data, Response::MODEL_COLLECTION)
;
}, ['response', 'projectDB', 'audits']);
});
App::get('/v1/database/collections')
->desc('List Collections')
@ -103,6 +106,8 @@ App::get('/v1/database/collections')
->param('limit', 25, new Range(0, 100), 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true)
->param('offset', 0, new Range(0, 40000), 'Results offset. The default value is 0. Use this param to manage pagination.', true)
->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true)
->inject('response')
->inject('projectDB')
->action(function ($search, $limit, $offset, $orderType, $response, $projectDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -120,7 +125,7 @@ App::get('/v1/database/collections')
'sum' => $projectDB->getSum(),
'collections' => $results
]), Response::MODEL_COLLECTION_LIST);
}, ['response', 'projectDB']);
});
App::get('/v1/database/collections/:collectionId')
->desc('Get Collection')
@ -134,6 +139,8 @@ App::get('/v1/database/collections/:collectionId')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_COLLECTION)
->param('collectionId', '', new UID(), 'Collection unique ID.')
->inject('response')
->inject('projectDB')
->action(function ($collectionId, $response, $projectDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -145,7 +152,7 @@ App::get('/v1/database/collections/:collectionId')
}
$response->dynamic($collection, Response::MODEL_COLLECTION);
}, ['response', 'projectDB']);
});
App::put('/v1/database/collections/:collectionId')
->desc('Update Collection')
@ -164,6 +171,9 @@ App::put('/v1/database/collections/:collectionId')
->param('read', [], new ArrayList(new Text(64)), 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions(/docs/permissions) and get a full list of available permissions.')
->param('write', [], new ArrayList(new Text(64)), 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.')
->param('rules', [], function ($projectDB) { return new ArrayList(new Collection($projectDB, [Database::SYSTEM_COLLECTION_RULES], ['$collection' => Database::SYSTEM_COLLECTION_RULES, '$permissions' => ['read' => [], 'write' => []]])); }, 'Array of [rule objects](/docs/rules). Each rule define a collection field name, data type and validation.', true, ['projectDB'])
->inject('response')
->inject('projectDB')
->inject('audits')
->action(function ($collectionId, $name, $read, $write, $rules, $response, $projectDB, $audits) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -217,7 +227,7 @@ App::put('/v1/database/collections/:collectionId')
;
$response->dynamic($collection, Response::MODEL_COLLECTION);
}, ['response', 'projectDB', 'audits']);
});
App::delete('/v1/database/collections/:collectionId')
->desc('Delete Collection')
@ -232,6 +242,11 @@ App::delete('/v1/database/collections/:collectionId')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_NONE)
->param('collectionId', '', new UID(), 'Collection unique ID.')
->inject('response')
->inject('projectDB')
->inject('events')
->inject('audits')
->inject('deletes')
->action(function ($collectionId, $response, $projectDB, $events, $audits, $deletes) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -263,7 +278,7 @@ App::delete('/v1/database/collections/:collectionId')
;
$response->noContent();
}, ['response', 'projectDB', 'events', 'audits', 'deletes']);
});
App::post('/v1/database/collections/:collectionId/documents')
->desc('Create Document')
@ -284,6 +299,9 @@ App::post('/v1/database/collections/:collectionId/documents')
->param('parentDocument', '', new UID(), 'Parent document unique ID. Use when you want your new document to be a child of a parent document.', true)
->param('parentProperty', '', new Key(), 'Parent document property name. Use when you want your new document to be a child of a parent document.', true)
->param('parentPropertyType', Document::SET_TYPE_ASSIGN, new WhiteList([Document::SET_TYPE_ASSIGN, Document::SET_TYPE_APPEND, Document::SET_TYPE_PREPEND], true), 'Parent document property connection type. You can set this value to **assign**, **append** or **prepend**, default value is assign. Use when you want your new document to be a child of a parent document.', true)
->inject('response')
->inject('projectDB')
->inject('audits')
->action(function ($collectionId, $data, $read, $write, $parentDocument, $parentProperty, $parentPropertyType, $response, $projectDB, $audits) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -380,7 +398,7 @@ App::post('/v1/database/collections/:collectionId/documents')
->setStatusCode(Response::STATUS_CODE_CREATED)
->dynamic($data, Response::MODEL_ANY)
;
}, ['response', 'projectDB', 'audits']);
});
App::get('/v1/database/collections/:collectionId/documents')
->desc('List Documents')
@ -401,6 +419,8 @@ App::get('/v1/database/collections/:collectionId/documents')
->param('orderType', 'ASC', new WhiteList(['DESC', 'ASC'], true), 'Order direction. Possible values are DESC for descending order, or ASC for ascending order.', true)
->param('orderCast', 'string', new WhiteList(['int', 'string', 'date', 'time', 'datetime'], true), 'Order field type casting. Possible values are int, string, date, time or datetime. The database will attempt to cast the order field to the value you pass here. The default value is a string.', true)
->param('search', '', new Text(256), 'Search query. Enter any free text search. The database will try to find a match against all document attributes and children. Max length: 256 chars.', true)
->inject('response')
->inject('projectDB')
->action(function ($collectionId, $filters, $limit, $offset, $orderField, $orderType, $orderCast, $search, $response, $projectDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -441,7 +461,7 @@ App::get('/v1/database/collections/:collectionId/documents')
;
$response->dynamic($collection, Response::MODEL_DOCUMENT_LIST);
}, ['response', 'projectDB']);
});
App::get('/v1/database/collections/:collectionId/documents/:documentId')
->desc('Get Document')
@ -456,8 +476,9 @@ App::get('/v1/database/collections/:collectionId/documents/:documentId')
->label('sdk.response.model', Response::MODEL_ANY)
->param('collectionId', null, new UID(), 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection).')
->param('documentId', null, new UID(), 'Document unique ID.')
->action(function ($collectionId, $documentId, $request, $response, $projectDB) {
/** @var Utopia\Swoole\Request $request */
->inject('response')
->inject('projectDB')
->action(function ($collectionId, $documentId, $response, $projectDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -469,7 +490,7 @@ App::get('/v1/database/collections/:collectionId/documents/:documentId')
}
$response->dynamic($document, Response::MODEL_ANY);
}, ['request', 'response', 'projectDB']);
});
App::patch('/v1/database/collections/:collectionId/documents/:documentId')
->desc('Update Document')
@ -488,6 +509,9 @@ App::patch('/v1/database/collections/:collectionId/documents/:documentId')
->param('data', [], new JSON(), 'Document data as JSON object.')
->param('read', [], new ArrayList(new Text(64)), 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.')
->param('write', [], new ArrayList(new Text(64)), 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.')
->inject('response')
->inject('projectDB')
->inject('audits')
->action(function ($collectionId, $documentId, $data, $read, $write, $response, $projectDB, $audits) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -546,7 +570,7 @@ App::patch('/v1/database/collections/:collectionId/documents/:documentId')
;
$response->dynamic($data, Response::MODEL_ANY);
}, ['response', 'projectDB', 'audits']);
});
App::delete('/v1/database/collections/:collectionId/documents/:documentId')
->desc('Delete Document')
@ -562,6 +586,10 @@ App::delete('/v1/database/collections/:collectionId/documents/:documentId')
->label('sdk.response.model', Response::MODEL_NONE)
->param('collectionId', null, new UID(), 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection).')
->param('documentId', null, new UID(), 'Document unique ID.')
->inject('response')
->inject('projectDB')
->inject('events')
->inject('audits')
->action(function ($collectionId, $documentId, $response, $projectDB, $events, $audits) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -600,4 +628,4 @@ App::delete('/v1/database/collections/:collectionId/documents/:documentId')
;
$response->noContent();
}, ['response', 'projectDB', 'events', 'audits']);
});

View file

@ -38,6 +38,8 @@ App::post('/v1/functions')
->param('events', [], new ArrayList(new WhiteList(array_keys(Config::getParam('events')), true)), 'Events list.', true)
->param('schedule', '', new Cron(), 'Schedule CRON syntax.', true)
->param('timeout', 15, new Range(1, 900), 'Function maximum execution time in seconds.', true)
->inject('response')
->inject('projectDB')
->action(function ($name, $env, $vars, $events, $schedule, $timeout, $response, $projectDB) {
$function = $projectDB->createDocument([
'$collection' => Database::SYSTEM_COLLECTION_FUNCTIONS,
@ -67,7 +69,7 @@ App::post('/v1/functions')
->setStatusCode(Response::STATUS_CODE_CREATED)
->dynamic($function, Response::MODEL_FUNCTION)
;
}, ['response', 'projectDB']);
});
App::get('/v1/functions')
->groups(['api', 'functions'])
@ -84,6 +86,8 @@ App::get('/v1/functions')
->param('limit', 25, new Range(0, 100), 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true)
->param('offset', 0, new Range(0, 2000), 'Results offset. The default value is 0. Use this param to manage pagination.', true)
->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true)
->inject('response')
->inject('projectDB')
->action(function ($search, $limit, $offset, $orderType, $response, $projectDB) {
$results = $projectDB->getCollection([
'limit' => $limit,
@ -98,7 +102,7 @@ App::get('/v1/functions')
'sum' => $projectDB->getSum(),
'functions' => $results
]), Response::MODEL_FUNCTION_LIST);
}, ['response', 'projectDB']);
});
App::get('/v1/functions/:functionId')
->groups(['api', 'functions'])
@ -112,6 +116,8 @@ App::get('/v1/functions/:functionId')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_FUNCTION)
->param('functionId', '', new UID(), 'Function unique ID.')
->inject('response')
->inject('projectDB')
->action(function ($functionId, $response, $projectDB) {
$function = $projectDB->getDocument($functionId);
@ -120,7 +126,7 @@ App::get('/v1/functions/:functionId')
}
$response->dynamic($function, Response::MODEL_FUNCTION);
}, ['response', 'projectDB']);
});
App::get('/v1/functions/:functionId/usage')
->desc('Get Function Usage')
@ -131,6 +137,10 @@ App::get('/v1/functions/:functionId/usage')
->label('sdk.method', 'getUsage')
->param('functionId', '', new UID(), 'Function unique ID.')
->param('range', '30d', new WhiteList(['24h', '7d', '30d', '90d']), 'Date range.', true)
->inject('response')
->inject('project')
->inject('projectDB')
->inject('register')
->action(function ($functionId, $range, $response, $project, $projectDB, $register) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Document $project */
@ -233,7 +243,7 @@ App::get('/v1/functions/:functionId/usage')
}, $compute)),
],
]);
}, ['response', 'project', 'projectDB', 'register']);
});
App::put('/v1/functions/:functionId')
->groups(['api', 'functions'])
@ -252,6 +262,8 @@ App::put('/v1/functions/:functionId')
->param('events', [], new ArrayList(new WhiteList(array_keys(Config::getParam('events')), true)), 'Events list.', true)
->param('schedule', '', new Cron(), 'Schedule CRON syntax.', true)
->param('timeout', 15, new Range(1, 900), 'Function maximum execution time in seconds.', true)
->inject('response')
->inject('projectDB')
->action(function ($functionId, $name, $vars, $events, $schedule, $timeout, $response, $projectDB) {
$function = $projectDB->getDocument($functionId);
@ -291,7 +303,7 @@ App::put('/v1/functions/:functionId')
}
$response->dynamic($function, Response::MODEL_FUNCTION);
}, ['response', 'projectDB']);
});
App::patch('/v1/functions/:functionId/tag')
->groups(['api', 'functions'])
@ -306,6 +318,8 @@ App::patch('/v1/functions/:functionId/tag')
->label('sdk.response.model', Response::MODEL_FUNCTION)
->param('functionId', '', new UID(), 'Function unique ID.')
->param('tag', '', new UID(), 'Tag unique ID.')
->inject('response')
->inject('projectDB')
->action(function ($functionId, $tag, $response, $projectDB) {
$function = $projectDB->getDocument($functionId);
$tag = $projectDB->getDocument($tag);
@ -332,7 +346,7 @@ App::patch('/v1/functions/:functionId/tag')
}
$response->dynamic($function, Response::MODEL_FUNCTION);
}, ['response', 'projectDB']);
});
App::delete('/v1/functions/:functionId')
->groups(['api', 'functions'])
@ -346,6 +360,9 @@ App::delete('/v1/functions/:functionId')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_NONE)
->param('functionId', '', new UID(), 'Function unique ID.')
->inject('response')
->inject('projectDB')
->inject('deletes')
->action(function ($functionId, $response, $projectDB, $deletes) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -366,7 +383,7 @@ App::delete('/v1/functions/:functionId')
;
$response->noContent();
}, ['response', 'projectDB', 'deletes']);
});
App::post('/v1/functions/:functionId/tags')
->groups(['api', 'functions'])
@ -384,6 +401,10 @@ App::post('/v1/functions/:functionId/tags')
->param('command', '', new Text('1028'), 'Code execution command.')
->param('code', [], new File(), 'Gzip file containing your code.', false)
// ->param('code', '', new Text(128), 'Code package. Use the '.APP_NAME.' code packager to create a deployable package file.')
->inject('request')
->inject('response')
->inject('projectDB')
->inject('usage')
->action(function ($functionId, $command, $code, $request, $response, $projectDB, $usage) {
$function = $projectDB->getDocument($functionId);
@ -452,7 +473,7 @@ App::post('/v1/functions/:functionId/tags')
->setStatusCode(Response::STATUS_CODE_CREATED)
->dynamic($tag, Response::MODEL_TAG)
;
}, ['request', 'response', 'projectDB', 'usage']);
});
App::get('/v1/functions/:functionId/tags')
->groups(['api', 'functions'])
@ -470,6 +491,8 @@ App::get('/v1/functions/:functionId/tags')
->param('limit', 25, new Range(0, 100), 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true)
->param('offset', 0, new Range(0, 2000), 'Results offset. The default value is 0. Use this param to manage pagination.', true)
->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true)
->inject('response')
->inject('projectDB')
->action(function ($functionId, $search, $limit, $offset, $orderType, $response, $projectDB) {
$function = $projectDB->getDocument($functionId);
@ -491,7 +514,7 @@ App::get('/v1/functions/:functionId/tags')
'sum' => $projectDB->getSum(),
'tags' => $results
]), Response::MODEL_TAG_LIST);
}, ['response', 'projectDB']);
});
App::get('/v1/functions/:functionId/tags/:tagId')
->groups(['api', 'functions'])
@ -506,6 +529,8 @@ App::get('/v1/functions/:functionId/tags/:tagId')
->label('sdk.response.model', Response::MODEL_TAG)
->param('functionId', '', new UID(), 'Function unique ID.')
->param('tagId', '', new UID(), 'Tag unique ID.')
->inject('response')
->inject('projectDB')
->action(function ($functionId, $tagId, $response, $projectDB) {
$function = $projectDB->getDocument($functionId);
@ -524,7 +549,7 @@ App::get('/v1/functions/:functionId/tags/:tagId')
}
$response->dynamic($tag, Response::MODEL_TAG);
}, ['response', 'projectDB']);
});
App::delete('/v1/functions/:functionId/tags/:tagId')
->groups(['api', 'functions'])
@ -539,6 +564,9 @@ App::delete('/v1/functions/:functionId/tags/:tagId')
->label('sdk.response.model', Response::MODEL_NONE)
->param('functionId', '', new UID(), 'Function unique ID.')
->param('tagId', '', new UID(), 'Tag unique ID.')
->inject('response')
->inject('projectDB')
->inject('usage')
->action(function ($functionId, $tagId, $response, $projectDB, $usage) {
$function = $projectDB->getDocument($functionId);
@ -579,7 +607,7 @@ App::delete('/v1/functions/:functionId/tags/:tagId')
;
$response->noContent();
}, ['response', 'projectDB', 'usage']);
});
App::post('/v1/functions/:functionId/executions')
->groups(['api', 'functions'])
@ -594,6 +622,9 @@ App::post('/v1/functions/:functionId/executions')
->label('sdk.response.model', Response::MODEL_EXECUTION)
->param('functionId', '', new UID(), 'Function unique ID.')
// ->param('async', 1, new Range(0, 1), 'Execute code asynchronously. Pass 1 for true, 0 for false. Default value is 1.', true)
->inject('response')
->inject('project')
->inject('projectDB')
->action(function ($functionId, /*$async,*/ $response, $project, $projectDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Document $project */
@ -647,7 +678,7 @@ App::post('/v1/functions/:functionId/executions')
->setStatusCode(Response::STATUS_CODE_CREATED)
->dynamic($execution, Response::MODEL_EXECUTION)
;
}, ['response', 'project', 'projectDB']);
});
App::get('/v1/functions/:functionId/executions')
->groups(['api', 'functions'])
@ -665,6 +696,8 @@ App::get('/v1/functions/:functionId/executions')
->param('limit', 25, new Range(0, 100), 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true)
->param('offset', 0, new Range(0, 2000), 'Results offset. The default value is 0. Use this param to manage pagination.', true)
->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true)
->inject('response')
->inject('projectDB')
->action(function ($functionId, $search, $limit, $offset, $orderType, $response, $projectDB) {
$function = $projectDB->getDocument($functionId);
@ -686,7 +719,7 @@ App::get('/v1/functions/:functionId/executions')
'sum' => $projectDB->getSum(),
'executions' => $results
]), Response::MODEL_EXECUTION_LIST);
}, ['response', 'projectDB']);
});
App::get('/v1/functions/:functionId/executions/:executionId')
->groups(['api', 'functions'])
@ -701,6 +734,8 @@ App::get('/v1/functions/:functionId/executions/:executionId')
->label('sdk.response.model', Response::MODEL_EXECUTION)
->param('functionId', '', new UID(), 'Function unique ID.')
->param('executionId', '', new UID(), 'Execution unique ID.')
->inject('response')
->inject('projectDB')
->action(function ($functionId, $executionId, $response, $projectDB) {
$function = $projectDB->getDocument($functionId);
@ -719,4 +754,4 @@ App::get('/v1/functions/:functionId/executions/:executionId')
}
$response->dynamic($execution, Response::MODEL_EXECUTION);
}, ['response', 'projectDB']);
});

View file

@ -14,21 +14,23 @@ App::get('/v1/health')
->label('sdk.namespace', 'health')
->label('sdk.method', 'get')
->label('sdk.description', '/docs/references/health/get.md')
->inject('response')
->action(function ($response) {
/** @var Appwrite\Utopia\Response $response */
$response->json(['status' => 'OK']);
}, ['response']);
});
App::get('/v1/health/version')
->desc('Get Version')
->groups(['api', 'health'])
->label('scope', 'public')
->inject('response')
->action(function ($response) {
/** @var Appwrite\Utopia\Response $response */
$response->json(['version' => APP_VERSION_STABLE]);
}, ['response']);
});
App::get('/v1/health/db')
->desc('Get DB')
@ -38,6 +40,8 @@ App::get('/v1/health/db')
->label('sdk.namespace', 'health')
->label('sdk.method', 'getDB')
->label('sdk.description', '/docs/references/health/get-db.md')
->inject('response')
->inject('register')
->action(function ($response, $register) {
/** @var Appwrite\Utopia\Response $response */
/** @var Utopia\Registry\Registry $register */
@ -45,7 +49,7 @@ App::get('/v1/health/db')
$register->get('db'); /* @var $db PDO */
$response->json(['status' => 'OK']);
}, ['response', 'register']);
});
App::get('/v1/health/cache')
->desc('Get Cache')
@ -55,13 +59,15 @@ App::get('/v1/health/cache')
->label('sdk.namespace', 'health')
->label('sdk.method', 'getCache')
->label('sdk.description', '/docs/references/health/get-cache.md')
->inject('response')
->inject('register')
->action(function ($response, $register) {
/** @var Appwrite\Utopia\Response $response */
/** @var Utopia\Registry\Registry $register */
$register->get('cache'); /* @var $cache Predis\Client */
$response->json(['status' => 'OK']);
}, ['response']);
});
App::get('/v1/health/time')
->desc('Get Time')
@ -71,6 +77,7 @@ App::get('/v1/health/time')
->label('sdk.namespace', 'health')
->label('sdk.method', 'getTime')
->label('sdk.description', '/docs/references/health/get-time.md')
->inject('response')
->action(function ($response) {
/** @var Appwrite\Utopia\Response $response */
@ -109,7 +116,7 @@ App::get('/v1/health/time')
}
$response->json(['remote' => $timestamp, 'local' => \time(), 'diff' => $diff]);
}, ['response']);
});
App::get('/v1/health/queue/webhooks')
->desc('Get Webhooks Queue')
@ -119,11 +126,12 @@ App::get('/v1/health/queue/webhooks')
->label('sdk.namespace', 'health')
->label('sdk.method', 'getQueueWebhooks')
->label('sdk.description', '/docs/references/health/get-queue-webhooks.md')
->inject('response')
->action(function ($response) {
/** @var Appwrite\Utopia\Response $response */
$response->json(['size' => Resque::size('v1-webhooks')]);
}, ['response']);
});
App::get('/v1/health/queue/tasks')
->desc('Get Tasks Queue')
@ -133,11 +141,12 @@ App::get('/v1/health/queue/tasks')
->label('sdk.namespace', 'health')
->label('sdk.method', 'getQueueTasks')
->label('sdk.description', '/docs/references/health/get-queue-tasks.md')
->inject('response')
->action(function ($response) {
/** @var Appwrite\Utopia\Response $response */
$response->json(['size' => Resque::size('v1-tasks')]);
}, ['response']);
});
App::get('/v1/health/queue/logs')
->desc('Get Logs Queue')
@ -147,11 +156,12 @@ App::get('/v1/health/queue/logs')
->label('sdk.namespace', 'health')
->label('sdk.method', 'getQueueLogs')
->label('sdk.description', '/docs/references/health/get-queue-logs.md')
->inject('response')
->action(function ($response) {
/** @var Appwrite\Utopia\Response $response */
$response->json(['size' => Resque::size('v1-audit')]);
}, ['response']);
});
App::get('/v1/health/queue/usage')
->desc('Get Usage Queue')
@ -161,11 +171,12 @@ App::get('/v1/health/queue/usage')
->label('sdk.namespace', 'health')
->label('sdk.method', 'getQueueUsage')
->label('sdk.description', '/docs/references/health/get-queue-usage.md')
->inject('response')
->action(function ($response) {
/** @var Appwrite\Utopia\Response $response */
$response->json(['size' => Resque::size('v1-usage')]);
}, ['response']);
});
App::get('/v1/health/queue/certificates')
->desc('Get Certificate Queue')
@ -175,11 +186,12 @@ App::get('/v1/health/queue/certificates')
->label('sdk.namespace', 'health')
->label('sdk.method', 'getQueueCertificates')
->label('sdk.description', '/docs/references/health/get-queue-certificates.md')
->inject('response')
->action(function ($response) {
/** @var Appwrite\Utopia\Response $response */
$response->json(['size' => Resque::size('v1-certificates')]);
}, ['response']);
});
App::get('/v1/health/queue/functions')
->desc('Get Functions Queue')
@ -189,11 +201,12 @@ App::get('/v1/health/queue/functions')
->label('sdk.namespace', 'health')
->label('sdk.method', 'getQueueFunctions')
->label('sdk.description', '/docs/references/health/get-queue-functions.md')
->inject('response')
->action(function ($response) {
/** @var Appwrite\Utopia\Response $response */
$response->json(['size' => Resque::size('v1-functions')]);
}, ['response']);
});
App::get('/v1/health/storage/local')
->desc('Get Local Storage')
@ -203,6 +216,7 @@ App::get('/v1/health/storage/local')
->label('sdk.namespace', 'health')
->label('sdk.method', 'getStorageLocal')
->label('sdk.description', '/docs/references/health/get-storage-local.md')
->inject('response')
->action(function ($response) {
/** @var Appwrite\Utopia\Response $response */
@ -224,7 +238,7 @@ App::get('/v1/health/storage/local')
}
$response->json(['status' => 'OK']);
}, ['response']);
});
App::get('/v1/health/anti-virus')
->desc('Get Anti virus')
@ -234,6 +248,7 @@ App::get('/v1/health/anti-virus')
->label('sdk.namespace', 'health')
->label('sdk.method', 'getAntiVirus')
->label('sdk.description', '/docs/references/health/get-storage-anti-virus.md')
->inject('response')
->action(function ($response) {
/** @var Appwrite\Utopia\Response $response */
@ -247,7 +262,7 @@ App::get('/v1/health/anti-virus')
'status' => (@$antiVirus->ping()) ? 'online' : 'offline',
'version' => @$antiVirus->version(),
]);
}, ['response']);
});
App::get('/v1/health/stats') // Currently only used internally
->desc('Get System Stats')
@ -257,6 +272,8 @@ App::get('/v1/health/stats') // Currently only used internally
// ->label('sdk.namespace', 'health')
// ->label('sdk.method', 'getStats')
->label('docs', false)
->inject('response')
->inject('register')
->action(function ($response, $register) {
/** @var Appwrite\Utopia\Response $response */
/** @var Utopia\Registry\Registry $register */
@ -288,4 +305,4 @@ App::get('/v1/health/stats') // Currently only used internally
'memory_used_peak_human' => $cacheStats['used_memory_peak_human'] ?? 0,
],
]);
}, ['response', 'register']);
});

View file

@ -16,6 +16,10 @@ App::get('/v1/locale')
->label('sdk.response.code', Response::STATUS_CODE_OK)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_LOCALE)
->inject('request')
->inject('response')
->inject('locale')
->inject('geodb')
->action(function ($request, $response, $locale, $geodb) {
/** @var Utopia\Swoole\Request $request */
/** @var Appwrite\Utopia\Response $response */
@ -64,7 +68,7 @@ App::get('/v1/locale')
->addHeader('Expires', \date('D, d M Y H:i:s', \time() + $time).' GMT') // 45 days cache
;
$response->dynamic(new Document($output), Response::MODEL_LOCALE);
}, ['request', 'response', 'locale', 'geodb']);
});
App::get('/v1/locale/countries')
->desc('List Countries')
@ -77,6 +81,8 @@ App::get('/v1/locale/countries')
->label('sdk.response.code', Response::STATUS_CODE_OK)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_COUNTRY_LIST)
->inject('response')
->inject('locale')
->action(function ($response, $locale) {
/** @var Appwrite\Utopia\Response $response */
/** @var Utopia\Locale\Locale $locale */
@ -94,7 +100,7 @@ App::get('/v1/locale/countries')
}
$response->dynamic(new Document(['countries' => $output, 'sum' => \count($output)]), Response::MODEL_COUNTRY_LIST);
}, ['response', 'locale']);
});
App::get('/v1/locale/countries/eu')
->desc('List EU Countries')
@ -106,7 +112,9 @@ App::get('/v1/locale/countries/eu')
->label('sdk.description', '/docs/references/locale/get-countries-eu.md')
->label('sdk.response.code', Response::STATUS_CODE_OK)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_COUNTRY_LIST)
->label('sdk.response.model', Response::MODEL_COUNTRY_LIST)
->inject('response')
->inject('locale')
->action(function ($response, $locale) {
/** @var Appwrite\Utopia\Response $response */
/** @var Utopia\Locale\Locale $locale */
@ -127,7 +135,7 @@ App::get('/v1/locale/countries/eu')
}
$response->dynamic(new Document(['countries' => $output, 'sum' => \count($output)]), Response::MODEL_COUNTRY_LIST);
}, ['response', 'locale']);
});
App::get('/v1/locale/countries/phones')
->desc('List Countries Phone Codes')
@ -140,6 +148,8 @@ App::get('/v1/locale/countries/phones')
->label('sdk.response.code', Response::STATUS_CODE_OK)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_PHONE_LIST)
->inject('response')
->inject('locale')
->action(function ($response, $locale) {
/** @var Appwrite\Utopia\Response $response */
/** @var Utopia\Locale\Locale $locale */
@ -161,7 +171,7 @@ App::get('/v1/locale/countries/phones')
}
$response->dynamic(new Document(['phones' => $output, 'sum' => \count($output)]), Response::MODEL_PHONE_LIST);
}, ['response', 'locale']);
});
App::get('/v1/locale/continents')
->desc('List Continents')
@ -174,6 +184,8 @@ App::get('/v1/locale/continents')
->label('sdk.response.code', Response::STATUS_CODE_OK)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_CONTINENT_LIST)
->inject('response')
->inject('locale')
->action(function ($response, $locale) {
/** @var Appwrite\Utopia\Response $response */
/** @var Utopia\Locale\Locale $locale */
@ -190,7 +202,7 @@ App::get('/v1/locale/continents')
}
$response->dynamic(new Document(['continents' => $output, 'sum' => \count($output)]), Response::MODEL_CONTINENT_LIST);
}, ['response', 'locale']);
});
App::get('/v1/locale/currencies')
->desc('List Currencies')
@ -203,6 +215,7 @@ App::get('/v1/locale/currencies')
->label('sdk.response.code', Response::STATUS_CODE_OK)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_CURRENCY_LIST)
->inject('response')
->action(function ($response) {
/** @var Appwrite\Utopia\Response $response */
@ -213,7 +226,7 @@ App::get('/v1/locale/currencies')
}, $list);
$response->dynamic(new Document(['currencies' => $list, 'sum' => \count($list)]), Response::MODEL_CURRENCY_LIST);
}, ['response']);
});
App::get('/v1/locale/languages')
@ -227,6 +240,7 @@ App::get('/v1/locale/languages')
->label('sdk.response.code', Response::STATUS_CODE_OK)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_LANGUAGE_LIST)
->inject('response')
->action(function ($response) {
/** @var Appwrite\Utopia\Response $response */
@ -237,4 +251,4 @@ App::get('/v1/locale/languages')
}, $list);
$response->dynamic(new Document(['languages' => $list, 'sum' => \count($list)]), Response::MODEL_LANGUAGE_LIST);
}, ['response']);
});

View file

@ -40,6 +40,9 @@ App::post('/v1/projects')
->param('legalCity', '', new Text(256), 'Project legal City. Max length: 256 chars.', true)
->param('legalAddress', '', new Text(256), 'Project legal Address. Max length: 256 chars.', true)
->param('legalTaxId', '', new Text(256), 'Project legal Tax ID. Max length: 256 chars.', true)
->inject('response')
->inject('consoleDB')
->inject('projectDB')
->action(function ($name, $teamId, $description, $logo, $url, $legalName, $legalCountry, $legalState, $legalCity, $legalAddress, $legalTaxId, $response, $consoleDB, $projectDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -87,7 +90,7 @@ App::post('/v1/projects')
->setStatusCode(Response::STATUS_CODE_CREATED)
->dynamic($project, Response::MODEL_PROJECT)
;
}, ['response', 'consoleDB', 'projectDB']);
});
App::get('/v1/projects')
->desc('List Projects')
@ -102,6 +105,8 @@ App::get('/v1/projects')
->param('limit', 25, new Range(0, 100), 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true)
->param('offset', 0, new Range(0, 2000), 'Results offset. The default value is 0. Use this param to manage pagination.', true)
->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true)
->inject('response')
->inject('consoleDB')
->action(function ($search, $limit, $offset, $orderType, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -119,7 +124,7 @@ App::get('/v1/projects')
'sum' => $consoleDB->getSum(),
'projects' => $results
]), Response::MODEL_PROJECT_LIST);
}, ['response', 'consoleDB']);
});
App::get('/v1/projects/:projectId')
->desc('Get Project')
@ -131,6 +136,8 @@ App::get('/v1/projects/:projectId')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_PROJECT)
->param('projectId', '', new UID(), 'Project unique ID.')
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -142,7 +149,7 @@ App::get('/v1/projects/:projectId')
}
$response->dynamic($project, Response::MODEL_PROJECT);
}, ['response', 'consoleDB']);
});
App::get('/v1/projects/:projectId/usage')
->desc('Get Project')
@ -152,6 +159,10 @@ App::get('/v1/projects/:projectId/usage')
->label('sdk.method', 'getUsage')
->param('projectId', '', new UID(), 'Project unique ID.')
->param('range', '30d', new WhiteList(['24h', '7d', '30d', '90d'], true), 'Date range.', true)
->inject('response')
->inject('consoleDB')
->inject('projectDB')
->inject('register')
->action(function ($projectId, $range, $response, $consoleDB, $projectDB, $register) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -312,7 +323,7 @@ App::get('/v1/projects/:projectId/usage')
),
],
]);
}, ['response', 'consoleDB', 'projectDB', 'register']);
});
App::patch('/v1/projects/:projectId')
->desc('Update Project')
@ -334,6 +345,8 @@ App::patch('/v1/projects/:projectId')
->param('legalCity', '', new Text(256), 'Project legal city. Max length: 256 chars.', true)
->param('legalAddress', '', new Text(256), 'Project legal address. Max length: 256 chars.', true)
->param('legalTaxId', '', new Text(256), 'Project legal tax ID. Max length: 256 chars.', true)
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $name, $description, $logo, $url, $legalName, $legalCountry, $legalState, $legalCity, $legalAddress, $legalTaxId, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -362,7 +375,7 @@ App::patch('/v1/projects/:projectId')
}
$response->dynamic($project, Response::MODEL_PROJECT);
}, ['response', 'consoleDB']);
});
App::patch('/v1/projects/:projectId/oauth2')
->desc('Update Project OAuth2')
@ -377,6 +390,8 @@ App::patch('/v1/projects/:projectId/oauth2')
->param('provider', '', new WhiteList(\array_keys(Config::getParam('providers')), true), 'Provider Name', false)
->param('appId', '', new Text(256), 'Provider app ID. Max length: 256 chars.', true)
->param('secret', '', new text(512), 'Provider secret key. Max length: 512 chars.', true)
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $provider, $appId, $secret, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -397,7 +412,7 @@ App::patch('/v1/projects/:projectId/oauth2')
}
$response->dynamic($project, Response::MODEL_PROJECT);
}, ['response', 'consoleDB']);
});
App::delete('/v1/projects/:projectId')
->desc('Delete Project')
@ -410,6 +425,10 @@ App::delete('/v1/projects/:projectId')
->label('sdk.response.model', Response::MODEL_NONE)
->param('projectId', '', new UID(), 'Project unique ID.')
->param('password', '', new UID(), 'Your user password for confirmation. Must be between 6 to 32 chars.')
->inject('response')
->inject('user')
->inject('consoleDB')
->inject('deletes')
->action(function ($projectId, $password, $response, $user, $consoleDB, $deletes) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Document $user */
@ -447,7 +466,7 @@ App::delete('/v1/projects/:projectId')
}
$response->noContent();
}, ['response', 'user', 'consoleDB', 'deletes']);
});
// Webhooks
@ -467,6 +486,8 @@ App::post('/v1/projects/:projectId/webhooks')
->param('security', false, new Boolean(true), 'Certificate verification, false for disabled or true for enabled.')
->param('httpUser', '', new Text(256), 'Webhook HTTP user. Max length: 256 chars.', true)
->param('httpPass', '', new Text(256), 'Webhook HTTP password. Max length: 256 chars.', true)
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $name, $events, $url, $security, $httpUser, $httpPass, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -509,7 +530,7 @@ App::post('/v1/projects/:projectId/webhooks')
->setStatusCode(Response::STATUS_CODE_CREATED)
->dynamic($webhook, Response::MODEL_WEBHOOK)
;
}, ['response', 'consoleDB']);
});
App::get('/v1/projects/:projectId/webhooks')
->desc('List Webhooks')
@ -521,6 +542,8 @@ App::get('/v1/projects/:projectId/webhooks')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_WEBHOOK_LIST)
->param('projectId', '', new UID(), 'Project unique ID.')
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -537,7 +560,7 @@ App::get('/v1/projects/:projectId/webhooks')
'sum' => count($webhooks),
'webhooks' => $webhooks
]), Response::MODEL_WEBHOOK_LIST);
}, ['response', 'consoleDB']);
});
App::get('/v1/projects/:projectId/webhooks/:webhookId')
->desc('Get Webhook')
@ -550,6 +573,8 @@ App::get('/v1/projects/:projectId/webhooks/:webhookId')
->label('sdk.response.model', Response::MODEL_WEBHOOK)
->param('projectId', null, new UID(), 'Project unique ID.')
->param('webhookId', null, new UID(), 'Webhook unique ID.')
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $webhookId, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -567,7 +592,7 @@ App::get('/v1/projects/:projectId/webhooks/:webhookId')
}
$response->dynamic($webhook, Response::MODEL_WEBHOOK);
}, ['response', 'consoleDB']);
});
App::put('/v1/projects/:projectId/webhooks/:webhookId')
->desc('Update Webhook')
@ -586,6 +611,8 @@ App::put('/v1/projects/:projectId/webhooks/:webhookId')
->param('security', false, new Boolean(true), 'Certificate verification, false for disabled or true for enabled.')
->param('httpUser', '', new Text(256), 'Webhook HTTP user. Max length: 256 chars.', true)
->param('httpPass', '', new Text(256), 'Webhook HTTP password. Max length: 256 chars.', true)
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $webhookId, $name, $events, $url, $security, $httpUser, $httpPass, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -618,7 +645,7 @@ App::put('/v1/projects/:projectId/webhooks/:webhookId')
}
$response->dynamic($webhook, Response::MODEL_WEBHOOK);
}, ['response', 'consoleDB']);
});
App::delete('/v1/projects/:projectId/webhooks/:webhookId')
->desc('Delete Webhook')
@ -631,6 +658,8 @@ App::delete('/v1/projects/:projectId/webhooks/:webhookId')
->label('sdk.response.model', Response::MODEL_NONE)
->param('projectId', null, new UID(), 'Project unique ID.')
->param('webhookId', null, new UID(), 'Webhook unique ID.')
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $webhookId, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -652,7 +681,7 @@ App::delete('/v1/projects/:projectId/webhooks/:webhookId')
}
$response->noContent();
}, ['response', 'consoleDB']);
});
// Keys
@ -668,6 +697,8 @@ App::post('/v1/projects/:projectId/keys')
->param('projectId', null, new UID(), 'Project unique ID.')
->param('name', null, new Text(128), 'Key name. Max length: 128 chars.')
->param('scopes', null, new ArrayList(new WhiteList(Config::getParam('scopes'), true)), 'Key scopes list.')
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $name, $scopes, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -705,7 +736,7 @@ App::post('/v1/projects/:projectId/keys')
->setStatusCode(Response::STATUS_CODE_CREATED)
->dynamic($key, Response::MODEL_KEY)
;
}, ['response', 'consoleDB']);
});
App::get('/v1/projects/:projectId/keys')
->desc('List Keys')
@ -717,6 +748,8 @@ App::get('/v1/projects/:projectId/keys')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_KEY_LIST)
->param('projectId', null, new UID(), 'Project unique ID.')
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -733,7 +766,7 @@ App::get('/v1/projects/:projectId/keys')
'sum' => count($keys),
'keys' => $keys
]), Response::MODEL_KEY_LIST);
}, ['response', 'consoleDB']);
});
App::get('/v1/projects/:projectId/keys/:keyId')
->desc('Get Key')
@ -746,6 +779,8 @@ App::get('/v1/projects/:projectId/keys/:keyId')
->label('sdk.response.model', Response::MODEL_KEY)
->param('projectId', null, new UID(), 'Project unique ID.')
->param('keyId', null, new UID(), 'Key unique ID.')
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $keyId, $response, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
@ -760,7 +795,7 @@ App::get('/v1/projects/:projectId/keys/:keyId')
}
$response->dynamic($key, Response::MODEL_KEY);
}, ['response', 'consoleDB']);
});
App::put('/v1/projects/:projectId/keys/:keyId')
->desc('Update Key')
@ -775,6 +810,8 @@ App::put('/v1/projects/:projectId/keys/:keyId')
->param('keyId', null, new UID(), 'Key unique ID.')
->param('name', null, new Text(128), 'Key name. Max length: 128 chars.')
->param('scopes', null, new ArrayList(new WhiteList(Config::getParam('scopes'), true)), 'Key scopes list')
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $keyId, $name, $scopes, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -801,7 +838,7 @@ App::put('/v1/projects/:projectId/keys/:keyId')
}
$response->dynamic($key, Response::MODEL_KEY);
}, ['response', 'consoleDB']);
});
App::delete('/v1/projects/:projectId/keys/:keyId')
->desc('Delete Key')
@ -814,6 +851,8 @@ App::delete('/v1/projects/:projectId/keys/:keyId')
->label('sdk.response.model', Response::MODEL_NONE)
->param('projectId', null, new UID(), 'Project unique ID.')
->param('keyId', null, new UID(), 'Key unique ID.')
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $keyId, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -835,7 +874,7 @@ App::delete('/v1/projects/:projectId/keys/:keyId')
}
$response->noContent();
}, ['response', 'consoleDB']);
});
// Tasks
@ -858,6 +897,8 @@ App::post('/v1/projects/:projectId/tasks')
->param('httpHeaders', null, new ArrayList(new Text(256)), 'Task HTTP headers list.', true)
->param('httpUser', '', new Text(256), 'Task HTTP user. Max length: 256 chars.', true)
->param('httpPass', '', new Text(256), 'Task HTTP password. Max length: 256 chars.', true)
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $name, $status, $schedule, $security, $httpMethod, $httpUrl, $httpHeaders, $httpUser, $httpPass, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -915,7 +956,7 @@ App::post('/v1/projects/:projectId/tasks')
->setStatusCode(Response::STATUS_CODE_CREATED)
->dynamic($task, Response::MODEL_TASK)
;
}, ['response', 'consoleDB']);
});
App::get('/v1/projects/:projectId/tasks')
->desc('List Tasks')
@ -927,6 +968,8 @@ App::get('/v1/projects/:projectId/tasks')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_TASK_LIST)
->param('projectId', '', new UID(), 'Project unique ID.')
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -944,7 +987,7 @@ App::get('/v1/projects/:projectId/tasks')
'tasks' => $tasks
]), Response::MODEL_TASK_LIST);
}, ['response', 'consoleDB']);
});
App::get('/v1/projects/:projectId/tasks/:taskId')
->desc('Get Task')
@ -957,6 +1000,8 @@ App::get('/v1/projects/:projectId/tasks/:taskId')
->label('sdk.response.model', Response::MODEL_TASK)
->param('projectId', null, new UID(), 'Project unique ID.')
->param('taskId', null, new UID(), 'Task unique ID.')
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $taskId, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -974,7 +1019,7 @@ App::get('/v1/projects/:projectId/tasks/:taskId')
}
$response->dynamic($task, Response::MODEL_TASK);
}, ['response', 'consoleDB']);
});
App::put('/v1/projects/:projectId/tasks/:taskId')
->desc('Update Task')
@ -996,6 +1041,8 @@ App::put('/v1/projects/:projectId/tasks/:taskId')
->param('httpHeaders', null, new ArrayList(new Text(256)), 'Task HTTP headers list.', true)
->param('httpUser', '', new Text(256), 'Task HTTP user. Max length: 256 chars.', true)
->param('httpPass', '', new Text(256), 'Task HTTP password. Max length: 256 chars.', true)
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $taskId, $name, $status, $schedule, $security, $httpMethod, $httpUrl, $httpHeaders, $httpUser, $httpPass, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -1040,7 +1087,7 @@ App::put('/v1/projects/:projectId/tasks/:taskId')
}
$response->dynamic($task, Response::MODEL_TASK);
}, ['response', 'consoleDB']);
});
App::delete('/v1/projects/:projectId/tasks/:taskId')
->desc('Delete Task')
@ -1053,6 +1100,8 @@ App::delete('/v1/projects/:projectId/tasks/:taskId')
->label('sdk.response.model', Response::MODEL_NONE)
->param('projectId', null, new UID(), 'Project unique ID.')
->param('taskId', null, new UID(), 'Task unique ID.')
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $taskId, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -1074,7 +1123,7 @@ App::delete('/v1/projects/:projectId/tasks/:taskId')
}
$response->noContent();
}, ['response', 'consoleDB']);
});
// Platforms
@ -1093,6 +1142,8 @@ App::post('/v1/projects/:projectId/platforms')
->param('key', '', new Text(256), 'Package name for android or bundle ID for iOS. Max length: 256 chars.', true)
->param('store', '', new Text(256), 'App store or Google Play store ID. Max length: 256 chars.', true)
->param('hostname', '', new Text(256), 'Platform client hostname. Max length: 256 chars.', true)
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $type, $name, $key, $store, $hostname, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -1134,7 +1185,7 @@ App::post('/v1/projects/:projectId/platforms')
->setStatusCode(Response::STATUS_CODE_CREATED)
->dynamic($platform, Response::MODEL_PLATFORM)
;
}, ['response', 'consoleDB']);
});
App::get('/v1/projects/:projectId/platforms')
->desc('List Platforms')
@ -1146,6 +1197,8 @@ App::get('/v1/projects/:projectId/platforms')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_PLATFORM_LIST)
->param('projectId', '', new UID(), 'Project unique ID.')
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -1162,7 +1215,7 @@ App::get('/v1/projects/:projectId/platforms')
'sum' => count($platforms),
'platforms' => $platforms
]), Response::MODEL_PLATFORM_LIST);
}, ['response', 'consoleDB']);
});
App::get('/v1/projects/:projectId/platforms/:platformId')
->desc('Get Platform')
@ -1175,6 +1228,8 @@ App::get('/v1/projects/:projectId/platforms/:platformId')
->label('sdk.response.model', Response::MODEL_PLATFORM)
->param('projectId', null, new UID(), 'Project unique ID.')
->param('platformId', null, new UID(), 'Platform unique ID.')
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $platformId, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -1192,7 +1247,7 @@ App::get('/v1/projects/:projectId/platforms/:platformId')
}
$response->dynamic($platform, Response::MODEL_PLATFORM);
}, ['response', 'consoleDB']);
});
App::put('/v1/projects/:projectId/platforms/:platformId')
->desc('Update Platform')
@ -1209,6 +1264,8 @@ App::put('/v1/projects/:projectId/platforms/:platformId')
->param('key', '', new Text(256), 'Package name for android or bundle ID for iOS. Max length: 256 chars.', true)
->param('store', '', new Text(256), 'App store or Google Play store ID. Max length: 256 chars.', true)
->param('hostname', '', new Text(256), 'Platform client URL. Max length: 256 chars.', true)
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $platformId, $name, $key, $store, $hostname, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -1238,7 +1295,7 @@ App::put('/v1/projects/:projectId/platforms/:platformId')
}
$response->dynamic($platform, Response::MODEL_PLATFORM);
}, ['response', 'consoleDB']);
});
App::delete('/v1/projects/:projectId/platforms/:platformId')
->desc('Delete Platform')
@ -1251,6 +1308,8 @@ App::delete('/v1/projects/:projectId/platforms/:platformId')
->label('sdk.response.model', Response::MODEL_NONE)
->param('projectId', null, new UID(), 'Project unique ID.')
->param('platformId', null, new UID(), 'Platform unique ID.')
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $platformId, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -1272,7 +1331,7 @@ App::delete('/v1/projects/:projectId/platforms/:platformId')
}
$response->noContent();
}, ['response', 'consoleDB']);
});
// Domains
@ -1287,6 +1346,8 @@ App::post('/v1/projects/:projectId/domains')
->label('sdk.response.model', Response::MODEL_DOMAIN)
->param('projectId', null, new UID(), 'Project unique ID.')
->param('domain', null, new DomainValidator(), 'Domain name.')
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $domain, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -1341,7 +1402,7 @@ App::post('/v1/projects/:projectId/domains')
->setStatusCode(Response::STATUS_CODE_CREATED)
->dynamic($domain, Response::MODEL_DOMAIN)
;
}, ['response', 'consoleDB']);
});
App::get('/v1/projects/:projectId/domains')
->desc('List Domains')
@ -1353,6 +1414,8 @@ App::get('/v1/projects/:projectId/domains')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_DOMAIN_LIST)
->param('projectId', '', new UID(), 'Project unique ID.')
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -1369,7 +1432,7 @@ App::get('/v1/projects/:projectId/domains')
'sum' => count($domains),
'domains' => $domains
]), Response::MODEL_DOMAIN_LIST);
}, ['response', 'consoleDB']);
});
App::get('/v1/projects/:projectId/domains/:domainId')
->desc('Get Domain')
@ -1382,6 +1445,8 @@ App::get('/v1/projects/:projectId/domains/:domainId')
->label('sdk.response.model', Response::MODEL_DOMAIN)
->param('projectId', null, new UID(), 'Project unique ID.')
->param('domainId', null, new UID(), 'Domain unique ID.')
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $domainId, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -1399,7 +1464,7 @@ App::get('/v1/projects/:projectId/domains/:domainId')
}
$response->dynamic($domain, Response::MODEL_DOMAIN);
}, ['response', 'consoleDB']);
});
App::patch('/v1/projects/:projectId/domains/:domainId/verification')
->desc('Update Domain Verification Status')
@ -1412,6 +1477,8 @@ App::patch('/v1/projects/:projectId/domains/:domainId/verification')
->label('sdk.response.model', Response::MODEL_DOMAIN)
->param('projectId', null, new UID(), 'Project unique ID.')
->param('domainId', null, new UID(), 'Domain unique ID.')
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $domainId, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -1460,7 +1527,7 @@ App::patch('/v1/projects/:projectId/domains/:domainId/verification')
]);
$response->dynamic($domain, Response::MODEL_DOMAIN);
}, ['response', 'consoleDB']);
});
App::delete('/v1/projects/:projectId/domains/:domainId')
->desc('Delete Domain')
@ -1473,6 +1540,8 @@ App::delete('/v1/projects/:projectId/domains/:domainId')
->label('sdk.response.model', Response::MODEL_NONE)
->param('projectId', null, new UID(), 'Project unique ID.')
->param('domainId', null, new UID(), 'Domain unique ID.')
->inject('response')
->inject('consoleDB')
->action(function ($projectId, $domainId, $response, $consoleDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $consoleDB */
@ -1494,4 +1563,4 @@ App::delete('/v1/projects/:projectId/domains/:domainId')
}
$response->noContent();
}, ['response', 'consoleDB']);
});

View file

@ -40,10 +40,14 @@ App::post('/v1/storage/files')
->param('file', [], new File(), 'Binary file.', false)
->param('read', [], new ArrayList(new Text(64)), 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.')
->param('write', [], new ArrayList(new Text(64)), 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.')
->action(function ($file, $read, $write, $request, $response, $user, $projectDB, $audits, $usage) {
->inject('request')
->inject('response')
->inject('projectDB')
->inject('audits')
->inject('usage')
->action(function ($file, $read, $write, $request, $response, $projectDB, $audits, $usage) {
/** @var Utopia\Swoole\Request $request */
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Document $user */
/** @var Appwrite\Database\Database $projectDB */
/** @var Appwrite\Event\Event $audits */
/** @var Appwrite\Event\Event $usage */
@ -154,7 +158,7 @@ App::post('/v1/storage/files')
->setStatusCode(Response::STATUS_CODE_CREATED)
->dynamic($file, Response::MODEL_FILE)
;
}, ['request', 'response', 'user', 'projectDB', 'audits', 'usage']);
});
App::get('/v1/storage/files')
->desc('List Files')
@ -171,6 +175,8 @@ App::get('/v1/storage/files')
->param('limit', 25, new Range(0, 100), 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true)
->param('offset', 0, new Range(0, 2000), 'Results offset. The default value is 0. Use this param to manage pagination.', true)
->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true)
->inject('response')
->inject('projectDB')
->action(function ($search, $limit, $offset, $orderType, $response, $projectDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -189,7 +195,7 @@ App::get('/v1/storage/files')
'sum' => $projectDB->getSum(),
'files' => $results
]), Response::MODEL_FILE_LIST);
}, ['response', 'projectDB']);
});
App::get('/v1/storage/files/:fileId')
->desc('Get File')
@ -203,6 +209,8 @@ App::get('/v1/storage/files/:fileId')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_FILE)
->param('fileId', '', new UID(), 'File unique ID.')
->inject('response')
->inject('projectDB')
->action(function ($fileId, $response, $projectDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -214,7 +222,7 @@ App::get('/v1/storage/files/:fileId')
}
$response->dynamic($file, Response::MODEL_FILE);
}, ['response', 'projectDB']);
});
App::get('/v1/storage/files/:fileId/preview')
->desc('Get File Preview')
@ -233,6 +241,10 @@ App::get('/v1/storage/files/:fileId/preview')
->param('quality', 100, new Range(0, 100), 'Preview image quality. Pass an integer between 0 to 100. Defaults to 100.', true)
->param('background', '', new HexColor(), 'Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.', true)
->param('output', '', new WhiteList(\array_keys(Config::getParam('storage-outputs')), true), 'Output format type (jpeg, jpg, png, gif and webp).', true)
->inject('request')
->inject('response')
->inject('project')
->inject('projectDB')
->action(function ($fileId, $width, $height, $quality, $background, $output, $request, $response, $project, $projectDB) {
/** @var Utopia\Swoole\Request $request */
/** @var Appwrite\Utopia\Response $response */
@ -341,7 +353,7 @@ App::get('/v1/storage/files/:fileId/preview')
;
unset($resize);
}, ['request', 'response', 'project', 'projectDB']);
});
App::get('/v1/storage/files/:fileId/download')
->desc('Get File for Download')
@ -355,6 +367,8 @@ App::get('/v1/storage/files/:fileId/download')
->label('sdk.response.type', '*/*')
->label('sdk.methodType', 'location')
->param('fileId', '', new UID(), 'File unique ID.')
->inject('response')
->inject('projectDB')
->action(function ($fileId, $response, $projectDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -397,7 +411,7 @@ App::get('/v1/storage/files/:fileId/download')
->addHeader('X-Peak', \memory_get_peak_usage())
->send($source)
;
}, ['response', 'projectDB']);
});
App::get('/v1/storage/files/:fileId/view')
->desc('Get File for View')
@ -412,6 +426,8 @@ App::get('/v1/storage/files/:fileId/view')
->label('sdk.methodType', 'location')
->param('fileId', '', new UID(), 'File unique ID.')
->param('as', '', new WhiteList(['pdf', /*'html',*/ 'text'], true), 'Choose a file format to convert your file to. Currently you can only convert word and pdf files to pdf or txt. This option is currently experimental only, use at your own risk.', true)
->inject('response')
->inject('projectDB')
->action(function ($fileId, $as, $response, $projectDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -471,7 +487,7 @@ App::get('/v1/storage/files/:fileId/view')
->addHeader('X-Peak', \memory_get_peak_usage())
->send($output)
;
}, ['response', 'projectDB']);
});
App::put('/v1/storage/files/:fileId')
->desc('Update File')
@ -488,6 +504,9 @@ App::put('/v1/storage/files/:fileId')
->param('fileId', '', new UID(), 'File unique ID.')
->param('read', [], new ArrayList(new Text(64)), 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.')
->param('write', [], new ArrayList(new Text(64)), 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.')
->inject('response')
->inject('projectDB')
->inject('audits')
->action(function ($fileId, $read, $write, $response, $projectDB, $audits) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -517,7 +536,7 @@ App::put('/v1/storage/files/:fileId')
;
$response->dynamic($file, Response::MODEL_FILE);
}, ['response', 'projectDB', 'audits']);
});
App::delete('/v1/storage/files/:fileId')
->desc('Delete File')
@ -532,6 +551,11 @@ App::delete('/v1/storage/files/:fileId')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_NONE)
->param('fileId', '', new UID(), 'File unique ID.')
->inject('response')
->inject('projectDB')
->inject('events')
->inject('audits')
->inject('usage')
->action(function ($fileId, $response, $projectDB, $events, $audits, $usage) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -567,7 +591,7 @@ App::delete('/v1/storage/files/:fileId')
;
$response->noContent();
}, ['response', 'projectDB', 'events', 'audits', 'usage']);
});
// App::get('/v1/storage/files/:fileId/scan')
// ->desc('Scan Storage')

View file

@ -34,6 +34,9 @@ App::post('/v1/teams')
->label('sdk.response.model', Response::MODEL_TEAM)
->param('name', null, new Text(128), 'Team name. Max length: 128 chars.')
->param('roles', ['owner'], new ArrayList(new Key()), 'Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Max length for each role is 32 chars.', true)
->inject('response')
->inject('user')
->inject('projectDB')
->action(function ($name, $roles, $response, $user, $projectDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Document $user */
@ -91,7 +94,7 @@ App::post('/v1/teams')
->setStatusCode(Response::STATUS_CODE_CREATED)
->dynamic($team, Response::MODEL_TEAM)
;
}, ['response', 'user', 'projectDB']);
});
App::get('/v1/teams')
->desc('List Teams')
@ -108,6 +111,8 @@ App::get('/v1/teams')
->param('limit', 25, new Range(0, 100), 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true)
->param('offset', 0, new Range(0, 2000), 'Results offset. The default value is 0. Use this param to manage pagination.', true)
->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true)
->inject('response')
->inject('projectDB')
->action(function ($search, $limit, $offset, $orderType, $response, $projectDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -126,7 +131,7 @@ App::get('/v1/teams')
'sum' => $projectDB->getSum(),
'teams' => $results
]), Response::MODEL_TEAM_LIST);
}, ['response', 'projectDB']);
});
App::get('/v1/teams/:teamId')
->desc('Get Team')
@ -140,6 +145,8 @@ App::get('/v1/teams/:teamId')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_TEAM)
->param('teamId', '', new UID(), 'Team unique ID.')
->inject('response')
->inject('projectDB')
->action(function ($teamId, $response, $projectDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -151,7 +158,7 @@ App::get('/v1/teams/:teamId')
}
$response->dynamic($team, Response::MODEL_TEAM);
}, ['response', 'projectDB']);
});
App::put('/v1/teams/:teamId')
->desc('Update Team')
@ -167,6 +174,8 @@ App::put('/v1/teams/:teamId')
->label('sdk.response.model', Response::MODEL_TEAM)
->param('teamId', '', new UID(), 'Team unique ID.')
->param('name', null, new Text(128), 'Team name. Max length: 128 chars.')
->inject('response')
->inject('projectDB')
->action(function ($teamId, $name, $response, $projectDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -186,7 +195,7 @@ App::put('/v1/teams/:teamId')
}
$response->dynamic($team, Response::MODEL_TEAM);
}, ['response', 'projectDB']);
});
App::delete('/v1/teams/:teamId')
->desc('Delete Team')
@ -201,6 +210,9 @@ App::delete('/v1/teams/:teamId')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_NONE)
->param('teamId', '', new UID(), 'Team unique ID.')
->inject('response')
->inject('projectDB')
->inject('events')
->action(function ($teamId, $response, $projectDB, $events) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -236,7 +248,7 @@ App::delete('/v1/teams/:teamId')
;
$response->noContent();
}, ['response', 'projectDB', 'events']);
});
App::post('/v1/teams/:teamId/memberships')
->desc('Create Team Membership')
@ -255,6 +267,13 @@ App::post('/v1/teams/:teamId/memberships')
->param('name', '', new Text(128), 'New team member name. Max length: 128 chars.', true)
->param('roles', [], new ArrayList(new Key()), 'Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Max length for each role is 32 chars.')
->param('url', '', function ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the invitation email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.', false, ['clients']) // TODO add our own built-in confirm page
->inject('response')
->inject('project')
->inject('user')
->inject('projectDB')
->inject('locale')
->inject('audits')
->inject('mails')
->action(function ($teamId, $email, $name, $roles, $url, $response, $project, $user, $projectDB, $locale, $audits, $mails) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Document $project */
@ -431,7 +450,7 @@ App::post('/v1/teams/:teamId/memberships')
'name' => $name,
])), Response::MODEL_MEMBERSHIP)
;
}, ['response', 'project', 'user', 'projectDB', 'locale', 'audits', 'mails']);
});
App::get('/v1/teams/:teamId/memberships')
->desc('Get Team Memberships')
@ -449,6 +468,8 @@ App::get('/v1/teams/:teamId/memberships')
->param('limit', 25, new Range(0, 100), 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true)
->param('offset', 0, new Range(0, 2000), 'Results offset. The default value is 0. Use this param to manage pagination.', true)
->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true)
->inject('response')
->inject('projectDB')
->action(function ($teamId, $search, $limit, $offset, $orderType, $response, $projectDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -483,7 +504,7 @@ App::get('/v1/teams/:teamId/memberships')
}
$response->dynamic(new Document(['sum' => $projectDB->getSum(), 'memberships' => $users]), Response::MODEL_MEMBERSHIP_LIST);
}, ['response', 'projectDB']);
});
App::patch('/v1/teams/:teamId/memberships/:inviteId/status')
->desc('Update Team Membership Status')
@ -501,6 +522,12 @@ App::patch('/v1/teams/:teamId/memberships/:inviteId/status')
->param('inviteId', '', new UID(), 'Invite unique ID.')
->param('userId', '', new UID(), 'User unique ID.')
->param('secret', '', new Text(256), 'Secret key.')
->inject('request')
->inject('response')
->inject('user')
->inject('projectDB')
->inject('geodb')
->inject('audits')
->action(function ($teamId, $inviteId, $userId, $secret, $request, $response, $user, $projectDB, $geodb, $audits) {
/** @var Utopia\Swoole\Request $request */
/** @var Appwrite\Utopia\Response $response */
@ -663,7 +690,7 @@ App::patch('/v1/teams/:teamId/memberships/:inviteId/status')
'email' => $user->getAttribute('email'),
'name' => $user->getAttribute('name'),
])), Response::MODEL_MEMBERSHIP);
}, ['request', 'response', 'user', 'projectDB', 'geodb', 'audits']);
});
App::delete('/v1/teams/:teamId/memberships/:inviteId')
->desc('Delete Team Membership')
@ -679,6 +706,10 @@ App::delete('/v1/teams/:teamId/memberships/:inviteId')
->label('sdk.response.model', Response::MODEL_NONE)
->param('teamId', '', new UID(), 'Team unique ID.')
->param('inviteId', '', new UID(), 'Invite unique ID.')
->inject('response')
->inject('projectDB')
->inject('audits')
->inject('events')
->action(function ($teamId, $inviteId, $response, $projectDB, $audits, $events) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -726,4 +757,4 @@ App::delete('/v1/teams/:teamId/memberships/:inviteId')
;
$response->noContent();
}, ['response', 'projectDB', 'audits', 'events']);
});

View file

@ -33,6 +33,8 @@ App::post('/v1/users')
->param('email', '', new Email(), 'User email.')
->param('password', '', new Password(), 'User password. Must be between 6 to 32 chars.')
->param('name', '', new Text(128), 'User name. Max length: 128 chars.', true)
->inject('response')
->inject('projectDB')
->action(function ($email, $password, $name, $response, $projectDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -73,7 +75,7 @@ App::post('/v1/users')
->setStatusCode(Response::STATUS_CODE_CREATED)
->dynamic($user, Response::MODEL_USER)
;
}, ['response', 'projectDB']);
});
App::get('/v1/users')
->desc('List Users')
@ -90,6 +92,8 @@ App::get('/v1/users')
->param('limit', 25, new Range(0, 100), 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true)
->param('offset', 0, new Range(0, 2000), 'Results offset. The default value is 0. Use this param to manage pagination.', true)
->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true)
->inject('response')
->inject('projectDB')
->action(function ($search, $limit, $offset, $orderType, $response, $projectDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -108,7 +112,7 @@ App::get('/v1/users')
'sum' => $projectDB->getSum(),
'users' => $results
]), Response::MODEL_USER_LIST);
}, ['response', 'projectDB']);
});
App::get('/v1/users/:userId')
->desc('Get User')
@ -122,6 +126,8 @@ App::get('/v1/users/:userId')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_USER)
->param('userId', '', new UID(), 'User unique ID.')
->inject('response')
->inject('projectDB')
->action(function ($userId, $response, $projectDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -133,7 +139,7 @@ App::get('/v1/users/:userId')
}
$response->dynamic($user, Response::MODEL_USER);
}, ['response', 'projectDB']);
});
App::get('/v1/users/:userId/prefs')
->desc('Get User Preferences')
@ -147,6 +153,8 @@ App::get('/v1/users/:userId/prefs')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_ANY)
->param('userId', '', new UID(), 'User unique ID.')
->inject('response')
->inject('projectDB')
->action(function ($userId, $response, $projectDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -160,7 +168,7 @@ App::get('/v1/users/:userId/prefs')
$prefs = $user->getAttribute('prefs', '');
$response->dynamic(new Document($prefs), Response::MODEL_ANY);
}, ['response', 'projectDB']);
});
App::get('/v1/users/:userId/sessions')
->desc('Get User Sessions')
@ -174,6 +182,9 @@ App::get('/v1/users/:userId/sessions')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_SESSION_LIST)
->param('userId', '', new UID(), 'User unique ID.')
->inject('response')
->inject('projectDB')
->inject('locale')
->action(function ($userId, $response, $projectDB, $locale) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -220,6 +231,12 @@ App::get('/v1/users/:userId/logs')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_LOG_LIST)
->param('userId', '', new UID(), 'User unique ID.')
->inject('response')
->inject('register')
->inject('project')
->inject('projectDB')
->inject('locale')
->inject('geodb')
->action(function ($userId, $response, $register, $project, $projectDB, $locale, $geodb) {
/** @var Appwrite\Utopia\Response $response */
/** @var Utopia\Registry\Registry $register */
@ -314,7 +331,7 @@ App::get('/v1/users/:userId/logs')
}
$response->dynamic(new Document(['logs' => $output]), Response::MODEL_LOG_LIST);
}, ['response', 'register', 'project', 'projectDB', 'locale', 'geodb']);
});
App::patch('/v1/users/:userId/status')
->desc('Update User Status')
@ -330,6 +347,8 @@ App::patch('/v1/users/:userId/status')
->label('sdk.response.model', Response::MODEL_USER)
->param('userId', '', new UID(), 'User unique ID.')
->param('status', '', new WhiteList([Auth::USER_STATUS_ACTIVATED, Auth::USER_STATUS_BLOCKED, Auth::USER_STATUS_UNACTIVATED], true), 'User Status code. To activate the user pass '.Auth::USER_STATUS_ACTIVATED.', to block the user pass '.Auth::USER_STATUS_BLOCKED.' and for disabling the user pass '.Auth::USER_STATUS_UNACTIVATED)
->inject('response')
->inject('projectDB')
->action(function ($userId, $status, $response, $projectDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -349,7 +368,7 @@ App::patch('/v1/users/:userId/status')
}
$response->dynamic($user, Response::MODEL_USER);
}, ['response', 'projectDB']);
});
App::patch('/v1/users/:userId/prefs')
->desc('Update User Preferences')
@ -364,6 +383,8 @@ App::patch('/v1/users/:userId/prefs')
->label('sdk.response.model', Response::MODEL_ANY)
->param('userId', '', new UID(), 'User unique ID.')
->param('prefs', '', new Assoc(), 'Prefs key-value JSON object.')
->inject('response')
->inject('projectDB')
->action(function ($userId, $prefs, $response, $projectDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -383,7 +404,7 @@ App::patch('/v1/users/:userId/prefs')
}
$response->dynamic(new Document($prefs), Response::MODEL_ANY);
}, ['response', 'projectDB']);
});
App::delete('/v1/users/:userId/sessions/:sessionId')
->desc('Delete User Session')
@ -400,6 +421,9 @@ App::delete('/v1/users/:userId/sessions/:sessionId')
->label('abuse-limit', 100)
->param('userId', '', new UID(), 'User unique ID.')
->param('sessionId', null, new UID(), 'User unique session ID.')
->inject('response')
->inject('projectDB')
->inject('events')
->action(function ($userId, $sessionId, $response, $projectDB, $events) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -426,7 +450,7 @@ App::delete('/v1/users/:userId/sessions/:sessionId')
}
$response->noContent();
}, ['response', 'projectDB', 'events']);
});
App::delete('/v1/users/:userId/sessions')
->desc('Delete User Sessions')
@ -442,6 +466,9 @@ App::delete('/v1/users/:userId/sessions')
->label('sdk.response.model', Response::MODEL_NONE)
->label('abuse-limit', 100)
->param('userId', '', new UID(), 'User unique ID.')
->inject('response')
->inject('projectDB')
->inject('events')
->action(function ($userId, $response, $projectDB, $events) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -466,7 +493,7 @@ App::delete('/v1/users/:userId/sessions')
;
$response->noContent();
}, ['response', 'projectDB', 'events']);
});
App::delete('/v1/users/:userId')
->desc('Delete User')
@ -482,6 +509,10 @@ App::delete('/v1/users/:userId')
->label('sdk.response.model', Response::MODEL_NONE)
->label('abuse-limit', 100)
->param('userId', '', function () {return new UID();}, 'User unique ID.')
->inject('response')
->inject('projectDB')
->inject('events')
->inject('deletes')
->action(function ($userId, $response, $projectDB, $events, $deletes) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
@ -522,4 +553,4 @@ App::delete('/v1/users/:userId')
;
$response->noContent();
}, ['response', 'projectDB', 'events', 'deletes']);
});

View file

@ -407,6 +407,7 @@ App::get('/manifest.json')
->desc('Progressive app manifest file')
->label('scope', 'public')
->label('docs', false)
->inject('response')
->action(function ($response) {
/** @var Appwrite\Utopia\Response $response */
@ -427,30 +428,34 @@ App::get('/manifest.json')
],
],
]);
}, ['response']);
});
App::get('/robots.txt')
->desc('Robots.txt File')
->label('scope', 'public')
->label('docs', false)
->inject('response')
->action(function ($response) {
$template = new View(__DIR__.'/../views/general/robots.phtml');
$response->text($template->render(false));
}, ['response']);
});
App::get('/humans.txt')
->desc('Humans.txt File')
->label('scope', 'public')
->label('docs', false)
->inject('response')
->action(function ($response) {
$template = new View(__DIR__.'/../views/general/humans.phtml');
$response->text($template->render(false));
}, ['response']);
});
App::get('/.well-known/acme-challenge')
->desc('SSL Verification')
->label('scope', 'public')
->label('docs', false)
->inject('request')
->inject('response')
->action(function ($request, $response) {
$base = \realpath(APP_STORAGE_CERTIFICATES);
$path = \str_replace('/.well-known/acme-challenge/', '', $request->getParam('q'));
@ -479,7 +484,7 @@ App::get('/.well-known/acme-challenge')
}
$response->text($content);
}, ['request', 'response']);
});
include_once __DIR__ . '/shared/api.php';
include_once __DIR__ . '/shared/web.php';

View file

@ -174,6 +174,7 @@ App::post('/v1/mock/tests/general/upload')
->param('y', '', new Numeric(), 'Sample numeric param')
->param('z', null, new ArrayList(new Text(256)), 'Sample array param')
->param('file', [], new File(), 'Sample file param', false)
->inject('request')
->action(function ($x, $y, $z, $file, $request) {
/** @var Utopia\Swoole\Request $request */
@ -199,7 +200,7 @@ App::post('/v1/mock/tests/general/upload')
throw new Exception('Wrong file uploaded', 400);
}
}
}, ['request']);
});
App::get('/v1/mock/tests/general/redirect')
->desc('Mock a post request for SDK tests')
@ -210,11 +211,12 @@ App::get('/v1/mock/tests/general/redirect')
->label('sdk.method', 'redirect')
->label('sdk.description', 'Mock a redirect request for SDK tests')
->label('sdk.mock', true)
->inject('response')
->action(function ($response) {
/** @var Appwrite\Utopia\Response $response */
$response->redirect('/v1/mock/tests/general/redirect/done');
}, ['response']);
});
App::get('/v1/mock/tests/general/redirect/done')
->desc('Mock a post request for SDK tests')
@ -237,11 +239,12 @@ App::get('/v1/mock/tests/general/set-cookie')
->label('sdk.method', 'setCookie')
->label('sdk.description', 'Mock a set cookie request for SDK tests')
->label('sdk.mock', true)
->inject('response')
->action(function ($response) {
/** @var Appwrite\Utopia\Response $response */
$response->addCookie('cookieName', 'cookieValue', \time() + 31536000, '/', 'localhost', true, true);
}, ['response']);
});
App::get('/v1/mock/tests/general/get-cookie')
->desc('Mock a cookie request for SDK tests')
@ -252,13 +255,14 @@ App::get('/v1/mock/tests/general/get-cookie')
->label('sdk.method', 'getCookie')
->label('sdk.description', 'Mock a get cookie request for SDK tests')
->label('sdk.mock', true)
->inject('request')
->action(function ($request) {
/** @var Utopia\Swoole\Request $request */
if ($request->getCookie('cookieName', '') !== 'cookieValue') {
throw new Exception('Missing cookie value', 400);
}
}, ['request']);
});
App::get('/v1/mock/tests/general/empty')
->desc('Mock a post request for SDK tests')
@ -269,12 +273,12 @@ App::get('/v1/mock/tests/general/empty')
->label('sdk.method', 'empty')
->label('sdk.description', 'Mock a redirected request for SDK tests')
->label('sdk.mock', true)
->inject('response')
->action(function ($response) {
/** @var Appwrite\Utopia\Response $response */
$response->noContent();
exit();
}, ['response']);
});
App::get('/v1/mock/tests/general/oauth2')
->desc('Mock an OAuth2 login route')
@ -286,11 +290,12 @@ App::get('/v1/mock/tests/general/oauth2')
->param('redirect_uri', '', new Host(['localhost']), 'OAuth2 Redirect URI.') // Important to deny an open redirect attack
->param('scope', '', new Text(100), 'OAuth2 scope list.')
->param('state', '', new Text(1024), 'OAuth2 state.')
->inject('response')
->action(function ($clientId, $redirectURI, $scope, $state, $response) {
/** @var Appwrite\Utopia\Response $response */
$response->redirect($redirectURI.'?'.\http_build_query(['code' => 'abcdef', 'state' => $state]));
}, ['response']);
});
App::get('/v1/mock/tests/general/oauth2/token')
->desc('Mock an OAuth2 login route')
@ -302,6 +307,7 @@ App::get('/v1/mock/tests/general/oauth2/token')
->param('redirect_uri', '', new Host(['localhost']), 'OAuth2 Redirect URI.')
->param('client_secret', '', new Text(100), 'OAuth2 scope list.')
->param('code', '', new Text(100), 'OAuth2 state.')
->inject('response')
->action(function ($clientId, $redirectURI, $clientSecret, $code, $response) {
/** @var Appwrite\Utopia\Response $response */
@ -318,7 +324,7 @@ App::get('/v1/mock/tests/general/oauth2/token')
}
$response->json(['access_token' => '123456']);
}, ['response']);
});
App::get('/v1/mock/tests/general/oauth2/user')
->desc('Mock an OAuth2 user route')
@ -326,6 +332,7 @@ App::get('/v1/mock/tests/general/oauth2/user')
->label('scope', 'public')
->label('docs', false)
->param('token', '', new Text(100), 'OAuth2 Access Token.')
->inject('response')
->action(function ($token, $response) {
/** @var Appwrite\Utopia\Response $response */
@ -338,24 +345,26 @@ App::get('/v1/mock/tests/general/oauth2/user')
'name' => 'User Name',
'email' => 'user@localhost.test',
]);
}, ['response']);
});
App::get('/v1/mock/tests/general/oauth2/success')
->label('scope', 'public')
->groups(['mock'])
->label('docs', false)
->inject('response')
->action(function ($response) {
/** @var Appwrite\Utopia\Response $response */
$response->json([
'result' => 'success',
]);
}, ['response']);
});
App::get('/v1/mock/tests/general/oauth2/failure')
->groups(['mock'])
->label('scope', 'public')
->label('docs', false)
->inject('response')
->action(function ($response) {
/** @var Appwrite\Utopia\Response $response */
@ -364,7 +373,7 @@ App::get('/v1/mock/tests/general/oauth2/failure')
->json([
'result' => 'failure',
]);
}, ['response']);
});
App::shutdown(function($utopia, $response, $request) {
/** @var Utopia\App $utopia */

View file

@ -43,6 +43,7 @@ App::get('/error/:code')
->label('permission', 'public')
->label('scope', 'home')
->param('code', null, new \Utopia\Validator\Numeric(), 'Valid status code number', false)
->inject('layout')
->action(function ($code, $layout) {
/** @var Utopia\View $layout */
@ -55,12 +56,13 @@ App::get('/error/:code')
$layout
->setParam('title', APP_NAME.' - Error')
->setParam('body', $page);
}, ['layout']);
});
App::get('/console')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
->inject('layout')
->action(function ($layout) {
/** @var Utopia\View $layout */
@ -73,12 +75,13 @@ App::get('/console')
$layout
->setParam('title', APP_NAME.' - Console')
->setParam('body', $page);
}, ['layout']);
});
App::get('/console/account')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
->inject('layout')
->action(function ($layout) {
/** @var Utopia\View $layout */
@ -93,12 +96,13 @@ App::get('/console/account')
$layout
->setParam('title', 'Account - '.APP_NAME)
->setParam('body', $page);
}, ['layout']);
});
App::get('/console/notifications')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
->inject('layout')
->action(function ($layout) {
/** @var Utopia\View $layout */
@ -107,12 +111,13 @@ App::get('/console/notifications')
$layout
->setParam('title', APP_NAME.' - Notifications')
->setParam('body', $page);
}, ['layout']);
});
App::get('/console/home')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
->inject('layout')
->action(function ($layout) {
/** @var Utopia\View $layout */
@ -121,12 +126,13 @@ App::get('/console/home')
$layout
->setParam('title', APP_NAME.' - Console')
->setParam('body', $page);
}, ['layout']);
});
App::get('/console/settings')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
->inject('layout')
->action(function ($layout) {
/** @var Utopia\View $layout */
@ -142,12 +148,13 @@ App::get('/console/settings')
$layout
->setParam('title', APP_NAME.' - Settings')
->setParam('body', $page);
}, ['layout']);
});
App::get('/console/webhooks')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
->inject('layout')
->action(function ($layout) {
/** @var Utopia\View $layout */
@ -160,12 +167,13 @@ App::get('/console/webhooks')
$layout
->setParam('title', APP_NAME.' - Webhooks')
->setParam('body', $page);
}, ['layout']);
});
App::get('/console/keys')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
->inject('layout')
->action(function ($layout) {
/** @var Utopia\View $layout */
@ -177,12 +185,13 @@ App::get('/console/keys')
$layout
->setParam('title', APP_NAME.' - API Keys')
->setParam('body', $page);
}, ['layout']);
});
App::get('/console/tasks')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
->inject('layout')
->action(function ($layout) {
/** @var Utopia\View $layout */
@ -191,12 +200,13 @@ App::get('/console/tasks')
$layout
->setParam('title', APP_NAME.' - Tasks')
->setParam('body', $page);
}, ['layout']);
});
App::get('/console/database')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
->inject('layout')
->action(function ($layout) {
/** @var Utopia\View $layout */
@ -205,13 +215,16 @@ App::get('/console/database')
$layout
->setParam('title', APP_NAME.' - Database')
->setParam('body', $page);
}, ['layout']);
});
App::get('/console/database/collection')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
->param('id', '', new UID(), 'Collection unique ID.')
->inject('response')
->inject('layout')
->inject('projectDB')
->action(function ($id, $response, $layout, $projectDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Utopia\View $layout */
@ -241,13 +254,15 @@ App::get('/console/database/collection')
->addHeader('Expires', 0)
->addHeader('Pragma', 'no-cache')
;
}, ['response', 'layout', 'projectDB']);
});
App::get('/console/database/document')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
->param('collection', '', new UID(), 'Collection unique ID.')
->inject('layout')
->inject('projectDB')
->action(function ($collection, $layout, $projectDB) {
/** @var Utopia\View $layout */
/** @var Appwrite\Database\Database $projectDB */
@ -274,12 +289,13 @@ App::get('/console/database/document')
$layout
->setParam('title', APP_NAME.' - Database Document')
->setParam('body', $page);
}, ['layout', 'projectDB']);
});
App::get('/console/storage')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
->inject('layout')
->action(function ($layout) {
/** @var Utopia\View $layout */
$page = new View(__DIR__.'/../../views/console/storage/index.phtml');
@ -293,12 +309,13 @@ App::get('/console/storage')
$layout
->setParam('title', APP_NAME.' - Storage')
->setParam('body', $page);
}, ['layout']);
});
App::get('/console/users')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
->inject('layout')
->action(function ($layout) {
/** @var Utopia\View $layout */
@ -309,12 +326,13 @@ App::get('/console/users')
$layout
->setParam('title', APP_NAME.' - Users')
->setParam('body', $page);
}, ['layout']);
});
App::get('/console/users/user')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
->inject('layout')
->action(function ($layout) {
/** @var Utopia\View $layout */
@ -323,12 +341,13 @@ App::get('/console/users/user')
$layout
->setParam('title', APP_NAME.' - User')
->setParam('body', $page);
}, ['layout']);
});
App::get('/console/users/teams/team')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
->inject('layout')
->action(function ($layout) {
/** @var Utopia\View $layout */
@ -337,13 +356,14 @@ App::get('/console/users/teams/team')
$layout
->setParam('title', APP_NAME.' - Team')
->setParam('body', $page);
}, ['layout']);
});
App::get('/console/functions')
->groups(['web', 'console'])
->desc('Platform console project functions')
->label('permission', 'public')
->label('scope', 'console')
->inject('layout')
->action(function ($layout) {
$page = new View(__DIR__.'/../../views/console/functions/index.phtml');
@ -354,13 +374,14 @@ App::get('/console/functions')
$layout
->setParam('title', APP_NAME.' - Functions')
->setParam('body', $page);
}, ['layout']);
});
App::get('/console/functions/function')
->groups(['web', 'console'])
->desc('Platform console project function')
->label('permission', 'public')
->label('scope', 'console')
->inject('layout')
->action(function ($layout) {
$page = new View(__DIR__.'/../../views/console/functions/function.phtml');
@ -374,13 +395,14 @@ App::get('/console/functions/function')
$layout
->setParam('title', APP_NAME.' - Function')
->setParam('body', $page);
}, ['layout']);
});
App::get('/console/version')
->groups(['web', 'console'])
->desc('Check for new version')
->label('permission', 'public')
->label('scope', 'console')
->inject('response')
->action(function ($response) {
try {
$version = \json_decode(@\file_get_contents(App::getEnv('_APP_HOME', 'http://localhost').'/v1/health/version'), true);
@ -393,4 +415,4 @@ App::get('/console/version')
} catch (\Throwable $th) {
throw new Exception('Failed to check for a newer version', 500);
}
}, ['response']);
});

View file

@ -41,16 +41,18 @@ App::get('/')
->groups(['web', 'home'])
->label('permission', 'public')
->label('scope', 'home')
->inject('response')
->action(function ($response) {
/** @var Appwrite\Utopia\Response $response */
$response->redirect('/auth/signin');
}, ['response']);
});
App::get('/auth/signin')
->groups(['web', 'home'])
->label('permission', 'public')
->label('scope', 'home')
->inject('layout')
->action(function ($layout) {
/** @var Utopia\View $layout */
@ -59,12 +61,13 @@ App::get('/auth/signin')
$layout
->setParam('title', 'Sign In - '.APP_NAME)
->setParam('body', $page);
}, ['layout']);
});
App::get('/auth/signup')
->groups(['web', 'home'])
->label('permission', 'public')
->label('scope', 'home')
->inject('layout')
->action(function ($layout) {
/** @var Utopia\View $layout */
$page = new View(__DIR__.'/../../views/home/auth/signup.phtml');
@ -72,12 +75,13 @@ App::get('/auth/signup')
$layout
->setParam('title', 'Sign Up - '.APP_NAME)
->setParam('body', $page);
}, ['layout']);
});
App::get('/auth/recovery')
->groups(['web', 'home'])
->label('permission', 'public')
->label('scope', 'home')
->inject('layout')
->action(function ($layout) {
/** @var Utopia\View $layout */
@ -86,12 +90,13 @@ App::get('/auth/recovery')
$layout
->setParam('title', 'Password Recovery - '.APP_NAME)
->setParam('body', $page);
}, ['layout']);
});
App::get('/auth/confirm')
->groups(['web', 'home'])
->label('permission', 'public')
->label('scope', 'home')
->inject('layout')
->action(function ($layout) {
/** @var Utopia\View $layout */
@ -100,12 +105,13 @@ App::get('/auth/confirm')
$layout
->setParam('title', 'Account Confirmation - '.APP_NAME)
->setParam('body', $page);
}, ['layout']);
});
App::get('/auth/join')
->groups(['web', 'home'])
->label('permission', 'public')
->label('scope', 'home')
->inject('layout')
->action(function ($layout) {
/** @var Utopia\View $layout */
@ -114,12 +120,13 @@ App::get('/auth/join')
$layout
->setParam('title', 'Invitation - '.APP_NAME)
->setParam('body', $page);
}, ['layout']);
});
App::get('/auth/recovery/reset')
->groups(['web', 'home'])
->label('permission', 'public')
->label('scope', 'home')
->inject('layout')
->action(function ($layout) {
/** @var Utopia\View $layout */
@ -128,12 +135,13 @@ App::get('/auth/recovery/reset')
$layout
->setParam('title', 'Password Reset - '.APP_NAME)
->setParam('body', $page);
}, ['layout']);
});
App::get('/auth/oauth2/success')
->groups(['web', 'home'])
->label('permission', 'public')
->label('scope', 'home')
->inject('layout')
->action(function ($layout) {
/** @var Utopia\View $layout */
@ -145,12 +153,13 @@ App::get('/auth/oauth2/success')
->setParam('header', [])
->setParam('footer', [])
;
}, ['layout']);
});
App::get('/auth/oauth2/failure')
->groups(['web', 'home'])
->label('permission', 'public')
->label('scope', 'home')
->inject('layout')
->action(function ($layout) {
/** @var Utopia\View $layout */
@ -162,13 +171,14 @@ App::get('/auth/oauth2/failure')
->setParam('header', [])
->setParam('footer', [])
;
}, ['layout']);
});
App::get('/error/:code')
->groups(['web', 'home'])
->label('permission', 'public')
->label('scope', 'home')
->param('code', null, new \Utopia\Validator\Numeric(), 'Valid status code number', false)
->inject('layout')
->action(function ($code, $layout) {
/** @var Utopia\View $layout */
@ -181,7 +191,7 @@ App::get('/error/:code')
$layout
->setParam('title', 'Error'.' - '.APP_NAME)
->setParam('body', $page);
}, ['layout']);
}, ['']);
App::get('/specs/:format')
->groups(['web', 'home'])
@ -190,6 +200,9 @@ App::get('/specs/:format')
->param('format', 'swagger2', new WhiteList(['swagger2', 'open-api3'], true), 'Spec format.', true)
->param('platform', APP_PLATFORM_CLIENT, new WhiteList([APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER, APP_PLATFORM_CONSOLE], true), 'Choose target platform.', true)
->param('tests', 0, function () {return new Range(0, 1);}, 'Include only test services.', true)
->inject('utopia')
->inject('request')
->inject('response')
->action(function ($format, $platform, $tests, $utopia, $request, $response) {
/** @var Utopia\App $utopia */
/** @var Utopia\Swoole\Request $request */
@ -347,4 +360,4 @@ App::get('/specs/:format')
$response
->json($specs->parse());
}, ['utopia', 'request', 'response']);
});

View file

@ -34,7 +34,7 @@
"appwrite/php-clamav": "1.0.*",
"utopia-php/framework": "0.9.8",
"utopia-php/framework": "0.10.0",
"utopia-php/abuse": "0.2.*",
"utopia-php/audit": "0.3.*",
"utopia-php/cache": "0.2.*",

161
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "00d365ae66b44a9f8457822862f6e470",
"content-hash": "ec0368f495f4b9126f378e0057679100",
"packages": [
{
"name": "appwrite/php-clamav",
@ -1427,16 +1427,16 @@
},
{
"name": "utopia-php/framework",
"version": "0.9.8",
"version": "0.10.0",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/framework.git",
"reference": "4caec144554f028b3ec710a0cdd4f75193f01285"
"reference": "65909bdb24ef6b6c6751abfdea90caf96bbc6c50"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/framework/zipball/4caec144554f028b3ec710a0cdd4f75193f01285",
"reference": "4caec144554f028b3ec710a0cdd4f75193f01285",
"url": "https://api.github.com/repos/utopia-php/framework/zipball/65909bdb24ef6b6c6751abfdea90caf96bbc6c50",
"reference": "65909bdb24ef6b6c6751abfdea90caf96bbc6c50",
"shasum": ""
},
"require": {
@ -1470,9 +1470,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/framework/issues",
"source": "https://github.com/utopia-php/framework/tree/0.9.8"
"source": "https://github.com/utopia-php/framework/tree/0.10.0"
},
"time": "2020-11-11T20:34:58+00:00"
"time": "2020-12-26T12:02:39+00:00"
},
{
"name": "utopia-php/locale",
@ -2999,16 +2999,16 @@
},
{
"name": "phpunit/php-code-coverage",
"version": "dev-master",
"version": "9.2.x-dev",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "3952570aeea0f38f8523a4bbb647a6d45797220c"
"reference": "ad44fae76b874e7d49afb6923a66591e0a94bef6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/3952570aeea0f38f8523a4bbb647a6d45797220c",
"reference": "3952570aeea0f38f8523a4bbb647a6d45797220c",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ad44fae76b874e7d49afb6923a66591e0a94bef6",
"reference": "ad44fae76b874e7d49afb6923a66591e0a94bef6",
"shasum": ""
},
"require": {
@ -3033,7 +3033,6 @@
"ext-pcov": "*",
"ext-xdebug": "*"
},
"default-branch": true,
"type": "library",
"extra": {
"branch-alias": {
@ -3073,7 +3072,7 @@
"type": "github"
}
],
"time": "2020-12-18T12:30:12+00:00"
"time": "2020-12-24T12:26:22+00:00"
},
{
"name": "phpunit/php-file-iterator",
@ -3081,12 +3080,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
"reference": "20954647176fc684ea80b3801d73eab6d3734b58"
"reference": "544be757d192233486ad9119dcb297ebbf5f2dd4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/20954647176fc684ea80b3801d73eab6d3734b58",
"reference": "20954647176fc684ea80b3801d73eab6d3734b58",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/544be757d192233486ad9119dcb297ebbf5f2dd4",
"reference": "544be757d192233486ad9119dcb297ebbf5f2dd4",
"shasum": ""
},
"require": {
@ -3134,7 +3133,7 @@
"type": "github"
}
],
"time": "2020-12-18T12:31:37+00:00"
"time": "2020-12-24T12:27:43+00:00"
},
{
"name": "phpunit/php-invoker",
@ -3142,12 +3141,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-invoker.git",
"reference": "af6fff7777c93ca23726690b75e6b35936619a2a"
"reference": "05210af8d0ab68c811ae61a4bc42b066d62b88a0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/af6fff7777c93ca23726690b75e6b35936619a2a",
"reference": "af6fff7777c93ca23726690b75e6b35936619a2a",
"url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/05210af8d0ab68c811ae61a4bc42b066d62b88a0",
"reference": "05210af8d0ab68c811ae61a4bc42b066d62b88a0",
"shasum": ""
},
"require": {
@ -3198,7 +3197,7 @@
"type": "github"
}
],
"time": "2020-12-09T08:38:35+00:00"
"time": "2020-12-24T12:27:51+00:00"
},
{
"name": "phpunit/php-text-template",
@ -3206,12 +3205,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-text-template.git",
"reference": "1bf5e9937d86cfe12c90018ccb081dfb0ceee770"
"reference": "c1abda6e0590f8e7138eb48ade2f0b21a5c4257b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/1bf5e9937d86cfe12c90018ccb081dfb0ceee770",
"reference": "1bf5e9937d86cfe12c90018ccb081dfb0ceee770",
"url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/c1abda6e0590f8e7138eb48ade2f0b21a5c4257b",
"reference": "c1abda6e0590f8e7138eb48ade2f0b21a5c4257b",
"shasum": ""
},
"require": {
@ -3258,7 +3257,7 @@
"type": "github"
}
],
"time": "2020-12-18T12:32:19+00:00"
"time": "2020-12-24T12:28:23+00:00"
},
{
"name": "phpunit/php-timer",
@ -3266,12 +3265,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-timer.git",
"reference": "fe5620838118e9e4cef2ed462923e1f59016e8f4"
"reference": "59e401088c91efeb76150f0a301aa79e3ac95fd1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/fe5620838118e9e4cef2ed462923e1f59016e8f4",
"reference": "fe5620838118e9e4cef2ed462923e1f59016e8f4",
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/59e401088c91efeb76150f0a301aa79e3ac95fd1",
"reference": "59e401088c91efeb76150f0a301aa79e3ac95fd1",
"shasum": ""
},
"require": {
@ -3318,7 +3317,7 @@
"type": "github"
}
],
"time": "2020-12-18T12:31:54+00:00"
"time": "2020-12-24T12:27:59+00:00"
},
{
"name": "phpunit/phpunit",
@ -3483,12 +3482,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/cli-parser.git",
"reference": "b887289b80dd8394719d40e6e7fcef74203db570"
"reference": "7605547e80bf845bc2c1b2cc3f8ac0f5574caa63"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/b887289b80dd8394719d40e6e7fcef74203db570",
"reference": "b887289b80dd8394719d40e6e7fcef74203db570",
"url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/7605547e80bf845bc2c1b2cc3f8ac0f5574caa63",
"reference": "7605547e80bf845bc2c1b2cc3f8ac0f5574caa63",
"shasum": ""
},
"require": {
@ -3532,7 +3531,7 @@
"type": "github"
}
],
"time": "2020-12-18T12:32:47+00:00"
"time": "2020-12-24T12:28:52+00:00"
},
{
"name": "sebastian/code-unit",
@ -3596,12 +3595,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git",
"reference": "2e42a717208897d00b868a7086776ac89f676d0f"
"reference": "f861b90785c30dc0743554f0e615d8f950dc8e9d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/2e42a717208897d00b868a7086776ac89f676d0f",
"reference": "2e42a717208897d00b868a7086776ac89f676d0f",
"url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/f861b90785c30dc0743554f0e615d8f950dc8e9d",
"reference": "f861b90785c30dc0743554f0e615d8f950dc8e9d",
"shasum": ""
},
"require": {
@ -3644,7 +3643,7 @@
"type": "github"
}
],
"time": "2020-12-18T12:30:29+00:00"
"time": "2020-12-24T12:26:38+00:00"
},
{
"name": "sebastian/comparator",
@ -3652,12 +3651,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/comparator.git",
"reference": "f8a802b2820f3ed7aa72d684cc7342edef07ee90"
"reference": "1cfe9edf7ec9e4c18e54bb259110a053d09a899f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/f8a802b2820f3ed7aa72d684cc7342edef07ee90",
"reference": "f8a802b2820f3ed7aa72d684cc7342edef07ee90",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1cfe9edf7ec9e4c18e54bb259110a053d09a899f",
"reference": "1cfe9edf7ec9e4c18e54bb259110a053d09a899f",
"shasum": ""
},
"require": {
@ -3719,7 +3718,7 @@
"type": "github"
}
],
"time": "2020-12-18T12:30:37+00:00"
"time": "2020-12-24T12:38:43+00:00"
},
{
"name": "sebastian/complexity",
@ -3727,12 +3726,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/complexity.git",
"reference": "431f6c8278fadf1f978a367fb5b50d3fe79257a4"
"reference": "23030bf3d3722767fdc5f8f2d2d99b03f4e58122"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/431f6c8278fadf1f978a367fb5b50d3fe79257a4",
"reference": "431f6c8278fadf1f978a367fb5b50d3fe79257a4",
"url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/23030bf3d3722767fdc5f8f2d2d99b03f4e58122",
"reference": "23030bf3d3722767fdc5f8f2d2d99b03f4e58122",
"shasum": ""
},
"require": {
@ -3777,7 +3776,7 @@
"type": "github"
}
],
"time": "2020-12-18T12:32:27+00:00"
"time": "2020-12-24T12:28:32+00:00"
},
{
"name": "sebastian/diff",
@ -3785,12 +3784,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/diff.git",
"reference": "ee2368af73650a4bb1af6bf9e958344001d7e68f"
"reference": "02178c586d5fbd59d348798d7122237a2907f8a4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ee2368af73650a4bb1af6bf9e958344001d7e68f",
"reference": "ee2368af73650a4bb1af6bf9e958344001d7e68f",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/02178c586d5fbd59d348798d7122237a2907f8a4",
"reference": "02178c586d5fbd59d348798d7122237a2907f8a4",
"shasum": ""
},
"require": {
@ -3844,7 +3843,7 @@
"type": "github"
}
],
"time": "2020-12-18T12:30:46+00:00"
"time": "2020-12-24T12:26:54+00:00"
},
{
"name": "sebastian/environment",
@ -3852,12 +3851,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/environment.git",
"reference": "c6910747e97d6838d06dc72e2ea9f60b24f574b9"
"reference": "7bb5a20ec06e366cb75b0e126169649c62b397b1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/c6910747e97d6838d06dc72e2ea9f60b24f574b9",
"reference": "c6910747e97d6838d06dc72e2ea9f60b24f574b9",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/7bb5a20ec06e366cb75b0e126169649c62b397b1",
"reference": "7bb5a20ec06e366cb75b0e126169649c62b397b1",
"shasum": ""
},
"require": {
@ -3908,7 +3907,7 @@
"type": "github"
}
],
"time": "2020-12-18T12:30:54+00:00"
"time": "2020-12-24T12:27:03+00:00"
},
{
"name": "sebastian/exporter",
@ -3916,12 +3915,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git",
"reference": "25bad5473a55028cff0d58a55812ecfd52344abd"
"reference": "91975a2dbcf4a89184d9e4143c06b88d89644b58"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/25bad5473a55028cff0d58a55812ecfd52344abd",
"reference": "25bad5473a55028cff0d58a55812ecfd52344abd",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/91975a2dbcf4a89184d9e4143c06b88d89644b58",
"reference": "91975a2dbcf4a89184d9e4143c06b88d89644b58",
"shasum": ""
},
"require": {
@ -3986,7 +3985,7 @@
"type": "github"
}
],
"time": "2020-12-18T12:31:04+00:00"
"time": "2020-12-24T12:27:11+00:00"
},
{
"name": "sebastian/global-state",
@ -3994,12 +3993,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/global-state.git",
"reference": "27db5bebcc77aa943d8e30e0346f231eaeb286ce"
"reference": "0471b24bddeb05ffd0a5edc6837796f339068c25"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/27db5bebcc77aa943d8e30e0346f231eaeb286ce",
"reference": "27db5bebcc77aa943d8e30e0346f231eaeb286ce",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0471b24bddeb05ffd0a5edc6837796f339068c25",
"reference": "0471b24bddeb05ffd0a5edc6837796f339068c25",
"shasum": ""
},
"require": {
@ -4051,7 +4050,7 @@
"type": "github"
}
],
"time": "2020-12-18T12:31:12+00:00"
"time": "2020-12-24T12:27:19+00:00"
},
{
"name": "sebastian/lines-of-code",
@ -4059,12 +4058,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/lines-of-code.git",
"reference": "d998f7a3b6abedf9d2ed93c7b3f7ffc6cf0f6acb"
"reference": "219c932af1aeee0b4eccbc53af2181ff50e14b24"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/d998f7a3b6abedf9d2ed93c7b3f7ffc6cf0f6acb",
"reference": "d998f7a3b6abedf9d2ed93c7b3f7ffc6cf0f6acb",
"url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/219c932af1aeee0b4eccbc53af2181ff50e14b24",
"reference": "219c932af1aeee0b4eccbc53af2181ff50e14b24",
"shasum": ""
},
"require": {
@ -4109,7 +4108,7 @@
"type": "github"
}
],
"time": "2020-12-18T12:32:36+00:00"
"time": "2020-12-24T12:28:42+00:00"
},
{
"name": "sebastian/object-enumerator",
@ -4117,12 +4116,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/object-enumerator.git",
"reference": "31a6d04d6b49c0b6a1499eaac1a395a766a4176b"
"reference": "da36684b10f17db8718e314fa8d84b2e0ed7132e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/31a6d04d6b49c0b6a1499eaac1a395a766a4176b",
"reference": "31a6d04d6b49c0b6a1499eaac1a395a766a4176b",
"url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/da36684b10f17db8718e314fa8d84b2e0ed7132e",
"reference": "da36684b10f17db8718e314fa8d84b2e0ed7132e",
"shasum": ""
},
"require": {
@ -4167,7 +4166,7 @@
"type": "github"
}
],
"time": "2020-12-18T12:31:20+00:00"
"time": "2020-12-24T12:27:27+00:00"
},
{
"name": "sebastian/object-reflector",
@ -4175,12 +4174,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/object-reflector.git",
"reference": "b111d3533226d210f133d7b7e45783765794067f"
"reference": "6717d193da503616e69462cf98e2af3f4443335d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b111d3533226d210f133d7b7e45783765794067f",
"reference": "b111d3533226d210f133d7b7e45783765794067f",
"url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/6717d193da503616e69462cf98e2af3f4443335d",
"reference": "6717d193da503616e69462cf98e2af3f4443335d",
"shasum": ""
},
"require": {
@ -4223,7 +4222,7 @@
"type": "github"
}
],
"time": "2020-12-18T12:31:28+00:00"
"time": "2020-12-24T12:27:35+00:00"
},
{
"name": "sebastian/recursion-context",
@ -4231,12 +4230,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/recursion-context.git",
"reference": "d1e4fef0e0cf6c2becafc1f53169339a6e426fb8"
"reference": "cee249a3e471aa870067fa6155991230c7507924"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/d1e4fef0e0cf6c2becafc1f53169339a6e426fb8",
"reference": "d1e4fef0e0cf6c2becafc1f53169339a6e426fb8",
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cee249a3e471aa870067fa6155991230c7507924",
"reference": "cee249a3e471aa870067fa6155991230c7507924",
"shasum": ""
},
"require": {
@ -4287,7 +4286,7 @@
"type": "github"
}
],
"time": "2020-12-18T12:32:02+00:00"
"time": "2020-12-24T12:28:07+00:00"
},
{
"name": "sebastian/resource-operations",
@ -4351,12 +4350,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/type.git",
"reference": "a2baeeb40f81ad4b7348975332c6825b8f759871"
"reference": "67bfce3beb94968d175fdf117b80fc9a6b60bdd0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/type/zipball/a2baeeb40f81ad4b7348975332c6825b8f759871",
"reference": "a2baeeb40f81ad4b7348975332c6825b8f759871",
"url": "https://api.github.com/repos/sebastianbergmann/type/zipball/67bfce3beb94968d175fdf117b80fc9a6b60bdd0",
"reference": "67bfce3beb94968d175fdf117b80fc9a6b60bdd0",
"shasum": ""
},
"require": {
@ -4400,7 +4399,7 @@
"type": "github"
}
],
"time": "2020-12-18T12:32:10+00:00"
"time": "2020-12-24T12:28:15+00:00"
},
{
"name": "sebastian/version",

View file

@ -178,7 +178,7 @@ class OpenAPI3 extends Format
$bodyRequired = [];
foreach ($route->getParams() as $name => $param) { // Set params
$validator = (\is_callable($param['validator'])) ? call_user_func_array($param['validator'], $this->app->getResources($param['resources'])) : $param['validator']; /* @var $validator \Utopia\Validator */
$validator = (\is_callable($param['validator'])) ? call_user_func_array($param['validator'], $this->app->getResources($param['injections'])) : $param['validator']; /* @var $validator \Utopia\Validator */
$node = [
'name' => $name,

View file

@ -170,7 +170,7 @@ class Swagger2 extends Format
$bodyRequired = [];
foreach ($route->getParams() as $name => $param) { // Set params
$validator = (\is_callable($param['validator'])) ? call_user_func_array($param['validator'], $this->app->getResources($param['resources'])) : $param['validator']; /* @var $validator \Utopia\Validator */
$validator = (\is_callable($param['validator'])) ? call_user_func_array($param['validator'], $this->app->getResources($param['injections'])) : $param['validator']; /* @var $validator \Utopia\Validator */
$node = [
'name' => $name,

View file

@ -59,7 +59,7 @@ class HealthCustomServerTest extends Scope
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/health/db', array_merge([
$response = $this->client->call(Client::METHOD_GET, '/health/cache', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);