Improve params readability

This commit is contained in:
Khushboo Verma 2025-03-13 12:16:17 +05:30
parent a840d9de20
commit f2ba319e6e
37 changed files with 405 additions and 79 deletions

View file

@ -59,8 +59,12 @@ class Get extends Action
->callback([$this, 'action']);
}
public function action(string $value, string $type, Response $response, Database $dbForPlatform)
{
public function action(
string $value,
string $type,
Response $response,
Database $dbForPlatform
) {
if ($type === 'rules') {
$validator = new Domain($value);

View file

@ -87,8 +87,21 @@ class Create extends Action
->callback([$this, 'action']);
}
public function action(string $functionId, ?string $entrypoint, ?string $commands, mixed $code, mixed $activate, Request $request, Response $response, Database $dbForProject, Event $queueForEvents, Document $project, Device $deviceForFunctions, Device $deviceForLocal, Build $queueForBuilds)
{
public function action(
string $functionId,
?string $entrypoint,
?string $commands,
mixed $code,
mixed $activate,
Request $request,
Response $response,
Database $dbForProject,
Event $queueForEvents,
Document $project,
Device $deviceForFunctions,
Device $deviceForLocal,
Build $queueForBuilds
) {
$activate = \strval($activate) === 'true' || \strval($activate) === '1';
$function = $dbForProject->getDocument('functions', $functionId);

View file

@ -63,8 +63,15 @@ class Delete extends Action
->callback([$this, 'action']);
}
public function action(string $functionId, string $deploymentId, Response $response, Database $dbForProject, DeleteEvent $queueForDeletes, Event $queueForEvents, Device $deviceForFunctions)
{
public function action(
string $functionId,
string $deploymentId,
Response $response,
Database $dbForProject,
DeleteEvent $queueForDeletes,
Event $queueForEvents,
Device $deviceForFunctions
) {
$function = $dbForProject->getDocument('functions', $functionId);
if ($function->isEmpty()) {
throw new Exception(Exception::FUNCTION_NOT_FOUND);

View file

@ -31,7 +31,7 @@ class Get extends Action
$this
->setHttpMethod(Action::HTTP_REQUEST_METHOD_GET)
->setHttpPath('/v1/functions/:functionId/deployments/:deploymentId/download')
->httpAlias('/v1/functions/:functionId/deployments/:deploymentId/build/download', [ 'type' => 'output' ])
->httpAlias('/v1/functions/:functionId/deployments/:deploymentId/build/download', ['type' => 'output'])
->groups(['api', 'functions'])
->desc('Download deployment')
->label('scope', 'functions.read')
@ -63,8 +63,16 @@ class Get extends Action
->callback([$this, 'action']);
}
public function action(string $functionId, string $deploymentId, string $type, Response $response, Request $request, Database $dbForProject, Device $deviceForFunctions, Device $deviceForBuilds)
{
public function action(
string $functionId,
string $deploymentId,
string $type,
Response $response,
Request $request,
Database $dbForProject,
Device $deviceForFunctions,
Device $deviceForBuilds
) {
$function = $dbForProject->getDocument('functions', $functionId);
if ($function->isEmpty()) {
throw new Exception(Exception::FUNCTION_NOT_FOUND);

View file

@ -64,8 +64,16 @@ class Create extends Action
->callback([$this, 'action']);
}
public function action(string $functionId, string $deploymentId, string $buildId, Response $response, Database $dbForProject, Event $queueForEvents, Build $queueForBuilds, Device $deviceForFunctions)
{
public function action(
string $functionId,
string $deploymentId,
string $buildId,
Response $response,
Database $dbForProject,
Event $queueForEvents,
Build $queueForBuilds,
Device $deviceForFunctions
) {
$function = $dbForProject->getDocument('functions', $functionId);
if ($function->isEmpty()) {

View file

@ -51,8 +51,12 @@ class Get extends Action
->callback([$this, 'action']);
}
public function action(string $functionId, string $deploymentId, Response $response, Database $dbForProject)
{
public function action(
string $functionId,
string $deploymentId,
Response $response,
Database $dbForProject
) {
$function = $dbForProject->getDocument('functions', $functionId);
if ($function->isEmpty()) {

View file

@ -61,8 +61,14 @@ class Update extends Action
->callback([$this, 'action']);
}
public function action(string $functionId, string $deploymentId, Response $response, Database $dbForProject, Document $project, Event $queueForEvents)
{
public function action(
string $functionId,
string $deploymentId,
Response $response,
Database $dbForProject,
Document $project,
Event $queueForEvents
) {
$function = $dbForProject->getDocument('functions', $functionId);
if ($function->isEmpty()) {

View file

@ -77,8 +77,22 @@ class Create extends Base
->callback([$this, 'action']);
}
public function action(string $functionId, string $repository, string $owner, string $rootDirectory, string $version, bool $activate, Request $request, Response $response, Database $dbForProject, Database $dbForPlatform, Event $queueForEvents, Document $project, Build $queueForBuilds, GitHub $github)
{
public function action(
string $functionId,
string $repository,
string $owner,
string $rootDirectory,
string $version,
bool $activate,
Request $request,
Response $response,
Database $dbForProject,
Database $dbForPlatform,
Event $queueForEvents,
Document $project,
Build $queueForBuilds,
GitHub $github
) {
$function = $dbForProject->getDocument('functions', $functionId);
if ($function->isEmpty()) {
@ -108,8 +122,8 @@ class Create extends Base
);
$queueForEvents
->setParam('functionId', $function->getId())
->setParam('deploymentId', $deployment->getId());
->setParam('functionId', $function->getId())
->setParam('deploymentId', $deployment->getId());
$response
->setStatusCode(Response::STATUS_CODE_ACCEPTED)

View file

@ -74,8 +74,20 @@ class Create extends Base
->callback([$this, 'action']);
}
public function action(string $functionId, string $type, string $reference, bool $activate, Request $request, Response $response, Database $dbForProject, Database $dbForPlatform, Document $project, Event $queueForEvents, Build $queueForBuilds, GitHub $github)
{
public function action(
string $functionId,
string $type,
string $reference,
bool $activate,
Request $request,
Response $response,
Database $dbForProject,
Database $dbForPlatform,
Document $project,
Event $queueForEvents,
Build $queueForBuilds,
GitHub $github
) {
$function = $dbForProject->getDocument('functions', $functionId);
if ($function->isEmpty()) {

View file

@ -58,8 +58,13 @@ class XList extends Action
->callback([$this, 'action']);
}
public function action(string $functionId, array $queries, string $search, Response $response, Database $dbForProject)
{
public function action(
string $functionId,
array $queries,
string $search,
Response $response,
Database $dbForProject
) {
$function = $dbForProject->getDocument('functions', $functionId);
if ($function->isEmpty()) {

View file

@ -96,8 +96,25 @@ class Create extends Base
->callback([$this, 'action']);
}
public function action(string $functionId, string $body, mixed $async, string $path, string $method, mixed $headers, ?string $scheduledAt, Response $response, Request $request, Document $project, Database $dbForProject, Database $dbForPlatform, Document $user, Event $queueForEvents, StatsUsage $queueForStatsUsage, Func $queueForFunctions, Reader $geodb)
{
public function action(
string $functionId,
string $body,
mixed $async,
string $path,
string $method,
mixed $headers,
?string $scheduledAt,
Response $response,
Request $request,
Document $project,
Database $dbForProject,
Database $dbForPlatform,
Document $user,
Event $queueForEvents,
StatsUsage $queueForStatsUsage,
Func $queueForFunctions,
Reader $geodb
) {
$async = \strval($async) === 'true' || \strval($async) === '1';
if (!$async && !is_null($scheduledAt)) {

View file

@ -64,8 +64,14 @@ class Delete extends Base
->callback([$this, 'action']);
}
public function action(string $functionId, string $executionId, Response $response, Database $dbForProject, Database $dbForPlatform, Event $queueForEvents)
{
public function action(
string $functionId,
string $executionId,
Response $response,
Database $dbForProject,
Database $dbForPlatform,
Event $queueForEvents
) {
$function = $dbForProject->getDocument('functions', $functionId);
if ($function->isEmpty()) {

View file

@ -54,8 +54,12 @@ class Get extends Base
->callback([$this, 'action']);
}
public function action(string $functionId, string $executionId, Response $response, Database $dbForProject)
{
public function action(
string $functionId,
string $executionId,
Response $response,
Database $dbForProject
) {
$function = Authorization::skip(fn () => $dbForProject->getDocument('functions', $functionId));
$isAPIKey = Auth::isAppUser(Authorization::getRoles());

View file

@ -59,8 +59,12 @@ class XList extends Base
->callback([$this, 'action']);
}
public function action(string $functionId, array $queries, Response $response, Database $dbForProject)
{
public function action(
string $functionId,
array $queries,
Response $response,
Database $dbForProject
) {
$function = Authorization::skip(fn () => $dbForProject->getDocument('functions', $functionId));
$isAPIKey = Auth::isAppUser(Authorization::getRoles());

View file

@ -100,8 +100,32 @@ class Create extends Base
->callback([$this, 'action']);
}
public function action(string $functionId, string $name, string $runtime, array $execute, array $events, string $schedule, int $timeout, bool $enabled, bool $logging, string $entrypoint, string $commands, array $scopes, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $specification, Response $response, Database $dbForProject, callable $timelimit, Document $project, Event $queueForEvents, Database $dbForPlatform)
{
public function action(
string $functionId,
string $name,
string $runtime,
array $execute,
array $events,
string $schedule,
int $timeout,
bool $enabled,
bool $logging,
string $entrypoint,
string $commands,
array $scopes,
string $installationId,
string $providerRepositoryId,
string $providerBranch,
bool $providerSilentMode,
string $providerRootDirectory,
string $specification,
Response $response,
Database $dbForProject,
callable $timelimit,
Document $project,
Event $queueForEvents,
Database $dbForPlatform
) {
// Temporary abuse check
$abuseCheck = function () use ($project, $timelimit, $response) {

View file

@ -63,8 +63,14 @@ class Delete extends Base
->callback([$this, 'action']);
}
public function action(string $functionId, Response $response, Database $dbForProject, DeleteEvent $queueForDeletes, Event $queueForEvents, Database $dbForPlatform)
{
public function action(
string $functionId,
Response $response,
Database $dbForProject,
DeleteEvent $queueForDeletes,
Event $queueForEvents,
Database $dbForPlatform
) {
$function = $dbForProject->getDocument('functions', $functionId);
if ($function->isEmpty()) {

View file

@ -64,8 +64,15 @@ class Update extends Base
->callback([$this, 'action']);
}
public function action(string $functionId, string $deploymentId, Document $project, Response $response, Database $dbForProject, Event $queueForEvents, Database $dbForPlatform)
{
public function action(
string $functionId,
string $deploymentId,
Document $project,
Response $response,
Database $dbForProject,
Event $queueForEvents,
Database $dbForPlatform
) {
$function = $dbForProject->getDocument('functions', $functionId);
$deployment = $dbForProject->getDocument('deployments', $deploymentId);

View file

@ -51,8 +51,11 @@ class Get extends Base
->callback([$this, 'action']);
}
public function action(string $functionId, Response $response, Database $dbForProject)
{
public function action(
string $functionId,
Response $response,
Database $dbForProject
) {
$function = $dbForProject->getDocument('functions', $functionId);
if ($function->isEmpty()) {

View file

@ -106,8 +106,34 @@ class Update extends Base
->callback([$this, 'action']);
}
public function action(string $functionId, string $name, string $runtime, array $execute, array $events, string $schedule, int $timeout, bool $enabled, bool $logging, string $entrypoint, string $commands, array $scopes, string $installationId, ?string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Event $queueForEvents, Build $queueForBuilds, Database $dbForPlatform, GitHub $github)
{
public function action(
string $functionId,
string $name,
string $runtime,
array $execute,
array $events,
string $schedule,
int $timeout,
bool $enabled,
bool $logging,
string $entrypoint,
string $commands,
array $scopes,
string $installationId,
?string $providerRepositoryId,
string $providerBranch,
bool $providerSilentMode,
string $providerRootDirectory,
string $specification,
Request $request,
Response $response,
Database $dbForProject,
Document $project,
Event $queueForEvents,
Build $queueForBuilds,
Database $dbForPlatform,
GitHub $github
) {
// TODO: If only branch changes, re-deploy
$function = $dbForProject->getDocument('functions', $functionId);

View file

@ -57,8 +57,12 @@ class XList extends Base
->callback([$this, 'action']);
}
public function action(array $queries, string $search, Response $response, Database $dbForProject)
{
public function action(
array $queries,
string $search,
Response $response,
Database $dbForProject
) {
try {
$queries = Query::parseQueries($queries);
} catch (QueryException $e) {

View file

@ -66,8 +66,15 @@ class Create extends Base
->callback([$this, 'action']);
}
public function action(string $functionId, string $key, string $value, bool $secret, Response $response, Database $dbForProject, Database $dbForPlatform)
{
public function action(
string $functionId,
string $key,
string $value,
bool $secret,
Response $response,
Database $dbForProject,
Database $dbForPlatform
) {
$function = $dbForProject->getDocument('functions', $functionId);
if ($function->isEmpty()) {

View file

@ -59,8 +59,13 @@ class Delete extends Base
->callback([$this, 'action']);
}
public function action(string $functionId, string $variableId, Response $response, Database $dbForProject, Database $dbForPlatform)
{
public function action(
string $functionId,
string $variableId,
Response $response,
Database $dbForProject,
Database $dbForPlatform
) {
$function = $dbForProject->getDocument('functions', $functionId);
if ($function->isEmpty()) {

View file

@ -63,8 +63,16 @@ class Update extends Base
->callback([$this, 'action']);
}
public function action(string $functionId, string $variableId, string $key, ?string $value, ?bool $secret, Response $response, Database $dbForProject, Database $dbForPlatform)
{
public function action(
string $functionId,
string $variableId,
string $key,
?string $value,
?bool $secret,
Response $response,
Database $dbForProject,
Database $dbForPlatform
) {
$function = $dbForProject->getDocument('functions', $functionId);
if ($function->isEmpty()) {

View file

@ -86,8 +86,23 @@ class Create extends Action
->callback([$this, 'action']);
}
public function action(string $siteId, ?string $installCommand, ?string $buildCommand, ?string $outputDirectory, mixed $code, mixed $activate, Request $request, Response $response, Database $dbForProject, Database $dbForPlatform, Document $project, Event $queueForEvents, Device $deviceForSites, Device $deviceForLocal, Build $queueForBuilds)
{
public function action(
string $siteId,
?string $installCommand,
?string $buildCommand,
?string $outputDirectory,
mixed $code,
mixed $activate,
Request $request,
Response $response,
Database $dbForProject,
Database $dbForPlatform,
Document $project,
Event $queueForEvents,
Device $deviceForSites,
Device $deviceForLocal,
Build $queueForBuilds
) {
$activate = \strval($activate) === 'true' || \strval($activate) === '1';
$site = $dbForProject->getDocument('sites', $siteId);

View file

@ -63,8 +63,15 @@ class Delete extends Action
->callback([$this, 'action']);
}
public function action(string $siteId, string $deploymentId, Response $response, Database $dbForProject, DeleteEvent $queueForDeletes, Event $queueForEvents, Device $deviceForSites)
{
public function action(
string $siteId,
string $deploymentId,
Response $response,
Database $dbForProject,
DeleteEvent $queueForDeletes,
Event $queueForEvents,
Device $deviceForSites
) {
$site = $dbForProject->getDocument('sites', $siteId);
if ($site->isEmpty()) {
throw new Exception(Exception::SITE_NOT_FOUND);

View file

@ -62,8 +62,16 @@ class Get extends Action
->callback([$this, 'action']);
}
public function action(string $siteId, string $deploymentId, string $type, Response $response, Request $request, Database $dbForProject, Device $deviceForSites, Device $deviceForBuilds)
{
public function action(
string $siteId,
string $deploymentId,
string $type,
Response $response,
Request $request,
Database $dbForProject,
Device $deviceForSites,
Device $deviceForBuilds
) {
$site = $dbForProject->getDocument('sites', $siteId);
if ($site->isEmpty()) {
throw new Exception(Exception::SITE_NOT_FOUND);

View file

@ -65,8 +65,17 @@ class Create extends Action
->callback([$this, 'action']);
}
public function action(string $siteId, string $deploymentId, Response $response, Document $project, Database $dbForProject, Database $dbForPlatform, Event $queueForEvents, Build $queueForBuilds, Device $deviceForSites)
{
public function action(
string $siteId,
string $deploymentId,
Response $response,
Document $project,
Database $dbForProject,
Database $dbForPlatform,
Event $queueForEvents,
Build $queueForBuilds,
Device $deviceForSites
) {
$site = $dbForProject->getDocument('sites', $siteId);
if ($site->isEmpty()) {

View file

@ -59,8 +59,14 @@ class Update extends Action
->callback([$this, 'action']);
}
public function action(string $siteId, string $deploymentId, Response $response, Database $dbForProject, Document $project, Event $queueForEvents)
{
public function action(
string $siteId,
string $deploymentId,
Response $response,
Database $dbForProject,
Document $project,
Event $queueForEvents
) {
$site = $dbForProject->getDocument('sites', $siteId);
if ($site->isEmpty()) {

View file

@ -79,8 +79,22 @@ class Create extends Base
->callback([$this, 'action']);
}
public function action(string $siteId, string $repository, string $owner, string $rootDirectory, string $version, bool $activate, Request $request, Response $response, Database $dbForProject, Database $dbForPlatform, Document $project, Event $queueForEvents, Build $queueForBuilds, GitHub $github)
{
public function action(
string $siteId,
string $repository,
string $owner,
string $rootDirectory,
string $version,
bool $activate,
Request $request,
Response $response,
Database $dbForProject,
Database $dbForPlatform,
Document $project,
Event $queueForEvents,
Build $queueForBuilds,
GitHub $github
) {
$site = $dbForProject->getDocument('sites', $siteId);
if ($site->isEmpty()) {
@ -111,8 +125,8 @@ class Create extends Base
);
$queueForEvents
->setParam('siteId', $site->getId())
->setParam('deploymentId', $deployment->getId());
->setParam('siteId', $site->getId())
->setParam('deploymentId', $deployment->getId());
$response
->setStatusCode(Response::STATUS_CODE_ACCEPTED)

View file

@ -74,8 +74,20 @@ class Create extends Base
->callback([$this, 'action']);
}
public function action(string $siteId, string $type, string $reference, bool $activate, Request $request, Response $response, Database $dbForProject, Database $dbForPlatform, Document $project, Event $queueForEvents, Build $queueForBuilds, GitHub $github)
{
public function action(
string $siteId,
string $type,
string $reference,
bool $activate,
Request $request,
Response $response,
Database $dbForProject,
Database $dbForPlatform,
Document $project,
Event $queueForEvents,
Build $queueForBuilds,
GitHub $github
) {
$site = $dbForProject->getDocument('sites', $siteId);
if ($site->isEmpty()) {

View file

@ -91,8 +91,30 @@ class Create extends Base
->callback([$this, 'action']);
}
public function action(string $siteId, string $name, string $framework, bool $enabled, int $timeout, string $installCommand, string $buildCommand, string $outputDirectory, string $buildRuntime, string $adapter, string $installationId, string $fallbackFile, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $specification, Response $response, Database $dbForProject, Document $project, Event $queueForEvents, Database $dbForPlatform)
{
public function action(
string $siteId,
string $name,
string $framework,
bool $enabled,
int $timeout,
string $installCommand,
string $buildCommand,
string $outputDirectory,
string $buildRuntime,
string $adapter,
string $installationId,
string $fallbackFile,
string $providerRepositoryId,
string $providerBranch,
bool $providerSilentMode,
string $providerRootDirectory,
string $specification,
Response $response,
Database $dbForProject,
Document $project,
Event $queueForEvents,
Database $dbForPlatform
) {
if (!empty($adapter)) {
$configFramework = Config::getParam('frameworks')[$framework] ?? [];
$adapters = \array_keys($configFramework['adapters'] ?? []);

View file

@ -60,8 +60,13 @@ class Delete extends Base
->callback([$this, 'action']);
}
public function action(string $siteId, Response $response, Database $dbForProject, DeleteEvent $queueForDeletes, Event $queueForEvents)
{
public function action(
string $siteId,
Response $response,
Database $dbForProject,
DeleteEvent $queueForDeletes,
Event $queueForEvents
) {
$site = $dbForProject->getDocument('sites', $siteId);
if ($site->isEmpty()) {

View file

@ -61,8 +61,15 @@ class Update extends Base
->callback([$this, 'action']);
}
public function action(string $siteId, string $deploymentId, Document $project, Response $response, Database $dbForProject, Event $queueForEvents, Database $dbForPlatform)
{
public function action(
string $siteId,
string $deploymentId,
Document $project,
Response $response,
Database $dbForProject,
Event $queueForEvents,
Database $dbForPlatform
) {
$site = $dbForProject->getDocument('sites', $siteId);
$deployment = $dbForProject->getDocument('deployments', $deploymentId);

View file

@ -55,8 +55,13 @@ class XList extends Base
->callback([$this, 'action']);
}
public function action(array $frameworks, array $usecases, int $limit, int $offset, Response $response)
{
public function action(
array $frameworks,
array $usecases,
int $limit,
int $offset,
Response $response
) {
$templates = Config::getParam('templates-site', []);
if (!empty($frameworks)) {

View file

@ -57,8 +57,12 @@ class Get extends Base
->callback([$this, 'action']);
}
public function action(string $siteId, string $range, Response $response, Database $dbForProject)
{
public function action(
string $siteId,
string $range,
Response $response,
Database $dbForProject
) {
$site = $dbForProject->getDocument('sites', $siteId);
if ($site->isEmpty()) {

View file

@ -60,8 +60,15 @@ class Update extends Base
->callback([$this, 'action']);
}
public function action(string $siteId, string $variableId, string $key, ?string $value, ?bool $secret, Response $response, Database $dbForProject)
{
public function action(
string $siteId,
string $variableId,
string $key,
?string $value,
?bool $secret,
Response $response,
Database $dbForProject
) {
$site = $dbForProject->getDocument('sites', $siteId);
if ($site->isEmpty()) {

View file

@ -55,8 +55,11 @@ class XList extends Base
->callback([$this, 'action']);
}
public function action(string $siteId, Response $response, Database $dbForProject)
{
public function action(
string $siteId,
Response $response,
Database $dbForProject
) {
$site = $dbForProject->getDocument('sites', $siteId);
if ($site->isEmpty()) {