Skip to content

Commit 4574385

Browse files
authored
Merge pull request #11447 from appwrite/revert-10862-feat-1.8.x-new-schema
Revert "Features with schema changes"
2 parents cf16e3e + f8b31e7 commit 4574385

32 files changed

Lines changed: 179 additions & 7010 deletions

File tree

CONTRIBUTING.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ $ git push origin [name_of_your_new_branch]
111111

112112
## Setup From Source
113113

114-
To set up a working **development environment**, just fork the project git repository and install the backend and frontend dependencies using the proper package manager and run the docker-compose stack.
114+
To set up a working **development environment**, just fork the project git repository and install the backend and frontend dependencies using the proper package manager and create run the docker-compose stack.
115115

116116
> If you just want to install Appwrite for day-to-day use and not as a contributor, you can reference the [installation guide](https://github.com/appwrite/appwrite#installation), the [getting started guide](https://appwrite.io/docs/quick-starts), or the main [README](README.md) file.
117117
@@ -173,12 +173,12 @@ Learn more at our [Technology Stack](#technology-stack) section.
173173
- [MVVM](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93viewmodel) - Appwrite console architecture
174174

175175
##### Container Namespace Conventions
176-
To keep our services easy to understand within Docker we follow a naming convention for all our containers depending on its intended use.
176+
To keep our services easy to understand within Docker we follow a naming convention for all our containers depending on it's intended use.
177177

178178
`appwrite-worker-X` - Workers (`src/Appwrite/Platform/Workers/*`)
179179
`appwrite-task-X` - Tasks (`src/Appwrite/Platform/Tasks/*`)
180180

181-
Other containers should be named the same as their service, for example `redis` should just be called `redis`.
181+
Other containes should be named the same as their service, for example `redis` should just be called `redis`.
182182

183183
##### Security
184184

@@ -189,7 +189,7 @@ Other containers should be named the same as their service, for example `redis`
189189

190190
## Modules
191191

192-
As Appwrite grows, we noticed approach of having all service endpoints in `app/controllers/api/[service].php` is not maintainable. Not only it creates massive files, it also doesn't contain all product's features such as workers or tasks. While there might still be some occurrences of those controller files, we avoid it in all new development, and gradually migrate existing controllers to **HTTP modules**.
192+
As Appwrite grows, we noticed approach of having all service endpoints in `app/controllers/api/[service].php` is not maintainable. Not only it creates massive files, it also doesnt contain all product's features such as workers or tasks. While there might still be some occurances of those controller files, we avoid it in all new development, and gradually migrate existing controllers to **HTTP modules**.
193193

194194
### HTTP Endpoints
195195

@@ -204,7 +204,7 @@ Tips and tricks:
204204
1. If endpoint doesn't have resource, use service name as resource name too
205205
> Example: `Modules/Sites/Http/Sites/Get.php`
206206
207-
2. If there are multiple resources, use them all in folder structure
207+
2. If there are multiple resources, use then all in folder structure
208208
> Example: `Modules/Sites/Http/Deployments/Builds/Create.php`
209209
210210
3. Action can only be `Get`, `Create`, `Update`, `Delete` or `XList`
@@ -395,7 +395,7 @@ These are the current metrics we collect usage stats for:
395395

396396
> Note: The curly brackets in the metric name represents a template and is replaced with a value when the metric is processed.
397397
398-
Metrics are collected within 3 scopes Daily, monthly, and infinity. Adding new usage metric in order to aggregate usage stats is very simple, but very much dependent on where do you want to collect
398+
Metrics are collected within 3 scopes Daily, monthly, an infinity. Adding new usage metric in order to aggregate usage stats is very simple, but very much dependent on where do you want to collect
399399
statistics ,via API or via background worker. For both cases you will need to add a `const` variable in `app/init.php` under the usage metrics list using the naming convention `METRIC_<RESOURCE_NAME>` as shown below.
400400

401401
```php
@@ -661,7 +661,7 @@ docker compose exec redis redis-cli FLUSHALL
661661

662662
## Using preview domains locally
663663

664-
Appwrite Functions are automatically given a domain you can visit to execute the function. This domain has format `[SOMETHING].functions.localhost` unless you changed `_APP_DOMAIN_FUNCTIONS` environment variable. This default value works great when running Appwrite locally, but it can be impossible to use preview domains with Cloud workspaces such as Gitpod or GitHub Codespaces.
664+
Appwrite Functions are automatically given a domain you can visit to execute the function. This domain has format `[SOMETHING].functions.localhost` unless you changed `_APP_DOMAIN_FUNCTIONS` environment variable. This default value works great when running Appwrite locally, but it can be impossible to use preview domains with Cloud woekspaces such as Gitpod or GitHub Codespaces.
665665

666666
To use preview domains on Cloud workspaces, you can visit hostname provided by them, and supply function's preview domain as URL parameter:
667667

app/config/collections/projects.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,6 @@
777777
'filters' => [],
778778
],
779779
[
780-
// At the moment, always empty (no runtime supports it yet)
781780
'array' => false,
782781
'$id' => ID::custom('startCommand'),
783782
'type' => Database::VAR_STRING,
@@ -788,6 +787,17 @@
788787
'default' => null,
789788
'filters' => [],
790789
],
790+
[
791+
'array' => false,
792+
'$id' => ID::custom('specification'),
793+
'type' => Database::VAR_STRING,
794+
'format' => '',
795+
'size' => 128,
796+
'signed' => false,
797+
'required' => false,
798+
'default' => APP_COMPUTE_SPECIFICATION_DEFAULT,
799+
'filters' => [],
800+
],
791801
[
792802
'array' => false,
793803
'$id' => ID::custom('buildSpecification'),
@@ -1247,18 +1257,7 @@
12471257
],
12481258
[
12491259
'array' => false,
1250-
'$id' => ID::custom('buildSpecification'),
1251-
'type' => Database::VAR_STRING,
1252-
'format' => '',
1253-
'size' => 128,
1254-
'signed' => false,
1255-
'required' => false,
1256-
'default' => APP_COMPUTE_SPECIFICATION_DEFAULT,
1257-
'filters' => [],
1258-
],
1259-
[
1260-
'array' => false,
1261-
'$id' => ID::custom('runtimeSpecification'),
1260+
'$id' => ID::custom('specification'),
12621261
'type' => Database::VAR_STRING,
12631262
'format' => '',
12641263
'size' => 128,

app/controllers/general.php

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
use Appwrite\Utopia\Response\Filters\V17 as ResponseV17;
3131
use Appwrite\Utopia\Response\Filters\V18 as ResponseV18;
3232
use Appwrite\Utopia\Response\Filters\V19 as ResponseV19;
33-
use Appwrite\Utopia\Response\Filters\V20 as ResponseV20;
34-
use Appwrite\Utopia\Response\Filters\V21 as ResponseV21;
3533
use Appwrite\Utopia\View;
3634
use Executor\Executor;
3735
use MaxMind\Db\Reader;
@@ -323,8 +321,7 @@ function router(Http $utopia, Database $dbForPlatform, callable $getProjectDB, S
323321
};
324322

325323
$runtimes = Config::getParam($version === 'v2' ? 'runtimes-v2' : 'runtimes', []);
326-
// TODO: backwards-compatibility dual-read, remove eventually.
327-
$spec = Config::getParam('specifications')[$resource->getAttribute('runtimeSpecification', $resource->getAttribute('specification', APP_COMPUTE_SPECIFICATION_DEFAULT))];
324+
$spec = Config::getParam('specifications')[$resource->getAttribute('specification', APP_COMPUTE_SPECIFICATION_DEFAULT)];
328325

329326
$runtime = match ($type) {
330327
'function' => $runtimes[$resource->getAttribute('runtime')] ?? null,
@@ -554,10 +551,6 @@ function router(Http $utopia, Database $dbForPlatform, callable $getProjectDB, S
554551
}
555552
}
556553

557-
if (!empty($deployment->getAttribute('startCommand', ''))) {
558-
$startCommand = 'cd /usr/local/server/src/function/ && ' . $deployment->getAttribute('startCommand', '');
559-
}
560-
561554
$runtimeEntrypoint = match ($version) {
562555
'v2' => '',
563556
default => "cp /tmp/code.$extension /mnt/code/code.$extension && nohup helpers/start.sh \"$startCommand\"",
@@ -939,23 +932,17 @@ function router(Http $utopia, Database $dbForPlatform, callable $getProjectDB, S
939932
*/
940933
$responseFormat = $request->getHeader('x-appwrite-response-format', System::getEnv('_APP_SYSTEM_RESPONSE_FORMAT', ''));
941934
if ($responseFormat) {
942-
if (version_compare($responseFormat, '1.9.0', '<')) {
943-
$response->addFilter(new ResponseV21());
944-
}
945-
if (version_compare($responseFormat, '1.8.0', '<')) {
946-
$response->addFilter(new ResponseV20());
935+
if (version_compare($responseFormat, '1.4.0', '<')) {
936+
$response->addFilter(new ResponseV16());
947937
}
948-
if (version_compare($responseFormat, '1.7.0', '<')) {
949-
$response->addFilter(new ResponseV19());
938+
if (version_compare($responseFormat, '1.5.0', '<')) {
939+
$response->addFilter(new ResponseV17());
950940
}
951941
if (version_compare($responseFormat, '1.6.0', '<')) {
952942
$response->addFilter(new ResponseV18());
953943
}
954-
if (version_compare($responseFormat, '1.5.0', '<')) {
955-
$response->addFilter(new ResponseV17());
956-
}
957-
if (version_compare($responseFormat, '1.4.0', '<')) {
958-
$response->addFilter(new ResponseV16());
944+
if (version_compare($responseFormat, '1.7.0', '<')) {
945+
$response->addFilter(new ResponseV19());
959946
}
960947
if (version_compare($responseFormat, APP_VERSION_STABLE, '>')) {
961948
$warnings[] = "The current SDK is built for Appwrite " . $responseFormat . ". However, the current Appwrite server version is " . APP_VERSION_STABLE . ". Please downgrade your SDK to match the Appwrite version: https://appwrite.io/docs/sdks";

app/controllers/mock.php

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use Utopia\Database\Helpers\ID;
1212
use Utopia\Database\Helpers\Permission;
1313
use Utopia\Database\Helpers\Role;
14-
use Utopia\Database\Validator\Datetime as DatetimeValidator;
1514
use Utopia\Database\Validator\UID;
1615
use Utopia\Http\Http;
1716
use Utopia\Locale\Locale;
@@ -220,53 +219,6 @@
220219
->dynamic($key, Response::MODEL_KEY);
221220
});
222221

223-
Http::post('/v1/mock/time-travels')
224-
->desc('Create a time-travel to change $createdAt')
225-
->groups(['mock', 'api'])
226-
->label('scope', 'public')
227-
->label('docs', false)
228-
->param('projectId', '', new UID(), 'Project ID.')
229-
->param('resourceType', '', new WhiteList(['deployment']), 'Type of resource.')
230-
->param('resourceId', '', new UID(), 'ID of resource.')
231-
->param('createdAt', '', new DatetimeValidator(), 'New value for $createdAt')
232-
->inject('response')
233-
->inject('getProjectDB')
234-
->inject('dbForPlatform')
235-
->action(function (string $projectId, string $resourceType, string $resourceId, string $createdAt, Response $response, callable $getProjectDB, Database $dbForPlatform) {
236-
$isDevelopment = System::getEnv('_APP_ENV', 'development') === 'development';
237-
238-
if (!$isDevelopment) {
239-
throw new Exception(Exception::GENERAL_NOT_IMPLEMENTED);
240-
}
241-
242-
$project = $dbForPlatform->getDocument('projects', $projectId);
243-
244-
if ($project->isEmpty()) {
245-
throw new Exception(Exception::PROJECT_NOT_FOUND);
246-
}
247-
248-
$collection = match($resourceType) {
249-
'deployment' => 'deployments',
250-
default => throw new Exception(Exception::GENERAL_NOT_IMPLEMENTED)
251-
};
252-
253-
/** @var Database $dbForProject */
254-
$dbForProject = $getProjectDB($project);
255-
256-
$resource = $dbForProject->getDocument($collection, $resourceId);
257-
if ($resource->isEmpty()) {
258-
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Resource not found');
259-
}
260-
261-
$update = new Document([
262-
'$createdAt' => $createdAt,
263-
]);
264-
265-
$dbForProject->withPreserveDates(fn () => $dbForProject->updateDocument($collection, $resourceId, $update));
266-
267-
$response->noContent();
268-
});
269-
270222
Http::get('/v1/mock/github/callback')
271223
->desc('Create installation document using GitHub installation id')
272224
->groups(['mock', 'api', 'vcs'])

app/init/constants.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
const APP_COMPUTE_CPUS_DEFAULT = 0.5;
9494
const APP_COMPUTE_MEMORY_DEFAULT = 512;
9595
const APP_COMPUTE_SPECIFICATION_DEFAULT = Specification::S_1VCPU_512MB;
96-
const APP_COMPUTE_DEPLOYMENT_MAX_RETENTION = 100 * 365; // 100 years
9796
const APP_SDK_PLATFORM_SERVER = 'server';
9897
const APP_SDK_PLATFORM_CLIENT = 'client';
9998
const APP_SDK_PLATFORM_CONSOLE = 'console';

0 commit comments

Comments
 (0)