Compare commits

..
Author SHA1 Message Date
Torsten DittmannandGitHub ba24c0a843 Merge pull request #5455 from appwrite/fix-1.3.1-migration
Prevent migration from overriding existing data
2023-04-28 21:34:04 +02:00
Steven Nguyen 1e5dc3ad6f Bump version to 1.3.3 2023-04-28 12:29:46 -07:00
Steven Nguyen d0cfad9085 Prevent migration from overriding existing data
For users already on 1.3.1, after upgrading to 1.3.2, the migration
script would override existing auths, password history, team prefs, and
(relationship) attribute options with empty values. This commit fixes
the migration to set to an existing value if there was one.
2023-04-28 12:20:30 -07:00
Torsten DittmannandGitHub b2c8e182a5 Merge pull request #5442 from appwrite/fix-project-deletion-leftovers
fix: project deletion leftovers
2023-04-27 20:19:09 +02:00
Torsten DittmannandGitHub ff5132867e Merge pull request #5444 from appwrite/feat-bump-abuse-audit-database
Feat bump abuse audit database
2023-04-27 20:16:39 +02:00
Steven Nguyen 11d523b050 Bump utopia abuse, audit, and database 2023-04-27 10:42:55 -07:00
Torsten Dittmann e7c311044b chore: add changelog 2023-04-27 18:04:00 +02:00
Torsten Dittmann 7529f02bd6 fix: also delete webhooks on project deletion 2023-04-27 17:41:14 +02:00
Torsten Dittmann 31e65d954b fix: deletes worker for projects 2023-04-27 17:37:14 +02:00
Torsten Dittmann e1cf068652 fix: platforms query 2023-04-27 17:36:00 +02:00
Torsten Dittmann d45bc5e60f chore: upgrade console 2023-04-27 15:54:07 +02:00
Torsten DittmannandGitHub fb507ad83b Merge pull request #5432 from appwrite/chore-sync-1-3-x
chore: sync 1.3.x with master
2023-04-26 18:16:21 +02:00
Torsten Dittmann e9e83ae8ec Merge branch 'master' of https://github.com/appwrite/appwrite into chore-sync-1-3-x 2023-04-26 12:30:14 +02:00
Jake BarnbyandGitHub 4aa6ce3cfd Merge pull request #5426 from appwrite/fix-apple-getting-started
Fix typo in Apple Getting Started
2023-04-26 16:37:24 +12:00
Christy JacobandGitHub 0e5e3f6f6f Merge pull request #5362 from appwrite/update-cli
feat: update cli version
2023-04-25 23:49:29 +05:30
Torsten DittmannandGitHub 4ceae33a5a Merge pull request #5163 from yatharth1706/fix-5147-fix-error-description-in-case-of-duplicate-user
fix error description for duplicate user
2023-04-25 15:45:59 +02:00
Torsten DittmannandGitHub 713535bf79 Merge pull request #5285 from rinkuhasija/fix-5272-correct-documentation-model-attributeDatetime-Object-example
fix-models-attributeDatetime-object-example
2023-04-25 15:45:39 +02:00
Torsten DittmannandGitHub aaf5ab9024 Merge pull request #5382 from appwrite/fix-5381-var-missing-after-upgrade
Fix missing var after upgrade
2023-04-25 15:41:43 +02:00
Christy JacobandGitHub 1c4dc6a424 Merge pull request #3696 from appwrite/fix-event-multi-execution
Fix: event multi-execution
2023-04-25 17:31:45 +04:00
StevenandGitHub 2d0cf85edd Fix typo in Apple Getting Started 2023-04-24 12:03:41 -07:00
Torsten Dittmann 43a6945d30 fix: migration 2023-04-24 13:21:31 +02:00
Torsten Dittmann 4ebe485f05 remove: leftover from http.php 2023-04-24 13:11:39 +02:00
Torsten Dittmann 5ee3c592a4 chore: release 1.3.2 2023-04-24 13:10:28 +02:00
Torsten Dittmann ff82a24a4b feat: migration 2023-04-24 13:00:23 +02:00
Torsten Dittmann 5925d61a9c chore: update composer 2023-04-21 13:04:37 +02:00
Steven Nguyen 3f72b738fa Fix related creates 2023-04-20 18:44:53 -07:00
Torsten Dittmann 0230671717 chore: upgrade utopia-php/database 2023-04-20 21:10:48 +02:00
Steven Nguyen e8dee9296c Fix update document not merging existing data 2023-04-20 10:10:51 -07:00
Steven Nguyen 4113ae7ca5 Allow updating document with read-only relationship
A user should be able to update a document without touching the
relationship.

Relates: https://github.com/appwrite/appwrite/issues/5404
2023-04-19 17:21:41 -07:00
Steven Nguyen 37afb82d1c Delegate permissions check to database layer 2023-04-19 17:21:41 -07:00
Steven Nguyen 611dd9b86c Return 404 if a user doesn't have access to a collection
It is better to return 404 so that an end user doesn't know if the
collection actually exists but they don't have access or they really
don't have access.
2023-04-19 17:21:41 -07:00
Steven Nguyen 50bb69290f Ensure collections are created with permissions and documentSecurity 2023-04-19 17:21:41 -07:00
Steven Nguyen 471c832a4f Bump utopia-php/database version 2023-04-19 17:21:41 -07:00
Steven Nguyen d41df04b6a Ensure vars are not lost during upgrade
Using a reference on an array element while iterating over it caused
some unexpected behavior. Instead of using a reference, this change
uses a key to allow us to edit the array element.

For reference on the problem, see https://stackoverflow.com/questions/70691375/foreach-with-reference-causing-arrays-last-element-to-repeat.
2023-04-14 16:18:31 -07:00
Jake BarnbyandGitHub d1740d2121 Merge pull request #5363 from appwrite/fix-nested-id-required
Fix auto-setting custom ID on nested documents
2023-04-14 22:37:24 +12:00
Jake Barnby 0dea80c9da Cache whether relation is a list 2023-04-14 22:03:16 +12:00
Jake Barnby fb130f3aa2 Merge remote-tracking branch 'origin/1.3.x' into fix-nested-id-required 2023-04-14 21:59:42 +12:00
Jake BarnbyandGitHub 78aadd2f39 Merge pull request #5361 from appwrite/fix-team-pres-empty-array
Ensure empty team prefs returns as JSON object rather array
2023-04-13 21:09:37 +12:00
Jake Barnby 08be9c4c89 Update changelog 2023-04-13 16:35:42 +12:00
Jake Barnby 975b044de0 Iterate relation by reference on update 2023-04-13 16:08:53 +12:00
Jake Barnby c7317b0468 Fix auto-setting custom ID on nested documents 2023-04-13 15:59:57 +12:00
Christy Jacob 0fcfeb50a6 feat: update cli version 2023-04-13 01:48:44 +04:00
Christy Jacob 5d4e0762bb feat: update cli version 2023-04-13 01:33:25 +04:00
Christy Jacob f30d11ed60 feat: update cli version 2023-04-13 01:23:49 +04:00
Steven Nguyen bb2b48193f Ensure empty team prefs returns as JSON object rather array 2023-04-12 12:06:48 -07:00
Rinku Hasija f5c7568287 fix-models-attributeDatetime-object-example
Signed-off-by: Rinku Hasija <rishabhasija5454@gmail.com>
2023-03-25 17:32:46 +05:30
yatharth b5f02bd6c8 fix error description for duplicate user 2023-02-25 20:36:09 +05:30
Matej Bačo 7c2fa12414 Fix getting function ID 2022-08-17 13:42:06 +00:00
Matej Bačo c93b7aa452 Fix event-triggered multi-execution 2022-08-17 13:34:52 +00:00
26 changed files with 330 additions and 202 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
[submodule "app/console"]
path = app/console
url = https://github.com/appwrite/console
branch = 2.3.3
branch = 2.3.4
+14 -2
View File
@@ -1,12 +1,24 @@
# Version 1.3.3
## Bugs
- Fixed migration resetting some data [#5455](https://github.com/appwrite/appwrite/pull/5455)
# Version 1.3.2
## Bugs
- Fixed auto-setting custom ID on nested documents [#5363](https://github.com/appwrite/appwrite/pull/5363)
- Fixed listDocuments not returning all the documents [#5395](https://github.com/appwrite/appwrite/pull/5395)
- Fixed deleting keys, webhooks, platforms and domains after deleting project [#5395](https://github.com/appwrite/appwrite/pull/5395)
# Version 1.3.1
## Bugs
- Fixed Migration issue regarding 500 error [4906](https://github.com/appwrite/appwrite/pull/5356)
- Fixed Migration issue regarding 500 error [#5356](https://github.com/appwrite/appwrite/pull/5356)
# Version 1.3.0
## Features
- Password dictionary setting allows to compare user's password against command password database [4906](https://github.com/appwrite/appwrite/pull/4906)
- Password dictionary setting allows to compare user's password against command password database [#4906](https://github.com/appwrite/appwrite/pull/4906)
- Password history setting allows to save user's last used password so that it may not be used again. Maximum number of history saved is 20, which can be configured. Minimum is 0 which means disabled. [#4866](https://github.com/appwrite/appwrite/pull/4866)
- Update APIs to check X-Appwrite-Timestamp header [#5024](https://github.com/appwrite/appwrite/pull/5024)
- Database relationships [#5238](https://github.com/appwrite/appwrite/pull/5238)
+3 -3
View File
@@ -67,7 +67,7 @@ docker run -it --rm \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \
--entrypoint="install" \
appwrite/appwrite:1.3.1
appwrite/appwrite:1.3.3
```
### Windows
@@ -79,7 +79,7 @@ docker run -it --rm ^
--volume //var/run/docker.sock:/var/run/docker.sock ^
--volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^
--entrypoint="install" ^
appwrite/appwrite:1.3.1
appwrite/appwrite:1.3.3
```
#### PowerShell
@@ -89,7 +89,7 @@ docker run -it --rm `
--volume /var/run/docker.sock:/var/run/docker.sock `
--volume ${pwd}/appwrite:/usr/src/code/appwrite:rw `
--entrypoint="install" `
appwrite/appwrite:1.3.1
appwrite/appwrite:1.3.3
```
运行后,可以在浏览器上访问 http://localhost 找到 Appwrite 控制台。在非 Linux 的本机主机上完成安装后,服务器可能需要几分钟才能启动。
+4 -3
View File
@@ -51,6 +51,7 @@ Table of Contents:
- [CMD](#cmd)
- [PowerShell](#powershell)
- [Upgrade from an Older Version](#upgrade-from-an-older-version)
- [One-Click Setups](#one-click-setups)
- [Getting Started](#getting-started)
- [Services](#services)
- [SDKs](#sdks)
@@ -76,7 +77,7 @@ docker run -it --rm \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \
--entrypoint="install" \
appwrite/appwrite:1.3.1
appwrite/appwrite:1.3.3
```
### Windows
@@ -88,7 +89,7 @@ docker run -it --rm ^
--volume //var/run/docker.sock:/var/run/docker.sock ^
--volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^
--entrypoint="install" ^
appwrite/appwrite:1.3.1
appwrite/appwrite:1.3.3
```
#### PowerShell
@@ -98,7 +99,7 @@ docker run -it --rm `
--volume /var/run/docker.sock:/var/run/docker.sock `
--volume ${pwd}/appwrite:/usr/src/code/appwrite:rw `
--entrypoint="install" `
appwrite/appwrite:1.3.1
appwrite/appwrite:1.3.3
```
Once the Docker installation is complete, go to http://localhost to access the Appwrite console from your browser. Please note that on non-Linux native hosts, the server might take a few minutes to start after completing the installation.
+1 -1
View File
@@ -102,7 +102,7 @@ return [
],
Exception::USER_ALREADY_EXISTS => [
'name' => Exception::USER_ALREADY_EXISTS,
'description' => 'A user with the same email already exists in your project.',
'description' => 'A user with the same id, email, or phone already exists in your project.',
'code' => 409,
],
Exception::USER_BLOCKED => [
+19 -19
View File
@@ -28,7 +28,7 @@ return [
'gitUrl' => 'git@github.com:appwrite/sdk-for-web.git',
'gitRepoName' => 'sdk-for-web',
'gitUserName' => 'appwrite',
'gitBranch' => 'master',
'gitBranch' => 'dev',
'demos' => [
[
'icon' => 'react.svg',
@@ -76,7 +76,7 @@ return [
'gitUrl' => 'git@github.com:appwrite/sdk-for-flutter.git',
'gitRepoName' => 'sdk-for-flutter',
'gitUserName' => 'appwrite',
'gitBranch' => 'master',
'gitBranch' => 'dev',
],
[
'key' => 'apple',
@@ -94,7 +94,7 @@ return [
'gitUrl' => 'git@github.com:appwrite/sdk-for-apple.git',
'gitRepoName' => 'sdk-for-apple',
'gitUserName' => 'appwrite',
'gitBranch' => 'master',
'gitBranch' => 'dev',
],
[
'key' => 'objective-c',
@@ -111,7 +111,7 @@ return [
'gitUrl' => 'git@github.com:appwrite/sdk-for-objective-c.git',
'gitRepoName' => 'sdk-for-objective-c',
'gitUserName' => 'appwrite',
'gitBranch' => 'master',
'gitBranch' => 'dev',
],
[
'key' => 'android',
@@ -129,7 +129,7 @@ return [
'gitUrl' => 'git@github.com:appwrite/sdk-for-android.git',
'gitRepoName' => 'sdk-for-android',
'gitUserName' => 'appwrite',
'gitBranch' => 'main',
'gitBranch' => 'dev',
'docDirectories' => [
'Kotlin' => 'kotlin',
'Java' => 'java',
@@ -196,14 +196,14 @@ return [
'prism' => 'javascript',
'source' => \realpath(__DIR__ . '/../sdks/console-web'),
'gitUrl' => 'git@github.com:appwrite/sdk-for-console.git',
'gitBranch' => 'main',
'gitBranch' => 'dev',
'gitRepoName' => 'sdk-for-console',
'gitUserName' => 'appwrite',
],
[
'key' => 'cli',
'name' => 'Command Line',
'version' => '2.0.0',
'version' => '2.0.2',
'url' => 'https://github.com/appwrite/sdk-for-cli',
'package' => 'https://www.npmjs.com/package/appwrite-cli',
'enabled' => true,
@@ -216,7 +216,7 @@ return [
'gitUrl' => 'git@github.com:appwrite/sdk-for-cli.git',
'gitRepoName' => 'sdk-for-cli',
'gitUserName' => 'appwrite',
'gitBranch' => 'master',
'gitBranch' => 'dev',
],
],
],
@@ -244,7 +244,7 @@ return [
'gitUrl' => 'git@github.com:appwrite/sdk-for-node.git',
'gitRepoName' => 'sdk-for-node',
'gitUserName' => 'appwrite',
'gitBranch' => 'master',
'gitBranch' => 'dev',
],
[
'key' => 'deno',
@@ -262,7 +262,7 @@ return [
'gitUrl' => 'git@github.com:appwrite/sdk-for-deno.git',
'gitRepoName' => 'sdk-for-deno',
'gitUserName' => 'appwrite',
'gitBranch' => 'master',
'gitBranch' => 'dev',
],
[
'key' => 'php',
@@ -280,7 +280,7 @@ return [
'gitUrl' => 'git@github.com:appwrite/sdk-for-php.git',
'gitRepoName' => 'sdk-for-php',
'gitUserName' => 'appwrite',
'gitBranch' => 'master',
'gitBranch' => 'dev',
],
[
'key' => 'python',
@@ -298,7 +298,7 @@ return [
'gitUrl' => 'git@github.com:appwrite/sdk-for-python.git',
'gitRepoName' => 'sdk-for-python',
'gitUserName' => 'appwrite',
'gitBranch' => 'master',
'gitBranch' => 'dev',
],
[
'key' => 'ruby',
@@ -316,7 +316,7 @@ return [
'gitUrl' => 'git@github.com:appwrite/sdk-for-ruby.git',
'gitRepoName' => 'sdk-for-ruby',
'gitUserName' => 'appwrite',
'gitBranch' => 'master',
'gitBranch' => 'dev',
],
[
'key' => 'go',
@@ -334,7 +334,7 @@ return [
'gitUrl' => 'git@github.com:appwrite/sdk-for-go.git',
'gitRepoName' => 'sdk-for-go',
'gitUserName' => 'appwrite',
'gitBranch' => 'master',
'gitBranch' => 'dev',
],
[
'key' => 'java',
@@ -352,7 +352,7 @@ return [
'gitUrl' => 'git@github.com:appwrite/sdk-for-java.git',
'gitRepoName' => 'sdk-for-java',
'gitUserName' => 'appwrite',
'gitBranch' => 'master',
'gitBranch' => 'dev',
],
[
'key' => 'dotnet',
@@ -370,7 +370,7 @@ return [
'gitUrl' => 'git@github.com:appwrite/sdk-for-dotnet.git',
'gitRepoName' => 'sdk-for-dotnet',
'gitUserName' => 'appwrite',
'gitBranch' => 'main',
'gitBranch' => 'dev',
],
[
'key' => 'dart',
@@ -388,7 +388,7 @@ return [
'gitUrl' => 'git@github.com:appwrite/sdk-for-dart.git',
'gitRepoName' => 'sdk-for-dart',
'gitUserName' => 'appwrite',
'gitBranch' => 'master',
'gitBranch' => 'dev',
],
[
'key' => 'kotlin',
@@ -406,7 +406,7 @@ return [
'gitUrl' => 'git@github.com:appwrite/sdk-for-kotlin.git',
'gitRepoName' => 'sdk-for-kotlin',
'gitUserName' => 'appwrite',
'gitBranch' => 'main',
'gitBranch' => 'dev',
'docDirectories' => [
'Kotlin' => 'kotlin',
'Java' => 'java',
@@ -428,7 +428,7 @@ return [
'gitUrl' => 'git@github.com:appwrite/sdk-for-swift.git',
'gitRepoName' => 'sdk-for-swift',
'gitUserName' => 'appwrite',
'gitBranch' => 'main',
'gitBranch' => 'dev',
],
[
'key' => 'graphql',
+72 -60
View File
@@ -743,7 +743,7 @@ App::post('/v1/databases/:databaseId/collections')
]));
$collection = $dbForProject->getDocument('database_' . $database->getInternalId(), $collectionId);
$dbForProject->createCollection('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId());
$dbForProject->createCollection('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), permissions: $permissions ?? [], documentSecurity: $documentSecurity);
} catch (DuplicateException) {
throw new Exception(Exception::COLLECTION_ALREADY_EXISTS);
} catch (LimitException) {
@@ -1001,6 +1001,7 @@ App::put('/v1/databases/:databaseId/collections/:collectionId')
->setAttribute('documentSecurity', $documentSecurity)
->setAttribute('enabled', $enabled)
->setAttribute('search', implode(' ', [$collectionId, $name])));
$dbForProject->updateCollection('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $permissions, $documentSecurity);
} catch (AuthorizationException) {
throw new Exception(Exception::USER_UNAUTHORIZED);
} catch (StructureException $exception) {
@@ -2399,7 +2400,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/indexes')
$attributeIndex = \array_search($attribute, array_column($oldAttributes, 'key'));
if ($attributeIndex === false) {
throw new Exception(Exception::ATTRIBUTE_UNKNOWN, 'Unknown attribute: ' . $attribute . '. Verify the attribute name or create the attribute.");
throw new Exception(Exception::ATTRIBUTE_UNKNOWN, 'Unknown attribute: ' . $attribute);
}
$attributeStatus = $oldAttributes[$attributeIndex]['status'];
@@ -2743,8 +2744,13 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/documents')
if (empty($related)) {
continue;
}
if (!\is_array($related)) {
$related = [$related];
$isList = \is_array($related) && \array_values($related) === $related;
if ($isList) {
$relations = $related;
} else {
$relations = [$related];
}
$relatedCollectionId = $relationship->getAttribute('relatedCollection');
@@ -2752,7 +2758,15 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/documents')
fn() => $dbForProject->getDocument('database_' . $database->getInternalId(), $relatedCollectionId)
);
foreach ($related as $relation) {
foreach ($relations as &$relation) {
if (
\is_array($relation)
&& \array_values($relation) !== $relation
&& !isset($relation['$id'])
) {
$relation['$id'] = ID::unique();
$relation = new Document($relation);
}
if ($relation instanceof Document) {
$current = Authorization::skip(
fn() => $dbForProject->getDocument('database_' . $database->getInternalId() . '_collection_' . $relatedCollection->getInternalId(), $relation->getId())
@@ -2761,7 +2775,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/documents')
if ($current->isEmpty()) {
$type = Database::PERMISSION_CREATE;
if (!isset($relation['$id']) || $relation['$id'] === 'unique()') {
if (isset($relation['$id']) && $relation['$id'] === 'unique()') {
$relation['$id'] = ID::unique();
}
} else {
@@ -2774,6 +2788,12 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/documents')
$checkPermissions($relatedCollection, $relation, $type);
}
}
if ($isList) {
$document->setAttribute($relationship->getAttribute('key'), \array_values($relations));
} else {
$document->setAttribute($relationship->getAttribute('key'), \reset($relations));
}
}
};
@@ -2866,12 +2886,19 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents')
$collection = Authorization::skip(fn() => $dbForProject->getDocument('database_' . $database->getInternalId(), $collectionId));
if ($collection->isEmpty() || !$collection->getAttribute('enabled')) {
if (!($mode === APP_MODE_ADMIN && Auth::isPrivilegedUser(Authorization::getRoles()))) {
throw new Exception(Exception::COLLECTION_NOT_FOUND);
if (!($mode === APP_MODE_ADMIN && Auth::isPrivilegedUser(Authorization::getRoles()))) {
if (!$collection->getAttribute('documentSecurity', false)) {
$validator = new Authorization(Database::PERMISSION_READ);
if (!$validator->isValid($collection->getRead())) {
$collection = new Document();
}
}
}
if ($collection->isEmpty() || !$collection->getAttribute('enabled')) {
throw new Exception(Exception::COLLECTION_NOT_FOUND);
}
// Validate queries
$queriesValidator = new Documents($collection->getAttribute('attributes'), $collection->getAttribute('indexes'));
$validQueries = $queriesValidator->isValid($queries);
@@ -2898,34 +2925,16 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents')
$filterQueries = Query::groupByType($queries)['filters'];
$documents = Authorization::skip(fn () => $dbForProject->find('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $queries));
$documentSecurity = $collection->getAttribute('documentSecurity', false);
$validator = new Authorization(Database::PERMISSION_READ);
$valid = $validator->isValid($collection->getRead());
if (!$valid) {
$total = $documentSecurity
? $dbForProject->count('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $filterQueries, APP_LIMIT_COUNT)
: 0;
} else {
$total = Authorization::skip(fn() => $dbForProject->count('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $filterQueries, APP_LIMIT_COUNT));
}
$documents = $dbForProject->find('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $queries);
$total = $dbForProject->count('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $filterQueries, APP_LIMIT_COUNT);
// Add $collectionId and $databaseId for all documents
$processDocument = function (Document $collection, Document $document) use (&$processDocument, $dbForProject, $database): bool {
$documentSecurity = $collection->getAttribute('documentSecurity', false);
$validator = new Authorization(Database::PERMISSION_READ);
$valid = $validator->isValid($collection->getRead());
if (!$documentSecurity && !$valid) {
return false;
}
$valid = $valid || $validator->isValid($document->getRead());
if ($documentSecurity && !$valid) {
if ($document->isEmpty()) {
return false;
}
$document->removeAttribute('$collection');
$document->setAttribute('$databaseId', $database->getId());
$document->setAttribute('$collectionId', $collection->getId());
@@ -2969,18 +2978,10 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents')
};
// The linter is forcing this indentation
foreach ($documents as $index => $document) {
if (!$processDocument($collection, $document)) {
unset($documents[$index]);
if ($valid) {
$total--;
}
}
foreach ($documents as $document) {
$processDocument($collection, $document);
}
$documents = \array_values($documents);
$response->dynamic(new Document([
'total' => $total,
'documents' => $documents,
@@ -3035,7 +3036,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documen
$queries = Query::parseQueries($queries);
$document = Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $documentId, $queries));
$document = $dbForProject->getDocument('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $documentId, $queries);
if ($document->isEmpty()) {
throw new Exception(Exception::DOCUMENT_NOT_FOUND);
@@ -3043,17 +3044,8 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documen
// Add $collectionId and $databaseId for all documents
$processDocument = function (Document $collection, Document $document) use (&$processDocument, $dbForProject, $database) {
$documentSecurity = $collection->getAttribute('documentSecurity', false);
$validator = new Authorization(Database::PERMISSION_READ);
$valid = $validator->isValid($collection->getRead());
if (!$documentSecurity && !$valid) {
throw new Exception(Exception::DOCUMENT_NOT_FOUND);
}
$valid = $valid || $validator->isValid($document->getRead());
if ($documentSecurity && !$valid) {
throw new Exception(Exception::DOCUMENT_NOT_FOUND);
if ($document->isEmpty()) {
return;
}
$document->setAttribute('$databaseId', $database->getId());
@@ -3287,7 +3279,6 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum
$permissions = $document->getPermissions() ?? [];
}
$data = \array_merge($document->getArrayCopy(), $data);
$data['$collection'] = $collection->getId(); // Make sure user doesn't switch collectionID
$data['$createdAt'] = $document->getCreatedAt(); // Make sure user doesn't switch createdAt
$data['$id'] = $document->getId(); // Make sure user doesn't switch document unique ID
@@ -3321,8 +3312,13 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum
if (empty($related)) {
continue;
}
if (!\is_array($related)) {
$related = [$related];
$isList = \is_array($related) && \array_values($related) === $related;
if ($isList) {
$relations = $related;
} else {
$relations = [$related];
}
$relatedCollectionId = $relationship->getAttribute('relatedCollection');
@@ -3330,7 +3326,15 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum
fn() => $dbForProject->getDocument('database_' . $database->getInternalId(), $relatedCollectionId)
);
foreach ($related as $relation) {
foreach ($relations as &$relation) {
if (
\is_array($relation)
&& \array_values($relation) !== $relation
&& !isset($relation['$id'])
) {
$relation['$id'] = ID::unique();
$relation = new Document($relation);
}
if ($relation instanceof Document) {
$oldDocument = Authorization::skip(fn() => $dbForProject->getDocument(
'database_' . $database->getInternalId() . '_collection_' . $relatedCollection->getInternalId(),
@@ -3340,7 +3344,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum
if ($oldDocument->isEmpty()) {
$type = Database::PERMISSION_CREATE;
if (!isset($relation['$id']) || $relation['$id'] === 'unique()') {
if (isset($relation['$id']) && $relation['$id'] === 'unique()') {
$relation['$id'] = ID::unique();
}
} else {
@@ -3353,20 +3357,28 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum
$checkPermissions($relatedCollection, $relation, $oldDocument, $type);
}
}
if ($isList) {
$document->setAttribute($relationship->getAttribute('key'), \array_values($relations));
} else {
$document->setAttribute($relationship->getAttribute('key'), \reset($relations));
}
}
};
$checkPermissions($collection, $newDocument, $document, Database::PERMISSION_UPDATE);
$newDocument = new Document(\array_merge($document->getArrayCopy(), $data));
try {
$document = Authorization::skip(fn() => $dbForProject->withRequestTimestamp(
$document = $dbForProject->withRequestTimestamp(
$requestTimestamp,
fn () => $dbForProject->updateDocument(
'database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(),
$document->getId(),
$newDocument
)
));
);
} catch (AuthorizationException) {
throw new Exception(Exception::USER_UNAUTHORIZED);
} catch (DuplicateException) {
+1 -1
View File
@@ -1237,7 +1237,7 @@ App::get('/v1/projects/:projectId/platforms')
}
$platforms = $dbForConsole->find('platforms', [
Query::equal('projectId', [$project->getId()]),
Query::equal('projectInternalId', [$project->getInternalId()]),
Query::limit(5000),
]);
-6
View File
@@ -115,12 +115,6 @@ $http->on('start', function (Server $http) use ($payloadSize, $register) {
if (!$dbForConsole->getCollection($key)->isEmpty()) {
continue;
}
/**
* Skip to prevent 0.16 migration issues.
*/
if (in_array($key, ['cache', 'variables']) && $dbForConsole->exists(App::getEnv('_APP_DB_SCHEMA', 'appwrite'), 'bucket_1')) {
continue;
}
Console::success('[Setup] - Creating collection: ' . $collection['$id'] . '...');
+1 -1
View File
@@ -101,7 +101,7 @@ const APP_LIMIT_LIST_DEFAULT = 25; // Default maximum number of items to return
const APP_KEY_ACCCESS = 24 * 60 * 60; // 24 hours
const APP_CACHE_UPDATE = 24 * 60 * 60; // 24 hours
const APP_CACHE_BUSTER = 503;
const APP_VERSION_STABLE = '1.3.1';
const APP_VERSION_STABLE = '1.3.3';
const APP_DATABASE_ATTRIBUTE_EMAIL = 'email';
const APP_DATABASE_ATTRIBUTE_ENUM = 'enum';
const APP_DATABASE_ATTRIBUTE_IP = 'ip';
+5 -5
View File
@@ -95,9 +95,9 @@ $cli
if (is_null($value)) {
continue;
}
foreach ($vars as &$var) {
foreach ($vars as $i => $var) {
if ($var['name'] === $key) {
$var['default'] = $value;
$vars[$i]['default'] = $value;
}
}
}
@@ -114,9 +114,9 @@ $cli
if (is_null($value)) {
continue;
}
foreach ($vars as &$var) {
foreach ($vars as $i => $var) {
if ($var['name'] === $key) {
$var['default'] = $value;
$vars[$i]['default'] = $value;
}
}
}
@@ -146,7 +146,7 @@ $cli
$input = [];
foreach ($vars as $key => $var) {
foreach ($vars as $var) {
if (!empty($var['filter']) && ($interactive !== 'Y' || !Console::isInteractive())) {
if ($data && $var['default'] !== null) {
$input[$var['name']] = $var['default'];
+2 -2
View File
@@ -239,8 +239,8 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
cd ' . $target . ' && \
git init --initial-branch=' . $gitBranch . ' && \
git remote add origin ' . $gitUrl . ' && \
git fetch && \
git pull ' . $gitUrl . ' && \
git fetch origin ' . $gitBranch . ' && \
git pull origin ' . $gitBranch . ' && \
rm -rf ' . $target . '/* && \
cp -r ' . $result . '/* ' . $target . '/ && \
git add . && \
+23 -3
View File
@@ -9,7 +9,6 @@ use Utopia\Database\Document;
use Utopia\Database\Query;
use Appwrite\Resque\Worker;
use Executor\Executor;
use Utopia\Storage\Device\Local;
use Utopia\Abuse\Abuse;
use Utopia\Abuse\Adapters\TimeLimit;
use Utopia\CLI\Console;
@@ -291,12 +290,13 @@ class DeletesV1 extends Worker
protected function deleteProject(Document $document): void
{
$projectId = $document->getId();
$projectInternalId = $document->getInternalId();
// Delete project domains and certificates
// Delete project certificates
$dbForConsole = $this->getConsoleDB();
$domains = $dbForConsole->find('domains', [
Query::equal('projectInternalId', [$document->getInternalId()])
Query::equal('projectInternalId', [$projectInternalId])
]);
foreach ($domains as $domain) {
@@ -318,6 +318,26 @@ class DeletesV1 extends Worker
}
}
// Delete Platforms
$this->deleteByGroup('platforms', [
Query::equal('projectInternalId', [$projectInternalId])
], $dbForConsole);
// Delete Domains
$this->deleteByGroup('domains', [
Query::equal('projectInternalId', [$projectInternalId])
], $dbForConsole);
// Delete Keys
$this->deleteByGroup('keys', [
Query::equal('projectInternalId', [$projectInternalId])
], $dbForConsole);
// Delete Webhooks
$this->deleteByGroup('webhooks', [
Query::equal('projectInternalId', [$projectInternalId])
], $dbForConsole);
// Delete metadata tables
try {
$dbForProject->deleteCollection('_metadata');
+15 -11
View File
@@ -82,18 +82,22 @@ class FunctionsV1 extends Worker
Console::success('Iterating function: ' . $function->getAttribute('name'));
$this->execute(
project: $project,
function: $function,
dbForProject: $database,
trigger: 'event',
// Pass first, most verbose event pattern
event: $events[0],
eventData: $payload,
user: $user
);
try {
$this->execute(
project: $project,
function: $function,
dbForProject: $database,
trigger: 'event',
// Pass first, most verbose event pattern
event: $events[0],
eventData: $payload,
user: $user
);
Console::success('Triggered function: ' . $events[0]);
Console::success('Triggered function: ' . $events[0]);
} catch (\Throwable $th) {
Console::error("Failed to execute " . $function->getId() . " with error: " . $th->getMessage());
}
}
}
+3 -3
View File
@@ -43,13 +43,13 @@
"ext-sockets": "*",
"appwrite/php-clamav": "1.1.*",
"appwrite/php-runtimes": "0.11.*",
"utopia-php/abuse": "0.24.*",
"utopia-php/abuse": "0.25.*",
"utopia-php/analytics": "0.2.*",
"utopia-php/audit": "0.25.*",
"utopia-php/audit": "0.26.*",
"utopia-php/cache": "0.8.*",
"utopia-php/cli": "0.13.*",
"utopia-php/config": "0.2.*",
"utopia-php/database": "0.35.*",
"utopia-php/database": "0.36.*",
"utopia-php/domains": "1.1.*",
"utopia-php/framework": "0.28.*",
"utopia-php/image": "0.5.*",
Generated
+63 -66
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": "87de4ea3130e576470a63b21628e30fb",
"content-hash": "169ab6e7dd540e45309d3c5093506fad",
"packages": [
{
"name": "adhocore/jwt",
@@ -300,16 +300,16 @@
},
{
"name": "colinmollenhour/credis",
"version": "v1.14.0",
"version": "v1.15.0",
"source": {
"type": "git",
"url": "https://github.com/colinmollenhour/credis.git",
"reference": "dccc8a46586475075fbb012d8bd523b8a938c2dc"
"reference": "28810439de1d9597b7ba11794ed9479fb6f3de7c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/colinmollenhour/credis/zipball/dccc8a46586475075fbb012d8bd523b8a938c2dc",
"reference": "dccc8a46586475075fbb012d8bd523b8a938c2dc",
"url": "https://api.github.com/repos/colinmollenhour/credis/zipball/28810439de1d9597b7ba11794ed9479fb6f3de7c",
"reference": "28810439de1d9597b7ba11794ed9479fb6f3de7c",
"shasum": ""
},
"require": {
@@ -341,9 +341,9 @@
"homepage": "https://github.com/colinmollenhour/credis",
"support": {
"issues": "https://github.com/colinmollenhour/credis/issues",
"source": "https://github.com/colinmollenhour/credis/tree/v1.14.0"
"source": "https://github.com/colinmollenhour/credis/tree/v1.15.0"
},
"time": "2022-11-09T01:18:39+00:00"
"time": "2023-04-18T15:34:23+00:00"
},
{
"name": "composer/package-versions-deprecated",
@@ -481,22 +481,22 @@
},
{
"name": "guzzlehttp/guzzle",
"version": "7.5.0",
"version": "7.5.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "b50a2a1251152e43f6a37f0fa053e730a67d25ba"
"reference": "b964ca597e86b752cd994f27293e9fa6b6a95ed9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/b50a2a1251152e43f6a37f0fa053e730a67d25ba",
"reference": "b50a2a1251152e43f6a37f0fa053e730a67d25ba",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/b964ca597e86b752cd994f27293e9fa6b6a95ed9",
"reference": "b964ca597e86b752cd994f27293e9fa6b6a95ed9",
"shasum": ""
},
"require": {
"ext-json": "*",
"guzzlehttp/promises": "^1.5",
"guzzlehttp/psr7": "^1.9 || ^2.4",
"guzzlehttp/psr7": "^1.9.1 || ^2.4.5",
"php": "^7.2.5 || ^8.0",
"psr/http-client": "^1.0",
"symfony/deprecation-contracts": "^2.2 || ^3.0"
@@ -589,7 +589,7 @@
],
"support": {
"issues": "https://github.com/guzzle/guzzle/issues",
"source": "https://github.com/guzzle/guzzle/tree/7.5.0"
"source": "https://github.com/guzzle/guzzle/tree/7.5.1"
},
"funding": [
{
@@ -605,7 +605,7 @@
"type": "tidelift"
}
],
"time": "2022-08-28T15:39:27+00:00"
"time": "2023-04-17T16:30:08+00:00"
},
{
"name": "guzzlehttp/promises",
@@ -693,22 +693,22 @@
},
{
"name": "guzzlehttp/psr7",
"version": "2.4.4",
"version": "2.5.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "3cf1b6d4f0c820a2cf8bcaec39fc698f3443b5cf"
"reference": "b635f279edd83fc275f822a1188157ffea568ff6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/3cf1b6d4f0c820a2cf8bcaec39fc698f3443b5cf",
"reference": "3cf1b6d4f0c820a2cf8bcaec39fc698f3443b5cf",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/b635f279edd83fc275f822a1188157ffea568ff6",
"reference": "b635f279edd83fc275f822a1188157ffea568ff6",
"shasum": ""
},
"require": {
"php": "^7.2.5 || ^8.0",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0",
"psr/http-message": "^1.1 || ^2.0",
"ralouphie/getallheaders": "^3.0"
},
"provide": {
@@ -728,9 +728,6 @@
"bamarni-bin": {
"bin-links": true,
"forward-command": false
},
"branch-alias": {
"dev-master": "2.4-dev"
}
},
"autoload": {
@@ -792,7 +789,7 @@
],
"support": {
"issues": "https://github.com/guzzle/psr7/issues",
"source": "https://github.com/guzzle/psr7/tree/2.4.4"
"source": "https://github.com/guzzle/psr7/tree/2.5.0"
},
"funding": [
{
@@ -808,7 +805,7 @@
"type": "tidelift"
}
],
"time": "2023-03-09T13:19:02+00:00"
"time": "2023-04-17T16:11:26+00:00"
},
{
"name": "influxdb/influxdb-php",
@@ -1372,16 +1369,16 @@
},
{
"name": "psr/http-message",
"version": "1.1",
"version": "2.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
"reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba"
"reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/cb6ce4845ce34a8ad9e68117c10ee90a29919eba",
"reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71",
"reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71",
"shasum": ""
},
"require": {
@@ -1390,7 +1387,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1.x-dev"
"dev-master": "2.0.x-dev"
}
},
"autoload": {
@@ -1405,7 +1402,7 @@
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for HTTP messages",
@@ -1419,9 +1416,9 @@
"response"
],
"support": {
"source": "https://github.com/php-fig/http-message/tree/1.1"
"source": "https://github.com/php-fig/http-message/tree/2.0"
},
"time": "2023-04-04T09:50:52+00:00"
"time": "2023-04-04T09:54:51+00:00"
},
{
"name": "psr/log",
@@ -1808,26 +1805,26 @@
},
{
"name": "utopia-php/abuse",
"version": "0.24.0",
"version": "0.25.0",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/abuse.git",
"reference": "403641f16a53b81ac40b91111a86e5672da49e8c"
"reference": "49a180cab5316cddec9676d900d5112d03e97ffc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/abuse/zipball/403641f16a53b81ac40b91111a86e5672da49e8c",
"reference": "403641f16a53b81ac40b91111a86e5672da49e8c",
"url": "https://api.github.com/repos/utopia-php/abuse/zipball/49a180cab5316cddec9676d900d5112d03e97ffc",
"reference": "49a180cab5316cddec9676d900d5112d03e97ffc",
"shasum": ""
},
"require": {
"ext-curl": "*",
"ext-pdo": "*",
"php": ">=8.0",
"utopia-php/database": "0.35.*"
"utopia-php/database": "0.36.*"
},
"require-dev": {
"laravel/pint": "1.2.*",
"laravel/pint": "1.5.*",
"phpstan/phpstan": "^1.9",
"phpunit/phpunit": "^9.4"
},
@@ -1851,9 +1848,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/abuse/issues",
"source": "https://github.com/utopia-php/abuse/tree/0.24.0"
"source": "https://github.com/utopia-php/abuse/tree/0.25.0"
},
"time": "2023-04-11T05:31:55+00:00"
"time": "2023-04-27T15:43:47+00:00"
},
{
"name": "utopia-php/analytics",
@@ -1912,24 +1909,24 @@
},
{
"name": "utopia-php/audit",
"version": "0.25.0",
"version": "0.26.0",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/audit.git",
"reference": "adc209f2e16878e5468f0b9cfd9f7f7ab497db31"
"reference": "e7228080f14df28737fbb050c180c26d86ac0403"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/audit/zipball/adc209f2e16878e5468f0b9cfd9f7f7ab497db31",
"reference": "adc209f2e16878e5468f0b9cfd9f7f7ab497db31",
"url": "https://api.github.com/repos/utopia-php/audit/zipball/e7228080f14df28737fbb050c180c26d86ac0403",
"reference": "e7228080f14df28737fbb050c180c26d86ac0403",
"shasum": ""
},
"require": {
"php": ">=8.0",
"utopia-php/database": "0.35.*"
"utopia-php/database": "0.36.*"
},
"require-dev": {
"laravel/pint": "1.2.*",
"laravel/pint": "1.5.*",
"phpstan/phpstan": "^1.8",
"phpunit/phpunit": "^9.3"
},
@@ -1953,9 +1950,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/audit/issues",
"source": "https://github.com/utopia-php/audit/tree/0.25.0"
"source": "https://github.com/utopia-php/audit/tree/0.26.0"
},
"time": "2023-04-11T05:31:15+00:00"
"time": "2023-04-27T15:43:50+00:00"
},
{
"name": "utopia-php/cache",
@@ -2112,16 +2109,16 @@
},
{
"name": "utopia-php/database",
"version": "0.35.0",
"version": "0.36.1",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/database.git",
"reference": "f162c142fd61753c4b413b15c3c4041f3cd00bb2"
"reference": "f6ab65e59a199da5155c114564077b1ab8c4daef"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/database/zipball/f162c142fd61753c4b413b15c3c4041f3cd00bb2",
"reference": "f162c142fd61753c4b413b15c3c4041f3cd00bb2",
"url": "https://api.github.com/repos/utopia-php/database/zipball/f6ab65e59a199da5155c114564077b1ab8c4daef",
"reference": "f6ab65e59a199da5155c114564077b1ab8c4daef",
"shasum": ""
},
"require": {
@@ -2164,9 +2161,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/database/issues",
"source": "https://github.com/utopia-php/database/tree/0.35.0"
"source": "https://github.com/utopia-php/database/tree/0.36.1"
},
"time": "2023-04-11T04:02:22+00:00"
"time": "2023-04-27T08:39:55+00:00"
},
{
"name": "utopia-php/domains",
@@ -3037,16 +3034,16 @@
"packages-dev": [
{
"name": "appwrite/sdk-generator",
"version": "0.32.1",
"version": "0.32.2",
"source": {
"type": "git",
"url": "https://github.com/appwrite/sdk-generator.git",
"reference": "ba1d7afd57e3baef06c04ce6abc26f79310146df"
"reference": "cdec289bcf38c99d0074414d2438e9967d0c9699"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/ba1d7afd57e3baef06c04ce6abc26f79310146df",
"reference": "ba1d7afd57e3baef06c04ce6abc26f79310146df",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/cdec289bcf38c99d0074414d2438e9967d0c9699",
"reference": "cdec289bcf38c99d0074414d2438e9967d0c9699",
"shasum": ""
},
"require": {
@@ -3082,9 +3079,9 @@
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
"support": {
"issues": "https://github.com/appwrite/sdk-generator/issues",
"source": "https://github.com/appwrite/sdk-generator/tree/0.32.1"
"source": "https://github.com/appwrite/sdk-generator/tree/0.32.2"
},
"time": "2023-04-12T04:43:07+00:00"
"time": "2023-04-12T21:06:57+00:00"
},
{
"name": "doctrine/deprecations",
@@ -3787,16 +3784,16 @@
},
{
"name": "phpstan/phpdoc-parser",
"version": "1.18.1",
"version": "1.20.3",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpdoc-parser.git",
"reference": "22dcdfd725ddf99583bfe398fc624ad6c5004a0f"
"reference": "6c04009f6cae6eda2f040745b6b846080ef069c2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/22dcdfd725ddf99583bfe398fc624ad6c5004a0f",
"reference": "22dcdfd725ddf99583bfe398fc624ad6c5004a0f",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/6c04009f6cae6eda2f040745b6b846080ef069c2",
"reference": "6c04009f6cae6eda2f040745b6b846080ef069c2",
"shasum": ""
},
"require": {
@@ -3826,9 +3823,9 @@
"description": "PHPDoc parser with support for nullable, intersection and generic types",
"support": {
"issues": "https://github.com/phpstan/phpdoc-parser/issues",
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.18.1"
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.20.3"
},
"time": "2023-04-07T11:51:11+00:00"
"time": "2023-04-25T09:01:03+00:00"
},
{
"name": "phpunit/php-code-coverage",
@@ -0,0 +1 @@
appwrite console variables
+1 -1
View File
@@ -1 +1 @@
Create a new document. Before using this route, you should create a new collection and at least one attribute using either a [server integration](/docs/server/databases#databasesCreateCollection) API or directly from the Appwrite Console.
Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](/docs/server/databases#databasesCreateCollection) API or directly from your database console.
+1 -1
View File
@@ -33,7 +33,7 @@ Next we need to add a hook to save cookies when our app is opened by its callbac
> If you're using UIKit, you can skip this section.
In SwiftUI this is as simple as ensuring `.registerOAuthHanlder()` is called on the `View` you want to invoke an OAuth request from.
In SwiftUI this is as simple as ensuring `.registerOAuthHandler()` is called on the `View` you want to invoke an OAuth request from.
### Updating the SceneDelegate for UIKit
+11
View File
@@ -37,6 +37,9 @@ abstract class Migration
*/
protected Database $consoleDB;
/**
* @var \PDO
*/
protected \PDO $pdo;
/**
@@ -54,6 +57,8 @@ abstract class Migration
'1.2.1' => 'V17',
'1.3.0' => 'V18',
'1.3.1' => 'V18',
'1.3.2' => 'V18',
'1.3.3' => 'V18',
];
/**
@@ -102,6 +107,12 @@ abstract class Migration
return $this;
}
/**
* Set PDO for Migration.
*
* @param \PDO $pdo
* @return \Appwrite\Migration\Migration
*/
public function setPDO(\PDO $pdo): self
{
$this->pdo = $pdo;
+44 -5
View File
@@ -6,6 +6,8 @@ use Appwrite\Migration\Migration;
use Utopia\CLI\Console;
use Utopia\Database\Database;
use Utopia\Database\Document;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
class V18 extends Migration
{
@@ -25,6 +27,7 @@ class V18 extends Migration
Console::log('Migrating Project: ' . $this->project->getAttribute('name') . ' (' . $this->project->getId() . ')');
$this->projectDB->setNamespace("_{$this->project->getInternalId()}");
$this->addDocumentSecurityToProject();
Console::info('Migrating Databases');
$this->migrateDatabases();
@@ -58,6 +61,15 @@ class V18 extends Migration
}
$this->changeAttributeInternalType($collectionTable, $attribute['key'], 'DOUBLE');
}
try {
$documentSecurity = $collection->getAttribute('documentSecurity', false);
$permissions = $collection->getPermissions();
$this->projectDB->updateCollection($collectionTable, $permissions, $documentSecurity);
} catch (\Throwable $th) {
Console::warning($th->getMessage());
}
}
}
}
@@ -81,6 +93,12 @@ class V18 extends Migration
$this->changeAttributeInternalType($id, $attribute['$id'], 'DOUBLE');
}
try {
$this->projectDB->updateCollection($id, [Permission::create(Role::any())], true);
} catch (\Throwable $th) {
Console::warning($th->getMessage());
}
switch ($id) {
case 'users':
try {
@@ -141,31 +159,52 @@ class V18 extends Migration
/**
* Set default passwordHistory
*/
$document->setAttribute('auths', array_merge($document->getAttribute('auths', []), [
$document->setAttribute('auths', array_merge([
'passwordHistory' => 0,
'passwordDictionary' => false,
]));
], $document->getAttribute('auths', [])));
break;
case 'users':
/**
* Default Password history
*/
$document->setAttribute('passwordHistory', []);
$document->setAttribute('passwordHistory', $document->getAttribute('passwordHistory', []));
break;
case 'teams':
/**
* Default prefs
*/
$document->setAttribute('prefs', new \stdClass());
$document->setAttribute('prefs', $document->getAttribute('prefs', new \stdClass()));
break;
case 'attributes':
/**
* Default options
*/
$document->setAttribute('options', new \stdClass());
$document->setAttribute('options', $document->getAttribute('options', new \stdClass()));
break;
}
return $document;
}
protected function addDocumentSecurityToProject(): void
{
try {
/**
* Create 'documentSecurity' column
*/
$this->pdo->prepare("ALTER TABLE `{$this->projectDB->getDefaultDatabase()}`.`_{$this->project->getInternalId()}__metadata` ADD COLUMN IF NOT EXISTS documentSecurity TINYINT(1);")->execute();
} catch (\Throwable $th) {
Console::warning($th->getMessage());
}
try {
/**
* Set 'documentSecurity' column to 1 if NULL
*/
$this->pdo->prepare("UPDATE `{$this->projectDB->getDefaultDatabase()}`.`_{$this->project->getInternalId()}__metadata` SET documentSecurity = 1 WHERE documentSecurity IS NULL")->execute();
} catch (\Throwable $th) {
Console::warning($th->getMessage());
}
}
}
@@ -18,10 +18,10 @@ class AttributeDatetime extends Attribute
'example' => 'birthDay',
])
->addRule('type', [
'type' => self::TYPE_DATETIME,
'type' => self::TYPE_STRING,
'description' => 'Attribute type.',
'default' => '',
'example' => self::TYPE_DATETIME_EXAMPLE,
'example' => self::TYPE_DATETIME,
])
->addRule('format', [
'type' => self::TYPE_DATETIME,
@@ -4,6 +4,7 @@ namespace Appwrite\Utopia\Response\Model;
use Appwrite\Utopia\Response;
use Appwrite\Utopia\Response\Model;
use Utopia\Database\Document;
class Team extends Model
{
@@ -49,6 +50,24 @@ class Team extends Model
;
}
/**
* Process Document before returning it to the client
*
* @return Document
*/
public function filter(Document $document): Document
{
$prefs = $document->getAttribute('prefs');
if ($prefs instanceof Document) {
$prefs = $prefs->getArrayCopy();
}
if (is_array($prefs) && empty($prefs)) {
$document->setAttribute('prefs', new \stdClass());
}
return $document;
}
/**
* Get Name
*
+22 -4
View File
@@ -2853,9 +2853,7 @@ trait DatabasesBase
]);
// Current user has no collection permissions and document permissions are disabled
$this->assertEquals(200, $documentsUser2['headers']['status-code']);
$this->assertEquals(0, $documentsUser2['body']['total']);
$this->assertEquals(true, empty($documentsUser2['body']['documents']));
$this->assertEquals(404, $documentsUser2['headers']['status-code']);
// Enable document permissions
$collection = $this->client->call(CLient::METHOD_PUT, '/databases/' . $databaseId . '/collections/' . $collectionId, [
@@ -3339,6 +3337,26 @@ trait DatabasesBase
$this->assertEquals('Library 1', $person1['body']['library']['libraryName']);
// Create without nested ID
$person2 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $person['body']['$id'] . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'data' => [
'library' => [
'libraryName' => 'Library 2',
],
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
]
]);
$this->assertEquals('Library 2', $person2['body']['library']['libraryName']);
// Ensure IDs were set and internal IDs removed
$this->assertEquals($databaseId, $person1['body']['$databaseId']);
$this->assertEquals($databaseId, $person1['body']['library']['$databaseId']);
@@ -3901,7 +3919,7 @@ trait DatabasesBase
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(1, count($response['body']['documents']));
$this->assertEquals(2, count($response['body']['documents']));
$this->assertEquals(null, $response['body']['documents'][0]['fullName']);
$this->assertArrayNotHasKey("libraries", $response['body']['documents'][0]);
}
@@ -176,7 +176,7 @@ class DatabasesPermissionsTeamTest extends Scope
if ($success) {
$this->assertCount(1, $documents['body']['documents']);
} else {
$this->assertCount(0, $documents['body']['documents']);
$this->assertEquals(404, $documents['headers']['status-code']);
}
}