Merge pull request #11862 from appwrite/feat/project-onboarding-stages

feat(projects): add onboarding stages tracking and stages API
This commit is contained in:
Damodar Lohani authored and GitHub committed 2026-06-29 05:53:46 +05:45
commit a6f753e17b
18 files changed
+671

No files matched your search

+11
View File
@@ -342,6 +342,17 @@ $platformCollections = [
'array' => true,
'filters' => [],
],
[
'$id' => ID::custom('onboarding'),
'type' => Database::VAR_STRING,
'format' => '',
'size' => 65536,
'signed' => true,
'required' => false,
'default' => [],
'array' => false,
'filters' => ['json'],
],
[
'$id' => 'status',
'type' => Database::VAR_STRING,
+76
View File
@@ -0,0 +1,76 @@
<?php
/**
* Project onboarding stages keyed by SDK method (namespace + method name, same as Appwrite\SDK\Method).
* Values are `true` for O(1) isset() lookup in the API shutdown hook. Each key is persisted under
* project.onboarding when the matching API call succeeds.
*/
return [
// Connect — register platform
'project.createWebPlatform' => true,
'project.createAndroidPlatform' => true,
'project.createApplePlatform' => true,
'project.createWindowsPlatform' => true,
'project.createLinuxPlatform' => true,
// Connect — API key
'project.createKey' => true,
// Auth
'users.create' => true,
'account.create' => true,
'account.createAnonymousSession' => true,
'teams.create' => true,
// Databases — tablesDB
'tablesDB.create' => true,
'tablesDB.createTable' => true,
'tablesDB.createRow' => true,
// Databases — documentsDB
'documentsDB.create' => true,
'documentsDB.createCollection' => true,
'documentsDB.createDocument' => true,
// Databases — legacy
'databases.create' => true,
'databases.createCollection' => true,
'databases.createDocument' => true,
// Storage
'storage.createBucket' => true,
'storage.createFile' => true,
// Functions
'functions.create' => true,
// Deployment-creation SDK methods; OR them in the UI for a single
// "created a deployment" milestone.
'functions.createDeployment' => true,
'functions.createTemplateDeployment' => true,
'functions.createVcsDeployment' => true,
'functions.updateFunctionDeployment' => true,
// Messaging
'messaging.createTopic' => true,
'messaging.createMailgunProvider' => true,
'messaging.createSendgridProvider' => true,
'messaging.createSesProvider' => true,
'messaging.createResendProvider' => true,
'messaging.createSmtpProvider' => true,
'messaging.createSMTPProvider' => true,
'messaging.createMsg91Provider' => true,
'messaging.createTelesignProvider' => true,
'messaging.createTextmagicProvider' => true,
'messaging.createTwilioProvider' => true,
'messaging.createVonageProvider' => true,
'messaging.createFcmProvider' => true,
'messaging.createFCMProvider' => true,
'messaging.createApnsProvider' => true,
'messaging.createAPNSProvider' => true,
// Sites
'sites.create' => true,
// Deployment-creation SDK methods; OR them in the UI for a single
// "created a deployment" milestone.
'sites.createDeployment' => true,
'sites.createTemplateDeployment' => true,
'sites.createVcsDeployment' => true,
'sites.updateSiteDeployment' => true,
];
+2
View File
@@ -107,6 +107,8 @@ $admins = [
'tokens.write',
'schedules.read',
'schedules.write',
'stages.read',
'stages.write',
'insights.read',
'insights.write',
'reports.read',
+10
View File
@@ -75,6 +75,16 @@ return [
"Access to create, update, and delete project\'s templates",
"category" => "Project",
],
"stages.read" => [
"description" =>
"Access to read project\'s stages",
"category" => "Project",
],
"stages.write" => [
"description" =>
"Access to update project\'s stages",
"category" => "Project",
],
"oauth2.read" => [
"description" =>
"Access to read project\'s OAuth2 configuration",
+90
View File
@@ -24,6 +24,7 @@ use Appwrite\Usage\Context;
use Appwrite\Utopia\Database\Documents\User;
use Appwrite\Utopia\Request;
use Appwrite\Utopia\Response;
use Throwable;
use Utopia\Abuse\Abuse;
use Utopia\Bus\Bus;
use Utopia\Cache\Adapter\Filesystem;
@@ -1085,6 +1086,95 @@ Http::shutdown()
}
});
Http::shutdown()
->groups(['api'])
->inject('route')
->inject('response')
->inject('project')
->inject('user')
->inject('dbForPlatform')
->inject('authorization')
->inject('apiKey')
->inject('mode')
->action(function (Route $route, Response $response, Document $project, User $user, Database $dbForPlatform, Authorization $authorization, ?Key $apiKey, string $mode) {
/**
* Persist completed onboarding stage after usage shutdown so a schema/write failure here
* cannot suppress RequestCompleted or usage metrics on the same request.
*/
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode >= 300 || $project->getId() === 'console') {
return;
}
$sdkLabel = $route->getLabel('sdk', false);
if ($sdkLabel === false || $sdkLabel === null) {
return;
}
/** @var array<string, true> $onboarding */
$onboarding = Config::getParam('onboarding', []);
if ($onboarding === []) {
return;
}
$method = null;
if ($sdkLabel instanceof Method) {
$key = $sdkLabel->getNamespace() . '.' . $sdkLabel->getMethodName();
if (isset($onboarding[$key])) {
$method = $key;
}
} elseif (\is_array($sdkLabel)) {
foreach ($sdkLabel as $sdkMethod) {
if (! $sdkMethod instanceof Method) {
continue;
}
$key = $sdkMethod->getNamespace() . '.' . $sdkMethod->getMethodName();
if (isset($onboarding[$key])) {
$method = $key;
break;
}
}
}
if ($method === null) {
return;
}
$byMethod = $project->getAttribute('onboarding', []);
$status = \is_array($byMethod) ? ($byMethod[$method]['status'] ?? null) : null;
if ($status === ONBOARDING_STATUS_COMPLETED || $status === ONBOARDING_STATUS_SKIPPED) {
return;
}
if (! \is_array($byMethod)) {
$byMethod = [];
}
$actorType = ($apiKey !== null && $apiKey->getRole() === User::ROLE_KEYS)
? match ($apiKey->getType()) {
API_KEY_ACCOUNT => ACTOR_TYPE_KEY_ACCOUNT,
API_KEY_ORGANIZATION => ACTOR_TYPE_KEY_ORGANIZATION,
API_KEY_STANDARD, API_KEY_EPHEMERAL => ACTOR_TYPE_KEY_PROJECT,
default => ACTOR_TYPE_KEY_PROJECT,
}
: (! $user->isEmpty()
? ($mode === APP_MODE_ADMIN ? ACTOR_TYPE_ADMIN : ACTOR_TYPE_USER)
: ACTOR_TYPE_GUEST);
$byMethod[$method] = [
'status' => ONBOARDING_STATUS_COMPLETED,
'at' => DateTime::now(),
'actorType' => $actorType,
];
try {
$authorization->skip(fn () => $dbForPlatform->updateDocument('projects', $project->getId(), new Document([
'onboarding' => $byMethod,
])));
} catch (Throwable) {
// Missing `onboarding` attribute on upgraded installs must not break the request lifecycle.
}
});
Http::init()
->groups(['usage'])
->action(function () {
+1
View File
@@ -26,6 +26,7 @@ Config::load('projectScopes', __DIR__ . '/../config/scopes/project.php', $config
Config::load('organizationScopes', __DIR__ . '/../config/scopes/organization.php', $configAdapter);
Config::load('accountScopes', __DIR__ . '/../config/scopes/account.php', $configAdapter);
Config::load('services', __DIR__ . '/../config/services.php', $configAdapter); // List of services
Config::load('onboarding', __DIR__ . '/../config/onboarding.php', $configAdapter); // Project onboarding stages → routes
Config::load('variables', __DIR__ . '/../config/variables.php', $configAdapter); // List of env variables
Config::load('regions', __DIR__ . '/../config/regions.php', $configAdapter); // List of available regions
Config::load('avatar-browsers', __DIR__ . '/../config/avatars/browsers.php', $configAdapter);
+6
View File
@@ -172,6 +172,12 @@ const ACTOR_TYPE_KEY_PROJECT = 'keyProject';
const ACTOR_TYPE_KEY_ACCOUNT = 'keyAccount';
const ACTOR_TYPE_KEY_ORGANIZATION = 'keyOrganization';
/**
* Project onboarding stage status (stored per SDK method key under project.onboarding JSON).
*/
const ONBOARDING_STATUS_COMPLETED = 'completed';
const ONBOARDING_STATUS_SKIPPED = 'skipped';
/**
* MFA
*/
+3
View File
@@ -195,6 +195,7 @@ use Appwrite\Utopia\Response\Model\Schedule;
use Appwrite\Utopia\Response\Model\Session;
use Appwrite\Utopia\Response\Model\Site;
use Appwrite\Utopia\Response\Model\Specification;
use Appwrite\Utopia\Response\Model\Stage;
use Appwrite\Utopia\Response\Model\Subscriber;
use Appwrite\Utopia\Response\Model\Table;
use Appwrite\Utopia\Response\Model\Target;
@@ -285,6 +286,7 @@ Response::setModel(new BaseList('Email Templates List', Response::MODEL_EMAIL_TE
Response::setModel(new BaseList('Status List', Response::MODEL_HEALTH_STATUS_LIST, 'statuses', Response::MODEL_HEALTH_STATUS));
Response::setModel(new BaseList('Rule List', Response::MODEL_PROXY_RULE_LIST, 'rules', Response::MODEL_PROXY_RULE));
Response::setModel(new BaseList('Schedules List', Response::MODEL_SCHEDULE_LIST, 'schedules', Response::MODEL_SCHEDULE));
Response::setModel(new BaseList('Stages List', Response::MODEL_STAGE_LIST, 'stages', Response::MODEL_STAGE, false, false));
Response::setModel(new BaseList('Locale codes list', Response::MODEL_LOCALE_CODE_LIST, 'localeCodes', Response::MODEL_LOCALE_CODE));
Response::setModel(new BaseList('Provider list', Response::MODEL_PROVIDER_LIST, 'providers', Response::MODEL_PROVIDER));
Response::setModel(new BaseList('Message list', Response::MODEL_MESSAGE_LIST, 'messages', Response::MODEL_MESSAGE));
@@ -507,6 +509,7 @@ Response::setModel(new Headers());
Response::setModel(new Specification());
Response::setModel(new Rule());
Response::setModel(new Schedule());
Response::setModel(new Stage());
Response::setModel(new TemplateEmail());
Response::setModel(new ConsoleVariables());
Response::setModel(new ConsoleOAuth2ProviderParameter());
+1
View File
@@ -0,0 +1 @@
Get the onboarding stages for the current project, including each stage’s SDK method key and status (for example pending, completed, or skipped).
+1
View File
@@ -0,0 +1 @@
Update an onboarding stage for the current project. Use this endpoint to skip a stage or leave it unchanged without performing the related API action.
@@ -0,0 +1,144 @@
<?php
namespace Appwrite\Platform\Modules\Projects\Http\Stages;
use Appwrite\Auth\Key;
use Appwrite\Extend\Exception;
use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Database\Documents\User;
use Appwrite\Utopia\Response;
use Utopia\Config\Config;
use Utopia\Database\Database;
use Utopia\Database\DateTime;
use Utopia\Database\Document;
use Utopia\Database\Validator\UID;
use Utopia\Platform\Action;
use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\Boolean;
use Utopia\Validator\Text;
class Update extends Action
{
use HTTP;
public static function getName(): string
{
return 'updateStage';
}
public function __construct()
{
$this
->setHttpMethod(Action::HTTP_REQUEST_METHOD_PATCH)
->setHttpPath('/v1/projects/:projectId/stages/:stageId')
->desc('Update stage')
->groups(['api', 'projects'])
->label('scope', 'stages.write')
->label('audits.event', 'stages.update')
->label('audits.resource', 'project/{request.projectId}')
->label('sdk', new Method(
namespace: 'projects',
group: 'stages',
name: 'updateStage',
description: '/docs/references/projects/update-stage.md',
auth: [AuthType::ADMIN],
responses: [
new SDKResponse(
code: Response::STATUS_CODE_OK,
model: Response::MODEL_STAGE,
)
],
))
->param('projectId', '', new UID(), 'Project unique ID.')
->param('stageId', '', new Text(128), 'SDK method key (namespace.method).')
->param('skip', true, new Boolean(), 'Mark the stage as skipped.', true)
->inject('response')
->inject('dbForPlatform')
->inject('apiKey')
->inject('user')
->inject('mode')
->callback($this->action(...));
}
public function action(string $projectId, string $stageId, bool $skip, Response $response, Database $dbForPlatform, ?Key $apiKey, User $user, string $mode): void
{
$project = $dbForPlatform->getDocument('projects', $projectId);
if ($project->isEmpty()) {
throw new Exception(Exception::PROJECT_NOT_FOUND);
}
$this->assertOnboardingMethod($stageId);
$byMethod = $project->getAttribute('onboarding', []);
if (! \is_array($byMethod)) {
$byMethod = [];
}
$row = \is_array($byMethod[$stageId] ?? null) ? $byMethod[$stageId] : null;
if ($skip) {
$prev = \is_array($row) ? ($row['status'] ?? '') : '';
if ($prev !== ONBOARDING_STATUS_COMPLETED) {
$byMethod[$stageId] = [
'status' => ONBOARDING_STATUS_SKIPPED,
'at' => DateTime::now(),
'actorType' => $this->resolveActorType($apiKey, $user, $mode),
];
$project = $dbForPlatform->updateDocument('projects', $project->getId(), new Document([
'onboarding' => $byMethod,
]));
$byMethod = $project->getAttribute('onboarding', []);
$row = \is_array($byMethod[$stageId] ?? null) ? $byMethod[$stageId] : null;
}
}
$response->dynamic(new Document($this->formatStageRow($stageId, $row)), Response::MODEL_STAGE);
}
private function assertOnboardingMethod(string $method): void
{
if (! \array_key_exists($method, Config::getParam('onboarding', []))) {
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Unknown SDK method: ' . $method);
}
}
/**
* @param array<string, mixed>|null $row
* @return array<string, mixed>
*/
private function formatStageRow(string $method, ?array $row): array
{
$status = \is_array($row) ? ($row['status'] ?? null) : null;
$at = \is_array($row) ? ($row['at'] ?? '') : '';
$actorType = \is_array($row) ? ($row['actorType'] ?? '') : '';
return [
'id' => $method,
'sdk' => $method,
'status' => $status ?? 'pending',
'at' => $at,
'actorType' => $actorType,
];
}
private function resolveActorType(?Key $apiKey, User $user, string $mode): string
{
if ($apiKey !== null && $apiKey->getRole() === User::ROLE_KEYS) {
return match ($apiKey->getType()) {
API_KEY_ACCOUNT => ACTOR_TYPE_KEY_ACCOUNT,
API_KEY_ORGANIZATION => ACTOR_TYPE_KEY_ORGANIZATION,
API_KEY_STANDARD, API_KEY_EPHEMERAL => ACTOR_TYPE_KEY_PROJECT,
default => ACTOR_TYPE_KEY_PROJECT,
};
}
if (! $user->isEmpty()) {
return $mode === APP_MODE_ADMIN ? ACTOR_TYPE_ADMIN : ACTOR_TYPE_USER;
}
return ACTOR_TYPE_GUEST;
}
}
@@ -0,0 +1,96 @@
<?php
namespace Appwrite\Platform\Modules\Projects\Http\Stages;
use Appwrite\Extend\Exception;
use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response;
use Utopia\Config\Config;
use Utopia\Database\Database;
use Utopia\Database\Document;
use Utopia\Database\Validator\UID;
use Utopia\Platform\Action;
use Utopia\Platform\Scope\HTTP;
class XList extends Action
{
use HTTP;
public static function getName(): string
{
return 'listStages';
}
public function __construct()
{
$this
->setHttpMethod(Action::HTTP_REQUEST_METHOD_GET)
->setHttpPath('/v1/projects/:projectId/stages')
->desc('List stages')
->groups(['api', 'projects'])
->label('scope', 'stages.read')
->label('sdk', new Method(
namespace: 'projects',
group: 'stages',
name: 'listStages',
description: '/docs/references/projects/list-stages.md',
auth: [AuthType::ADMIN],
responses: [
new SDKResponse(
code: Response::STATUS_CODE_OK,
model: Response::MODEL_STAGE_LIST,
)
],
))
->param('projectId', '', new UID(), 'Project unique ID.')
->inject('response')
->inject('dbForPlatform')
->callback($this->action(...));
}
public function action(string $projectId, Response $response, Database $dbForPlatform): void
{
$project = $dbForPlatform->getDocument('projects', $projectId);
if ($project->isEmpty()) {
throw new Exception(Exception::PROJECT_NOT_FOUND);
}
$response->dynamic(new Document([
'stages' => $this->buildStagesList($project),
]), Response::MODEL_STAGE_LIST);
}
/**
* @return array<int, array<string, mixed>>
*/
private function buildStagesList(Document $project): array
{
$methods = \array_keys(Config::getParam('onboarding', []));
$byMethod = $project->getAttribute('onboarding', []);
if (! \is_array($byMethod)) {
$byMethod = [];
}
$out = [];
foreach ($methods as $method) {
$row = $byMethod[$method] ?? null;
$status = \is_array($row) ? ($row['status'] ?? null) : null;
$at = \is_array($row) ? ($row['at'] ?? '') : '';
$actorType = \is_array($row) ? ($row['actorType'] ?? '') : '';
$out[] = [
'id' => $method,
'sdk' => $method,
'status' => $status ?? 'pending',
'at' => $at,
'actorType' => $actorType,
];
}
return $out;
}
}
@@ -14,6 +14,8 @@ use Appwrite\Platform\Modules\Projects\Http\Projects\XList as ListProjects;
use Appwrite\Platform\Modules\Projects\Http\Schedules\Create as CreateSchedule;
use Appwrite\Platform\Modules\Projects\Http\Schedules\Get as GetSchedule;
use Appwrite\Platform\Modules\Projects\Http\Schedules\XList as ListSchedules;
use Appwrite\Platform\Modules\Projects\Http\Stages\Update as UpdateStages;
use Appwrite\Platform\Modules\Projects\Http\Stages\XList as ListStages;
use Utopia\Platform\Service;
class Http extends Service
@@ -35,5 +37,8 @@ class Http extends Service
$this->addAction(CreateSchedule::getName(), new CreateSchedule());
$this->addAction(GetSchedule::getName(), new GetSchedule());
$this->addAction(ListSchedules::getName(), new ListSchedules());
$this->addAction(ListStages::getName(), new ListStages());
$this->addAction(UpdateStages::getName(), new UpdateStages());
}
}
+2
View File
@@ -252,6 +252,8 @@ class Response extends SwooleResponse
// Project
public const MODEL_PROJECT = 'project';
public const MODEL_PROJECT_LIST = 'projectList';
public const MODEL_STAGE = 'stage';
public const MODEL_STAGE_LIST = 'stageList';
public const MODEL_PROJECT_AUTH_METHOD = 'projectAuthMethod';
public const MODEL_PROJECT_SERVICE = 'projectService';
public const MODEL_PROJECT_PROTOCOL = 'projectProtocol';
@@ -153,6 +153,12 @@ class Project extends Model
'default' => 'active',
'example' => 'active',
])
->addRule('onboarding', [
'type' => self::TYPE_JSON,
'description' => 'Stage progress (completed or skipped) with timestamps and actor types, keyed by stage id.',
'default' => [],
'example' => [],
])
// Resource: Auth methods
->addRule('authMethods', [
@@ -0,0 +1,61 @@
<?php
namespace Appwrite\Utopia\Response\Model;
use Appwrite\Utopia\Response;
use Appwrite\Utopia\Response\Model;
use Utopia\Database\Document;
class Stage extends Model
{
public function __construct()
{
$this
->addRule('id', [
'type' => self::TYPE_STRING,
'description' => 'Stage ID.',
'default' => '',
'example' => 'tablesDB.create',
])
->addRule('sdk', [
'type' => self::TYPE_STRING,
'description' => 'SDK method key (namespace.name) for this stage.',
'default' => '',
'example' => 'tablesDB.create',
])
->addRule('status', [
'type' => self::TYPE_STRING,
'description' => 'Stage status.',
'default' => 'pending',
'example' => 'completed',
])
->addRule('at', [
'type' => self::TYPE_DATETIME,
'description' => 'When the stage was completed or skipped, in ISO 8601 format.',
'default' => '',
'example' => self::TYPE_DATETIME_EXAMPLE,
])
->addRule('actorType', [
'type' => self::TYPE_STRING,
'description' => 'Actor type when the stage was recorded.',
'default' => '',
'example' => 'user',
])
;
}
public function getName(): string
{
return 'Stage';
}
public function getType(): string
{
return Response::MODEL_STAGE;
}
public function filter(Document $document): Document
{
return $document;
}
}
+140
View File
@@ -0,0 +1,140 @@
<?php
namespace Tests\E2E\Services\Project;
use Appwrite\Extend\Exception;
use Tests\E2E\Client;
use Utopia\Config\Config;
use Utopia\Database\Validator\Datetime as DatetimeValidator;
trait StagesBase
{
// =========================================================================
// List stages tests
// =========================================================================
public function testListProjectStages(): void
{
$projectId = $this->getProject()['$id'];
$response = $this->listStages($projectId);
$this->assertSame(200, $response['headers']['status-code']);
$this->assertIsArray($response['body']['stages']);
$this->assertCount(\count(Config::getParam('onboarding', [])), $response['body']['stages']);
$ids = array_column($response['body']['stages'], 'id');
$this->assertContains('tablesDB.create', $ids);
$this->assertContains('storage.createBucket', $ids);
$this->assertContains('functions.create', $ids);
foreach ($response['body']['stages'] as $stage) {
$this->assertSame($stage['id'], $stage['sdk']);
$this->assertArrayHasKey('status', $stage);
$this->assertArrayHasKey('at', $stage);
$this->assertArrayHasKey('actorType', $stage);
}
}
public function testListProjectStagesWithoutAuthentication(): void
{
$response = $this->listStages($this->getProject()['$id'], false);
$this->assertSame(401, $response['headers']['status-code']);
}
// =========================================================================
// Update stage (skip) tests
// =========================================================================
public function testUpdateProjectStageSkip(): void
{
$projectId = $this->getProject()['$id'];
$method = 'tablesDB.create';
$response = $this->updateStage($projectId, $method, true);
$this->assertSame(200, $response['headers']['status-code']);
$this->assertSame($method, $response['body']['id']);
$this->assertSame($method, $response['body']['sdk']);
$this->assertSame(ONBOARDING_STATUS_SKIPPED, $response['body']['status']);
$this->assertNotEmpty($response['body']['at']);
$this->assertSame(ACTOR_TYPE_USER, $response['body']['actorType']);
$dateValidator = new DatetimeValidator();
$this->assertSame(true, $dateValidator->isValid($response['body']['at']));
$list = $this->listStages($projectId);
$this->assertSame(200, $list['headers']['status-code']);
$databaseStage = null;
foreach ($list['body']['stages'] as $stage) {
if ($stage['id'] === $method) {
$databaseStage = $stage;
break;
}
}
$this->assertNotNull($databaseStage);
$this->assertSame(ONBOARDING_STATUS_SKIPPED, $databaseStage['status']);
$this->assertSame(ACTOR_TYPE_USER, $databaseStage['actorType']);
$response = $this->updateStage($projectId, 'unknown.method', true);
$this->assertSame(400, $response['headers']['status-code']);
$this->assertSame(Exception::GENERAL_ARGUMENT_INVALID, $response['body']['type']);
}
public function testUpdateProjectStageSkipFalseLeavesPending(): void
{
$projectId = $this->getProject()['$id'];
$method = 'storage.createBucket';
$response = $this->updateStage($projectId, $method, false);
$this->assertSame(200, $response['headers']['status-code']);
$this->assertSame($method, $response['body']['id']);
$this->assertSame('pending', $response['body']['status']);
}
public function testUpdateProjectStageWithoutAuthentication(): void
{
$response = $this->updateStage($this->getProject()['$id'], 'tablesDB.create', true, false);
$this->assertSame(401, $response['headers']['status-code']);
}
// =========================================================================
// Helpers
// =========================================================================
protected function listStages(string $projectId, bool $authenticated = true): mixed
{
// Stages live under /projects (console scope); use the root console session.
$headers = [
'content-type' => 'application/json',
'x-appwrite-project' => 'console',
];
if ($authenticated) {
$headers['origin'] = 'http://localhost';
$headers['cookie'] = 'a_session_console=' . $this->getRoot()['session'];
}
return $this->client->call(Client::METHOD_GET, '/projects/' . $projectId . '/stages', $headers, []);
}
protected function updateStage(string $projectId, string $stageId, bool $skip, bool $authenticated = true): mixed
{
$headers = [
'content-type' => 'application/json',
'x-appwrite-project' => 'console',
];
if ($authenticated) {
$headers['origin'] = 'http://localhost';
$headers['cookie'] = 'a_session_console=' . $this->getRoot()['session'];
}
return $this->client->call(Client::METHOD_PATCH, '/projects/' . $projectId . '/stages/' . rawurlencode($stageId), $headers, [
'skip' => $skip,
]);
}
}
@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Project;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideConsole;
final class StagesConsoleClientTest extends Scope
{
use StagesBase;
use ProjectCustom;
use SideConsole;
}