mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Merge pull request #13153 from appwrite/fix/documentsdb-vectorsdb-event-config
fix(events): allow documentsdb and vectorsdb event triggers for functions and webhooks
This commit is contained in:
4 files changed
+216
No files matched your search
@@ -311,6 +311,152 @@ return [
|
||||
'$description' => 'This event triggers when a database is deleted.',
|
||||
],
|
||||
],
|
||||
'documentsdb' => [
|
||||
'$model' => Response::MODEL_DATABASE,
|
||||
'$resource' => true,
|
||||
'$description' => 'This event triggers on any DocumentsDB database event.',
|
||||
'collections' => [
|
||||
'$model' => Response::MODEL_COLLECTION,
|
||||
'$resource' => true,
|
||||
'$description' => 'This event triggers on any collection event.',
|
||||
'documents' => [
|
||||
'$model' => Response::MODEL_DOCUMENT,
|
||||
'$resource' => true,
|
||||
'$description' => 'This event triggers on any documents event.',
|
||||
'create' => [
|
||||
'$description' => 'This event triggers when a document is created.',
|
||||
],
|
||||
'update' => [
|
||||
'$description' => 'This event triggers when a document is updated.'
|
||||
],
|
||||
'upsert' => [
|
||||
'$description' => 'This event triggers when a document is upserted.',
|
||||
],
|
||||
'delete' => [
|
||||
'$description' => 'This event triggers when a document is deleted.'
|
||||
],
|
||||
],
|
||||
'indexes' => [
|
||||
'$model' => Response::MODEL_INDEX,
|
||||
'$resource' => true,
|
||||
'$description' => 'This event triggers on any indexes event.',
|
||||
'create' => [
|
||||
'$description' => 'This event triggers when an index is created.',
|
||||
],
|
||||
'delete' => [
|
||||
'$description' => 'This event triggers when an index is deleted.'
|
||||
],
|
||||
'update' => [
|
||||
'$description' => 'This event triggers when an index is updated.',
|
||||
],
|
||||
],
|
||||
'attributes' => [
|
||||
'$model' => Response::MODEL_ATTRIBUTE,
|
||||
'$resource' => true,
|
||||
'$description' => 'This event triggers on any attributes event.',
|
||||
'create' => [
|
||||
'$description' => 'This event triggers when an attribute is created.',
|
||||
],
|
||||
'update' => [
|
||||
'$description' => 'This event triggers when an attribute is updated.',
|
||||
],
|
||||
'delete' => [
|
||||
'$description' => 'This event triggers when an attribute is deleted.'
|
||||
]
|
||||
],
|
||||
'create' => [
|
||||
'$description' => 'This event triggers when a collection is created.'
|
||||
],
|
||||
'update' => [
|
||||
'$description' => 'This event triggers when a collection is updated.',
|
||||
],
|
||||
'delete' => [
|
||||
'$description' => 'This event triggers when a collection is deleted.',
|
||||
],
|
||||
],
|
||||
'create' => [
|
||||
'$description' => 'This event triggers when a database is created.'
|
||||
],
|
||||
'update' => [
|
||||
'$description' => 'This event triggers when a database is updated.',
|
||||
],
|
||||
'delete' => [
|
||||
'$description' => 'This event triggers when a database is deleted.',
|
||||
],
|
||||
],
|
||||
'vectorsdb' => [
|
||||
'$model' => Response::MODEL_DATABASE,
|
||||
'$resource' => true,
|
||||
'$description' => 'This event triggers on any VectorsDB database event.',
|
||||
'collections' => [
|
||||
'$model' => Response::MODEL_COLLECTION,
|
||||
'$resource' => true,
|
||||
'$description' => 'This event triggers on any collection event.',
|
||||
'documents' => [
|
||||
'$model' => Response::MODEL_DOCUMENT,
|
||||
'$resource' => true,
|
||||
'$description' => 'This event triggers on any documents event.',
|
||||
'create' => [
|
||||
'$description' => 'This event triggers when a document is created.',
|
||||
],
|
||||
'update' => [
|
||||
'$description' => 'This event triggers when a document is updated.'
|
||||
],
|
||||
'upsert' => [
|
||||
'$description' => 'This event triggers when a document is upserted.',
|
||||
],
|
||||
'delete' => [
|
||||
'$description' => 'This event triggers when a document is deleted.'
|
||||
],
|
||||
],
|
||||
'indexes' => [
|
||||
'$model' => Response::MODEL_INDEX,
|
||||
'$resource' => true,
|
||||
'$description' => 'This event triggers on any indexes event.',
|
||||
'create' => [
|
||||
'$description' => 'This event triggers when an index is created.',
|
||||
],
|
||||
'delete' => [
|
||||
'$description' => 'This event triggers when an index is deleted.'
|
||||
],
|
||||
'update' => [
|
||||
'$description' => 'This event triggers when an index is updated.',
|
||||
],
|
||||
],
|
||||
'attributes' => [
|
||||
'$model' => Response::MODEL_ATTRIBUTE,
|
||||
'$resource' => true,
|
||||
'$description' => 'This event triggers on any attributes event.',
|
||||
'create' => [
|
||||
'$description' => 'This event triggers when an attribute is created.',
|
||||
],
|
||||
'update' => [
|
||||
'$description' => 'This event triggers when an attribute is updated.',
|
||||
],
|
||||
'delete' => [
|
||||
'$description' => 'This event triggers when an attribute is deleted.'
|
||||
]
|
||||
],
|
||||
'create' => [
|
||||
'$description' => 'This event triggers when a collection is created.'
|
||||
],
|
||||
'update' => [
|
||||
'$description' => 'This event triggers when a collection is updated.',
|
||||
],
|
||||
'delete' => [
|
||||
'$description' => 'This event triggers when a collection is deleted.',
|
||||
],
|
||||
],
|
||||
'create' => [
|
||||
'$description' => 'This event triggers when a database is created.'
|
||||
],
|
||||
'update' => [
|
||||
'$description' => 'This event triggers when a database is updated.',
|
||||
],
|
||||
'delete' => [
|
||||
'$description' => 'This event triggers when a database is deleted.',
|
||||
],
|
||||
],
|
||||
'buckets' => [
|
||||
'$model' => Response::MODEL_BUCKET,
|
||||
'$resource' => true,
|
||||
|
||||
@@ -216,5 +216,15 @@ final class EventTest extends TestCase
|
||||
$this->assertContains('documentsdb.factory-db.collections.assembly.documents.doc-123.update', $documentsDbEvents);
|
||||
$this->assertNotContains('documentsdb.factory-db.tables.assembly.rows.doc-123.update', $documentsDbEvents);
|
||||
$this->assertNotContains('databases.factory-db.collections.assembly.documents.doc-123.update', $documentsDbEvents);
|
||||
|
||||
$vectorsDb = new Document(['type' => 'vectorsdb']);
|
||||
$vectorsDbEvents = Event::generateEvents('databases.[databaseId].collections.[collectionId].documents.[documentId].update', [
|
||||
'databaseId' => 'factory-db',
|
||||
'collectionId' => 'assembly',
|
||||
'documentId' => 'doc-123',
|
||||
], $vectorsDb);
|
||||
$this->assertContains('vectorsdb.factory-db.collections.assembly.documents.doc-123.update', $vectorsDbEvents);
|
||||
$this->assertNotContains('vectorsdb.factory-db.tables.assembly.rows.doc-123.update', $vectorsDbEvents);
|
||||
$this->assertNotContains('databases.factory-db.collections.assembly.documents.doc-123.update', $vectorsDbEvents);
|
||||
}
|
||||
}
|
||||
@@ -79,6 +79,50 @@ final class EventValidatorTest extends TestCase
|
||||
$this->assertTrue($this->object->isValid('tablesdb.books.tables.chapters'));
|
||||
$this->assertTrue($this->object->isValid('tablesdb.books.tables.*'));
|
||||
$this->assertTrue($this->object->isValid('tablesdb.books.tables.chapters.columns.name.create'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.books.collections.chapters.documents.prolog.create'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.books.collections.chapters.documents.prolog'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.books.collections.chapters.documents.*.create'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.books.collections.chapters.documents.*'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.books.collections.*.documents.prolog.create'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.books.collections.*.documents.prolog'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.books.collections.*.documents.*.create'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.books.collections.*.documents.*'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.*.collections.chapters.documents.prolog.create'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.*.collections.chapters.documents.prolog'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.*.collections.chapters.documents.*.create'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.*.collections.chapters.documents.*'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.*.collections.*.documents.prolog.create'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.*.collections.*.documents.prolog'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.*.collections.*.documents.*.create'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.*.collections.*.documents.*'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.*.collections.*'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.*'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.books'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.books.collections.chapters'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.books.collections.*'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.books.collections.chapters.attributes.name.create'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.books.collections.chapters.documents.prolog.create'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.books.collections.chapters.documents.prolog'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.books.collections.chapters.documents.*.create'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.books.collections.chapters.documents.*'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.books.collections.*.documents.prolog.create'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.books.collections.*.documents.prolog'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.books.collections.*.documents.*.create'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.books.collections.*.documents.*'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.*.collections.chapters.documents.prolog.create'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.*.collections.chapters.documents.prolog'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.*.collections.chapters.documents.*.create'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.*.collections.chapters.documents.*'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.*.collections.*.documents.prolog.create'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.*.collections.*.documents.prolog'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.*.collections.*.documents.*.create'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.*.collections.*.documents.*'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.*.collections.*'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.*'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.books'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.books.collections.chapters'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.books.collections.*'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.books.collections.chapters.attributes.name.create'));
|
||||
$this->assertTrue($this->object->isValid('functions.*'));
|
||||
$this->assertTrue($this->object->isValid('buckets.*'));
|
||||
$this->assertTrue($this->object->isValid('teams.*'));
|
||||
@@ -97,6 +141,10 @@ final class EventValidatorTest extends TestCase
|
||||
$this->assertFalse($this->object->isValid('tables.*.rows.*.unknown'));
|
||||
$this->assertFalse($this->object->isValid('tablesdb.books.collections.chapters.documents.prolog.create'));
|
||||
$this->assertFalse($this->object->isValid('tablesdb.books.tables.chapters.rows.prolog.unknown'));
|
||||
$this->assertFalse($this->object->isValid('documentsdb.books.tables.chapters.rows.prolog.create'));
|
||||
$this->assertFalse($this->object->isValid('documentsdb.books.collections.chapters.documents.prolog.unknown'));
|
||||
$this->assertFalse($this->object->isValid('vectorsdb.books.tables.chapters.rows.prolog.create'));
|
||||
$this->assertFalse($this->object->isValid('vectorsdb.books.collections.chapters.documents.prolog.unknown'));
|
||||
$this->assertFalse($this->object->isValid('users.torsten.unknown'));
|
||||
$this->assertFalse($this->object->isValid('users.torsten.delete.email'));
|
||||
$this->assertFalse($this->object->isValid('teams.*.memberships.*.update.unknown'));
|
||||
|
||||
@@ -62,6 +62,16 @@ final class FunctionEventValidatorTest extends TestCase
|
||||
$this->assertTrue($this->object->isValid('tablesdb.*.tables.*.rows.*.create'));
|
||||
$this->assertTrue($this->object->isValid('tablesdb.*.tables.*'));
|
||||
$this->assertTrue($this->object->isValid('tablesdb.*'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.books.collections.chapters.documents.prolog.create'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.books.collections.chapters.documents.*.create'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.*.collections.*.documents.*.create'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.*.collections.*'));
|
||||
$this->assertTrue($this->object->isValid('documentsdb.*'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.books.collections.chapters.documents.prolog.create'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.books.collections.chapters.documents.*.create'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.*.collections.*.documents.*.create'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.*.collections.*'));
|
||||
$this->assertTrue($this->object->isValid('vectorsdb.*'));
|
||||
$this->assertTrue($this->object->isValid('buckets.*'));
|
||||
$this->assertTrue($this->object->isValid('teams.*'));
|
||||
$this->assertTrue($this->object->isValid('users.*'));
|
||||
@@ -78,6 +88,8 @@ final class FunctionEventValidatorTest extends TestCase
|
||||
$this->assertFalse($this->object->isValid('tables.*.unknown'));
|
||||
$this->assertFalse($this->object->isValid('tables.*.rows.*.unknown'));
|
||||
$this->assertFalse($this->object->isValid('tablesdb.books.collections.chapters.documents.prolog.create'));
|
||||
$this->assertFalse($this->object->isValid('documentsdb.books.tables.chapters.rows.prolog.create'));
|
||||
$this->assertFalse($this->object->isValid('vectorsdb.books.tables.chapters.rows.prolog.create'));
|
||||
$this->assertFalse($this->object->isValid('users.torsten.unknown'));
|
||||
$this->assertFalse($this->object->isValid('users.torsten.delete.email'));
|
||||
$this->assertFalse($this->object->isValid('teams.*.memberships.*.update.unknown'));
|
||||
|
||||
Reference in new issue
Block a user