Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat. HTTP Framework V2 #376

Merged
merged 52 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
bf740e2
fix validator namespaces
lohanidamodar Jul 18, 2023
3bf21fd
Switch v2 branch
Meldiron Oct 4, 2023
ffa1b71
Merge branch 'main' into feat-framework-v2
Meldiron Oct 5, 2023
1d4ab3d
Fix lockfile after merge
Meldiron Oct 5, 2023
41134cc
Make authorization per-instance
Meldiron Oct 19, 2023
a8bec8b
Fix incorrect Auth instance in tests
Meldiron Oct 19, 2023
fefad52
Fix tests
Meldiron Oct 19, 2023
c14be0f
PR review changes
Meldiron Jan 3, 2024
00c1553
Refactor auth message and action
Meldiron Jan 3, 2024
c2f3585
Fix test
Meldiron Jan 3, 2024
dd4331d
Merge pull request #375 from utopia-php/feat-authorization-v2-result
Meldiron Jan 3, 2024
59588d6
Make auth validator follow adapter
Meldiron Jan 24, 2024
e79ddd1
Upgrade dependencies
Meldiron Jan 24, 2024
8ce9213
Merge remote-tracking branch 'origin/main' into feat-framework-v2
Meldiron Jan 24, 2024
f55b13d
Fix tests
Meldiron Jan 24, 2024
26704cb
PR review changes
Meldiron Jan 25, 2024
95b4d71
Merge remote-tracking branch 'origin/feat-framework-v2' into feat-aut…
Meldiron Jan 25, 2024
efd5d1e
Update lockfile
Meldiron Jan 25, 2024
f0dc793
CI/CD fixes
Meldiron Jan 25, 2024
597a9ab
Fix all tests 🎉
Meldiron Jan 25, 2024
6f8b4a7
Remove validation exception
Meldiron Jan 25, 2024
b64caf4
Merge pull request #343 from utopia-php/feat-authorization-v2
abnegate Jan 25, 2024
fa6afda
Merge remote-tracking branch 'origin/main' into feat-framework-v2
Meldiron Feb 22, 2024
6dd6562
Post-merge fixes
Meldiron Feb 22, 2024
3465bc5
Add method for coroutine-style to wipe previous transformations state
Meldiron Feb 27, 2024
79fd579
Improve clear transformation
Meldiron Feb 27, 2024
c4727ee
Merge remote-tracking branch 'origin/main' into feat-framework-v2
Meldiron Mar 7, 2024
73fb443
Resolve framework V2 issues
Meldiron Mar 7, 2024
bdd9140
Add new method
Meldiron Mar 7, 2024
b0010c4
composer.lock
fogelito Apr 17, 2024
b3f7843
Merge branch 'main' of github.com:utopia-php/database into feat-frame…
fogelito Apr 17, 2024
0645d85
composer.lock
fogelito Apr 17, 2024
a0bd330
Merge branch 'main' of github.com:utopia-php/database into feat-frame…
fogelito Apr 18, 2024
6b8264a
updateRelationship
fogelito Apr 18, 2024
0d7b914
Remove Proxy files
fogelito Apr 19, 2024
2ed8b6b
Merge branch 'main' of github.com:utopia-php/database into feat-frame…
fogelito May 9, 2024
04abd91
pull main
fogelito May 9, 2024
f53d63b
lint
fogelito May 9, 2024
e29e62b
Merge branch 'refs/heads/main' into feat-framework-v2
byawitz Jun 6, 2024
5b0d6ba
chore: Updating composer.lock
byawitz Jun 6, 2024
0b45a0d
Merge branch 'refs/heads/main' into feat-framework-v2
byawitz Jul 19, 2024
964bfa2
chore: merge
byawitz Jul 19, 2024
ab01fa3
chore: codeql
byawitz Jul 19, 2024
9ddf91a
tests: Adjusting to new authorization
byawitz Jul 19, 2024
36720e8
chore: versions upgrade
byawitz Aug 9, 2024
a170c08
Merge branch 'main' into feat-framework-v2
byawitz Sep 4, 2024
a25e63e
chore: merge
byawitz Sep 4, 2024
8dfdf8d
chore: format
byawitz Sep 4, 2024
bfd1168
chore: Updating composer.lock
byawitz Sep 4, 2024
d70eb76
chore: format
byawitz Sep 4, 2024
e2bf86a
chore: Updating composer.lock
byawitz Sep 5, 2024
bb2a687
chore: updating packages
byawitz Sep 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ A list of the utopia/php concepts and their relevant equivalent using the differ
- **Document** - A simple JSON object that will be stored in one of the utopia/database collections. For SQL-based adapters, this will be equivalent to a row. For a No-SQL adapter, this will equivalent to a native document.
- **Attribute** - A simple document attribute. For SQL-based adapters, this will be equivalent to a column. For a No-SQL adapter, this will equivalent to a native document field.
- **Index** - A simple collection index used to improve the performance of your database queries.
- **Permissions** - Using permissions, you can decide which roles have read, create, update and delete access for a specific document. The special attribute `$permissions` is used to store permission metadata for each document in the collection. A permission role can be any string you want. You can use `Authorization::setRole()` to delegate new roles to your users, once obtained a new role a user would gain read, create, update or delete access to a relevant document.
- **Permissions** - Using permissions, you can decide which roles have read, create, update and delete access for a specific document. The special attribute `$permissions` is used to store permission metadata for each document in the collection. A permission role can be any string you want. You can use `$authorization->addRole()` to delegate new roles to your users, once obtained a new role a user would gain read, create, update or delete access to a relevant document.

### Filters

Expand Down
2 changes: 1 addition & 1 deletion bin/tasks/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
use Utopia\Database\Adapter\Mongo;
use Utopia\Database\Adapter\MySQL;
use Utopia\Database\Database;
use Utopia\Http\Validator\Text;
use Utopia\Mongo\Client;
use Utopia\Validator\Text;

/**
* @Example
Expand Down
19 changes: 10 additions & 9 deletions bin/tasks/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
use Utopia\Database\Validator\Authorization;
use Utopia\Http\Validator\Numeric;
use Utopia\Http\Validator\Text;
use Utopia\Mongo\Client;
use Utopia\Validator\Numeric;
use Utopia\Validator\Text;

$authorization = new Authorization();

/**
* @Example
Expand Down Expand Up @@ -61,7 +63,7 @@
$database->setNamespace($namespace);

// Outline collection schema
createSchema($database);
$createSchema($database);

// reclaim resources
$database = null;
Expand Down Expand Up @@ -121,7 +123,7 @@
$database->setNamespace($namespace);

// Outline collection schema
createSchema($database);
$createSchema($database);

// reclaim resources
$database = null;
Expand Down Expand Up @@ -183,7 +185,7 @@
$database->setNamespace($namespace);

// Outline collection schema
createSchema($database);
$createSchema($database);

// Fill DB
$faker = Factory::create();
Expand Down Expand Up @@ -226,14 +228,13 @@
});


function createSchema(Database $database): void
{
$createSchema = function (Database $database) use ($authorization): void {
if ($database->exists($database->getDatabase())) {
$database->delete($database->getDatabase());
}
$database->create();

Authorization::setRole(Role::any()->toString());
$authorization->addRole(Role::any()->toString());

$database->createCollection('articles', permissions: [
Permission::create(Role::any()),
Expand All @@ -247,7 +248,7 @@ function createSchema(Database $database): void
$database->createAttribute('articles', 'views', Database::VAR_INTEGER, 0, true);
$database->createAttribute('articles', 'tags', Database::VAR_STRING, 0, true, array: true);
$database->createIndex('articles', 'text', Database::INDEX_FULLTEXT, ['text']);
}
};

function createDocument($database, Generator $faker): void
{
Expand Down
24 changes: 11 additions & 13 deletions bin/tasks/query.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
use Utopia\Database\Adapter\MySQL;
use Utopia\Database\Database;
use Utopia\Database\Query;
use Utopia\Database\Validator\Authorization;
use Utopia\Http\Validator\Numeric;
use Utopia\Http\Validator\Text;
use Utopia\Mongo\Client;
use Utopia\Validator\Numeric;
use Utopia\Validator\Text;

/**
* @Example
Expand Down Expand Up @@ -84,35 +83,35 @@

$report = [];

$count = setRoles($faker, 1);
$count = $setRoles($faker, 1);
Console::info("\n{$count} roles:");
$report[] = [
'roles' => $count,
'results' => runQueries($database, $limit)
];

$count = setRoles($faker, 100);
$count = $setRoles($faker, 100);
Console::info("\n{$count} roles:");
$report[] = [
'roles' => $count,
'results' => runQueries($database, $limit)
];

$count = setRoles($faker, 400);
$count = $setRoles($faker, 400);
Console::info("\n{$count} roles:");
$report[] = [
'roles' => $count,
'results' => runQueries($database, $limit)
];

$count = setRoles($faker, 500);
$count = $setRoles($faker, 500);
Console::info("\n{$count} roles:");
$report[] = [
'roles' => $count,
'results' => runQueries($database, $limit)
];

$count = setRoles($faker, 1000);
$count = $setRoles($faker, 1000);
Console::info("\n{$count} roles:");
$report[] = [
'roles' => $count,
Expand All @@ -136,13 +135,12 @@
Console::error($error->getMessage());
});

function setRoles($faker, $count): int
{
$setRoles = function ($faker, $count) use ($authorization): int {
for ($i = 0; $i < $count; $i++) {
Authorization::setRole($faker->numerify('user####'));
$authorization->addRole($faker->numerify('user####'));
}
return \count(Authorization::getRoles());
}
return \count($authorization->getRoles());
};

function runQueries(Database $database, int $limit): array
{
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"ext-pdo": "*",
"ext-mbstring": "*",
"php": ">=8.0",
"utopia-php/framework": "0.33.*",
"utopia-php/framework": "1.0.*",
"utopia-php/cache": "0.10.*",
"utopia-php/mongo": "0.3.*"
},
Expand All @@ -45,7 +45,7 @@
"phpunit/phpunit": "9.6.*",
"pcov/clobber": "2.0.*",
"swoole/ide-helper": "5.1.3",
"utopia-php/cli": "0.14.*",
"utopia-php/cli": "0.19.*",
"laravel/pint": "1.17.*",
"phpstan/phpstan": "1.11.*",
"rregeer/phpunit-coverage-check": "0.3.*"
Expand Down
Loading
Loading